fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Menu_Bar.cxx

Go to the documentation of this file.
00001 //
00002 // "$Id: Fl_Menu_Bar.cxx 7903 2010-11-28 21:06:39Z matt $"
00003 //
00004 // Menu bar widget for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00028 #include <FL/Fl.H>
00029 #include <FL/Fl_Menu_Bar.H>
00030 #include <FL/fl_draw.H>
00031 
00032 void Fl_Menu_Bar::draw() {
00033   draw_box();
00034   if (!menu() || !menu()->text) return;
00035   const Fl_Menu_Item* m;
00036   int X = x()+6;
00037   for (m=menu()->first(); m->text; m = m->next()) {
00038     int W = m->measure(0,this) + 16;
00039     m->draw(X, y(), W, h(), this);
00040     X += W;
00041     if (m->flags & FL_MENU_DIVIDER) {
00042       int y1 = y() + Fl::box_dy(box());
00043       int y2 = y1 + h() - Fl::box_dh(box()) - 1;
00044 
00045       // Draw a vertical divider between menus...
00046       fl_color(FL_DARK3);
00047       fl_yxline(X - 6, y1, y2);
00048       fl_color(FL_LIGHT3);
00049       fl_yxline(X - 5, y1, y2);
00050     }
00051   }
00052 }
00053 
00054 int Fl_Menu_Bar::handle(int event) {
00055   const Fl_Menu_Item* v;
00056   if (menu() && menu()->text) switch (event) {
00057   case FL_ENTER:
00058   case FL_LEAVE:
00059     return 1;
00060   case FL_PUSH:
00061     v = 0;
00062   J1:
00063     v = menu()->pulldown(x(), y(), w(), h(), v, this, 0, 1);
00064     picked(v);
00065     return 1;
00066   case FL_SHORTCUT:
00067     if (visible_r()) {
00068       v = menu()->find_shortcut(0, true);
00069       if (v && v->submenu()) goto J1;
00070     }
00071     return test_shortcut() != 0;
00072   }
00073   return 0;
00074 }
00075 
00076 //
00077 // End of "$Id: Fl_Menu_Bar.cxx 7903 2010-11-28 21:06:39Z matt $".
00078 //