2 * Copyright (C) 2002,2003,2004,2005,2006 Daniel Heck
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef GUI_MENU_HH_INCLUDED
20 #define GUI_MENU_HH_INCLUDED
22 #include "gui/widgets.hh"
23 #include "gui/Menu.hh"
25 #include "ecl_geom.hh"
30 namespace enigma
{ namespace gui
{
31 /* -------------------- Menu -------------------- */
33 class Menu
: public Container
{
37 //! true: ok, false: menu aborted by user
38 virtual bool manage();
41 void add(Widget
*w
, ecl::Rect r
);
44 void draw (ecl::GC
&gc
, const ecl::Rect
&r
);
49 // Container interface
50 virtual void set_key_focus(Widget
*newfocus
);
51 virtual bool is_key_focus(Widget
*focus
);
54 void reset_active_widget() { active_widget
= NULL
; }
55 void reset_key_focus_widget() { key_focus_widget
= NULL
; }
58 virtual void draw_background(ecl::GC
&/*gc*/) {}
61 void handle_event(const SDL_Event
&e
);
63 void switch_active_widget(Widget
*to_activate
);
64 void track_active_widget( int x
, int y
); // used by mouse
65 void goto_adjacent_widget(int xdir
, int ydir
); // used by keyboard
68 Widget
*active_widget
;
69 Widget
*key_focus_widget
;
78 BuildVList(Menu
*cc
, const ecl::Rect
&rr
, int s
)
79 : r(rr
), container(cc
), skip(s
)
82 Widget
*add(Widget
*w
) {
88 ecl::Rect
pos() const { return r
; }
96 BuildHList(Menu
*cc
, const ecl::Rect
&rr
, int s
)
97 : r(rr
), container(cc
), skip(s
)
100 Widget
* add(Widget
*w
) {
101 container
->add(w
, r
);
105 Widget
*add (Widget
*w
, int width
) {
106 ecl::Rect
rr(r
.x
, r
.y
, width
, r
.h
);
107 container
->add(w
, rr
);
112 ecl::Rect
pos() const { return r
; }
115 }} // namespace enigma::gui