Second try at doing Set/GetClient right

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@967 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-11-06 13:13:43 +00:00
parent ed7174bafe
commit f5e27805de
18 changed files with 767 additions and 816 deletions

View File

@@ -296,6 +296,8 @@ public:
wxEVT_COMMAND_COMBOBOX_SELECTED
*/
class WXDLLEXPORT wxClientData;
class WXDLLEXPORT wxCommandEvent: public wxEvent
{
DECLARE_DYNAMIC_CLASS(wxCommandEvent)
@@ -308,10 +310,14 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent
*
*/
// Set/Get listbox/choice client data
// Set/Get client data from controls
inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline void *GetClientData() const { return m_clientData; }
// Set/Get client object from controls
inline void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; }
inline void *GetClientObject() const { return m_clientObject; }
// Get listbox selection if single-choice
inline int GetSelection() const { return m_commandInt; }
@@ -336,6 +342,7 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent
int m_commandInt;
long m_extraLong; // Additional information (e.g. select/deselect)
void* m_clientData; // Arbitrary client data
wxClientData* m_clientObject; // Arbitrary client object
};
// Scroll event class
@@ -979,7 +986,7 @@ public:
// the child which has the focus currently (may be NULL - use
// wxWindow::FindFocus then)
wxWindow* GetCurrentFocus() const { return (wxWindow *)m_clientData; }
void SetCurrentFocus(wxWindow *win) { m_clientData = (char *)win; }
void SetCurrentFocus(wxWindow *win) { m_clientData = (void *)win; }
};
/* TODO
@@ -1042,9 +1049,6 @@ class WXDLLEXPORT wxEvtHandler: public wxObject
virtual bool OnClose(void);
inline char *GetClientData(void) const { return m_clientData; }
inline void SetClientData(char *clientData) { m_clientData = clientData; }
virtual bool ProcessEvent(wxEvent& event);
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
@@ -1063,7 +1067,6 @@ protected:
protected:
wxEvtHandler* m_nextHandler;
wxEvtHandler* m_previousHandler;
char* m_clientData; // Any user client data
bool m_enabled; // Is event handler enabled?
wxList* m_dynamicEvents;

View File

@@ -87,6 +87,7 @@ public:
// implementation
wxList m_clientDataList;
wxList m_clientObjectList;
void AppendCommon( const wxString &item );
void ApplyWidgetStyle();

View File

@@ -106,6 +106,7 @@ public:
bool m_alreadySent;
wxList m_clientDataList;
wxList m_clientObjectList;
void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget();

View File

@@ -102,6 +102,7 @@ public:
GtkList *m_list;
wxList m_clientDataList;
wxList m_clientObjectList;
};
#endif // __GTKLISTBOXH__

View File

@@ -72,22 +72,6 @@ public:
virtual ~wxClientData() { }
};
//-----------------------------------------------------------------------------
// wxVoidClientData
//-----------------------------------------------------------------------------
class wxVoidClientData : public wxClientData
{
public:
wxVoidClientData() { m_data = NULL; }
wxVoidClientData( void *data ) { m_data = data; }
void SetData( void* data ) { m_data = data; }
void *GetData() const { return m_data; }
private:
void *m_data;
};
//-----------------------------------------------------------------------------
// wxStringClientData
//-----------------------------------------------------------------------------
@@ -196,7 +180,6 @@ public:
virtual void SetClientData( void *data );
virtual void *GetClientData();
virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -334,7 +317,8 @@ public:
bool m_isEnabled;
wxString m_windowName;
wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData;
wxClientData *m_clientObject;
void *m_clientData;
GtkWidget *m_widget;
GtkWidget *m_wxwindow;

View File

@@ -87,6 +87,7 @@ public:
// implementation
wxList m_clientDataList;
wxList m_clientObjectList;
void AppendCommon( const wxString &item );
void ApplyWidgetStyle();

View File

@@ -106,6 +106,7 @@ public:
bool m_alreadySent;
wxList m_clientDataList;
wxList m_clientObjectList;
void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget();

View File

@@ -102,6 +102,7 @@ public:
GtkList *m_list;
wxList m_clientDataList;
wxList m_clientObjectList;
};
#endif // __GTKLISTBOXH__

View File

@@ -72,22 +72,6 @@ public:
virtual ~wxClientData() { }
};
//-----------------------------------------------------------------------------
// wxVoidClientData
//-----------------------------------------------------------------------------
class wxVoidClientData : public wxClientData
{
public:
wxVoidClientData() { m_data = NULL; }
wxVoidClientData( void *data ) { m_data = data; }
void SetData( void* data ) { m_data = data; }
void *GetData() const { return m_data; }
private:
void *m_data;
};
//-----------------------------------------------------------------------------
// wxStringClientData
//-----------------------------------------------------------------------------
@@ -196,7 +180,6 @@ public:
virtual void SetClientData( void *data );
virtual void *GetClientData();
virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -334,7 +317,8 @@ public:
bool m_isEnabled;
wxString m_windowName;
wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData;
wxClientData *m_clientObject;
void *m_clientData;
GtkWidget *m_widget;
GtkWidget *m_wxwindow;

View File

@@ -104,6 +104,7 @@ wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId)
{
m_eventType = commandType;
m_clientData = (char *) NULL;
m_clientObject = (wxClientData *) NULL;
m_extraLong = 0;
m_commandInt = 0;
m_id = theId;
@@ -262,7 +263,6 @@ wxKeyEvent::wxKeyEvent(wxEventType type)
wxEvtHandler::wxEvtHandler(void)
{
m_clientData = (char *) NULL;
m_nextHandler = (wxEvtHandler *) NULL;
m_previousHandler = (wxEvtHandler *) NULL;
m_enabled = TRUE;

View File

@@ -70,6 +70,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item );
@@ -100,14 +101,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
wxChoice::~wxChoice()
{
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
Clear();
}
void wxChoice::AppendCommon( const wxString &item )
@@ -133,23 +127,23 @@ void wxChoice::AppendCommon( const wxString &item )
void wxChoice::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) NULL );
AppendCommon( item );
}
@@ -161,13 +155,7 @@ void wxChoice::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
node->SetData( (wxObject*) clientData );
}
void* wxChoice::GetClientData( int n )
@@ -177,18 +165,14 @@ void* wxChoice::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
return node->Data();
}
void wxChoice::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
@@ -201,13 +185,12 @@ wxClientData* wxChoice::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxChoice::Clear()
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
@@ -216,13 +199,15 @@ void wxChoice::Clear()
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientDataList.First();
wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
}

View File

@@ -82,6 +82,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientDataList.Append( (wxObject*)NULL );
m_clientObjectList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -149,23 +150,23 @@ void wxComboBox::AppendCommon( const wxString &item )
void wxComboBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) clientData );
AppendCommon( item );
}
@@ -177,13 +178,7 @@ void wxComboBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
node->SetData( (wxObject*) clientData );
}
void* wxComboBox::GetClientData( int n )
@@ -193,18 +188,14 @@ void* wxComboBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
return node->Data();
}
void wxComboBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
@@ -230,13 +221,15 @@ void wxComboBox::Clear()
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
wxNode *node = m_clientDataList.First();
wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
}
@@ -258,15 +251,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list );
g_list_free( list );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG( "wrong index" );
}
else
wxNode *node = m_clientObjectList.Nth( n );
if (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( node );
}
}

View File

@@ -101,6 +101,9 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] );
@@ -115,8 +118,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item );
m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item );
}
@@ -138,14 +139,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
wxListBox::~wxListBox()
{
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
Clear();
}
void wxListBox::AppendCommon( const wxString &item )
@@ -175,23 +169,23 @@ void wxListBox::AppendCommon( const wxString &item )
void wxListBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) NULL );
AppendCommon( item );
}
@@ -203,13 +197,7 @@ void wxListBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
node->SetData( (wxObject*) clientData );
}
void* wxListBox::GetClientData( int n )
@@ -219,18 +207,14 @@ void* wxListBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
return node->Data();
}
void wxListBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
@@ -243,7 +227,7 @@ wxClientData* wxListBox::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
@@ -255,13 +239,15 @@ void wxListBox::Clear()
gtk_list_clear_items( m_list, 0, Number() );
wxNode *node = m_clientDataList.First();
wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
}
@@ -281,15 +267,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list );
g_list_free( list );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG( "wrong index" );
}
else
wxNode *node = m_clientObjectList.Nth( n );
if (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( node );
}
}

View File

@@ -901,6 +901,7 @@ wxWindow::wxWindow()
m_wxwindow = (GtkWidget *) NULL;
m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE );
m_x = 0;
m_y = 0;
m_width = 0;
@@ -909,35 +910,48 @@ wxWindow::wxWindow()
m_minHeight = -1;
m_maxWidth = -1;
m_maxHeight = -1;
m_retCode = 0;
m_eventHandler = this;
m_windowValidator = (wxValidator *) NULL;
m_windowId = -1;
m_cursor = (wxCursor *) NULL;
m_font = *wxSWISS_FONT;
m_windowStyle = 0;
m_windowName = "noname";
m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
m_sizeSet = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment*) NULL;
m_vAdjust = (GtkAdjustment*) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget*) NULL;
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow;
m_clientObject = (wxClientData*) NULL;
m_clientData = NULL;
}
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@@ -1104,6 +1118,8 @@ wxWindow::~wxWindow()
wxTopLevelWindows.DeleteObject(this);
if (m_windowValidator) delete m_windowValidator;
if (m_clientObject) delete m_clientObject;
}
void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
@@ -1145,34 +1161,46 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_minHeight = -1;
m_maxWidth = -1;
m_maxHeight = -1;
m_retCode = 0;
m_eventHandler = this;
m_windowId = id;
m_sizeSet = FALSE;
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE;
// m_foregroundColour = wxBLACK;
m_windowStyle = style;
m_windowName = name;
m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_clientObject = (wxClientData*)NULL;
m_clientData = NULL;
}
void wxWindow::PostCreation()
@@ -1847,32 +1875,23 @@ void wxWindow::SetValidator( const wxValidator& validator )
void wxWindow::SetClientObject( wxClientData *data )
{
if (m_clientData) delete m_clientData;
m_clientData = data;
if (m_clientObject) delete m_clientObject;
m_clientObject = data;
}
wxClientData *wxWindow::GetClientObject()
{
return m_clientData;
return m_clientObject;
}
void wxWindow::SetClientData( void *data )
{
if (m_clientData) delete m_clientData;
if (data)
m_clientData = new wxVoidClientData( data );
else
m_clientData = (wxClientData*) NULL;
m_clientData = data;
}
void *wxWindow::GetClientData()
{
if (!m_clientData) return NULL;
wxVoidClientData *vd = (wxVoidClientData*) m_clientData;
return vd->GetData();
return m_clientData;
}
bool wxWindow::IsBeingDeleted()

View File

@@ -70,6 +70,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item );
@@ -100,14 +101,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
wxChoice::~wxChoice()
{
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
Clear();
}
void wxChoice::AppendCommon( const wxString &item )
@@ -133,23 +127,23 @@ void wxChoice::AppendCommon( const wxString &item )
void wxChoice::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) NULL );
AppendCommon( item );
}
@@ -161,13 +155,7 @@ void wxChoice::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
node->SetData( (wxObject*) clientData );
}
void* wxChoice::GetClientData( int n )
@@ -177,18 +165,14 @@ void* wxChoice::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
return node->Data();
}
void wxChoice::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
@@ -201,13 +185,12 @@ wxClientData* wxChoice::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxChoice::Clear()
{
wxCHECK_RET( m_widget != NULL, "invalid choice" );
@@ -216,13 +199,15 @@ void wxChoice::Clear()
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientDataList.First();
wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
}

View File

@@ -82,6 +82,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientDataList.Append( (wxObject*)NULL );
m_clientObjectList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -149,23 +150,23 @@ void wxComboBox::AppendCommon( const wxString &item )
void wxComboBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) clientData );
AppendCommon( item );
}
@@ -177,13 +178,7 @@ void wxComboBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
node->SetData( (wxObject*) clientData );
}
void* wxComboBox::GetClientData( int n )
@@ -193,18 +188,14 @@ void* wxComboBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
return node->Data();
}
void wxComboBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
@@ -230,13 +221,15 @@ void wxComboBox::Clear()
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
wxNode *node = m_clientDataList.First();
wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
}
@@ -258,15 +251,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list );
g_list_free( list );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG( "wrong index" );
}
else
wxNode *node = m_clientObjectList.Nth( n );
if (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( node );
}
}

View File

@@ -101,6 +101,9 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] );
@@ -115,8 +118,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item );
m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item );
}
@@ -138,14 +139,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
wxListBox::~wxListBox()
{
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
Clear();
}
void wxListBox::AppendCommon( const wxString &item )
@@ -175,23 +169,23 @@ void wxListBox::AppendCommon( const wxString &item )
void wxListBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
m_clientObjectList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) NULL );
AppendCommon( item );
}
@@ -203,13 +197,7 @@ void wxListBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
node->SetData( (wxObject*) clientData );
}
void* wxListBox::GetClientData( int n )
@@ -219,18 +207,14 @@ void* wxListBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
return node->Data();
}
void wxListBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
@@ -243,7 +227,7 @@ wxClientData* wxListBox::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientObjectList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
@@ -255,13 +239,15 @@ void wxListBox::Clear()
gtk_list_clear_items( m_list, 0, Number() );
wxNode *node = m_clientDataList.First();
wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
}
@@ -281,15 +267,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list );
g_list_free( list );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG( "wrong index" );
}
else
wxNode *node = m_clientObjectList.Nth( n );
if (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( node );
}
}

View File

@@ -901,6 +901,7 @@ wxWindow::wxWindow()
m_wxwindow = (GtkWidget *) NULL;
m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE );
m_x = 0;
m_y = 0;
m_width = 0;
@@ -909,35 +910,48 @@ wxWindow::wxWindow()
m_minHeight = -1;
m_maxWidth = -1;
m_maxHeight = -1;
m_retCode = 0;
m_eventHandler = this;
m_windowValidator = (wxValidator *) NULL;
m_windowId = -1;
m_cursor = (wxCursor *) NULL;
m_font = *wxSWISS_FONT;
m_windowStyle = 0;
m_windowName = "noname";
m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
m_sizeSet = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment*) NULL;
m_vAdjust = (GtkAdjustment*) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget*) NULL;
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow;
m_clientObject = (wxClientData*) NULL;
m_clientData = NULL;
}
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@@ -1104,6 +1118,8 @@ wxWindow::~wxWindow()
wxTopLevelWindows.DeleteObject(this);
if (m_windowValidator) delete m_windowValidator;
if (m_clientObject) delete m_clientObject;
}
void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
@@ -1145,34 +1161,46 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_minHeight = -1;
m_maxWidth = -1;
m_maxHeight = -1;
m_retCode = 0;
m_eventHandler = this;
m_windowId = id;
m_sizeSet = FALSE;
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE;
// m_foregroundColour = wxBLACK;
m_windowStyle = style;
m_windowName = name;
m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_clientObject = (wxClientData*)NULL;
m_clientData = NULL;
}
void wxWindow::PostCreation()
@@ -1847,32 +1875,23 @@ void wxWindow::SetValidator( const wxValidator& validator )
void wxWindow::SetClientObject( wxClientData *data )
{
if (m_clientData) delete m_clientData;
m_clientData = data;
if (m_clientObject) delete m_clientObject;
m_clientObject = data;
}
wxClientData *wxWindow::GetClientObject()
{
return m_clientData;
return m_clientObject;
}
void wxWindow::SetClientData( void *data )
{
if (m_clientData) delete m_clientData;
if (data)
m_clientData = new wxVoidClientData( data );
else
m_clientData = (wxClientData*) NULL;
m_clientData = data;
}
void *wxWindow::GetClientData()
{
if (!m_clientData) return NULL;
wxVoidClientData *vd = (wxVoidClientData*) m_clientData;
return vd->GetData();
return m_clientData;
}
bool wxWindow::IsBeingDeleted()