[wxmax commit] r164 - in trunk/wx.mod: samples wxpropgrid.mod wxpropgrid.mod/doc wxpropgrid.mod/src wxpropgrid.m...

8 views
Skip to first unread message

codesite...@google.com

unread,
Dec 15, 2007, 11:57:07 AM12/15/07
to wx...@googlegroups.com
Author: woollybah
Date: Sat Dec 15 08:55:59 2007
New Revision: 164

Added:
trunk/wx.mod/samples/propgrid.bmx
trunk/wx.mod/wxpropgrid.mod/
trunk/wx.mod/wxpropgrid.mod/common.bmx
trunk/wx.mod/wxpropgrid.mod/doc/
trunk/wx.mod/wxpropgrid.mod/glue.cpp
trunk/wx.mod/wxpropgrid.mod/glue.h
trunk/wx.mod/wxpropgrid.mod/src/
trunk/wx.mod/wxpropgrid.mod/src/advprops.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/editors.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/extras.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/
trunk/wx.mod/wxpropgrid.mod/src/include/wx/
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/advprops.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/editors.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/extras.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/manager.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/odcombo.h
(contents, props changed)

trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/pg_dox_mainpage.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/propdev.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/propgrid.doxygen
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/propgrid.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/props.h
(contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/manager.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/odcombo.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/propgrid.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/src/props.cpp (contents, props changed)
trunk/wx.mod/wxpropgrid.mod/wxpropgrid.bmx
Modified:
trunk/wx.mod/wxradiobox.mod/glue.cpp

Log:
Added wxPropGrid and sample.

Fixed wxRadioBox function using wrong type.

Added: trunk/wx.mod/samples/propgrid.bmx
==============================================================================
--- (empty file)
+++ trunk/wx.mod/samples/propgrid.bmx Sat Dec 15 08:55:59 2007
@@ -0,0 +1,493 @@
+SuperStrict
+
+Framework wx.wxApp
+Import wx.wxFrame
+Import wx.wxPropGrid
+Import wx.wxTextCtrl
+Import wx.wxRadioBox
+Import wx.wxSystemSettings
+
+New MyApp.run()
+
+
+Type MyApp Extends wxApp
+
+ Field frame:MyFrame
+
+ Method OnInit:Int()
+
+ frame = MyFrame(New MyFrame.Create(,,"wxPropertyGrid sample", -1,
-1, 300, 500))
+
+ SetTopWindow(frame)
+
+ frame.show()
+
+ Return True
+
+ End Method
+
+End Type
+
+Type MyFrame Extends wxFrame
+
+ Const PGID:Int = 1
+ Const TCID:Int = 2
+ Const ID_ABOUT:Int = wxID_ABOUT
+ Const ID_QUIT:Int = wxID_EXIT
+ Const ID_APPENDPROP:Int = 5
+ Const ID_APPENDCAT:Int = 6
+ Const ID_INSERTPROP:Int = 7
+ Const ID_INSERTCAT:Int = 8
+ Const ID_ENABLE:Int = 9
+ Const ID_HIDE:Int = 10
+ Const ID_DELETE:Int = 11
+ Const ID_DELETER:Int = 12
+ Const ID_DELETEALL:Int = 13
+ Const ID_UNSPECIFY:Int = 14
+ Const ID_ITERATE1:Int = 15
+ Const ID_ITERATE2:Int = 16
+ Const ID_ITERATE3:Int = 17
+ Const ID_ITERATE4:Int = 18
+ Const ID_CLEARMODIF:Int = 19
+ Const ID_FREEZE:Int = 20
+ Const ID_DUMPLIST:Int = 21
+ Const ID_COLOURSCHEME1:Int = 22
+ Const ID_COLOURSCHEME2:Int = 23
+ Const ID_COLOURSCHEME3:Int = 24
+ Const ID_COLOURSCHEME4:Int = 52
+ Const ID_CATCOLOURS:Int = 25
+ Const ID_SETCOLOUR:Int = 26
+ Const ID_STATICLAYOUT:Int = 27
+ Const ID_CLEAR:Int = 28
+ Const ID_POPULATE1:Int = 29
+ Const ID_POPULATE2:Int = 30
+ Const ID_COLLAPSE:Int = 31
+ Const ID_COLLAPSEALL:Int = 32
+ Const ID_GETVALUES:Int = 33
+ Const ID_SETVALUES:Int = 34
+ Const ID_SETVALUES2:Int = 35
+ Const ID_RUNTEST:Int = 36
+ Const ID_SAVETOFILE:Int = 37
+ Const ID_SAVETOFILE2:Int = 38
+ Const ID_LOADFROMFILE:Int = 39
+ Const ID_CHANGEFLAGSITEMS:Int = 40
+ Const ID_TESTINSERTCHOICE:Int = 41
+ Const ID_TESTDELETECHOICE:Int = 42
+ Const ID_INSERTPAGE:Int = 43
+ Const ID_REMOVEPAGE:Int = 44
+ Const ID_SETSPINCTRLEDITOR:Int = 45
+ Const ID_SETPROPERTYVALUE:Int = 46
+ Const ID_TESTREPLACE:Int = 47
+ Const ID_SETCOLUMNS:Int = 48
+ Const ID_TESTXRC:Int = 49
+ Const ID_ENABLECOMMONVALUES:Int = 50
+ Const ID_SELECTSTYLE:Int = 51
+
+ Field m_itemCatColours:wxMenuItem
+ Field m_itemFreeze:wxMenuItem
+ Field m_itemEnable:wxMenuItem
+
+ Field m_propGrid:wxPropertyGrid
+
+ Field m_tcPropLabel:wxTextCtrl
+ Field m_panel:wxWindow
+
+ Field m_radiobox:wxRadioBox
+
+ Method OnInit()
+
+ wxInitAllImageHandlers()
+
+ CreateGrid( wxPG_BOLD_MODIFIED | wxPG_SPLITTER_AUTO_CENTER | ..
+ wxPG_AUTO_SORT ..
+ | wxTAB_TRAVERSAL ..
+ | wxPG_TOOLBAR ..
+ | wxPG_DESCRIPTION, ..
+ wxPG_EX_MODE_BUTTONS)
+ 'wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER |
+ 'wxPG_TOOLTIPS |
+ 'wxPG_HIDE_CATEGORIES |
+ 'wxPG_LIMITED_EDITING |
+ ' extra style
+ '| wxPG_EX_AUTO_UNSPECIFIED_VALUES
+ '| wxPG_EX_GREY_LABEL_WHEN_DISABLED
+ '| wxPG_EX_NATIVE_DOUBLE_BUFFERING
+ '| wxPG_EX_HELP_AS_TOOLTIPS
+
+
+ ' Create menubar
+
+ Local menuFile:wxMenu = New wxMenu.Create("", wxMENU_TEAROFF)
+ Local menuTry:wxMenu = New wxMenu.Create()
+ Local menuTools1:wxMenu = New wxMenu.Create()
+ Local menuTools2:wxMenu = New wxMenu.Create()
+ Local menuHelp:wxMenu = New wxMenu.Create()
+
+
+ menuHelp.Append(ID_ABOUT, "&About...", "Show about dialog")
+
+ menuTools1.Append(ID_APPENDPROP, "Append New Property")
+ menuTools1.Append(ID_APPENDCAT, "Append New Category~tCtrl-S")
+ menuTools1.AppendSeparator()
+ menuTools1.Append(ID_INSERTPROP, "Insert New Property~tCtrl-Q")
+ menuTools1.Append(ID_INSERTCAT, "Insert New Category~tCtrl-W")
+ menuTools1.AppendSeparator()
+ menuTools1.Append(ID_DELETE, "Delete Selected")
+ menuTools1.Append(ID_DELETER, "Delete Random")
+ menuTools1.Append(ID_DELETEALL, "Delete All")
+ menuTools1.AppendSeparator()
+ menuTools1.Append(ID_SETCOLOUR, "Set Bg Colour")
+ menuTools1.Append(ID_UNSPECIFY, "Set to Unspecified")
+ menuTools1.Append(ID_CLEAR, "Set Value to Default")
+ menuTools1.AppendSeparator()
+ m_itemEnable = menuTools1.Append(ID_ENABLE, "Enable", "Toggles
item's enabled state.")
+ m_itemEnable.Enable( False )
+ menuTools1.Append(ID_HIDE, "Hide", "Shows or hides a property")
+
+ menuTools2.Append(ID_ITERATE1, "Iterate Over Properties")
+ menuTools2.Append(ID_ITERATE2, "Iterate Over Visible Items")
+ menuTools2.Append(ID_ITERATE3, "Reverse Iterate Over Properties")
+ menuTools2.Append(ID_ITERATE4, "Iterate Over Categories")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_SETPROPERTYVALUE, "Set Property Value")
+ menuTools2.Append(ID_CLEARMODIF, "Clear Modified Status", "Clears
wxPG_MODIFIED flag from all properties.")
+ menuTools2.AppendSeparator()
+ m_itemFreeze =
menuTools2.AppendCheckItem(ID_FREEZE, "Freeze", "Disables painting,
auto-sorting, etc.")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_DUMPLIST, "Display Values as wxVariant
List", "Tests GetAllValues method and wxVariant conversion.")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_GETVALUES, "Get Property Values", "Stores all
property values.")
+ menuTools2.Append(ID_SETVALUES, "Set Property Values", "Reverts
property values to those last stored.")
+ menuTools2.Append(ID_SETVALUES2, "Set Property Values 2", "Adds
property values that should not initially be as items (so new items are created).")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_COLLAPSE, "Collapse Selected")
+ menuTools2.Append(ID_COLLAPSEALL, "Collapse All")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_INSERTPAGE, "Add Page")
+ menuTools2.Append(ID_REMOVEPAGE, "Remove Page")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_CHANGEFLAGSITEMS, "Change Children of FlagsProp")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_TESTINSERTCHOICE, "Test InsertPropertyChoice")
+ menuTools2.Append(ID_TESTDELETECHOICE, "Test DeletePropertyChoice")
+ menuTools2.AppendSeparator()
+ menuTools2.Append(ID_SETSPINCTRLEDITOR, "Use SpinCtrl Editor")
+ menuTools2.Append(ID_TESTREPLACE, "Test ReplaceProperty")
+
+ menuTry.Append(ID_SELECTSTYLE, "Set Window Style", "Select window
style flags used by the grid.")
+ menuTry.AppendSeparator()
+
+ menuTry.AppendRadioItem( ID_COLOURSCHEME1, "Standard Colour Scheme")
+ menuTry.AppendRadioItem( ID_COLOURSCHEME2, "White Colour Scheme")
+ menuTry.AppendRadioItem( ID_COLOURSCHEME3, ".NET Colour Scheme")
+ menuTry.AppendRadioItem( ID_COLOURSCHEME4, "Cream Colour Scheme")
+ menuTry.AppendSeparator()
+ m_itemCatColours =
menuTry.AppendCheckItem(ID_CATCOLOURS, "Category Specific Colours", ..
+ "Switches between category-specific cell colours and default
scheme (actually done using SetPropertyTextColour and SetPropertyBackgroundColour).")
+ menuTry.AppendSeparator()
+ menuTry.AppendCheckItem(ID_STATICLAYOUT, "Static
Layout", "Switches between user-modifiedable and static layouts.")
+ menuTry.Append(ID_SETCOLUMNS, "Set Number of Columns")
+ menuTry.Append(ID_ENABLECOMMONVALUES, "Use Common Values", "Enable
values that are common to all properties.")
+ menuTry.AppendSeparator()
+ menuTry.Append(ID_TESTXRC, "Display XRC sample")
+ menuTry.AppendSeparator()
+ menuTry.Append(ID_RUNTEST, "Run Tests")
+
+ menuFile.Append(ID_SAVETOFILE, "&Save Page (use class names)...", ..
+ "Saves current property page to a text file, using property
class names.")
+ menuFile.Append(ID_SAVETOFILE2, "&Save Page (use value names)...", ..
+ "Saves current property page to a text file, using property
value type names.")
+ menuFile.Append(ID_LOADFROMFILE, "&Load Page...", "Loads current
property page from a text file")
+ menuFile.AppendSeparator()
+ menuFile.Append(ID_QUIT, "E&xit~tAlt-X", "Quit this program")
+
+ ' Now append the freshly created menu To the menu bar...
+
+ Local menuBar:wxMenuBar = New wxMenuBar.Create()
+ menuBar.Append(menuFile, "&File")
+ menuBar.Append(menuTry, "&Try These!")
+ menuBar.Append(menuTools1, "&Basic")
+ menuBar.Append(menuTools2, "&Advanced")
+ menuBar.Append(menuHelp, "&Help")
+
+ ' ... And attach this menu bar To the frame
+ SetMenuBar(menuBar)
+
+ ' Create a status bar
+ CreateStatusBar(1)
+ SetStatusText("")
+
+ 'Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, OnQuit)
+ 'Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, OnAbout)
+
+ End Method
+
+ Method CreateGrid( style:Int, extraStyle:Int )
+
+ Local wasCreated:Int = False
+
+ If m_panel Then
+ wasCreated = True
+ m_panel.Destroy()
+ End If
+
+ Local panel:wxWindow = New wxPanel.Create(Self, -1, 0, 0, 400, 400)
+ m_panel = panel
+
+ ' Column
+ Local topSizer:wxBoxSizer = New wxBoxSizer.Create( wxVERTICAL )
+
+ Local rb_items:String[] = ["Categorized", "Alphabetic"]
+ m_radiobox = New wxRadioBox.Create( panel, TCID, " Mode ", -1, -1,
-1, -1, rb_items, 2, wxRA_SPECIFY_COLS )
+
+ Connect(m_radiobox.GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED,
OnRadioBoxChange )
+
+ topSizer.Add( m_radiobox, 0, wxEXPAND )
+
+
+ Local pg:wxPropertyGrid = New wxPropertyGrid.Create(panel, PGID, -1,
-1, -1, -1, style )
+ m_propGrid = pg
+
+ pg.SetExtraStyle(extraStyle)
+
+ PopulateWithStandardItems()
+
+ topSizer.Add( m_propGrid, 1, wxEXPAND )
+
+ panel.SetSizer( topSizer )
+ topSizer.SetSizeHints( panel )
+
+ Local panelSizer:wxBoxSizer = New wxBoxSizer.Create( wxHORIZONTAL )
+ panelSizer.Add( panel, 1, wxEXPAND|wxFIXED_MINSIZE )
+ SetSizer( panelSizer )
+ panelSizer.SetSizeHints( Self )
+
+ If wasCreated Then
+ SetSize( ..
+ (wxSystemSettings.GetMetric(wxSYS_SCREEN_X)/10)*4, ..
+ (wxSystemSettings.GetMetric(wxSYS_SCREEN_Y)/10)*8)
+ Centre()
+ End If
+
+ End Method
+
+ Method PopulateWithStandardItems()
+
+ Local pg:wxPropertyGrid = m_propGrid
+
+ Local pid:wxPGId
+
+ ' Append is ideal way To add items To wxPropertyGrid.
+ pg.Append( New wxPropertyCategory.Create("Appearance", wxPG_LABEL) )
+
+ pg.Append( New wxStringProperty.Create("Label", wxPG_LABEL,
GetTitle()) )
+
+ pg.Append( New wxFontProperty.Create("Font", wxPG_LABEL) )
+ pg.SetPropertyHelpString("Font", "Editing this will change font used
in the property grid.")
+
+ pg.Append( New wxSystemColourProperty.Create("Margin Colour",
wxPG_LABEL, pg.GetGrid().GetMarginColour()) )
+
+
+
+ pg.Append( New wxSystemColourProperty.Create("Cell Colour",
wxPG_LABEL, pg.GetGrid().GetCellBackgroundColour()) )
+
+ pg.Append( New wxSystemColourProperty.Create("Cell Text Colour",
wxPG_LABEL, pg.GetGrid().GetCellTextColour()) )
+
+ pg.Append( New wxSystemColourProperty.Create("Line Colour",
wxPG_LABEL, pg.GetGrid().GetLineColour()) )
+
+' pg.Append( New wxFlagsProperty.Create("Window Styles", wxPG_LABEL,
m_combinedFlags, GetWindowStyle()) )
+
+
+ End Method
+
+ Method PopulateWithExamples()
+ End Method
+
+ Method PopulateWithLibraryConfig()
+ End Method
+
+
+ Function OnCloseClick( event:wxEvent )
+ End Function
+
+ Function OnLabelTextChange( event:wxEvent )
+ End Function
+
+
+ Function OnColourScheme( event:wxEvent )
+ End Function
+
+
+ Function OnInsertPropClick( event:wxEvent )
+ End Function
+
+ Function OnAppendPropClick( event:wxEvent )
+ End Function
+
+ Function OnClearClick( event:wxEvent )
+ End Function
+
+ Function OnAppendCatClick( event:wxEvent )
+ End Function
+
+ Function OnInsertCatClick( event:wxEvent )
+ End Function
+
+ Function OnDelPropClick( event:wxEvent )
+ End Function
+
+ Function OnDelPropRClick( event:wxEvent )
+ End Function
+
+
+ Function OnContextMenu( event:wxEvent )
+ End Function
+
+
+ Function OnEnableDisable( event:wxEvent )
+ End Function
+
+ Function OnHideShow( event:wxEvent )
+ End Function
+
+ Function OnClearModifyStatusClick( event:wxEvent )
+ End Function
+
+ Function OnFreezeClick( event:wxEvent )
+ End Function
+
+ Function OnDumpList( event:wxEvent )
+ End Function
+
+ Function OnCatColours( event:wxEvent )
+ End Function
+
+ Function OnSetColumns( event:wxEvent )
+ End Function
+
+ Function OnMisc( event:wxEvent )
+ End Function
+
+ Function OnPopulateClick( event:wxEvent )
+ End Function
+
+ Function OnSetSpinCtrlEditorClick( event:wxEvent )
+ End Function
+
+ Function OnTestReplaceClick( event:wxEvent )
+ End Function
+
+ Function OnTestXRC( event:wxEvent )
+ End Function
+
+ Function OnEnableCommonValues( event:wxEvent )
+ End Function
+
+ Function OnSelectStyle( event:wxEvent )
+ End Function
+
+
+ Function OnChangeFlagsPropItemsClick( event:wxEvent )
+ End Function
+
+
+ Function OnSaveToFileClick( event:wxEvent )
+ End Function
+
+ Function OnLoadFromFileClick( event:wxEvent )
+ End Function
+
+
+ Function OnSetPropertyValue( event:wxEvent )
+ End Function
+
+ Function OnInsertChoice( event:wxEvent )
+ End Function
+
+ Function OnDeleteChoice( event:wxEvent )
+ End Function
+
+ Function OnInsertPage( event:wxEvent )
+ End Function
+
+ Function OnRemovePage( event:wxEvent )
+ End Function
+
+
+ Function OnRadioBoxChange( event:wxEvent )
+ End Function
+
+
+ Function OnIterate1Click( event:wxEvent )
+ End Function
+
+ Function OnIterate2Click( event:wxEvent )
+ End Function
+
+ Function OnIterate3Click( event:wxEvent )
+ End Function
+
+ Function OnIterate4Click( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridChange( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridChanging( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridSelect( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridHighlight( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridItemRightClick( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridItemDoubleClick( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridPageChange( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridButtonClick( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridTextUpdate( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridKeyEvent( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridItemCollapse( event:wxEvent )
+ End Function
+
+ Function OnPropertyGridItemExpand( event:wxEvent )
+ End Function
+
+ Function OnAbout( event:wxEvent )
+ End Function
+
+ Function OnMove( event:wxEvent )
+ End Function
+
+ Function OnResize( event:wxEvent )
+ End Function
+
+ Function OnPaint( event:wxEvent )
+ End Function
+
+ Function OnCloseEvent( event:wxEvent )
+ End Function
+
+ Function OnIdle( event:wxEvent )
+ End Function
+
+ Method RunTests()
+ End Method
+
+
+
+End Type
+

Added: trunk/wx.mod/wxpropgrid.mod/common.bmx
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/common.bmx Sat Dec 15 08:55:59 2007
@@ -0,0 +1,125 @@
+' Copyright (c) 2007 Bruce A Henderson
+'
+' Permission is hereby granted, free of charge, to any person
obtaining a copy
+' of this software and associated documentation files
(the "Software"), to deal
+' in the Software without restriction, including without limitation
the rights
+' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+' copies of the Software, and to permit persons to whom the Software is
+' furnished to do so, subject to the following conditions:
+'
+' The above copyright notice and this permission notice shall be
included in
+' all copies or substantial portions of the Software.
+'
+' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
+' THE SOFTWARE.
+'
+SuperStrict
+
+Import wx.wx
+Import wx.wxPanel
+Import BRL.Blitz
+
+
+' headers :-)
+?linux
+Import "../lib/linux/wx/include/gtk2-unicode-release-static/*.h"
+Import "../include/*.h"
+?win32
+Import "../lib/win32/mswu/*.h"
+Import "../include/*.h"
+?macosppc
+Import "../lib/macosppc/wx/include/mac-unicode-release-static/*.h"
+Import "../include/*.h"
+?macosx86
+Import "../lib/macosx86/wx/include/mac-unicode-release-static/*.h"
+Import "../include/*.h"
+?
+
+Import "src/include/*.h"
+
+Import "src/advprops.cpp"
+Import "src/editors.cpp"
+Import "src/extras.cpp"
+Import "src/manager.cpp"
+Import "src/odcombo.cpp"
+Import "src/propgrid.cpp"
+Import "src/props.cpp"
+
+Import "glue.cpp"
+
+Extern
+
+ Function bmx_wxpropertygrid_create:Byte Ptr(handle:Object,
parent:Byte Ptr, id:Int, x:Int, y:Int, w:Int, h:Int, style:Int)
+ Function bmx_wxpropertygrid_append:Byte Ptr(handle:Byte Ptr,
property:Byte Ptr)
+ Function bmx_wxpropertygrid_getgrid:Byte Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getcaptionbackgroundcolour:Byte
Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getcaptionforegroundcolour:Byte
Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getcellbackgroundcolour:Byte
Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getcelldisabledtextcolour:Byte
Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getcelltextcolour:Byte Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getlinecolour:Byte Ptr(handle:Byte Ptr)
+ Function bmx_wxpropertygrid_getmargincolour:Byte Ptr(handle:Byte Ptr)
+
+ Function bmx_wxstringproperty_create:Byte Ptr(label:String,
name:String, value:String)
+
+ Function bmx_wxpropertycategory_create:Byte Ptr(label:String, name:String)
+
+ Function bmx_wxfontproperty_create:Byte Ptr(label:String,
name:String, font:Byte Ptr)
+
+ Function
bmx_wxpropertycontainermethods_setpropertyhelpstringid(handle:Byte Ptr,
id:Byte Ptr, helpString:String)
+ Function
bmx_wxpropertycontainermethods_setpropertyhelpstring(handle:Byte Ptr,
name:String, helpString:String)
+
+ Function bmx_wxsystemcolourproperty_create:Byte Ptr(label:String,
name:String, value:Byte Ptr)
+
+ Function bmx_wxcolourpropertyvalue_delete(handle:Byte Ptr)
+
+ Function bmx_wxpgid_delete(handle:Byte Ptr)
+
+End Extern
+
+Const wxPG_LABEL:String = Null
+
+Const wxPG_AUTO_SORT:Int = $00000010
+
+Const wxPG_HIDE_CATEGORIES:Int = $00000020
+Const wxPG_ALPHABETIC_MODE:Int = wxPG_HIDE_CATEGORIES | wxPG_AUTO_SORT
+Const wxPG_BOLD_MODIFIED:Int = $00000040
+Const wxPG_SPLITTER_AUTO_CENTER:Int = $00000080
+Const wxPG_TOOLTIPS:Int = $00000100
+Const wxPG_HIDE_MARGIN:Int = $00000200
+Const wxPG_STATIC_SPLITTER:Int = $00000400
+Const wxPG_STATIC_LAYOUT:Int = wxPG_HIDE_MARGIN | wxPG_STATIC_SPLITTER
+Const wxPG_LIMITED_EDITING:Int = $00000800
+Const wxPG_TOOLBAR:Int = $00001000
+Const wxPG_DESCRIPTION:Int = $00002000
+Const wxPG_COMPACTOR:Int = $00004000
+
+Const wxPG_EX_INIT_NOCAT:Int = $00001000
+Const wxPG_EX_NO_FLAT_TOOLBAR:Int = $00002000
+Const wxPG_EX_MODE_BUTTONS:Int = $00008000
+Const wxPG_EX_HELP_AS_TOOLTIPS:Int = $00010000
+Const wxPG_EX_GREY_LABEL_WHEN_DISABLED:Int = $00040000
+Const wxPG_EX_NATIVE_DOUBLE_BUFFERING:Int = $00080000
+Const wxPG_EX_PROCESS_EVENTS_IMMEDIATELY:Int = $00100000
+Const wxPG_EX_AUTO_UNSPECIFIED_VALUES:Int = $00200000
+
+Const wxPG_DEFAULT_STYLE:Int = 0
+Const wxPGMAN_DEFAULT_STYLE:Int = 0
+Const wxPG_KEEP_STRUCTURE:Int = $00000010
+Const wxPG_RECURSE:Int = $00000020
+Const wxPG_RECURSE_STARTS:Int = $00000040
+Const wxPG_FORCE:Int = $00000080
+
+Const wxPG_LOW:Int = 1
+Const wxPG_HIGH:Int = 2
+
+Const wxPG_FULL_VALUE:Int = $00000001
+Const wxPG_REPORT_ERROR:Int = $00000002
+Const wxPG_PROPERTY_SPECIFIC:Int = $00000004
+Const wxPG_EDITABLE_VALUE:Int = $00000008
+

Added: trunk/wx.mod/wxpropgrid.mod/glue.cpp
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/glue.cpp Sat Dec 15 08:55:59 2007
@@ -0,0 +1,163 @@
+/*
+ Copyright (c) 2007 Bruce A Henderson
+
+ Permission is hereby granted, free of charge, to any person
obtaining a copy
+ of this software and associated documentation files
(the "Software"), to deal
+ in the Software without restriction, including without limitation
the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
+ THE SOFTWARE.
+*/
+
+#include "glue.h"
+
+// ---------------------------------------------------------------------------------------
+
+MaxPropertyGrid::MaxPropertyGrid(BBObject * handle, wxWindow * parent,
wxWindowID id, int x, int y,
+ int w, int h, long style)
+ : wxPropertyGrid(parent, id, wxPoint(x, y), wxSize(w, h), style)
+{
+ wxbind(this, handle);
+}
+
+MaxPropertyGrid::~MaxPropertyGrid() {
+ wxunbind(this);
+}
+
+MaxPGId::MaxPGId(const wxPGId& p)
+{
+ pgId = wxPGId(p);
+}
+
+wxPGId & MaxPGId::PGId() {
+ return pgId;
+}
+
+MaxColourPropertyValue::MaxColourPropertyValue(const
wxColourPropertyValue& v)
+{
+ value = wxColourPropertyValue(v);
+}
+
+wxColourPropertyValue & MaxColourPropertyValue::Value() {
+ return value;
+}
+
+// *********************************************
+
+wxPropertyGrid * bmx_wxpropertygrid_create(BBObject * handle, wxWindow
* parent, wxWindowID id, int x, int y, int w, int h, long style) {
+ return new MaxPropertyGrid(handle, parent, id, x, y, w, h, style);
+}
+
+MaxPGId * bmx_wxpropertygrid_append(wxPropertyGrid * grid,
wxPGProperty * property) {
+ return new MaxPGId(grid->Append(property));
+}
+
+wxPropertyGrid * bmx_wxpropertygrid_getgrid(wxPropertyGrid * grid) {
+ return grid->GetGrid();
+}
+
+MaxColour *
bmx_wxpropertygrid_getcaptionbackgroundcolour(wxPropertyGrid * grid) {
+ wxColour c(grid->GetCaptionBackgroundColour());
+ return new MaxColour(c);
+}
+
+MaxColour *
bmx_wxpropertygrid_getcaptionforegroundcolour(wxPropertyGrid * grid) {
+ wxColour c(grid->GetCaptionForegroundColour());
+ return new MaxColour(c);
+}
+
+MaxColour * bmx_wxpropertygrid_getcellbackgroundcolour(wxPropertyGrid
* grid) {
+ wxColour c(grid->GetCellBackgroundColour());
+ return new MaxColour(c);
+}
+
+MaxColour *
bmx_wxpropertygrid_getcelldisabledtextcolour(wxPropertyGrid * grid) {
+ wxColour c(grid->GetCellDisabledTextColour());
+ return new MaxColour(c);
+}
+
+MaxColour * bmx_wxpropertygrid_getcelltextcolour(wxPropertyGrid *
grid) {
+ wxColour c(grid->GetCellTextColour());
+ return new MaxColour(c);
+}
+
+MaxColour * bmx_wxpropertygrid_getlinecolour(wxPropertyGrid * grid) {
+ wxColour c(grid->GetLineColour());
+ return new MaxColour(c);
+}
+
+MaxColour * bmx_wxpropertygrid_getmargincolour(wxPropertyGrid * grid) {
+ wxColour c(grid->GetMarginColour());
+ return new MaxColour(c);
+}
+
+
+// *********************************************
+
+wxPGProperty * bmx_wxstringproperty_create(BBString * label, BBString
* name, BBString * value) {
+ if (name != &bbEmptyString) {
+ return new wxStringProperty(wxStringFromBBString(label),
wxStringFromBBString(name), wxStringFromBBString(value));
+ } else {
+ return new wxStringProperty(wxStringFromBBString(label), wxPG_LABEL, wxStringFromBBString(value));
+ }
+}
+
+// *********************************************
+
+wxPGProperty * bmx_wxpropertycategory_create(BBString * label,
BBString * name) {
+ if (name != &bbEmptyString) {
+ return new wxPropertyCategory(wxStringFromBBString(label), wxStringFromBBString(name));
+ } else {
+ return new wxPropertyCategory(wxStringFromBBString(label));
+ }
+}
+
+// *********************************************
+
+wxPGProperty * bmx_wxfontproperty_create(BBString * label, BBString *
name, MaxFont * font) {
+ return new wxFontProperty(wxStringFromBBString(label),
+ (name != &bbEmptyString) ? wxStringFromBBString(name) : wxPG_LABEL,
+ (font) ? font->Font() : wxFont());
+}
+
+// *********************************************
+
+void
bmx_wxpropertycontainermethods_setpropertyhelpstringid(wxPropertyContainerMethods
* prop, MaxPGId * id, BBString * helpString) {
+ prop->SetPropertyHelpString(id->PGId(), wxStringFromBBString(helpString));
+}
+
+void
bmx_wxpropertycontainermethods_setpropertyhelpstring(wxPropertyContainerMethods
* prop, BBString * name, BBString * helpString) {
+ prop->SetPropertyHelpString(wxStringFromBBString(name), wxStringFromBBString(helpString));
+}
+
+// *********************************************
+
+wxSystemColourProperty * bmx_wxsystemcolourproperty_create(BBString *
label, BBString * name, MaxColour * value) {
+ return new wxSystemColourProperty(wxStringFromBBString(label),
+ (name != &bbEmptyString) ? wxStringFromBBString(name) : wxPG_LABEL,
+ (value) ? value->Colour() : wxColour());
+}
+
+// *********************************************
+
+void bmx_wxcolourpropertyvalue_delete(MaxColourPropertyValue * value) {
+ delete value;
+}
+
+// *********************************************
+
+void bmx_wxpgid_delete(MaxPGId * id) {
+ delete id;
+}
+

Added: trunk/wx.mod/wxpropgrid.mod/glue.h
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/glue.h Sat Dec 15 08:55:59 2007
@@ -0,0 +1,95 @@
+/*
+ Copyright (c) 2007 Bruce A Henderson
+
+ Permission is hereby granted, free of charge, to any person
obtaining a copy
+ of this software and associated documentation files
(the "Software"), to deal
+ in the Software without restriction, including without limitation
the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
+ THE SOFTWARE.
+*/
+
+#include "wxglue.h"
+#include "wx/propgrid/propgrid.h"
+#include "wx/propgrid/advprops.h"
+
+class MaxPropertyGrid;
+class MaxPGId;
+class MaxColourPropertyValue;
+
+extern "C" {
+
+#include <blitz.h>
+
+ wxPropertyGrid * bmx_wxpropertygrid_create(BBObject * handle,
wxWindow * parent, wxWindowID id, int x, int y, int w, int h, long style);
+ MaxPGId * bmx_wxpropertygrid_append(wxPropertyGrid * grid,
wxPGProperty * property);
+ wxPropertyGrid * bmx_wxpropertygrid_getgrid(wxPropertyGrid * grid);
+ MaxColour *
bmx_wxpropertygrid_getcaptionbackgroundcolour(wxPropertyGrid * grid);
+ MaxColour *
bmx_wxpropertygrid_getcaptionforegroundcolour(wxPropertyGrid * grid);
+ MaxColour * bmx_wxpropertygrid_getcellbackgroundcolour(wxPropertyGrid
* grid);
+ MaxColour *
bmx_wxpropertygrid_getcelldisabledtextcolour(wxPropertyGrid * grid);
+ MaxColour * bmx_wxpropertygrid_getcelltextcolour(wxPropertyGrid * grid);
+ MaxColour * bmx_wxpropertygrid_getlinecolour(wxPropertyGrid * grid);
+ MaxColour * bmx_wxpropertygrid_getmargincolour(wxPropertyGrid * grid);
+
+ wxPGProperty * bmx_wxstringproperty_create(BBString * label, BBString
* name, BBString * value);
+
+ wxPGProperty * bmx_wxpropertycategory_create(BBString * label,
BBString * name);
+
+ wxPGProperty * bmx_wxfontproperty_create(BBString * label, BBString *
name, MaxFont * font);
+
+ void
bmx_wxpropertycontainermethods_setpropertyhelpstringid(wxPropertyContainerMethods
* prop, MaxPGId * id, BBString * helpString);
+ void
bmx_wxpropertycontainermethods_setpropertyhelpstring(wxPropertyContainerMethods
* prop, BBString * name, BBString * helpString);
+
+ wxSystemColourProperty * bmx_wxsystemcolourproperty_create(BBString *
label, BBString * name, MaxColour * value);
+
+ void bmx_wxcolourpropertyvalue_delete(MaxColourPropertyValue * value);
+
+ void bmx_wxpgid_delete(MaxPGId * id);
+
+}
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+class MaxPGId
+{
+public:
+ MaxPGId(const wxPGId & p);
+ wxPGId & PGId();
+
+private:
+ wxPGId pgId;
+
+};
+
+class MaxPropertyGrid : public wxPropertyGrid
+{
+public:
+ MaxPropertyGrid(BBObject * handle, wxWindow * parent, wxWindowID id,
int x, int y, int w, int h, long style);
+ ~ MaxPropertyGrid();
+
+};
+
+class MaxColourPropertyValue
+{
+public:
+ MaxColourPropertyValue(const wxColourPropertyValue & v);
+ wxColourPropertyValue & Value();
+
+private:
+ wxColourPropertyValue value;
+
+};
+

Added: trunk/wx.mod/wxpropgrid.mod/src/advprops.cpp
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/advprops.cpp Sat Dec 15 08:55:59 2007
@@ -0,0 +1,1976 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: advprops.cpp
+// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
+// Author: Jaakko Salli
+// Modified by:
+// Created: Sep-25-2004
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+ #pragma implementation "advprops.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/defs.h"
+ #include "wx/object.h"
+ #include "wx/hash.h"
+ #include "wx/string.h"
+ #include "wx/log.h"
+ #include "wx/event.h"
+ #include "wx/window.h"
+ #include "wx/panel.h"
+ #include "wx/dc.h"
+ #include "wx/dcclient.h"
+ #include "wx/button.h"
+ #include "wx/pen.h"
+ #include "wx/brush.h"
+ #include "wx/cursor.h"
+ #include "wx/dialog.h"
+ #include "wx/settings.h"
+ #include "wx/msgdlg.h"
+ #include "wx/choice.h"
+ #include "wx/stattext.h"
+ #include "wx/textctrl.h"
+ #include "wx/scrolwin.h"
+ #include "wx/dirdlg.h"
+ #include "wx/combobox.h"
+ #include "wx/layout.h"
+ #include "wx/sizer.h"
+ #include "wx/textdlg.h"
+ #include "wx/filedlg.h"
+ #include "wx/intl.h"
+#endif
+
+#define __wxPG_SOURCE_FILE__
+
+#include <wx/propgrid/propgrid.h>
+
+#if wxPG_INCLUDE_ADVPROPS
+
+#include <wx/propgrid/propdev.h>
+
+#include <wx/propgrid/advprops.h>
+
+#ifdef __WXMSW__
+ #include <wx/msw/private.h>
+#endif
+
+// -----------------------------------------------------------------------
+
+#if defined(__WXMSW__)
+ #define wxPG_CAN_DRAW_CURSOR 1
+#elif defined(__WXGTK__)
+ #define wxPG_CAN_DRAW_CURSOR 0
+#elif defined(__WXMAC__)
+ #define wxPG_CAN_DRAW_CURSOR 0
+#else
+ #define wxPG_CAN_DRAW_CURSOR 0
+#endif
+
+
+// -----------------------------------------------------------------------
+// Value type related
+// -----------------------------------------------------------------------
+
+
+bool operator == (const wxFont&, const wxFont&)
+{
+ return false;
+}
+
+// Implement dynamic class for type value.
+IMPLEMENT_DYNAMIC_CLASS(wxColourPropertyValue, wxObject)
+
+bool operator == (const wxColourPropertyValue& a, const
wxColourPropertyValue& b)
+{
+ return ( ( a.m_colour == b.m_colour ) && (a.m_type == b.m_type) );
+}
+
+bool operator == (const wxArrayInt& array1, const wxArrayInt& array2)
+{
+ if ( array1.GetCount() != array2.GetCount() )
+ return false;
+ size_t i;
+ for ( i=0; i<array1.GetCount(); i++ )
+ {
+ if ( array1[i] != array2[i] )
+ return false;
+ }
+ return true;
+}
+
+// -----------------------------------------------------------------------
+// wxSpinCtrl-based property editor
+// -----------------------------------------------------------------------
+
+#if wxUSE_SPINBTN
+
+//
+// Implement an editor control that allows using wxSpinCtrl (actually,
+// a combination of wxTextCtrl and wxSpinButton) to edit value of
+// wxIntProperty and wxFloatProperty (and similar).
+//
+// Note that new editor classes needs to be registered before use.
+// This can be accomplished using wxPGRegisterEditorClass macro, which
+// is used for SpinCtrl in wxPropertyContainerMethods::RegisterAdditionalEditors
+// (see below). Registeration can also be performed in a constructor
of a
+// property that is likely to require the editor in question.
+//
+
+
+#include <wx/spinbutt.h>
+
+
+// NOTE: Regardless that this class inherits from a working editor, it has
+// all necessary methods to work independently. wxTextCtrl stuff is only
+// used for event handling here.
+class wxPGSpinCtrlEditor : public wxPGTextCtrlEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGSpinCtrlEditor)
+public:
+ virtual ~wxPGSpinCtrlEditor();
+
+ // See below for short explanations of what these are suppposed to do.
+ wxPG_DECLARE_CREATECONTROLS
+
+ virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
+ wxWindow* wnd, wxEvent& event ) const;
+};
+
+
+// This macro also defines global wxPGEditor_SpinCtrl for storing
+// the singleton class instance.
+WX_PG_IMPLEMENT_EDITOR_CLASS(SpinCtrl,wxPGSpinCtrlEditor,wxPGEditor)
+
+
+// Trivial destructor.
+wxPGSpinCtrlEditor::~wxPGSpinCtrlEditor()
+{
+}
+
+
+// Create controls and initialize event handling.
+wxPGWindowList wxPGSpinCtrlEditor::CreateControls( wxPropertyGrid*
propgrid, wxPGProperty* property,
+ const wxPoint& pos,
const wxSize& sz ) const
+{
+ const int margin = 1;
+ wxSize butSz(18, sz.y);
+ wxSize tcSz(sz.x - butSz.x - margin, sz.y);
+ wxPoint butPos(pos.x + tcSz.x + margin, pos.y);
+
+ wxSpinButton* wnd2 = new wxSpinButton();
+#ifdef __WXMSW__
+ wnd2->Hide();
+#endif
+ wnd2->Create( propgrid->GetPanel(), wxPG_SUBID2, butPos, butSz,
wxSP_VERTICAL );
+
+ int min = INT_MIN;
+ int max = INT_MAX;
+
+ wxVariant v;
+ v = property->GetAttribute(wxT("Min"));
+ if ( wxPGIsVariantType(v, long) )
+ min = v.GetLong();
+ v = property->GetAttribute(wxT("Max"));
+ if ( wxPGIsVariantType(v, long) )
+ max = v.GetLong();
+
+ wnd2->SetRange( min, max );
+ wnd2->SetValue( 0 );
+
+ propgrid->Connect( wxPG_SUBID2, wxEVT_SCROLL_LINEUP,
+ (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
+ &wxPropertyGrid::OnCustomEditorEvent, NULL,
propgrid );
+ propgrid->Connect( wxPG_SUBID2, wxEVT_SCROLL_LINEDOWN,
+ (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
+ &wxPropertyGrid::OnCustomEditorEvent, NULL,
propgrid );
+
+ // Let's add validator to make sure only numbers can be entered
+ wxString temps;
+ wxTextValidator validator(wxFILTER_NUMERIC, &temps);
+
+ wxTextCtrl* wnd1 = (wxTextCtrl*)
wxPGTextCtrlEditor::CreateControls( propgrid, property, pos, tcSz ).m_primary;
+ wnd1->SetValidator(validator);
+
+ return wxPGWindowList(wnd1, wnd2);
+}
+
+// Control's events are redirected here
+bool wxPGSpinCtrlEditor::OnEvent( wxPropertyGrid* propgrid,
wxPGProperty* property,
+ wxWindow* wnd, wxEvent& event ) const
+{
+ int evtType = event.GetEventType();
+
+ if ( evtType == wxEVT_SCROLL_LINEUP || evtType ==
wxEVT_SCROLL_LINEDOWN )
+ {
+ wxString s;
+ // Can't use wnd since it might be clipper window
+ wxTextCtrl* tc = wxDynamicCast(propgrid->GetEditorControl(), wxTextCtrl);
+
+ if ( tc )
+ s = tc->GetValue();
+ else
+ s = property->GetValueAsString(wxPG_FULL_VALUE);
+
+ wxSpinButton* spinButton = (wxSpinButton*) propgrid->GetEditorControlSecondary();
+ int spinMin = spinButton->GetMin();
+ int spinMax = spinButton->GetMax();
+
+ if ( property->IsValueType(wxT("double")) )
+ {
+ double v_d;
+
+ // Try double
+ if ( s.ToDouble(&v_d) )
+ {
+ if ( evtType == wxEVT_SCROLL_LINEUP ) v_d += 1.0;
+ else v_d -= 1.0;
+
+ // Min/Max
+ double dSpinMin = (double) spinMin;
+ double dSpinMax = (double) spinMax;
+ if ( v_d > dSpinMax ) v_d = dSpinMax;
+ else if ( v_d < dSpinMin ) v_d = dSpinMin;
+
+ wxPropertyGrid::DoubleToString(s, v_d, 6, true, NULL);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ long v_l;
+
+ // Try long
+ if ( s.ToLong(&v_l, 0) )
+ {
+ if ( evtType == wxEVT_SCROLL_LINEUP ) v_l++;
+ else v_l--;
+
+ // Min/Max
+ if ( v_l > spinMax ) v_l = spinMax;
+ else if ( v_l < spinMin ) v_l = spinMin;
+
+ s = wxString::Format(wxT("%i"),(int)v_l);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ if ( tc )
+ tc->SetValue(s);
+
+ return true;
+ }
+
+ return wxPGTextCtrlEditor::OnEvent(propgrid,property,wnd,event);
+}
+
+#endif // wxUSE_SPINBTN
+
+
+// -----------------------------------------------------------------------
+// wxDatePickerCtrl-based property editor
+// -----------------------------------------------------------------------
+
+#if wxUSE_DATEPICKCTRL
+
+
+#include <wx/datectrl.h>
+#include <wx/dateevt.h>
+
+class wxPGDatePickerCtrlEditor : public wxPGEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGDatePickerCtrlEditor)
+public:
+ virtual ~wxPGDatePickerCtrlEditor();
+
+ wxPG_DECLARE_CREATECONTROLS
+
+ virtual void UpdateControl( wxPGProperty* property, wxWindow* wnd
) const;
+ virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
+ wxWindow* wnd, wxEvent& event ) const;
+ virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* wnd ) const;
+ virtual void SetValueToUnspecified( wxWindow* wnd ) const;
+};
+
+
+WX_PG_IMPLEMENT_EDITOR_CLASS(DatePickerCtrl,wxPGDatePickerCtrlEditor,wxPGEditor)
+
+
+wxPGDatePickerCtrlEditor::~wxPGDatePickerCtrlEditor()
+{
+}
+
+wxPGWindowList wxPGDatePickerCtrlEditor::CreateControls(
wxPropertyGrid* propgrid,
+ wxPGProperty* property,
+ const
wxPoint& pos,
+ const wxSize&
sz ) const
+{
+ wxCHECK_MSG( property->IsKindOf(WX_PG_CLASSINFO(wxDateProperty)),
+ NULL,
+ wxT("DatePickerCtrl editor can only be used with
wxDateProperty or derivative.") );
+
+ wxDateProperty* prop = (wxDateProperty*) property;
+
+ // Use two stage creation to allow cleaner display on wxMSW
+ wxDatePickerCtrl* ctrl = new wxDatePickerCtrl();
+#ifdef __WXMSW__
+ ctrl->Hide();
+ wxSize useSz = wxDefaultSize;
+ useSz.x = sz.x;
+#else
+ wxSize useSz = sz;
+#endif
+ ctrl->Create(propgrid->GetPanel(),
+ wxPG_SUBID1,
+ prop->GetDateValue(),
+ pos,
+ useSz,
+ prop->GetDatePickerStyle() | wxNO_BORDER);
+
+ // Connect all required events to grid's OnCustomEditorEvent
+ // (all relevenat wxTextCtrl, wxComboBox and wxButton events are
+ // already connected)
+ propgrid->Connect( wxPG_SUBID1, wxEVT_DATE_CHANGED,
+ (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
+ &wxPropertyGrid::OnCustomEditorEvent );
+
+#ifdef __WXMSW__
+ ctrl->Show();
+#endif
+
+ return ctrl;
+}
+
+// Copies value from property to control
+void wxPGDatePickerCtrlEditor::UpdateControl( wxPGProperty* property,
wxWindow* wnd ) const
+{
+ wxDatePickerCtrl* ctrl = (wxDatePickerCtrl*) wnd;
+ wxASSERT( ctrl && ctrl->IsKindOf(CLASSINFO(wxDatePickerCtrl)) );
+
+ // We assume that property's data type is 'int' (or something similar),
+ // thus allowing us to get raw, unchecked value via DoGetValue.
+ ctrl->SetValue( property->GetValue().GetDateTime() );
+}
+
+// Control's events are redirected here
+bool wxPGDatePickerCtrlEditor::OnEvent( wxPropertyGrid* WXUNUSED(propgrid),
+ wxPGProperty* WXUNUSED(property),
+ wxWindow* WXUNUSED(wnd),
+ wxEvent& event ) const
+{
+ if ( event.GetEventType() == wxEVT_DATE_CHANGED )
+ return true;
+
+ return false;
+}
+
+bool wxPGDatePickerCtrlEditor::GetValueFromControl( wxVariant&
variant, wxPGProperty* WXUNUSED(property), wxWindow* wnd ) const
+{
+ wxDatePickerCtrl* ctrl = (wxDatePickerCtrl*) wnd;
+ wxASSERT( ctrl && ctrl->IsKindOf(CLASSINFO(wxDatePickerCtrl)) );
+
+ variant = ctrl->GetValue();
+
+ return true;
+}
+
+void wxPGDatePickerCtrlEditor::SetValueToUnspecified( wxWindow*
WXUNUSED(wnd) ) const
+{
+ // TODO?
+ //wxDateProperty* prop = (wxDateProperty*) property;
+ //ctrl->SetValue(?);
+}
+
+#endif // wxUSE_DATEPICKCTRL
+
+
+// -----------------------------------------------------------------------
+// wxFontProperty
+// -----------------------------------------------------------------------
+
+#include <wx/fontdlg.h>
+#include <wx/fontenum.h>
+
+static const wxChar* gs_fp_es_family_labels[] = {
+ wxT("Default"), wxT("Decorative"),
+ wxT("Roman"), wxT("Script"),
+ wxT("Swiss"), wxT("Modern"),
+ (const wxChar*) NULL
+};
+
+static long gs_fp_es_family_values[] = {
+ wxDEFAULT, wxDECORATIVE,
+ wxROMAN, wxSCRIPT,
+ wxSWISS, wxMODERN
+};
+
+static const wxChar* gs_fp_es_style_labels[] = {
+ wxT("Normal"),
+ wxT("Slant"),
+ wxT("Italic"),
+ (const wxChar*) NULL
+};
+
+static long gs_fp_es_style_values[] = {
+ wxNORMAL,
+ wxSLANT,
+ wxITALIC
+};
+
+static const wxChar* gs_fp_es_weight_labels[] = {
+ wxT("Normal"),
+ wxT("Light"),
+ wxT("Bold"),
+ (const wxChar*) NULL
+};
+
+static long gs_fp_es_weight_values[] = {
+ wxNORMAL,
+ wxLIGHT,
+ wxBOLD
+};
+
+// Class body is in advprops.h
+
+
+WX_PG_IMPLEMENT_PROPERTY_CLASS(wxFontProperty,wxPGPropertyWithChildren,
+ wxFont,const wxFont&,TextCtrlAndButton)
+
+
+wxFontProperty::wxFontProperty( const wxString& label, const wxString& name,
+ const wxFont& value )
+ : wxPGPropertyWithChildren(label,name)
+{
+ SetValue( wxFontToVariant(value) );
+
+ // Initialize font family choices list
+ if ( !wxPGGlobalVars->m_fontFamilyChoices )
+ {
+ WX_PG_GLOBALS_LOCKER()
+
+ wxFontEnumerator enumerator;
+ enumerator.EnumerateFacenames();
+
+#if wxMINOR_VERSION > 6
+ wxArrayString faceNames = enumerator.GetFacenames();
+#else
+ wxArrayString& faceNames = *enumerator.GetFacenames();
+#endif
+
+ faceNames.Sort();
+
+ wxPGGlobalVars->m_fontFamilyChoices = new wxPGChoices(faceNames);
+ }
+
+ wxString emptyString(wxEmptyString);
+
+ wxFont& font = wxFontFromVariant(m_value);
+
+ AddChild( new wxIntProperty( _("Point
Size"),emptyString,(long)font.GetPointSize() ) );
+
+ AddChild( new wxEnumProperty(_("Family"), emptyString,
+ gs_fp_es_family_labels,gs_fp_es_family_values,
+ font.GetFamily()) );
+
+ wxString faceName = font.GetFaceName();
+ // If font was not in there, add it now
+ if ( faceName.length() &&
+ wxPGGlobalVars->m_fontFamilyChoices->Index(faceName) ==
wxNOT_FOUND )
+ wxPGGlobalVars->m_fontFamilyChoices->AddAsSorted(faceName);
+
+ wxPGProperty* p = new wxEnumProperty(_("Face Name"),emptyString,
+ *wxPGGlobalVars->m_fontFamilyChoices);
+
+ p->SetValueFromString(faceName, wxPG_FULL_VALUE);
+
+ AddChild( p );
+
+ AddChild( new wxEnumProperty(_("Style"),emptyString,
+
gs_fp_es_style_labels,gs_fp_es_style_values,font.GetStyle()) );
+
+ AddChild( new wxEnumProperty(_("Weight"),emptyString,
+
gs_fp_es_weight_labels,gs_fp_es_weight_values,font.GetWeight()) );
+
+ AddChild( new wxBoolProperty(_("Underlined"),emptyString,
+ font.GetUnderlined()) );
+}
+
+wxFontProperty::~wxFontProperty() { }
+
+bool wxFontProperty::ValidateValue( wxVariant& value ) const
+{
+ wxFont& font = wxFontFromVariant(value);
+ wxASSERT(&font);
+
+ wxFont font2;
+ if ( !font.Ok() )
+ font2 = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL);
+ else
+ font2 = font;
+
+ value = wxFontToVariant(font2);
+
+ return true;
+}
+
+wxString wxFontProperty::GetValueAsString( int argFlags ) const
+{
+ return wxPGPropertyWithChildren::GetValueAsString(argFlags);
+}
+
+bool wxFontProperty::OnEvent( wxPropertyGrid* propgrid, wxWindow* WXUNUSED(primary),
+ wxEvent& event )
+{
+ if ( propgrid->IsMainButtonEvent(event) )
+ {
+ // Update value from last minute changes
+ PrepareValueForDialogEditing(propgrid);
+
+ wxFontData data;
+ data.SetInitialFont( wxFontFromVariant(m_value) );
+ data.SetColour(*wxBLACK);
+
+ wxFontDialog dlg(propgrid, data);
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ propgrid->EditorsValueWasModified();
+
+ wxVariant variant = wxFontToVariant(dlg.GetFontData().GetChosenFont());
+ propgrid->ValueChangeInEvent( variant );
+ return true;
+ }
+ }
+ return false;
+}
+
+void wxFontProperty::RefreshChildren()
+{
+ if ( !GetCount() ) return;
+ const wxFont& font = wxFontFromVariant(m_value);
+ Item(0)->SetValue( (long)font.GetPointSize() );
+ Item(1)->SetValue( (long)font.GetFamily() );
+ Item(2)->SetValueFromString( font.GetFaceName(), wxPG_FULL_VALUE );
+ Item(3)->SetValue( (long)font.GetStyle() );
+ Item(4)->SetValue( (long)font.GetWeight() );
+ Item(5)->SetValue( font.GetUnderlined() );
+}
+
+void wxFontProperty::ChildChanged( wxVariant& thisValue, int ind,
wxVariant& childValue ) const
+{
+ wxFont& font = wxFontFromVariant(thisValue);
+
+ if ( ind == 0 )
+ {
+ font.SetPointSize( wxPGVariantToInt(childValue) );
+ }
+ else if ( ind == 1 )
+ {
+ int fam = childValue.GetLong();
+ if ( fam < wxDEFAULT ||
+ fam > wxTELETYPE )
+ fam = wxDEFAULT;
+ font.SetFamily( fam );
+ }
+ else if ( ind == 2 )
+ {
+ font.SetFaceName(
wxPGGlobalVars->m_fontFamilyChoices->GetLabel(childValue.GetLong()) );
+ }
+ else if ( ind == 3 )
+ {
+ int st = childValue.GetLong();
+ if ( st != wxFONTSTYLE_NORMAL &&
+ st != wxFONTSTYLE_SLANT &&
+ st != wxFONTSTYLE_ITALIC )
+ st = wxFONTWEIGHT_NORMAL;
+ font.SetStyle( st );
+ }
+ else if ( ind == 4 )
+ {
+ int wt = childValue.GetLong();
+ if ( wt != wxFONTWEIGHT_NORMAL &&
+ wt != wxFONTWEIGHT_LIGHT &&
+ wt != wxFONTWEIGHT_BOLD )
+ wt = wxFONTWEIGHT_NORMAL;
+ font.SetWeight( wt );
+ }
+ else if ( ind == 5 )
+ {
+ font.SetUnderlined( childValue.GetBool() );
+ }
+}
+
+/*
+wxSize wxFontProperty::OnMeasureImage() const
+{
+ return wxSize(-1,-1);
+}
+
+void wxFontProperty::OnCustomPaint(wxDC& dc,
+ const wxRect& rect,
+ wxPGPaintData& paintData)
+{
+ wxString drawFace;
+ if ( paintData.m_choiceItem >= 0 )
+ drawFace = wxPGGlobalVars->m_fontFamilyChoices->GetLabel(paintData.m_choiceItem);
+ else
+ drawFace = m_value_wxFont.GetFaceName();
+
+ if ( drawFace.length() )
+ {
+ // Draw the background
+ dc.SetBrush(
wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)) );
+ //dc.SetBrush( *wxWHITE_BRUSH );
+ //dc.SetPen( *wxMEDIUM_GREY_PEN );
+ dc.DrawRectangle( rect );
+
+ wxFont oldFont = dc.GetFont();
+ wxFont drawFont(oldFont.GetPointSize(),
+ wxDEFAULT,wxNORMAL,wxBOLD,false,drawFace);
+ dc.SetFont(drawFont);
+
+ dc.SetTextForeground(
wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT) );
+ dc.DrawText( wxT("Aa"), rect.x+2, rect.y+1 );
+
+ dc.SetFont(oldFont);
+ }
+ else
+ {
+ // No file - just draw a white box
+ dc.SetBrush ( *wxWHITE_BRUSH );
+ dc.DrawRectangle ( rect );
+ }
+}
+*/
+
+
+// -----------------------------------------------------------------------
+// wxSystemColourProperty
+// -----------------------------------------------------------------------
+
+// wxEnumProperty based classes cannot use wxPG_PROP_CLASS_SPECIFIC_1
+#define wxPG_PROP_HIDE_CUSTOM_COLOUR wxPG_PROP_CLASS_SPECIFIC_2
+
+#include <wx/colordlg.h>
+
+//#define wx_cp_es_syscolours_len 25
+static const wxChar* gs_cp_es_syscolour_labels[] = {
+ wxT("AppWorkspace"),
+ wxT("ActiveBorder"),
+ wxT("ActiveCaption"),
+ wxT("ButtonFace"),
+ wxT("ButtonHighlight"),
+ wxT("ButtonShadow"),
+ wxT("ButtonText"),
+ wxT("CaptionText"),
+ wxT("ControlDark"),
+ wxT("ControlLight"),
+ wxT("Desktop"),
+ wxT("GrayText"),
+ wxT("Highlight"),
+ wxT("HighlightText"),
+ wxT("InactiveBorder"),
+ wxT("InactiveCaption"),
+ wxT("InactiveCaptionText"),
+ wxT("Menu"),
+ wxT("Scrollbar"),
+ wxT("Tooltip"),
+ wxT("TooltipText"),
+ wxT("Window"),
+ wxT("WindowFrame"),
+ wxT("WindowText"),
+ wxT("Custom"),
+ (const wxChar*) NULL
+};
+
+static long gs_cp_es_syscolour_values[] = {
+ wxSYS_COLOUR_APPWORKSPACE,
+ wxSYS_COLOUR_ACTIVEBORDER,
+ wxSYS_COLOUR_ACTIVECAPTION,
+ wxSYS_COLOUR_BTNFACE,
+ wxSYS_COLOUR_BTNHIGHLIGHT,
+ wxSYS_COLOUR_BTNSHADOW,
+ wxSYS_COLOUR_BTNTEXT ,
+ wxSYS_COLOUR_CAPTIONTEXT,
+ wxSYS_COLOUR_3DDKSHADOW,
+ wxSYS_COLOUR_3DLIGHT,
+ wxSYS_COLOUR_BACKGROUND,
+ wxSYS_COLOUR_GRAYTEXT,
+ wxSYS_COLOUR_HIGHLIGHT,
+ wxSYS_COLOUR_HIGHLIGHTTEXT,
+ wxSYS_COLOUR_INACTIVEBORDER,
+ wxSYS_COLOUR_INACTIVECAPTION,
+ wxSYS_COLOUR_INACTIVECAPTIONTEXT,
+ wxSYS_COLOUR_MENU,
+ wxSYS_COLOUR_SCROLLBAR,
+ wxSYS_COLOUR_INFOBK,
+ wxSYS_COLOUR_INFOTEXT,
+ wxSYS_COLOUR_WINDOW,
+ wxSYS_COLOUR_WINDOWFRAME,
+ wxSYS_COLOUR_WINDOWTEXT,
+ wxPG_COLOUR_CUSTOM
+};
+
+
+WX_PG_IMPLEMENT_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue,
wxColourPropertyValue)
+
+
+// Class body is in advprops.h
+
+WX_PG_IMPLEMENT_PROPERTY_CLASS(wxSystemColourProperty,wxEnumProperty,
+ wxColourPropertyValue,const wxColourPropertyValue&,Choice)
+
+
+void wxSystemColourProperty::Init( int type, const wxColour& colour )
+{
+ wxColourPropertyValue cpv;
+
+ if ( colour.Ok() )
+ cpv.Init( type, colour );
+ else
+ cpv.Init( type, *wxWHITE );
+
+ m_flags |= wxPG_PROP_STATIC_CHOICES; // Colour selection cannot be changed.
+
+ m_value = wxColourPropertyValueToVariant(cpv);
+
+ OnSetValue();
+}
+
+
+static wxPGChoices gs_wxSystemColourProperty_choicesCache;
+
+
+wxSystemColourProperty::wxSystemColourProperty( const wxString& label,
const wxString& name,
+ const wxColourPropertyValue& value )
+ : wxEnumProperty( label,
+ name,
+ gs_cp_es_syscolour_labels,
+ gs_cp_es_syscolour_values,
+ &gs_wxSystemColourProperty_choicesCache )
+{
+ if ( &value )
+ Init( value.m_type, value.m_colour );
+ else
+ Init( wxPG_COLOUR_CUSTOM, *wxWHITE );
+}
+
+
+wxSystemColourProperty::wxSystemColourProperty( const wxString& label,
const wxString& name,
+ const wxChar** labels, const long* values, wxPGChoices* choicesCache,
+ const wxColourPropertyValue& value )
+ : wxEnumProperty( label, name, labels, values, choicesCache )
+{
+ if ( &value )
+ Init( value.m_type, value.m_colour );
+ else
+ Init( wxPG_COLOUR_CUSTOM, *wxWHITE );
+}
+
+
+wxSystemColourProperty::wxSystemColourProperty( const wxString& label,
const wxString& name,
+ const wxChar** labels, const long* values, wxPGChoices* choicesCache,
+ const wxColour& value )
+ : wxEnumProperty( label, name, labels, values, choicesCache )
+{
+ if ( &value )
+ Init( wxPG_COLOUR_CUSTOM, value );
+ else
+ Init( wxPG_COLOUR_CUSTOM, *wxWHITE );
+}
+
+
+wxSystemColourProperty::~wxSystemColourProperty() { }
+
+
+wxColourPropertyValue wxSystemColourProperty::GetVal( const wxVariant*
pVariant ) const
+{
+ if ( !pVariant )
+ pVariant = &m_value;
+
+ wxColourPropertyValue* v1 = &wxColourPropertyValueFromVariant(*pVariant);
+ if ( v1 )
+ return *v1;
+
+ wxColour* pCol = wxGetVariantCast(*pVariant, wxColour);
+ wxColour col;
+
+ if ( pCol )
+ col = *pCol;
+ else
+ col << *pVariant;
+
+ wxColourPropertyValue v2( wxPG_COLOUR_CUSTOM, col );
+
+ int colInd = ColToInd(col);
+ if ( colInd != wxNOT_FOUND )
+ v2.m_type = colInd;
+
+ return v2;
+}
+
+wxVariant wxSystemColourProperty::DoTranslateVal(
wxColourPropertyValue& v ) const
+{
+ return wxColourPropertyValueToVariant(v);
+}
+
+int wxSystemColourProperty::ColToInd( const wxColour& colour ) const
+{
+ size_t i;
+ size_t i_max = m_choices.GetCount() - 1;
+
+ if ( !colour.Ok() )
+ return wxNOT_FOUND;
+
+ long pixval = wxPG_COLOUR(colour.Red(),colour.Green(),colour.Blue());
+
+ for ( i=0; i<i_max; i++ )
+ {
+ int ind = i;
+ if ( m_choices[i].HasValue() )
+ ind = m_choices[i].GetValue();
+
+ if ( GetColour(ind) == pixval )
+ {
+ /*wxLogDebug(wxT("%s(%s): Index %i for (
getcolour(%i,%i,%i), colour(%i,%i,%i))"),
+ GetClassName(),GetLabel().c_str(),
+ (int)i,(int)GetColour(ind).Red(),(int)GetColour(ind).Green(),(int)GetColour(ind).Blue(),
+ (int)colour.Red(),(int)colour.Green(),(int)colour.Blue());*/
+ return ind;
+ }
+ }
+ return wxNOT_FOUND;
+}
+
+
+static inline wxColour wxColourFromPGLong( long col )
+{
+ return wxColour((col&0xFF),((col>>8)&0xFF),((col>>16)&0xFF));
+}
+
+
+bool wxSystemColourProperty::ValidateValue( wxVariant& value ) const
+{
+ // Convert from generic wxobject ptr to wxPGDataColour
+ if ( wxPGIsVariantType(value, wxobject) )
+ {
+ wxASSERT( value.IsValueKindOf(CLASSINFO(wxColour)) );
+ wxColour* pCol = (wxColour*) value.GetWxObjectPtr();
+#if wxCHECK_VERSION(2,8,0)
+ value << *pCol;
+#else
+ wxPGVariantAssign(value, WXVARIANT(*pCol));
+#endif
+ }
+
+ wxColourPropertyValue val = GetVal(&value);
+
+ if ( val.m_type == wxPG_COLOUR_UNSPECIFIED )
+ {
+ value.MakeNull();
+ return true;
+ }
+
+ if ( !val.m_colour.Ok() )
+ {
+ val.Init( wxPG_COLOUR_CUSTOM, *wxWHITE );
+ value = TranslateVal(val);
+ return true;
+ }
+
+ if ( val.m_type < wxPG_COLOUR_WEB_BASE )
+ val.m_colour = GetColour( val.m_type );
+
+ value = TranslateVal(val);
+ return true;
+}
+
+
+void wxSystemColourProperty::OnSetValue()
+{
+ wxColourPropertyValue* pCpv = &wxColourPropertyValueFromVariant(m_value);
+ wxColour col;
+ if ( pCpv )
+ col = pCpv->m_colour;
+ else
+ col << m_value;
+
+ if ( !col.Ok() )
+ {
+ SetValueToUnspecified();
+ SetIndex(wxNOT_FOUND);
+ return;
+ }
+
+ int ind;
+
+ if ( pCpv )
+ if ( pCpv->m_type < wxPG_COLOUR_WEB_BASE )
+ {
+ if ( m_choices.HasValues() )
+ ind = GetIndexForValue(pCpv->m_type);
+ else
+ ind = ColToInd(col);
+ }
+ else
+ {
+ pCpv->m_type = wxPG_COLOUR_CUSTOM;
+ ind = m_choices.GetCount()-1;
+ }
+ else
+ ind = ColToInd(col);
+
+ SetIndex(ind);
+}
+
+
+long wxSystemColourProperty::GetColour( int index ) const
+{
+ wxColour colour = wxSystemSettings::GetColour(
(wxSystemColour)index );
+ return wxPG_COLOUR(colour.Red(),colour.Green(),colour.Blue());
+}
+
+
+wxString wxSystemColourProperty::GetValueAsString( int argFlags ) const
+{
+ wxColourPropertyValue val = GetVal();
+
+ // Always show custom colour for non-choice editor
+ // Assumes changed editor means its textctrl based...
+ if ( val.m_type == wxPG_COLOUR_CUSTOM ||
+ (argFlags & wxPG_PROPERTY_SPECIFIC) )
+ {
+ return wxString::Format(wxT("(%i,%i,%i)"),
+ (int)val.m_colour.Red(),
+ (int)val.m_colour.Green(),
+ (int)val.m_colour.Blue());
+ }
+
+ int ind = GetIndex();
+ if ( ind == -1 )
+ return wxEmptyString;
+
+ return m_choices.GetLabel(ind);
+}
+
+
+wxSize wxSystemColourProperty::OnMeasureImage( int ) const
+{
+ return wxPG_DEFAULT_IMAGE_SIZE;
+}
+
+
+bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const
+{
+ wxASSERT( m_value.GetType() != wxT("string") );
+
+ bool res = false;
+
+ wxPropertyGrid* propgrid = GetGrid();
+ wxColourPropertyValue val = GetVal();
+
+ val.m_type = wxPG_COLOUR_CUSTOM;
+
+ wxColourData data;
+ data.SetChooseFull(true);
+ data.SetColour(val.m_colour);
+ int i;
+ for ( i = 0; i < 16; i++)
+ {
+ wxColour colour(i*16, i*16, i*16);
+ data.SetCustomColour(i, colour);
+ }
+
+ wxColourDialog dialog(propgrid, &data);
+ if ( dialog.ShowModal() == wxID_OK )
+ {
+ wxColourData retData = dialog.GetColourData();
+ val.m_colour = retData.GetColour();
+
+ variant = DoTranslateVal(val);
+
+ res = true;
+ }
+
+ return res;
+}
+
+
+bool wxSystemColourProperty::IntToValue( wxVariant& variant, int
number, int WXUNUSED(argFlags) ) const
+{
+ int index = number;
+ int type = GetValueForIndex(index);
+ bool hasValue = m_choices[index].HasValue();
+
+ if ( ( hasValue && type == wxPG_COLOUR_CUSTOM ) ||
+ ( !hasValue && (index == (int)(m_choices.GetCount()-1) &&
+ !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR))
+ )
+ )
+ {
+ QueryColourFromUser(variant);
+ }
+ else
+ {
+ variant = TranslateVal( type, GetColour(type) );
+ }
+
+ return true;
+}
+
+// Need to do some extra event handling.
+bool wxSystemColourProperty::OnEvent( wxPropertyGrid* propgrid,
wxWindow* WXUNUSED(primary), wxEvent& event )
+{
+ if ( propgrid->IsMainButtonEvent(event) )
+ {
+ // We need to handle button click in case editor has been
+ // switched to one that has wxButton as well.
+ wxVariant variant;
+ if ( QueryColourFromUser(variant) )
+ {
+ propgrid->ValueChangeInEvent(variant);
+ return true;
+ }
+ }
+ return false;
+}
+
+/*class wxPGColourPropertyRenderer : public wxPGDefaultRenderer
+{
+public:
+ virtual void Render( wxDC& dc, const wxRect& rect,
+ const wxPropertyGrid* propertyGrid,
wxPGProperty* property,
+ int WXUNUSED(column), int item, int
WXUNUSED(flags) ) const
+ {
+ wxASSERT(
property->IsKindOf(CLASSINFO(wxSystemColourProperty)) );
+ wxSystemColourProperty* prop = wxStaticCast(property, wxSystemColourProperty);
+
+ dc.SetPen(*wxBLACK_PEN);
+ if ( item >= 0 &&
+ ( item < (int)(prop->GetItemCount()-1) || (prop->HasFlag(wxPG_PROP_HIDE_CUSTOM_COLOUR)))
+ )
+ {
+ int colInd;
+ const wxArrayInt& values = prop->GetValues();
+ if ( values.GetCount() )
+ colInd = values[item];
+ else
+ colInd = item;
+ dc.SetBrush( wxColour( prop->GetColour( colInd ) ) );
+ }
+ else if ( !prop->IsValueUnspecified() )
+ dc.SetBrush( prop->GetVal().m_colour );
+ else
+ dc.SetBrush( *wxWHITE );
+
+ wxRect imageRect = propertyGrid->GetImageRect(property, item);
+ wxLogDebug(wxT("%i, %i"),imageRect.x,imageRect.y);
+ dc.DrawRectangle( rect.x+imageRect.x, rect.y+imageRect.y,
+ imageRect.width, imageRect.height );
+
+ wxString text;
+ if ( item == -1 )
+ text = property->GetValueAsString();
+ else
+ text = property->GetChoiceString(item);
+ DrawText( dc, rect, imageRect.width, text );
+ }
+protected:
+};
+
+wxPGColourPropertyRenderer g_wxPGColourPropertyRenderer;
+
+wxPGCellRenderer* wxSystemColourProperty::GetCellRenderer( int column
) const
+{
+ if ( column == 1 )
+ return &g_wxPGColourPropertyRenderer;
+ return wxEnumProperty::GetCellRenderer(column);
+}*/
+
+void wxSystemColourProperty::OnCustomPaint( wxDC& dc, const wxRect& rect,
+ wxPGPaintData& paintdata )
+{
+ if ( paintdata.m_choiceItem >= 0 &&
+ ( paintdata.m_choiceItem < (int)(GetItemCount()-1) ||
(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR))
+ )
+ {
+ int colInd;
+ if ( m_choices[paintdata.m_choiceItem].HasValue() )
+ colInd = m_choices[paintdata.m_choiceItem].GetValue();
+ else
+ colInd = paintdata.m_choiceItem;
+ dc.SetBrush( wxColour ( GetColour( colInd ) ) );
+ }
+ else if ( !IsValueUnspecified() )
+ dc.SetBrush( GetVal().m_colour );
+ else
+ dc.SetBrush( *wxWHITE );
+
+ dc.DrawRectangle ( rect );
+}
+
+
+bool wxSystemColourProperty::StringToValue( wxVariant& value, const
wxString& text, int argFlags ) const
+{
+ wxColourPropertyValue val;
+ if ( text[0] == wxT('(') )
+ {
+ // Custom colour.
+ val.m_type = wxPG_COLOUR_CUSTOM;
+
+ int r, g, b;
+ wxSscanf(text.c_str(),wxT("(%i,%i,%i)"),&r,&g,&b);
+ val.m_colour.Set(r,g,b);
+ }
+ else
+ {
+ // Predefined colour.
+ bool res = wxEnumProperty::StringToValue(value, text, argFlags);
+ if ( res )
+ {
+ val.m_type = GetIndex();
+ if ( val.m_type >= 0 && m_choices[val.m_type].HasValue() )
+ val.m_type = m_choices[val.m_type].GetValue();
+
+ // Get proper colour for type.
+ val.m_colour = wxColourFromPGLong(GetColour(val.m_type));
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ value = wxColourPropertyValueToVariant(val);
+
+ return true;
+}
+
+
+bool wxSystemColourProperty::DoSetAttribute( const wxString& name,
wxVariant& value )
+{
+ if ( name == wxPG_COLOUR_ALLOW_CUSTOM )
+ {
+ int ival = value.GetLong();
+
+ SetChoicesExclusive(); // Make sure we don't corrupt colour
lists of other properties
+
+ if ( ival && (m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
+ {
+ // Show custom choice
+ m_choices.Add(wxT("Custom"),wxPG_COLOUR_CUSTOM);
+ m_flags &= ~(wxPG_PROP_HIDE_CUSTOM_COLOUR);
+ }
+ else if ( !ival && !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
+ {
+ // Hide custom choice
+ m_choices.RemoveAt(m_choices.GetCount()-1);
+ m_flags |= wxPG_PROP_HIDE_CUSTOM_COLOUR;
+ }
+ return true;
+ }
+ return false;
+}
+
+
+// -----------------------------------------------------------------------
+// wxColourProperty
+// -----------------------------------------------------------------------
+
+static const wxChar* gs_cp_es_normcolour_labels[] = {
+ wxT("Black"),
+ wxT("Maroon"),
+ wxT("Navy"),
+ wxT("Purple"),
+ wxT("Teal"),
+ wxT("Gray"),
+ wxT("Green"),
+ wxT("Olive"),
+ wxT("Brown"),
+ wxT("Blue"),
+ wxT("Fuchsia"),
+ wxT("Red"),
+ wxT("Orange"),
+ wxT("Silver"),
+ wxT("Lime"),
+ wxT("Aqua"),
+ wxT("Yellow"),
+ wxT("White"),
+ wxT("Custom"),
+ (const wxChar*) NULL
+};
+
+static unsigned long gs_cp_es_normcolour_colours[] = {
+ wxPG_COLOUR(0,0,0),
+ wxPG_COLOUR(128,0,0),
+ wxPG_COLOUR(0,0,128),
+ wxPG_COLOUR(128,0,128),
+ wxPG_COLOUR(0,128,128),
+ wxPG_COLOUR(128,128,128),
+ wxPG_COLOUR(0,128,0),
+ wxPG_COLOUR(128,128,0),
+ wxPG_COLOUR(166,124,81),
+ wxPG_COLOUR(0,0,255),
+ wxPG_COLOUR(255,0,255),
+ wxPG_COLOUR(255,0,0),
+ wxPG_COLOUR(247,148,28),
+ wxPG_COLOUR(192,192,192),
+ wxPG_COLOUR(0,255,0),
+ wxPG_COLOUR(0,255,255),
+ wxPG_COLOUR(255,255,0),
+ wxPG_COLOUR(255,255,255),
+ wxPG_COLOUR(0,0,0)
+};
+
+WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(wxColourProperty,
+ gs_cp_es_normcolour_labels,
+ (const long*)NULL,
+ gs_cp_es_normcolour_colours,
+ TextCtrlAndButton)
+
+// -----------------------------------------------------------------------
+// wxCursorProperty
+// -----------------------------------------------------------------------
+
+#define wxPG_CURSOR_IMAGE_WIDTH 32
+
+#define NUM_CURSORS 28
+
+//#define wx_cp_es_syscursors_len 28
+static const wxChar* gs_cp_es_syscursors_labels[NUM_CURSORS+1] = {
+ wxT("Default"),
+ wxT("Arrow"),
+ wxT("Right Arrow"),
+ wxT("Blank"),
+ wxT("Bullseye"),
+ wxT("Character"),
+ wxT("Cross"),
+ wxT("Hand"),
+ wxT("I-Beam"),
+ wxT("Left Button"),
+ wxT("Magnifier"),
+ wxT("Middle Button"),
+ wxT("No Entry"),
+ wxT("Paint Brush"),
+ wxT("Pencil"),
+ wxT("Point Left"),
+ wxT("Point Right"),
+ wxT("Question Arrow"),
+ wxT("Right Button"),
+ wxT("Sizing NE-SW"),
+ wxT("Sizing N-S"),
+ wxT("Sizing NW-SE"),
+ wxT("Sizing W-E"),
+ wxT("Sizing"),
+ wxT("Spraycan"),
+ wxT("Wait"),
+ wxT("Watch"),
+ wxT("Wait Arrow"),
+ (const wxChar*) NULL
+};
+
+static long gs_cp_es_syscursors_values[NUM_CURSORS] = {
+ wxCURSOR_NONE,
+ wxCURSOR_ARROW,
+ wxCURSOR_RIGHT_ARROW,
+ wxCURSOR_BLANK,
+ wxCURSOR_BULLSEYE,
+ wxCURSOR_CHAR,
+ wxCURSOR_CROSS,
+ wxCURSOR_HAND,
+ wxCURSOR_IBEAM,
+ wxCURSOR_LEFT_BUTTON,
+ wxCURSOR_MAGNIFIER,
+ wxCURSOR_MIDDLE_BUTTON,
+ wxCURSOR_NO_ENTRY,
+ wxCURSOR_PAINT_BRUSH,
+ wxCURSOR_PENCIL,
+ wxCURSOR_POINT_LEFT,
+ wxCURSOR_POINT_RIGHT,
+ wxCURSOR_QUESTION_ARROW,
+ wxCURSOR_RIGHT_BUTTON,
+ wxCURSOR_SIZENESW,
+ wxCURSOR_SIZENS,
+ wxCURSOR_SIZENWSE,
+ wxCURSOR_SIZEWE,
+ wxCURSOR_SIZING,
+ wxCURSOR_SPRAYCAN,
+ wxCURSOR_WAIT,
+ wxCURSOR_WATCH,
+ wxCURSOR_ARROWWAIT
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxCursorProperty, wxEnumProperty)
+
+wxCursorProperty::wxCursorProperty( const wxString& label, const
wxString& name,
+ int value )
+ : wxEnumProperty( label,
+ name,
+ gs_cp_es_syscursors_labels,
+ gs_cp_es_syscursors_values,
+ value )
+{
+ m_flags |= wxPG_PROP_STATIC_CHOICES; // Cursor selection cannot be changed.
+}
+
+wxCursorProperty::~wxCursorProperty()
+{
+}
+
+wxSize wxCursorProperty::OnMeasureImage( int item ) const
+{
+#if wxPG_CAN_DRAW_CURSOR
+ if ( item != -1 && item < NUM_CURSORS )
+ return wxSize(wxPG_CURSOR_IMAGE_WIDTH,wxPG_CURSOR_IMAGE_WIDTH);
+#endif
+ return wxSize(0,0);
+}
+
+#if wxPG_CAN_DRAW_CURSOR
+
+/*class wxPGCursorPropertyRenderer : public wxPGDefaultRenderer
+{
+public:
+ virtual void Render( wxDC& dc, const wxRect& rect,
+ const wxPropertyGrid* WXUNUSED(propertyGrid),
wxPGProperty* property,
+ int WXUNUSED(column), int item, int
WXUNUSED(flags) ) const
+ {
+ //wxASSERT( property->IsKindOf(CLASSINFO(wxCursorProperty)) );
+ dc.SetBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE
) );
+
+ if ( item >= 0 )
+ {
+ dc.DrawRectangle( rect );
+
+ int cursorindex = gs_cp_es_syscursors_values[item];
+
+ if ( cursorindex == wxCURSOR_NONE )
+ cursorindex = wxCURSOR_ARROW;
+
+ wxCursor cursor( cursorindex );
+
+ #ifdef __WXMSW__
+ ::DrawIconEx( (HDC)dc.GetHDC(),
+ rect.x,
+ rect.y,
+ (HICON)cursor.GetHandle(),
+ 0,
+ 0,
+ 0,
+ NULL,
+ DI_COMPAT | DI_DEFAULTSIZE | DI_NORMAL
+ );
+ #endif
+ }
+
+ DrawText( dc, rect, wxPG_CURSOR_IMAGE_WIDTH,
property->GetValueAsString() );
+ }
+protected:
+};
+
+wxPGCursorPropertyRenderer g_wxPGCursorPropertyRenderer;
+
+wxPGCellRenderer* wxCursorProperty::GetCellRenderer( int column ) const
+{
+ if ( column == 1 )
+ return &g_wxPGCursorPropertyRenderer;
+ return wxEnumProperty::GetCellRenderer(column);
+}*/
+
+void wxCursorProperty::OnCustomPaint( wxDC& dc,
+ const wxRect& rect,
+ wxPGPaintData& paintdata )
+{
+ // Background brush
+ dc.SetBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
+
+ if ( paintdata.m_choiceItem >= 0 )
+ {
+ dc.DrawRectangle( rect );
+
+ if ( paintdata.m_choiceItem < NUM_CURSORS )
+ {
+ int cursorindex = gs_cp_es_syscursors_values[paintdata.m_choiceItem];
+
+ {
+ if ( cursorindex == wxCURSOR_NONE )
+ cursorindex = wxCURSOR_ARROW;
+
+ wxCursor cursor( cursorindex );
+
+ #ifdef __WXMSW__
+ ::DrawIconEx( (HDC)dc.GetHDC(),
+ rect.x,
+ rect.y,
+ (HICON)cursor.GetHandle(),
+ 0,
+ 0,
+ 0,
+ NULL,
+ DI_COMPAT | DI_DEFAULTSIZE | DI_NORMAL
+ );
+ #endif
+ }
+ }
+ }
+}
+
+#else
+void wxCursorProperty::OnCustomPaint( wxDC&, const wxRect&,
wxPGPaintData& ) { }
+/*wxPGCellRenderer* wxCursorProperty::GetCellRenderer( int column ) const
+{
+ return wxEnumProperty::GetCellRenderer(column);
+}*/
+#endif
+
+// -----------------------------------------------------------------------
+// wxImageFileProperty
+// -----------------------------------------------------------------------
+
+#if wxUSE_IMAGE
+
+const wxString& wxPGGetDefaultImageWildcard()
+{
+ WX_PG_GLOBALS_LOCKER()
+
+ // Form the wildcard, if not done yet
+ if ( !wxPGGlobalVars->m_pDefaultImageWildcard.length() )
+ {
+
+ wxString str;
+
+ // TODO: This section may require locking (using global).
+
+ wxList& handlers = wxImage::GetHandlers();
+
+ wxList::iterator node;
+
+ // Let's iterate over the image handler list.
+ //for ( wxList::Node *node = handlers.GetFirst(); node; node =
node->GetNext() )
+ for ( node = handlers.begin(); node != handlers.end(); node++ )
+ {
+ wxImageHandler *handler = (wxImageHandler*)*node;
+
+ wxString ext_lo = handler->GetExtension();
+ wxString ext_up = ext_lo.Upper();
+
+ str.append( ext_up );
+ str.append( wxT(" files (*.") );
+ str.append( ext_up );
+ str.append( wxT(")|*.") );
+ str.append( ext_lo );
+ str.append( wxT("|") );
+ }
+
+ str.append ( wxT("All files (*.*)|*.*") );
+
+ wxPGGlobalVars->m_pDefaultImageWildcard = str;
+ }
+
+ return wxPGGlobalVars->m_pDefaultImageWildcard;
+}
+
+WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(wxImageFileProperty,
+ wxFileProperty,
+ const wxString&)
+
+wxImageFileProperty::wxImageFileProperty( const wxString& label, const
wxString& name,
+ const wxString& value )
+ : wxFileProperty(label,name,value)
+{
+ SetAttribute( wxPG_FILE_WILDCARD, wxPGGetDefaultImageWildcard() );
+
+ m_pImage = (wxImage*) NULL;
+ m_pBitmap = (wxBitmap*) NULL;
+}
+
+wxImageFileProperty::~wxImageFileProperty()
+{
+ if ( m_pBitmap )
+ delete m_pBitmap;
+ if ( m_pImage )
+ delete m_pImage;
+}
+
+void wxImageFileProperty::OnSetValue()
+{
+ wxFileProperty::OnSetValue();
+
+ // Delete old image
+ if ( m_pImage )
+ {
+ delete m_pImage;
+ m_pImage = NULL;
+ }
+ if ( m_pBitmap )
+ {
+ delete m_pBitmap;
+ m_pBitmap = NULL;
+ }
+
+ // Create the image thumbnail
+ if ( m_filename.FileExists() )
+ {
+ m_pImage = new wxImage( m_filename.GetFullPath() );
+ }
+}
+
+wxSize wxImageFileProperty::OnMeasureImage( int ) const
+{
+ return wxPG_DEFAULT_IMAGE_SIZE;
+}
+
+void wxImageFileProperty::OnCustomPaint( wxDC& dc,
+ const wxRect& rect,
+ wxPGPaintData& )
+{
+ if ( m_pBitmap || (m_pImage && m_pImage->Ok() ) )
+ {
+ // Draw the thumbnail
+
+ // Create the bitmap here because required size is not known
in OnSetValue().
+ if ( !m_pBitmap )
+ {
+ m_pImage->Rescale( rect.width, rect.height );
+ m_pBitmap = new wxBitmap( *m_pImage );
+ delete m_pImage;
+ m_pImage = NULL;
+ }
+
+ dc.DrawBitmap( *m_pBitmap, rect.x, rect.y, false );
+ }
+ else
+ {
+ // No file - just draw a white box
+ dc.SetBrush( *wxWHITE_BRUSH );
+ dc.DrawRectangle ( rect );
+ }
+}
+
+#endif // wxUSE_IMAGE
+
+// -----------------------------------------------------------------------
+// wxMultiChoiceProperty
+// -----------------------------------------------------------------------
+
+#if wxUSE_CHOICEDLG
+
+#include <wx/choicdlg.h>
+
+#ifndef __WXPYTHON__
+wxPGProperty* wxPG_CONSTFUNC(wxMultiChoiceProperty)(const wxString& label,
+ const wxString& name,
+ const wxPGChoices& choices,
+ const wxArrayInt& value)
+{
+ return new wxPG_PROPCLASS(wxMultiChoiceProperty)(label,name,choices,value);
+}
+#endif
+
+wxPGProperty* wxPG_CONSTFUNC(wxMultiChoiceProperty)(const wxString& label,
+ const wxString& name,
+ const
wxArrayString& strings,
+ const wxArrayInt& value)
+{
+ return new wxPG_PROPCLASS(wxMultiChoiceProperty)(label,name,strings,value);
+}
+
+WX_PG_IMPLEMENT_PROPERTY_CLASS(wxMultiChoiceProperty,wxPGProperty,
+ wxArrayInt,const wxArrayInt&,TextCtrlAndButton)
+
+wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label,
+ const wxString& name,
+ const wxPGChoices& choices,
+ const wxArrayInt& value)
+ : wxPGProperty(label,name)
+{
+ m_choices.Assign(choices);
+ SetValueI(value);
+}
+
+
+wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label,
+ const wxString& name,
+ const wxArrayString& strings,
+ const wxArrayInt& value)
+ : wxPGProperty(label,name)
+{
+ m_choices.Set(strings);
+ SetValueI(value);
+}
+
+wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label,
+ const wxString& name,
+ const wxArrayInt& WXUNUSED(value))
+ : wxPGProperty(label,name)
+{
+}
+
+wxMultiChoiceProperty::~wxMultiChoiceProperty()
+{
+}
+
+void wxMultiChoiceProperty::SetValueI( const wxArrayInt& arr )
+{
+ if ( &arr )
+ {
+ m_value = WXVARIANT(arr);
+ GenerateValueAsString();
+ }
+ else
+ {
+ m_display = wxEmptyString;
+ }
+}
+
+void wxMultiChoiceProperty::OnSetValue()
+{
+ GenerateValueAsString();
+}
+
+wxString wxMultiChoiceProperty::GetValueAsString( int ) const
+{
+ return m_display;
+}
+
+void wxMultiChoiceProperty::GenerateValueAsString()
+{
+ // Allow zero-length strings list
+ if ( !m_choices.IsOk() || !m_choices.GetCount() )
+ {
+ m_display = wxEmptyString;
+ return;
+ }
+
+ wxString& tempStr = m_display;
+ wxArrayInt indices = GetValueAsIndices();
+ unsigned int i;
+ unsigned int itemCount = indices.GetCount();
+
+ tempStr.Empty();
+
+ if ( itemCount )
+ tempStr.append( wxT("\"") );
+
+ for ( i = 0; i < itemCount; i++ )
+ {
+ int ind = indices.Item(i);
+ wxCHECK_RET( ind >= 0 && ind < (int)m_choices.GetCount(),
+ wxT("value out of range") );
+ tempStr.append( m_choices.GetLabel(ind) );
+ tempStr.append( wxT("\"") );
+ if ( i < (itemCount-1) )
+ tempStr.append ( wxT(" \"") );
+ }
+}
+
+wxArrayInt wxMultiChoiceProperty::GetValueAsIndices() const
+{
+ const wxArrayInt& valueArr = WX_PG_VARIANT_GETVALUEREF( m_value,
wxArrayInt );
+
+ if ( m_choices.GetCount() )
+ {
+ // Translate values to string indices.
+ wxArrayInt selections;
+
+ unsigned int i;
+ for ( i=0; i<valueArr.GetCount(); i++ )
+ {
+ int sIndex = m_choices.Index(valueArr[i]);
+ if ( sIndex >= 0 )
+ selections.Add(sIndex);
+ }
+
+ return selections;
+ }
+
+ return valueArr;
+}
+
+bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid,
+ wxWindow* WXUNUSED(primary),
+ wxEvent& event )
+{
+ if ( propgrid->IsMainButtonEvent(event) )
+ {
+ // Update the value
+ PrepareValueForDialogEditing(propgrid);
+
+ wxArrayString labels = m_choices.GetLabels();
+
+ // launch editor dialog
+ wxMultiChoiceDialog dlg( propgrid,
+ _("Make a selection:"),
+ m_label,
+ m_choices.GetCount(),
+ &labels[0],
+ wxCHOICEDLG_STYLE );
+
+ dlg.Move(
propgrid->GetGoodEditorDialogPosition(this,dlg.GetSize()) );
+
+ dlg.SetSelections(GetValueAsIndices());
+
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ wxArrayInt arrInt = dlg.GetSelections();
+
+ wxVariant variant;
+
+ if ( m_choices.GetCount() )
+ {
+ // Translate string indices to values.
+ wxArrayInt values;
+
+ unsigned int i;
+ for ( i=0; i<arrInt.GetCount(); i++ )
+ values.Add(m_choices.GetValue(arrInt.Item(i)));
+
+ variant = WXVARIANT(values);
+ }
+ else
+ {
+ variant = WXVARIANT(arrInt);
+ }
+
+ propgrid->ValueChangeInEvent(variant);
+
+ return true;
+ }
+ }
+ return false;
+}
+
+int wxMultiChoiceProperty::GetChoiceInfo( wxPGChoiceInfo* choiceinfo )
+{
+ if ( choiceinfo )
+ {
+ if ( m_choices.IsOk() )
+ choiceinfo->m_choices = &m_choices;
+
+ }
+ return -1;
+}
+
+bool wxMultiChoiceProperty::StringToValue( wxVariant& variant, const
wxString& text, int ) const
+{
+ wxArrayInt arr;
+
+ WX_PG_TOKENIZER2_BEGIN(text,wxT('"'))
+ int ind = m_choices.Index( token );
+ if ( ind != wxNOT_FOUND )
+ {
+ if ( m_choices.HasValue(ind) )
+ ind = m_choices.GetValue(ind);
+
+ arr.Add(ind);
+ }
+ WX_PG_TOKENIZER2_END()
+
+ wxVariant v( WXVARIANT(arr) );
+ variant = v;
+
+ return true;
+}
+
+#endif // wxUSE_CHOICEDLG
+
+
+// -----------------------------------------------------------------------
+// wxDateProperty
+// -----------------------------------------------------------------------
+
+#if wxUSE_DATETIME
+
+
+#if wxUSE_DATEPICKCTRL
+ #define dtCtrl DatePickerCtrl
+#else
+ #define dtCtrl TextCtrl
+#endif
+
+WX_PG_IMPLEMENT_PROPERTY_CLASS(wxDateProperty,
+ wxPGProperty,
+ wxDateTime,
+ const wxDateTime&,
+ dtCtrl)
+
+
+wxString wxDateProperty::ms_defaultDateFormat;
+
+
+wxDateProperty::wxDateProperty( const wxString& label,
+ const wxString& name,
+ const wxDateTime& value )
+ : wxPGProperty(label,name)
+{
+ //wxPGRegisterDefaultValueType(wxDateTime)
+
+#if wxUSE_DATEPICKCTRL
+ wxPGRegisterEditorClass(DatePickerCtrl);
+
+ m_dpStyle = wxDP_DEFAULT | wxDP_SHOWCENTURY;
+#else
+ m_dpStyle = 0;
+#endif
+
+ SetValue( value );
+}
+
+wxDateProperty::~wxDateProperty()
+{
+}
+
+bool wxDateProperty::StringToValue( wxVariant& variant, const
wxString& text,
+ int WXUNUSED(argFlags) ) const
+{
+ wxDateTime dt;
+ const wxChar* c = dt.ParseFormat(text.c_str(),wxDefaultDateTimeFormat);
+ if ( c )
+ {
+ variant = dt;
+ return true;
+ }
+
+ return false;
+}
+
+wxString wxDateProperty::GetValueAsString( int argFlags ) const
+{
+ const wxChar* format = (const wxChar*) NULL;
+
+ wxDateTime dateTime = m_value.GetDateTime();
+
+ if ( !dateTime.IsValid() )
+ return wxT("Invalid");
+
+ if ( !ms_defaultDateFormat.length() )
+ {
+#if wxUSE_DATEPICKCTRL
+ bool showCentury = m_dpStyle & wxDP_SHOWCENTURY ? true : false;
+#else
+ bool showCentury = true;
+#endif
+ ms_defaultDateFormat = DetermineDefaultDateFormat( showCentury );
+ }
+
+ if ( m_format.length() &&
+ !(argFlags & wxPG_FULL_VALUE) )
+ format = m_format.c_str();
+
+ // Determine default from locale
+ // NB: This is really simple stuff, but can't figure anything
+ // better without proper support in wxLocale
+ if ( !format )
+ format = ms_defaultDateFormat.c_str();
+
+ return dateTime.Format(format);
+}
+
+wxString wxDateProperty::DetermineDefaultDateFormat( bool showCentury )
+{
+ // This code is basicly copied from datectlg.cpp's SetFormat
+ //
+ wxString format;
+
+ wxDateTime dt;
+ dt.ParseFormat(wxT("2003-10-13"), wxT("%Y-%m-%d"));
+ wxString str(dt.Format(wxT("%x")));
+
+ const wxChar *p = str.c_str();
+ while ( *p )
+ {
+ int n=wxAtoi(p);
+ if (n == dt.GetDay())
+ {
+ format.Append(wxT("%d"));
+ p += 2;
+ }
+ else if (n == (int)dt.GetMonth()+1)
+ {
+ format.Append(wxT("%m"));
+ p += 2;
+ }
+ else if (n == dt.GetYear())
+ {
+ format.Append(wxT("%Y"));
+ p += 4;
+ }
+ else if (n == (dt.GetYear() % 100))
+ {
+ if (showCentury)
+ format.Append(wxT("%Y"));
+ else
+ format.Append(wxT("%y"));
+ p += 2;
+ }
+ else
+ format.Append(*p++);
+ }
+
+ return format;
+}
+
+bool wxDateProperty::DoSetAttribute( const wxString& name, wxVariant&
value )
+{
+ if ( name == wxPG_DATE_FORMAT )
+ {
+ m_format = value.GetString();
+ return true;
+ }
+ else if ( name == wxPG_DATE_PICKER_STYLE )
+ {
+ m_dpStyle = value.GetLong();
+ ms_defaultDateFormat.clear(); // This may need recalculation
+ return true;
+ }
+ return false;
+}
+
+#endif // wxUSE_DATETIME
+
+
+// -----------------------------------------------------------------------
+// wxPropertyContainerMethods
+// -----------------------------------------------------------------------
+
+void wxPropertyContainerMethods::InitAllTypeHandlers()
+{
+ //wxPG_INIT_REQUIRED_TYPE(wxColour)
+ //wxPG_INIT_REQUIRED_TYPE(wxFont)
+ //wxPG_INIT_REQUIRED_TYPE(wxArrayInt)
+ //wxPG_INIT_REQUIRED_TYPE(wxColourPropertyValue)
+/*#if wxUSE_DATETIME
+ wxPGRegisterDefaultValueType(wxDateTime)
+#endif*/
+}
+
+// -----------------------------------------------------------------------
+
+void wxPropertyContainerMethods::RegisterAdditionalEditors()
+{
+#if wxUSE_SPINBTN
+ wxPGRegisterEditorClass(SpinCtrl);
+#endif
+#if wxUSE_DATEPICKCTRL
+ wxPGRegisterEditorClass(DatePickerCtrl);
+#endif
+}
+
+// -----------------------------------------------------------------------
+
+#endif // wxPG_INCLUDE_ADVPROPS

Added: trunk/wx.mod/wxpropgrid.mod/src/editors.cpp
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/editors.cpp Sat Dec 15 08:55:59 2007
@@ -0,0 +1,2150 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: editors.cpp
+// Purpose: wxPropertyGrid editors
+// Author: Jaakko Salli
+// Modified by:
+// Created: Apr-14-2007
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+ #pragma implementation "editors.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/defs.h"
+ #include "wx/object.h"
+ #include "wx/hash.h"
+ #include "wx/string.h"
+ #include "wx/log.h"
+ #include "wx/event.h"
+ #include "wx/window.h"
+ #include "wx/panel.h"
+ #include "wx/dc.h"
+ #include "wx/dcclient.h"
+ #include "wx/dcmemory.h"
+ #include "wx/button.h"
+ #include "wx/pen.h"
+ #include "wx/brush.h"
+ #include "wx/cursor.h"
+ #include "wx/dialog.h"
+ #include "wx/settings.h"
+ #include "wx/msgdlg.h"
+ #include "wx/choice.h"
+ #include "wx/stattext.h"
+ #include "wx/scrolwin.h"
+ #include "wx/dirdlg.h"
+ #include "wx/layout.h"
+ #include "wx/sizer.h"
+ #include "wx/textdlg.h"
+ #include "wx/filedlg.h"
+ #include "wx/statusbr.h"
+ #include "wx/intl.h"
+ #include "wx/frame.h"
+#endif
+
+
+#include "wx/timer.h"
+#include "wx/dcbuffer.h"
+#include "wx/bmpbuttn.h"
+
+
+// This define is necessary to prevent macro clearing
+#define __wxPG_SOURCE_FILE__
+
+#include <wx/propgrid/propgrid.h>
+#include <wx/propgrid/propdev.h>
+#include <wx/propgrid/editors.h>
+#include <wx/propgrid/props.h>
+
+#ifdef __WXPYTHON__
+ #include <wx/propgrid/advprops.h>
+ #include <wx/propgrid/extras.h>
+#endif
+
+#if wxPG_USE_RENDERER_NATIVE
+ #include <wx/renderer.h>
+#endif
+
+// How many pixels between textctrl and button
+#ifdef __WXMAC__
+ #define wxPG_TEXTCTRL_AND_BUTTON_SPACING 8
+#else
+ #define wxPG_TEXTCTRL_AND_BUTTON_SPACING 2
+#endif
+
+#define wxPG_BUTTON_SIZEDEC 0
+
+#if wxPG_USING_WXOWNERDRAWNCOMBOBOX
+ #include <wx/odcombo.h>
+#else
+ #include <wx/propgrid/odcombo.h>
+#endif
+
+#ifdef __WXMSW__
+ #include <wx/msw/private.h>
+#endif
+
+// -----------------------------------------------------------------------
+
+#if defined(__WXMSW__)
+ // tested
+ #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable
border of native textctrl.
+ #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable
border of native textctrl.
+
+ #define wxPG_NAT_BUTTON_BORDER_ANY 1
+ #define wxPG_NAT_BUTTON_BORDER_X 1
+ #define wxPG_NAT_BUTTON_BORDER_Y 1
+
+ #define wxPG_CHECKMARK_XADJ 1
+ #define wxPG_CHECKMARK_YADJ (-1)
+ #define wxPG_CHECKMARK_WADJ 0
+ #define wxPG_CHECKMARK_HADJ 0
+ #define wxPG_CHECKMARK_DEFLATE 0
+
+ #define wxPG_TEXTCTRLYADJUST (m_spacingy+0)
+
+#elif defined(__WXGTK__)
+ // tested
+ #define wxPG_CHECKMARK_XADJ 0
+ #define wxPG_CHECKMARK_YADJ 0
+ #define wxPG_CHECKMARK_WADJ (-1)
+ #define wxPG_CHECKMARK_HADJ (-1)
+ #define wxPG_CHECKMARK_DEFLATE 3
+
+ #define wxPG_NAT_TEXTCTRL_BORDER_X 3 // Unremovable border of
native textctrl.
+ #define wxPG_NAT_TEXTCTRL_BORDER_Y 3 // Unremovable border of
native textctrl.
+
+ #define wxPG_NAT_BUTTON_BORDER_ANY 1
+ #define wxPG_NAT_BUTTON_BORDER_X 1
+ #define wxPG_NAT_BUTTON_BORDER_Y 1
+
+ #define wxPG_TEXTCTRLYADJUST 0
+
+#elif defined(__WXMAC__)
+ // *not* tested
+ #define wxPG_CHECKMARK_XADJ 0
+ #define wxPG_CHECKMARK_YADJ 0
+ #define wxPG_CHECKMARK_WADJ 0
+ #define wxPG_CHECKMARK_HADJ 0
+ #define wxPG_CHECKMARK_DEFLATE 0
+
+ #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable border of
native textctrl.
+ #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable border of
native textctrl.
+
+ #define wxPG_NAT_BUTTON_BORDER_ANY 0
+ #define wxPG_NAT_BUTTON_BORDER_X 0
+ #define wxPG_NAT_BUTTON_BORDER_Y 0
+
+ #define wxPG_TEXTCTRLYADJUST 3
+
+#else
+ // defaults
+ #define wxPG_CHECKMARK_XADJ 0
+ #define wxPG_CHECKMARK_YADJ 0
+ #define wxPG_CHECKMARK_WADJ 0
+ #define wxPG_CHECKMARK_HADJ 0
+ #define wxPG_CHECKMARK_DEFLATE 0
+
+ #define wxPG_NAT_TEXTCTRL_BORDER_X 0 // Unremovable border of
native textctrl.
+ #define wxPG_NAT_TEXTCTRL_BORDER_Y 0 // Unremovable border of
native textctrl.
+
+ #define wxPG_NAT_BUTTON_BORDER_ANY 0
+ #define wxPG_NAT_BUTTON_BORDER_X 0
+ #define wxPG_NAT_BUTTON_BORDER_Y 0
+
+ #define wxPG_TEXTCTRLYADJUST 0
+
+#endif
+
+#if (!wxPG_NAT_TEXTCTRL_BORDER_X && !wxPG_NAT_TEXTCTRL_BORDER_Y)
+ #define wxPG_ENABLE_CLIPPER_WINDOW 0
+#else
+ #define wxPG_ENABLE_CLIPPER_WINDOW 1
+#endif
+
+
+// for odcombo
+#define wxPG_CHOICEXADJUST 0
+#define wxPG_CHOICEYADJUST 0
+
+#define ODCB_CUST_PAINT_MARGIN 6 // Number added to
image width for SetCustomPaintWidth
+
+// Milliseconds to wait for two mouse-ups after focus inorder
+// to trigger a double-click.
+#define DOUBLE_CLICK_CONVERSION_TRESHOLD 500
+
+// -----------------------------------------------------------------------
+// wxPGEditor
+// -----------------------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxPGEditor, wxObject)
+
+wxPGEditor::~wxPGEditor()
+{
+}
+
+
+/*wxPGCellRenderer* wxPGEditor::GetCellRenderer() const
+{
+ return &g_wxPGDefaultRenderer;
+}*/
+
+void wxPGEditor::DrawValue( wxDC& dc, const wxRect& rect,
wxPGProperty* property, const wxString& text ) const
+{
+ if ( !property->IsValueUnspecified() )
+ dc.DrawText( text, rect.x+wxPG_XBEFORETEXT, rect.y );
+}
+
+#ifdef __WXPYTHON__
+bool wxPGEditor::GetValueFromControl( wxVariant&, wxPGProperty*,
wxWindow* ) const
+{
+ return false;
+}
+
+wxPGVariantAndBool wxPGEditor::PyGetValueFromControl( wxPGProperty*
property, wxWindow* ctrl ) const
+{
+ wxPGVariantAndBool vab;
+ vab.m_result = GetValueFromControl(vab.m_value, property, ctrl);
+ if ( vab.m_result )
+ vab.m_valueValid = true;
+ return vab;
+}
+#endif
+
+void wxPGEditor::SetControlStringValue( wxWindow*, const wxString& ) const
+{
+}
+
+
+void wxPGEditor::SetControlIntValue( wxWindow*, int ) const
+{
+}
+
+
+int wxPGEditor::InsertItem( wxWindow*, const wxString&, int ) const
+{
+ return -1;
+}
+
+
+void wxPGEditor::DeleteItem( wxWindow*, int ) const
+{
+ return;
+}
+
+
+void wxPGEditor::OnFocus( wxPGProperty*, wxWindow* ) const
+{
+}
+
+
+bool wxPGEditor::CanContainCustomImage() const
+{
+ return false;
+}
+
+// -----------------------------------------------------------------------
+// wxPGClipperWindow
+// -----------------------------------------------------------------------
+
+
+#if wxPG_ENABLE_CLIPPER_WINDOW
+
+//
+// Clipper window is used to "remove" borders from controls
+// which otherwise insist on having them despite of supplied
+// wxNO_BORDER window style.
+//
+class wxPGClipperWindow : public wxWindow
+{
+ DECLARE_CLASS(wxPGClipperWindow)
+public:
+
+ wxPGClipperWindow()
+ : wxWindow()
+ {
+ wxPGClipperWindow::Init();
+ }
+
+ wxPGClipperWindow(wxWindow* parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize)
+ {
+ Init();
+ Create(parent,id,pos,size);
+ }
+
+ void Create(wxWindow* parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize);
+
+ virtual ~wxPGClipperWindow();
+
+ virtual bool ProcessEvent(wxEvent& event);
+
+ inline wxWindow* GetControl() const { return m_ctrl; }
+
+ // This is called before wxControl is constructed.
+ void GetControlRect( int xadj, int yadj, wxPoint& pt, wxSize& sz );
+
+ // This is caleed after wxControl has been constructed.
+ void SetControl( wxWindow* ctrl );
+
+ virtual void Refresh( bool eraseBackground = true,
+ const wxRect *rect = (const wxRect *) NULL );
+ virtual void SetFocus();
+
+ virtual bool SetFont(const wxFont& font);
+
+ inline int GetXClip() const { return m_xadj; }
+
+ inline int GetYClip() const { return m_yadj; }
+
+protected:
+ wxWindow* m_ctrl;
+
+ int m_xadj; // Horizontal border clip.
+
+ int m_yadj; // Vertical border clip.
+
+private:
+ void Init ()
+ {
+ m_ctrl = (wxWindow*) NULL;
+ }
+};
+
+
+IMPLEMENT_CLASS(wxPGClipperWindow,wxWindow)
+
+
+// This is called before wxControl is constructed.
+void wxPGClipperWindow::GetControlRect( int xadj, int yadj, wxPoint&
pt, wxSize& sz )
+{
+ m_xadj = xadj;
+ m_yadj = yadj;
+ pt.x = -xadj;
+ pt.y = -yadj;
+ wxSize own_size = GetSize();
+ sz.x = own_size.x+(xadj*2);
+ sz.y = own_size.y+(yadj*2);
+}
+
+
+// This is caleed after wxControl has been constructed.
+void wxPGClipperWindow::SetControl( wxWindow* ctrl )
+{
+ m_ctrl = ctrl;
+
+ // GTK requires this.
+ ctrl->SetSizeHints(3,3);
+
+ // Correct size of this window to match the child.
+ wxSize sz = GetSize();
+ wxSize chsz = ctrl->GetSize();
+
+ int hei_adj = chsz.y - (sz.y+(m_yadj*2));
+ if ( hei_adj )
+ SetSize(sz.x,chsz.y-(m_yadj*2));
+
+}
+
+
+void wxPGClipperWindow::Refresh( bool eraseBackground, const wxRect
*rect )
+{
+ wxWindow::Refresh(false,rect);
+ if ( m_ctrl )
+ m_ctrl->Refresh(eraseBackground);
+}
+
+
+// Pass focus to control
+void wxPGClipperWindow::SetFocus()
+{
+ if ( m_ctrl )
+ m_ctrl->SetFocus();
+ else
+ wxWindow::SetFocus();
+}
+
+
+bool wxPGClipperWindow::SetFont(const wxFont& font)
+{
+ bool res = wxWindow::SetFont(font);
+ if ( m_ctrl )
+ return m_ctrl->SetFont(font);
+ return res;
+}
+
+
+void wxPGClipperWindow::Create(wxWindow* parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size )
+{
+ wxWindow::Create(parent,id,pos,size);
+}
+
+
+wxPGClipperWindow::~wxPGClipperWindow()
+{
+}
+
+
+bool wxPGClipperWindow::ProcessEvent(wxEvent& event)
+{
+ if ( event.GetEventType() == wxEVT_SIZE )
+ {
+ if ( m_ctrl )
+ {
+ // Maintain correct size relationship.
+ wxSize sz = GetSize();
+ m_ctrl->SetSize(sz.x+(m_xadj*2),sz.y+(m_yadj*2));
+ event.Skip();
+ return false;
+ }
+ }
+ return wxWindow::ProcessEvent(event);
+}
+
+#endif // wxPG_ENABLE_CLIPPER_WINDOW
+
+/*wxWindow* wxPropertyGrid::GetActualEditorControl( wxWindow* ctrl )
+{
+#if wxPG_ENABLE_CLIPPER_WINDOW
+ // Pass real control instead of clipper window
+ if ( ctrl->IsKindOf(CLASSINFO(wxPGClipperWindow)) )
+ {
+ return ((wxPGClipperWindow*)ctrl)->GetControl();
+ }
+#else
+ return ctrl;
+#endif
+}*/
+
+// -----------------------------------------------------------------------
+// wxPGTextCtrlEditor
+// -----------------------------------------------------------------------
+
+// Clipper window support macro (depending on whether it is used
+// for this editor or not)
+/*
+#if wxPG_NAT_TEXTCTRL_BORDER_X || wxPG_NAT_TEXTCTRL_BORDER_Y
+ #define wxPG_NAT_TEXTCTRL_BORDER_ANY 1
+ #define wxPGDeclareRealTextCtrl(WND) \
+ wxASSERT( WND ); \
+ wxTextCtrl* tc = (wxTextCtrl*)((wxPGClipperWindow*)WND)->GetControl()
+#else
+ #define wxPG_NAT_TEXTCTRL_BORDER_ANY 0
+ #define wxPGDeclareRealTextCtrl(WND) \
+ wxASSERT( WND ); \
+ wxTextCtrl* tc = (wxTextCtrl*)WND
+#endif
+*/
+
+WX_PG_IMPLEMENT_EDITOR_CLASS(TextCtrl,wxPGTextCtrlEditor,wxPGEditor)
+
+
+wxPGWindowList wxPGTextCtrlEditor::CreateControls( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ const wxPoint& pos,
+ const wxSize& sz ) const
+{
+ wxString text;
+
+ // If has children and limited editing, then don't create.
+ if ((property->GetFlags() & wxPG_PROP_NOEDITOR) &&
+ property->GetParentingType() < 0 &&
+ !property->IsKindOf(WX_PG_CLASSINFO(wxCustomProperty)))
+ return (wxWindow*) NULL;
+
+ if ( !property->IsValueUnspecified() )
+ text = property->GetValueString(property->HasFlag(wxPG_PROP_READONLY)?0:wxPG_EDITABLE_VALUE);
+
+ int flags = 0;
+ if ( (property->GetFlags() & wxPG_PROP_PASSWORD) &&
+ property->IsKindOf(WX_PG_CLASSINFO(wxStringProperty)) )
+ flags |= wxTE_PASSWORD;
+
+ wxWindow* wnd = propGrid->GenerateEditorTextCtrl(pos,sz,text,(wxWindow*)NULL,flags,
+ property->GetMaxLength());
+
+ return wnd;
+}
+
+#if 0
+void wxPGTextCtrlEditor::DrawValue( wxDC& dc, wxPGProperty* property,
const wxRect& rect ) const
+{
+ if ( !property->IsValueUnspecified() )
+ {
+ wxString drawStr = property->GetDisplayedString();
+
+ // Code below should no longer be needed, as the obfuscation
+ // is now done in GetValueAsString.
+ /*if ( (property->GetFlags() & wxPG_PROP_PASSWORD) &&
+ property->IsKindOf(WX_PG_CLASSINFO(wxStringProperty)) )
+ {
+ size_t a = drawStr.length();
+ drawStr.Empty();
+ drawStr.Append(wxT('*'),a);
+ }*/
+ dc.DrawText( drawStr, rect.x+wxPG_XBEFORETEXT, rect.y );
+ }
+}
+#endif
+
+void wxPGTextCtrlEditor::UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const
+{
+ wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl);
+ tc->SetValue(property->GetDisplayedString());
+}
+
+
+// Provided so that, for example, ComboBox editor can use the same code
+// (multiple inheritance would get way too messy).
+bool wxPGTextCtrlEditor::OnTextCtrlEvent( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ wxEvent& event )
+{
+ if ( !ctrl )
+ return false;
+
+ if ( event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER )
+ {
+ if ( propGrid->IsEditorsValueModified() )
+ {
+ return true;
+ }
+ }
+ else if ( event.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED )
+ {
+ wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl);
+
+ // If value is unspecified and character count is zero,
+ // then do not set as modified.
+ if ( !property->IsValueUnspecified() ||
+ !tc ||
+ (tc->IsKindOf(CLASSINFO(wxTextCtrl)) &&
+ (tc->GetLastPosition() > 0)) )
+ {
+
+ // We must check this since an 'empty' text event
+ // may be triggered when creating the property.
+ if ( !(propGrid->GetInternalFlags() &
wxPG_FL_IN_SELECT_PROPERTY) )
+ {
+ //
+ // Pass this event outside wxPropertyGrid so that,
+ // if necessary, program can tell when user is editing
+ // a textctrl.
+ // FIXME: Is it safe to change event id in the middle
of event
+ // processing (seems to work, but...)?
+ event.Skip();
+ event.SetId(propGrid->GetId());
+ }
+
+ propGrid->EditorsValueWasModified();
+ }
+ }
+ return false;
+}
+
+
+bool wxPGTextCtrlEditor::OnEvent( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ wxEvent& event ) const
+{
+ return wxPGTextCtrlEditor::OnTextCtrlEvent(propGrid,property,ctrl,event);
+}
+
+
+bool wxPGTextCtrlEditor::GetTextCtrlValueFromControl( wxVariant&
variant, wxPGProperty* property, wxWindow* ctrl )
+{
+ wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl);
+
+ bool res = property->ActualStringToValue(variant, tc->GetValue(), 0);
+
+ // Changing unspecified always causes event (returning
+ // true here should be enough to trigger it).
+ // TODO: Move to propgrid.cpp
+ if ( !res && property->IsValueUnspecified() )
+ res = true;
+
+ return res;
+}
+
+
+bool wxPGTextCtrlEditor::GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl ) const
+{
+ return wxPGTextCtrlEditor::GetTextCtrlValueFromControl(variant,
property, ctrl);
+}
+
+
+void wxPGTextCtrlEditor::SetValueToUnspecified( wxWindow* ctrl ) const
+{
+ wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl);
+
+ tc->Remove(0,tc->GetValue().length());
+}
+
+
+void wxPGTextCtrlEditor::SetControlStringValue( wxWindow* ctrl, const
wxString& txt ) const
+{
+ wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl);
+
+ tc->SetValue(txt);
+}
+
+
+void wxPGTextCtrlEditor::OnFocus( wxPGProperty*, wxWindow* wnd ) const
+{
+ wxTextCtrl* tc = wxStaticCast(wnd, wxTextCtrl);
+
+ tc->SetSelection(-1,-1);
+}
+
+
+wxPGTextCtrlEditor::~wxPGTextCtrlEditor() { }
+
+
+// -----------------------------------------------------------------------
+// wxPGChoiceEditor
+// -----------------------------------------------------------------------
+
+
+WX_PG_IMPLEMENT_EDITOR_CLASS(Choice,wxPGChoiceEditor,wxPGEditor)
+
+
+// This is a special enhanced double-click processor class.
+// In essence, it allows for double-clicks for which the
+// first click "created" the control.
+class wxPGDoubleClickProcessor : public wxEvtHandler
+{
+public:
+
+ wxPGDoubleClickProcessor( wxPGOwnerDrawnComboBox* combo )
+ : wxEvtHandler()
+ {
+ m_timeLastMouseUp = 0;
+ m_combo = combo;
+ m_downReceived = false;
+ }
+
+protected:
+
+ void OnMouseEvent( wxMouseEvent& event )
+ {
+ wxLongLong t = ::wxGetLocalTimeMillis();
+ int evtType = event.GetEventType();
+
+ if ( m_combo->HasFlag(wxPGCC_DCLICK_CYCLES) &&
+ !m_combo->IsPopupShown() )
+ {
+ // Just check that it is in the text area
+ wxPoint pt = event.GetPosition();
+ if ( m_combo->GetTextRect().wxPGRectContains(pt) )
+ {
+ if ( evtType == wxEVT_LEFT_DOWN )
+ {
+ // Set value to avoid up-events without
corresponding downs
+ m_downReceived = true;
+ }
+ else if ( evtType == wxEVT_LEFT_DCLICK )
+ {
+ // We'll make our own double-clicks
+ event.SetEventType(0);
+ return;
+ }
+ else if ( evtType == wxEVT_LEFT_UP )
+ {
+ if ( m_downReceived || m_timeLastMouseUp == 1 )
+ {
+ wxLongLong timeFromLastUp = (t-m_timeLastMouseUp);
+
+ if ( timeFromLastUp <
DOUBLE_CLICK_CONVERSION_TRESHOLD )
+ {
+ event.SetEventType(wxEVT_LEFT_DCLICK);
+ m_timeLastMouseUp = 1;
+ }
+ else
+ {
+ m_timeLastMouseUp = t;
+ }
+ }
+ }
+ }
+ }
+
+ event.Skip();
+ }
+
+ void OnSetFocus( wxFocusEvent& event )
+ {
+ m_timeLastMouseUp = ::wxGetLocalTimeMillis();
+ event.Skip();
+ }
+
+private:
+ wxLongLong m_timeLastMouseUp;
+ wxPGOwnerDrawnComboBox* m_combo;
+ bool m_downReceived;
+
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxPGDoubleClickProcessor, wxEvtHandler)
+ EVT_MOUSE_EVENTS(wxPGDoubleClickProcessor::OnMouseEvent)
+ EVT_SET_FOCUS(wxPGDoubleClickProcessor::OnSetFocus)
+END_EVENT_TABLE()
+
+
+
+class wxPGComboBox : public wxPGOwnerDrawnComboBox
+{
+public:
+
+ wxPGComboBox()
+ : wxPGOwnerDrawnComboBox()
+ {
+ m_dclickProcessor = (wxPGDoubleClickProcessor*) NULL;
+ m_sizeEventCalled = false;
+ }
+
+ ~wxPGComboBox()
+ {
+ if ( m_dclickProcessor )
+ {
+ RemoveEventHandler(m_dclickProcessor);
+ delete m_dclickProcessor;
+ }
+ }
+
+ bool Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style = 0,
+ const wxValidator& validator = wxDefaultValidator,
+ const wxString& name = wxT("wxOwnerDrawnComboBox"))
+ {
+ if ( !wxPGOwnerDrawnComboBox::Create( parent,
+ id,
+ value,
+ pos,
+ size,
+ choices,
+ style,
+ validator,
+ name ) )
+ return false;
+
+ m_dclickProcessor = new wxPGDoubleClickProcessor(this);
+
+ PushEventHandler(m_dclickProcessor);
+
+ return true;
+ }
+
+#if wxPG_USING_WXOWNERDRAWNCOMBOBOX
+ virtual void OnDrawItem( wxDC& dc, const wxRect& rect, int item,
int flags ) const
+#else
+ virtual bool OnDrawItem( wxDC& dc, const wxRect& rect, int item,
int flags ) const
+#endif
+ {
+ wxPropertyGrid* pg = GetGrid();
+ pg->OnComboItemPaint((wxPGCustomComboControl*)this,item,dc,(wxRect&)rect,flags);
+#if !wxPG_USING_WXOWNERDRAWNCOMBOBOX
+ return true;
+#endif
+ }
+ virtual wxCoord OnMeasureItem( size_t item ) const
+ {
+ wxPropertyGrid* pg = GetGrid();
+ wxRect rect;
+ rect.x = -1;
+ rect.width = 0;
+ pg->OnComboItemPaint((wxPGCustomComboControl*)this,item,*((wxDC*)NULL),rect,0);
+ return rect.height;
+ }
+
+ wxPropertyGrid* GetGrid() const
+ {
+ wxPropertyGrid* pg = wxDynamicCast(GetParent()->GetParent(),wxPropertyGrid);
+ wxASSERT(pg);
+ return pg;
+ }
+
+ virtual wxCoord OnMeasureItemWidth( size_t item ) const
+ {
+ wxPropertyGrid* pg = GetGrid();
+ wxRect rect;
+ rect.x = -1;
+ rect.width = -1;
+ pg->OnComboItemPaint((wxPGCustomComboControl*)this,item,*((wxDC*)NULL),rect,0);
+ return rect.width;
+ }
+
+ virtual void PositionTextCtrl( int WXUNUSED(textCtrlXAdjust), int
WXUNUSED(textCtrlYAdjust) )
+ {
+ wxPropertyGrid* pg = GetGrid();
+ wxPGOwnerDrawnComboBox::PositionTextCtrl(
+ wxPG_TEXTCTRLXADJUST -
(wxPG_XBEFOREWIDGET+wxPG_CONTROL_MARGIN+1) - 1,
+ pg->GetSpacingY() + 2
+ );
+ }
+
+private:
+ wxPGDoubleClickProcessor* m_dclickProcessor;
+ bool m_sizeEventCalled;
+};
+
+
+void wxPropertyGrid::OnComboItemPaint( wxPGCustomComboControl* pCc,
+ int item,
+ wxDC& dc,
+ wxRect& rect,
+ int flags )
+{
+ wxPGComboBox* pCb = (wxPGComboBox*)pCc;
+
+ // Sanity check
+ wxASSERT( IsKindOf(CLASSINFO(wxPropertyGrid)) );
+
+ wxPGProperty* p = m_selected;
+ wxString text;
+
+ const wxPGChoices* pChoices = &p->GetChoices();
+ const wxPGCommonValue* comVal = NULL;
+ int choiceCount = p->GetChoiceCount();
+ int comVals = p->GetDisplayedCommonValueCount();
+ int comValIndex = -1;
+ if ( item >= choiceCount && comVals > 0 )
+ {
+ comValIndex = item - choiceCount;
+ comVal = GetCommonValue(comValIndex);
+ if ( !p->IsValueUnspecified() )
+ text = comVal->GetLabel();
+ }
+ else
+ {
+ if ( !(flags & wxPGCC_PAINTING_CONTROL) )
+ {
+ text = pCb->GetString(item);
+ }
+ else
+ {
+ if ( !p->IsValueUnspecified() )
+ text = p->GetValueString(0);
+ }
+ }
+
+ if ( item < 0 )
+ return;
+
+#if !wxPG_USING_WXOWNERDRAWNCOMBOBOX
+ // Add wxPGCC_PAINTING_SELECTED
+ if ( !(flags & wxPGCC_PAINTING_CONTROL) &&
+
wxDynamicCast(pCb->GetPopup()->GetControl(),wxVListBox)->GetSelection()
== item )
+ flags |= wxPGCC_PAINTING_SELECTED;
+#endif
+
+ //
+ // Decide what custom image size to use
+ wxSize cis = GetImageSize(p, item);
+
+ if ( rect.x < 0 )
+ {
+ // Default measure behaviour (no flexible, custom paint image only)
+ if ( rect.width < 0 )
+ {
+ wxCoord x, y;
+ GetTextExtent(text, &x, &y, 0, 0, &m_font);
+ rect.width = cis.x + wxCC_CUSTOM_IMAGE_MARGIN1 +
wxCC_CUSTOM_IMAGE_MARGIN2 + 9 + x;
+ }
+
+ rect.height = cis.y + 2;
+ return;
+ }
+
+ wxPGPaintData paintdata;
+ paintdata.m_parent = NULL;
+ paintdata.m_choiceItem = item;
+
+ // This is by the current (1.0.0b) spec - if painting control,
item is -1
+ if ( (flags & wxPGCC_PAINTING_CONTROL) )
+ paintdata.m_choiceItem = -1;
+
+ if ( &dc )
+ dc.SetBrush(*wxWHITE_BRUSH);
+
+ if ( rect.x >= 0 )
+ {
+ //
+ // DrawItem call
+
+ wxPoint pt(rect.x + wxPG_CONTROL_MARGIN - wxPG_CHOICEXADJUST - 1,
+ rect.y + 1);
+
+ int renderFlags = 0;
+
+ if ( flags & wxPGCC_PAINTING_CONTROL )
+ renderFlags |= wxPGCellRenderer::Control;
+
+ if ( flags & wxPGCC_PAINTING_SELECTED )
+ renderFlags |= wxPGCellRenderer::Selected;
+
+ if ( cis.x > 0 && (p->HasFlag(wxPG_PROP_CUSTOMIMAGE) ||
!(flags & wxPGCC_PAINTING_CONTROL)) &&
+ ( !p->m_dataExt || !p->m_dataExt->m_valueBitmap || item
== pCb->GetSelection() ) &&
+ ( item >= 0 || (flags & wxPGCC_PAINTING_CONTROL) )
+ )
+ {
+ pt.x += wxCC_CUSTOM_IMAGE_MARGIN1;
+ wxRect r(pt.x,pt.y,cis.x,cis.y);
+
+ if ( flags & wxPGCC_PAINTING_CONTROL )
+ {
+ //r.width = cis.x;
+ r.height = wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight);
+ }
+
+ paintdata.m_drawnWidth = r.width;
+
+ dc.SetPen(m_colPropFore);
+ if ( comValIndex >= 0 )
+ {
+ const wxPGCommonValue* cv = GetCommonValue(comValIndex);
+ wxPGCellRenderer* renderer = cv->GetRenderer();
+ r.width = rect.width;
+ renderer->Render( dc, r, this, p, m_selColumn,
comValIndex, renderFlags );
+ return;
+ }
+ else if ( item >= 0 )
+ {
+ p->OnCustomPaint( dc, r, paintdata );
+ }
+ else
+ {
+ dc.DrawRectangle( r );
+ }
+
+ pt.x += paintdata.m_drawnWidth + wxCC_CUSTOM_IMAGE_MARGIN2
- 1;
+ }
+ else
+ {
+ // TODO: This aligns text so that it seems to be horizontally
+ // on the same line as property values. Not really
+ // sure if its needed, but seems to not cause any harm.
+ pt.x -= 1;
+
+ if ( item < 0 && (flags & wxPGCC_PAINTING_CONTROL) )
+ item = pCb->GetSelection();
+
+ if ( pChoices && item >= 0 && comValIndex < 0 )
+ {
+ const wxPGChoiceEntry& cell = pChoices->Item(item);
+ wxPGCellRenderer* renderer = wxPGGlobalVars->m_defaultRenderer;
+ int imageOffset = renderer->PreDrawCell( dc, rect,
cell, renderFlags );
+ if ( imageOffset )
+ imageOffset += wxCC_CUSTOM_IMAGE_MARGIN1 + wxCC_CUSTOM_IMAGE_MARGIN2;
+ pt.x += imageOffset;
+ }
+ }
+
+ //
+ // Draw text
+ //
+
+ pt.y += (rect.height-m_fontHeight)/2 - 1;
+
+ pt.x += 1;
+
+ dc.DrawText( text, pt.x + wxPG_XBEFORETEXT, pt.y );
+ }
+ else
+ {
+ //
+ // MeasureItem call
+
+ p->OnCustomPaint( dc, rect, paintdata );
+ rect.height = paintdata.m_drawnHeight + 2;
+ rect.width = cis.x + wxCC_CUSTOM_IMAGE_MARGIN1 +
wxCC_CUSTOM_IMAGE_MARGIN2 + 9;
+ }
+}
+
+bool wxPGChoiceEditor_SetCustomPaintWidth( wxPropertyGrid* propGrid,
wxPGComboBox* cb, int cmnVal )
+{
+ wxPGProperty* property = propGrid->GetSelectedProperty();
+ wxASSERT( property );
+
+ if ( cmnVal >= 0 )
+ {
+ // Yes, a common value is being selected
+ property->SetCommonValue( cmnVal );
+ wxSize imageSize = propGrid->GetCommonValue(cmnVal)->
+ GetRenderer()->GetImageSize(property, 1, cmnVal);
+ if ( imageSize.x ) imageSize.x += ODCB_CUST_PAINT_MARGIN;
+ cb->SetCustomPaintWidth( imageSize.x );
+ return false;
+ }
+ else
+ {
+ wxSize imageSize = propGrid->GetImageSize(property, -1);
+ if ( imageSize.x ) imageSize.x += ODCB_CUST_PAINT_MARGIN;
+ cb->SetCustomPaintWidth( imageSize.x );
+ return true;
+ }
+}
+
+// CreateControls calls this with CB_READONLY in extraStyle
+wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ const wxPoint& pos,
+ const wxSize& sz,
+ long extraStyle ) const
+{
+ wxString defString;
+
+ // Get choices.
+ int index = property->GetChoiceInfo( NULL );
+
+ bool isUnspecified = property->IsValueUnspecified();
+
+ if ( isUnspecified )
+ index = -1;
+ else
+ defString = property->GetDisplayedString();
+
+ const wxPGChoices& choices = property->GetChoices();
+
+ wxArrayString labels = choices.GetLabels();
+
+ wxPGComboBox* cb;
+
+ wxPoint po(pos);
+ wxSize si(sz);
+ po.y += wxPG_CHOICEYADJUST;
+ si.y -= (wxPG_CHOICEYADJUST*2);
+
+ po.x += wxPG_CHOICEXADJUST;
+ si.x -= wxPG_CHOICEXADJUST;
+ wxWindow* ctrlParent = propGrid->GetPanel();
+
+ int odcbFlags = extraStyle | wxNO_BORDER | wxPGCC_PROCESS_ENTER | wxPGCC_ALT_KEYS;
+
+ //
+ // If this editor was alternate for TextCtrlAndButton, then
+ // let's clear the readonly flag.
+ if (
property->DoGetEditorClass()->IsKindOf(CLASSINFO(wxPGTextCtrlAndButtonEditor)) )
+ {
+ odcbFlags &= ~wxCB_READONLY;
+ }
+
+ if ( (property->GetFlags() & wxPG_PROP_USE_DCC) &&
+ (property->IsKindOf(CLASSINFO(wxBoolProperty)) ) )
+ odcbFlags |= wxPGCC_DCLICK_CYCLES;
+
+ //
+ // If common value specified, use appropriate index
+ unsigned int cmnVals = property->GetDisplayedCommonValueCount();
+ if ( cmnVals )
+ {
+ if ( !isUnspecified )
+ {
+ int cmnVal = property->GetCommonValue();
+ if ( cmnVal >= 0 )
+ {
+ index = labels.size() + cmnVal;
+ }
+ }
+
+ unsigned int i;
+ for ( i=0; i<cmnVals; i++ )
+ labels.Add(propGrid->GetCommonValueLabel(i));
+ }
+
+ cb = new wxPGComboBox();
+#ifdef __WXMSW__
+ cb->Hide();
+#endif
+ cb->Create(ctrlParent,
+ wxPG_SUBID1,
+ wxString(),
+ po,
+ si,
+ labels,
+ odcbFlags);
+
+ //int extRight = propGrid->GetClientSize().x - (po.x+si.x);
+ //int extRight = - (po.x+si.x);
+
+ cb->SetButtonPosition(si.y,0,wxRIGHT);
+ //cb->SetPopupExtents( 1, extRight );
+ cb->SetTextIndent(wxPG_XBEFORETEXT-1);
+
+ wxPGChoiceEditor_SetCustomPaintWidth( propGrid, cb,
property->GetCommonValue() );
+ /*if ( property->GetFlags() & wxPG_PROP_CUSTOMIMAGE )
+ {
+ wxSize imageSize = propGrid->GetImageSize(property, index);
+ if ( imageSize.x ) imageSize.x += ODCB_CUST_PAINT_MARGIN;
+ cb->SetCustomPaintWidth( imageSize.x );
+ }*/
+
+ if ( index >= 0 && index < (int)cb->GetCount() )
+ {
+ cb->SetSelection( index );
+ if ( defString.length() )
+ cb->SetText( defString );
+ }
+ else if ( !(extraStyle & wxCB_READONLY) && defString.length() )
+ cb->SetValue( defString );
+ else
+ cb->SetSelection( -1 );
+
+#ifdef __WXMSW__
+ cb->Show();
+#endif
+
+ return (wxWindow*) cb;
+}
+
+
+void wxPGChoiceEditor::UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const
+{
+ wxASSERT( ctrl );
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ wxASSERT( cb->IsKindOf(CLASSINFO(wxPGOwnerDrawnComboBox)));
+ int ind = property->GetChoiceInfo( (wxPGChoiceInfo*)NULL );
+ cb->SetSelection(ind);
+}
+
+wxPGWindowList wxPGChoiceEditor::CreateControls( wxPropertyGrid*
propGrid, wxPGProperty* property,
+ const wxPoint& pos, const wxSize& sz ) const
+{
+ return CreateControlsBase(propGrid,property,pos,sz,wxCB_READONLY);
+}
+
+
+int wxPGChoiceEditor::InsertItem( wxWindow* ctrl, const wxString&
label, int index ) const
+{
+ wxASSERT( ctrl );
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ wxASSERT( cb->IsKindOf(CLASSINFO(wxPGOwnerDrawnComboBox)));
+
+ if (index < 0)
+ index = cb->GetCount();
+
+ return cb->Insert(label,index);
+}
+
+
+void wxPGChoiceEditor::DeleteItem( wxWindow* ctrl, int index ) const
+{
+ wxASSERT( ctrl );
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ wxASSERT( cb->IsKindOf(CLASSINFO(wxPGOwnerDrawnComboBox)));
+
+ cb->Delete(index);
+}
+
+bool wxPGChoiceEditor::OnEvent( wxPropertyGrid* propGrid,
wxPGProperty* property,
+ wxWindow* ctrl, wxEvent& event ) const
+{
+ if ( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
+ {
+ wxPGComboBox* cb = (wxPGComboBox*)ctrl;
+ int index = cb->GetSelection();
+ int cmnValIndex = -1;
+ int cmnVals = property->GetDisplayedCommonValueCount();
+ int items = cb->GetCount();
+
+ if ( index >= (items-cmnVals) )
+ {
+ // Yes, a common value is being selected
+ cmnValIndex = index - (items-cmnVals);
+ property->SetCommonValue( cmnValIndex );
+
+ // Truly set value to unspecified?
+ if ( propGrid->GetUnspecifiedCommonValue() == cmnValIndex )
+ {
+ if ( !property->IsValueUnspecified() )
+ propGrid->SetInternalFlag(wxPG_FL_VALUE_CHANGE_IN_EVENT);
+ property->SetValueToUnspecified();
+ if ( !cb->HasFlag(wxCB_READONLY) )
+ cb->GetTextCtrl()->SetValue(wxEmptyString);
+ return false;
+ }
+ }
+ return wxPGChoiceEditor_SetCustomPaintWidth( propGrid, cb,
cmnValIndex );
+ }
+ return false;
+}
+
+
+bool wxPGChoiceEditor::GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+
+ int index = cb->GetSelection();
+
+ if ( index != property->GetChoiceInfo( (wxPGChoiceInfo*) NULL ) ||
+ // Changing unspecified always causes event (returning
+ // true here should be enough to trigger it).
+ property->IsValueUnspecified()
+ )
+ {
+ return property->ActualIntToValue( variant, index, 0 );
+ }
+ return false;
+}
+
+
+void wxPGChoiceEditor::SetControlStringValue( wxWindow* ctrl, const
wxString& txt ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ wxASSERT( cb );
+ cb->SetValue(txt);
+}
+
+
+void wxPGChoiceEditor::SetControlIntValue( wxWindow* ctrl, int value ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ wxASSERT( cb );
+ cb->SetSelection(value);
+}
+
+
+void wxPGChoiceEditor::SetValueToUnspecified( wxWindow* ctrl ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ cb->SetSelection(-1);
+}
+
+
+bool wxPGChoiceEditor::CanContainCustomImage() const
+{
+ return true;
+}
+
+
+wxPGChoiceEditor::~wxPGChoiceEditor() { }
+
+
+// -----------------------------------------------------------------------
+// wxPGComboBoxEditor
+// -----------------------------------------------------------------------
+
+
+WX_PG_IMPLEMENT_EDITOR_CLASS(ComboBox,wxPGComboBoxEditor,wxPGChoiceEditor)
+
+
+void wxPGComboBoxEditor::UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ cb->SetValue(property->GetValueString(wxPG_EDITABLE_VALUE));
+
+ // TODO: If string matches any selection, then select that.
+}
+
+
+wxPGWindowList wxPGComboBoxEditor::CreateControls( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ const wxPoint& pos,
+ const wxSize& sz ) const
+{
+ return CreateControlsBase(propGrid,property,pos,sz,0);
+}
+
+
+bool wxPGComboBoxEditor::OnEvent( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ wxEvent& event ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*) NULL;
+ wxWindow* textCtrl = (wxWindow*) NULL;
+
+ if ( ctrl )
+ {
+ cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ textCtrl = cb->GetTextCtrl();
+ }
+
+ if (
wxPGTextCtrlEditor::OnTextCtrlEvent(propGrid,property,textCtrl,event) )
+ return true;
+
+ return wxPGChoiceEditor::OnEvent(propGrid,property,ctrl,event);
+}
+
+
+bool wxPGComboBoxEditor::GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+
+ bool res = property->ActualStringToValue(variant, cb->GetValue(), 0);
+
+ // Changing unspecified always causes event (returning
+ // true here should be enough to trigger it).
+ if ( !res && property->IsValueUnspecified() )
+ res = true;
+
+ return res;
+}
+
+
+void wxPGComboBoxEditor::OnFocus( wxPGProperty*, wxWindow* ctrl ) const
+{
+ wxPGOwnerDrawnComboBox* cb = (wxPGOwnerDrawnComboBox*)ctrl;
+ cb->GetTextCtrl()->SetSelection(-1,-1);
+}
+
+
+wxPGComboBoxEditor::~wxPGComboBoxEditor() { }
+
+
+// -----------------------------------------------------------------------
+// wxPGChoiceAndButtonEditor
+// -----------------------------------------------------------------------
+
+
+// This simpler implement_editor macro doesn't define class body.
+WX_PG_IMPLEMENT_EDITOR_CLASS(ChoiceAndButton,wxPGChoiceAndButtonEditor,wxPGChoiceEditor)
+
+
+wxPGWindowList wxPGChoiceAndButtonEditor::CreateControls(
wxPropertyGrid* propGrid,
+
wxPGProperty* property,
+ const
wxPoint& pos,
+ const
wxSize& sz ) const
+{
+ // Use one two units smaller to match size of the combo's dropbutton.
+ // (normally a bigger button is used because it looks better)
+ int bt_wid = sz.y;
+ bt_wid -= 2;
+ wxSize bt_sz(bt_wid,bt_wid);
+
+ // Position of button.
+ wxPoint bt_pos(pos.x+sz.x-bt_sz.x,pos.y);
+#ifdef __WXMAC__
+ bt_pos.y -= 1;
+#else
+ bt_pos.y += 1;
+#endif
+
+ wxWindow* bt = propGrid->GenerateEditorButton( bt_pos, bt_sz );
+
+ // Size of choice.
+ wxSize ch_sz(sz.x-bt->GetSize().x,sz.y);
+
+#ifdef __WXMAC__
+ ch_sz.x -= wxPG_TEXTCTRL_AND_BUTTON_SPACING;
+#endif
+
+ wxWindow* ch = wxPG_EDITOR(Choice)->CreateControls(propGrid,property,
+ pos,ch_sz).m_primary;
+
+#ifdef __WXMSW__
+ bt->Show();
+#endif
+
+ return wxPGWindowList(ch, bt);
+}
+
+
+wxPGChoiceAndButtonEditor::~wxPGChoiceAndButtonEditor() { }
+
+
+// -----------------------------------------------------------------------
+// wxPGTextCtrlAndButtonEditor
+// -----------------------------------------------------------------------
+
+
+// This simpler implement_editor macro doesn't define class body.
+WX_PG_IMPLEMENT_EDITOR_CLASS(TextCtrlAndButton,wxPGTextCtrlAndButtonEditor,wxPGTextCtrlEditor)
+
+
+wxPGWindowList wxPGTextCtrlAndButtonEditor::CreateControls(
wxPropertyGrid* propGrid,
+
wxPGProperty* property,
+ const
wxPoint& pos,
+ const
wxSize& sz ) const
+{
+ wxWindow* wnd2;
+ wxWindow* wnd = propGrid->GenerateEditorTextCtrlAndButton( pos,
sz, &wnd2,
+ property->GetFlags() & wxPG_PROP_NOEDITOR, property);
+
+ return wxPGWindowList(wnd, wnd2);
+}
+
+
+wxPGTextCtrlAndButtonEditor::~wxPGTextCtrlAndButtonEditor() { }
+
+
+// -----------------------------------------------------------------------
+// wxPGCheckBoxEditor
+// -----------------------------------------------------------------------
+
+#if wxPG_INCLUDE_CHECKBOX
+
+WX_PG_IMPLEMENT_EDITOR_CLASS(CheckBox,wxPGCheckBoxEditor,wxPGEditor)
+
+
+// state argument: 0x01 = set if checked
+// 0x02 = set if rectangle should be bold
+static void DrawSimpleCheckBox( wxDC& dc, const wxRect& rect, int
box_hei, int state, const wxColour& linecol )
+{
+
+ // Box rectangle.
+ wxRect r(rect.x+wxPG_XBEFORETEXT,rect.y+((rect.height-box_hei)/2),box_hei,box_hei);
+
+ // Draw check mark first because it is likely to overdraw the
+ // surrounding rectangle.
+ if ( state & 1 )
+ {
+ wxRect r2(r.x+wxPG_CHECKMARK_XADJ,
+ r.y+wxPG_CHECKMARK_YADJ,
+ r.width+wxPG_CHECKMARK_WADJ,
+ r.height+wxPG_CHECKMARK_HADJ);
+ #if wxPG_CHECKMARK_DEFLATE
+ r2.Deflate(wxPG_CHECKMARK_DEFLATE);
+ #endif
+ dc.DrawCheckMark(r2);
+
+ // This would draw a simple cross check mark.
+ // dc.DrawLine(r.x,r.y,r.x+r.width-1,r.y+r.height-1);
+ // dc.DrawLine(r.x,r.y+r.height-1,r.x+r.width-1,r.y);
+
+ }
+
+ if ( !(state & 2) )
+ {
+ // Pen for thin rectangle.
+ dc.SetPen(linecol);
+ }
+ else
+ {
+ // Pen for bold rectangle.
+ wxPen linepen(linecol,2,wxSOLID);
+ linepen.SetJoin(wxJOIN_MITER); // This prevents round edges.
+ dc.SetPen(linepen);
+ r.x++;
+ r.y++;
+ r.width--;
+ r.height--;
+ }
+
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+
+ dc.DrawRectangle(r);
+ dc.SetPen(*wxTRANSPARENT_PEN);
+}
+
+//
+// Real simple custom-drawn checkbox-without-label class.
+//
+class wxSimpleCheckBox : public wxControl
+{
+public:
+
+ void SetValue( int value );
+
+ wxSimpleCheckBox( wxWindow* parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize )
+ : wxControl(parent,id,pos,size,wxNO_BORDER|wxWANTS_CHARS)
+ {
+ // Due to SetOwnFont stuff necessary for GTK+ 1.2, we need to
have this
+ SetFont( parent->GetFont() );
+
+ m_state = 0;
+ wxPropertyGrid* pg = (wxPropertyGrid*) parent->GetParent();
+ wxASSERT( pg->IsKindOf(CLASSINFO(wxPropertyGrid)) );
+ m_boxHeight = pg->GetFontHeight();
+ SetBackgroundStyle( wxBG_STYLE_COLOUR );
+ }
+
+ virtual ~wxSimpleCheckBox();
+
+ virtual bool ProcessEvent(wxEvent& event);
+
+ int m_state;
+ int m_boxHeight;
+
+ static wxBitmap* ms_doubleBuffer;
+
+};
+
+wxSimpleCheckBox::~wxSimpleCheckBox()
+{
+ delete ms_doubleBuffer;
+ ms_doubleBuffer = NULL;
+}
+
+
+wxBitmap* wxSimpleCheckBox::ms_doubleBuffer = (wxBitmap*) NULL;
+
+// value = 2 means toggle (sorry, too lazy to do constants)
+void wxSimpleCheckBox::SetValue( int value )
+{
+ if ( value > 1 )
+ {
+ m_state++;
+ if ( m_state > 1 ) m_state = 0;
+ }
+ else
+ {
+ m_state = value;
+ }
+ Refresh();
+
+ wxCommandEvent evt(wxEVT_COMMAND_CHECKBOX_CLICKED,GetParent()->GetId());
+
+ wxPropertyGrid* propGrid = (wxPropertyGrid*) GetParent()->GetParent();
+ wxASSERT( propGrid->IsKindOf(CLASSINFO(wxPropertyGrid)) );
+ propGrid->OnCustomEditorEvent(evt);
+}
+
+
+bool wxSimpleCheckBox::ProcessEvent(wxEvent& event)
+{
+ wxPropertyGrid* propGrid = (wxPropertyGrid*) GetParent()->GetParent();
+ wxASSERT( propGrid->IsKindOf(CLASSINFO(wxPropertyGrid)) );
+
+ if ( event.GetEventType() == wxEVT_NAVIGATION_KEY )
+ {
+ //wxLogDebug(wxT("wxEVT_NAVIGATION_KEY"));
+ //SetFocusFromKbd();
+ //event.Skip();
+ //return wxControl::ProcessEvent(event);
+ }
+ else
+ if ( ( (event.GetEventType() == wxEVT_LEFT_DOWN ||
event.GetEventType() == wxEVT_LEFT_DCLICK)
+ && ((wxMouseEvent&)event).m_x > (wxPG_XBEFORETEXT-2)
+ && ((wxMouseEvent&)event).m_x <=
(wxPG_XBEFORETEXT-2+m_boxHeight) )
+ )
+ {
+ SetValue(2);
+ return true;
+ }
+ else if ( event.GetEventType() == wxEVT_PAINT )
+ {
+ wxSize clientSize = GetClientSize();
+ wxPaintDC dc(this);
+
+ /*
+ // Buffered paint DC doesn't seem to do much good
+ if ( !ms_doubleBuffer ||
+ clientSize.x > ms_doubleBuffer->GetWidth() ||
+ clientSize.y > ms_doubleBuffer->GetHeight() )
+ {
+ delete ms_doubleBuffer;
+ ms_doubleBuffer = new wxBitmap(clientSize.x+25,clientSize.y+25);
+ }
+
+ wxBufferedPaintDC dc(this,*ms_doubleBuffer);
+ */
+
+ wxRect rect(0,0,clientSize.x,clientSize.y);
+ //rect.x -= 1;
+ rect.y += 1;
+ rect.width += 1;
+
+ m_boxHeight = propGrid->GetFontHeight();
+
+ wxColour bgcol = GetBackgroundColour();
+ dc.SetBrush( bgcol );
+ dc.SetPen( bgcol );
+ dc.DrawRectangle( rect );
+
+ wxColour txcol = GetForegroundColour();
+
+ int state = m_state;
+ if ( m_font.GetWeight() == wxBOLD )
+ state |= 2;
+
+ DrawSimpleCheckBox(dc,rect,m_boxHeight,state,txcol);
+
+ // If focused, indicate it somehow.
+ /*
+ if ( wxWindow::FindFocus() == this )
+ {
+ rect.x += 1;
+ rect.width -= 1;
+
+ wxPGDrawFocusRect(dc,rect);
+ }
+ */
+
+ return true;
+ }
+ else if ( event.GetEventType() == wxEVT_SIZE ||
+ event.GetEventType() == wxEVT_SET_FOCUS ||
+ event.GetEventType() == wxEVT_KILL_FOCUS
+ )
+ {
+ Refresh();
+ }
+ else if ( event.GetEventType() == wxEVT_KEY_DOWN )
+ {
+ wxKeyEvent& keyEv = (wxKeyEvent&) event;
+
+ if ( keyEv.GetKeyCode() == WXK_TAB )
+ {
+ propGrid->SendNavigationKeyEvent( keyEv.ShiftDown()?0:1 );
+ return true;
+ }
+ else
+ if ( keyEv.GetKeyCode() == WXK_SPACE )
+ {
+ SetValue(2);
+ return true;
+ }
+ }
+ return wxControl::ProcessEvent(event);
+}
+
+
+wxPGWindowList wxPGCheckBoxEditor::CreateControls( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ const wxPoint& pos,
+ const wxSize& size
) const
+{
+ wxPoint pt = pos;
+ pt.x -= wxPG_XBEFOREWIDGET;
+ wxSize sz = size;
+ sz.x = propGrid->GetFontHeight() + (wxPG_XBEFOREWIDGET*2) + 4;
+
+ wxSimpleCheckBox* cb = new wxSimpleCheckBox(propGrid->GetPanel(),wxPG_SUBID1,pt,sz);
+
+ cb->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
+
+ cb->Connect( wxPG_SUBID1, wxEVT_LEFT_DOWN,
+ (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
+ &wxPropertyGrid::OnCustomEditorEvent, NULL, propGrid );
+
+ cb->Connect( wxPG_SUBID1, wxEVT_LEFT_DCLICK,
+ (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
+ &wxPropertyGrid::OnCustomEditorEvent, NULL, propGrid );
+
+ if ( property->GetChoiceInfo((wxPGChoiceInfo*)NULL) &&
+ !property->IsValueUnspecified() )
+ cb->m_state = 1;
+
+ // If mouse cursor was on the item, toggle the value now.
+ if ( propGrid->GetInternalFlags() & wxPG_FL_ACTIVATION_BY_CLICK )
+ {
+ wxPoint pt = cb->ScreenToClient(::wxGetMousePosition());
+ if ( pt.x <= (wxPG_XBEFORETEXT-2+cb->m_boxHeight) )
+ {
+ cb->m_state++;
+
+ if ( cb->m_state > 1 )
+ cb->m_state = 0;
+
+ property->SetValueFromInt(cb->m_state,0);
+ propGrid->EditorsValueWasModified();
+ propGrid->DoPropertyChanged(property, NULL, 0);
+ }
+ }
+
+ propGrid->SetInternalFlag( wxPG_FL_FIXED_WIDTH_EDITOR );
+
+ return cb;
+}
+
+/*
+class wxPGCheckBoxRenderer : public wxPGDefaultRenderer
+{
+public:
+
+ virtual void Render( wxDC& dc, const wxRect& rect,
+ const wxPropertyGrid* WXUNUSED(propertyGrid),
wxPGProperty* property,
+ int WXUNUSED(column), int WXUNUSED(item), int
WXUNUSED(flags) ) const
+ {
+ int state = 0;
+ if ( !(property->GetFlags() & wxPG_PROP_UNSPECIFIED) )
+ {
+ state = ((wxPGProperty*)property)->GetChoiceInfo((wxPGChoiceInfo*)NULL);
+ if ( dc.GetFont().GetWeight() == wxBOLD ) state |= 2;
+ }
+ DrawSimpleCheckBox(dc,rect,dc.GetCharHeight(),state,dc.GetTextForeground());
+ }
+
+protected:
+};
+
+wxPGCheckBoxRenderer g_wxPGCheckBoxRenderer;
+
+wxPGCellRenderer* wxPGCheckBoxEditor::GetCellRenderer() const
+{
+ return &g_wxPGCheckBoxRenderer;
+}
+*/
+
+void wxPGCheckBoxEditor::DrawValue( wxDC& dc, const wxRect& rect,
wxPGProperty* property, const wxString& WXUNUSED(text) ) const
+{
+ int state = 0;
+ if ( !property->IsValueUnspecified() )
+ {
+ state = property->GetChoiceInfo((wxPGChoiceInfo*)NULL);
+ if ( dc.GetFont().GetWeight() == wxBOLD ) state |= 2;
+ }
+ DrawSimpleCheckBox(dc,rect,dc.GetCharHeight(),state,dc.GetTextForeground());
+}
+
+void wxPGCheckBoxEditor::UpdateControl( wxPGProperty* property,
wxWindow* ctrl ) const
+{
+ wxASSERT( ctrl );
+ ((wxSimpleCheckBox*)ctrl)->m_state = property->GetChoiceInfo((wxPGChoiceInfo*)NULL);
+ ctrl->Refresh();
+}
+
+
+bool wxPGCheckBoxEditor::OnEvent( wxPropertyGrid* WXUNUSED(propGrid),
wxPGProperty* WXUNUSED(property),
+ wxWindow* WXUNUSED(ctrl), wxEvent& event ) const
+{
+ if ( event.GetEventType() == wxEVT_COMMAND_CHECKBOX_CLICKED )
+ {
+ return true;
+ }
+ return false;
+}
+
+
+bool wxPGCheckBoxEditor::GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl ) const
+{
+ wxSimpleCheckBox* cb = (wxSimpleCheckBox*)ctrl;
+
+ int index = cb->m_state;
+
+ if ( index != property->GetChoiceInfo( (wxPGChoiceInfo*) NULL ) ||
+ // Changing unspecified always causes event (returning
+ // true here should be enough to trigger it).
+ property->IsValueUnspecified()
+ )
+ {
+ return property->ActualIntToValue(variant, index, 0);
+ }
+ return false;
+}
+
+
+void wxPGCheckBoxEditor::SetControlIntValue( wxWindow* ctrl, int value
) const
+{
+ if ( value != 0 ) value = 1;
+ ((wxSimpleCheckBox*)ctrl)->m_state = value;
+ ctrl->Refresh();
+}
+
+
+void wxPGCheckBoxEditor::SetValueToUnspecified( wxWindow* ctrl ) const
+{
+ ((wxSimpleCheckBox*)ctrl)->m_state = 0;
+ ctrl->Refresh();
+}
+
+
+wxPGCheckBoxEditor::~wxPGCheckBoxEditor() { }
+
+
+#endif // wxPG_INCLUDE_CHECKBOX
+
+// -----------------------------------------------------------------------
+
+wxWindow* wxPropertyGrid::GetEditorControl() const
+{
+ wxWindow* ctrl = m_wndPrimary;
+
+ if ( !ctrl )
+ return ctrl;
+
+ // If it's clipper window, return its child instead
+#if wxPG_ENABLE_CLIPPER_WINDOW
+ if ( ctrl->IsKindOf(CLASSINFO(wxPGClipperWindow)) )
+ {
+ return ((wxPGClipperWindow*)ctrl)->GetControl();
+ }
+#endif
+
+ return ctrl;
+}
+
+// -----------------------------------------------------------------------
+
+void wxPropertyGrid::CorrectEditorWidgetSizeX()
+{
+ if ( m_selColumn == -1 )
+ return;
+
+ int secWid = 0;
+ int newSplitterx = m_pState->GetSplitterPosition(m_selColumn-1);
+ int newWidth = newSplitterx + m_pState->m_colWidths[m_selColumn];
+
+ if ( m_wndSecondary )
+ {
+ // if width change occurred, move secondary wnd by that amount
+ wxRect r = m_wndSecondary->GetRect();
+ secWid = r.width;
+ r.x = newWidth - secWid;
+
+ m_wndSecondary->SetSize( r );
+
+ // if primary is textctrl, then we have to add some extra space
+#ifdef __WXMAC__
+ if ( m_wndPrimary )
+#else
+ if ( m_wndPrimary &&
m_wndPrimary->IsKindOf(CLASSINFO(wxTextCtrl)) )
+#endif
+ secWid += wxPG_TEXTCTRL_AND_BUTTON_SPACING;
+ }
+
+ if ( m_wndPrimary )
+ {
+ wxRect r = m_wndPrimary->GetRect();
+
+ r.x = newSplitterx+m_ctrlXAdjust;
+
+ if ( !(m_iFlags & wxPG_FL_FIXED_WIDTH_EDITOR) )
+ r.width = newWidth - r.x - secWid;
+
+ m_wndPrimary->SetSize(r);
+ }
+
+ if ( m_wndSecondary )
+ m_wndSecondary->Refresh();
+}
+
+// -----------------------------------------------------------------------
+
+void wxPropertyGrid::CorrectEditorWidgetPosY( wxPGProperty*
isBelowThis, int heightAdd )
+{
+ if ( !m_selected )
+ return;
+
+ int propY = m_lineHeight - 3; // Have some space since usually
propy != ctrly
+ if ( isBelowThis )
+ propY += isBelowThis->GetY2(m_lineHeight);
+
+ if ( m_wndPrimary )
+ {
+ wxPoint pos = m_wndPrimary->GetPosition();
+
+ if ( pos.y > propY )
+ m_wndPrimary->Move(pos.x, pos.y+heightAdd);
+ }
+
+ if ( m_wndSecondary )
+ {
+ wxPoint pos = m_wndSecondary->GetPosition();
+
+ if ( pos.y > propY )
+ m_wndSecondary->Move(pos.x, pos.y+heightAdd);
+ }
+}
+
+// -----------------------------------------------------------------------
+
+bool wxPropertyGrid::AdjustPosForClipperWindow( wxWindow* topCtrlWnd,
int* x, int* y )
+{
+#if wxPG_ENABLE_CLIPPER_WINDOW
+ // Take clipper window into account
+ if (topCtrlWnd->GetPosition().x < 1 &&
+ !topCtrlWnd->IsKindOf(CLASSINFO(wxPGClipperWindow)))
+ {
+ topCtrlWnd = topCtrlWnd->GetParent();
+ wxASSERT( topCtrlWnd->IsKindOf(CLASSINFO(wxPGClipperWindow)) );
+ *x -= ((wxPGClipperWindow*)topCtrlWnd)->GetXClip();
+ *y -= ((wxPGClipperWindow*)topCtrlWnd)->GetYClip();
+ return true;
+ }
+#else
+ wxUnusedVar(topCtrlWnd);
+ wxUnusedVar(x);
+ wxUnusedVar(y);
+#endif
+ return false;
+}
+
+// -----------------------------------------------------------------------
+
+// Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
+// fits into that category as well).
+void wxPropertyGrid::FixPosForTextCtrl( wxWindow* ctrl, const wxPoint&
offset )
+{
+ // Center the control vertically
+ wxRect finalPos = ctrl->GetRect();
+ int y_adj = (m_lineHeight - finalPos.height)/2 + wxPG_TEXTCTRLYADJUST;
+
+ // Prevent over-sized control
+ int sz_dec = (y_adj + finalPos.height) - m_lineHeight;
+ if ( sz_dec < 0 ) sz_dec = 0;
+
+ finalPos.y += y_adj;
+ finalPos.height -= (y_adj+sz_dec);
+
+ const int textCtrlXAdjust = wxPG_TEXTCTRLXADJUST;
+
+ finalPos.x += textCtrlXAdjust;
+ finalPos.width -= textCtrlXAdjust;
+
+ finalPos.x += offset.x;
+ finalPos.y += offset.y;
+
+ ctrl->SetSize(finalPos);
+}
+
+// -----------------------------------------------------------------------
+
+wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
+ const wxSize& sz,
+ const wxString& value,
+ wxWindow* secondary,
+ int extraStyle,
+ int maxLen )
+{
+ wxPGProperty* selected = m_selected;
+ wxASSERT(selected);
+
+ int tcFlags = wxTE_PROCESS_ENTER | extraStyle;
+
+ if ( selected->HasFlag(wxPG_PROP_READONLY) )
+ tcFlags |= wxTE_READONLY;
+
+ wxPoint p(pos.x,pos.y);
+ wxSize s(sz.x,sz.y);
+
+ // Need to reduce width of text control on Mac
+#if defined(__WXMAC__)
+ s.x -= 8;
+#endif
+
+ // Take button into acccount
+ if ( secondary )
+ {
+ s.x -= (secondary->GetSize().x + wxPG_TEXTCTRL_AND_BUTTON_SPACING);
+ m_iFlags &= ~(wxPG_FL_PRIMARY_FILLS_ENTIRE);
+ }
+
+ // If the height is significantly higher, then use border, and
fill the rect exactly.
+ bool hasSpecialSize = false;
+
+ if ( (sz.y - m_lineHeight) > 5 )
+ hasSpecialSize = true;
+
+#if wxPG_NAT_TEXTCTRL_BORDER_ANY
+
+ // Create clipper window
+ wxPGClipperWindow* wnd = new wxPGClipperWindow();
+#if defined(__WXMSW__)
+ wnd->Hide();
+#endif
+ wnd->Create(GetPanel(),wxPG_SUBID1,p,s);
+
+ // This generates rect of the control inside the clipper window
+ if ( !hasSpecialSize )
+ wnd->GetControlRect(wxPG_NAT_TEXTCTRL_BORDER_X,
wxPG_NAT_TEXTCTRL_BORDER_Y, p, s);
+ else
+ wnd->GetControlRect(0, 0, p, s);
+
+ wxWindow* ctrlParent = wnd;
+
+#else
+
+ wxWindow* ctrlParent = GetPanel();
+
+ if ( !hasSpecialSize )
+ tcFlags |= wxNO_BORDER;
+
+#endif
+
+ wxTextCtrl* tc = new wxTextCtrl();
+
+#if defined(__WXMSW__) && !wxPG_NAT_TEXTCTRL_BORDER_ANY
+ tc->Hide();
+#endif
+ tc->Create(ctrlParent,wxPG_SUBID1,value, p, s,tcFlags);
+
+#if wxPG_NAT_TEXTCTRL_BORDER_ANY
+ wxWindow* ed = wnd;
+ wnd->SetControl(tc);
+#else
+ wxWindow* ed = tc;
+#endif
+
+ // Center the control vertically
+ if ( !hasSpecialSize )
+ FixPosForTextCtrl(ed);
+
+#ifdef __WXMSW__
+ ed->Show();
+ if ( secondary )
+ secondary->Show();
+#endif
+
+ // Set maximum length
+ if ( maxLen > 0 )
+ tc->SetMaxLength( maxLen );
+
+ return (wxWindow*) ed;
+}
+
+// -----------------------------------------------------------------------
+
+wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos,
const wxSize& sz )
+{
+ wxPGProperty* selected = m_selected;
+ wxASSERT(selected);
+
+#ifdef __WXMAC__
+ // Decorations are chunky on Mac, and we can't make the button
square, so
+ // do things a bit differently on this platform.
+
+ wxPoint p(pos.x+sz.x,
+ pos.y+wxPG_BUTTON_SIZEDEC-wxPG_NAT_BUTTON_BORDER_Y);
+ wxSize s(25, -1);
+
+ wxButton* but = new wxButton();
+ but->Create(GetPanel(),wxPG_SUBID2,wxT("..."),p,s,wxWANTS_CHARS);
+
+ // Now that we know the size, move to the correct position
+ p.x = pos.x + sz.x - but->GetSize().x - 2;
+ but->Move(p);
+
+#else
+ wxSize s(sz.y-(wxPG_BUTTON_SIZEDEC*2)+(wxPG_NAT_BUTTON_BORDER_Y*2),
+ sz.y-(wxPG_BUTTON_SIZEDEC*2)+(wxPG_NAT_BUTTON_BORDER_Y*2));
+
+ // Reduce button width to lineheight
+ if ( s.x > m_lineHeight )
+ s.x = m_lineHeight;
+
+ wxPoint p(pos.x+sz.x-s.x,
+ pos.y+wxPG_BUTTON_SIZEDEC-wxPG_NAT_BUTTON_BORDER_Y);
+
+ wxButton* but = new wxButton();
+#ifdef __WXMSW__
+ but->Hide();
+#endif
+ but->Create(GetPanel(),wxPG_SUBID2,wxT("..."),p,s,wxWANTS_CHARS);
+
+ but->SetFont( m_captionFont );
+#endif
+
+ if ( selected->HasFlag(wxPG_PROP_READONLY) )
+ but->Disable();
+
+ return but;
+}
+
+// -----------------------------------------------------------------------
+
+wxWindow* wxPropertyGrid::GenerateEditorTextCtrlAndButton( const
wxPoint& pos,
+ const
wxSize& sz,
+ wxWindow** psecondary,
+ int limitedEditing,
+
wxPGProperty* property )
+{
+ wxButton* but = (wxButton*)GenerateEditorButton(pos,sz);
+ *psecondary = (wxWindow*)but;
+
+ if ( limitedEditing )
+ {
+ #ifdef __WXMSW__
+ // There is button Show in GenerateEditorTextCtrl as well
+ but->Show();
+ #endif
+ return (wxWindow*) NULL;
+ }
+
+ wxString text;
+
+ if ( !property->IsValueUnspecified() )
+ text = property->GetValueString(property->HasFlag(wxPG_PROP_READONLY)?0:wxPG_EDITABLE_VALUE);
+
+ return GenerateEditorTextCtrl(pos,sz,text,but,property->m_maxLen);
+}
+
+// -----------------------------------------------------------------------
+// wxPGEditorDialogAdapter
+// -----------------------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxPGEditorDialogAdapter, wxObject)
+
+bool wxPGEditorDialogAdapter::ShowDialog( wxPropertyGrid* propGrid,
wxPGProperty* property )
+{
+ if ( !propGrid->EditorValidate() )
+ return false;
+
+ bool res = DoShowDialog( propGrid, property );
+
+ if ( res )
+ {
+ propGrid->ValueChangeInEvent( m_value );
+ return true;
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------
+// wxPGMultiButton
+// -----------------------------------------------------------------------
+
+wxPGMultiButton::wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz )
+ : wxWindow( pg->GetPanel(), wxPG_SUBID2, wxPoint(-100,-100),
wxSize(0, sz.y) ),
+ m_fullEditorSize(sz), m_buttonsWidth(0)
+{
+ SetBackgroundColour(pg->GetCellBackgroundColour());
+}
+
+int wxPGMultiButton::GenId( int id ) const
+{
+ if ( id < -1 )
+ {
+ if ( m_buttons.size() )
+ id = GetButton(m_buttons.size()-1)->GetId() + 1;
+ else
+ id = wxPG_SUBID2;
+ }
+ return id;
+}
+
+#if wxUSE_BMPBUTTON
+void wxPGMultiButton::Add( const wxBitmap& bitmap, int id )
+{
+ id = GenId(id);
+ wxSize sz = GetSize();
+ wxButton* button = new wxBitmapButton( this, id, bitmap,
wxPoint(sz.x, 0), wxSize(sz.y, sz.y) );
+ m_buttons.push_back(button);
+ int bw = button->GetSize().x;
+ SetSize(wxSize(sz.x+bw,sz.y));
+ m_buttonsWidth += bw;
+}
+#endif
+
+void wxPGMultiButton::Add( const wxString& label, int id )
+{
+ id = GenId(id);
+ wxSize sz = GetSize();
+ wxButton* button = new wxButton( this, id, label, wxPoint(sz.x,
0), wxSize(sz.y, sz.y) );
+ m_buttons.push_back(button);
+ int bw = button->GetSize().x;
+ SetSize(wxSize(sz.x+bw,sz.y));
+ m_buttonsWidth += bw;
+}
+
+// -----------------------------------------------------------------------

Added: trunk/wx.mod/wxpropgrid.mod/src/extras.cpp
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/extras.cpp Sat Dec 15 08:55:59 2007
@@ -0,0 +1,23 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: extras.cpp
+// Purpose: wxPropertyGrid Extras
+// Author: Jaakko Salli
+// Modified by:
+// Created: Mar-05-2006
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+//
+// In wxPython version this file will have additional property and
+// editor control source code.
+//
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+

Added: trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/advprops.h
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/advprops.h Sat
Dec 15 08:55:59 2007
@@ -0,0 +1,390 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: advprops.h
+// Purpose: wxPropertyGrid Advanced Properties (font, colour, etc.)
+// Author: Jaakko Salli
+// Modified by:
+// Created: Sep-25-2004
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_PROPGRID_ADVPROPS_H_
+#define _WX_PROPGRID_ADVPROPS_H_
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+ #pragma interface "advprops.cpp"
+#endif
+
+#ifndef wxPG_INCLUDE_ADVPROPS
+ #error "Include propgrid.h"
+#endif
+
+#include "props.h"
+
+// -----------------------------------------------------------------------
+
+
+//
+// Additional Value Type Handlers
+//
+#ifndef SWIG
+bool WXDLLIMPEXP_PG operator == (const wxFont&, const wxFont&);
+
+bool WXDLLIMPEXP_PG operator == (const wxArrayInt& array1, const
wxArrayInt& array2);
+#endif
+
+
+//
+// Additional Property Editors
+//
+#if wxUSE_SPINBTN
+WX_PG_DECLARE_EDITOR_WITH_DECL(SpinCtrl,WXDLLIMPEXP_PG)
+#endif
+
+#if wxUSE_DATEPICKCTRL
+WX_PG_DECLARE_EDITOR_WITH_DECL(DatePickerCtrl,WXDLLIMPEXP_PG)
+#endif
+
+// -----------------------------------------------------------------------
+
+
+// Web colour is currently unsupported
+#define wxPG_COLOUR_WEB_BASE 0x10000
+//#define wxPG_TO_WEB_COLOUR(A) ((wxUint32)(A+wxPG_COLOUR_WEB_BASE))
+
+
+#define wxPG_COLOUR_CUSTOM 0xFFFFFF
+#define wxPG_COLOUR_UNSPECIFIED (wxPG_COLOUR_CUSTOM+1)
+
+/** \class wxColourPropertyValue
+ \ingroup classes
+ \brief Because text, background and other colours tend to differ between
+ platforms, wxSystemColourProperty must be able to select between system
+ colour and, when necessary, to pick a custom one. wxSystemColourProperty
+ value makes this possible.
+*/
+class WXDLLIMPEXP_PG wxColourPropertyValue : public wxObject
+{
+public:
+ /** An integer value relating to the colour, and which exact
+ meaning depends on the property with which it is used.
+
+ For wxSystemColourProperty:
+
+ Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR
+ macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM.
+
+ For custom colour properties without values array specified:
+
+ index or wxPG_COLOUR_CUSTOM
+
+ For custom colour properties <b>with</b> values array specified:
+
+ m_arrValues[index] or wxPG_COLOUR_CUSTOM
+ */
+ wxUint32 m_type;
+
+ /** Resulting colour. Should be correct regardless of type. */
+ wxColour m_colour;
+
+ wxColourPropertyValue() { }
+
+ wxColourPropertyValue( const wxColourPropertyValue& v )
+ {
+ m_type = v.m_type;
+ m_colour = v.m_colour;
+ }
+
+ inline void Init( wxUint32 type, const wxColour& colour )
+ {
+ m_type = type;
+ m_colour = colour;
+ }
+
+ inline wxColourPropertyValue( const wxColour& colour )
+ {
+ m_type = wxPG_COLOUR_CUSTOM;
+ m_colour = colour;
+ }
+
+ inline wxColourPropertyValue( wxUint32 type )
+ {
+ m_type = type;
+ }
+
+ inline wxColourPropertyValue( wxUint32 type, const wxColour&
colour )
+ {
+ Init( type, colour );
+ }
+
+#ifndef SWIG
+
+ void operator= (const wxColourPropertyValue& cpv)
+ {
+ Init( cpv.m_type, cpv.m_colour );
+ }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxColourPropertyValue)
+#endif
+};
+
+
+#ifndef SWIG
+bool WXDLLIMPEXP_PG operator == (const wxColourPropertyValue&, const wxColourPropertyValue&);
+
+WX_PG_DECLARE_WXOBJECT_VARIANT_DATA(wxPGVariantDataColourPropertyValue,
wxColourPropertyValue, WXDLLIMPEXP_PG)
+#endif
+
+#ifndef SWIG
+ #define wxPG_EMPTY_CPV (*((wxColourPropertyValue*)NULL))
+ #define wxPG_NORMAL_FONT (*wxNORMAL_FONT)
+#else
+ #define wxPG_EMPTY_CPV wxCPV_wxPG_EMPTY
+ #define wxPG_NORMAL_FONT wxFONT_wxPG_NORMAL_FONT
+#endif
+
+
+// -----------------------------------------------------------------------
+// Declare part of custom colour property macro pairs.
+
+#if wxUSE_IMAGE || defined(SWIG)
+ #include <wx/image.h>
+#endif
+
+// -----------------------------------------------------------------------
+
+class WXDLLIMPEXP_PG wxFontProperty : public wxPGPropertyWithChildren
+{
+ WX_PG_DECLARE_PROPERTY_CLASS(wxFontProperty)
+public:
+
+ wxFontProperty( const wxString& label = wxPG_LABEL, const
wxString& name = wxPG_LABEL, const wxFont& value = wxFont() );
+ virtual ~wxFontProperty();
+ virtual bool ValidateValue( wxVariant& value ) const;
+ virtual wxString GetValueAsString( int argFlags = 0 ) const;
+
+ WX_PG_DECLARE_EVENT_METHODS()
+ WX_PG_DECLARE_PARENTAL_METHODS()
+ //WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
+
+protected:
+};
+
+// -----------------------------------------------------------------------
+
+
+/** If set, then match from list is searched for a custom colour. */
+#define wxPG_PROP_TRANSLATE_CUSTOM wxPG_PROP_CLASS_SPECIFIC_1
+
+
+class WXDLLIMPEXP_PG wxSystemColourProperty : public wxEnumProperty
+{
+ WX_PG_DECLARE_PROPERTY_CLASS(wxSystemColourProperty)
+public:
+
+ wxSystemColourProperty( const wxString& label = wxPG_LABEL,
+ const wxString& name = wxPG_LABEL,
+ const wxColourPropertyValue& value =
wxColourPropertyValue() );
+ ~wxSystemColourProperty();
+
+ virtual bool ValidateValue( wxVariant& value ) const;
+ virtual void OnSetValue();
+ virtual bool IntToValue( wxVariant& variant, int number, int
argFlags = 0 ) const;
+
+ WX_PG_DECLARE_BASIC_TYPE_METHODS()
+ WX_PG_DECLARE_EVENT_METHODS()
+ WX_PG_DECLARE_ATTRIBUTE_METHODS()
+
+ WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
+ //virtual wxSize GetImageSize( int item ) const;
+ //virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
+
+ // Helper function to show the colour dialog
+ bool QueryColourFromUser( wxVariant& variant ) const;
+
+ // Default is to use wxSystemSettings::GetColour(index). Override
to use
+ // custom colour tables etc.
+ virtual long GetColour( int index ) const;
+
+ wxColourPropertyValue GetVal( const wxVariant* pVariant = NULL ) const;
+
+protected:
+
+ // Special constructors to be used by derived classes.
+ wxSystemColourProperty( const wxString& label, const wxString& name,
+ const wxChar** labels, const long* values, wxPGChoices* choicesCache,
+ const wxColourPropertyValue& value );
+ wxSystemColourProperty( const wxString& label, const wxString& name,
+ const wxChar** labels, const long* values, wxPGChoices* choicesCache,
+ const wxColour& value );
+
+ void Init( int type, const wxColour& colour );
+
+ // Utility functions for internal use
+ virtual wxVariant DoTranslateVal( wxColourPropertyValue& v ) const;
+ wxVariant TranslateVal( wxColourPropertyValue& v ) const
+ {
+ return DoTranslateVal( v );
+ }
+ wxVariant TranslateVal( int type, const wxColour& colour ) const
+ {
+ wxColourPropertyValue v(type, colour);
+ return DoTranslateVal( v );
+ }
+
+ // Translates colour to a int value, return wxNOT_FOUND if no match.
+ int ColToInd( const wxColour& colour ) const;
+};
+
+// -----------------------------------------------------------------------
+
+WX_PG_DECLARE_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR_WITH_DECL(wxColourProperty,
class WXDLLIMPEXP_PG)
+
+// -----------------------------------------------------------------------
+
+class WXDLLIMPEXP_PG wxCursorProperty : public wxEnumProperty
+{
+ DECLARE_DYNAMIC_CLASS(wxCursorProperty)
+
+ wxCursorProperty( const wxString& label= wxPG_LABEL,
+ const wxString& name= wxPG_LABEL,
+ int value = 0 );
+ virtual ~wxCursorProperty();
+
+ WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
+ //virtual wxSize GetImageSize( int item ) const;
+ //virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
+};
+
+// -----------------------------------------------------------------------
+
+#if wxUSE_IMAGE
+
+WXDLLIMPEXP_PG const wxString& wxPGGetDefaultImageWildcard();
+
+class WXDLLIMPEXP_PG wxImageFileProperty : public wxFileProperty
+{
+ DECLARE_DYNAMIC_CLASS(wxImageFileProperty)
+public:
+
+ wxImageFileProperty( const wxString& label= wxPG_LABEL,
+ const wxString& name = wxPG_LABEL,
+ const wxString& value = wxEmptyString);
+ virtual ~wxImageFileProperty();
+
+ virtual void OnSetValue();
+
+ WX_PG_DECLARE_CUSTOM_PAINT_METHODS()
+
+protected:
+ wxBitmap* m_pBitmap; // final thumbnail area
+ wxImage* m_pImage; // intermediate thumbnail area
+};
+
+#endif
+
+#if wxUSE_CHOICEDLG || defined(SWIG)
+
+class WXDLLIMPEXP_PG wxMultiChoiceProperty : public wxPGProperty
+{
+ WX_PG_DECLARE_PROPERTY_CLASS(wxMultiChoiceProperty)
+public:
+
+ wxMultiChoiceProperty( const wxString& label,
+ const wxString& name,
+ const wxArrayString& strings,
+ const wxArrayInt& value );
+#ifndef SWIG
+ wxMultiChoiceProperty( const wxString& label = wxPG_LABEL,
+ const wxString& name = wxPG_LABEL,
+ const wxArrayInt& value = wxArrayInt() );
+ wxMultiChoiceProperty( const wxString& label,
+ const wxString& name,
+ const wxPGChoices& choices,
+ const wxArrayInt& value = wxArrayInt() );
+#endif
+ virtual ~wxMultiChoiceProperty();
+
+ virtual void OnSetValue();
+ virtual wxString GetValueAsString( int flags = 0 ) const;
+ virtual bool StringToValue( wxVariant& variant, const wxString&
text, int argFlags = 0 ) const;
+ WX_PG_DECLARE_EVENT_METHODS()
+
+ virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
+
+protected:
+
+ void SetValueI( const wxArrayInt& arr ); // I stands for internal
+ void GenerateValueAsString();
+
+ // Returns translation of values into string indices.
+ wxArrayInt GetValueAsIndices() const;
+
+ wxPGChoices m_choices; // Holds strings (any values given
are ignored).
+
+ wxString m_display; // Cache displayed text since
generating it is relatively complicated.
+};
+
+#endif // wxUSE_CHOICEDLG
+
+// -----------------------------------------------------------------------
+
+#if wxUSE_DATETIME || defined(SWIG)
+
+class WXDLLIMPEXP_PG wxDateProperty : public wxPGProperty
+{
+ WX_PG_DECLARE_PROPERTY_CLASS(wxDateProperty)
+public:
+
+ wxDateProperty( const wxString& label = wxPG_LABEL,
+ const wxString& name = wxPG_LABEL,
+ const wxDateTime& value = wxDateTime() );
+ virtual ~wxDateProperty();
+
+ virtual wxString GetValueAsString( int flags = 0 ) const;
+ virtual bool StringToValue( wxVariant& variant, const wxString&
text, int argFlags = 0 ) const;
+
+ WX_PG_DECLARE_ATTRIBUTE_METHODS()
+
+ inline void SetFormat( const wxString& format )
+ {
+ m_format = format;
+ }
+
+ inline const wxString& GetFormat() const
+ {
+ return m_format;
+ }
+
+ inline void SetDateValue( const wxDateTime& dt )
+ {
+ //m_valueDateTime = dt;
+ m_value = dt;
+ }
+
+ inline wxDateTime GetDateValue() const
+ {
+ //return m_valueDateTime;
+ return m_value;
+ }
+
+ inline long GetDatePickerStyle() const
+ {
+ return m_dpStyle;
+ }
+
+protected:
+ wxString m_format;
+ long m_dpStyle; // DatePicker style
+
+ static wxString ms_defaultDateFormat;
+ static wxString DetermineDefaultDateFormat( bool showCentury );
+};
+
+#endif
+
+// -----------------------------------------------------------------------
+
+#endif // _WX_PROPGRID_ADVPROPS_H_

Added: trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/editors.h
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/editors.h Sat
Dec 15 08:55:59 2007
@@ -0,0 +1,571 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: editors.h
+// Purpose: wxPropertyGrid editors
+// Author: Jaakko Salli
+// Modified by:
+// Created: Apr-14-2007
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_PROPGRID_EDITORS_H_
+#define _WX_PROPGRID_EDITORS_H_
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+ #pragma interface "editors.cpp"
+#endif
+
+// -----------------------------------------------------------------------
+// wxPGWindowList contains list of editor windows returned by CreateControls.
+
+class wxPGWindowList
+{
+public:
+ wxPGWindowList()
+ {
+ m_primary = m_secondary = NULL;
+ }
+
+ void SetSecondary( wxWindow* secondary ) { m_secondary =
secondary; }
+
+ wxWindow* m_primary;
+ wxWindow* m_secondary;
+
+#ifndef SWIG
+ wxPGWindowList( wxWindow* a )
+ {
+ m_primary = a;
+ m_secondary = NULL;
+ };
+ wxPGWindowList( wxWindow* a, wxWindow* b )
+ {
+ m_primary = a;
+ m_secondary = b;
+ };
+#endif
+};
+
+// -----------------------------------------------------------------------
+
+/** \class wxPGEditor
+ \ingroup classes
+ \brief Base for property editor classes.
+ \remarks
+ - Event handling:
+ wxPGEditor::CreateControls should Connect all necessary events
to the
+ wxPropertyGrid::OnCustomEditorEvent. For Example:
+ \code
+ // Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
+ // control to the OnEvent.
+ // NOTE: This event in particular is actually
automatically conveyed, but
+ // it is just used as an example.
+ propgrid->Connect( wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
+ (wxObjectEventFunction)
(wxEventFunction) (wxCommandEventFunction)
+ &wxPropertyGrid::OnCustomEditorEvent );
+ \endcode
+ OnCustomEditorEvent will then forward events, first to wxPGEditor::OnEvent
+ and then to wxPGProperty::OnEvent.
+ - You need to call macro wxPGRegisterEditorClass(EditorName)
before using a custom editor class.
+ - See propgrid.cpp for how builtin editors works (starting from wxPGTextCtrlEditor).
+*/
+class WXDLLIMPEXP_PG wxPGEditor : public wxObject
+{
+ DECLARE_ABSTRACT_CLASS(wxPGEditor)
+public:
+
+ /** Constructor. */
+ wxPGEditor()
+ : wxObject()
+ {
+ #if defined(__WXPYTHON__)
+ m_scriptObject = NULL;
+ #endif
+ }
+
+ /** Destructor. */
+ virtual ~wxPGEditor();
+
+ /** Returns pointer to the name of the editor. For example, wxPG_EDITOR(TextCtrl)
+ has name "TextCtrl". This method is autogenerated for custom editors.
+ */
+ virtual wxPG_CONST_WXCHAR_PTR GetName() const = 0;
+
+ /** Instantiates editor controls.
+ \remarks
+ - Primary control shall use id wxPG_SUBID1, and secondary
(button) control
+ shall use wxPG_SUBID2.
+ \param propgrid
+ wxPropertyGrid to which the property belongs (use as parent
for control).
+ \param propert
+ Property for which this method is called.
+ \param pos
+ Position, inside wxPropertyGrid, to create control(s) to.
+ \param size
+ Initial size for control(s).
+ \param psecondary
+ If method generates a secondary (button) control, pointer to
it must
+ be stored here.
+ */
+ virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid,
wxPGProperty* property,
+ const wxPoint& pos, const wxSize& sz ) const = 0;
+ #define wxPG_DECLARE_CREATECONTROLS \
+ virtual wxPGWindowList CreateControls( wxPropertyGrid*
propgrid, wxPGProperty* property, \
+ const wxPoint& pos, const wxSize& sz ) const;
+
+ /** Loads value from property to the control. */
+ virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl
) const = 0;
+
+ /** Used to get the renderer to draw the value with when the
control is hidden.
+
+ Default implementation returns g_wxPGDefaultRenderer.
+ */
+ //virtual wxPGCellRenderer* GetCellRenderer() const;
+
+ /** Draws value for given property.
+ */
+ virtual void DrawValue( wxDC& dc, const wxRect& rect,
wxPGProperty* property, const wxString& text ) const;
+
+ /** Handles events. Returns true if value in control was modified
+ (see wxPGProperty::OnEvent for more information).
+ */
+ virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
+ wxWindow* wnd_primary, wxEvent& event ) const = 0;
+
+#ifndef DOXYGEN
+private:
+#else
+public:
+#endif
+ /** Returns value from control, via parameter 'variant'.
+ Usually ends up calling property's StringToValue or IntToValue.
+ Returns true if value was different.
+ */
+ virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl ) const WX_PG_NOT_PURE_IN_WXPYTHON;
+public:
+
+#ifdef __WXPYTHON__
+ virtual wxPGVariantAndBool PyGetValueFromControl( wxPGProperty*
property, wxWindow* ctrl ) const;
+#endif
+
+ bool ActualGetValueFromControl( wxVariant& variant, wxPGProperty*
property, wxWindow* ctrl ) const
+ {
+ #ifdef __WXPYTHON__
+ if ( m_scriptObject )
+ {
+ wxPGVariantAndBool vab = PyGetValueFromControl(property, ctrl);
+ if ( vab.m_valueValid )
+ variant = vab.m_value;
+ return vab.m_result;
+ }
+ #endif
+ return GetValueFromControl(variant, property, ctrl);
+ }
+
+ /** Sets value in control to unspecified. */
+ virtual void SetValueToUnspecified( wxWindow* ctrl ) const = 0;
+
+ /** Sets control's value specifically from string. */
+ virtual void SetControlStringValue( wxWindow* ctrl, const
wxString& txt ) const;
+
+ /** Sets control's value specifically from int (applies to choice
etc.). */
+ virtual void SetControlIntValue( wxWindow* ctrl, int value ) const;
+
+ /** Inserts item to existing control. Index -1 means appending.
+ Default implementation does nothing. Returns index of item added.
+ */
+ virtual int InsertItem( wxWindow* ctrl, const wxString& label, int
index ) const;
+
+ /** Deletes item from existing control.
+ Default implementation does nothing.
+ */
+ virtual void DeleteItem( wxWindow* ctrl, int index ) const;
+
+ /** Extra processing when control gains focus. For example, wxTextCtrl
+ based controls should select all text.
+ */
+ virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
+
+ /** Returns true if control itself can contain the custom image.
Default is
+ to return false.
+ */
+ virtual bool CanContainCustomImage() const;
+
+#if defined(__WXPYTHON__) && !defined(SWIG)
+ // This is the python object that contains and owns the C++ representation.
+ PyObject* m_scriptObject;
+#endif
+
+protected:
+};
+
+
+//#ifndef SWIG
+#if 1
+
+
+#define WX_PG_DECLARE_EDITOR_CLASS(CLASSNAME) \
+ DECLARE_DYNAMIC_CLASS(CLASSNAME) \
+public: \
+ virtual wxPG_CONST_WXCHAR_PTR GetName() const; \
+private:
+
+
+#define WX_PG_IMPLEMENT_EDITOR_CLASS(EDITOR,CLASSNAME,BASECLASS) \
+IMPLEMENT_DYNAMIC_CLASS(CLASSNAME, BASECLASS) \
+wxPG_CONST_WXCHAR_PTR CLASSNAME::GetName() const \
+{ \
+ return wxT(#EDITOR); \
+} \
+wxPGEditor* wxPGEditor_##EDITOR = (wxPGEditor*) NULL; \
+wxPGEditor* wxPGConstruct##EDITOR##EditorClass() \
+{ \
+ wxASSERT( !wxPGEditor_##EDITOR ); \
+ return new CLASSNAME(); \
+}
+
+
+#define WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS() \
+wxPG_DECLARE_CREATECONTROLS \
+virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl )
const; \
+virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty*
property, \
+ wxWindow* primary, wxEvent& event ) const; \
+virtual bool GetValueFromControl( wxVariant& variant, wxPGProperty*
property, wxWindow* ctrl ) const; \
+virtual void SetValueToUnspecified( wxWindow* ctrl ) const;
+
+
+//
+// Following are the built-in editor classes.
+//
+
+class WXDLLIMPEXP_PG wxPGTextCtrlEditor : public wxPGEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGTextCtrlEditor)
+public:
+ wxPGTextCtrlEditor() {}
+ virtual ~wxPGTextCtrlEditor();
+
+ WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
+
+ //virtual wxPGCellRenderer* GetCellRenderer() const;
+ virtual void SetControlStringValue( wxWindow* ctrl, const
wxString& txt ) const;
+ virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
+
+ // Provided so that, for example, ComboBox editor can use the same code
+ // (multiple inheritance would get way too messy).
+ static bool OnTextCtrlEvent( wxPropertyGrid* propgrid,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ wxEvent& event );
+
+ static bool GetTextCtrlValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl );
+
+};
+
+
+class WXDLLIMPEXP_PG wxPGChoiceEditor : public wxPGEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGChoiceEditor)
+public:
+ wxPGChoiceEditor() {}
+ virtual ~wxPGChoiceEditor();
+
+ WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
+
+ virtual void SetControlIntValue( wxWindow* ctrl, int value ) const;
+ virtual void SetControlStringValue( wxWindow* ctrl, const
wxString& txt ) const;
+
+ virtual int InsertItem( wxWindow* ctrl, const wxString& label, int
index ) const;
+ virtual void DeleteItem( wxWindow* ctrl, int index ) const;
+ virtual bool CanContainCustomImage() const;
+
+ // CreateControls calls this with CB_READONLY in extraStyle
+ wxWindow* CreateControlsBase( wxPropertyGrid* propgrid,
+ wxPGProperty* property,
+ const wxPoint& pos,
+ const wxSize& sz,
+ long extraStyle ) const;
+
+};
+
+
+class WXDLLIMPEXP_PG wxPGComboBoxEditor : public wxPGChoiceEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGComboBoxEditor)
+public:
+ wxPGComboBoxEditor() {}
+ virtual ~wxPGComboBoxEditor();
+
+ wxPG_DECLARE_CREATECONTROLS // Macro is used for conviency due to
different signature with wxPython
+
+ virtual void UpdateControl( wxPGProperty* property, wxWindow* ctrl
) const;
+
+ virtual bool OnEvent( wxPropertyGrid* propgrid, wxPGProperty* property,
+ wxWindow* ctrl, wxEvent& event ) const;
+
+ virtual bool GetValueFromControl( wxVariant& variant,
wxPGProperty* property, wxWindow* ctrl ) const;
+
+ virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
+
+};
+
+
+class WXDLLIMPEXP_PG wxPGChoiceAndButtonEditor : public wxPGChoiceEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGChoiceAndButtonEditor)
+public:
+ wxPGChoiceAndButtonEditor() {}
+ virtual ~wxPGChoiceAndButtonEditor();
+ wxPG_DECLARE_CREATECONTROLS // Macro is used for conviency due to
different signature with wxPython
+};
+
+
+class WXDLLIMPEXP_PG wxPGTextCtrlAndButtonEditor : public wxPGTextCtrlEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGTextCtrlAndButtonEditor)
+public:
+ wxPGTextCtrlAndButtonEditor() {}
+ virtual ~wxPGTextCtrlAndButtonEditor();
+ wxPG_DECLARE_CREATECONTROLS
+};
+
+
+#if wxPG_INCLUDE_CHECKBOX
+
+//
+// Use custom check box code instead of native control
+// for cleaner (ie. more integrated) look.
+//
+class WXDLLIMPEXP_PG wxPGCheckBoxEditor : public wxPGEditor
+{
+ WX_PG_DECLARE_EDITOR_CLASS(wxPGCheckBoxEditor)
+public:
+ wxPGCheckBoxEditor() {}
+ virtual ~wxPGCheckBoxEditor();
+
+ WX_PG_IMPLEMENT_EDITOR_CLASS_STD_METHODS()
+
+ virtual void DrawValue( wxDC& dc, const wxRect& rect,
wxPGProperty* property, const wxString& text ) const;
+ //virtual wxPGCellRenderer* GetCellRenderer() const;
+
+ virtual void SetControlIntValue( wxWindow* ctrl, int value ) const;
+};
+
+#endif
+
+#endif // SWIG
+
+
+// -----------------------------------------------------------------------
+// Editor class registeration macros
+
+#define wxPGRegisterEditorClass(EDITOR) \
+ if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
+ { \
+ wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass(
wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR) ); \
+ }
+
+// Use this in RegisterDefaultEditors.
+#define wxPGRegisterDefaultEditorClass(EDITOR) \
+if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \
+ { \
+ wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass(
wxPGConstruct##EDITOR##EditorClass(), wxT(#EDITOR), true ); \
+ }
+
+#define wxPG_INIT_REQUIRED_EDITOR(T) \
+ wxPGRegisterEditorClass(T)
+
+
+// -----------------------------------------------------------------------
+
+/** \class wxPGEditorDialogAdapter
+ \ingroup classes
+ \brief
+ Derive a class from this to adapt an existing editor dialog or
function to
+ be used when editor button of a property is pushed.
+
+ You only need to derive class and implement DoShowDialog() to
create and
+ show the dialog, and finally submit the value returned by the dialog
+ via SetValue().
+*/
+class WXDLLIMPEXP_PG wxPGEditorDialogAdapter : public wxObject
+{
+ DECLARE_ABSTRACT_CLASS(wxPGEditorDialogAdapter)
+public:
+ wxPGEditorDialogAdapter()
+ : wxObject()
+ {
+#if defined(__WXPYTHON__)
+ m_scriptObject = NULL;
+#endif
+ }
+
+ virtual ~wxPGEditorDialogAdapter() { }
+
+ bool ShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property );
+
+ virtual bool DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty*
property ) = 0;
+
+ void SetValue( wxVariant value )
+ {
+ m_value = value;
+ }
+
+#if defined(__WXPYTHON__) && !defined(SWIG)
+ // This is the python object that contains and owns the C++ representation.
+ PyObject* m_scriptObject;
+#endif
+protected:
+
+private:
+ wxVariant m_value;
+};
+
+// -----------------------------------------------------------------------
+
+
+/** \class wxPGMultiButton
+ \ingroup classes
+ \brief
+ This class can be used to have multiple buttons in a property editor.
+ You will need to create a new property editor class, override CreateControls,
+ and have it return wxPGMultiButton instance in wxPGWindowList::SetSecondary().
+ For instance, here we add three buttons to a textctrl editor:
+
+ \code
+
+ #include <wx/propgrid/editors.h>
+
+ class wxMultiButtonTextCtrlEditor : public wxPGTextCtrlEditor
+ {
+ WX_PG_DECLARE_EDITOR_CLASS(wxMultiButtonTextCtrlEditor)
+ public:
+ wxMultiButtonTextCtrlEditor() {}
+ virtual ~wxMultiButtonTextCtrlEditor() {}
+
+ wxPG_DECLARE_CREATECONTROLS
+ virtual bool OnEvent( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ wxEvent& event ) const;
+
+ };
+
+ WX_PG_IMPLEMENT_EDITOR_CLASS(MultiButtonTextCtrlEditor, wxMultiButtonTextCtrlEditor,
+ wxPGTextCtrlEditor)
+
+ wxPGWindowList wxMultiButtonTextCtrlEditor::CreateControls(
wxPropertyGrid* propGrid,
+
wxPGProperty* property,
+ const
wxPoint& pos,
+ const
wxSize& sz ) const
+ {
+ // Create and populate buttons-subwindow
+ wxPGMultiButton* buttons = new wxPGMultiButton( propGrid, sz );
+
+ // Add two regular buttons
+ buttons->Add( wxT("...") );
+ buttons->Add( wxT("A") );
+ // Add a bitmap button
+ buttons->Add( wxArtProvider::GetBitmap(wxART_FOLDER) );
+
+ // Create the 'primary' editor control (textctrl in this case)
+ wxPGWindowList wndList = wxPGTextCtrlEditor::CreateControls
+ ( propGrid, property, pos,
buttons->GetPrimarySize() );
+
+ // Finally, move buttons-subwindow to correct position and
make sure
+ // returned wxPGWindowList contains our custom button list.
+ buttons->FinalizePosition(pos);
+
+ wndList.SetSecondary( buttons );
+ return wndList;
+ }
+
+ bool wxMultiButtonTextCtrlEditor::OnEvent( wxPropertyGrid* propGrid,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ wxEvent& event ) const
+ {
+ if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED )
+ {
+ wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary();
+
+ if ( event.GetId() == buttons->GetButtonId(0) )
+ {
+ // Do something when first button is pressed
+ return true;
+ }
+ if ( event.GetId() == buttons->GetButtonId(1) )
+ {
+ // Do something when first button is pressed
+ return true;
+ }
+ if ( event.GetId() == buttons->GetButtonId(2) )
+ {
+ // Do something when second button is pressed
+ return true;
+ }
+ }
+ return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
+ }
+
+ \endcode
+
+ Further to use this editor, code like this can be used:
+
+ \code
+
+ // Register editor class - needs only to be called once
+ wxPGRegisterEditorClass( MultiButtonTextCtrlEditor );
+
+ // Insert the property that will have multiple buttons
+ propGrid->Append( new
wxLongStringProperty(wxT("MultipleButtons"), wxPG_LABEL) );
+
+ // Change property to use editor created in the previous code segment
+ propGrid->SetPropertyEditor( wxT("MultipleButtons"),
wxPG_EDITOR(MultiButtonTextCtrlEditor) );
+
+ \endcode
+*/
+class WXDLLIMPEXP_PG wxPGMultiButton : public wxWindow
+{
+public:
+
+ wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz );
+
+ virtual ~wxPGMultiButton() { }
+
+ wxWindow* GetButton( unsigned int i ) { return (wxWindow*)
m_buttons[i]; }
+ const wxWindow* GetButton( unsigned int i ) const { return (const
wxWindow*) m_buttons[i]; }
+
+ /** Utility function to be used in event handlers.
+ */
+ int GetButtonId( unsigned int i ) const { return
GetButton(i)->GetId(); }
+
+ void Add( const wxString& label, int id = -2 );
+#if wxUSE_BMPBUTTON
+ void Add( const wxBitmap& bitmap, int id = -2 );
+#endif
+
+ wxSize GetPrimarySize() const
+ {
+ return wxSize(m_fullEditorSize.x - m_buttonsWidth, m_fullEditorSize.y);
+ }
+
+ void FinalizePosition( const wxPoint& pos )
+ {
+ Move( pos.x + m_fullEditorSize.x - m_buttonsWidth, pos.y );
+ }
+
+#ifndef DOXYGEN
+protected:
+
+ int GenId( int id ) const;
+
+ wxArrayPtrVoid m_buttons;
+ wxSize m_fullEditorSize;
+ int m_buttonsWidth;
+#endif // !DOXYGEN
+};
+
+// -----------------------------------------------------------------------
+
+#endif // _WX_PROPGRID_EDITORS_H_

Added: trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/extras.h
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/extras.h Sat
Dec 15 08:55:59 2007
@@ -0,0 +1,20 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: extras.h
+// Purpose: wxPropertyGrid Extras Header
+// Author: Jaakko Salli
+// Modified by:
+// Created: Mar-05-2006
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef WX_PROPGRID_EXTRAS_H
+#define WX_PROPGRID_EXTRAS_H
+
+//
+// In wxPython version this file will have additional property and
+// editor control headers.
+//
+
+#endif // WX_PROPGRID_EXTRAS_H

Added: trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/manager.h
==============================================================================
--- (empty file)
+++ trunk/wx.mod/wxpropgrid.mod/src/include/wx/propgrid/manager.h Sat
Dec 15 08:55:59 2007
@@ -0,0 +1,836 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: manager.h
+// Purpose: wxPropertyGridManager
+// Author: Jaakko Salli
+// Modified by:
+// Created: Jan-14-2005
+// RCS-ID: $Id:
+// Copyright: (c) Jaakko Salli
+// Licence: wxWindows license
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_PROPGRID_MANAGER_H_
+#define _WX_PROPGRID_MANAGER_H_
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+ #pragma interface "manager.cpp"
+#endif
+
+#include <wx/propgrid/propgrid.h>
+
+#if wxPG_INCLUDE_MANAGER || defined(DOXYGEN)
+
+// -----------------------------------------------------------------------
+
+#ifndef SWIG
+extern WXDLLIMPEXP_PG const wxChar *wxPropertyGridManagerNameStr;
+#endif
+
+/** \class wxPropertyGridPage
+ \ingroup classes
+ \brief
+ Holder of property grid page information. You can subclass this and
+ give instance in wxPropertyGridManager::AddPage. It inherits from
+ wxEvtHandler and can be used to process events specific to this
+ page (id of events will still be same as manager's). If you don't
+ want to use it to process all events of the page, you need to
+ return false in the derived wxPropertyGridPage::IsHandlingAllEvents.
+
+ Please note that wxPropertyGridPage lacks many non-const property
+ manipulation functions found in wxPropertyGridManager. Please use
+ parent manager (m_manager member variable) when needed.
+
+ <h4>Derived from</h4>
+
+ wxPropertyGridState\n
+ wxPropertyContainerMethods\n
+ wxEvtHandler\n
+ wxObject\n
+
+ <h4>Include files</h4>
+
+ <wx/propgrid/manager.h>
+
+ <h4>Event handling</h4>
+
+ wxPropertyGridPage receives events emitted by its
wxPropertyGridManager, but
+ only those events that are specific to that page. If wxPropertyGridPage::IsHandlingAllEvents
+ returns false, then unhandled events are sent to the manager's
parent, as usual.
+*/
+class WXDLLIMPEXP_PG wxPropertyGridPage : public wxEvtHandler,
+ public wxPropertyContainerMethods,
+ public wxPropertyGridState
+{
+ friend class wxPropertyGridManager;
+#ifndef SWIG
+ DECLARE_CLASS(wxPropertyGridPage)
+#endif
+public:
+
+ wxPropertyGridPage();
+ virtual ~wxPropertyGridPage();
+
+ /** Return pointer to contained property grid state.
+ */
+ inline wxPropertyGridState* GetStatePtr()
+ {
+ return this;
+ }
+
+ /** Do any member initialization in this method.
+ \remarks
+ - Called every time the page is added into a manager.
+ - You can add properties to the page here.
+ */
+ virtual void Init() {};
+
+ /** Return false here to indicate unhandled events should be
+ propagated to manager's parent, as normal.
+ */
+ virtual bool IsHandlingAllEvents() const { return true; }
+
+ /** Propagate to other pages.
+ */
+ virtual void DoSetSplitterPosition( int pos, int splitterColumn =
0, bool allPages = true );
+
+ /** Propagate to other pages.
+ */
+ void DoSetSplitterPositionThisPage( int pos, int splitterColumn =
0 )
+ {
+ wxPropertyGridState::DoSetSplitterPosition( pos,
splitterColumn );
+ }
+
+#ifndef SWIG
+protected:
+
+ virtual void RefreshProperty( wxPGProperty* p );
+
+ //virtual bool ProcessEvent( wxEvent& event );
+
+ wxPropertyGridManager* m_manager;
+ wxString m_label;
+ int m_id; // toolbar index
+
+private:
+ bool m_isDefault; // is this base page object?
+
+private:
+ DECLARE_EVENT_TABLE()
+#endif
+};
+
+// -----------------------------------------------------------------------
+
+/** \class wxPropertyGridManager
+ \ingroup classes
+ \brief
+ wxPropertyGridManager is an efficient multi-page version of wxPropertyGrid,
+ which can optionally have toolbar for mode and page selection, and
help text box.
+ Use window flags to select components to include.
+
+ <h4>Derived from</h4>
+
+ wxPropertyContainerMethods\n
+ wxWindow\n
+ wxEvtHandler\n
+ wxObject\n
+
+ <h4>Include files</h4>
+
+ <wx/propgrid/manager.h>
+
+ <h4>Window styles</h4>
+
+ @link wndflags Additional Window Styles@endlink
+
+ <h4>Event handling</h4>
+
+ To process input from a propertygrid control, use these event
handler macros to
+ direct input to member functions that take a wxPropertyGridEvent argument.
+
+ <table>
+ <tr><td>EVT_PG_SELECTED (id, func)</td><td>Property is selected.</td></tr>
+ <tr><td>EVT_PG_CHANGED (id, func)</td><td>Property value is modified.</td></tr>
+ <tr><td>EVT_PG_CHANGING (id, func)</td><td>Property value is about
to be changed. Use wxPropertyGridEvent::GetValue() to take a peek at
the pending value.</td></tr>
+ <tr><td>EVT_PG_HIGHLIGHTED (id, func)</td><td>Mouse moves over
property. Event's property is NULL if hovered on area that is not a property.</td></tr>
+ <tr><td>EVT_PG_PAGE_CHANGED (id, func)</td><td>User changed page
in manager.</td></tr>
+ <tr><td>EVT_PG_ITEM_COLLAPSED (id, func)</td><td>User collapses a
property or category.</td></tr>
+ <tr><td>EVT_PG_ITEM_EXPANDED (id, func)</td><td>User expands a
property or category.</td></tr>
+ <tr><td>EVT_BUTTON (id, func)</td><td>Button in a property editor
was clicked. Only occurs if the property doesn't handle button clicks itself.</td></tr>
+ <tr><td>EVT_TEXT (id, func)</td><td>wxTextCtrl based editor was
updated (but property value was not yet modified)</td></tr>
+ </table>
+
+ \sa @link wxPropertyGridEvent wxPropertyGridEvent@endlink
+
+*/
+// BM_MANAGER
+class WXDLLIMPEXP_PG wxPropertyGridManager : public wxPanel, public wxPropertyContainerMethods
+{
+#ifndef SWIG
+ DECLARE_CLASS(wxPropertyGridManager)
+#endif
+ friend class wxPropertyGridPage;
+public:
+
+#ifdef SWIG
+ %pythonAppend wxPropertyGridManager {
+ self._setOORInfo(self)
+ self.DoDefaultTypeMappings()
+ self.edited_objects = {}
+ self.DoDefaultValueTypeMappings()
+ if not hasattr(self.__class__,'_vt2setter'):
+ self.__class__._vt2setter = {}
+ }
+ %pythonAppend wxPropertyGridManager() ""
+
+ wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxPGMAN_DEFAULT_STYLE,
+ const wxChar* name =
wxPyPropertyGridManagerNameStr );
+ %RenameCtor(PrePropertyGridManager, wxPropertyGridManager());
+
+#else
+
+ /** Two step constructor. Call Create when this constructor is called
to build up the
+ wxPropertyGridManager.
+ */
+ wxPropertyGridManager();
+
+ /** The default constructor. The styles to be used are styles
valid for
+ the wxWindow.
+ \sa @link wndflags Additional Window Styles@endlink
+ */
+ wxPropertyGridManager( wxWindow *parent, wxWindowID id = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxPGMAN_DEFAULT_STYLE,
+ const wxChar* name =
wxPropertyGridManagerNameStr );
+
+ /** Destructor */
+ virtual ~wxPropertyGridManager();
+
+#endif
+
+ /** Creates new property page. Note that the first page is not created
+ automatically.
+ \param label
+ A label for the page. This may be shown as a toolbar tooltip etc.
+ \param bmp
+ Bitmap image for toolbar. If wxNullBitmap is used, then a built-in
+ default image is used.
+ \param pageObj
+ wxPropertyGridPage instance. Manager will take ownership of
this object.
+ NULL indicates that a default page instance should be created.
+ \retval
+ Returns index to the page created.
+ \remarks
+ If toolbar is used, it is highly recommended that the pages are
+ added when the toolbar is not turned off using window style flag
+ switching.
+ */
+ inline int AddPage( const wxString& label = wxEmptyString,
+ const wxBitmap& bmp = wxPG_NULL_BITMAP,
+ wxPropertyGridPage* pageObj =
(wxPropertyGridPage*) NULL )
+ {
+ return InsertPage(-1,label,bmp,pageObj);
+ }
+
+ /** Returns true if all property grid data changes have been
committed. Usually
+ only returns false if value in active editor has been
invalidated by a
+ wxValidator.
+ */
+ inline bool CanClose()
+ {
+ return m_pPropGrid->CanClose();
+ }
+
+ void ClearModifiedStatus ( wxPGPropArg id );
+
+ inline void ClearModifiedStatus ()
+ {
+ m_pPropGrid->ClearModifiedStatus();
+ }
+
+ /** Deletes all properties on given page.
+ */
+ void ClearPage( int page );
+
+ /** Two step creation. Whenever the control is created without any parameters,
+ use Create to actually create it. Don't access the control's
public methods
+ before this is called.
+ \sa @link wndflags Additional Window Styles@endlink
+ */
+ bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxPGMAN_DEFAULT_STYLE,
+ const wxChar* name = wxPropertyGridManagerNameStr );
+
+ /** Enables or disables (shows/hides) categories according to
parameter enable.
+ WARNING: Not tested properly, use at your own risk.
+ */
+ inline bool EnableCategories( bool enable )
+ {
+ long fl = m_windowStyle | wxPG_HIDE_CATEGORIES;
+ if ( enable ) fl = m_windowStyle & ~(wxPG_HIDE_CATEGORIES);
+ SetWindowStyleFlag(m_windowStyle);
+ return true;
+ }
+
+ /** Call to enable or disable usage of common values (values that
can be selected for
+ properties instead of their normal values).
+
+ Common values are disabled by the default.
+ */
+ void EnableCommonValues( bool enable = true )
+ {
+ m_pPropGrid->EnableCommonValues(enable);
+ }
+
+ /** Selects page, scrolls and/or expands items to ensure that the
+ given item is visible. Returns true if something was actually done.
+ */
+ bool EnsureVisible( wxPGPropArg id );
+
+ /** Returns number of children of the root property of the
selected page. */
+ inline size_t GetChildrenCount()
+ {
+ return GetChildrenCount(
wxPGIdGen(m_pPropGrid->m_pState->m_properties) );
+ }
+
+ /** Returns number of children of the root property of given page. */
+ size_t GetChildrenCount( int pageIndex );
+
+ /** Returns number of children for the property.
+
+ NB: Cannot be in container methods class due to name hiding.
+ */
+ inline size_t GetChildrenCount( wxPGPropArg id ) const
+ {
+ wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
+ return p->GetChildCount();
+ }
+
+ /** Returns number of columns on given page. By the default,
+ returns number of columns on current page. */
+ int GetColumnCount( int page = -1 ) const;
+
+ /** Returns height of the description text box. */
+ int GetDescBoxHeight() const;
+
+ /** Returns pointer to the contained wxPropertyGrid. This does not change
+ after wxPropertyGridManager has been created, so you can
safely obtain
+ pointer once and use it for the entire lifetime of the instance.
+ */
+ inline wxPropertyGrid* GetGrid()
+ {
+ wxASSERT(m_pPropGrid);
+ return m_pPropGrid;
+ };
+
+ /** Returns iterator class instance.
+ \remarks
+ Calling this method in wxProp

==============================================================================
Diff truncated at 200k characters

codesite...@google.com

unread,
Dec 15, 2007, 11:57:07 AM12/15/07
to wx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages