Skip to content

Commit

Permalink
First attempt at consistently using Fl_Font as a type for the font in…
Browse files Browse the repository at this point in the history
…dex and Fl_Font_Size as a type to measure font height (or rather size).

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6113 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Apr 23, 2008
1 parent 88c0d72 commit 7c8f5cc
Show file tree
Hide file tree
Showing 46 changed files with 204 additions and 190 deletions.
49 changes: 26 additions & 23 deletions FL/Enumerations.H
Expand Up @@ -287,30 +287,33 @@ enum Fl_Align { // align() values
FL_ALIGN_NOWRAP = 0 // for back compatability
};

enum Fl_Font { // standard fonts
FL_HELVETICA = 0,
FL_HELVETICA_BOLD,
FL_HELVETICA_ITALIC,
FL_HELVETICA_BOLD_ITALIC,
FL_COURIER,
FL_COURIER_BOLD,
FL_COURIER_ITALIC,
FL_COURIER_BOLD_ITALIC,
FL_TIMES,
FL_TIMES_BOLD,
FL_TIMES_ITALIC,
FL_TIMES_BOLD_ITALIC,
FL_SYMBOL,
FL_SCREEN,
FL_SCREEN_BOLD,
FL_ZAPF_DINGBATS,

FL_FREE_FONT = 16, // first one to allocate
FL_BOLD = 1, // add this to helvetica, courier, or times
FL_ITALIC = 2 // add this to helvetica, courier, or times
};
typedef unsigned int Fl_Font;
typedef unsigned int Fl_Font_Size;

// standard fonts
const Fl_Font FL_HELVETICA = 0;
const Fl_Font FL_HELVETICA_BOLD = 1;
const Fl_Font FL_HELVETICA_ITALIC = 2;
const Fl_Font FL_HELVETICA_BOLD_ITALIC = 3;
const Fl_Font FL_COURIER = 4;
const Fl_Font FL_COURIER_BOLD = 5;
const Fl_Font FL_COURIER_ITALIC = 6;
const Fl_Font FL_COURIER_BOLD_ITALIC = 7;
const Fl_Font FL_TIMES = 8;
const Fl_Font FL_TIMES_BOLD = 9;
const Fl_Font FL_TIMES_ITALIC = 10;
const Fl_Font FL_TIMES_BOLD_ITALIC = 11;
const Fl_Font FL_SYMBOL = 12;
const Fl_Font FL_SCREEN = 13;
const Fl_Font FL_SCREEN_BOLD = 14;
const Fl_Font FL_ZAPF_DINGBATS = 15;

const Fl_Font FL_FREE_FONT = 16; // first one to allocate
const Fl_Font FL_BOLD = 1; // add this to helvetica, courier, or times
const Fl_Font FL_ITALIC = 2; // add this to helvetica, courier, or times

extern FL_EXPORT Fl_Font_Size FL_NORMAL_SIZE;

extern FL_EXPORT int FL_NORMAL_SIZE;

enum Fl_Color { // standard colors
// These are used as default colors in widgets and altered as necessary
Expand Down
11 changes: 6 additions & 5 deletions FL/Fl_Browser_.H
Expand Up @@ -53,7 +53,8 @@ class FL_EXPORT Fl_Browser_ : public Fl_Group {
int offset_; // how far down top_ item the real_position is
int max_width; // widest object seen so far
uchar has_scrollbar_; // which scrollbars are enabled
uchar textfont_, textsize_;
Fl_Font textfont_;
Fl_Font_Size textsize_;
unsigned textcolor_;
void* top_; // which item scrolling position is in
void* selection_; // which is selected (except for FL_MULTI_BROWSER)
Expand Down Expand Up @@ -131,10 +132,10 @@ public:
BOTH_ALWAYS = 7
};

Fl_Font textfont() const {return (Fl_Font)textfont_;}
void textfont(uchar s) {textfont_ = s;}
uchar textsize() const {return textsize_;}
void textsize(uchar s) {textsize_ = s;}
Fl_Font textfont() const {return textfont_;}
void textfont(Fl_Font s) {textfont_ = s;}
Fl_Font_Size textsize() const {return textsize_;}
void textsize(Fl_Font_Size s) {textsize_ = s;}
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
void textcolor(unsigned n) {textcolor_ = n;}

Expand Down
11 changes: 6 additions & 5 deletions FL/Fl_Chart.H
Expand Up @@ -59,7 +59,8 @@ class FL_EXPORT Fl_Chart : public Fl_Widget {
FL_CHART_ENTRY *entries;
double min,max;
uchar autosize_;
uchar textfont_,textsize_;
Fl_Font textfont_;
Fl_Font_Size textsize_;
unsigned textcolor_;
protected:
void draw();
Expand All @@ -76,10 +77,10 @@ public:
void size(int W, int H) { Fl_Widget::size(W, H); }
int maxsize() const {return maxnumb;}
void maxsize(int);
Fl_Font textfont() const {return (Fl_Font)textfont_;}
void textfont(uchar s) {textfont_ = s;}
uchar textsize() const {return textsize_;}
void textsize(uchar s) {textsize_ = s;}
Fl_Font textfont() const {return textfont_;}
void textfont(Fl_Font s) {textfont_ = s;}
Fl_Font_Size textsize() const {return textsize_;}
void textsize(Fl_Font_Size s) {textsize_ = s;}
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
void textcolor(unsigned n) {textcolor_ = n;}
uchar autosize() const {return autosize_;}
Expand Down
11 changes: 6 additions & 5 deletions FL/Fl_Counter.H
Expand Up @@ -40,7 +40,8 @@

class FL_EXPORT Fl_Counter : public Fl_Valuator {

uchar textfont_, textsize_;
Fl_Font textfont_;
Fl_Font_Size textsize_;
unsigned textcolor_;
double lstep_;
uchar mouseobj;
Expand All @@ -60,10 +61,10 @@ public:
void lstep(double a) {lstep_ = a;}
void step(double a,double b) {Fl_Valuator::step(a); lstep_ = b;}
void step(double a) {Fl_Valuator::step(a);}
Fl_Font textfont() const {return (Fl_Font)textfont_;}
void textfont(uchar s) {textfont_ = s;}
uchar textsize() const {return textsize_;}
void textsize(uchar s) {textsize_ = s;}
Fl_Font textfont() const {return textfont_;}
void textfont(Fl_Font s) {textfont_ = s;}
Fl_Font_Size textsize() const {return textsize_;}
void textsize(Fl_Font_Size s) {textsize_ = s;}
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
void textcolor(unsigned s) {textcolor_ = s;}

Expand Down
4 changes: 2 additions & 2 deletions FL/Fl_File_Browser.H
Expand Up @@ -67,8 +67,8 @@ public:

int load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort);

uchar textsize() const { return (Fl_Browser::textsize()); };
void textsize(uchar s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); };
Fl_Font_Size textsize() const { return Fl_Browser::textsize(); };
void textsize(Fl_Font_Size s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); };

int filetype() const { return (filetype_); };
void filetype(int t) { filetype_ = t; };
Expand Down
8 changes: 4 additions & 4 deletions FL/Fl_File_Chooser.H
Expand Up @@ -150,10 +150,10 @@ public:
int shown();
void textcolor(Fl_Color c);
Fl_Color textcolor();
void textfont(uchar f);
uchar textfont();
void textsize(uchar s);
uchar textsize();
void textfont(Fl_Font f);
Fl_Font textfont();
void textsize(Fl_Font_Size s);
Fl_Font_Size textsize();
void type(int t);
int type();
void * user_data() const;
Expand Down
4 changes: 2 additions & 2 deletions FL/Fl_Help_Dialog.H
Expand Up @@ -74,8 +74,8 @@ public:
void resize(int xx, int yy, int ww, int hh);
void show();
void show(int argc, char **argv);
void textsize(uchar s);
uchar textsize();
void textsize(Fl_Font_Size s);
Fl_Font_Size textsize();
void topline(const char *n);
void topline(int n);
void value(const char *f);
Expand Down
33 changes: 17 additions & 16 deletions FL/Fl_Help_View.H
Expand Up @@ -103,16 +103,17 @@ class FL_EXPORT Fl_Help_View : public Fl_Group //// Help viewer widget
bgcolor_, // Background color
textcolor_, // Text color
linkcolor_; // Link color
uchar textfont_, // Default font for text
textsize_; // Default font size
Fl_Font textfont_; // Default font for text
Fl_Font_Size textsize_; // Default font size
const char *value_; // HTML text value

int nblocks_, // Number of blocks/paragraphs
ablocks_; // Allocated blocks
Fl_Help_Block *blocks_; // Blocks

int nfonts_; // Number of fonts in stack
uchar fonts_[100][2]; // Font stack
Fl_Font fonts_[100]; // Font stack
Fl_Font_Size font_sizes_[100]; // Font Size stack

Fl_Help_Func *link_; // Link transform function

Expand Down Expand Up @@ -164,15 +165,15 @@ class FL_EXPORT Fl_Help_View : public Fl_Group //// Help viewer widget
int get_length(const char *l);
int handle(int);

void initfont(uchar &f, uchar &s) { nfonts_ = 0;
fl_font(f = fonts_[0][0] = textfont_,
s = fonts_[0][1] = textsize_); }
void pushfont(uchar f, uchar s) { if (nfonts_ < 99) nfonts_ ++;
fl_font(fonts_[nfonts_][0] = f,
fonts_[nfonts_][1] = s); }
void popfont(uchar &f, uchar &s) { if (nfonts_ > 0) nfonts_ --;
fl_font(f = fonts_[nfonts_][0],
s = fonts_[nfonts_][1]); }
void initfont(Fl_Font &f, Fl_Font_Size &s) { nfonts_ = 0;
fl_font(f = fonts_[0] = textfont_,
s = font_sizes_[0] = textsize_); }
void pushfont(Fl_Font f, Fl_Font_Size s) { if (nfonts_ < 99) nfonts_ ++;
fl_font(fonts_[nfonts_] = f,
font_sizes_[nfonts_] = s); }
void popfont(Fl_Font &f, Fl_Font_Size &s) { if (nfonts_ > 0) nfonts_ --;
fl_font(f = fonts_[nfonts_],
s = font_sizes_[nfonts_]); }

void hv_draw(const char *t, int x, int y);
char begin_selection();
Expand All @@ -198,10 +199,10 @@ public:
void size(int W, int H) { Fl_Widget::size(W, H); }
void textcolor(Fl_Color c) { if (textcolor_ == defcolor_) textcolor_ = c; defcolor_ = c; }
Fl_Color textcolor() const { return (defcolor_); }
void textfont(uchar f) { textfont_ = f; format(); }
uchar textfont() const { return (textfont_); }
void textsize(uchar s) { textsize_ = s; format(); }
uchar textsize() const { return (textsize_); }
void textfont(Fl_Font f) { textfont_ = f; format(); }
Fl_Font textfont() const { return (textfont_); }
void textsize(Fl_Font_Size s) { textsize_ = s; format(); }
Fl_Font_Size textsize() const { return (textsize_); }
const char *title() { return (title_); }
void topline(const char *n);
void topline(int);
Expand Down
12 changes: 6 additions & 6 deletions FL/Fl_Input_.H
Expand Up @@ -61,8 +61,8 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
int shortcut_;

uchar erase_cursor_only;
uchar textfont_;
uchar textsize_;
Fl_Font textfont_;
Fl_Font_Size textsize_;
unsigned textcolor_;
unsigned cursor_color_;

Expand Down Expand Up @@ -123,10 +123,10 @@ public:
int shortcut() const {return shortcut_;}
void shortcut(int s) {shortcut_ = s;}

Fl_Font textfont() const {return (Fl_Font)textfont_;}
void textfont(uchar s) {textfont_ = s;}
uchar textsize() const {return textsize_;}
void textsize(uchar s) {textsize_ = s;}
Fl_Font textfont() const {return textfont_;}
void textfont(Fl_Font s) {textfont_ = s;}
Fl_Font_Size textsize() const {return textsize_;}
void textsize(Fl_Font_Size s) {textsize_ = s;}
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
void textcolor(unsigned n) {textcolor_ = n;}
Fl_Color cursor_color() const {return (Fl_Color)cursor_color_;}
Expand Down
8 changes: 4 additions & 4 deletions FL/Fl_Input_Choice.H
Expand Up @@ -166,16 +166,16 @@ public:
void textcolor(Fl_Color c) {
inp_->textcolor(c);
}
uchar textfont() const {
Fl_Font textfont() const {
return (inp_->textfont());
}
void textfont(uchar f) {
void textfont(Fl_Font f) {
inp_->textfont(f);
}
uchar textsize() const {
Fl_Font_Size textsize() const {
return (inp_->textsize());
}
void textsize(uchar s) {
void textsize(Fl_Font_Size s) {
inp_->textsize(s);
}
const char* value() const {
Expand Down
12 changes: 6 additions & 6 deletions FL/Fl_Menu_.H
Expand Up @@ -42,8 +42,8 @@ protected:

uchar alloc;
uchar down_box_;
uchar textfont_;
uchar textsize_;
Fl_Font textfont_;
Fl_Font_Size textsize_;
unsigned textcolor_;

public:
Expand Down Expand Up @@ -80,10 +80,10 @@ public:
const char *text() const {return value_ ? value_->text : 0;}
const char *text(int i) const {return menu_[i].text;}

Fl_Font textfont() const {return (Fl_Font)textfont_;}
void textfont(uchar c) {textfont_=c;}
uchar textsize() const {return textsize_;}
void textsize(uchar c) {textsize_=c;}
Fl_Font textfont() const {return textfont_;}
void textfont(Fl_Font c) {textfont_=c;}
Fl_Font_Size textsize() const {return textsize_;}
void textsize(Fl_Font_Size c) {textsize_=c;}
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
void textcolor(unsigned c) {textcolor_=c;}

Expand Down
12 changes: 6 additions & 6 deletions FL/Fl_Menu_Item.H
Expand Up @@ -58,8 +58,8 @@ struct FL_EXPORT Fl_Menu_Item {
void *user_data_;
int flags;
uchar labeltype_;
uchar labelfont_;
uchar labelsize_;
Fl_Font labelfont_;
Fl_Font_Size labelsize_;
unsigned labelcolor_;

// advance N items, skipping submenus:
Expand All @@ -77,10 +77,10 @@ struct FL_EXPORT Fl_Menu_Item {
void labeltype(Fl_Labeltype a) {labeltype_ = a;}
Fl_Color labelcolor() const {return (Fl_Color)labelcolor_;}
void labelcolor(unsigned a) {labelcolor_ = a;}
Fl_Font labelfont() const {return (Fl_Font)labelfont_;}
void labelfont(uchar a) {labelfont_ = a;}
uchar labelsize() const {return labelsize_;}
void labelsize(uchar a) {labelsize_ = a;}
Fl_Font labelfont() const {return labelfont_;}
void labelfont(Fl_Font a) {labelfont_ = a;}
Fl_Font_Size labelsize() const {return labelsize_;}
void labelsize(Fl_Font_Size a) {labelsize_ = a;}
Fl_Callback_p callback() const {return callback_;}
void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;}
void callback(Fl_Callback* c) {callback_=c;}
Expand Down
8 changes: 4 additions & 4 deletions FL/Fl_Spinner.H
Expand Up @@ -192,16 +192,16 @@ class Fl_Spinner : public Fl_Group
void textcolor(Fl_Color c) {
input_.textcolor(c);
}
uchar textfont() const {
Fl_Font textfont() const {
return (input_.textfont());
}
void textfont(uchar f) {
void textfont(Fl_Font f) {
input_.textfont(f);
}
uchar textsize() const {
Fl_Font_Size textsize() const {
return (input_.textsize());
}
void textsize(uchar s) {
void textsize(Fl_Font_Size s) {
input_.textsize(s);
}
uchar type() const { return (input_.type()); }
Expand Down
12 changes: 6 additions & 6 deletions FL/Fl_Text_Display.H
Expand Up @@ -122,10 +122,10 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {
int shortcut() const {return shortcut_;}
void shortcut(int s) {shortcut_ = s;}

Fl_Font textfont() const {return (Fl_Font)textfont_;}
void textfont(uchar s) {textfont_ = s;}
uchar textsize() const {return textsize_;}
void textsize(uchar s) {textsize_ = s;}
Fl_Font textfont() const {return textfont_;}
void textfont(Fl_Font s) {textfont_ = s;}
Fl_Font_Size textsize() const {return textsize_;}
void textsize(Fl_Font_Size s) {textsize_ = s;}
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
void textcolor(unsigned n) {textcolor_ = n;}

Expand Down Expand Up @@ -285,8 +285,8 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {

int shortcut_;

uchar textfont_;
uchar textsize_;
Fl_Font textfont_;
Fl_Font_Size textsize_;
unsigned textcolor_;

// The following are not presently used from the original NEdit code,
Expand Down

0 comments on commit 7c8f5cc

Please sign in to comment.