xforms.git - xforms

index : xforms.git
xforms
summary refs log tree commit diff
diff options
context:
space:
mode:
authorJens Thoms Toerring <jt@toerring.de>2017年07月25日 22:24:59 +0200
committerJens Thoms Toerring <jt@toerring.de>2017年07月25日 22:24:59 +0200
commit0b8e2868b82e2cf05645d628220fda8751d351d1 (patch)
tree4dd354fdef38b467b6e0cddb7cefc3e442de45d1
parent4ca05a78fe30757a87a156714ec2d75f35158fcd (diff)
downloadxforms-0b8e2868b82e2cf05645d628220fda8751d351d1.tar.gz
Some attempts to make things less dependent on the screen resolution (if a unit is set)
Diffstat
-rw-r--r--fdesign/fd_printC.c 13
-rw-r--r--lib/button.c 6
-rw-r--r--lib/chart.c 2
-rw-r--r--lib/choice.c 8
-rw-r--r--lib/colsel.c 38
-rw-r--r--lib/flinternal.h 2
-rw-r--r--lib/flresource.c 12
-rw-r--r--lib/fonts.c 25
-rw-r--r--lib/fselect.c 85
-rw-r--r--lib/goodies.c 1
-rw-r--r--lib/include/Basic.h 5
-rw-r--r--lib/input.c 4
-rw-r--r--lib/menu.c 2
-rw-r--r--lib/objects.c 166
-rw-r--r--lib/oneliner.c 8
-rw-r--r--lib/popup.c 8
-rw-r--r--lib/select.c 2
-rw-r--r--lib/slider.c 5
-rw-r--r--lib/tbox.c 5
-rw-r--r--lib/tooltip.c 2
-rw-r--r--lib/xpopup.c 2
21 files changed, 279 insertions, 122 deletions
diff --git a/fdesign/fd_printC.c b/fdesign/fd_printC.c
index 453c32d..492f32c 100644
--- a/fdesign/fd_printC.c
+++ b/fdesign/fd_printC.c
@@ -1601,10 +1601,10 @@ output_object( FILE * fp,
fprintf( fp, "fl_add_%s( ", class_name );
fprintf( fp, "FL_%s,", find_type_name( obj->objclass, obj->type ) );
- fakeobj.x = obj->x;
- fakeobj.y = obj->y;
- fakeobj.w = obj->w;
- fakeobj.h = obj->h;
+ fakeobj.x = obj->x;
+ fakeobj.y = obj->y;
+ fakeobj.w = obj->w;
+ fakeobj.h = obj->h;
fli_scale_object( &fakeobj, sc, sc );
label = get_label( obj, 1 );
@@ -1643,8 +1643,9 @@ output_object( FILE * fp,
fprintf( fp, " fl_set_object_lcolor( obj, %s );\n",
fli_query_colorname( obj->lcol ) );
- if ( obj->lsize != defobj->lsize )
- emit_attrib( fp, obj->lsize, vn_lsize, "fl_set_object_lsize" );
+ if ( sc * obj->lsize != defobj->lsize )
+ emit_attrib( fp, - FL_crnd(sc * obj->lsize), vn_lsize,
+ "fl_set_object_lsize" );
if ( obj->align != defobj->align )
emit_attrib( fp, obj->align, vn_align, "fl_set_object_lalign" );
diff --git a/lib/button.c b/lib/button.c
index 983836a..7bcc44f 100644
--- a/lib/button.c
+++ b/lib/button.c
@@ -499,6 +499,9 @@ fl_create_generic_button( int objclass,
obj->how_return = FL_RETURN_CHANGED;
}
+ if ( fli_cntl.buttonFontSize )
+ obj->lsize = fli_cntl.buttonFontSize;
+
sp = obj->spec = fl_calloc( 1, sizeof *sp );
sp->event = FL_DRAW;
@@ -514,9 +517,6 @@ fl_create_generic_button( int objclass,
for ( i = 0; i < 5; i++ )
sp->react_to[ i ] = 1;
- if ( fli_cntl.buttonLabelSize )
- obj->lsize = fli_cntl.buttonLabelSize;
-
return obj;
}
diff --git a/lib/chart.c b/lib/chart.c
index c301060..ca69966 100644
--- a/lib/chart.c
+++ b/lib/chart.c
@@ -621,7 +621,7 @@ fl_create_chart( int type,
sp->autosize = 1;
sp->min = sp->max = 0.0;
- sp->lsize = FL_TINY_SIZE;
+ sp->lsize = fl_adapt_to_dpi( FL_TINY_SIZE );
sp->lstyle = FL_NORMAL_STYLE;
sp->lcol = FL_BLACK;
diff --git a/lib/choice.c b/lib/choice.c
index 01b9924..6a836ba 100644
--- a/lib/choice.c
+++ b/lib/choice.c
@@ -500,7 +500,8 @@ fl_create_choice( int type,
obj = fl_make_object( FL_CHOICE, type, x, y, w, h, label, handle_choice );
- obj->boxtype = type == FL_NORMAL_CHOICE2 ? FL_UP_BOX : FL_CHOICE_BOXTYPE;
+ obj->boxtype = type == FL_NORMAL_CHOICE2 ?
+ FL_UP_BOX : FL_CHOICE_BOXTYPE;
obj->col1 = FL_CHOICE_COL1;
obj->col2 = FL_CHOICE_COL2;
obj->lcol = FL_CHOICE_LCOL;
@@ -508,8 +509,9 @@ fl_create_choice( int type,
obj->want_update = 1;
obj->spec = sp = fl_calloc( 1, sizeof *sp );
- sp->fontsize = fli_cntl.choiceFontSize ?
- fli_cntl.choiceFontSize : FL_DEFAULT_SIZE;
+ sp->fontsize = fli_cntl.choiceFontSize
+ ? fli_cntl.choiceFontSize
+ : fl_adapt_to_dpi( FL_DEFAULT_SIZE );
sp->fontstyle = FL_NORMAL_STYLE;
sp->align = FL_ALIGN_CENTER;
diff --git a/lib/colsel.c b/lib/colsel.c
index 1d5bd43..07ca39d 100644
--- a/lib/colsel.c
+++ b/lib/colsel.c
@@ -60,22 +60,44 @@ create_colorform( void )
if ( cs->colorform )
return;
- cs->colorform = fl_bgn_form( FL_UP_BOX, 240, 220 );
+ cs->colorform = fl_bgn_form( FL_UP_BOX,
+ fl_adapt_to_unit( 240 ),
+ fl_adapt_to_unit( 220 ) );
for ( i = 0; i < 8; i++ )
for ( j = 0; j < 8; j++ )
{
- cs->col[ 8 * i + j ] = fl_add_button( FL_NORMAL_BUTTON, 40 + j * 20,
- 10 + i * 20, 20, 20, "" );
+ cs->col[ 8 * i + j ] =
+ fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 40 + j * 20 ),
+ fl_adapt_to_unit( 10 + i * 20 ),
+ fl_adapt_to_unit( 20 ),
+ fl_adapt_to_unit( 20 ), "" );
fl_set_object_boxtype( cs->col[ 8 * i + j ], FL_BORDER_BOX );
fl_set_object_lcolor( cs->col[ 8 * i + j ], 7 );
}
- cs->prev = fl_add_button( FL_NORMAL_BUTTON, 10, 10, 30, 160, "@4" );
- cs->next = fl_add_button( FL_NORMAL_BUTTON, 200, 10, 30, 160, "@6" );
- cs->cancel = fl_add_button( FL_NORMAL_BUTTON, 80, 180, 140, 30, "Cancel" );
- cs->cindex = fl_add_text( FL_NORMAL_TEXT, 5, 180, 70, 30, "Cancel" );
- fl_set_object_lsize( cs->cindex,FL_TINY_SIZE );
+ cs->prev = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 10 ),
+ fl_adapt_to_unit( 10 ),
+ fl_adapt_to_unit( 30 ),
+ fl_adapt_to_unit( 160 ), "@4" );
+ cs->next = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 200 ),
+ fl_adapt_to_unit( 10 ),
+ fl_adapt_to_unit( 30 ),
+ fl_adapt_to_unit( 160 ), "@6" );
+ cs->cancel = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 80 ),
+ fl_adapt_to_unit( 180 ),
+ fl_adapt_to_unit( 140 ),
+ fl_adapt_to_unit( 30 ), "Cancel" );
+ cs->cindex = fl_add_text( FL_NORMAL_TEXT,
+ fl_adapt_to_unit( 5 ),
+ fl_adapt_to_unit( 180 ),
+ fl_adapt_to_unit( 70 ),
+ fl_adapt_to_unit( 30 ), "Cancel" );
+ fl_set_object_lsize( cs->cindex, fl_adapt_to_dpi( FL_TINY_SIZE ) );
fl_end_form( );
}
diff --git a/lib/flinternal.h b/lib/flinternal.h
index 8316a47..87794bd 100644
--- a/lib/flinternal.h
+++ b/lib/flinternal.h
@@ -198,6 +198,8 @@ void fli_scale_form( FL_FORM *,
double,
double );
+int fli_scale_size( int size );
+
void fli_handle_form( FL_FORM * form,
int event,
int key,
diff --git a/lib/flresource.c b/lib/flresource.c
index 073018e..666acd0 100644
--- a/lib/flresource.c
+++ b/lib/flresource.c
@@ -321,8 +321,7 @@ fl_set_coordunit( int u )
if ( cu == NULL )
{
- M_err( "fl_set_coordunit",
- "Invald coord unit, defaulting to \"pixel\"" );
+ M_err( __func__, "Invald coord unit, defaulting to \"pixel\"" );
u = FL_COORD_PIXEL;
cu = "pixel";
}
@@ -1142,8 +1141,13 @@ fl_initialize( int * na,
if ( xdpi / ydpi > 1.05 || ydpi / xdpi < 0.95 )
M_warn( "fl_initialize", "NonSquarePixel %.1f %.1f", xdpi, ydpi );
- fl_dpi = ( xdpi + ydpi ) / 2;
- fl_dpi = FL_nint( fl_dpi * 10.0 + 0.5 ) * 0.1;
+ fl_dpi = FL_nint( FL_nint( 10 * ( xdpi + ydpi ) / 2 ) / 10.0 );
+
+// char const * x = getenv("DPI");
+// if (x)
+// sscanf( x, "%lf", &fl_dpi );
+//
+// printf( "screen DPI = %f", fl_dpi );
M_info( "fl_initialize", "screen DPI = %f", fl_dpi );
diff --git a/lib/fonts.c b/lib/fonts.c
index ba3dec5..9778cf3 100644
--- a/lib/fonts.c
+++ b/lib/fonts.c
@@ -137,7 +137,7 @@ fli_init_font( void )
defaultfs = XLoadQueryFont( flx->display, DEFAULTF2 );
/* Load a couple of fonts at normal size to prevent the caching code from
- using bad looking replacement if strange sizes are requested */
+ using bad looking replacements if strange sizes are requested */
fl_get_font_struct( FL_NORMAL_STYLE, FL_DEFAULT_SIZE );
fl_get_font_struct( FL_BOLD_STYLE, FL_DEFAULT_SIZE );
@@ -165,7 +165,7 @@ fl_set_font( int numb,
if ( fl_state[ fl_vmode ].cur_fnt == fs )
{
#if FL_DEBUG >= ML_DEBUG
- M_debug( "fl_set_font", "current", fli_curfnt );
+ M_debug( __func__, "current", fli_curfnt );
#endif
return;
}
@@ -185,7 +185,7 @@ fl_set_font( int numb,
unsigned long res = 0;
if ( XGetFontProperty( flx->fs, XA_RESOLUTION, &res ) )
- M_info2( "fl_set_font", "FontResolution: %lu", res );
+ M_info2( __func__, "FontResolution: %lu", res );
}
}
@@ -204,19 +204,19 @@ fl_set_font_name( int n,
if ( n < 0 || n >= FL_MAXFONTS )
{
- M_warn( "fl_set_font_name", "Bad font number (%d)", n );
+ M_warn( __func__, "Bad font number (%d)", n );
return -1;
}
if ( ! name || ! *name )
{
- M_warn( "fl_set_font_name", "Bad font name" );
+ M_warn( __func__, "Bad font name" );
return -1;
}
if ( strlen( name ) > FL_MAX_FONTNAME_LENGTH )
{
- M_warn( "fl_set_font_name", "Font name too long" );
+ M_warn( __func__, "Font name too long" );
return -1;
}
@@ -300,8 +300,8 @@ fl_enumerate_fonts( void ( * output )( const char *s ),
/***************************************
* All font changes go through this routine. If with_fail is false,
- * this routine will not fail even if requested font can't be loaded.
- * A substitution will be made.
+ * this routine will not fail even if the requested font can't be
+ * loaded: a substitution will be made.
***************************************/
static XFontStruct *
@@ -321,8 +321,7 @@ try_get_font_struct( int numb,
if ( size <= 0 )
{
- M_info( "try_get_font_struct",
- "Bad font size requested (%d), using %d istead",
+ M_info( __func__, "Bad font size requested (%d), using %d istead",
size, size < 0 ? -size : 1 );
size = size < 0 ? -size : 1;
}
@@ -337,12 +336,12 @@ try_get_font_struct( int numb,
loadable or not, so it's not a fatal error if it fails. Issue
a message for information therefore. */
- M_info( "try_get_font_struct", "Bad FontStyle requested: %d: %s",
+ M_info( __func__, "Bad FontStyle requested: %d: %s",
numb, flf->fname );
}
if ( ! fl_state[ fl_vmode ].cur_fnt )
- M_warn( "try_get_font_struct", "bad font returned" );
+ M_warn( __func__, "bad font returned" );
return fl_state[ fl_vmode ].cur_fnt;
}
@@ -377,7 +376,7 @@ try_get_font_struct( int numb,
if ( with_fail )
return NULL;
- M_warn( "try_get_font_struct", "Can't load %s, using subsitute",
+ M_warn( __func__, "Can't load %s, using subsitute",
fli_curfnt );
/* Search for a replacement with the nearest size */
diff --git a/lib/fselect.c b/lib/fselect.c
index c74e701..76c99a1 100644
--- a/lib/fselect.c
+++ b/lib/fselect.c
@@ -1171,21 +1171,29 @@ create_form_fselect( void )
{
FL_OBJECT *obj;
int oldy = fli_inverted_y;
- int oldunit = fl_get_coordunit( );
fli_inverted_y = 0;
- fl_set_coordunit( FL_COORD_PIXEL );
- fs->fselect = fl_bgn_form( FL_FLAT_BOX, 305, 330 );
+ fs->fselect = fl_bgn_form( FL_FLAT_BOX,
+ fl_adapt_to_unit( 305 ),
+ fl_adapt_to_unit( 330 ) );
- fs->dirlabel = obj = fl_add_text( FL_NORMAL_TEXT, 12, 15, 64, 24,
+ fs->dirlabel = obj = fl_add_text( FL_NORMAL_TEXT,
+ fl_adapt_to_unit( 12 ),
+ fl_adapt_to_unit( 15 ),
+ fl_adapt_to_unit( 64 ),
+ fl_adapt_to_unit( 24 ),
"D010円irectory" );
fl_set_object_boxtype( obj, FL_FRAME_BOX );
fl_set_object_lalign( obj, FL_ALIGN_CENTER );
fl_set_object_resize( obj, FL_RESIZE_NONE );
fl_set_object_gravity( obj, FL_NorthWest, FL_NorthWest );
- fs->dirbutt = obj = fl_add_button( FL_NORMAL_BUTTON, 76, 15, 217, 24, "" );
+ fs->dirbutt = obj = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 76 ),
+ fl_adapt_to_unit( 15 ),
+ fl_adapt_to_unit( 217 ),
+ fl_adapt_to_unit( 24 ), "" );
fl_set_button_shortcut( obj, "#D#d", 1 );
fl_set_object_boxtype( obj, FL_FRAME_BOX );
fl_set_object_lalign( obj, fl_to_inside_lalign( FL_ALIGN_LEFT ) );
@@ -1193,47 +1201,75 @@ create_form_fselect( void )
fl_set_object_gravity( obj, FL_NorthWest, FL_NorthEast );
fl_set_object_callback( obj, directory_cb, 0 );
- fs->patlabel = obj = fl_add_text( FL_NORMAL_TEXT, 12, 41, 64, 24,
+ fs->patlabel = obj = fl_add_text( FL_NORMAL_TEXT,
+ fl_adapt_to_unit( 12 ),
+ fl_adapt_to_unit( 41 ),
+ fl_adapt_to_unit( 64 ),
+ fl_adapt_to_unit( 24 ),
"P010円attern" );
fl_set_object_boxtype( obj, FL_FRAME_BOX );
fl_set_object_lalign( obj, FL_ALIGN_CENTER );
fl_set_object_resize( obj, FL_RESIZE_NONE );
fl_set_object_gravity( obj, FL_NorthWest, FL_NorthWest );
- fs->patbutt = obj = fl_add_button( FL_NORMAL_BUTTON, 76, 41, 217, 24, "" );
+ fs->patbutt = obj = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 76 ),
+ fl_adapt_to_unit( 41 ),
+ fl_adapt_to_unit( 217 ),
+ fl_adapt_to_unit( 24 ), "" );
fl_set_button_shortcut( obj, "#P#p", 1 );
fl_set_object_boxtype( obj, FL_FRAME_BOX );
fl_set_object_resize( obj, FL_RESIZE_X );
fl_set_object_gravity( obj, FL_NorthWest, FL_NorthEast );
fl_set_object_callback( obj, pattern_cb, 0 );
- fs->resbutt = obj = fl_add_button( FL_NORMAL_BUTTON, 210, 80, 83, 28,
+ fs->resbutt = obj = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 210 ),
+ fl_adapt_to_unit( 80 ),
+ fl_adapt_to_unit( 83 ),
+ fl_adapt_to_unit( 28 ),
"Rescan" );
fl_set_button_shortcut( obj, "#R#r", 1 );
fl_set_object_resize( obj, FL_RESIZE_NONE );
fl_set_object_gravity( obj, FL_NorthEast, FL_NorthEast );
fl_set_object_callback( obj, rescan_cb, 0 );
- fs->cancel = obj = fl_add_button( FL_NORMAL_BUTTON, 210, 203, 83, 28,
+ fs->cancel = obj = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 210 ),
+ fl_adapt_to_unit( 203 ),
+ fl_adapt_to_unit( 83 ),
+ fl_adapt_to_unit( 28 ),
"Cancel" );
fl_set_button_shortcut( obj, "#C#c^[", 1 );
fl_set_object_color( obj, FL_COL1, FL_GREEN );
fl_set_object_resize( obj, FL_RESIZE_NONE );
fl_set_object_gravity( obj, FL_SouthEast, FL_SouthEast );
- fs->ready = obj = fl_add_button( FL_RETURN_BUTTON, 210, 233, 83, 28,
+ fs->ready = obj = fl_add_button( FL_RETURN_BUTTON,
+ fl_adapt_to_unit( 210 ),
+ fl_adapt_to_unit( 233 ),
+ fl_adapt_to_unit( 83 ),
+ fl_adapt_to_unit( 28 ),
"Ready" );
fl_set_object_color( obj, FL_COL1, FL_GREEN );
fl_set_object_resize( obj, FL_RESIZE_NONE );
fl_set_object_gravity( obj, FL_SouthEast, FL_SouthEast );
- fs->prompt = obj = fl_add_text( FL_NORMAL_TEXT, 20, 270, 264, 18,
+ fs->prompt = obj = fl_add_text( FL_NORMAL_TEXT,
+ fl_adapt_to_unit( 20 ),
+ fl_adapt_to_unit( 270 ),
+ fl_adapt_to_unit( 264 ),
+ fl_adapt_to_unit( 18 ),
"File name:" );
fl_set_object_lalign( obj, fl_to_inside_lalign( FL_ALIGN_LEFT ) );
fl_set_object_resize( obj, FL_RESIZE_NONE );
fl_set_object_gravity( obj, FL_SouthWest, FL_SouthWest );
- fs->input = obj = fl_add_input( FL_NORMAL_INPUT, 30, 290, 235, 27, "" );
+ fs->input = obj = fl_add_input( FL_NORMAL_INPUT,
+ fl_adapt_to_unit( 30 ),
+ fl_adapt_to_unit( 290 ),
+ fl_adapt_to_unit( 235 ),
+ fl_adapt_to_unit( 27 ), "" );
fl_set_object_boxtype( obj, FL_SHADOW_BOX );
fl_set_object_color( obj, FL_WHITE, FL_WHITE );
fl_set_object_resize( obj, FL_RESIZE_X );
@@ -1241,7 +1277,11 @@ create_form_fselect( void )
fl_set_object_callback( obj, input_cb, 0 );
fl_set_object_return( obj, FL_RETURN_CHANGED );
- fs->browser = obj = fl_add_browser( FL_HOLD_BROWSER, 15, 80, 185, 180, "" );
+ fs->browser = obj = fl_add_browser( FL_HOLD_BROWSER,
+ fl_adapt_to_unit( 15 ),
+ fl_adapt_to_unit( 80 ),
+ fl_adapt_to_unit( 185 ),
+ fl_adapt_to_unit( 180 ), "" );
fl_set_object_callback( obj, select_cb, 0 );
fl_set_browser_dblclick_callback( obj, select_cb, 1 );
fl_set_object_resize( obj, FL_RESIZE_ALL );
@@ -1250,9 +1290,21 @@ create_form_fselect( void )
fs->appbuttgrp = fl_bgn_group( );
- fs->appbutt[ 0 ] = fl_add_button( FL_NORMAL_BUTTON, 210, 114, 83, 28, "" );
- fs->appbutt[ 1 ] = fl_add_button( FL_NORMAL_BUTTON, 210, 142, 83, 28, "" );
- fs->appbutt[ 2 ] = fl_add_button( FL_NORMAL_BUTTON, 210, 170, 83, 28, "" );
+ fs->appbutt[ 0 ] = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 210 ),
+ fl_adapt_to_unit( 114 ),
+ fl_adapt_to_unit( 83 ),
+ fl_adapt_to_unit( 28 ), "" );
+ fs->appbutt[ 1 ] = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 210 ),
+ fl_adapt_to_unit( 142 ),
+ fl_adapt_to_unit( 83 ),
+ fl_adapt_to_unit( 28 ), "" );
+ fs->appbutt[ 2 ] = fl_add_button( FL_NORMAL_BUTTON,
+ fl_adapt_to_unit( 210 ),
+ fl_adapt_to_unit( 170 ),
+ fl_adapt_to_unit( 83 ),
+ fl_adapt_to_unit( 28 ), "" );
fl_end_group( );
@@ -1264,7 +1316,6 @@ create_form_fselect( void )
fl_set_form_atclose( fs->fselect, fl_goodies_atclose, fs->cancel );
fli_inverted_y = oldy;
- fl_set_coordunit( oldunit );
/* These labels sometimes don't fit the above set sizes, so we
resize the whole file selector box to make them fit */
diff --git a/lib/goodies.c b/lib/goodies.c
index 4503979..a3e1551 100644
--- a/lib/goodies.c
+++ b/lib/goodies.c
@@ -29,7 +29,6 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-
#include "include/forms.h"
#include "flinternal.h"
#include "bitmaps/q.xbm" /* in directory bitmaps */
diff --git a/lib/include/Basic.h b/lib/include/Basic.h
index e4b106a..544396b 100644
--- a/lib/include/Basic.h
+++ b/lib/include/Basic.h
@@ -1633,5 +1633,10 @@ typedef const char * ( * FL_VAL_FILTER )( FL_OBJECT *,
FL_EXPORT int fl_is_same_object( FL_OBJECT * obj1,
FL_OBJECT * obj2 );
+FL_EXPORT FL_COORD fl_adapt_to_dpi( FL_COORD size );
+
+FL_EXPORT FL_COORD fal_adapt_to_unit( FL_COORD size );
+
+
#endif /* ! defined FL_BASIC_H */
diff --git a/lib/input.c b/lib/input.c
index 149694a..15c4601 100644
--- a/lib/input.c
+++ b/lib/input.c
@@ -1729,8 +1729,6 @@ fl_create_input( int type,
obj->col2 = FL_INPUT_COL2;
obj->align = FL_INPUT_ALIGN;
obj->lcol = FL_INPUT_LCOL;
- obj->lsize = fli_cntl.inputFontSize ?
- fli_cntl.inputFontSize : FL_DEFAULT_SIZE;
obj->set_return = fl_set_input_return;
fl_set_object_prehandler( obj, input_pre );
@@ -1742,6 +1740,8 @@ fl_create_input( int type,
obj->input = 1;
obj->click_timeout = FL_CLICK_TIMEOUT;
obj->spec = sp = fl_calloc( 1, sizeof *sp );
+ if ( fli_cntl.inputFontSize )
+ obj->lsize = fli_cntl.inputFontSize;
sp->textcol = FL_INPUT_TCOL;
sp->curscol = FL_INPUT_CCOL;
diff --git a/lib/menu.c b/lib/menu.c
index f689d93..62540a3 100644
--- a/lib/menu.c
+++ b/lib/menu.c
@@ -364,6 +364,8 @@ fl_create_menu( int type,
obj->col2 = FL_MENU_COL2;
obj->lcol = FL_MENU_LCOL;
obj->lstyle = FL_NORMAL_STYLE;
+ if ( fli_cntl.menuFontSize )
+ obj->lsize = fli_cntl.menuFontSize;
obj->align = FL_MENU_ALIGN;
if ( type == FL_TOUCH_MENU )
diff --git a/lib/objects.c b/lib/objects.c
index 4aa3a99..a40bb85 100644
--- a/lib/objects.c
+++ b/lib/objects.c
@@ -185,54 +185,35 @@ fl_make_object( int objclass,
fli_cntl.coordUnit = FL_COORD_PIXEL;
}
- obj->wantkey = FL_KEY_NORMAL;
-
- obj->flpixmap = NULL;
- obj->label = fl_strdup( label ? label : "" );
- obj->handle = handle;
- obj->align = FL_ALIGN_CENTER;
- obj->lcol = FL_BLACK;
- obj->col1 = FL_COL1;
- obj->col2 = FL_MCOL;
-
- if ( IS_BUTTON_CLASS( objclass ) && fli_cntl.buttonFontSize )
- obj->lsize = fli_cntl.buttonFontSize;
- else if ( objclass == FL_MENU && fli_cntl.menuFontSize )
- obj->lsize = fli_cntl.menuFontSize;
- else if ( ( objclass == FL_CHOICE || objclass == FL_SELECT )
- && fli_cntl.choiceFontSize )
- obj->lsize = fli_cntl.choiceFontSize;
- else if ( objclass == FL_INPUT && fli_cntl.inputFontSize )
- obj->lsize = fli_cntl.inputFontSize;
- else if ( objclass == FL_SLIDER && fli_cntl.sliderFontSize )
- obj->lsize = fli_cntl.sliderFontSize;
-#if 0
- else if ( objclass == FL_BROWSER && fli_cntl.browserFontSize )
- obj->lsize = fli_cntl.browserFontSize;
-#endif
- else if ( fli_cntl.labelFontSize )
- obj->lsize = fli_cntl.labelFontSize;
- else
- obj->lsize = FL_DEFAULT_SIZE;
-
- obj->lstyle = FL_NORMAL_STYLE;
- obj->shortcut = fl_calloc( 1, sizeof *obj->shortcut );
- *obj->shortcut = 0;
- obj->active = 1;
- obj->visible = FL_VISIBLE;
- obj->object_callback = NULL;
- obj->spec = NULL;
- obj->next = obj->prev = NULL;
- obj->form = NULL;
- obj->dbl_background = FL_COL1;
- obj->parent = NULL;
- obj->child = NULL;
- obj->nc = NULL;
- obj->group_id = 0;
- obj->set_return = NULL;
- obj->how_return = FL_RETURN_ALWAYS;
- obj->returned = 0;
- obj->is_under = 0;
+ obj->wantkey = FL_KEY_NORMAL;
+ obj->flpixmap = NULL;
+ obj->label = fl_strdup( label ? label : "" );
+ obj->handle = handle;
+ obj->align = FL_ALIGN_CENTER;
+ obj->lcol = FL_BLACK;
+ obj->col1 = FL_COL1;
+ obj->col2 = FL_MCOL;
+ obj->lsize = fli_cntl.labelFontSize
+ ? fli_cntl.labelFontSize
+ : fl_adapt_to_dpi( FL_DEFAULT_SIZE );
+ obj->lstyle = FL_NORMAL_STYLE;
+ obj->shortcut = fl_calloc( 1, sizeof *obj->shortcut );
+ *obj->shortcut = 0;
+ obj->active = 1;
+ obj->visible = FL_VISIBLE;
+ obj->object_callback = NULL;
+ obj->spec = NULL;
+ obj->next = obj->prev = NULL;
+ obj->form = NULL;
+ obj->dbl_background = FL_COL1;
+ obj->parent = NULL;
+ obj->child = NULL;
+ obj->nc = NULL;
+ obj->group_id = 0;
+ obj->set_return = NULL;
+ obj->how_return = FL_RETURN_ALWAYS;
+ obj->returned = 0;
+ obj->is_under = 0;
return obj;
}
@@ -1197,7 +1178,10 @@ fl_get_object_lcol( FL_OBJECT * obj )
/***************************************
- * Sets the label's text size of an object
+ * Sets the label's text size of an object. Note: if the size
+ * is negative the current screen resolution is taken into
+ * account, i.e., it's assumed that the font size is in units
+ * of the currently set unit (with fl_set_coordunit()).
***************************************/
void
@@ -1216,6 +1200,9 @@ fl_set_object_lsize( FL_OBJECT * obj,
if ( obj->objclass != FL_BEGIN_GROUP && obj->lsize == lsize )
return;
+ if ( lsize < 0 )
+ lsize = fli_scale_size( - lsize );
+
/* For objects that have their label on the outside (or that are
transparent) we hide the object and, after setting the new label font
size, re-show them in order to get everything beneath them redrawn */
@@ -2960,8 +2947,8 @@ fli_combine_rectangles( FL_RECT * r1,
* taken into account. The calculation takes care of rounding errors
* and has the property that if two objects were "glued" together be-
* fore scaling they will remain so. The function also doesn't re-
- * calculates intersection between objects, this has to be done by the
- * caller if necessary.
+ * calculates intersection between objects, this has to be done by
+ * the caller if necessary.
***************************************/
void
@@ -3010,6 +2997,83 @@ fli_scale_object( FL_OBJECT * obj,
/***************************************
+ ***************************************/
+
+int
+fli_scale_size( int size )
+{
+ switch ( fli_cntl.coordUnit )
+ {
+ case FL_COORD_MM :
+ return FL_nint( size * fl_dpi / 25.4 );
+
+ case FL_COORD_POINT :
+ return FL_nint( size * fl_dpi / 72.0 );
+
+ case FL_COORD_centiPOINT :
+ return FL_nint( size * fl_dpi / 7200.0 );
+
+ case FL_COORD_centiMM :
+ return FL_nint( size * fl_dpi / 2540.0 );
+ }
+
+ return size;
+}
+
+
+/***************************************
+ * Converts a size for the current DPI screen resolution
+ * assuming the input value is from a design with 96 DPI.
+ * Used for convertung font sizes.
+ ***************************************/
+
+FL_COORD
+fl_adapt_to_dpi( FL_COORD size )
+{
+ switch ( fli_cntl.coordUnit )
+ {
+ case FL_COORD_MM :
+ case FL_COORD_POINT :
+ case FL_COORD_centiPOINT :
+ case FL_COORD_centiMM :
+ return FL_crnd( fl_dpi * size / 96.0 );
+
+ default :
+ return size;
+ }
+}
+
+
+/***************************************
+ * Converts a size to what's needed with the currently set
+ * unit and the actual screen DPI, assuming the orginal
+ * design resolution was 96 DPI.
+ * Used for converting object positions and sizes.
+ ***************************************/
+
+FL_COORD
+fl_adapt_to_unit( FL_COORD size )
+{
+ switch ( fli_cntl.coordUnit )
+ {
+ case FL_COORD_MM :
+ return FL_crnd( size * 25.4 / 96.0 );
+
+ case FL_COORD_POINT :
+ return FL_crnd( size * 72.0 / 96.0 );
+
+ case FL_COORD_centiPOINT :
+ return FL_crnd( size * 7200.0 / 96.0 );
+
+ case FL_COORD_centiMM :
+ return FL_crnd( size * 2540.0 / 96.0 );
+ }
+
+ return size;
+}
+
+
+/***************************************
* Register a preemptive object handler
***************************************/
diff --git a/lib/oneliner.c b/lib/oneliner.c
index 659f11b..792625d 100644
--- a/lib/oneliner.c
+++ b/lib/oneliner.c
@@ -55,8 +55,8 @@ create_it( void )
text = fl_add_box( FL_BORDER_BOX, 0, 0, 5, 5, "" );
- fl_set_object_lstyle( text, fntstyle );
- fl_set_object_lsize( text, fntsize );
+ fl_set_object_lstyle( text, fl_adapt_to_dpi( fntstyle ) );
+ fl_set_object_lsize( text, fl_adapt_to_dpi( fntsize ) );
fl_set_object_lcolor( text, textcolor );
fl_set_object_color( text, background, background );
fl_end_form( );
@@ -81,8 +81,8 @@ fl_show_oneliner( const char * s,
fl_get_string_dimension( fntstyle, fntsize, s, strlen( s ), &w, &h );
- w += ( 2 * fntsize ) / 3;
- h += ( 2 * fntsize ) / 3;
+ w += fl_adapt_to_dpi( ( 2 * fntsize ) / 3 );
+ h += fl_adapt_to_dpi( ( 2 * fntsize ) / 3 );
fl_freeze_form( oneliner );
fl_set_form_geometry( oneliner, x, y, w, h );
diff --git a/lib/popup.c b/lib/popup.c
index 69667c8..76bc115 100644
--- a/lib/popup.c
+++ b/lib/popup.c
@@ -4327,11 +4327,11 @@ fli_popup_init( void )
popup_title_font_style = FL_EMBOSSED_STYLE;
#ifdef __sgi
- popup_entry_font_size = FL_SMALL_SIZE,
- popup_title_font_size = FL_SMALL_SIZE;
+ popup_entry_font_size = fl_adapt_to_dpi( FL_SMALL_SIZE ),
+ popup_title_font_size = fl_adapt_to_dpi( FL_SMALL_SIZE );
#else
- popup_entry_font_size = FL_NORMAL_SIZE;
- popup_title_font_size = FL_NORMAL_SIZE;
+ popup_entry_font_size = fl_adapt_to_dpi( FL_NORMAL_SIZE );
+ popup_title_font_size = fl_adapt_to_dpi( FL_NORMAL_SIZE );
#endif
popup_bg_color = FL_MCOL;
diff --git a/lib/select.c b/lib/select.c
index 66a49ce..d895f84 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -72,7 +72,7 @@ fl_create_select( int type,
sp->sel = NULL;
sp->align = FL_ALIGN_CENTER;
sp->style = FL_NORMAL_STYLE;
- sp->size = FL_NORMAL_SIZE;
+ sp->size = fl_adapt_to_dpi( FL_NORMAL_SIZE );
sp->color = FL_BLACK;
sp->timeout_id = -1;
sp->repeat_ms = 500;
diff --git a/lib/slider.c b/lib/slider.c
index 53e3f47..e8a83ba 100644
--- a/lib/slider.c
+++ b/lib/slider.c
@@ -800,8 +800,11 @@ create_slider( int objclass,
ob->col2 = FL_SLIDER_COL2;
ob->align = FL_SLIDER_ALIGN;
ob->lcol = FL_SLIDER_LCOL;
- ob->lsize = FL_TINY_SIZE;
ob->spec = sp = fl_calloc( 1, sizeof *sp );
+ ob->lsize = fli_cntl.sliderFontSize
+ ? fli_cntl.sliderFontSize
+ : fl_adapt_to_dpi( FL_TINY_SIZE );
+
sp->min = 0.0;
sp->max = 1.0;
sp->val = sp->start_val = 0.5;
diff --git a/lib/tbox.c b/lib/tbox.c
index 23b3e22..c8e7c96 100644
--- a/lib/tbox.c
+++ b/lib/tbox.c
@@ -93,8 +93,9 @@ fli_create_tbox( int type,
sp->yoffset = 0;
sp->max_width = 0;
sp->max_height = 0;
- sp->def_size = fli_cntl.browserFontSize ?
- fli_cntl.browserFontSize : FLI_TBOX_FONTSIZE;
+ sp->def_size = fli_cntl.browserFontSize
+ ? fli_cntl.browserFontSize
+ : fl_adapt_to_dpi( FLI_TBOX_FONTSIZE );
sp->def_style = FL_NORMAL_STYLE;
sp->def_align = FL_ALIGN_LEFT;
sp->def_height = 0;
diff --git a/lib/tooltip.c b/lib/tooltip.c
index c8ba8e5..c009a64 100644
--- a/lib/tooltip.c
+++ b/lib/tooltip.c
@@ -65,7 +65,7 @@ create_it( void )
tip = fl_calloc( 1, sizeof *tip );
tip->fntstyle = FL_NORMAL_STYLE;
- tip->fntsize = FL_DEFAULT_SIZE;
+ tip->fntsize = fl_adapt_to_dpi( FL_DEFAULT_SIZE );
tip->boxtype = FL_BORDER_BOX;
tip->lalign = fl_to_inside_lalign( FL_ALIGN_LEFT );
tip->textcolor = FL_BLACK;
diff --git a/lib/xpopup.c b/lib/xpopup.c
index e9629e6..fe6d0d6 100644
--- a/lib/xpopup.c
+++ b/lib/xpopup.c
@@ -166,6 +166,7 @@ init_pupfont( void )
if ( ! pup_title_font_struct )
{
+ pup_title_font_size = fl_adapt_to_dpi( pup_title_font_size );
pup_title_font_struct = fl_get_fntstruct( pup_title_font_style,
pup_title_font_size );
XTextExtents( pup_title_font_struct, "qjQb", 4, &junk,
@@ -174,6 +175,7 @@ init_pupfont( void )
if ( ! pup_font_struct )
{
+ pup_font_size = fl_adapt_to_dpi( pup_font_size );
pup_font_struct = fl_get_fntstruct( pup_font_style, pup_font_size );
XTextExtents( pup_font_struct, "qjQb", 4, &junk, &pup_ascent,
&pup_desc, &chs );
generated by cgit v1.2.3 (git 2.25.1) at 2025年11月25日 06:18:45 +0000

AltStyle によって変換されたページ (->オリジナル) /