| author | Jens Thoms Toerring <jt@toerring.de> | 2014年06月07日 20:56:43 +0200 |
|---|---|---|
| committer | Jens Thoms Toerring <jt@toerring.de> | 2014年06月07日 20:56:43 +0200 |
| commit | 77ad3770f1bcb22a1ef2cbbd577b924bb06b5a01 (patch) | |
| tree | 8c82b63e2a0a5e6c8b6eeaf383479608f553a7fc | |
| parent | 2facf752870723f9e23454d27ede871c13d13e35 (diff) | |
| download | xforms-77ad3770f1bcb22a1ef2cbbd577b924bb06b5a01.tar.gz | |
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | doc/part4_drawing_objects.texi | 2 | ||||
| -rw-r--r-- | doc/part5_overview.texi | 12 | ||||
| -rw-r--r-- | doc/part6_images.texi | 6 | ||||
| -rw-r--r-- | doc/xforms.texi | 2 | ||||
| -rw-r--r-- | fdesign/fd_main.c | 2 | ||||
| -rw-r--r-- | fdesign/fd_printC.c | 8 | ||||
| -rw-r--r-- | image/image.c | 2 | ||||
| -rw-r--r-- | image/image_postscript.c | 4 | ||||
| -rw-r--r-- | image/ps_core.c | 2 | ||||
| -rw-r--r-- | lib/appwin.c | 6 | ||||
| -rw-r--r-- | lib/asyn_io.c | 17 | ||||
| -rw-r--r-- | lib/cursor.c | 1 | ||||
| -rw-r--r-- | lib/extern.h | 11 | ||||
| -rw-r--r-- | lib/flresource.c | 6 | ||||
| -rw-r--r-- | lib/flvisual.c | 2 | ||||
| -rw-r--r-- | lib/forms.c | 8 | ||||
| -rw-r--r-- | lib/global.c | 2 | ||||
| -rw-r--r-- | lib/include/Basic.h | 2 | ||||
| -rw-r--r-- | lib/include/XBasic.h | 3 | ||||
| -rw-r--r-- | lib/input.c | 12 | ||||
| -rw-r--r-- | lib/objects.c | 101 | ||||
| -rw-r--r-- | lib/tbox.c | 30 | ||||
| -rw-r--r-- | lib/xpopup.c | 4 | ||||
| -rw-r--r-- | lib/xtext.c | 178 |
@@ -1,3 +1,7 @@ +2014年06月07日 Jens Thoms Toerring <jt@toerring.de> + + * Lots of minor corrections + 2014年06月04日 Jens Thoms Toerring <jt@toerring.de> * lib/input.c: some more corrections. diff --git a/doc/part4_drawing_objects.texi b/doc/part4_drawing_objects.texi index 2163405..bdc28fa 100644 --- a/doc/part4_drawing_objects.texi +++ b/doc/part4_drawing_objects.texi @@ -920,7 +920,7 @@ cursor can optionally be drawn void fl_draw_text_cursor(int align, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, FL_COLOR col, int style, int size, char *str, - int FL_COLOR ccol, int pos); + FL_COLOR ccol, int pos); @end example @noindent where @code{ccol} is the color of the cursor and @code{pos} is its diff --git a/doc/part5_overview.texi b/doc/part5_overview.texi index cbe68d0..1e1abd3 100644 --- a/doc/part5_overview.texi +++ b/doc/part5_overview.texi @@ -2269,6 +2269,18 @@ information for each of the visual modes. Of interest is only the entry for the visual mode in use, @code{@ref{fl_vmode}}. +@vindex fl_dpi +@findex fl_get_dpi() +@anchor{fl_dpi} +@anchor{fl_get_dpi()} +@item double fl_dpi +@item double fl_get_dpi() +The @code{fl_dpi} variable contains the screen resolution (in dots +per inch), averaged over the resolutions in @code{x}- and +@code{y}-direction. The funtion is a convenience macros with the same +result. + + @vindex fl_visual @findex fl_get_visual() @anchor{fl_visual} diff --git a/doc/part6_images.texi b/doc/part6_images.texi index 8b1eb6d..273009b 100644 --- a/doc/part6_images.texi +++ b/doc/part6_images.texi @@ -3,10 +3,10 @@ Although images are not typically a part of the GUI, they are often part of an application. For this reason and others, image support is -part of Forms Library. It is somewhat not unexpected that the users of -a graphical user interface want some graphics support. +part of Forms Library. It is not unusual that the users of a graphical +user interface want some graphics support. -The most important reason to have image support in the library is the +The most important reason to have image support in the library is the amount of questions/requests on the mailing list of the Forms Library about images. It convinced us that having image support will make many Forms Library users life easier. diff --git a/doc/xforms.texi b/doc/xforms.texi index 17e32cd..354838f 100644 --- a/doc/xforms.texi +++ b/doc/xforms.texi @@ -2,7 +2,7 @@ @setfilename xforms.info @settitle XForms (Forms Library) - Version 1.2 (Rev. 4)@*A Graphical User Interface Toolkit for X -@set lastupdate June 4, 2014 +@set lastupdate June 6, 2014 @paragraphindent 0 @titlepage diff --git a/fdesign/fd_main.c b/fdesign/fd_main.c index 3b2dc0a..41067b6 100644 --- a/fdesign/fd_main.c +++ b/fdesign/fd_main.c @@ -678,7 +678,7 @@ pre_connect( int argc, create_the_forms( ); init_classes( ); - fli_dpi = 95; + fl_dpi = 96; if ( i > argc - 1 ) { diff --git a/fdesign/fd_printC.c b/fdesign/fd_printC.c index ccc0501..b09e2d8 100644 --- a/fdesign/fd_printC.c +++ b/fdesign/fd_printC.c @@ -883,13 +883,13 @@ get_conversion_factor( void ) double sc = 1.0; if ( fdopt.unit == FL_COORD_POINT ) - sc = 72.00 / fli_dpi; + sc = 72.00 / fl_dpi; else if ( fdopt.unit == FL_COORD_MM ) - sc = 25.40 / fli_dpi; + sc = 25.40 / fl_dpi; else if ( fdopt.unit == FL_COORD_centiPOINT ) - sc = 7200.00 / fli_dpi; + sc = 7200.00 / fl_dpi; else if ( fdopt.unit == FL_COORD_centiMM ) - sc = 2540.00 / fli_dpi; + sc = 2540.00 / fl_dpi; return sc; } diff --git a/image/image.c b/image/image.c index d2c6069..da6fa19 100644 --- a/image/image.c +++ b/image/image.c @@ -1421,7 +1421,7 @@ flimage_dup_( FL_IMAGE * sim, memcpy( im->io_spec, sim->io_spec, sim->spec_size ); } - /* reset stuff that's on a per-image basis */ + /* Reset stuff that's on a per-image basis */ im->depth = 0; im->vclass = 0; diff --git a/image/image_postscript.c b/image/image_postscript.c index e839ef3..d89cf51 100644 --- a/image/image_postscript.c +++ b/image/image_postscript.c @@ -60,14 +60,12 @@ flimage_ps_options( void ) if ( ! sp ) { - extern float fli_dpi; /* I don't like this and will change it */ - sp = fl_calloc( 1, sizeof *sp ); sp->orientation = FLPS_AUTO; sp->paper_w = 8.5; sp->paper_h = 11.0; sp->auto_fit = 1; - sp->xdpi = sp->ydpi = fli_dpi; + sp->xdpi = sp->ydpi = fl_dpi; sp->printer_dpi = 300; sp->vm = sp->hm = 0.3; sp->xscale = sp->yscale = 1.0; diff --git a/image/ps_core.c b/image/ps_core.c index 0fa9fc3..75bbf6f 100644 --- a/image/ps_core.c +++ b/image/ps_core.c @@ -61,7 +61,7 @@ flps_init( void ) /* driver will fill-in appropriate vals for minus */ local_flps->drawbox = -1; - local_flps->xdpi = local_flps->ydpi = fli_dpi; + local_flps->xdpi = local_flps->ydpi = fl_dpi; local_flps->pack = 1; /* Cache */ diff --git a/lib/appwin.c b/lib/appwin.c index 7a2167d..b307c21 100644 --- a/lib/appwin.c +++ b/lib/appwin.c @@ -207,9 +207,9 @@ fl_add_event_callback( Window win, /*************************************** - * Removes one or all event callbacks for a window. May be - * called with for a window for which no event callbacks - * have been set, so handle also that case gracefully. + * Removes one or all event callbacks for a window. Might be + * called for a window for which no event callbacks have been + * set, so handle also that case gracefully. ***************************************/ void diff --git a/lib/asyn_io.c b/lib/asyn_io.c index 6639937..f70b364 100644 --- a/lib/asyn_io.c +++ b/lib/asyn_io.c @@ -67,7 +67,7 @@ static void clear_freelist( void ); ***************************************/ static void -collect_fd( void ) +collect_fds( void ) { FLI_IO_REC *p; int nf = 0; @@ -84,7 +84,7 @@ collect_fd( void ) { if ( p->source < 0 ) { - M_err( "collect_fd", "source < 0\n" ); + M_err( "collect_fds", "source < 0\n" ); continue; } @@ -126,7 +126,7 @@ fl_add_io_callback( int fd, fli_context->io_rec = io_rec; - collect_fd( ); + collect_fds( ); } @@ -169,19 +169,20 @@ fl_remove_io_callback( int fd, then fli_watch_io(), iterating over all IO callbacks still tries to to access the 'next' field and if the structure has been deallocated completely (instead of having been temporarily moved - to somewhere else where it still can be accessed) stumbles badly. - That's also why fli_watch_io() calls clear_freelist() - it's the - only instance that knows when the structure isn't needed anymore. */ + to somewhere else where it still can be accessed) it stumbles + badly. That's also why fli_watch_io() calls clear_freelist() - + it's the only place where it's known when the structure isn't + needed anymore. */ add_to_freelist( io ); } - collect_fd( ); + collect_fds( ); } /*************************************** - * Watch for activities using select or poll. Timeout in milli-second + * Watch for activities using select or poll. Timeout is in milli-seconds. ***************************************/ void diff --git a/lib/cursor.c b/lib/cursor.c index 1ee699f..002af10 100644 --- a/lib/cursor.c +++ b/lib/cursor.c @@ -37,7 +37,6 @@ #include "include/forms.h" #include "flinternal.h" -#include "extern.h" #define MAX_CURSORS 64 /* max. number of bitmap cursors */ diff --git a/lib/extern.h b/lib/extern.h index ac99102..cf97072 100644 --- a/lib/extern.h +++ b/lib/extern.h @@ -41,17 +41,6 @@ extern FL_OBJECT *fli_current_group; #define FLI_INACTIVE_PATTERN fli_gray_pattern[ 1 ] -extern Display *fl_display; -extern Window fl_root, - fl_vroot; -extern int fl_screen; - -extern int fl_vmode; - -extern int fl_scrh, - fl_scrw; - -extern float fli_dpi; extern FL_IOPT fli_cntl; extern int fli_inverted_y; diff --git a/lib/flresource.c b/lib/flresource.c index f4abe6e..073018e 100644 --- a/lib/flresource.c +++ b/lib/flresource.c @@ -1142,10 +1142,10 @@ fl_initialize( int * na, if ( xdpi / ydpi > 1.05 || ydpi / xdpi < 0.95 ) M_warn( "fl_initialize", "NonSquarePixel %.1f %.1f", xdpi, ydpi ); - fli_dpi = ( xdpi + ydpi ) / 2; - fli_dpi = ( ( int ) ( fli_dpi * 10.0 + 0.3 ) ) * 0.1; + fl_dpi = ( xdpi + ydpi ) / 2; + fl_dpi = FL_nint( fl_dpi * 10.0 + 0.5 ) * 0.1; - M_info( "fl_initialize", "screen DPI = %f", fli_dpi ); + M_info( "fl_initialize", "screen DPI = %f", fl_dpi ); fl_vmode = fli_initialize_program_visual( ); fli_init_colormap( fl_vmode ); diff --git a/lib/flvisual.c b/lib/flvisual.c index f8e82c1..99ac097 100644 --- a/lib/flvisual.c +++ b/lib/flvisual.c @@ -188,7 +188,7 @@ select_best_visual( void ) if ( fli_cntl.debug ) { M_warn( "select_best_visual", "XlibVersion: %s", XlibVersion ); - M_info( "select_best_visual", "DPI = %d", fli_dpi ); + M_info( "select_best_visual", "DPI = %d", fl_dpi ); M_warn( "select_best_visual", "No. of Visuals: %d", xvn ); for ( j = 0; j < 6; j++ ) if ( bestv[ j ] ) diff --git a/lib/forms.c b/lib/forms.c index 874f4bf..965f574 100644 --- a/lib/forms.c +++ b/lib/forms.c @@ -36,10 +36,10 @@ #include "private/flvasprintf.h" -#define PointToPixel( a ) FL_crnd( ( a ) * fli_dpi / 72.0 ) -#define MMToPixel( a ) FL_crnd( ( a ) * fli_dpi / 25.4 ) -#define CMMToPixel( a ) FL_crnd( ( a ) * fli_dpi / 2540.0 ) -#define CPointToPixel( a ) FL_crnd( ( a ) * fli_dpi / 7200.0 ) +#define PointToPixel( a ) FL_crnd( ( a ) * fl_dpi / 72.0 ) +#define MMToPixel( a ) FL_crnd( ( a ) * fl_dpi / 25.4 ) +#define CMMToPixel( a ) FL_crnd( ( a ) * fl_dpi / 2540.0 ) +#define CPointToPixel( a ) FL_crnd( ( a ) * fl_dpi / 7200.0 ) static FL_FORM * create_new_form( FL_Coord, FL_Coord ); diff --git a/lib/global.c b/lib/global.c index 0104ea6..11490dd 100644 --- a/lib/global.c +++ b/lib/global.c @@ -62,7 +62,7 @@ XKeyboardControl fli_keybdcontrol; unsigned long fli_keybdmask = ( 1L << 8 ) - 1; -float fli_dpi = 80.0; +double fl_dpi = 96.0; int fli_inverted_y; diff --git a/lib/include/Basic.h b/lib/include/Basic.h index 133d930..7544193 100644 --- a/lib/include/Basic.h +++ b/lib/include/Basic.h @@ -1438,7 +1438,7 @@ FL_EXPORT void fl_draw_text_cursor( int align, int style, int size, const char * str, - int cc, + FL_COLOR cc, int pos ); #define fl_draw_box fl_draw_box diff --git a/lib/include/XBasic.h b/lib/include/XBasic.h index 1c7117f..7cb75e0 100644 --- a/lib/include/XBasic.h +++ b/lib/include/XBasic.h @@ -142,6 +142,9 @@ FL_EXPORT FL_State fl_state[ ]; FL_EXPORT char *fl_ul_magic_char; +FL_EXPORT double fl_dpi; +#define fl_get_dpi( ) ( fl_dpi ) + FL_EXPORT int fl_mode_capable( int mode, int warn ); diff --git a/lib/input.c b/lib/input.c index 294bf82..34f78e0 100644 --- a/lib/input.c +++ b/lib/input.c @@ -64,8 +64,8 @@ static int make_line_visible( FL_OBJECT * obj, static int make_char_visible( FL_OBJECT * obj, int xpos ); -static void copy_attributes( FL_OBJECT *, - FL_OBJECT * ); +static void copy_attributes( FL_OBJECT * dest, + const FL_OBJECT * src ); static int date_validator( FL_OBJECT *, const char *, @@ -303,7 +303,7 @@ draw_input( FL_OBJECT * obj ) && sp->beginrange >= sp->endrange ) ? sp->position : -1, sp->beginrange, sp->endrange, - sp->str, sp->drawtype != COMPLETE, + sp->str, sp->drawtype != COMPLETE, sp->topline, sp->topline + sp->screenlines, 0 ); @@ -2919,8 +2919,8 @@ fl_get_input_editkeymap( FL_EditKeymap * keymap ) ***************************************/ static void -copy_attributes( FL_OBJECT * dest, - FL_OBJECT * src ) +copy_attributes( FL_OBJECT * dest, + const FL_OBJECT * src ) { if ( src == dest ) return; @@ -3003,7 +3003,7 @@ fl_set_input_cursor_visible( FL_OBJECT * obj, ***************************************/ int -fl_input_changed( FL_OBJECT *obj ) +fl_input_changed( FL_OBJECT * obj ) { return ( ( FLI_INPUT_SPEC * ) obj->spec )->changed; } diff --git a/lib/objects.c b/lib/objects.c index 05fe9d3..bc119c5 100644 --- a/lib/objects.c +++ b/lib/objects.c @@ -31,7 +31,6 @@ #include "include/forms.h" #include "flinternal.h" -#include <string.h> #include "private/flvasprintf.h" @@ -45,19 +44,19 @@ extern FL_OBJECT * fli_handled_parent; /* defined in events.c */ static void redraw( FL_FORM *, int ); static void lose_focus( FL_OBJECT * ); -static void get_object_rect( FL_OBJECT *, - XRectangle *, - int ); -static XRectangle * get_label_rect( FL_OBJECT * obj, - XRectangle * rect ); -static int objects_intersect( FL_OBJECT *, - FL_OBJECT * ); +static void get_object_rect( const FL_OBJECT * obj, + XRectangle * rect, + int extra ); +static XRectangle * get_label_rect( const FL_OBJECT * obj, + XRectangle * rect ); +static int objects_intersect( const FL_OBJECT *, + const FL_OBJECT * ); static void mark_object_for_redraw( FL_OBJECT * ); -static int object_is_under( FL_OBJECT * ); +static int object_is_under( const FL_OBJECT * ); static void checked_hide_tooltip( FL_OBJECT *, XEvent * ); static int prep_recalc( FL_FORM * form, - FL_OBJECT * start_obj ); + FL_OBJECT * start_obj ); static void finish_recalc( FL_FORM * form, FL_OBJECT * start_obj ); @@ -83,9 +82,9 @@ static FL_RECT *tmp_rects = NULL; && ( form )->frozen == 0 ) -/* Macro for checking if a label is to be consider to be "outside" of its - object for redrawing purposes. When a label is outside its object and - we change the position or size of the object or the text, style or +/* Macro for checking if a label is to be considered to be "outside" of its + object for redrawing purposes. When a label is outside of its object and + we change the position or size of the object, the text, or style or font size of the label then other objects under the label also need to be redrawn. In priciple calling fl_is_outside_lalign() should do the job but there are some semi-transparent objects which we need to @@ -119,7 +118,7 @@ bg_object( FL_FORM * form ) /*************************************** - * Creates an object - NOT FOR USE BY USERS OF THE LIBRARY! + * Creates an object - NOT MEANT FOR USE BY USERS OF THE LIBRARY! ***************************************/ FL_OBJECT * @@ -164,19 +163,19 @@ fl_make_object( int objclass, break; case FL_COORD_MM : - fli_scale_object( obj, fli_dpi / 25.4, fli_dpi / 25.4 ); + fli_scale_object( obj, fl_dpi / 25.4, fl_dpi / 25.4 ); break; case FL_COORD_POINT : - fli_scale_object( obj, fli_dpi / 72.0, fli_dpi / 72.0 ); + fli_scale_object( obj, fl_dpi / 72.0, fl_dpi / 72.0 ); break; case FL_COORD_centiPOINT : - fli_scale_object( obj, fli_dpi / 7200.0, fli_dpi / 7200.0 ); + fli_scale_object( obj, fl_dpi / 7200.0, fl_dpi / 7200.0 ); break; case FL_COORD_centiMM : - fli_scale_object( obj, fli_dpi / 2540.0, fli_dpi / 2540.0 ); + fli_scale_object( obj, fl_dpi / 2540.0, fl_dpi / 2540.0 ); break; default: @@ -1983,7 +1982,7 @@ fl_get_focus_object( FL_FORM * form ) /*************************************** * Returns an object of type 'find' in a form, starting at 'obj'. - * If find_object() does not return an object the event that + * If the function does not return an object the event that * triggered the call will be eaten. This is how the deactived * and inactive objects reject events. * Modify with care! @@ -2265,8 +2264,8 @@ fl_redraw_object( FL_OBJECT * obj ) ***************************************/ static int -objects_intersect( FL_OBJECT * obj1, - FL_OBJECT * obj2 ) +objects_intersect( const FL_OBJECT * obj1, + const FL_OBJECT * obj2 ) { if ( tmp_vdata ) { @@ -2660,7 +2659,7 @@ handle_object( FL_OBJECT * obj, case FL_FOCUS: /* 'refocus' is set if on the last FL_UNFOCUS it was found that the text in the input field didn't validate. In that - case the focus has to go back to that field instead to a + case the focus has to go back to that field and *not* to a different one */ if ( refocus && refocus->form ) @@ -3133,7 +3132,7 @@ fl_call_object_callback( FL_OBJECT * obj ) ***************************************/ static int -object_is_under( FL_OBJECT * obj ) +object_is_under( const FL_OBJECT * obj ) { FL_OBJECT *o; int cnt = 0; @@ -3543,8 +3542,8 @@ fl_get_object_bbox( FL_OBJECT * obj, ***************************************/ static XRectangle * -get_label_rect( FL_OBJECT * obj, - XRectangle * rect ) +get_label_rect( const FL_OBJECT * obj, + XRectangle * rect ) { int sw, sh; @@ -3597,9 +3596,9 @@ get_label_rect( FL_OBJECT * obj, ***************************************/ static void -get_object_rect( FL_OBJECT * obj, - FL_RECT * rect, - int extra ) +get_object_rect( const FL_OBJECT * obj, + FL_RECT * rect, + int extra ) { if ( obj->objclass == FL_FRAME || obj->objclass == FL_LABELFRAME @@ -3617,7 +3616,7 @@ get_object_rect( FL_OBJECT * obj, /* Include the label into the box - but only for labels that are not within the object. If "inside" labels extend beyond the limits of the object things look ugly anyway and it doesn't seem to make too much - sense to slow down the program any further for that case. */ + sense to slow down the program for this case. */ if ( obj->label && *obj->label && OL( obj ) ) { @@ -3634,20 +3633,22 @@ void fl_set_object_automatic( FL_OBJECT * obj, int flag ) { - if ( obj->automatic != ( flag ? 1 : 0 ) ) - { - obj->automatic = flag ? 1 : 0; + flag = flag ? 1 : 0; - if ( obj->form ) - { - if ( flag ) - obj->form->num_auto_objects++; - else - obj->form->num_auto_objects--; - } + if ( obj->automatic == flag ) + return; - fli_recount_auto_objects( ); + obj->automatic = flag; + + if ( obj->form ) + { + if ( flag ) + obj->form->num_auto_objects++; + else + obj->form->num_auto_objects--; } + + fli_recount_auto_objects( ); } @@ -3698,12 +3699,16 @@ lose_focus( FL_OBJECT * obj ) /*************************************** - * Part of the public interface, not used within the library + * Part of the public interface, not used within the library. + * Calls a user supplied function on all objects of a form but stops + * in between of the function, when called on one of the objects, + * returns 0. The function also gets called for objects that mark the + * begin and end of a group! ***************************************/ void fl_for_all_objects( FL_FORM * form, - int ( * cb )( FL_OBJECT *, void * ), + int ( * fp )( FL_OBJECT *, void * ), void * v ) { FL_OBJECT *obj; @@ -3714,13 +3719,13 @@ fl_for_all_objects( FL_FORM * form, return; } - if ( ! cb ) + if ( ! fp ) { M_err( "fl_for_all_objects", "NULL callback function" ); return; } - for ( obj = bg_object( form ); obj && ! cb( obj, v ); obj = obj->next ) + for ( obj = bg_object( form ); obj && ! fp( obj, v ); obj = obj->next ) /* empty */ ; } @@ -3762,10 +3767,10 @@ fl_set_object_helper_f( FL_OBJECT * obj, /*************************************** * Function for setting the conditions under which an object gets * returned (or its callback invoked). If the object has to do - * additional work on setting te condition (e.g. it has child - * objects that also need to be set) it has to set up it's own - * function that then will called in the end. This function should - * only be called once an object has been created completely! + * additional work on setting the condition (e.g. it has child + * objects that also need to be set) it has to set up its own + * function that then will be called in the end. This function should + * only be called once an object has been fully created! ***************************************/ int @@ -44,7 +44,7 @@ static int handle_tbox( FL_OBJECT *, int, void * ); -static GC create_gc( FL_OBJECT *, +static GC create_gc( const FL_OBJECT *, int, int, FL_COLOR, @@ -319,7 +319,7 @@ fli_tbox_insert_line( FL_OBJECT * obj, tl->specialGC = None; tl->incomp_esc = 0; - /* Check for flags at the start of the line. When we're done 'p' + /* Check for flags at the start of the line. When we're done 'p' will points to the start of the string to be shown in the textbox. */ while ( *p && *p == sp->specialkey && ! done ) @@ -608,16 +608,16 @@ fli_tbox_add_chars( FL_OBJECT * obj, of the line from the old text and the new text, delete te old line and then draw a new one in its place. - Another question is how to deal with situations where by a previous - call with e.g. "@C3" a color was selected and in the next call the + Another question is how to deal with situations where, by a previous + call with e.g. "@C3", a color was selected and in the next call the string to be added starts with a digit, let's say '7'. One possibility would be to re-evaluate the combined string to mean "@C37", setting a different color. But since in older versions this didn't happen - (and some users may rely on this, it is assumed that this isn't the + (and some users may rely on this), it is assumed that this isn't the users intention and to avoid the two digits to become collated and interpreted as the number of a different color "@ " is inserted in between the digits, with "@ " treated as a separator between digits - (the intended ose of "@ " is to allow lines like "@C3@ 2. Chapter", i. + (the intended use of "@ " is to allow lines like "@C3@ 2. Chapter", i. e. having a color specification, followed by printable text that starts with a digit). */ @@ -1455,14 +1455,14 @@ fli_tbox_set_dblclick_callback( FL_OBJECT * obj, ***************************************/ static GC -create_gc( FL_OBJECT * obj, - int style, - int size, - FL_COLOR color, - int clip_x, - int clip_y, - int clip_w, - int clip_h ) +create_gc( const FL_OBJECT * obj, + int style, + int size, + FL_COLOR color, + int clip_x, + int clip_y, + int clip_w, + int clip_h ) { GC gc; XGCValues xgcv; @@ -1864,7 +1864,7 @@ fli_tbox_get_topline( FL_OBJECT * obj ) return -1; /* If the box was never shown assume that the very first line will - be the one that's goin tp be in topmost position */ + be the one that's going to be in topmost position */ if ( ! sp->def_height ) return 0; diff --git a/lib/xpopup.c b/lib/xpopup.c index 26f0c07..e9629e6 100644 --- a/lib/xpopup.c +++ b/lib/xpopup.c @@ -583,7 +583,7 @@ fl_setpup_default_fontsize( int size ) pup_font_size = size; pup_title_font_size = size; - pup_font_struct = pup_title_font_struct = 0; + pup_font_struct = pup_title_font_struct = NULL; if ( ! flx->display ) return old_pup_font_size; @@ -2103,7 +2103,7 @@ fl_showpup( int n ) xgcv.foreground = fl_get_flcolor( FL_INACTIVE ); m->gc_inactive = XCreateGC( flx->display, m->win, vmask, &xgcv ); - /* special hack for B&W */ + /* Special hack for B&W */ if ( fli_dithered( fl_vmode ) ) XSetFillStyle( flx->display, m->gc_inactive, FillStippled ); diff --git a/lib/xtext.c b/lib/xtext.c index 0afa202..64ea315 100644 --- a/lib/xtext.c +++ b/lib/xtext.c @@ -103,19 +103,22 @@ fli_get_max_pixels_line( void ) } -typedef int ( * DrawString )( Display *, - Drawable, GC, - int, - int, - const char *, - int ); +/* type fitting both XDrawString() and XDrawImageString() */ + +typedef int ( * DrawString )( Display * display, + Drawable d, + GC gc, + int x, + int y, + const char * string, + int length ); /*************************************** * Major text drawing routine. It draws text (possibly consisting of several * lines) into the box specified via the coordinates and using the given * alignment relative to that box. Also a cursor is drawn. For lines that - * contain a specal character indicating underlining this is also handled. + * contain a special character indicating underlining this is also handled. * Finally, parts of the text can be shown as selected. * * Arguments: @@ -126,7 +129,7 @@ typedef int ( * DrawString )( Display *, * -1 = clipping is done but already has been set externally * backcol color to be used for selected text * forecol color for (unselected) text - * curscol color of cursor + * curscol color for cursor * style text font style * size text font size * curspos index into string where cursor is to be drawn (if negative or @@ -135,15 +138,15 @@ typedef int ( * DrawString )( Display *, * selend index into string where selection ends (to get selection this * must be larger than 'selstart') * istr pointer to the text to be drawn - * img if non-zero use XDrawImageString() instead of XDrawString() - * to draw the text + * img if non-zero also draw background (use XDrawImageString() + * instead of XDrawString() to draw the text) * topline first line of the text to be actually shown (counting starts * at 1) * endline last line to be shown (if less than 1 or too large is replaced * by the number of lines in the text) - * bkcol background color + * bkcol background color (used when 'img' is true) * - * Returns the width (in pixel) of the widest line of the text. + * Returns the width (in pixel) of the widest line of the text drawn. ***************************************/ int @@ -160,7 +163,7 @@ fli_draw_string( int align, int size, int curspos, int selstart, - int selend, + int selend, const char * istr, int img, int topline, @@ -181,7 +184,7 @@ fli_draw_string( int align, the very first position and there's no string to output. It would be tempting to also bail out if the height 'h' is 0 or even negative but there are some code paths were this actually may happen and we - wouldn't outut a string even though it is needed (I know, it's a + wouldn't output a string even though it is needed (I know, it's a bloody mess but fixing it right now would probably take a few weeks and even might break existing code...) */ @@ -278,7 +281,7 @@ fli_draw_string( int align, max_pixelline = i; } - /* Calculate the x- and y- positon of were to print the text */ + /* Calculate the x- and y- positon of where to print the text */ switch ( horalign ) { @@ -330,7 +333,7 @@ fli_draw_string( int align, fli_textcolor( forecol ); fli_bk_textcolor( bkcol ); - /* Draw the lines requested */ + /* Draw all the lines requested */ for ( i = topline; i < endline; i++ ) { @@ -399,7 +402,7 @@ fli_draw_string( int align, fl_rectf( xsel, line->y - flx->fasc, wsel, flx->fheight, forecol ); - fli_textcolor( backcol ); /* bkcol ? */ + fli_textcolor( backcol ); drawIt( flx->display, flx->win, flx->textgc, xsel, line->y, line->str + start, len ); fli_textcolor( forecol ); @@ -476,6 +479,8 @@ fli_draw_string( int align, fl_rectf( xc, yc, 2, flx->fheight, curscol ); } + /* Free our copy of the string */ + fli_safe_free( str ); /* Reset clipping if required */ @@ -488,6 +493,12 @@ fli_draw_string( int align, /*************************************** + * Function returns the index of the character in the label of the object + * the mouse is over or -1 if it's not over the label. Note that the function + * has some limitations: it can only be used on labels inside of the object + * and the label string may not contain underline characters (and the label + * can't be a symbol) - if you try to use it on labels that don't satisfy + * these requirements -1 is returned. ***************************************/ int @@ -534,7 +545,7 @@ fl_get_label_char_at_mouse( FL_OBJECT * obj ) * mouse is to the left of the start of the line) * The function expects a string that doesn't contain mon-printable characters * (except '\n' for starts a new lines) - * This function is supposed to ork on text drawn using fli_draw_string() + * This function is supposed to work on text drawn using fli_draw_string() * using the same relevant arguments (alignment, box, font style and size * and string) as passed to this function. * @@ -732,58 +743,59 @@ fli_get_pos_in_string( int align, ***/ /*************************************** - * Draws a (multi-line) text with a cursor on a white background + * Draw text with cursor and, if 'bk' is set, also the background + * (but with no highlighting) + ***************************************/ + +static void +fli_draw_text_cursor( int align, /* alignment in box */ + FL_Coord x, /* box geometry */ + FL_Coord y, + FL_Coord w, + FL_Coord h, + const char * str, /* string to draw */ + int style, /* font style and size */ + int size, + FL_COLOR c, /* color for text */ + FL_COLOR bc, /* background color */ + FL_COLOR cc, /* color for cursor */ + int bk, /* draws background when set */ + int pos ) /* index of cursor position */ +{ + fli_draw_string( align, x, y, w, h, 0, FL_NOCOLOR, c, cc, + style, size, pos, 0, -1, str, bk, 0, 0, bc ); +} + + +/*************************************** + * Draws a (multi-line) text with a cursor (no background, no highlighting) ***************************************/ void -fl_draw_text_cursor( int align, - FL_Coord x, +fl_draw_text_cursor( int align, /* alignment in box */ + FL_Coord x, /* box geometry */ FL_Coord y, FL_Coord w, FL_Coord h, - FL_COLOR c, - int style, + FL_COLOR c, /* text color */ + int style, /* font style and size */ int size, - const char * str, - int cc, - int pos ) + const char * str, /* the text to draw */ + FL_COLOR cc, /* cursor color */ + int pos ) /* cursor position */ { - fli_draw_string( align, x, y, w, h, 0, FL_WHITE, c, cc, - style, size, pos, 0, -1, str, 0, 0, 0, 0 ); + fli_draw_text_cursor( align, x, y, w, h, str, style, size, + c, FL_NOCOLOR, cc, 0, pos ); } /*************************************** ***************************************/ -static void -fli_draw_text_cursor( int align, - FL_Coord x, - FL_Coord y, - FL_Coord w, - FL_Coord h, - const char * str, - int style, - int size, - FL_COLOR c, - FL_COLOR bc, - FL_COLOR cc, - int bk, - int pos ) -{ - fli_draw_string( align, x, y, w, h, 0, FL_WHITE, c, cc, - style, size, pos, 0, -1, str, bk, 0, 0, bc ); -} - - #define D( x, y, c ) \ fli_draw_text_cursor( align, x, y, w, h, str, \ style,size, c, bc, 0, bk, -1 ) - -/*************************************** - ***************************************/ - void fli_draw_text_inside( int align, FL_Coord x, @@ -863,7 +875,7 @@ fli_draw_text_inside( int align, } fli_draw_text_cursor( align, x, y, w, h, str, style, size, - c, bc, 0, special ? 0 : bk, -1 ); + c, bc, FL_NOCOLOR, special ? 0 : bk, -1 ); } @@ -889,66 +901,6 @@ fl_draw_text( int align, /*************************************** ***************************************/ -#if 0 - -void -fl_draw_text_beside( int align, - FL_Coord x, - FL_Coord y, - FL_Coord w, - FL_Coord h, - char * str, - int len, - int style, - int size, - FL_COLOR c, - FL_COLOR bc, - int bk ) -{ - int newa, - newx, - newy, - dx = 0, - dy = 0; - - if ( ! str || ! *str ) - return; - - if ( fl_is_inside_lalign( align ) && ! fl_is_center_lalign( align ) ) - M_warn( "drw_text_beside", "align request is inside" ); - - if ( align & FL_ALIGN_LEFT ) - { - if ( align & FL_ALIGN_BOTTOM || align & FL_ALIGN_TOP ) - dx = - 4; - else - dx = 1; - } - else if ( align & FL_ALIGN_RIGHT ) - { - if ( align & FL_ALIGN_BOTTOM || align & FL_ALIGN_TOP ) - dx = 4; - else - dx = - 1; - } - - if ( align & FL_ALIGN_BOTTOM ) - dy = - 2; - else if ( align & FL_ALIGN_TOP ) - dy = 2; - - x += dx; - y += dy; - - fli_get_outside_align( align, x, y, w, h, &newa, &newx, &newy ); - fli_draw_text_inside( align, x, y, w, h, str, style, size, c, bc, bk ); -} -#endif - - -/*************************************** - ***************************************/ - void fl_draw_text_beside( int align, FL_Coord x, |