Adonthell  0.4
win_select.h
1 /*
2  (C) Copyright 2000 Joel Vennin
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef _WIN_SELECT_H_
20 #define _WIN_SELECT_H_
21 
22 #include "win_scroll.h"
23 
24 class win_select : public win_scroll
25 {
26  public:
27 
28  win_select();
29 
30  bool input_update();
31 
32  void add(win_base * w);
33 
34  void remove(win_base * w);
35 
36  void remove_all();
37 
38  void set_mode(const u_int8 mode){mode_ = mode;}
39 
40  void set_border_select(win_border * border){border_select_ = border;}
41 
42  void set_circle(const bool b) {circle_ = b;}
43  bool is_circle(){return circle_;}
44 
45  void set_default();
46 
47  void set_default_object(const win_base * wb);
48 
49  void set_default_position(const u_int16 pos);
50 
51  void set_pos( const u_int8 pos) {win_scroll::set_pos(pos);finish_scroll_ = true;}
52 
53  bool update();
54 
55  win_base * get_selected_object();
56 
57  u_int16 get_selected_position();
58 
59  static const u_int8 MODE_BORDER = 0;
60 
61  static const u_int8 MODE_BRIGHTNESS = 1;
62 
63 
64 
65 
66 
67  protected:
68 
69  void rules(const bool b, win_base * wb);
70 
71  void update_cur_select_position();
72 
73  void next();
74 
75  void previous();
76 
77  void activate();
78 
79  u_int8 mode_;
80 
81  bool circle_;
82 
83  bool finish_scroll_;
84 
85  win_border * border_select_;
86 
87  lwb::iterator cur_select_;
88 };
89 
90 
91 
92 /*
93 class win_base;
94 class win_theme;
95 class win_container;
96 class win_scrolled;
97 
98 class win_select : public win_scrolled
99 {
100  protected:
101 #ifndef SWIG
102  //index of the current object which is selected
103  list<win_base *>::iterator index_list;
104  //to show the selected object if isn't visible in the select
105  void update_position();
106  //mode to select
107  u_int8 mode_selected_;
108 
109  //type of the select method
110  u_int8 type_selected_;
111 
112 
113  //if this select has a father
114  win_select * fatherselect_;
115 
116  bool select_circle_;
117 
118  //current win_select activate
119  static win_select * curselect_;
120  void next_();
121  void previous_();
122 
123  static bool activate_keyboard_;
124 
125  virtual void on_next();
126  virtual void on_previous();
127 
128  //use this function to activate the object see win_base.h
129  void on_activate();
130 
131  bool activate___();
132 
133 
134  void set_select_object(win_base*,bool b);
135 #endif
136 
137  public:
138  win_select(s_int16 tx,s_int16 ty,u_int16 tl,u_int16 th,win_theme * wth);
139  ~win_select();
140  //Add object
141  void add(win_base *);
142  void add(win_select *);
143  //remove
144  void remove(win_base *);
145  void remove_all();
146  void destroy();
147  bool update();
148  //get the pointer of the object which is selected
149  win_base * get();
150  //get the position of the object which is selected
151  u_int16 get_pos();
152  //set the default object
153  void set_default(win_base * wb);
154  void set_default(u_int16 ); //set the default object with a number, 1 is the first object 2 is the .....
155 
156  void set_default(); //set the first object which can be selected
157 
158  void set_can_be_selected_all(bool);//set to b all the element which are in the select
159 
160 
161  void set_type(u_int8); //set type of the select, WIN_SELECT_TYPE_NORMAL,WIN_SELECT_TYPE_SCROLL, default is normal
162  u_int8 type() {return type_selected_;}
163 
164 
165  //set the mode of the selection WIN_SELECT_MODE_BRIGHTNESS, WIN_SELECT_MODE_BORDER, cursor not implemented
166  void set_select_mode(u_int8);
167 
168  void set_select_circle(bool b){select_circle_=b;}
169  bool is_select_circle(){return select_circle_;}
170 
171  //next object
172  static void next();
173  //previous object
174  static void previous();
175  //set the curselect
176  static void set_cur_select(win_select * ws);
177  //return a the father select
178  static bool back();
179  //activate the object
180  static void activate();
181 
182  static void set_activate_keyboard(bool b){activate_keyboard_=b;}
183  static bool is_activate_keyboard(){return activate_keyboard_;}
184 
185  //set the curselect to NULL, needed if you want clean select
186  static void init();
187 
188  IMPORTANT
189  you can with win_select browse a tree of selection, if you want to return at the last node call the back function, or if you want
190  to go at a node you have selected just call the on_activate_function
191 
192  static s_int32 next_key;
193  static s_int32 previous_key;
194  static s_int32 activate_key;
195  static s_int32 back_key;
196 };
197 
198 */
199 #endif
200 
201 
202 
203 
204 
win_base
Common properties for each win_base's object.
Definition: win_base.h:51
win_select::update
bool update()
Update process.
Definition: win_select.cc:302
win_select
Definition: win_select.h:24
win_scroll
Definition: win_scroll.h:25
u_int8
#define u_int8
8 bits long unsigned integer
Definition: types.h:35
win_select::input_update
bool input_update()
Input Update process .
Definition: win_select.cc:177
u_int16
#define u_int16
16 bits long unsigned integer
Definition: types.h:38
win_border
Definition: win_border.h:31