fix compile against newer giflib
[rofl0r-obeditor.git] / src / common__ob_controls.h
blobaa52d52a89bce04dc6ede4b8cba53de3a6bbd15c
1 /*
2 * common__ob_controls.h
4 * Created on: 28 avr. 2009
5 * Author: pat
6 */
8 #ifndef COMMON__OB_CONTROLS_H_
9 #define COMMON__OB_CONTROLS_H_
11 #include <wx/event.h>
12 #include <wx/filepicker.h>
13 #include <vector>
14 #include <map>
16 #include "common__tools.h"
17 #include "common__globals.h"
19 //****************************************************
20 //****************************************************
21 typedef struct
23 int num_token;
24 wxString tag;
26 atom_path;
28 class ob_token_path
30 public:
31 ob_token_path(){};
32 ob_token_path( const wxString& tag, int num_token = -1 );
33 ob_token_path(const ob_token_path& ob_tp
34 , const wxString& subtag = wxString()
35 , int num_sub_token = -1 );
36 ob_token_path( ob_token_path& src );
37 ob_token_path& operator=( const ob_token_path& obtp );
38 ~ob_token_path();
40 bool IsEmpty();
41 wxString GetPath();
43 bool Append__SubTag( const wxString& subtag );
44 bool Append__SubToken( int num_sub_token );
46 ob_token_path* BuildPath_Sibling_Token( int decal );
49 ob_object* Resolve_With( ob_object* _o );
50 wxString Get_With( ob_object* _o );
51 bool Set_To( ob_object* _o, wxString& val );
53 protected:
54 void Clear_l_atoms();
55 std::list<atom_path*> l_atoms;
58 //****************************************************
59 //****************************************************
60 enum
62 OBPROP_DONOTHING = 0x0001
63 , OBPROP_DEL_TAG = 0x0002
64 , OBPROP_TRUNCATE = 0x0003
66 , OBPROP_DEF_MASK = 0x00FF
68 , OBPROP_SETDEF_IFEMPTY = 0x0100
72 class ob_property : public wxEvtHandler
74 public:
75 static wxColour default_values_color;
76 public:
77 // Facilities for ComboBoxes
78 static void SetRange(wxWindow* comboBox, int min,int max);
79 static void SetEnums( wxWindow* comboBox
80 , const wxArrayString& _displayed
81 , const wxArrayString& _values
84 public:
85 ob_property( const wxString& tag,const int num_token = 0
86 , int type_prop = PROPTYPE_STRING
87 , const wxString& def_val = wxString(), int do_on_default = OBPROP_DEL_TAG);
88 ~ob_property();
90 wxSizer* BuildControls(
91 ob_object* obj
92 , wxWindow* parent
93 , wxWindow*& res_Ctrl
94 , const wxString& ctrlName, int ctrl_w = wxDefaultCoord
95 , const wxString& str_label = wxString(), int label_w = wxDefaultCoord
96 , int ctrl_more_styles = 0 );
98 //-------------------------------------------------------------
99 // Getting the special default val for this prop
100 // ex : return the pointed entity prop if referer_path is set
101 wxString Get_SpecialDefault_Val(ob_object* o );
102 bool Have_SpecialDefault_Val(ob_object* o );
104 // Return special val if there is one, else def_val
105 wxString Get_Default_Val(ob_object* _o );
107 wxString Get_Curr_Value(ob_object* _o);
109 bool Update_CtrlVal( wxWindow* ctrl );
111 public:
112 wxString prefix;
113 wxString tag;
114 int num_token;
115 int type_prop;
116 wxString def_val;
117 int do_on_default;
119 // If the prop have a referer tag for his default value
120 // (ex: a spawn have some referers to entity associated for health, score, etc...)
121 ob_token_path referer_path;
124 protected:
125 ob_object* CreateDefaultObject(ob_object* o);
126 void pUpdate( ob_object* obj, wxWindow* theCtrl, const wxString& val );
127 void MayTruncate(ob_object* obj, ob_object* subobj, wxWindow* theCtrl );
128 void Signal_Modified( ob_object* obj, wxWindow* theCtrl);
130 protected:
131 void Evt_TxtChange(wxCommandEvent& evt);
132 void Evt_FileChange(wxCommandEvent& evt);
133 void Evt_ChckChange(wxCommandEvent& evt);
134 void Evt_Combo(wxCommandEvent& evt);
137 extern std::map<wxString,ob_property*> ob_props;
139 #ifndef EVT_OBPROP_CHANGE
140 #define EVT_OBPROP_CHANGE(fn) \
141 DECLARE_EVENT_TABLE_ENTRY( \
142 wxEVT_OBPROP_CHANGE, wxID_ANY, wxID_ANY, \
143 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \
144 (wxObject *) NULL \
146 #endif
149 //****************************************************
150 //****************************************************
151 class KalachnikofButton: public wxBitmapButton
153 public:
154 KalachnikofButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const size_t _clicks_interval_ms = 200, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxT("button") );
155 ~KalachnikofButton();
157 size_t clicks_interval;
158 protected:
159 wxTimer* theTimer;
160 bool b_clickedOn;
162 protected:
163 void EvtTimerOut( wxTimerEvent& event );
164 void EvtMouseSomething( wxMouseEvent& event );
166 DECLARE_EVENT_TABLE()
169 //****************************************************
171 class prObFileChooserCtrl : public wxControl
173 public:
174 prObFileChooserCtrl(
175 wxWindow *_parent
176 , const int _id = wxID_ANY
177 , const wxString& _File_or_Directory = wxString()
178 , const bool _b_file_must_exist = true
179 , const int _width = wxDefaultCoord
180 , const int style = 0
182 ~prObFileChooserCtrl();
184 bool SetFullPath( const wxString& _File );
185 bool SetObPath( const wxString& _File );
186 wxFileName GetFileName();
187 wxString GetFullPath();
188 wxString GetObPath();
190 virtual int Update(bool b_filePicker );
192 protected:
193 int minWidth;
194 wxString File_or_Directory;
196 wxTextCtrl *txtCtrl_file;
197 wxFilePickerCtrl *filePck_file;
199 bool b_updating;
200 bool b_file_must_exist;
201 bool b_init;
203 virtual wxSize DoGetBestSize() const;
204 virtual void DoSetSize(int x, int y, int width, int height);
205 virtual wxSize GetMinSize() const;
207 void Init();
208 void EvtSize(wxSizeEvent& event);
209 void EvtGetFocus( wxFocusEvent& evt );
210 void EvtCharPress( wxKeyEvent& event);
211 void EvtImgPickerChg(wxFileDirPickerEvent& event );
212 void EvtPaint( wxPaintEvent& WXUNUSED(event));
213 void EvtImgPickerClick( wxMouseEvent& event );
216 DECLARE_EVENT_TABLE()
221 //****************************************************
223 #ifndef EVT_OBFILECHOOSER_CHANGE
224 #define EVT_OBFILECHOOSER_CHANGE(id, fn) \
225 DECLARE_EVENT_TABLE_ENTRY( \
226 wxEVT_OBFILECHOOSER_CHANGE, id, wxID_ANY, \
227 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \
228 (wxObject *) NULL \
230 #endif
235 //****************************************************
236 //************ BASE SCROLL PANNEL CLASSES ***********
237 //****************************************************
238 class AScrollPanel : public wxScrolledWindow
240 public :
241 AScrollPanel( wxWindow *_parent );
242 ~AScrollPanel();
243 void EvtSize( wxSizeEvent& event );
244 virtual bool Layout();
245 virtual wxSize GetMinSize()const;
247 void Set_FixedDirections( bool b_H, bool b_V ); // Horizontable length fix ? Verticable length fix ?
249 protected:
250 virtual wxSize DoGetBestSize() const;
251 virtual void DoGetClientSize( int* width, int* height) const;
252 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
254 void OnPaint( wxPaintEvent &WXUNUSED(event) );
256 bool b_fix_V;
257 bool b_fix_H;
259 int h;
260 DECLARE_EVENT_TABLE()
266 #endif /* COMMON__OB_CONTROLS_H_ */