diff options
| author | Greg Ercolano <erco@seriss.com> | 2018-03-31 17:17:37 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2018-03-31 17:17:37 +0000 |
| commit | 309d9a61b9759ad2ecc1c85458d3b9a8b97c575b (patch) | |
| tree | 458433893f733e012aee2685b845b24ca2b623f3 /src | |
| parent | 69584dda96eeae60dbb4fe70a1b452e0effce224 (diff) | |
Added Fl::menu_linespacing() to solve STR# 2927.
Method name follows Fl_Tree::linespacing().
Implemented similarly to Fl::scrollbar_size(), since its use crosses Fl_Menu_Item and 'menuwindow' classes.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12815 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 20 | ||||
| -rw-r--r-- | src/Fl_Menu.cxx | 16 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index 011e978e0..8695add93 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -136,7 +136,8 @@ int Fl::damage_, Fl::e_is_click, Fl::e_keysym, Fl::e_original_keysym, - Fl::scrollbar_size_ = 16; + Fl::scrollbar_size_ = 16, + Fl::menu_linespacing_ = 4; // 4: was a local macro in Fl_Menu.cxx called "LEADING" char *Fl::e_text = (char *)""; int Fl::e_length; @@ -232,6 +233,23 @@ void Fl::scrollbar_size(int W) { scrollbar_size_ = W; } +/** + Gets the default line spacing used by menus. + \returns The default line spacing, in pixels. +*/ +int Fl::menu_linespacing() { + return menu_linespacing_; +} + +/** + Sets the default line spacing used by menus. + Default is 4. + \param[in] H The new default line spacing between menu items, in pixels. +*/ +void Fl::menu_linespacing(int H) { + menu_linespacing_ = H; +} + /** Returns whether or not the mouse event is inside the given rectangle. diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 1d56a1ebd..a943a6b33 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -143,8 +143,6 @@ public: int is_inside(int x, int y); }; -#define LEADING 4 // extra vertical leading - extern char fl_draw_shortcut; /** @@ -200,7 +198,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m, x += 3; w -= 8; } else { - fl_draw_box(b, x+1, y-(LEADING-2)/2, w-2, h+(LEADING-2), r); + fl_draw_box(b, x+1, y-(Fl::menu_linespacing()-2)/2, w-2, h+(Fl::menu_linespacing()-2), r); } } @@ -344,7 +342,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, if (m) for (; m->text; m = m->next()) { int hh; int w1 = m->measure(&hh, button); - if (hh+LEADING>itemheight) itemheight = hh+LEADING; + if (hh+Fl::menu_linespacing()>itemheight) itemheight = hh+Fl::menu_linespacing(); if (m->flags&(FL_SUBMENU|FL_SUBMENU_POINTER)) w1 += FL_NORMAL_SIZE; if (w1 > W) W = w1; @@ -382,7 +380,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, //if (X > scr_x+scr_w-W) X = right_edge-W; if (X > scr_x+scr_w-W) X = scr_x+scr_w-W; x(X); w(W); - h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+3); + h((numitems ? itemheight*numitems-Fl::menu_linespacing() : 0)+2*BW+3); if (selected >= 0) { Y = Y+(Hp-itemheight)/2-selected*itemheight-BW; } else { @@ -459,10 +457,10 @@ void menuwindow::drawentry(const Fl_Menu_Item* m, int n, int eraseit) { int W = w(); int ww = W-2*BW-1; int yy = BW+1+n*itemheight; - int hh = itemheight - LEADING; + int hh = itemheight - Fl::menu_linespacing(); if (eraseit && n != selected) { - fl_push_clip(xx+1, yy-(LEADING-2)/2, ww-2, hh+(LEADING-2)); + fl_push_clip(xx+1, yy-(Fl::menu_linespacing()-2)/2, ww-2, hh+(Fl::menu_linespacing()-2)); draw_box(box(), 0, 0, w(), h(), button ? button->color() : color()); fl_pop_clip(); } @@ -496,9 +494,9 @@ void menuwindow::drawentry(const Fl_Menu_Item* m, int n, int eraseit) { if (m->flags & FL_MENU_DIVIDER) { fl_color(FL_DARK3); - fl_xyline(BW-1, yy+hh+(LEADING-2)/2, W-2*BW+2); + fl_xyline(BW-1, yy+hh+(Fl::menu_linespacing()-2)/2, W-2*BW+2); fl_color(FL_LIGHT3); - fl_xyline(BW-1, yy+hh+((LEADING-2)/2+1), W-2*BW+2); + fl_xyline(BW-1, yy+hh+((Fl::menu_linespacing()-2)/2+1), W-2*BW+2); } } |
