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 = 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 WX_PG_DECLARE_EDITOR_CLASS(wxPGTextCtrlEditor)
00240 #endif
00241 public:
00242 wxPGTextCtrlEditor() {}
00243 virtual ~wxPGTextCtrlEditor();
00244
00245 WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
00246
00247
00248 virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
00249 virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
00250
00251
00252
00253 static bool OnTextCtrlEvent( wxPropertyGrid* propgrid,
00254 wxPGProperty* property,
00255 wxWindow* ctrl,
00256 wxEvent& event );
00257
00258 static bool GetTextCtrlValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl );
00259
00260 };
00261
00262
00263 class WXDLLIMPEXP_PG wxPGChoiceEditor : public wxPGEditor
00264 {
00265 #ifndef SWIG
00266 WX_PG_DECLARE_EDITOR_CLASS(wxPGChoiceEditor)
00267 #endif
00268 public:
00269 wxPGChoiceEditor() {}
00270 virtual ~wxPGChoiceEditor();
00271
00272 WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
00273
00274 virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
00275 virtual void SetControlStringValue( wxPGProperty* property, wxWindow* ctrl, const wxString& txt ) const;
00276
00277 virtual int InsertItem( wxWindow* ctrl, const wxString& label, int index ) const;
00278 virtual void DeleteItem( wxWindow* ctrl, int index ) const;
00279 virtual bool CanContainCustomImage() const;
00280
00281
00282 wxWindow* CreateControlsBase( wxPropertyGrid* propgrid,
00283 wxPGProperty* property,
00284 const wxPoint& pos,
00285 const wxSize& sz,
00286 long extraStyle ) const;
00287
00288 };
00289
00290
00291 class WXDLLIMPEXP_PG wxPGComboBoxEditor : public wxPGChoiceEditor
00292 {
00293 #ifndef SWIG
00294 WX_PG_DECLARE_EDITOR_CLASS(wxPGComboBoxEditor)
00295 #endif
00296 public:
00297 wxPGComboBoxEditor() {}
00298 virtual ~wxPGComboBoxEditor();
00299
00300 wxPG_DECLARE_CREATECONTROLS
00301
00302 virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl ) const;
00303
00304 virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
00305 wxWindow* ctrl, wxEvent& event ) const;
00306
00307 virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty* property, wxWindow* ctrl ) const;
00308
00309 virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
00310
00311 };
00312
00313
00314 class WXDLLIMPEXP_PG wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
00315 {
00316 #ifndef SWIG
00317 WX_PG_DECLARE_EDITOR_CLASS(wxPGChoiceAndButtonEditor)
00318 #endif
00319 public:
00320 wxPGChoiceAndButtonEditor() {}
00321 virtual ~wxPGChoiceAndButtonEditor();
00322 wxPG_DECLARE_CREATECONTROLS
00323 };
00324
00325
00326 class WXDLLIMPEXP_PG wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
00327 {
00328 #ifndef SWIG
00329 WX_PG_DECLARE_EDITOR_CLASS(wxPGTextCtrlAndButtonEditor)
00330 #endif
00331 public:
00332 wxPGTextCtrlAndButtonEditor() {}
00333 virtual ~wxPGTextCtrlAndButtonEditor();
00334 wxPG_DECLARE_CREATECONTROLS
00335 };
00336
00337
00338 #if wxPG_INCLUDE_CHECKBOX || defined(DOXYGEN)
00339
00340
00341
00342
00343
00344 class WXDLLIMPEXP_PG wxPGCheckBoxEditor : public wxPGEditor
00345 {
00346 #ifndef SWIG
00347 WX_PG_DECLARE_EDITOR_CLASS(wxPGCheckBoxEditor)
00348 #endif
00349 public:
00350 wxPGCheckBoxEditor() {}
00351 virtual ~wxPGCheckBoxEditor();
00352
00353 WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
00354
00355 virtual void DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property, const wxString& text ) const;
00356
00357
00358 virtual void SetControlIntValue( wxPGProperty* property, wxWindow* ctrl, int value ) const;
00359 };
00360
00361 #endif
00362
00363
00364
00365
00366
00367 #define wxPGRegisterEditorClass(EDITOR) \
00368 if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
00369 { \
00370 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR) ); \
00371 }
00372
00373
00374 #define wxPGRegisterDefaultEditorClass(EDITOR) \
00375 if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
00376 { \
00377 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR), true ); \
00378 }
00379
00380 #define wxPG_INIT_REQUIRED_EDITOR(T) \
00381 wxPGRegisterEditorClass(T)
00382
00383
00384
00385
00396 class WXDLLIMPEXP_PG wxPGEditorDialogAdapter : public wxObject
00397 {
00398 #ifndef SWIG
00399 DECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter)
00400 #endif
00401 public:
00402 wxPGEditorDialogAdapter()
00403 : wxObject()
00404 {
00405 #if defined(__WXPYTHON__)
00406 m_scriptObject = NULL;
00407 #endif
00408 }
00409
00410 virtual ~wxPGEditorDialogAdapter() { }
00411
00412 bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
00413
00414 virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property ) = 0;
00415
00416 void SetValue( wxVariant value )
00417 {
00418 m_value = value;
00419 }
00420
00424 wxVariant& GetValue()
00425 {
00426 return m_value;
00427 }
00428
00429 #if defined(__WXPYTHON__) && !defined(SWIG)
00430
00431 PyObject* m_scriptObject;
00432 #endif
00433 protected:
00434
00435 private:
00436 wxVariant m_value;
00437 };
00438
00439
00440
00441
00545 class WXDLLIMPEXP_PG wxPGMultiButton : public wxWindow
00546 {
00547 public:
00548
00549 wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
00550
00551 virtual ~wxPGMultiButton() { }
00552
00553 wxWindow* GetButton( unsigned int i ) { return (wxWindow*) m_buttons[i]; }
00554 const wxWindow* GetButton( unsigned int i ) const { return (const wxWindow*) m_buttons[i]; }
00555
00558 int GetButtonId( unsigned int i ) const { return GetButton(i)->GetId(); }
00559
00562 int GetCount() const { return (int) m_buttons.size(); }
00563
00564 void Add( const wxString& label, int id = -2 );
00565 #if wxUSE_BMPBUTTON
00566 void Add( const wxBitmap& bitmap, int id = -2 );
00567 #endif
00568
00569 wxSize GetPrimarySize() const
00570 {
00571 return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
00572 }
00573
00574 void FinalizePosition( const wxPoint& pos )
00575 {
00576 Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y );
00577 }
00578
00579 #ifndef DOXYGEN
00580 protected:
00581
00582 int GenId( int id ) const;
00583
00584 wxArrayPtrVoid m_buttons;
00585 wxSize m_fullEditorSize;
00586 int m_buttonsWidth;
00587 #endif // !DOXYGEN
00588 };
00589
00590
00591
00592
00593
00594 WXDLLIMPEXP_PG bool wxPG_TextCtrl_SetMargins(wxWindow* tc,
00595 const wxPoint& margins);
00596
00597
00598
00599 #endif // _WX_PROPGRID_EDITORS_H_