2 * common__ob_controls.h
4 * Created on: 28 avr. 2009
8 #ifndef COMMON__OB_CONTROLS_H_
9 #define COMMON__OB_CONTROLS_H_
12 #include <wx/filepicker.h>
16 #include "common__tools.h"
17 #include "common__globals.h"
19 //****************************************************
20 //****************************************************
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
);
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
);
55 std::list
<atom_path
*> l_atoms
;
58 //****************************************************
59 //****************************************************
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
75 static wxColour default_values_color
;
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
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
);
90 wxSizer
* BuildControls(
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
);
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
;
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
);
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 ), \
149 //****************************************************
150 //****************************************************
151 class KalachnikofButton
: public wxBitmapButton
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
;
163 void EvtTimerOut( wxTimerEvent
& event
);
164 void EvtMouseSomething( wxMouseEvent
& event
);
166 DECLARE_EVENT_TABLE()
169 //****************************************************
171 class prObFileChooserCtrl
: public wxControl
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
);
194 wxString File_or_Directory
;
196 wxTextCtrl
*txtCtrl_file
;
197 wxFilePickerCtrl
*filePck_file
;
200 bool b_file_must_exist
;
203 virtual wxSize
DoGetBestSize() const;
204 virtual void DoSetSize(int x
, int y
, int width
, int height
);
205 virtual wxSize
GetMinSize() const;
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 ), \
235 //****************************************************
236 //************ BASE SCROLL PANNEL CLASSES ***********
237 //****************************************************
238 class AScrollPanel
: public wxScrolledWindow
241 AScrollPanel( wxWindow
*_parent
);
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 ?
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
) );
260 DECLARE_EVENT_TABLE()
266 #endif /* COMMON__OB_CONTROLS_H_ */