MacArthur, Ian (SELEX GALILEO, UK) wrote:
>
>> It's a question to behave consistently if we scale/zooned the widgets
>> size/position we should as well do the same with it's font size.
>
> Why?
> The behaviour you describe is consistent, and is pretty much what every
> toolkit does. Indeed, I can't, off-hand, think of any that scale label
> font sizes as their containing widgets change size, though I guess a few
> do allow that as a (non-default) optional behaviour?
>
>
> The setting of font sizes is predominantly an accessibility issue, not a
> simple cosmetic one, so changing the selected font size is seldom a wise
> choice.
> I know some users who will rant and roar if your change their font
> settings in any way (particularly folk using screen readers, or with
> poor eyesight, for example.)
>
> <note>
> That said, the default font settings in fltk are too small on some
> modern high-DPI displays, so some means of setting the default font
> appropriately is probably useful.
>
> At present, in code where I care about the minimum font size, I attempt
> to do this by trying to determine the display DPI at app start-up, then
> I overwrite the global fontsize setting held in FL_NORMAL_SIZE (which
> looks like a define, but is actually a global var originating in
> Fl_Widget.cxx)
>
> E.g.
>
>       /** Change Default font size for widgets */
>       extern Fl_Fontsize FL_NORMAL_SIZE;
>               :
>               :
>       my_new_size = 14;
>               :
>               :
>       // find the display DPI...
>       my_new_size =<whatever...>;
>               :
>               :
>       FL_NORMAL_SIZE = my_new_size;
>               :
>       // now create my widgets...
>               :
>
> The default value for FL_NORMAL_SIZE is 14, but you can change it.
> I always change it *before* creating any widgets though - I do not know
> if changing it will dynamically scale the widget font sizes...
> </note>
>
> However, making the font smaller (or bigger) because the button is
> shrinking (growing) - that I am not convinced by at all.
>
> Or - am I not understanding what you are suggesting?
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
> 3EL
> A company registered in England&  Wales.  Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>

Probably you didn't understand what my concern and probably didn't you 
have tried what I proposed.

Try this:

Open test/input.cxx and add this line to it:

   window->resizable(window);
   window->show(argc,argv);  ///// this is a new line to be added
   return Fl::run();

Compile and run it type something on all input fields, resize to full 
screen and after that resize it to 1/3 of the original one.


After that try this one and to the same when running it, I mean type 
something on input fields and resize, and tell me if you can understand by :

 >
 >> It's a question to behave consistently if we scale/zooned the widgets
 >> size/position we should as well do the same with it's font size.
 >

-------------------------
//
// "$Id: input.cxx 6777 2009-04-23 15:32:19Z matt $"
//
// Input field test program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2009 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
//     http://www.fltk.org/str.php
//

#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Float_Input.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Secret_Input.H>
#include <FL/Fl_Multiline_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Color_Chooser.H>
#include <vector>

void cb(Fl_Widget *ob) {
   printf("Callback for %s '%s'\n",ob->label(),((Fl_Input*)ob)->value());
}

int when = 0;

int intial_height = 0;
Fl_Fontsize initial_font_size = 14;
Fl_Input *input[5];

void toggle_cb(Fl_Widget *o, long v) {
   if (((Fl_Toggle_Button*)o)->value()) when |= v; else when &= ~v;
   for (int i=0; i<5; i++) input[i]->when(when);
}

void test(Fl_Input *i) {
   if (i->changed()) {
     i->clear_changed(); printf("%s '%s'\n",i->label(),i->value());
     char utf8buf[10];
     int last = fl_utf8encode(i->index(i->position()), utf8buf);
     utf8buf[last] = 0;
     printf("Symbol at cursor position: %s\n", utf8buf);
   }
}

void button_cb(Fl_Widget *,void *) {
   for (int i=0; i<5; i++) test(input[i]);
}

void color_cb(Fl_Widget* button, void* v) {
   Fl_Color c;
   switch ((long)v) {
   case 0: c = FL_BACKGROUND2_COLOR; break;
   case 1: c = FL_SELECTION_COLOR; break;
   default: c = FL_FOREGROUND_COLOR; break;
   }
   uchar r,g,b; Fl::get_color(c, r,g,b);
   if (fl_color_chooser(0,r,g,b)) {
     Fl::set_color(c,r,g,b); Fl::redraw();
     button->labelcolor(fl_contrast(FL_BLACK,c));
     button->redraw();
   }
}

class Resizable_Window : public Fl_Double_Window {
public:
        Resizable_Window(int X, int Y, int W, int H, const char *L = 
0):Fl_Double_Window(X, Y, W, H, L) {};
   Resizable_Window(int W, int H, const char *L = 0):Fl_Double_Window(W, 
H, L) {};
public:
   void resize(int x, int y, int w, int h);
};

void Resizable_Window::resize(int x, int y, int w, int h) {

     float hratio = h / (float)(intial_height); // root height
     //float wratio = w / (float)tmp.w;

     for(unsigned i=0; i < 5; i++)
     {
         input[i]->labelsize( initial_font_size * hratio);
         input[i]->textsize( initial_font_size * hratio);
     }
     Fl_Double_Window::resize(x,y,w,h);
}


int main(int argc, char **argv) {
   // the following two lines set the correct color scheme, so that
   // calling fl_contrast below will return good results
   Fl::args(argc, argv);
   Fl::get_system_colors();
   intial_height = 400;
   Resizable_Window *window = new Resizable_Window(400,intial_height);

   int y = 10;
   input[0] = new Fl_Input(70,y,300,30,"Normal:"); y += 35;
   input[0]->tooltip("Normal input field");
   // input[0]->cursor_color(FL_SELECTION_COLOR);
   // input[0]->maximum_size(20);
   // input[0]->static_value("this is a testgarbage");
   input[1] = new Fl_Float_Input(70,y,300,30,"Float:"); y += 35;
   input[1]->tooltip("Input field for floating-point number (F1)");
   input[1]->shortcut(FL_F+1);
   input[2] = new Fl_Int_Input(70,y,300,30,"Int:"); y += 35;
   input[2]->tooltip("Input field for integer number (F2)");
   input[2]->shortcut(FL_F+2);
   input[3] = new Fl_Secret_Input(70,y,300,30,"&Secret:"); y += 35;
   input[3]->tooltip("Input field for password (Alt-S)");
   input[4] = new Fl_Multiline_Input(70,y,300,100,"&Multiline:"); y += 105;
   input[4]->tooltip("Input field for short text with newlines (Alt-M)");
   input[4]->wrap(1);

   for (int i = 0; i < 4; i++) {
     input[i]->when(0); input[i]->callback(cb);
   }
   int y1 = y;

   Fl_Button *b;
   b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_CHANGED");
   b->callback(toggle_cb, FL_WHEN_CHANGED); y += 25;
   b->tooltip("Do callback each time the text changes");
   b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_RELEASE");
   b->callback(toggle_cb, FL_WHEN_RELEASE); y += 25;
   b->tooltip("Do callback when widget loses focus");
   b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_ENTER_KEY");
   b->callback(toggle_cb, FL_WHEN_ENTER_KEY); y += 25;
   b->tooltip("Do callback when user hits Enter key");
   b = new Fl_Toggle_Button(10,y,200,25,"FL_WHEN_NOT_CHANGED");
   b->callback(toggle_cb, FL_WHEN_NOT_CHANGED); y += 25;
   b->tooltip("Do callback even if the text is not changed");
   y += 5;
   b = new Fl_Button(10,y,200,25,"&print changed()");
   b->callback(button_cb);
   b->tooltip("Print widgets that have changed() flag set");

   b = new Fl_Button(220,y1,100,25,"color"); y1 += 25;
   b->color(input[0]->color()); b->callback(color_cb, (void*)0);
   b->tooltip("Color behind the text");
   b = new Fl_Button(220,y1,100,25,"selection_color"); y1 += 25;
   b->color(input[0]->selection_color()); b->callback(color_cb, (void*)1);
   b->labelcolor(fl_contrast(FL_BLACK,b->color()));
   b->tooltip("Color behind selected text");
   b = new Fl_Button(220,y1,100,25,"textcolor"); y1 += 25;
   b->color(input[0]->textcolor()); b->callback(color_cb, (void*)2);
   b->labelcolor(fl_contrast(FL_BLACK,b->color()));
   b->tooltip("Color of the text");

   window->end();
   window->resizable(window);
   window->show(argc,argv);
   return Fl::run();
}

//
// End of "$Id: input.cxx 6777 2009-04-23 15:32:19Z matt $".
//

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to