Adonthell 0.4
win_select.h
00001 /*
00002    $Id: win_select.h,v 1.18 2001/07/30 23:08:12 jol Exp $
00003 
00004    (C) Copyright 2000 Joel Vennin
00005    Part of the Adonthell Project http://adonthell.linuxgames.com
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details
00013 */
00014 
00015 #ifndef _WIN_SELECT_H_
00016 #define _WIN_SELECT_H_
00017 
00018 #include "win_scroll.h"
00019 
00020 class win_select : public win_scroll
00021 {
00022  public:
00023   
00024   win_select();
00025 
00026   bool input_update();
00027   
00028   void add(win_base * w);
00029   
00030   void remove(win_base * w);
00031 
00032   void remove_all();
00033   
00034   void set_mode(const u_int8 mode){mode_ = mode;}
00035   
00036   void set_border_select(win_border * border){border_select_ = border;}
00037   
00038   void set_circle(const bool  b) {circle_ = b;}
00039   bool is_circle(){return circle_;}
00040 
00041   void set_default();
00042 
00043   void set_default_object(const win_base * wb);
00044 
00045   void set_default_position(const u_int16 pos);
00046 
00047   void set_pos( const u_int8 pos) {win_scroll::set_pos(pos);finish_scroll_ = true;}
00048 
00049   bool update();
00050 
00051   win_base * get_selected_object();
00052   
00053   u_int16 get_selected_position();
00054 
00055   static const u_int8 MODE_BORDER = 0;
00056   
00057   static const u_int8 MODE_BRIGHTNESS = 1;
00058 
00059 
00060 
00061 
00062   
00063  protected:
00064   
00065   void rules(const bool b, win_base * wb);
00066 
00067   void update_cur_select_position();
00068 
00069   void next();
00070   
00071   void previous();
00072 
00073   void activate();
00074 
00075   u_int8 mode_;
00076   
00077   bool circle_;
00078 
00079   bool finish_scroll_;
00080 
00081   win_border * border_select_;
00082 
00083   lwb::iterator cur_select_;
00084 };
00085 
00086 
00087 
00088 /*
00089 class win_base;
00090 class win_theme;
00091 class win_container;
00092 class win_scrolled;
00093 
00094 class win_select : public win_scrolled
00095 {
00096  protected:
00097 #ifndef SWIG
00098   //index of the current object which is selected
00099   list<win_base *>::iterator index_list;
00100   //to show the selected object if isn't visible in the select 
00101   void update_position();
00102   //mode to select
00103   u_int8 mode_selected_;
00104   
00105   //type of the select method
00106   u_int8 type_selected_;
00107   
00108 
00109   //if this select has a father
00110   win_select * fatherselect_;
00111  
00112   bool select_circle_;
00113 
00114  //current win_select activate
00115   static win_select * curselect_;
00116   void next_();
00117   void previous_();
00118  
00119   static bool activate_keyboard_;
00120 
00121   virtual void on_next();
00122   virtual void on_previous();
00123   
00124   //use this function to activate the object see win_base.h
00125   void on_activate();
00126   
00127   bool activate___();
00128   
00129   
00130   void set_select_object(win_base*,bool b);
00131 #endif
00132 
00133  public:
00134   win_select(s_int16 tx,s_int16 ty,u_int16 tl,u_int16 th,win_theme * wth);
00135   ~win_select();
00136   //Add object
00137   void add(win_base *);
00138   void add(win_select *);
00139   //remove
00140   void remove(win_base *);
00141   void remove_all();
00142   void destroy();
00143   bool update();
00144   //get the pointer of the object which is selected
00145   win_base * get();
00146   //get the position of the object which is selected
00147   u_int16 get_pos();
00148   //set the default object
00149   void set_default(win_base * wb);
00150   void set_default(u_int16 ); //set the default object with a number, 1 is the first object 2 is the .....
00151   
00152   void set_default(); //set the first object which can be selected
00153   
00154   void set_can_be_selected_all(bool);//set to b all the element which are in the select
00155 
00156  
00157   void set_type(u_int8); //set type of the select, WIN_SELECT_TYPE_NORMAL,WIN_SELECT_TYPE_SCROLL, default is normal
00158   u_int8 type() {return type_selected_;}
00159 
00160 
00161   //set the mode of the selection WIN_SELECT_MODE_BRIGHTNESS, WIN_SELECT_MODE_BORDER, cursor not implemented
00162   void set_select_mode(u_int8);
00163  
00164   void set_select_circle(bool b){select_circle_=b;}
00165   bool is_select_circle(){return select_circle_;}
00166 
00167   //next object
00168   static void next();
00169   //previous object
00170   static void previous();
00171   //set the curselect
00172   static void set_cur_select(win_select * ws);
00173   //return a the father select
00174   static bool back();
00175   //activate the object
00176   static void activate();
00177 
00178   static void set_activate_keyboard(bool b){activate_keyboard_=b;}
00179   static bool is_activate_keyboard(){return activate_keyboard_;}
00180   
00181   //set the curselect to NULL, needed if you want clean select
00182   static void init();
00183   
00184   IMPORTANT
00185     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
00186     to go at a node you have selected just call the on_activate_function
00187    
00188   static s_int32 next_key;
00189   static s_int32 previous_key;
00190   static s_int32 activate_key;
00191   static s_int32 back_key;
00192 };
00193 
00194 */
00195 #endif
00196 
00197 
00198 
00199 
00200