diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2025-09-20 19:19:34 +0200 | 
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2025-09-20 19:19:34 +0200 | 
| commit | e7d20cf352688bf717a01f4e6d9e6f497c2bea4c (patch) | |
| tree | cfd2ef9b569f49af985a6f1ec44f2614f63c8e78 /app/wlib/gtklib | |
| parent | a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (diff) | |
New upstream version 5.3.1Beta2upstream/5.3.1Beta2
Diffstat (limited to 'app/wlib/gtklib')
| -rw-r--r-- | app/wlib/gtklib/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | app/wlib/gtklib/bitmap.c | 13 | ||||
| -rw-r--r-- | app/wlib/gtklib/browserhelp.c | 2 | ||||
| -rw-r--r-- | app/wlib/gtklib/button.c | 7 | ||||
| -rw-r--r-- | app/wlib/gtklib/gtkint.h | 3 | ||||
| -rw-r--r-- | app/wlib/gtklib/pixbuf.c | 11 | ||||
| -rw-r--r-- | app/wlib/gtklib/print.c | 8 | ||||
| -rw-r--r-- | app/wlib/gtklib/tooltip.c | 6 | ||||
| -rw-r--r-- | app/wlib/gtklib/util.c | 85 | ||||
| -rw-r--r-- | app/wlib/gtklib/window.c | 10 | ||||
| -rw-r--r-- | app/wlib/gtklib/wpref.c | 15 | 
11 files changed, 102 insertions, 64 deletions
diff --git a/app/wlib/gtklib/CMakeLists.txt b/app/wlib/gtklib/CMakeLists.txt index 6c673d9..ab0d790 100644 --- a/app/wlib/gtklib/CMakeLists.txt +++ b/app/wlib/gtklib/CMakeLists.txt @@ -3,6 +3,7 @@  target_include_directories(xtrkcad-wlib   	PRIVATE   	${xtrkcad-lib_SOURCE_DIR} +	${xtrkcad-lib_BINARY_DIR}  )  target_sources(xtrkcad-wlib @@ -78,6 +79,11 @@ find_package (GTK2)  # configure for GTK's native Unix print  find_package (GTKUnixPrint) +# Needed for xtc.image1 include +add_dependencies(xtrkcad-wlib +	genbitmaps +) +  target_include_directories(xtrkcad-wlib  	PRIVATE  	${GTK_INCLUDE_DIRS} diff --git a/app/wlib/gtklib/bitmap.c b/app/wlib/gtklib/bitmap.c index b1ff2ed..7136461 100644 --- a/app/wlib/gtklib/bitmap.c +++ b/app/wlib/gtklib/bitmap.c @@ -67,8 +67,11 @@ wBitmapCreate( wWin_p parent, wWinPix_t x, wWinPix_t y, long options,  		gtk_widget_realize( parent->widget );        /* force allocation, if pending */  	} -	/* create the bitmap from supplied xpm data */ -	pixbuf = gdk_pixbuf_new_from_xpm_data( (const char **)iconP->bits ); +	/* create the bitmap from supplied data */ +	assert ( *(int*)iconP->bits == 0x47646b50 || +	     *(int*)iconP->bits == 0x506b6447 ); +	pixbuf = gdk_pixbuf_new_from_inline( -1, iconP->bits, FALSE, NULL ); +	  	g_object_ref_sink(pixbuf);  	image = gtk_image_new_from_pixbuf( pixbuf );  	gtk_widget_show( image ); @@ -106,7 +109,7 @@ wIcon_p wIconCreateBitMap( wWinPix_t w, wWinPix_t h, const char * bits,  	ip->color = color;  	// Copy bits  	int nBytes = ( ( w + 7 ) / 8 ) * h; -	ip->bits = (char*)malloc( nBytes ); +	ip->bits = (wIconBitMap_t)malloc( nBytes );  	memcpy( (void*)ip->bits, bits, nBytes );  	return ip;  } @@ -117,7 +120,7 @@ wIcon_p wIconCreateBitMap( wWinPix_t w, wWinPix_t h, const char * bits,   * \returns icon handle   */ -wIcon_p wIconCreatePixMap( char *pm[] ) +wIcon_p wIconCreatePixMap( wIconBitMap_t pm )  {  	wIcon_p ip;  	ip = (wIcon_p)malloc( sizeof *ip ); @@ -125,7 +128,7 @@ wIcon_p wIconCreatePixMap( char *pm[] )  	ip->w = 0;  	ip->h = 0;  	ip->color = 0; -	ip->bits = pm; +	ip->bits = (wIconBitMap_t) pm;  	return ip;  } diff --git a/app/wlib/gtklib/browserhelp.c b/app/wlib/gtklib/browserhelp.c index 6d2ac5d..9b32d79 100644 --- a/app/wlib/gtklib/browserhelp.c +++ b/app/wlib/gtklib/browserhelp.c @@ -91,7 +91,7 @@ TopicToUrl(char **helpUrl, const char *topic)  void wHelp(const char * topic)  {  	int rc; -	char *url; +	char *url = NULL;  //    char *currentPath;  	assert(topic != NULL); diff --git a/app/wlib/gtklib/button.c b/app/wlib/gtklib/button.c index 7193b11..c337f46 100644 --- a/app/wlib/gtklib/button.c +++ b/app/wlib/gtklib/button.c @@ -33,6 +33,7 @@  #include "gtkint.h"  #include "i18n.h" +#include "assert.h"  #define MIN_BUTTON_WIDTH (80) @@ -97,7 +98,11 @@ void wlibSetLabel(  			bm = (wIcon_p)labelStr;  			if (bm->gtkIconType == gtkIcon_pixmap) { -				pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)bm->bits); +				// check gdk_pixbuf header  +				assert ( *(int*)bm->bits == 0x47646b50 || +				     *(int*)bm->bits == 0x506b6447 ); +				pixbuf = gdk_pixbuf_new_from_inline( -1, bm->bits, FALSE, NULL );
 +				  			} else {  				pixbuf = wlibPixbufFromXBM( bm );  			} diff --git a/app/wlib/gtklib/gtkint.h b/app/wlib/gtklib/gtkint.h index e3757a4..b1f44e4 100644 --- a/app/wlib/gtklib/gtkint.h +++ b/app/wlib/gtklib/gtkint.h @@ -27,6 +27,7 @@  #include "gdk/gdk.h"  #include "gtk/gtk.h" +#include <assert.h>  #ifdef WINDOWS  #define strcasecmp _stricmp @@ -137,7 +138,7 @@ struct wIcon_t {  	wWinPix_t w;  	wWinPix_t h;  	wDrawColor color; -	const void * bits; +	wIconBitMap_t bits;  };  extern char wConfigName[]; diff --git a/app/wlib/gtklib/pixbuf.c b/app/wlib/gtklib/pixbuf.c index 0d6e8b7..d0c1068 100644 --- a/app/wlib/gtklib/pixbuf.c +++ b/app/wlib/gtklib/pixbuf.c @@ -48,14 +48,20 @@ GdkPixbuf* wlibMakePixbuf(          wIcon_p ip)  {  	GdkPixbuf * pixbuf; +#ifdef LATER  	char line0[40];  	char line2[40]; +#endif  	assert(ip != NULL); -	if (ip->gtkIconType == gtkIcon_pixmap) { -		pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)ip->bits); +	assert( ip->gtkIconType == gtkIcon_pixmap ); +	assert ( *(int*)ip->bits == 0x47646b50 || +	     *(int*)ip->bits == 0x506b6447 ); +	pixbuf = gdk_pixbuf_new_from_inline( -1, ip->bits, FALSE, NULL ); +#ifdef LATER		  	} else { +		assert( ip->gtkIconType != gtkIcon_pixmap );  		const char * bits;  		long rgb;  		int row,col,wb; @@ -92,6 +98,7 @@ GdkPixbuf* wlibMakePixbuf(  			g_free(pixmapData[row+3]);  		}  	} +#endif  	return pixbuf;  } diff --git a/app/wlib/gtklib/print.c b/app/wlib/gtklib/print.c index 609efa9..2c7c278 100644 --- a/app/wlib/gtklib/print.c +++ b/app/wlib/gtklib/print.c @@ -755,7 +755,7 @@ void psPrintString(  	/** \todo use a getter function instead of double conversion */  	desc = pango_font_description_from_string(wlibFontTranslate(fp)); -	pango_font_description_set_size(desc, fs * PANGO_SCALE * scale_text); +	pango_font_description_set_absolute_size(desc, fs * PANGO_SCALE * scale_text);  	// render the string to a Pango layout  	pango_layout_set_font_description(layout, desc); @@ -1063,14 +1063,14 @@ wBool_t wPrintDocStart(const char * title, int fTotalPageCount, int * copiesP)  			psPrint_d.dpi = p_def;  			scale_adjust = 72/p_def;  		} else { -			if (printTextScale > 0.0) { -				scale_text = printTextScale; -			}  			if (printScale > 0.0) {  				scale_adjust = printScale;  			}  			psPrint_d.dpi = 72;  		} +		if (printTextScale > 0.0) { +			scale_text = printTextScale; +		}  		// in XTrackCAD 0,0 is top left, in cairo bottom left. This is  		// corrected via the following transformations. diff --git a/app/wlib/gtklib/tooltip.c b/app/wlib/gtklib/tooltip.c index 75c8870..7c1eef9 100644 --- a/app/wlib/gtklib/tooltip.c +++ b/app/wlib/gtklib/tooltip.c @@ -159,9 +159,9 @@ void wControlSetBalloon( wControl_p b, wWinPix_t dx, wWinPix_t dy,  		//GtkWidget *alignment;
  		GdkColor color;
 -		color.red = 0x00C5 * 65536/255;
 -		color.green = 0x006F * 65536/255;
 -		color.blue = 0x0078 * 65536/255;
 +		color.red = 0x00FE * 65536/255;
 +		color.green = 0x007F * 65536/255;
 +		color.blue = 0x007F * 65536/255;
  		balloonF = gtk_window_new( GTK_WINDOW_POPUP );
  		gtk_window_set_type_hint( GTK_WINDOW( balloonF), GDK_WINDOW_TYPE_HINT_TOOLTIP );
 diff --git a/app/wlib/gtklib/util.c b/app/wlib/gtklib/util.c index 3f746e6..b8777fd 100644 --- a/app/wlib/gtklib/util.c +++ b/app/wlib/gtklib/util.c @@ -76,7 +76,7 @@ static wBool_t reverseIcon =  #endif  #endif - +static bool audioOn;  /*   ***************************************************************************** @@ -97,45 +97,38 @@ GdkPixbuf* wlibPixbufFromXBM(          wIcon_p ip)  {  	GdkPixbuf * pixbuf; - -	char line0[40]; -	char line2[40]; - -	char ** pixmapData; -	int row, col, wb; -	long rgb; -	const char * bits; - -	wb = (ip->w + 7) / 8; -	pixmapData = (char**) malloc((3 + ip->h) * sizeof *pixmapData); -	pixmapData[0] = line0; -	rgb = wDrawGetRGB(ip->color); -	sprintf(line0, " %ld %ld 2 1", ip->w, ip->h); -	sprintf(line2, "# c #%2.2lx%2.2lx%2.2lx", (rgb >> 16)&0xFF, (rgb >> 8)&0xFF, -	        rgb & 0xFF); -	pixmapData[1] = ". c None s None"; -	pixmapData[2] = line2; -	bits = ip->bits; - -	for (row = 0; row < ip->h; row++) { -		pixmapData[row + 3] = (char*) malloc((ip->w + 1) * sizeof **pixmapData); - -		for (col = 0; col < ip->w; col++) { -			if (bits[ row * wb + (col >> 3) ] & (1 << (col & 07))) { -				pixmapData[row + 3][col] = '#'; -			} else { -				pixmapData[row + 3][col] = '.'; +	wIconBitMap_t bits = ip->bits; +	static unsigned char background[4] = { 0xFF, 0xFF, 0xFF, 0x0 }; +	long rgb = wDrawGetRGB(ip->color); +	unsigned char foreground[4]; +	foreground[0] = ( rgb >> 16 ) & 0xFF; +	foreground[1] = ( rgb >> 8 ) &0xFF; +	foreground[2] = rgb & 0xFF; +	foreground[3] = 0xFF; +	int wb = (ip->w + 7) / 8; +	size_t siz = ip->h * (wb * 8) * 4 * sizeof ( unsigned char ); +	unsigned char * pData = (unsigned char*)malloc( siz ); +	unsigned char * pCurr = pData; +	int iStride = cairo_format_stride_for_width( CAIRO_FORMAT_RGB24, ip->w ); + +	for ( int y = 0; y < ip->h; y++ ) { +		for ( int x = 0; x < ip->w; x++ ) { +			int iIndex = y * wb + ( x >> 3 ); +			int iOffset = x & 0x7; +			unsigned char iValue = bits[ iIndex ]; +			int iMask = 1<<iOffset; +			wBool_t bOn = (iValue & iMask) ? TRUE : FALSE ;  +			for ( int p = 0; p < 4; p++ ) { +				*pCurr++ = ( bOn ? foreground[p] : background[p] );  			} +//			printf( bOn?"*":" " );  		} -		pixmapData[row + 3][ip->w] = 0; +//		printf( "\n" );  	} +//	printf("\n"); -	pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) pixmapData); - -	for (row = 0; row < ip->h; row++) { -		free(pixmapData[row + 3]); -	} -	free(pixmapData); +	pixbuf = gdk_pixbuf_new_from_data( pData, GDK_COLORSPACE_RGB, TRUE, 8, +			ip->w, ip->h, iStride, NULL, NULL );  	return pixbuf;  } @@ -355,13 +348,27 @@ wControl_p wlibGetControlFromPos(   *****************************************************************************   */ +  /** - * Beep! - * \return + * Change audio setting. + *  + * \param setting   true: beep is on + */ +void +wSetAudio(bool setting) +{ +    audioOn = (setting > 0); +} + +/** + * Sound speaker if audio is enabled. + *    */  void wBeep(void)  { -	gdk_display_beep(gdk_display_get_default()); +	if(audioOn) { +		gdk_display_beep(gdk_display_get_default()); +	}  }  /** diff --git a/app/wlib/gtklib/window.c b/app/wlib/gtklib/window.c index b8a3cdf..f5050ea 100644 --- a/app/wlib/gtklib/window.c +++ b/app/wlib/gtklib/window.c @@ -53,7 +53,7 @@ static int keyState;  static wBool_t gtkBlockEnabled = TRUE;  static wBool_t maximize_at_next_show = FALSE; -#include "../../bin/bitmaps/xtc.xpm" +#include "bitmaps/xtc.image1"  static GdkPixbuf *windowIconPixbuf = NULL;  /* @@ -305,7 +305,7 @@ void wWinSetSize(  void wWinShow(          wWin_p win,		/* Window */ -        wBool_t show)		/* Command */ +        unsigned show)		/* Command */  {  	//GtkRequisition min_req, pref_req; @@ -318,7 +318,8 @@ void wWinShow(  	}  	int width, height; - +	show &= ~(DONTGRABFOCUS);	// flag is ignored on Linux +	  	if (show) {  		keyState = 0;  		getPos(win); @@ -360,6 +361,7 @@ void wWinShow(  		gtk_window_present(GTK_WINDOW(win->gtkwin)); +  		gdk_window_raise(gtk_widget_get_window(win->gtkwin));  		if (win->shown && win->modalLevel > 0) { @@ -1049,7 +1051,7 @@ static wWin_p wWinCommonCreate(  	}  	if ( windowIconPixbuf == NULL ) { -		windowIconPixbuf = gdk_pixbuf_new_from_xpm_data((const char**)&xtc_xpm); +		windowIconPixbuf = gdk_pixbuf_new_from_inline(-1, (unsigned char *)xtc_image1, FALSE, NULL);  	}  	gtk_window_set_icon( GTK_WINDOW(w->gtkwin), windowIconPixbuf ); diff --git a/app/wlib/gtklib/wpref.c b/app/wlib/gtklib/wpref.c index 356dd95..d83f3e9 100644 --- a/app/wlib/gtklib/wpref.c +++ b/app/wlib/gtklib/wpref.c @@ -107,6 +107,11 @@ const char * wGetAppLibDir( void )  		return appLibDir;  	} +	strcpy(appLibDir, XTRKCAD_INSTALL_PREFIX "/" XTRKCAD_SHARE_INSTALL_DIR); +	if ((stat( appLibDir, &buf) == 0 ) && S_ISDIR(buf.st_mode)) { +		return appLibDir; +	} +  	char * dir1 = "/usr/share/";  	char * dir2 = "/usr/local/share/";  	char * beta = ""; @@ -265,13 +270,15 @@ wlibSetProfileFilename(char *name)  	if (name && name[0]) {  		size_t length;  		length = snprintf(profileFile, 0, "%s", name); -		profileFile = malloc(length + sizeof(NULL)); +		length += sizeof(""); +		profileFile = malloc(length);  		snprintf( profileFile, length, "%s", name );  	} else {  		size_t length;   		length = snprintf(profileFile, 0, "%s/%s.rc", workDir, wConfigName ); -		profileFile = malloc(length + sizeof(NULL)); -		length = snprintf(profileFile, length+sizeof(NULL), "%s/%s.rc", workDir, wConfigName ); +		length += sizeof(""); +		profileFile = malloc(length); +		length = snprintf(profileFile, length, "%s/%s.rc", workDir, wConfigName );  	}  } @@ -631,4 +638,4 @@ wPrefFormatLine(const char* section, const char* name, const char* value, char*  		value = "";  	}  	sprintf(result, "%s.%s: %s", section, name, value); -}
\ No newline at end of file +}  | 
