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
This commit is contained in:
Vadim Zeitlin
2000-03-01 18:55:29 +00:00
parent 66eca538a0
commit c4608a8af3
6 changed files with 311 additions and 127 deletions

View File

@@ -58,6 +58,7 @@
#define wxGRID_VALUE_BOOL _T("bool") #define wxGRID_VALUE_BOOL _T("bool")
#define wxGRID_VALUE_NUMBER _T("long") #define wxGRID_VALUE_NUMBER _T("long")
#define wxGRID_VALUE_FLOAT _T("double") #define wxGRID_VALUE_FLOAT _T("double")
#define wxGRID_VALUE_CHOICE _T("choice")
#define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
#define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
@@ -89,17 +90,17 @@ class WXDLLEXPORT wxSpinCtrl;
#define wxSafeDecRef(p) if ( p ) (p)->DecRef() #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxGridCellRenderer: this class is responsible for actually drawing the cell // wxGridCellWorker: common base class for wxGridCellRenderer and
// in the grid. You may pass it to the wxGridCellAttr (below) to change the // wxGridCellEditor
// 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 // NB: this is more an implementation convenience than a design issue, so this
// predefined derived classes or derive your own class from it. // class is not documented and is not public at all
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxGridCellRenderer class WXDLLEXPORT wxGridCellWorker
{ {
public: public:
wxGridCellRenderer() { m_nRef = 1; } wxGridCellWorker() { m_nRef = 1; }
// this class is ref counted: it is created with ref count of 1, so // 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 // calling DecRef() once will delete it. Calling IncRef() allows to lock
@@ -107,6 +108,34 @@ public:
void IncRef() { m_nRef++; } void IncRef() { m_nRef++; }
void DecRef() { if ( !--m_nRef ) delete this; } 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 // draw the given cell on the provided DC inside the given rectangle
// using the style specified by the attribute and the default or selected // using the style specified by the attribute and the default or selected
// state corresponding to the isSelected value. // state corresponding to the isSelected value.
@@ -127,24 +156,8 @@ public:
wxDC& dc, wxDC& dc,
int row, int col) = 0; 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 // create a new object which is the copy of this one
virtual wxGridCellRenderer *Clone() const = 0; 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 // the default renderer for the cells containing string data
@@ -278,17 +291,11 @@ private:
// even for the entire grid. // even for the entire grid.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxGridCellEditor class WXDLLEXPORT wxGridCellEditor : public wxGridCellWorker
{ {
public: public:
wxGridCellEditor(); 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; } bool IsCreated() { return m_control != NULL; }
// Creates the actual edit control // Creates the actual edit control
@@ -334,13 +341,13 @@ public:
// Final cleanup // Final cleanup
virtual void Destroy(); virtual void Destroy();
// create a new object which is the copy of this one
virtual wxGridCellEditor *Clone() const = 0;
protected: protected:
// the dtor is private because only DecRef() can delete us // the dtor is private because only DecRef() can delete us
virtual ~wxGridCellEditor(); virtual ~wxGridCellEditor();
// the ref count - when it goes to 0, we die
size_t m_nRef;
// the control we show on screen // the control we show on screen
wxControl* m_control; wxControl* m_control;
@@ -376,6 +383,12 @@ public:
virtual void StartingKey(wxKeyEvent& event); virtual void StartingKey(wxKeyEvent& event);
virtual void HandleReturn(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: protected:
wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; } wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
@@ -384,6 +397,7 @@ protected:
void DoReset(const wxString& startValue); void DoReset(const wxString& startValue);
private: private:
size_t m_maxChars; // max number of chars allowed
wxString m_startValue; wxString m_startValue;
}; };
@@ -405,6 +419,12 @@ public:
virtual void Reset(); virtual void Reset();
virtual void StartingKey(wxKeyEvent& event); 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: protected:
wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; } wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }
@@ -436,6 +456,9 @@ public:
virtual void Reset(); virtual void Reset();
virtual void StartingKey(wxKeyEvent& event); virtual void StartingKey(wxKeyEvent& event);
virtual wxGridCellEditor *Clone() const
{ return new wxGridCellFloatEditor; }
protected: protected:
// string representation of m_valueOld // string representation of m_valueOld
wxString GetString() const wxString GetString() const
@@ -462,6 +485,9 @@ public:
virtual void Reset(); virtual void Reset();
virtual void StartingClick(); virtual void StartingClick();
virtual wxGridCellEditor *Clone() const
{ return new wxGridCellBoolEditor; }
protected: protected:
wxCheckBox *CBox() const { return (wxCheckBox *)m_control; } wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }
@@ -474,7 +500,8 @@ class WXDLLEXPORT wxGridCellChoiceEditor : public wxGridCellEditor
{ {
public: public:
// if !allowOthers, user can't type a string not in choices array // 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); bool allowOthers = FALSE);
virtual void Create(wxWindow* parent, virtual void Create(wxWindow* parent,
@@ -488,6 +515,11 @@ public:
virtual void Reset(); virtual void Reset();
// parameters string format is "item1[,item2[...,itemN]]"
virtual void SetParameters(const wxString& params);
virtual wxGridCellEditor *Clone() const;
protected: protected:
wxComboBox *Combo() const { return (wxComboBox *)m_control; } wxComboBox *Combo() const { return (wxComboBox *)m_control; }

View File

@@ -669,9 +669,9 @@ void GridFrame::OnVTable(wxCommandEvent& )
s = wxGetTextFromUser( "Size of the table to create", s = wxGetTextFromUser( "Size of the table to create",
"Size:", "Size:",
s ); s );
s.ToLong( &s_sizeGrid ); s.ToLong( &s_sizeGrid );
#else #else
s_sizeGrid = wxGetNumberFromUser("Size of the table to create", s_sizeGrid = wxGetNumberFromUser("Size of the table to create",
"Size: ", "Size: ",
@@ -679,7 +679,7 @@ void GridFrame::OnVTable(wxCommandEvent& )
s_sizeGrid, s_sizeGrid,
0, 32000, this); 0, 32000, this);
#endif #endif
if ( s_sizeGrid != -1 ) if ( s_sizeGrid != -1 )
{ {
BigGridFrame* win = new BigGridFrame(s_sizeGrid); BigGridFrame* win = new BigGridFrame(s_sizeGrid);
@@ -828,7 +828,7 @@ static struct BugsGridData
Severity severity; Severity severity;
int prio; int prio;
#ifndef __BORLANDC__ #ifndef __BORLANDC__
wxString platform; wxString platform;
#else #else
@@ -836,7 +836,7 @@ static struct BugsGridData
#endif #endif
bool opened; bool opened;
} gs_dataBugsGrid [] = } gs_dataBugsGrid [] =
{ {
{ 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), TRUE }, { 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), TRUE },
{ 27, _T("bar crashes"), Sev_Critical, 1, _T("all"), FALSE }, { 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) // fall thorugh (TODO should be a list)
case Col_Summary: case Col_Summary:
return wxString::Format(_T("%s:80"), wxGRID_VALUE_STRING);
case Col_Platform: case Col_Platform:
return wxGRID_VALUE_STRING; return wxString::Format(_T("%s:all,MSW,GTK,other"), wxGRID_VALUE_CHOICE);
case Col_Opened: case Col_Opened:
return wxGRID_VALUE_BOOL; return wxGRID_VALUE_BOOL;
@@ -970,7 +972,7 @@ void BugsGridTable::SetValue( int row, int col, const wxString& value )
case Col_Platform: case Col_Platform:
#ifndef __BORLANDC__ #ifndef __BORLANDC__
gd.platform = value; gd.platform = value;
#else #else
// this generates a warning message if you are using the // this generates a warning message if you are using the
// memory tracing code but it should be ok :MB // memory tracing code but it should be ok :MB
// //

View File

@@ -47,6 +47,7 @@
#include "wx/textfile.h" #include "wx/textfile.h"
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
#include "wx/tokenzr.h"
#include "wx/grid.h" #include "wx/grid.h"
@@ -286,7 +287,19 @@ public:
void RegisterDataType(const wxString& typeName, void RegisterDataType(const wxString& typeName,
wxGridCellRenderer* renderer, wxGridCellRenderer* renderer,
wxGridCellEditor* editor); 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); 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); wxGridCellRenderer* GetRenderer(int index);
wxGridCellEditor* GetEditor(int index); wxGridCellEditor* GetEditor(int index);
@@ -338,8 +351,6 @@ static const int GRID_HASH_SIZE = 100;
wxGridCellEditor::wxGridCellEditor() wxGridCellEditor::wxGridCellEditor()
{ {
m_control = NULL; m_control = NULL;
m_nRef = 1;
} }
@@ -455,6 +466,7 @@ void wxGridCellEditor::StartingClick()
wxGridCellTextEditor::wxGridCellTextEditor() wxGridCellTextEditor::wxGridCellTextEditor()
{ {
m_maxChars = 0;
} }
void wxGridCellTextEditor::Create(wxWindow* parent, void wxGridCellTextEditor::Create(wxWindow* parent,
@@ -468,6 +480,8 @@ void wxGridCellTextEditor::Create(wxWindow* parent,
#endif #endif
); );
// TODO: use m_maxChars
wxGridCellEditor::Create(parent, id, evtHandler); wxGridCellEditor::Create(parent, id, evtHandler);
} }
@@ -604,6 +618,28 @@ void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event)
#endif #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 // wxGridCellNumberEditor
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -723,6 +759,35 @@ void wxGridCellNumberEditor::StartingKey(wxKeyEvent& event)
event.Skip(); 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 // wxGridCellFloatEditor
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -925,13 +990,25 @@ wxGridCellChoiceEditor::wxGridCellChoiceEditor(size_t count,
bool allowOthers) bool allowOthers)
: m_allowOthers(allowOthers) : m_allowOthers(allowOthers)
{ {
m_choices.Alloc(count); if ( count )
for ( size_t n = 0; n < count; n++ )
{ {
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, void wxGridCellChoiceEditor::Create(wxWindow* parent,
wxWindowID id, wxWindowID id,
wxEvtHandler* evtHandler) wxEvtHandler* evtHandler)
@@ -1007,6 +1084,23 @@ void wxGridCellChoiceEditor::Reset()
Combo()->SetInsertionPointEnd(); 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 // 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 // renderer classes
// ============================================================================ // ============================================================================
@@ -1079,15 +1187,6 @@ void wxGridCellRenderer::Draw(wxGrid& grid,
dc.DrawRectangle(rect); dc.DrawRectangle(rect);
} }
void wxGridCellRenderer::SetParameters(const wxString& WXUNUSED(params))
{
// nothing to do
}
wxGridCellRenderer::~wxGridCellRenderer()
{
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxGridCellStringRenderer // wxGridCellStringRenderer
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1917,7 +2016,7 @@ void wxGridTypeRegistry::RegisterDataType(const wxString& typeName,
wxGridDataTypeInfo* info = new wxGridDataTypeInfo(typeName, renderer, editor); wxGridDataTypeInfo* info = new wxGridDataTypeInfo(typeName, renderer, editor);
// is it already registered? // is it already registered?
int loc = FindDataType(typeName); int loc = FindRegisteredDataType(typeName);
if ( loc != wxNOT_FOUND ) if ( loc != wxNOT_FOUND )
{ {
delete m_typeinfo[loc]; delete m_typeinfo[loc];
@@ -1929,18 +2028,108 @@ void wxGridTypeRegistry::RegisterDataType(const wxString& typeName,
} }
} }
int wxGridTypeRegistry::FindDataType(const wxString& typeName) int wxGridTypeRegistry::FindRegisteredDataType(const wxString& typeName)
{ {
int found = -1; size_t count = m_typeinfo.GetCount();
for ( size_t i = 0; i < count; i++ )
for (size_t i=0; i<m_typeinfo.Count(); i++) { {
if (typeName == m_typeinfo[i]->m_typeName) { if ( typeName == m_typeinfo[i]->m_typeName )
found = i; {
break; return i;
} }
} }
return found; return wxNOT_FOUND;
}
int wxGridTypeRegistry::FindDataType(const wxString& typeName)
{
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;
}
// 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 index;
} }
wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index) wxGridCellRenderer* wxGridTypeRegistry::GetRenderer(int index)
@@ -2928,21 +3117,8 @@ void wxGrid::Create()
m_rowLabelWidth = WXGRID_DEFAULT_ROW_LABEL_WIDTH; m_rowLabelWidth = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT; m_colLabelHeight = WXGRID_DEFAULT_COL_LABEL_HEIGHT;
// data type registration: register all standard data types // create the type registry
// TODO: may be allow the app to selectively disable some of them?
m_typeRegistry = new wxGridTypeRegistry; 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 // subwindow components that make up the wxGrid
m_cornerLabelWin = new wxGridCornerLabelWindow( this, m_cornerLabelWin = new wxGridCornerLabelWindow( this,
@@ -6933,7 +7109,7 @@ wxGridCellRenderer* wxGrid::GetDefaultRendererForCell(int row, int col) const
wxGridCellEditor* wxGridCellEditor*
wxGrid::GetDefaultEditorForType(const wxString& typeName) const wxGrid::GetDefaultEditorForType(const wxString& typeName) const
{ {
int index = m_typeRegistry->FindDataType(typeName); int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND ) if ( index == wxNOT_FOUND )
{ {
wxFAIL_MSG(wxT("Unknown data type name")); wxFAIL_MSG(wxT("Unknown data type name"));
@@ -6947,41 +7123,15 @@ wxGrid::GetDefaultEditorForType(const wxString& typeName) const
wxGridCellRenderer* wxGridCellRenderer*
wxGrid::GetDefaultRendererForType(const wxString& typeName) const wxGrid::GetDefaultRendererForType(const wxString& typeName) const
{ {
// first try to find an exact match int index = m_typeRegistry->FindOrCloneDataType(typeName);
wxGridCellRenderer *renderer;
int index = m_typeRegistry->FindDataType(typeName);
if ( index == wxNOT_FOUND ) if ( index == wxNOT_FOUND )
{ {
// then try to construct a renderer from the base name and parameters wxFAIL_MSG(wxT("Unknown data type name"));
// following it
// the first part of the typename is the "real" type, anything after ':' return NULL;
// 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(':')));
// register the new typename
m_typeRegistry->RegisterDataType(typeName, renderer, NULL);
}
else
{
renderer = m_typeRegistry->GetRenderer(index);
} }
return renderer; return m_typeRegistry->GetRenderer(index);
} }

View File

@@ -78,7 +78,7 @@ wxMenuBar::wxMenuBar( long style )
} }
PostCreation(); PostCreation();
ApplyWidgetStyle(); ApplyWidgetStyle();
} }
@@ -110,7 +110,7 @@ wxMenuBar::wxMenuBar()
m_widget = GTK_WIDGET(m_menubar); m_widget = GTK_WIDGET(m_menubar);
PostCreation(); PostCreation();
ApplyWidgetStyle(); ApplyWidgetStyle();
} }
@@ -351,25 +351,25 @@ wxMenu *wxMenuBar::Remove(size_t pos)
if ( !menu ) if ( !menu )
return (wxMenu*) NULL; 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( "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 ) ); 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 // unparent calls unref() and that would delete the widget so we raise
// the ref count to 2 artificially before invoking unparent. // the ref count to 2 artificially before invoking unparent.
gtk_widget_ref( menu->m_menu ); gtk_widget_ref( menu->m_menu );
gtk_widget_unparent( menu->m_menu ); gtk_widget_unparent( menu->m_menu );
gtk_widget_destroy( menu->m_owner ); gtk_widget_destroy( menu->m_owner );
/* /*
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) ); 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 ) ); printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
*/ */
return menu; 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 ) static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
{ {
if (g_isIdle) wxapp_install_idle_handler(); if (g_isIdle) wxapp_install_idle_handler();
int id = menu->FindMenuIdByMenuItem(widget); int id = menu->FindMenuIdByMenuItem(widget);
/* should find it for normal (not popup) menu */ /* should find it for normal (not popup) menu */

View File

@@ -78,7 +78,7 @@ wxMenuBar::wxMenuBar( long style )
} }
PostCreation(); PostCreation();
ApplyWidgetStyle(); ApplyWidgetStyle();
} }
@@ -110,7 +110,7 @@ wxMenuBar::wxMenuBar()
m_widget = GTK_WIDGET(m_menubar); m_widget = GTK_WIDGET(m_menubar);
PostCreation(); PostCreation();
ApplyWidgetStyle(); ApplyWidgetStyle();
} }
@@ -351,25 +351,25 @@ wxMenu *wxMenuBar::Remove(size_t pos)
if ( !menu ) if ( !menu )
return (wxMenu*) NULL; 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( "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 ) ); 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 // unparent calls unref() and that would delete the widget so we raise
// the ref count to 2 artificially before invoking unparent. // the ref count to 2 artificially before invoking unparent.
gtk_widget_ref( menu->m_menu ); gtk_widget_ref( menu->m_menu );
gtk_widget_unparent( menu->m_menu ); gtk_widget_unparent( menu->m_menu );
gtk_widget_destroy( menu->m_owner ); gtk_widget_destroy( menu->m_owner );
/* /*
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) ); 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 ) ); printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
*/ */
return menu; 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 ) static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
{ {
if (g_isIdle) wxapp_install_idle_handler(); if (g_isIdle) wxapp_install_idle_handler();
int id = menu->FindMenuIdByMenuItem(widget); int id = menu->FindMenuIdByMenuItem(widget);
/* should find it for normal (not popup) menu */ /* should find it for normal (not popup) menu */

View File

@@ -420,7 +420,7 @@ void wxTextCtrl::SetValue(const wxString& value)
if ( (value.length() > 0x400) || (value != GetValue()) ) if ( (value.length() > 0x400) || (value != GetValue()) )
{ {
wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos); wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
SetWindowText(GetHwnd(), valueDos.c_str()); SetWindowText(GetHwnd(), valueDos.c_str());
AdjustSpaceLimit(); AdjustSpaceLimit();
@@ -558,7 +558,7 @@ void wxTextCtrl::SetInsertionPoint(long pos)
SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos)); SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos));
#endif // Win32/16 #endif // Win32/16
static const char *nothing = ""; static const wxChar *nothing = _T("");
SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing); SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing);
} }