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