From e70b4f10951f806a7b6cf7e65317a21421e2f3a6 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 25 Aug 2003 23:33:36 +0000 Subject: [PATCH] unicode adaptions, menu support git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23224 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/button.cpp | 2 +- src/msw/checkbox.cpp | 2 +- src/msw/colour.cpp | 16 ++----- src/msw/frame.cpp | 5 +- src/msw/menu.cpp | 106 ++++++++++++++++++++++++++++++++++++------- src/msw/menuitem.cpp | 46 +++++++++++++++++++ src/msw/notebook.cpp | 2 +- src/msw/radiobut.cpp | 2 +- src/msw/spinbutt.cpp | 4 -- src/msw/statbox.cpp | 2 +- src/msw/stattext.cpp | 2 +- src/msw/textctrl.cpp | 2 +- 12 files changed, 151 insertions(+), 40 deletions(-) diff --git a/src/msw/button.cpp b/src/msw/button.cpp index ad4270cd20..948d1c76b8 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -91,7 +91,7 @@ WX_BEGIN_PROPERTIES_TABLE(wxButton) WX_DELEGATE( OnClick , wxEVT_COMMAND_BUTTON_CLICKED , wxCommandEvent) WX_PROPERTY( Font , wxFont , SetFont , GetFont , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - WX_PROPERTY( Label, wxString , SetLabel, GetLabel, wxEmptyString, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( Label, wxString , SetLabel, GetLabel, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) WX_PROPERTY_FLAGS( WindowStyle , wxButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp index 57e205af1d..6c3c6eafda 100644 --- a/src/msw/checkbox.cpp +++ b/src/msw/checkbox.cpp @@ -86,7 +86,7 @@ WX_BEGIN_PROPERTIES_TABLE(wxCheckBox) WX_DELEGATE( OnClick , wxEVT_COMMAND_CHECKBOX_CLICKED , wxCommandEvent ) WX_PROPERTY( Font , wxFont , SetFont , GetFont , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY( Value ,bool, SetValue, GetValue, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY_FLAGS( WindowStyle , wxCheckBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style WX_END_PROPERTIES_TABLE() diff --git a/src/msw/colour.cpp b/src/msw/colour.cpp index 1f99c2a348..eebf6ed159 100644 --- a/src/msw/colour.cpp +++ b/src/msw/colour.cpp @@ -27,8 +27,6 @@ #if wxUSE_EXTENDED_RTTI -/* - template<> void wxStringReadValue(const wxString &s , wxColour &data ) { // copied from VS xrc @@ -51,19 +49,15 @@ template<> void wxStringReadValue(const wxString &s , wxColour &data ) template<> void wxStringWriteValue(wxString &s , const wxColour &data ) { - s = wxString::Format("#%2X%2X%2X", data.Red() , data.Green() , data.Blue() ) ; + s = wxString::Format("#%02X%02X%02X", data.Red() , data.Green() , data.Blue() ) ; } -WX_CUSTOM_TYPE_INFO(wxColour) - -*/ - -IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( wxColour , wxObject , "wx/colour.h" ) +IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour , wxObject , "wx/colour.h" , &wxToStringConverter , &wxFromStringConverter) WX_BEGIN_PROPERTIES_TABLE(wxColour) - WX_READONLY_PROPERTY( Red, unsigned char , Red , 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - WX_READONLY_PROPERTY( Green, unsigned char , Green , 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - WX_READONLY_PROPERTY( Blue, unsigned char , Blue , 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_READONLY_PROPERTY( Red, unsigned char , Red , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_READONLY_PROPERTY( Green, unsigned char , Green , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_READONLY_PROPERTY( Blue, unsigned char , Blue , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_END_PROPERTIES_TABLE() WX_CONSTRUCTOR_3( wxColour , unsigned char , Red , unsigned char , Green , unsigned char , Blue ) diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 90ba4b843e..438db56ff0 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -131,9 +131,10 @@ WX_END_FLAGS( wxFrameStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") WX_BEGIN_PROPERTIES_TABLE(wxFrame) - WX_PROPERTY( Title,wxString, SetTitle, GetTitle, wxEmptyString , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style -/* + WX_PROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + /* TODO PROPERTIES style (wxDEFAULT_FRAME_STYLE) diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 6f1343b30c..ece5953e23 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -112,25 +112,99 @@ UINT GetMenuState(HMENU hMenu, UINT id, UINT flags) // implementation // ============================================================================ +#include + +WX_DEFINE_LIST( wxMenuInfoList ) ; + +#if wxUSE_EXTENDED_RTTI + +WX_DEFINE_FLAGS( wxMenuStyle ) + +WX_BEGIN_FLAGS( wxMenuStyle ) + WX_FLAGS_MEMBER(wxMENU_TEAROFF) +WX_END_FLAGS( wxMenuStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxMenu, wxEvtHandler,"wx/menu.h") + +WX_COLLECTION_TYPE_INFO( wxMenuItem * , wxMenuItemList ) ; + +template<> void wxCollectionToVariantArray( wxMenuItemList const &theList, wxxVariantArray &value) +{ + wxListCollectionToVariantArray( theList , value ) ; +} + +WX_BEGIN_PROPERTIES_TABLE(wxMenu) + WX_DELEGATE( OnSelect , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) + WX_PROPERTY( Title, wxString , SetTitle, GetTitle, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_READONLY_PROPERTY_FLAGS( MenuStyle , wxMenuStyle , long , GetStyle , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style + WX_PROPERTY_COLLECTION( MenuItems , wxMenuItemList , wxMenuItem* , Append , GetMenuItems , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxMenu) +WX_END_HANDLERS_TABLE() + +WX_DIRECT_CONSTRUCTOR_2( wxMenu , wxString , Title , long , MenuStyle ) + +WX_DEFINE_FLAGS( wxMenuBarStyle ) + +WX_BEGIN_FLAGS( wxMenuBarStyle ) + WX_FLAGS_MEMBER(wxMB_DOCKABLE) +WX_END_FLAGS( wxMenuBarStyle ) + +// the negative id would lead the window (its superclass !) to vetoe streaming out otherwise +bool wxMenuBarStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & ) +{ + return true ; +} + +IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuBar, wxWindow ,"wx/menu.h",wxMenuBarStreamingCallback) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxMenuInfo, wxObject , "wx/menu.h" ) + +WX_BEGIN_PROPERTIES_TABLE(wxMenuInfo) + WX_READONLY_PROPERTY( Menu , wxMenu* , GetMenu , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_READONLY_PROPERTY( Title , wxString , GetTitle , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxMenuInfo) +WX_END_HANDLERS_TABLE() + +WX_CONSTRUCTOR_2( wxMenuInfo , wxMenu* , Menu , wxString , Title ) + +WX_COLLECTION_TYPE_INFO( wxMenuInfo * , wxMenuInfoList ) ; + +template<> void wxCollectionToVariantArray( wxMenuInfoList const &theList, wxxVariantArray &value) +{ + wxListCollectionToVariantArray( theList , value ) ; +} + +WX_BEGIN_PROPERTIES_TABLE(wxMenuBar) + WX_PROPERTY_COLLECTION( MenuInfos , wxMenuInfoList , wxMenuInfo* , Append , GetMenuInfos , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxMenuBar) +WX_END_HANDLERS_TABLE() + +WX_CONSTRUCTOR_DUMMY( wxMenuBar ) + +#else IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow) +IMPLEMENT_DYNAMIC_CLASS(wxMenuInfo, wxObject) +#endif -/* - TODO PROPERTIES - wxMenu - label - help - - separator - break - label - accel - radio - checkable - help - bitmap - wxMenuItem -*/ +const wxMenuInfoList& wxMenuBar::GetMenuInfos() const +{ + wxMenuInfoList* list = const_cast< wxMenuInfoList* >( &m_menuInfos ) ; + WX_CLEAR_LIST( wxMenuInfoList , *list ) ; + for( size_t i = 0 ; i < GetMenuCount() ; ++i ) + { + wxMenuInfo* info = new wxMenuInfo() ; + info->Create( const_cast(this)->GetMenu(i) , GetLabelTop(i) ) ; + list->Append( info ) ; + } + return m_menuInfos ; +} // --------------------------------------------------------------------------- // wxMenu construction, adding and removing menu items diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 09ef0d039f..acd80a9dc2 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -77,7 +77,48 @@ UINT GetMenuState(HMENU hMenu, UINT id, UINT flags) ; // dynamic classes implementation // ---------------------------------------------------------------------------- +#if wxUSE_EXTENDED_RTTI + +bool wxMenuItemStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & ) +{ + const wxMenuItem * mitem = dynamic_cast(object) ; + if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().IsEmpty() ) + { + // we don't stream out the first two items for menus with a title, they will be reconstructed + if ( mitem->GetMenu()->FindItemByPosition(0) == mitem || mitem->GetMenu()->FindItemByPosition(1) == mitem ) + return false ; + } + return true ; +} + +WX_BEGIN_ENUM( wxItemKind ) + WX_ENUM_MEMBER( wxITEM_SEPARATOR ) + WX_ENUM_MEMBER( wxITEM_NORMAL ) + WX_ENUM_MEMBER( wxITEM_CHECK ) + WX_ENUM_MEMBER( wxITEM_RADIO ) +WX_END_ENUM( wxItemKind ) + +IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem, wxObject,"wx/menuitem.h",wxMenuItemStreamingCallback) + +WX_BEGIN_PROPERTIES_TABLE(wxMenuItem) + WX_PROPERTY( Parent,wxMenu*, SetMenu, GetMenu, , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( Id,int, SetId, GetId, , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( Text, wxString , SetText, GetText, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( Help, wxString , SetHelp, GetHelp, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_READONLY_PROPERTY( Kind, wxItemKind , GetKind , , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( SubMenu,wxMenu*, SetSubMenu, GetSubMenu, , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( Enabled , bool , Enable , IsEnabled , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Checked , bool , Check , IsChecked , wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Checkable , bool , SetCheckable , IsCheckable , wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxMenuItem) +WX_END_HANDLERS_TABLE() + +WX_DIRECT_CONSTRUCTOR_6( wxMenuItem , wxMenu* , Parent , int , Id , wxString , Text , wxString , Help , wxItemKind , Kind , wxMenu* , SubMenu ) +#else IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) +#endif // ---------------------------------------------------------------------------- // wxMenuItem @@ -155,6 +196,11 @@ int wxMenuItem::GetRealId() const bool wxMenuItem::IsChecked() const { + // fix that RTTI is always getting the correct state (separators cannot be checked, but the call below + // returns true + if ( GetId() == wxID_SEPARATOR ) + return false ; + int flag = ::GetMenuState(GetHMenuOf(m_parentMenu), GetId(), MF_BYCOMMAND); return (flag & MF_CHECKED) != 0; diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 7e4f7772c6..b98ac069e8 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -186,7 +186,7 @@ WX_CONSTRUCTOR_5( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , WX_BEGIN_PROPERTIES_TABLE(wxNotebookPageInfo) WX_READONLY_PROPERTY( Page , wxNotebookPage* , GetPage , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - WX_READONLY_PROPERTY( Text , wxString , GetText , wxEmptyString , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_READONLY_PROPERTY( Text , wxString , GetText , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_READONLY_PROPERTY( Selected , bool , GetSelected , false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) WX_READONLY_PROPERTY( ImageId , int , GetImageId , -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_END_PROPERTIES_TABLE() diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index 006dd835ef..6ea82634aa 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -88,7 +88,7 @@ IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton, wxControl,"wx/radiobut.h") WX_BEGIN_PROPERTIES_TABLE(wxRadioButton) WX_DELEGATE( OnClick , wxEVT_COMMAND_RADIOBUTTON_SELECTED , wxCommandEvent ) WX_PROPERTY( Font , wxFont , SetFont , GetFont , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) WX_PROPERTY( Value ,bool, SetValue, GetValue,, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) WX_PROPERTY_FLAGS( WindowStyle , wxRadioButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style WX_END_PROPERTIES_TABLE() diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index 2e4aa9b8cd..e5b120c6b6 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -101,10 +101,6 @@ WX_BEGIN_PROPERTIES_TABLE(wxSpinButton) WX_PROPERTY( Min , int , SetMin, GetMin, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY( Max , int , SetMax, GetMax, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY_FLAGS( WindowStyle , wxSpinButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style -/* - TODO PROPERTIES - style wxSP_VERTICAL | wxSP_ARROW_KEYS -*/ WX_END_PROPERTIES_TABLE() WX_BEGIN_HANDLERS_TABLE(wxSpinButton) diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 261d5366ac..d17de195f8 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -79,7 +79,7 @@ WX_END_FLAGS( wxStaticBoxStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox, wxControl,"wx/statbox.h") WX_BEGIN_PROPERTIES_TABLE(wxStaticBox) - WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY_FLAGS( WindowStyle , wxStaticBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style /* TODO PROPERTIES : diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 57bdddeb2f..a6d3d92786 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -73,7 +73,7 @@ WX_END_FLAGS( wxStaticTextStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticText, wxControl,"wx/stattext.h") WX_BEGIN_PROPERTIES_TABLE(wxStaticText) - WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Label,wxString, SetLabel, GetLabel, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY_FLAGS( WindowStyle , wxStaticTextStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style WX_END_PROPERTIES_TABLE() diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index dc40f52b81..018c197c8d 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -170,7 +170,7 @@ IMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl,"wx/textctrl.h") WX_BEGIN_PROPERTIES_TABLE(wxTextCtrl) WX_PROPERTY( Font , wxFont , SetFont , GetFont ,, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - WX_PROPERTY( Value , wxString , SetValue, GetValue, wxEmptyString , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + WX_PROPERTY( Value , wxString , SetValue, GetValue, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) WX_PROPERTY_FLAGS( WindowStyle , wxTextCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style WX_END_PROPERTIES_TABLE() -- 2.45.2