00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _WX_PROPGRID_EDITORS_H_
00013 #define _WX_PROPGRID_EDITORS_H_
00014
00015
00016
00017
00018 class wxPGWindowList
00019 {
00020 public:
00021 wxPGWindowList()
00022 {
00023 m_primary = m_secondary = NULL;
00024 }
00025
00026 void SetSecondary( wxWindow* secondary ) { m_secondary = secondary; }
00027
00028 wxWindow* m_primary;
00029 wxWindow* m_secondary;
00030
00031 #ifndef SWIG
00032 wxPGWindowList( wxWindow* a )
00033 {
00034 m_primary = a;
00035 m_secondary = NULL;
00036 };
00037 wxPGWindowList( wxWindow* a, wxWindow* b )
00038 {
00039 m_primary = a;
00040 m_secondary = b;
00041 };
00042 #endif
00043 };
00044
00045
00046
00068 class WXDLLIMPEXP_PG wxPGEditor : public wxObject
00069 {
00070 #ifndef SWIG
00071 DECLARE_ABSTRACT_CLASS(wxPGEditor)
00072 #endif
00073 public:
00074
00076 wxPGEditor()
00077 : wxObject()
00078 {
00079 #if defined(__WXPYTHON__)
00080 m_scriptObject = NULL;
00081 #endif
00082 }
00083
00085 virtual ~wxPGEditor();
00086
00090 virtual wxPG_CONST_WXCHAR_PTR GetName() const = 0;
00091
00105 virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property,
00106 const wxPoint& pos, const wxSize& size ) const = 0;
00107 #define wxPG_DECLARE_CREATECONTROLS \
00108 virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property, \
00109 const wxPoint& pos, const wxSize& sz ) const;
00110
00112 virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const = 0;
00113
00118
00119
00122 virtual void DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const;
00123
00127 virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
00128 wxWindow* wnd_primary, wxEvent& event ) const = 0;
00129
00130 #ifndef DOXYGEN
00131 private:
00132 #else
00133 public:
00134 #endif
00135
00139 virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const WX_PG_NOT_PURE_IN_WXPYTHON;
00140 public:
00141
00142 #ifdef __WXPYTHON__
00143 virtual wxPGVariantAndBool PyGetValueFromControl( wxPGProperty* property, wxWindow* ctrl ) const;
00144 #endif
00145
00146 bool ActualGetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const
00147 {
00148 #ifdef __WXPYTHON__
00149 if ( m_scriptObject )
00150 {
00151 wxPGVariantAndBool vab = PyGetValueFromControl(property, ctrl);
00152 if ( vab.m_valueValid )
00153 variant = vab.m_value;
00154 return vab.m_result;
00155 }
00156 #endif
00157 return GetValueFromControl(variant, property, ctrl);
00158 }
00159
00161 virtual void SetValueToUnspecified( wxPGProperty* property, wxWindow* ctrl ) const = 0;
00162
00164 virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
00165
00167 virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
00168
00172 virtual int InsertItem( wxWindow* ctrl, const wxString& label, int index ) const;
00173
00177 virtual void DeleteItem( wxWindow* ctrl, int index ) const;
00178
00182 virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
00183
00187 virtual bool CanContainCustomImage() const;
00188
00189 #if defined(__WXPYTHON__) && !defined(SWIG)
00190
00191 PyObject* m_scriptObject;
00192 #endif
00193
00194 protected:
00195 };
00196
00197
00198
00199
00200
00201
00202 #define WX_PG_DECLARE_EDITOR_CLASS(CLASSNAME) \
00203 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
00204 public: \
00205 virtual wxPG_CONST_WXCHAR_PTR GetName() const; \
00206 private:
00207
00208
00209 #define WX_PG_IMPLEMENT_EDITOR_CLASS(EDITOR,CLASSNAME,BASECLASS) \
00210 IMPLEMENT_DYNAMIC_CLASS(CLASSNAME, BASECLASS) \
00211 wxPG_CONST_WXCHAR_PTR CLASSNAME::GetName() const \
00212 { \
00213 return wxT(#EDITOR); \
00214 } \
00215 wxPGEditor* wxPGEditor_##EDITOR = (wxPGEditor*) NULL; \
00216 wxPGEditor* wxPGConstruct##EDITOR##EditorClass() \
00217 { \
00218 wxASSERT( !wxPGEditor_##EDITOR ); \
00219 return new CLASSNAME(); \
00220 }
00221
00222
00223 #define WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS() \
00224 wxPG_DECLARE_CREATECONTROLS \
00225 virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const; \
00226 virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property, \
00227 wxWindow* primary, wxEvent& event ) const; \
00228 virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const; \
00229 virtual void SetValueToUnspecified( wxPGProperty* property, wxWindow* ctrl ) const;
00230
00231
00232
00233
00234
00235
00236 class WXDLLIMPEXP_PG wxPGTextCtrlEditor : public wxPGEditor
00237 {
00238 #ifndef SWIG
00239 DECLARE_DYNAMIC_CLASS(wxPGTextCtrlEditor)
00240 #endif
00241 public:
00242 wxPGTextCtrlEditor() {}
00243 virtual ~wxPGTextCtrlEditor();
00244
00245 WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
00246 virtual wxPG_CONST_WXCHAR_PTR GetName() const;
00247
00248
00249 virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
00250 virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
00251
00252
00253
00254 static bool OnTextCtrlEvent( wxPropertyGrid* propgrid,
00255 wxPGProperty* property,
00256 wxWindow* ctrl,
00257 wxEvent& event );
00258
00259 static bool GetTextCtrlValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl );
00260
00261 };
00262
00263
00264 class WXDLLIMPEXP_PG wxPGChoiceEditor : public wxPGEditor
00265 {
00266 #ifndef SWIG
00267 DECLARE_DYNAMIC_CLASS(wxPGChoiceEditor)
00268 #endif
00269 public:
00270 wxPGChoiceEditor() {}
00271 virtual ~wxPGChoiceEditor();
00272
00273 WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
00274 virtual wxPG_CONST_WXCHAR_PTR GetName() const;
00275
00276 virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
00277 virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
00278
00279 virtual int InsertItem( wxWindow* ctrl, const wxString& label, int index ) const;
00280 virtual void DeleteItem( wxWindow* ctrl, int index ) const;
00281 virtual bool CanContainCustomImage() const;
00282
00283
00284 wxWindow* CreateControlsBase( wxPropertyGrid* propgrid,
00285 wxPGProperty* property,
00286 const wxPoint& pos,
00287 const wxSize& sz,
00288 long extraStyle ) const;
00289
00290 };
00291
00292
00293 class WXDLLIMPEXP_PG wxPGComboBoxEditor : public wxPGChoiceEditor
00294 {
00295 #ifndef SWIG
00296 DECLARE_DYNAMIC_CLASS(wxPGComboBoxEditor)
00297 #endif
00298 public:
00299 wxPGComboBoxEditor() {}
00300 virtual ~wxPGComboBoxEditor();
00301
00302 wxPG_DECLARE_CREATECONTROLS
00303
00304 virtual wxPG_CONST_WXCHAR_PTR GetName() const;
00305
00306 virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const;
00307
00308 virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
00309 wxWindow* ctrl, wxEvent& event ) const;
00310
00311 virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const;
00312
00313 virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
00314
00315 };
00316
00317
00318 class WXDLLIMPEXP_PG wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
00319 {
00320 #ifndef SWIG
00321 DECLARE_DYNAMIC_CLASS(wxPGChoiceAndButtonEditor)
00322 #endif
00323 public:
00324 wxPGChoiceAndButtonEditor() {}
00325 virtual ~wxPGChoiceAndButtonEditor();
00326 virtual wxPG_CONST_WXCHAR_PTR GetName() const;
00327 wxPG_DECLARE_CREATECONTROLS
00328 };
00329
00330
00331 class WXDLLIMPEXP_PG wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
00332 {
00333 #ifndef SWIG
00334 DECLARE_DYNAMIC_CLASS(wxPGTextCtrlAndButtonEditor)
00335 #endif
00336 public:
00337 wxPGTextCtrlAndButtonEditor() {}
00338 virtual ~wxPGTextCtrlAndButtonEditor();
00339 virtual wxPG_CONST_WXCHAR_PTR GetName() const;
00340 wxPG_DECLARE_CREATECONTROLS
00341 };
00342
00343
00344 #if wxPG_INCLUDE_CHECKBOX || defined(DOXYGEN)
00345
00346
00347
00348
00349
00350 class WXDLLIMPEXP_PG wxPGCheckBoxEditor : public wxPGEditor
00351 {
00352 #ifndef SWIG
00353 DECLARE_DYNAMIC_CLASS(wxPGCheckBoxEditor)
00354 #endif
00355 public:
00356 wxPGCheckBoxEditor() {}
00357 virtual ~wxPGCheckBoxEditor();
00358
00359 virtual wxPG_CONST_WXCHAR_PTR GetName() const;
00360 WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
00361
00362 virtual void DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const;
00363
00364
00365 virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
00366 };
00367
00368 #endif
00369
00370
00371
00372
00373
00374 #define wxPGRegisterEditorClass(EDITOR) \
00375 if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
00376 { \
00377 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR) ); \
00378 }
00379
00380
00381 #define wxPGRegisterDefaultEditorClass(EDITOR) \
00382 if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
00383 { \
00384 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR), true ); \
00385 }
00386
00387 #define wxPG_INIT_REQUIRED_EDITOR(T) \
00388 wxPGRegisterEditorClass(T)
00389
00390
00391
00392
00403 class WXDLLIMPEXP_PG wxPGEditorDialogAdapter : public wxObject
00404 {
00405 #ifndef SWIG
00406 DECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter)
00407 #endif
00408 public:
00409 wxPGEditorDialogAdapter()
00410 : wxObject()
00411 {
00412 #if defined(__WXPYTHON__)
00413 m_scriptObject = NULL;
00414 #endif
00415 }
00416
00417 virtual ~wxPGEditorDialogAdapter() { }
00418
00419 bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
00420
00421 virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property ) = 0;
00422
00423 void SetValue( wxVariant value )
00424 {
00425 m_value = value;
00426 }
00427
00431 wxVariant& GetValue()
00432 {
00433 return m_value;
00434 }
00435
00436 #if defined(__WXPYTHON__) && !defined(SWIG)
00437
00438 PyObject* m_scriptObject;
00439 #endif
00440 protected:
00441
00442 private:
00443 wxVariant m_value;
00444 };
00445
00446
00447
00448
00552 class WXDLLIMPEXP_PG wxPGMultiButton : public wxWindow
00553 {
00554 public:
00555
00556 wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
00557
00558 virtual ~wxPGMultiButton() { }
00559
00560 wxWindow* GetButton( unsigned int i ) { return (wxWindow*) m_buttons[i]; }
00561 const wxWindow* GetButton( unsigned int i ) const { return (const wxWindow*) m_buttons[i]; }
00562
00565 int GetButtonId( unsigned int i ) const { return GetButton(i)->GetId(); }
00566
00569 int GetCount() const { return (int) m_buttons.size(); }
00570
00571 void Add( const wxString& label, int id = -2 );
00572 #if wxUSE_BMPBUTTON
00573 void Add( const wxBitmap& bitmap, int id = -2 );
00574 #endif
00575
00576 wxSize GetPrimarySize() const
00577 {
00578 return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
00579 }
00580
00581 void FinalizePosition( const wxPoint& pos )
00582 {
00583 Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y );
00584 }
00585
00586 #ifndef DOXYGEN
00587 protected:
00588
00589 int GenId( int id ) const;
00590
00591 wxArrayPtrVoid m_buttons;
00592 wxSize m_fullEditorSize;
00593 int m_buttonsWidth;
00594 #endif // !DOXYGEN
00595 };
00596
00597
00598
00599 #endif // _WX_PROPGRID_EDITORS_H_