From c4608a8af3735907d923c57311eae957a40ff0eb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 1 Mar 2000 18:55:29 +0000 Subject: [PATCH] 1. warning in gtk/menu.cpp fixed 2. Unicode fix in msw/textctrl.cpp 3. more parameters support in grid editors/handlers git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6380 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 100 ++++++++----- samples/newgrid/griddemo.cpp | 16 +- src/generic/grid.cpp | 282 +++++++++++++++++++++++++++-------- src/gtk/menu.cpp | 16 +- src/gtk1/menu.cpp | 16 +- src/msw/textctrl.cpp | 4 +- 6 files changed, 309 insertions(+), 125 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 4477e57531..5f4a112e78 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -58,6 +58,7 @@ #define wxGRID_VALUE_BOOL _T("bool") #define wxGRID_VALUE_NUMBER _T("long") #define wxGRID_VALUE_FLOAT _T("double") +#define wxGRID_VALUE_CHOICE _T("choice") #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER @@ -89,17 +90,17 @@ class WXDLLEXPORT wxSpinCtrl; #define wxSafeDecRef(p) if ( p ) (p)->DecRef() // ---------------------------------------------------------------------------- -// wxGridCellRenderer: this class is responsible for actually drawing the cell -// in the grid. You may pass it to the wxGridCellAttr (below) to change the -// format of one given cell or to wxGrid::SetDefaultRenderer() to change the -// view of all cells. This is an ABC, you will normally use one of the -// predefined derived classes or derive your own class from it. +// wxGridCellWorker: common base class for wxGridCellRenderer and +// wxGridCellEditor +// +// NB: this is more an implementation convenience than a design issue, so this +// class is not documented and is not public at all // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxGridCellRenderer +class WXDLLEXPORT wxGridCellWorker { public: - wxGridCellRenderer() { m_nRef = 1; } + wxGridCellWorker() { m_nRef = 1; } // this class is ref counted: it is created with ref count of 1, so // calling DecRef() once will delete it. Calling IncRef() allows to lock @@ -107,6 +108,34 @@ public: void IncRef() { m_nRef++; } void DecRef() { if ( !--m_nRef ) delete this; } + // interpret renderer parameters: arbitrary string whose interpretatin is + // left to the derived classes + virtual void SetParameters(const wxString& params); + +protected: + // virtual dtor for any base class - private because only DecRef() can + // delete us + virtual ~wxGridCellWorker(); + +private: + size_t m_nRef; + + // suppress the stupid gcc warning about the class having private dtor and + // no friends + friend class wxGridCellWorkerDummyFriend; +}; + +// ---------------------------------------------------------------------------- +// wxGridCellRenderer: this class is responsible for actually drawing the cell +// in the grid. You may pass it to the wxGridCellAttr (below) to change the +// format of one given cell or to wxGrid::SetDefaultRenderer() to change the +// view of all cells. This is an ABC, you will normally use one of the +// predefined derived classes or derive your own class from it. +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxGridCellRenderer : public wxGridCellWorker +{ +public: // draw the given cell on the provided DC inside the given rectangle // using the style specified by the attribute and the default or selected // state corresponding to the isSelected value. @@ -127,24 +156,8 @@ public: wxDC& dc, int row, int col) = 0; - // interpret renderer parameters: arbitrary string whose interpretatin is - // left to the derived classes - virtual void SetParameters(const wxString& params); - // create a new object which is the copy of this one virtual wxGridCellRenderer *Clone() const = 0; - -protected: - // virtual dtor for any base class - private because only DecRef() can - // delete us - virtual ~wxGridCellRenderer(); - -private: - size_t m_nRef; - - // suppress the stupid gcc warning about the class having private dtor and - // no friends - friend class wxGridCellRendererDummyFriend; }; // the default renderer for the cells containing string data @@ -278,17 +291,11 @@ private: // even for the entire grid. // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxGridCellEditor +class WXDLLEXPORT wxGridCellEditor : public wxGridCellWorker { public: wxGridCellEditor(); - // this class is ref counted: it is created with ref count of 1, so - // calling DecRef() once will delete it. Calling IncRef() allows to lock - // it until the matching DecRef() is called - void IncRef() { m_nRef++; } - void DecRef() { if ( !--m_nRef ) delete this; } - bool IsCreated() { return m_control != NULL; } // Creates the actual edit control @@ -334,13 +341,13 @@ public: // Final cleanup virtual void Destroy(); + // create a new object which is the copy of this one + virtual wxGridCellEditor *Clone() const = 0; + protected: // the dtor is private because only DecRef() can delete us virtual ~wxGridCellEditor(); - // the ref count - when it goes to 0, we die - size_t m_nRef; - // the control we show on screen wxControl* m_control; @@ -376,6 +383,12 @@ public: virtual void StartingKey(wxKeyEvent& event); virtual void HandleReturn(wxKeyEvent& event); + // parameters string format is "max_width" + virtual void SetParameters(const wxString& params); + + virtual wxGridCellEditor *Clone() const + { return new wxGridCellTextEditor; } + protected: wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; } @@ -384,6 +397,7 @@ protected: void DoReset(const wxString& startValue); private: + size_t m_maxChars; // max number of chars allowed wxString m_startValue; }; @@ -405,6 +419,12 @@ public: virtual void Reset(); virtual void StartingKey(wxKeyEvent& event); + // parameters string format is "min,max" + virtual void SetParameters(const wxString& params); + + virtual wxGridCellEditor *Clone() const + { return new wxGridCellNumberEditor(m_min, m_max); } + protected: wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; } @@ -436,6 +456,9 @@ public: virtual void Reset(); virtual void StartingKey(wxKeyEvent& event); + virtual wxGridCellEditor *Clone() const + { return new wxGridCellFloatEditor; } + protected: // string representation of m_valueOld wxString GetString() const @@ -462,6 +485,9 @@ public: virtual void Reset(); virtual void StartingClick(); + virtual wxGridCellEditor *Clone() const + { return new wxGridCellBoolEditor; } + protected: wxCheckBox *CBox() const { return (wxCheckBox *)m_control; } @@ -474,7 +500,8 @@ class WXDLLEXPORT wxGridCellChoiceEditor : public wxGridCellEditor { public: // if !allowOthers, user can't type a string not in choices array - wxGridCellChoiceEditor(size_t count, const wxChar* choices[], + wxGridCellChoiceEditor(size_t count = 0, + const wxChar* choices[] = NULL, bool allowOthers = FALSE); virtual void Create(wxWindow* parent, @@ -488,6 +515,11 @@ public: virtual void Reset(); + // parameters string format is "item1[,item2[...,itemN]]" + virtual void SetParameters(const wxString& params); + + virtual wxGridCellEditor *Clone() const; + protected: wxComboBox *Combo() const { return (wxComboBox *)m_control; } diff --git a/samples/newgrid/griddemo.cpp b/samples/newgrid/griddemo.cpp index 23ff16424d..7817e47a27 100644 --- a/samples/newgrid/griddemo.cpp +++ b/samples/newgrid/griddemo.cpp @@ -669,9 +669,9 @@ void GridFrame::OnVTable(wxCommandEvent& ) s = wxGetTextFromUser( "Size of the table to create", "Size:", s ); - + s.ToLong( &s_sizeGrid ); - + #else s_sizeGrid = wxGetNumberFromUser("Size of the table to create", "Size: ", @@ -679,7 +679,7 @@ void GridFrame::OnVTable(wxCommandEvent& ) s_sizeGrid, 0, 32000, this); #endif - + if ( s_sizeGrid != -1 ) { BigGridFrame* win = new BigGridFrame(s_sizeGrid); @@ -828,7 +828,7 @@ static struct BugsGridData Severity severity; int prio; - + #ifndef __BORLANDC__ wxString platform; #else @@ -836,7 +836,7 @@ static struct BugsGridData #endif bool opened; -} gs_dataBugsGrid [] = +} gs_dataBugsGrid [] = { { 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), TRUE }, { 27, _T("bar crashes"), Sev_Critical, 1, _T("all"), FALSE }, @@ -870,8 +870,10 @@ wxString BugsGridTable::GetTypeName(int WXUNUSED(row), int col) // fall thorugh (TODO should be a list) case Col_Summary: + return wxString::Format(_T("%s:80"), wxGRID_VALUE_STRING); + case Col_Platform: - return wxGRID_VALUE_STRING; + return wxString::Format(_T("%s:all,MSW,GTK,other"), wxGRID_VALUE_CHOICE); case Col_Opened: return wxGRID_VALUE_BOOL; @@ -970,7 +972,7 @@ void BugsGridTable::SetValue( int row, int col, const wxString& value ) case Col_Platform: #ifndef __BORLANDC__ gd.platform = value; -#else +#else // this generates a warning message if you are using the // memory tracing code but it should be ok :MB // diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index d4558292eb..dce4f7b9c8 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -47,6 +47,7 @@ #include "wx/textfile.h" #include "wx/spinctrl.h" +#include "wx/tokenzr.h" #include "wx/grid.h" @@ -286,7 +287,19 @@ public: void RegisterDataType(const wxString& typeName, wxGridCellRenderer* renderer, wxGridCellEditor* editor); + + // find one of already registered data types + int FindRegisteredDataType(const wxString& typeName); + + // try to FindRegisteredDataType(), if this fails and typeName is one of + // standard typenames, register it and return its index int FindDataType(const wxString& typeName); + + // try to FindDataType(), if it fails see if it is not one of already + // registered data types with some params in which case clone the + // registered data type and set params for it + int FindOrCloneDataType(const wxString& typeName); + wxGridCellRenderer* GetRenderer(int index); wxGridCellEditor* GetEditor(int index); @@ -338,8 +351,6 @@ static const int GRID_HASH_SIZE = 100; wxGridCellEditor::wxGridCellEditor() { m_control = NULL; - - m_nRef = 1; } @@ -455,6 +466,7 @@ void wxGridCellEditor::StartingClick() wxGridCellTextEditor::wxGridCellTextEditor() { + m_maxChars = 0; } void wxGridCellTextEditor::Create(wxWindow* parent, @@ -468,6 +480,8 @@ void wxGridCellTextEditor::Create(wxWindow* parent, #endif ); + // TODO: use m_maxChars + wxGridCellEditor::Create(parent, id, evtHandler); } @@ -604,6 +618,28 @@ void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event) #endif } +void wxGridCellTextEditor::SetParameters(const wxString& params) +{ + if ( !params ) + { + // reset to default + m_maxChars = 0; + } + else + { + long tmp; + if ( !params.ToLong(&tmp) ) + { + wxLogDebug(_T("Invalid wxGridCellTextEditor parameter string " + "'%s' ignored"), params.c_str()); + } + else + { + m_maxChars = (size_t)tmp; + } + } +} + // ---------------------------------------------------------------------------- // wxGridCellNumberEditor // ---------------------------------------------------------------------------- @@ -723,6 +759,35 @@ void wxGridCellNumberEditor::StartingKey(wxKeyEvent& event) event.Skip(); } +void wxGridCellNumberEditor::SetParameters(const wxString& params) +{ + if ( !params ) + { + // reset to default + m_min = + m_max = -1; + } + else + { + long tmp; + if ( params.BeforeFirst(_T(',')).ToLong(&tmp) ) + { + m_min = (int)tmp; + + if ( params.AfterFirst(_T(',')).ToLong(&tmp) ) + { + m_max = (int)tmp; + + // skip the error message below + return; + } + } + + wxLogDebug(_T("Invalid wxGridCellNumberEditor parameter string " + "'%s' ignored"), params.c_str()); + } +} + // ---------------------------------------------------------------------------- // wxGridCellFloatEditor // ---------------------------------------------------------------------------- @@ -925,13 +990,25 @@ wxGridCellChoiceEditor::wxGridCellChoiceEditor(size_t count, bool allowOthers) : m_allowOthers(allowOthers) { - m_choices.Alloc(count); - for ( size_t n = 0; n < count; n++ ) + if ( count ) { - m_choices.Add(choices[n]); + m_choices.Alloc(count); + for ( size_t n = 0; n < count; n++ ) + { + m_choices.Add(choices[n]); + } } } +wxGridCellEditor *wxGridCellChoiceEditor::Clone() const +{ + wxGridCellChoiceEditor *editor = new wxGridCellChoiceEditor; + editor->m_allowOthers = m_allowOthers; + editor->m_choices = m_choices; + + return editor; +} + void wxGridCellChoiceEditor::Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) @@ -1007,6 +1084,23 @@ void wxGridCellChoiceEditor::Reset() Combo()->SetInsertionPointEnd(); } +void wxGridCellChoiceEditor::SetParameters(const wxString& params) +{ + if ( !params ) + { + // what can we do? + return; + } + + m_choices.Empty(); + + wxStringTokenizer tk(params, _T(',')); + while ( tk.HasMoreTokens() ) + { + m_choices.Add(tk.GetNextToken()); + } +} + // ---------------------------------------------------------------------------- // wxGridCellEditorEvtHandler // ---------------------------------------------------------------------------- @@ -1049,6 +1143,20 @@ void wxGridCellEditorEvtHandler::OnChar(wxKeyEvent& event) } } +// ---------------------------------------------------------------------------- +// wxGridCellWorker is an (almost) empty common base class for +// wxGridCellRenderer and wxGridCellEditor managing ref counting +// ---------------------------------------------------------------------------- + +void wxGridCellWorker::SetParameters(const wxString& WXUNUSED(params)) +{ + // nothing to do +} + +wxGridCellWorker::~wxGridCellWorker() +{ +} + // ============================================================================ // renderer classes // ============================================================================ @@ -1079,15 +1187,6 @@ void wxGridCellRenderer::Draw(wxGrid& grid, dc.DrawRectangle(rect); } -void wxGridCellRenderer::SetParameters(const wxString& WXUNUSED(params)) -{ - // nothing to do -} - -wxGridCellRenderer::~wxGridCellRenderer() -{ -} - // ---------------------------------------------------------------------------- // wxGridCellStringRenderer // ---------------------------------------------------------------------------- @@ -1917,7 +2016,7 @@ void wxGridTypeRegistry::RegisterDataType(const wxString& typeName, wxGridDataTypeInfo* info = new wxGridDataTypeInfo(typeName, renderer, editor); // is it already registered? - int loc = FindDataType(typeName); + int loc = FindRegisteredDataType(typeName); if ( loc != wxNOT_FOUND ) { delete m_typeinfo[loc]; @@ -1929,18 +2028,108 @@ void wxGridTypeRegistry::RegisterDataType(const wxString& typeName, } } +int wxGridTypeRegistry::FindRegisteredDataType(const wxString& typeName) +{ + size_t count = m_typeinfo.GetCount(); + for ( size_t i = 0; i < count; i++ ) + { + if ( typeName == m_typeinfo[i]->m_typeName ) + { + return i; + } + } + + return wxNOT_FOUND; +} + int wxGridTypeRegistry::FindDataType(const wxString& typeName) { - int found = -1; + int index = FindRegisteredDataType(typeName); + if ( index == wxNOT_FOUND ) + { + // check whether this is one of the standard ones, in which case + // register it "on the fly" + if ( typeName == wxGRID_VALUE_STRING ) + { + RegisterDataType(wxGRID_VALUE_STRING, + new wxGridCellStringRenderer, + new wxGridCellTextEditor); + } + else if ( typeName == wxGRID_VALUE_BOOL ) + { + RegisterDataType(wxGRID_VALUE_BOOL, + new wxGridCellBoolRenderer, + new wxGridCellBoolEditor); + } + else if ( typeName == wxGRID_VALUE_NUMBER ) + { + RegisterDataType(wxGRID_VALUE_NUMBER, + new wxGridCellNumberRenderer, + new wxGridCellNumberEditor); + } + else if ( typeName == wxGRID_VALUE_FLOAT ) + { + RegisterDataType(wxGRID_VALUE_FLOAT, + new wxGridCellFloatRenderer, + new wxGridCellFloatEditor); + } + else if ( typeName == wxGRID_VALUE_CHOICE ) + { + RegisterDataType(wxGRID_VALUE_CHOICE, + new wxGridCellStringRenderer, + new wxGridCellChoiceEditor); + } + else + { + return wxNOT_FOUND; + } - for (size_t i=0; im_typeName) { - found = i; - break; + // we get here only if just added the entry for this type, so return + // the last index + index = m_typeinfo.GetCount() - 1; + } + + return index; +} + +int wxGridTypeRegistry::FindOrCloneDataType(const wxString& typeName) +{ + int index = FindDataType(typeName); + if ( index == wxNOT_FOUND ) + { + // the first part of the typename is the "real" type, anything after ':' + // are the parameters for the renderer + index = FindDataType(typeName.BeforeFirst(_T(':'))); + if ( index == wxNOT_FOUND ) + { + return wxNOT_FOUND; } + + wxGridCellRenderer *renderer = GetRenderer(index); + wxGridCellRenderer *rendererOld = renderer; + renderer = renderer->Clone(); + rendererOld->DecRef(); + + wxGridCellEditor *editor = GetEditor(index); + wxGridCellEditor *editorOld = editor; + editor = editor->Clone(); + editorOld->DecRef(); + + // do it even if there are no parameters to reset them to defaults + wxString params = typeName.AfterFirst(_T(':')); + renderer->SetParameters(params); + editor->SetParameters(params); + + // register the new typename + renderer->IncRef(); + editor->IncRef(); + RegisterDataType(typeName, renderer, editor); + + // we just registered it, it's the last one + index = m_typeinfo.GetCount() - 1; } - return found; + return index; } wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index) @@ -2928,21 +3117,8 @@ void wxGrid::Create() m_rowLabelWidth = WXGRID_DEFAULT_ROW_LABEL_WIDTH; m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT; - // data type registration: register all standard data types - // TODO: may be allow the app to selectively disable some of them? + // create the type registry m_typeRegistry = new wxGridTypeRegistry; - RegisterDataType(wxGRID_VALUE_STRING, - new wxGridCellStringRenderer, - new wxGridCellTextEditor); - RegisterDataType(wxGRID_VALUE_BOOL, - new wxGridCellBoolRenderer, - new wxGridCellBoolEditor); - RegisterDataType(wxGRID_VALUE_NUMBER, - new wxGridCellNumberRenderer, - new wxGridCellNumberEditor); - RegisterDataType(wxGRID_VALUE_FLOAT, - new wxGridCellFloatRenderer, - new wxGridCellFloatEditor); // subwindow components that make up the wxGrid m_cornerLabelWin = new wxGridCornerLabelWindow( this, @@ -6933,7 +7109,7 @@ wxGridCellRenderer* wxGrid::GetDefaultRendererForCell(int row, int col) const wxGridCellEditor* wxGrid::GetDefaultEditorForType(const wxString& typeName) const { - int index = m_typeRegistry->FindDataType(typeName); + int index = m_typeRegistry->FindOrCloneDataType(typeName); if ( index == wxNOT_FOUND ) { wxFAIL_MSG(wxT("Unknown data type name")); @@ -6947,41 +7123,15 @@ wxGrid::GetDefaultEditorForType(const wxString& typeName) const wxGridCellRenderer* wxGrid::GetDefaultRendererForType(const wxString& typeName) const { - // first try to find an exact match - wxGridCellRenderer *renderer; - int index = m_typeRegistry->FindDataType(typeName); + int index = m_typeRegistry->FindOrCloneDataType(typeName); if ( index == wxNOT_FOUND ) { - // then try to construct a renderer from the base name and parameters - // following it - - // the first part of the typename is the "real" type, anything after ':' - // are the parameters for the renderer - index = m_typeRegistry->FindDataType(typeName.BeforeFirst(_T(':'))); - if ( index == wxNOT_FOUND ) - { - wxFAIL_MSG(wxT("Unknown data type name")); - - return NULL; - } - - renderer = m_typeRegistry->GetRenderer(index); - wxGridCellRenderer *rendererOld = renderer; - renderer = renderer->Clone(); - rendererOld->DecRef(); - - // do it even if there are no parameters to reset them to defaults - renderer->SetParameters(typeName.AfterFirst(_T(':'))); + wxFAIL_MSG(wxT("Unknown data type name")); - // register the new typename - m_typeRegistry->RegisterDataType(typeName, renderer, NULL); - } - else - { - renderer = m_typeRegistry->GetRenderer(index); + return NULL; } - return renderer; + return m_typeRegistry->GetRenderer(index); } diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 8f5de087be..e30e13f7b8 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -78,7 +78,7 @@ wxMenuBar::wxMenuBar( long style ) } PostCreation(); - + ApplyWidgetStyle(); } @@ -110,7 +110,7 @@ wxMenuBar::wxMenuBar() m_widget = GTK_WIDGET(m_menubar); PostCreation(); - + ApplyWidgetStyle(); } @@ -351,25 +351,25 @@ wxMenu *wxMenuBar::Remove(size_t pos) if ( !menu ) return (wxMenu*) NULL; - GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); /* + GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); printf( "factory entries before %d\n", (int)g_slist_length(m_factory->items) ); printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) ); */ - + // unparent calls unref() and that would delete the widget so we raise // the ref count to 2 artificially before invoking unparent. gtk_widget_ref( menu->m_menu ); gtk_widget_unparent( menu->m_menu ); - + gtk_widget_destroy( menu->m_owner ); - + /* printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) ); printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) ); */ - + return menu; } @@ -489,7 +489,7 @@ void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) { if (g_isIdle) wxapp_install_idle_handler(); - + int id = menu->FindMenuIdByMenuItem(widget); /* should find it for normal (not popup) menu */ diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 8f5de087be..e30e13f7b8 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -78,7 +78,7 @@ wxMenuBar::wxMenuBar( long style ) } PostCreation(); - + ApplyWidgetStyle(); } @@ -110,7 +110,7 @@ wxMenuBar::wxMenuBar() m_widget = GTK_WIDGET(m_menubar); PostCreation(); - + ApplyWidgetStyle(); } @@ -351,25 +351,25 @@ wxMenu *wxMenuBar::Remove(size_t pos) if ( !menu ) return (wxMenu*) NULL; - GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); /* + GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); printf( "factory entries before %d\n", (int)g_slist_length(m_factory->items) ); printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) ); */ - + // unparent calls unref() and that would delete the widget so we raise // the ref count to 2 artificially before invoking unparent. gtk_widget_ref( menu->m_menu ); gtk_widget_unparent( menu->m_menu ); - + gtk_widget_destroy( menu->m_owner ); - + /* printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) ); printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) ); */ - + return menu; } @@ -489,7 +489,7 @@ void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) { if (g_isIdle) wxapp_install_idle_handler(); - + int id = menu->FindMenuIdByMenuItem(widget); /* should find it for normal (not popup) menu */ diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index c4e85c8f19..e48ba50b35 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -420,7 +420,7 @@ void wxTextCtrl::SetValue(const wxString& value) if ( (value.length() > 0x400) || (value != GetValue()) ) { wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos); - + SetWindowText(GetHwnd(), valueDos.c_str()); AdjustSpaceLimit(); @@ -558,7 +558,7 @@ void wxTextCtrl::SetInsertionPoint(long pos) SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos)); #endif // Win32/16 - static const char *nothing = ""; + static const wxChar *nothing = _T(""); SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing); } -- 2.45.2