| author | Jens Thoms Toerring <jt@toerring.de> | 2016年02月24日 13:30:12 +0100 |
|---|---|---|
| committer | Jens Thoms Toerring <jt@toerring.de> | 2016年02月24日 13:30:12 +0100 |
| commit | 128ee8ddc96de0136875e2b6034bcc5ea761bcce (patch) | |
| tree | 65b0fce6168e54e39bebd4c7c7cf9cef4924325d | |
| parent | a0b5efb777a740d2e914343479528ebb287ec314 (diff) | |
| download | xforms-128ee8ddc96de0136875e2b6034bcc5ea761bcce.tar.gz | |
| -rw-r--r-- | INSTALL.git | 10 | ||||
| -rw-r--r-- | doc/part5_overview.texi | 11 | ||||
| -rw-r--r-- | fdesign/fd_attribs.c | 6 | ||||
| -rw-r--r-- | fdesign/fd_main.c | 2 | ||||
| -rw-r--r-- | fdesign/fd_objects.c | 2 | ||||
| -rw-r--r-- | fdesign/sp_menu.c | 6 | ||||
| -rw-r--r-- | lib/flinternal.h | 3 | ||||
| -rw-r--r-- | lib/include/bitmap.h | 3 | ||||
| -rw-r--r-- | lib/pixmap.c | 290 |
diff --git a/INSTALL.git b/INSTALL.git index a9a03f1..7a53a55 100644 --- a/INSTALL.git +++ b/INSTALL.git @@ -28,11 +28,11 @@ install XForms successfully is present on your machine and then creates Makefiles etc. But this 'configure' script itself also gets created automatically using the 'autoconf' and 'automake' tools and thus is not included in the git -repository. Furthermore, you need the 'libtool'. +repository. Furthermore, you need the 'libtool' package. Most Linux distributions have packages with these names, so you probably can install them without much effort. -If you can't then you will have to download them from +If you can't you will have to download them from http://www.gnu.org/software/autoconf/ http://www.gnu.org/software/automake/ @@ -45,6 +45,6 @@ Once these tools are installed all you've got to do is to run the script 'autogen.sh' in the main directory of XForms. If it succeeds you then can continue like in a "normal" in- stall (i.e. first run the './confgure' script just created -while running the 'autogen.sh' scrupt, followed by 'make' -and finally 'make install' - also see the INSTALL file for -more detailed instructions). +by running the 'autogen.sh' scrupt, followed by 'make' and +finally 'make install' - also see the INSTALL file for more +detailed instructions). diff --git a/doc/part5_overview.texi b/doc/part5_overview.texi index 1e1abd3..3cf4a08 100644 --- a/doc/part5_overview.texi +++ b/doc/part5_overview.texi @@ -1738,17 +1738,22 @@ visible, not all window managers honor such requests once the window is visible. Also note that the constraints only apply to the next call of @code{@ref{fl_show_form()}} for the form. -To set or change the icon shown when a form is iconified use the -following routine +To set or change the icon shown when a form is iconified use one of the +following routines @findex fl_set_form_icon() @anchor{fl_set_form_icon()} +@findex fl_set_form_icon_data() +@anchor{fl_set_form_icon_data()} @example void fl_set_form_icon(FL_FORM *form, Pixmap icon, Pixmap mask); +void fl_set_form_icon_data(FL_FORM *form, char **data); @end example @noindent where @code{icon} can be any valid pixmap ID. (@pxref{Pixmap Object} for some of the routines that can be used to create pixmaps.) Note -that a previously set icon if not freed or modified in anyway. +that a previously set icon is not freed or modified in anyway. The +second functions can be used to instead used if you have valid pixmap +data as an array of strings (e.g., by having included an 'xpm' file). If, for any reason, you would like to change the form title after the form has been made visible, the following calls can be used (they will diff --git a/fdesign/fd_attribs.c b/fdesign/fd_attribs.c index e7d6b83..b4420d1 100644 --- a/fdesign/fd_attribs.c +++ b/fdesign/fd_attribs.c @@ -609,6 +609,12 @@ readback_attributes( FL_OBJECT * obj ) set_object_name( obj, name, cbname, fl_get_input( fd_generic_attrib->argobj ) ); + /* in fdesign, FL_BOX has no choice() for type but a boxtype: + copy boxtype to type to generate the correct source code files */ + + if ( obj->objclass == FL_BOX ) + obj->type = obj->boxtype; + fl_free( cbname ); fl_free( name ); diff --git a/fdesign/fd_main.c b/fdesign/fd_main.c index 41067b6..23d5a62 100644 --- a/fdesign/fd_main.c +++ b/fdesign/fd_main.c @@ -976,7 +976,7 @@ main( int argc, fl_set_form_position( fd_control->control, x, y ); fl_set_app_mainform( fd_control->control ); - fli_set_form_icon_data( fd_control->control, fd_logo_pixels ); + fl_set_form_icon_data( fd_control->control, fd_logo_pixels ); fl_show_form( fd_control->control, FL_PLACE_GEOMETRY, ( 1 || fd_cntlborder ) ? FL_FULLBORDER : FL_TRANSIENT, "Control" ); diff --git a/fdesign/fd_objects.c b/fdesign/fd_objects.c index 3aa106f..5c9217d 100644 --- a/fdesign/fd_objects.c +++ b/fdesign/fd_objects.c @@ -620,7 +620,7 @@ init_classes( void ) bl++; fl_add_browser_line( fd_control->objectbrowser, "freeobject" ); - add_class_def( VN( FL_FREE ), "freeobject", fd_create_free, fd_add_free, + add_class_def( VN( FL_FREE ), "free", fd_create_free, fd_add_free, ++bl ); add_type_def( FL_FREE, FL_NORMAL_FREE, "NORMAL_FREE" ); add_type_def( FL_FREE, FL_INACTIVE_FREE, "INACTIVE_FREE" ); diff --git a/fdesign/sp_menu.c b/fdesign/sp_menu.c index 6e3d4b3..91ddaf8 100644 --- a/fdesign/sp_menu.c +++ b/fdesign/sp_menu.c @@ -65,7 +65,7 @@ menu_create_spec_form( void ) fl_set_choice_item_shortcut( menu_attrib->mode, 1, "Cc#C" ); fl_set_choice_item_shortcut( menu_attrib->mode, 1, "Rr#R" ); fl_set_browser_dblclick_callback( menu_attrib->content_br, - change_menu_item_cb, 0 ); + change_menu_item_cb, 0 ); return menu_attrib->menuattrib; } @@ -436,7 +436,7 @@ replace_menu_item_cb( FL_OBJECT * obj FL_UNUSED_ARG, fl_replace_menu_item( curobj, k, s ); - fl_set_menu_item_shortcut( menu_attrib->vdata, k, sc ); + fl_set_menu_item_shortcut( curobj, k, sc ); fl_set_menu_item_mode( curobj, k, get_pupmode_value( mode ) ); @@ -493,6 +493,8 @@ change_menu_item_cb( FL_OBJECT * obj FL_UNUSED_ARG, if ( sp->shortcut[ i ] ) fl_set_input( menu_attrib->shortcut, sp->shortcut[ i ] ); + else + fl_set_input( menu_attrib->shortcut, "" ); fl_set_choice_text( menu_attrib->mode, get_pupmode_name( sp->mode[ i ] ) + 3 ); diff --git a/lib/flinternal.h b/lib/flinternal.h index 4df5ca1..818b782 100644 --- a/lib/flinternal.h +++ b/lib/flinternal.h @@ -894,9 +894,6 @@ char * fli_sstrcpy( char * dest, const char * src, size_t n ); -void fli_set_form_icon_data( FL_FORM *, - char ** ); - char *fli_getcwd( char *, int ); diff --git a/lib/include/bitmap.h b/lib/include/bitmap.h index 66ed496..2993996 100644 --- a/lib/include/bitmap.h +++ b/lib/include/bitmap.h @@ -141,5 +141,8 @@ FL_EXPORT Pixmap fl_create_from_pixmapdata( Window win, FL_EXPORT void fl_free_pixmap( Pixmap id ); +FL_EXPORT void fl_set_form_icon_data( FL_FORM * form, + char ** data ); + #endif /* ! defined FL_BITMAP_H */ diff --git a/lib/pixmap.c b/lib/pixmap.c index 5a0fe6a..cdd6f29 100644 --- a/lib/pixmap.c +++ b/lib/pixmap.c @@ -61,7 +61,71 @@ typedef struct { focus_h; } PixmapSPEC; -static XpmAttributes *xpmattrib; + +static int red_closeness = 40000; +static int green_closeness = 30000; +static int blue_closeness = 50000; + + +/*************************************** + * Basic attributes + ***************************************/ + +static void +init_xpm_attributes( Window win, + XpmAttributes * xpma, + FL_COLOR tran FL_UNUSED_ARG ) +{ + XWindowAttributes xwa; + + XGetWindowAttributes( flx->display, win, &xwa ); + xpma->valuemask = XpmVisual | XpmDepth | XpmColormap; + xpma->depth = xwa.depth; + xpma->visual = xwa.visual; + xpma->colormap = xwa.colormap; + + xpma->valuemask |= XpmRGBCloseness; + xpma->red_closeness = red_closeness; + xpma->green_closeness = green_closeness; + xpma->blue_closeness = blue_closeness; + +#if XpmRevision >= 7 + xpma->valuemask |= XpmReturnPixels | XpmReturnAllocPixels; +#else + xpma->valuemask |= XpmReturnPixels; +#endif + + /* According to the documentation transparency isn't implemented */ + + xpma->colorsymbols = NULL; +#if 0 + xpma->valuemask |= XpmColorSymbols; + xpma->colorsymbols = fl_calloc( 2, sizeof *xpma->colorsymbols ); + xpma->numsymbols = 2; + + xpma->colorsymbols[ 0 ].name = "None"; + xpma->colorsymbols[ 0 ].value = 0; + xpma->colorsymbols[ 0 ].pixel = fl_get_flcolor( tran ); + + xpma->colorsymbols[ 1 ].name = "opaque"; + xpma->colorsymbols[ 1 ].value = 0; + xpma->colorsymbols[ 1 ].pixel = fl_get_flcolor( FL_BLACK ); +#endif +} + + +/********************************************************************** + ******************************************************************{**/ + +static void +del_xpm_attributes( XpmAttributes * xpma ) +{ + if ( ! xpma ) + return; + + fl_free( xpma->colorsymbols ); + fl_free( xpma ); +} /*************************************** @@ -94,7 +158,7 @@ cleanup_xpma_struct( XpmAttributes * xpma ) xpma->colormap = None; XpmFreeAttributes( xpma ); - fl_free( xpma ); + del_xpm_attributes( xpma ); } @@ -330,61 +394,10 @@ show_pixmap( FL_OBJECT * obj, } -static int red_closeness = 40000; -static int green_closeness = 30000; -static int blue_closeness = 50000; - - -/*************************************** - * Basic attributes - ***************************************/ - -static void -init_xpm_attributes( Window win, - XpmAttributes * xpma, - FL_COLOR tran ) -{ - XWindowAttributes xwa; - - XGetWindowAttributes( flx->display, win, &xwa ); - xpma->valuemask = XpmVisual | XpmDepth | XpmColormap; - xpma->depth = xwa.depth; - xpma->visual = xwa.visual; - xpma->colormap = xwa.colormap; - - xpma->valuemask |= XpmRGBCloseness; - xpma->red_closeness = red_closeness; - xpma->green_closeness = green_closeness; - xpma->blue_closeness = blue_closeness; - -#if XpmRevision >= 7 - xpma->valuemask |= XpmReturnPixels | XpmReturnAllocPixels; -#else - xpma->valuemask |= XpmReturnPixels; -#endif - - { - static XpmColorSymbol xpcm[ 2 ]; - - xpcm[ 0 ].name = "None"; - xpcm[ 0 ].value = 0; - xpcm[ 0 ].pixel = fl_get_flcolor( tran ); - xpcm[ 1 ].name = "opaque"; - xpcm[ 1 ].value = 0; - xpcm[ 1 ].pixel = fl_get_flcolor( FL_BLACK ); - - xpma->valuemask |= XpmColorSymbols; - xpma->colorsymbols = xpcm; - xpma->numsymbols = 2; - } -} - - /********************************************************************** * Static PIXMAP ******************************************************************{**/ - static void draw_pixmap( FL_OBJECT * obj ) { @@ -495,24 +508,19 @@ fl_add_pixmap( int type, /*************************************** ***************************************/ -Pixmap -fl_create_from_pixmapdata( Window win, - char ** data, - unsigned int * w, - unsigned int * h, - Pixmap * sm, - int * hotx, - int * hoty, - FL_COLOR tran ) +static Pixmap +create_from_pixmapdata( Window win, + char ** data, + unsigned int * w, + unsigned int * h, + Pixmap * sm, + int * hotx, + int * hoty, + XpmAttributes * xpmattrib ) { Pixmap p = None; int s; - /* This ensures we do not depend on the header/dl having the same size */ - - xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); - init_xpm_attributes( win, xpmattrib, tran ); - s = XpmCreatePixmapFromData( flx->display, win, data, &p, sm, xpmattrib ); if ( s != XpmSuccess ) @@ -524,23 +532,44 @@ fl_create_from_pixmapdata( Window win, ( s == XpmColorFailed ? "(Can't get color)" : "" ) ) ) ); if ( s < 0 ) - { - fl_free( xpmattrib ); return None; - } } if ( p != None ) { - *w = xpmattrib->width; - *h = xpmattrib->height; + if ( w ) + *w = xpmattrib->width; + if ( h ) + *h = xpmattrib->height; if ( hotx ) *hotx = xpmattrib->x_hotspot; if ( hoty ) *hoty = xpmattrib->y_hotspot; } - else - fl_free( xpmattrib ); + + return p; +} + + +/*************************************** + ***************************************/ + +Pixmap +fl_create_from_pixmapdata( Window win, + char ** data, + unsigned int * w, + unsigned int * h, + Pixmap * sm, + int * hotx, + int * hoty, + FL_COLOR tran ) +{ + Pixmap p = None; + XpmAttributes * xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); + + init_xpm_attributes( win, xpmattrib, tran ); + p = create_from_pixmapdata( win, data, w, h, sm, hotx, hoty, xpmattrib ); + del_xpm_attributes( xpmattrib ); return p; } @@ -583,8 +612,8 @@ fl_get_pixmap_pixmap( FL_OBJECT * obj, { FL_BUTTON_STRUCT *sp; - if ( ! IsValidClass( obj, FL_PIXMAP ) - && ! IsValidClass( obj, FL_PIXMAPBUTTON ) ) + if ( ! ( IsValidClass( obj, FL_PIXMAP ) + || IsValidClass( obj, FL_PIXMAPBUTTON ) ) ) { M_err( "fl_get_pixmap_pixmap", "%s is not Pixmap/pixmapbutton " ); @@ -604,25 +633,21 @@ fl_get_pixmap_pixmap( FL_OBJECT * obj, /*************************************** - * Generic routine to read a pixmap file. ***************************************/ -Pixmap -fl_read_pixmapfile( Window win, - const char * file, - unsigned int * w, - unsigned int * h, - Pixmap * shape_mask, - int * hotx, - int * hoty, - FL_COLOR tran ) +static Pixmap +read_pixmapfile( Window win, + const char * file, + unsigned int * w, + unsigned int * h, + Pixmap * shape_mask, + int * hotx, + int * hoty, + XpmAttributes * xpmattrib ) { Pixmap p = None; int s; - xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); - init_xpm_attributes( win, xpmattrib, tran ); - s = XpmReadFileToPixmap( flx->display, win, ( char * ) file, &p, shape_mask, xpmattrib ); @@ -635,24 +660,45 @@ fl_read_pixmapfile( Window win, ( s == XpmColorFailed ? "(Can't get color)" : "" ) ) ) ); if ( s < 0 ) - { - fl_free( xpmattrib ); return None; - } } if ( p != None ) { - *w = xpmattrib->width; - *h = xpmattrib->height; - + if ( w ) + *w = xpmattrib->width; + if ( h ) + *h = xpmattrib->height; if ( hotx ) *hotx = xpmattrib->x_hotspot; if ( hoty ) *hoty = xpmattrib->y_hotspot; } - else - fl_free( xpmattrib ); + + return p; +} + + +/*************************************** + * Generic routine to read a pixmap file. + ***************************************/ + +Pixmap +fl_read_pixmapfile( Window win, + const char * file, + unsigned int * w, + unsigned int * h, + Pixmap * shape_mask, + int * hotx, + int * hoty, + FL_COLOR tran ) +{ + Pixmap p = None; + XpmAttributes * xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); + + init_xpm_attributes( win, xpmattrib, tran ); + p = read_pixmapfile( win, file, w, h, shape_mask, hotx, hoty, xpmattrib); + del_xpm_attributes( xpmattrib ); return p; } @@ -670,6 +716,7 @@ fl_set_pixmap_file( FL_OBJECT * obj, FL_BUTTON_STRUCT *sp; int hotx, hoty; Window win; + XpmAttributes * xpmattrib; if ( ! flx || ! flx->display ) return; @@ -678,8 +725,12 @@ fl_set_pixmap_file( FL_OBJECT * obj, sp = obj->spec; win = FL_ObjWin( obj ) ? FL_ObjWin( obj ) : fl_default_win( ); - p = fl_read_pixmapfile( win, fname, &sp->bits_w, &sp->bits_h, - &shape_mask, &hotx, &hoty, obj->col1 ); + + xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); + init_xpm_attributes( win, xpmattrib, obj->col1 ); + + p = read_pixmapfile( win, fname, &sp->bits_w, &sp->bits_h, + &shape_mask, &hotx, &hoty, xpmattrib ); if ( p != None ) { @@ -687,6 +738,8 @@ fl_set_pixmap_file( FL_OBJECT * obj, ( ( PixmapSPEC * ) sp->cspecv )->xpma = xpmattrib; fl_redraw_object( obj ); } + else + del_xpm_attributes( xpmattrib ); } @@ -844,6 +897,7 @@ fl_set_pixmap_data( FL_OBJECT * obj, Pixmap p, shape_mask = None; int hx, hy; + XpmAttributes * xpmattrib; CHECK( obj, "fl_set_pixmap_data" ); @@ -852,8 +906,12 @@ fl_set_pixmap_data( FL_OBJECT * obj, sp = obj->spec; win = FL_ObjWin( obj ) ? FL_ObjWin( obj ) : fl_default_win( ); - p = fl_create_from_pixmapdata( win, bits, &sp->bits_w, &sp->bits_h, - &shape_mask, &hx, &hy, obj->col1 ); + + xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); + init_xpm_attributes( win, xpmattrib, obj->col1 ); + + p = create_from_pixmapdata( win, bits, &sp->bits_w, &sp->bits_h, + &shape_mask, &hx, &hy, xpmattrib ); if ( p != None ) { @@ -861,7 +919,8 @@ fl_set_pixmap_data( FL_OBJECT * obj, ( ( PixmapSPEC * ) sp->cspecv )->xpma = xpmattrib; fl_redraw_object( obj ); } - + else + del_xpm_attributes( xpmattrib ); } @@ -947,6 +1006,7 @@ fl_set_pixmapbutton_focus_data( FL_OBJECT * obj, shape_mask = None; int hx, hy; + XpmAttributes * xpmattrib; CHECK( obj, "fl_set_pixmapbutton_focus_data" ); @@ -956,14 +1016,20 @@ fl_set_pixmapbutton_focus_data( FL_OBJECT * obj, sp = obj->spec; psp = sp->cspecv; win = FL_ObjWin( obj ) ? FL_ObjWin( obj ) : fl_default_win( ); - p = fl_create_from_pixmapdata( win, bits, &psp->focus_w, &psp->focus_h, - &shape_mask, &hx, &hy, obj->col1 ); + + xpmattrib = fl_calloc( 1, XpmAttributesSize( ) ); + init_xpm_attributes( win, xpmattrib, obj->col1 ); + + p = create_from_pixmapdata( win, bits, &psp->focus_w, &psp->focus_h, + &shape_mask, &hx, &hy, xpmattrib ); if ( p != None ) { change_focuspixmap( sp, win, p, shape_mask, 0 ); ( ( PixmapSPEC * ) sp->cspecv )->xpma = xpmattrib; } + else + del_xpm_attributes( xpmattrib ); } @@ -992,10 +1058,7 @@ fl_set_pixmapbutton_focus_file( FL_OBJECT * obj, &shape_mask, &hotx, &hoty, obj->col1 ); if ( p != None ) - { change_focuspixmap( sp, win, p, shape_mask, 0 ); - fl_free( xpmattrib ); - } } @@ -1042,25 +1105,20 @@ fl_free_pixmap_focus_pixmap( FL_OBJECT * obj ) /*************************************** - * This can't go into forms.c as it will pull xpm into - * programs that don't need it ***************************************/ void -fli_set_form_icon_data( FL_FORM * form, - char ** data ) +fl_set_form_icon_data( FL_FORM * form, + char ** data ) { Pixmap p, s = None; - unsigned int j; - p = fl_create_from_pixmapdata( fl_root, data, &j, &j, &s, NULL, NULL, 0 ); + p = fl_create_from_pixmapdata( fl_root, data, NULL, NULL, &s, + NULL, NULL, 0 ); if ( p != None ) - { fl_set_form_icon( form, p, s ); - fl_free( xpmattrib ); - } } |