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

View File

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

View File

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

View File

@@ -101,7 +101,8 @@ public:
void ApplyWidgetStyle(); void ApplyWidgetStyle();
GtkList *m_list; GtkList *m_list;
wxList m_clientDataList; wxList m_clientDataList;
wxList m_clientObjectList;
}; };
#endif // __GTKLISTBOXH__ #endif // __GTKLISTBOXH__

View File

@@ -72,22 +72,6 @@ public:
virtual ~wxClientData() { } 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 // wxStringClientData
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -195,7 +179,6 @@ public:
virtual void SetClientData( void *data ); virtual void SetClientData( void *data );
virtual void *GetClientData(); virtual void *GetClientData();
virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -334,7 +317,8 @@ public:
bool m_isEnabled; bool m_isEnabled;
wxString m_windowName; wxString m_windowName;
wxAcceleratorTable m_acceleratorTable; wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData; wxClientData *m_clientObject;
void *m_clientData;
GtkWidget *m_widget; GtkWidget *m_widget;
GtkWidget *m_wxwindow; GtkWidget *m_wxwindow;

View File

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

View File

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

View File

@@ -101,7 +101,8 @@ public:
void ApplyWidgetStyle(); void ApplyWidgetStyle();
GtkList *m_list; GtkList *m_list;
wxList m_clientDataList; wxList m_clientDataList;
wxList m_clientObjectList;
}; };
#endif // __GTKLISTBOXH__ #endif // __GTKLISTBOXH__

View File

@@ -72,22 +72,6 @@ public:
virtual ~wxClientData() { } 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 // wxStringClientData
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -195,7 +179,6 @@ public:
virtual void SetClientData( void *data ); virtual void SetClientData( void *data );
virtual void *GetClientData(); virtual void *GetClientData();
virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -334,7 +317,8 @@ public:
bool m_isEnabled; bool m_isEnabled;
wxString m_windowName; wxString m_windowName;
wxAcceleratorTable m_acceleratorTable; wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData; wxClientData *m_clientObject;
void *m_clientData;
GtkWidget *m_widget; GtkWidget *m_widget;
GtkWidget *m_wxwindow; GtkWidget *m_wxwindow;

View File

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

View File

@@ -55,7 +55,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
SetValidator( validator ); SetValidator( validator );
m_widget = gtk_option_menu_new(); m_widget = gtk_option_menu_new();
@@ -70,7 +70,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
m_clientDataList.Append( (wxObject*) NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] ); GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item ); gtk_menu_append( GTK_MENU(menu), item );
@@ -100,14 +101,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
wxChoice::~wxChoice() wxChoice::~wxChoice()
{ {
wxNode *node = m_clientDataList.First(); Clear();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxChoice::AppendCommon( const wxString &item ) void wxChoice::AppendCommon( const wxString &item )
@@ -132,24 +126,24 @@ void wxChoice::AppendCommon( const wxString &item )
void wxChoice::Append( const wxString &item ) void wxChoice::Append( const wxString &item )
{ {
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxChoice::Append( const wxString &item, void *clientData ) void wxChoice::Append( const wxString &item, void *clientData )
{ {
if (clientData) m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) ); m_clientObjectList.Append( (wxObject*) NULL );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxChoice::Append( const wxString &item, wxClientData *clientData ) 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 ); AppendCommon( item );
} }
@@ -161,13 +155,7 @@ void wxChoice::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); node->SetData( (wxObject*) clientData );
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
} }
void* wxChoice::GetClientData( int n ) void* wxChoice::GetClientData( int n )
@@ -177,36 +165,31 @@ void* wxChoice::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL; if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data(); return node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
} }
void wxChoice::SetClientObject( int n, wxClientData* clientData ) void wxChoice::SetClientObject( int n, wxClientData* clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd; if (cd) delete cd;
node->SetData( (wxObject*) clientData ); node->SetData( (wxObject*) clientData );
} }
wxClientData* wxChoice::GetClientObject( int n ) wxClientData* wxChoice::GetClientObject( int n )
{ {
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" ); 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; if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data(); return (wxClientData*) node->Data();
} }
void wxChoice::Clear() void wxChoice::Clear()
{ {
@@ -216,13 +199,15 @@ void wxChoice::Clear()
GtkWidget *menu = gtk_menu_new(); GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientDataList.First(); wxNode *node = m_clientObjectList.First();
while (node) while (node)
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
node = node->Next(); node = node->Next();
} }
m_clientObjectList.Clear();
m_clientDataList.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] ); GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*)NULL );
m_clientObjectList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -148,24 +149,24 @@ void wxComboBox::AppendCommon( const wxString &item )
void wxComboBox::Append( const wxString &item ) void wxComboBox::Append( const wxString &item )
{ {
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxComboBox::Append( const wxString &item, void *clientData ) void wxComboBox::Append( const wxString &item, void *clientData )
{ {
if (clientData) m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) ); m_clientObjectList.Append( (wxObject*)NULL );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxComboBox::Append( const wxString &item, wxClientData *clientData ) 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 ); AppendCommon( item );
} }
@@ -177,13 +178,7 @@ void wxComboBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); node->SetData( (wxObject*) clientData );
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
} }
void* wxComboBox::GetClientData( int n ) void* wxComboBox::GetClientData( int n )
@@ -193,23 +188,19 @@ void* wxComboBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL; if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data(); return node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
} }
void wxComboBox::SetClientObject( int n, wxClientData* clientData ) void wxComboBox::SetClientObject( int n, wxClientData* clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd; if (cd) delete cd;
node->SetData( (wxObject*) clientData ); node->SetData( (wxObject*) clientData );
} }
@@ -230,13 +221,15 @@ void wxComboBox::Clear()
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() ); gtk_list_clear_items( GTK_LIST(list), 0, Number() );
wxNode *node = m_clientDataList.First(); wxNode *node = m_clientObjectList.First();
while (node) while (node)
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
node = node->Next(); node = node->Next();
} }
m_clientObjectList.Clear();
m_clientDataList.Clear(); m_clientDataList.Clear();
} }
@@ -258,15 +251,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list ); gtk_list_remove_items( listbox, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) if (node)
{
wxFAIL_MSG( "wrong index" );
}
else
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( 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++) for (int i = 0; i < n; i++)
{ {
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *list_item; GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] ); list_item = gtk_list_item_new_with_label( choices[i] );
@@ -115,8 +118,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item ); ConnectWidget( list_item );
m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
@@ -138,14 +139,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
wxListBox::~wxListBox() wxListBox::~wxListBox()
{ {
wxNode *node = m_clientDataList.First(); Clear();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxListBox::AppendCommon( const wxString &item ) void wxListBox::AppendCommon( const wxString &item )
@@ -174,24 +168,24 @@ void wxListBox::AppendCommon( const wxString &item )
void wxListBox::Append( const wxString &item ) void wxListBox::Append( const wxString &item )
{ {
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxListBox::Append( const wxString &item, void *clientData ) void wxListBox::Append( const wxString &item, void *clientData )
{ {
if (clientData) m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) ); m_clientObjectList.Append( (wxObject*) NULL );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxListBox::Append( const wxString &item, wxClientData *clientData ) 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 ); AppendCommon( item );
} }
@@ -203,13 +197,7 @@ void wxListBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); node->SetData( (wxObject*) clientData );
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
} }
void* wxListBox::GetClientData( int n ) void* wxListBox::GetClientData( int n )
@@ -219,18 +207,14 @@ void* wxListBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL; if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data(); return node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
} }
void wxListBox::SetClientObject( int n, wxClientData* clientData ) void wxListBox::SetClientObject( int n, wxClientData* clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); wxClientData *cd = (wxClientData*) node->Data();
@@ -243,7 +227,7 @@ wxClientData* wxListBox::GetClientObject( int n )
{ {
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" ); 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; if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data(); return (wxClientData*) node->Data();
@@ -255,13 +239,15 @@ void wxListBox::Clear()
gtk_list_clear_items( m_list, 0, Number() ); gtk_list_clear_items( m_list, 0, Number() );
wxNode *node = m_clientDataList.First(); wxNode *node = m_clientObjectList.First();
while (node) while (node)
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
node = node->Next(); node = node->Next();
} }
m_clientObjectList.Clear();
m_clientDataList.Clear(); m_clientDataList.Clear();
} }
@@ -281,15 +267,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list ); gtk_list_remove_items( m_list, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) if (node)
{
wxFAIL_MSG( "wrong index" );
}
else
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( node ); m_clientDataList.DeleteNode( node );
} }
} }

View File

@@ -124,28 +124,28 @@ static guint32 gs_timeLastClick = 0;
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( gdk_event->area.x, win->m_updateRegion.Union( gdk_event->area.x,
gdk_event->area.y, gdk_event->area.y,
gdk_event->area.width, gdk_event->area.width,
gdk_event->area.height ); gdk_event->area.height );
if (gdk_event->count > 0) return; if (gdk_event->count > 0) return;
/* /*
printf( "OnExpose from " ); printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
win->m_updateRegion.Clear(); win->m_updateRegion.Clear();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -154,16 +154,16 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
win->m_updateRegion.Clear(); win->m_updateRegion.Clear();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -172,131 +172,131 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{ {
if (!win->HasVMT()) return FALSE; if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnDrag) return FALSE;
/* /*
printf( "OnKeyPress from " ); printf( "OnKeyPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
long key_code = 0; long key_code = 0;
switch (gdk_event->keyval) switch (gdk_event->keyval)
{
case GDK_BackSpace: key_code = WXK_BACK; break;
case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
case GDK_Clear: key_code = WXK_CLEAR; break;
case GDK_Return: key_code = WXK_RETURN; break;
case GDK_Pause: key_code = WXK_PAUSE; break;
case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
case GDK_Escape: key_code = WXK_ESCAPE; break;
case GDK_Delete: key_code = WXK_DELETE; break;
case GDK_Home: key_code = WXK_HOME; break;
case GDK_Left: key_code = WXK_LEFT; break;
case GDK_Up: key_code = WXK_UP; break;
case GDK_Right: key_code = WXK_RIGHT; break;
case GDK_Down: key_code = WXK_DOWN; break;
case GDK_Prior: key_code = WXK_PRIOR; break;
// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_Next: key_code = WXK_NEXT; break;
// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_End: key_code = WXK_END; break;
case GDK_Begin: key_code = WXK_HOME; break;
case GDK_Select: key_code = WXK_SELECT; break;
case GDK_Print: key_code = WXK_PRINT; break;
case GDK_Execute: key_code = WXK_EXECUTE; break;
case GDK_Insert: key_code = WXK_INSERT; break;
case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
case GDK_KP_Tab: key_code = WXK_TAB; break;
case GDK_KP_Enter: key_code = WXK_RETURN; break;
case GDK_KP_Home: key_code = WXK_HOME; break;
case GDK_KP_Left: key_code = WXK_LEFT; break;
case GDK_KP_Up: key_code = WXK_UP; break;
case GDK_KP_Right: key_code = WXK_RIGHT; break;
case GDK_KP_Down: key_code = WXK_DOWN; break;
case GDK_KP_Prior: key_code = WXK_PRIOR; break;
// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_KP_Next: key_code = WXK_NEXT; break;
// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_KP_End: key_code = WXK_END; break;
case GDK_KP_Begin: key_code = WXK_HOME; break;
case GDK_KP_Insert: key_code = WXK_INSERT; break;
case GDK_KP_Delete: key_code = WXK_DELETE; break;
case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break;
case GDK_KP_Add: key_code = WXK_ADD; break;
case GDK_KP_Separator: key_code = WXK_SEPARATOR; break;
case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break;
case GDK_KP_Decimal: key_code = WXK_DECIMAL; break;
case GDK_KP_Divide: key_code = WXK_DIVIDE; break;
case GDK_KP_0: key_code = WXK_NUMPAD0; break;
case GDK_KP_1: key_code = WXK_NUMPAD1; break;
case GDK_KP_2: key_code = WXK_NUMPAD2; break;
case GDK_KP_3: key_code = WXK_NUMPAD3; break;
case GDK_KP_4: key_code = WXK_NUMPAD4; break;
case GDK_KP_5: key_code = WXK_NUMPAD5; break;
case GDK_KP_6: key_code = WXK_NUMPAD6; break;
case GDK_KP_7: key_code = WXK_NUMPAD7; break;
case GDK_KP_8: key_code = WXK_NUMPAD7; break;
case GDK_KP_9: key_code = WXK_NUMPAD9; break;
case GDK_F1: key_code = WXK_F1; break;
case GDK_F2: key_code = WXK_F2; break;
case GDK_F3: key_code = WXK_F3; break;
case GDK_F4: key_code = WXK_F4; break;
case GDK_F5: key_code = WXK_F5; break;
case GDK_F6: key_code = WXK_F6; break;
case GDK_F7: key_code = WXK_F7; break;
case GDK_F8: key_code = WXK_F8; break;
case GDK_F9: key_code = WXK_F9; break;
case GDK_F10: key_code = WXK_F10; break;
case GDK_F11: key_code = WXK_F11; break;
case GDK_F12: key_code = WXK_F12; break;
default:
{ {
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) case GDK_BackSpace: key_code = WXK_BACK; break;
key_code = gdk_event->keyval; case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
case GDK_Clear: key_code = WXK_CLEAR; break;
case GDK_Return: key_code = WXK_RETURN; break;
case GDK_Pause: key_code = WXK_PAUSE; break;
case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
case GDK_Escape: key_code = WXK_ESCAPE; break;
case GDK_Delete: key_code = WXK_DELETE; break;
case GDK_Home: key_code = WXK_HOME; break;
case GDK_Left: key_code = WXK_LEFT; break;
case GDK_Up: key_code = WXK_UP; break;
case GDK_Right: key_code = WXK_RIGHT; break;
case GDK_Down: key_code = WXK_DOWN; break;
case GDK_Prior: key_code = WXK_PRIOR; break;
// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_Next: key_code = WXK_NEXT; break;
// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_End: key_code = WXK_END; break;
case GDK_Begin: key_code = WXK_HOME; break;
case GDK_Select: key_code = WXK_SELECT; break;
case GDK_Print: key_code = WXK_PRINT; break;
case GDK_Execute: key_code = WXK_EXECUTE; break;
case GDK_Insert: key_code = WXK_INSERT; break;
case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
case GDK_KP_Tab: key_code = WXK_TAB; break;
case GDK_KP_Enter: key_code = WXK_RETURN; break;
case GDK_KP_Home: key_code = WXK_HOME; break;
case GDK_KP_Left: key_code = WXK_LEFT; break;
case GDK_KP_Up: key_code = WXK_UP; break;
case GDK_KP_Right: key_code = WXK_RIGHT; break;
case GDK_KP_Down: key_code = WXK_DOWN; break;
case GDK_KP_Prior: key_code = WXK_PRIOR; break;
// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_KP_Next: key_code = WXK_NEXT; break;
// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_KP_End: key_code = WXK_END; break;
case GDK_KP_Begin: key_code = WXK_HOME; break;
case GDK_KP_Insert: key_code = WXK_INSERT; break;
case GDK_KP_Delete: key_code = WXK_DELETE; break;
case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break;
case GDK_KP_Add: key_code = WXK_ADD; break;
case GDK_KP_Separator: key_code = WXK_SEPARATOR; break;
case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break;
case GDK_KP_Decimal: key_code = WXK_DECIMAL; break;
case GDK_KP_Divide: key_code = WXK_DIVIDE; break;
case GDK_KP_0: key_code = WXK_NUMPAD0; break;
case GDK_KP_1: key_code = WXK_NUMPAD1; break;
case GDK_KP_2: key_code = WXK_NUMPAD2; break;
case GDK_KP_3: key_code = WXK_NUMPAD3; break;
case GDK_KP_4: key_code = WXK_NUMPAD4; break;
case GDK_KP_5: key_code = WXK_NUMPAD5; break;
case GDK_KP_6: key_code = WXK_NUMPAD6; break;
case GDK_KP_7: key_code = WXK_NUMPAD7; break;
case GDK_KP_8: key_code = WXK_NUMPAD7; break;
case GDK_KP_9: key_code = WXK_NUMPAD9; break;
case GDK_F1: key_code = WXK_F1; break;
case GDK_F2: key_code = WXK_F2; break;
case GDK_F3: key_code = WXK_F3; break;
case GDK_F4: key_code = WXK_F4; break;
case GDK_F5: key_code = WXK_F5; break;
case GDK_F6: key_code = WXK_F6; break;
case GDK_F7: key_code = WXK_F7; break;
case GDK_F8: key_code = WXK_F8; break;
case GDK_F9: key_code = WXK_F9; break;
case GDK_F10: key_code = WXK_F10; break;
case GDK_F11: key_code = WXK_F11; break;
case GDK_F12: key_code = WXK_F12; break;
default:
{
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
key_code = gdk_event->keyval;
}
} }
}
if (!key_code) return FALSE; if (!key_code) return FALSE;
wxKeyEvent event( wxEVT_CHAR ); wxKeyEvent event( wxEVT_CHAR );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_keyCode = key_code; event.m_keyCode = key_code;
event.m_x = 0; event.m_x = 0;
event.m_y = 0; event.m_y = 0;
event.SetEventObject( win ); event.SetEventObject( win );
bool ret = win->GetEventHandler()->ProcessEvent( event ); bool ret = win->GetEventHandler()->ProcessEvent( event );
if (!ret) if (!ret)
{
wxWindow *ancestor = win;
while (ancestor)
{ {
int command = ancestor->GetAcceleratorTable()->GetCommand( event ); wxWindow *ancestor = win;
if (command != -1) while (ancestor)
{ {
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); int command = ancestor->GetAcceleratorTable()->GetCommand( event );
ret = ancestor->GetEventHandler()->ProcessEvent( command_event ); if (command != -1)
break; {
} wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ancestor = ancestor->GetParent(); ret = ancestor->GetEventHandler()->ProcessEvent( command_event );
break;
}
ancestor = ancestor->GetParent();
}
} }
}
if (ret) if (ret)
{ {
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
} }
return ret; return ret;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -305,108 +305,108 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{ {
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow) if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
{ {
gtk_widget_grab_focus (win->m_wxwindow); if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
{
gtk_widget_grab_focus (win->m_wxwindow);
/* /*
printf( "GrabFocus from " ); printf( "GrabFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
*/
}
}
if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
} wxEventType event_type = wxEVT_LEFT_DOWN;
}
if (!win->HasVMT()) return TRUE; if (gdk_event->button == 1)
/*
printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
*/
wxEventType event_type = wxEVT_LEFT_DOWN;
if (gdk_event->button == 1)
{
switch (gdk_event->type)
{ {
case GDK_BUTTON_PRESS: event_type = wxEVT_LEFT_DOWN; break; switch (gdk_event->type)
case GDK_2BUTTON_PRESS: event_type = wxEVT_LEFT_DCLICK; break; {
default: break; case GDK_BUTTON_PRESS: event_type = wxEVT_LEFT_DOWN; break;
case GDK_2BUTTON_PRESS: event_type = wxEVT_LEFT_DCLICK; break;
default: break;
}
} }
} else if (gdk_event->button == 2)
else if (gdk_event->button == 2)
{
switch (gdk_event->type)
{ {
case GDK_BUTTON_PRESS: event_type = wxEVT_MIDDLE_DOWN; break; switch (gdk_event->type)
case GDK_2BUTTON_PRESS: event_type = wxEVT_MIDDLE_DCLICK; break; {
default: break; case GDK_BUTTON_PRESS: event_type = wxEVT_MIDDLE_DOWN; break;
case GDK_2BUTTON_PRESS: event_type = wxEVT_MIDDLE_DCLICK; break;
default: break;
}
} }
} else if (gdk_event->button == 3)
else if (gdk_event->button == 3)
{
switch (gdk_event->type)
{ {
case GDK_BUTTON_PRESS: event_type = wxEVT_RIGHT_DOWN; break; switch (gdk_event->type)
case GDK_2BUTTON_PRESS: event_type = wxEVT_RIGHT_DCLICK; break; {
default: break; case GDK_BUTTON_PRESS: event_type = wxEVT_RIGHT_DOWN; break;
case GDK_2BUTTON_PRESS: event_type = wxEVT_RIGHT_DCLICK; break;
default: break;
}
} }
}
wxMouseEvent event( event_type ); wxMouseEvent event( event_type );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
event.m_x = (long)gdk_event->x; event.m_x = (long)gdk_event->x;
event.m_y = (long)gdk_event->y; event.m_y = (long)gdk_event->y;
// Some control don't have their own X window and thus cannot get // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_capturing)
{
wxNode *node = win->GetChildren()->First();
while (node)
{ {
wxWindow *child = (wxWindow*)node->Data(); wxNode *node = win->GetChildren()->First();
if ((child->m_x <= event.m_x) && while (node)
(child->m_y <= event.m_y) && {
(child->m_x+child->m_width >= event.m_x) && wxWindow *child = (wxWindow*)node->Data();
(child->m_y+child->m_height >= event.m_y)) if ((child->m_x <= event.m_x) &&
{ (child->m_y <= event.m_y) &&
win = child; (child->m_x+child->m_width >= event.m_x) &&
event.m_x -= child->m_x; (child->m_y+child->m_height >= event.m_y))
event.m_y -= child->m_y; {
break; win = child;
} event.m_x -= child->m_x;
node = node->Next(); event.m_y -= child->m_y;
break;
}
node = node->Next();
}
} }
}
event.SetEventObject( win ); event.SetEventObject( win );
gs_timeLastClick = gdk_event->time; gs_timeLastClick = gdk_event->time;
if (win->GetEventHandler()->ProcessEvent( event )) if (win->GetEventHandler()->ProcessEvent( event ))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" ); gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
return TRUE; return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -415,68 +415,68 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{ {
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE; if (!win->HasVMT()) return TRUE;
/* /*
printf( "OnButtonRelease from " ); printf( "OnButtonRelease from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
wxEventType event_type = wxEVT_NULL; wxEventType event_type = wxEVT_NULL;
switch (gdk_event->button) switch (gdk_event->button)
{
case 1: event_type = wxEVT_LEFT_UP; break;
case 2: event_type = wxEVT_MIDDLE_UP; break;
case 3: event_type = wxEVT_RIGHT_UP; break;
}
wxMouseEvent event( event_type );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
event.m_x = (long)gdk_event->x;
event.m_y = (long)gdk_event->y;
// Some control don't have their own X window and thus cannot get
// any events.
if (!g_capturing)
{
wxNode *node = win->GetChildren()->First();
while (node)
{ {
wxWindow *child = (wxWindow*)node->Data(); case 1: event_type = wxEVT_LEFT_UP; break;
if ((child->m_x <= event.m_x) && case 2: event_type = wxEVT_MIDDLE_UP; break;
(child->m_y <= event.m_y) && case 3: event_type = wxEVT_RIGHT_UP; break;
(child->m_x+child->m_width >= event.m_x) &&
(child->m_y+child->m_height >= event.m_y))
{
win = child;
event.m_x -= child->m_x;
event.m_y -= child->m_y;
break;
}
node = node->Next();
} }
}
event.SetEventObject( win ); wxMouseEvent event( event_type );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
event.m_x = (long)gdk_event->x;
event.m_y = (long)gdk_event->y;
if (win->GetEventHandler()->ProcessEvent( event )) // Some control don't have their own X window and thus cannot get
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" ); // any events.
return TRUE; if (!g_capturing)
{
wxNode *node = win->GetChildren()->First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
if ((child->m_x <= event.m_x) &&
(child->m_y <= event.m_y) &&
(child->m_x+child->m_width >= event.m_x) &&
(child->m_y+child->m_height >= event.m_y))
{
win = child;
event.m_x -= child->m_x;
event.m_y -= child->m_y;
break;
}
node = node->Next();
}
}
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -872,14 +872,14 @@ static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailab
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{ {
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget), GTK_WIDGET(child->m_widget),
child->m_x, child->m_x,
child->m_y ); child->m_y );
gtk_widget_set_usize( GTK_WIDGET(child->m_widget), gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
child->m_width, child->m_width,
child->m_height ); child->m_height );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -901,6 +901,7 @@ wxWindow::wxWindow()
m_wxwindow = (GtkWidget *) NULL; m_wxwindow = (GtkWidget *) NULL;
m_parent = (wxWindow *) NULL; m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
m_x = 0; m_x = 0;
m_y = 0; m_y = 0;
m_width = 0; m_width = 0;
@@ -909,35 +910,48 @@ wxWindow::wxWindow()
m_minHeight = -1; m_minHeight = -1;
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_retCode = 0; m_retCode = 0;
m_eventHandler = this; m_eventHandler = this;
m_windowValidator = (wxValidator *) NULL; m_windowValidator = (wxValidator *) NULL;
m_windowId = -1; m_windowId = -1;
m_cursor = (wxCursor *) NULL; m_cursor = (wxCursor *) NULL;
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
m_windowStyle = 0; m_windowStyle = 0;
m_windowName = "noname"; m_windowName = "noname";
m_constraints = (wxLayoutConstraints *) NULL; m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL; m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL; m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL; m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE; m_autoLayout = FALSE;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
m_hasScrolling = FALSE; m_hasScrolling = FALSE;
m_isScrolling = FALSE; m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL; m_hAdjust = (GtkAdjustment*) NULL;
m_vAdjust = (GtkAdjustment *) NULL; m_vAdjust = (GtkAdjustment*) NULL;
m_oldHorizontalPos = 0.0; m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0; m_oldVerticalPos = 0.0;
m_isShown = FALSE; m_isShown = FALSE;
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL;
m_dropTarget = (wxDropTarget*) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow; m_insertCallback = wxInsertChildInWindow;
m_clientObject = (wxClientData*) NULL;
m_clientData = NULL;
} }
wxWindow::wxWindow( wxWindow *parent, wxWindowID id, wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@@ -1104,6 +1118,8 @@ wxWindow::~wxWindow()
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if (m_windowValidator) delete m_windowValidator; if (m_windowValidator) delete m_windowValidator;
if (m_clientObject) delete m_clientObject;
} }
void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
@@ -1113,8 +1129,8 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
if (m_needParent && (parent == NULL)) if (m_needParent && (parent == NULL))
wxFatalError( "Need complete parent.", name ); wxFatalError( "Need complete parent.", name );
m_widget = (GtkWidget *) NULL; m_widget = (GtkWidget*) NULL;
m_wxwindow = (GtkWidget *) NULL; m_wxwindow = (GtkWidget*) NULL;
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_parent = parent; m_parent = parent;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
@@ -1145,34 +1161,46 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_minHeight = -1; m_minHeight = -1;
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_retCode = 0; m_retCode = 0;
m_eventHandler = this; m_eventHandler = this;
m_windowId = id; m_windowId = id;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_cursor = new wxCursor( wxCURSOR_ARROW ); m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE; // m_backgroundColour = wxWHITE;
// m_foregroundColour = wxBLACK; // m_foregroundColour = wxBLACK;
m_windowStyle = style; m_windowStyle = style;
m_windowName = name; m_windowName = name;
m_constraints = (wxLayoutConstraints *) NULL; m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL; m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL; m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL; m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE; m_autoLayout = FALSE;
m_hasScrolling = FALSE; m_hasScrolling = FALSE;
m_isScrolling = FALSE; m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL; m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL; m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0; m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0; m_oldVerticalPos = 0.0;
m_isShown = FALSE; m_isShown = FALSE;
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL; m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL; m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
m_clientObject = (wxClientData*)NULL;
m_clientData = NULL;
} }
void wxWindow::PostCreation() void wxWindow::PostCreation()
@@ -1847,32 +1875,23 @@ void wxWindow::SetValidator( const wxValidator& validator )
void wxWindow::SetClientObject( wxClientData *data ) void wxWindow::SetClientObject( wxClientData *data )
{ {
if (m_clientData) delete m_clientData; if (m_clientObject) delete m_clientObject;
m_clientData = data; m_clientObject = data;
} }
wxClientData *wxWindow::GetClientObject() wxClientData *wxWindow::GetClientObject()
{ {
return m_clientData; return m_clientObject;
} }
void wxWindow::SetClientData( void *data ) void wxWindow::SetClientData( void *data )
{ {
if (m_clientData) delete m_clientData; m_clientData = data;
if (data)
m_clientData = new wxVoidClientData( data );
else
m_clientData = (wxClientData*) NULL;
} }
void *wxWindow::GetClientData() void *wxWindow::GetClientData()
{ {
if (!m_clientData) return NULL; return m_clientData;
wxVoidClientData *vd = (wxVoidClientData*) m_clientData;
return vd->GetData();
} }
bool wxWindow::IsBeingDeleted() bool wxWindow::IsBeingDeleted()

View File

@@ -55,7 +55,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
SetValidator( validator ); SetValidator( validator );
m_widget = gtk_option_menu_new(); m_widget = gtk_option_menu_new();
@@ -70,7 +70,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
m_clientDataList.Append( (wxObject*) NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] ); GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item ); gtk_menu_append( GTK_MENU(menu), item );
@@ -100,14 +101,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
wxChoice::~wxChoice() wxChoice::~wxChoice()
{ {
wxNode *node = m_clientDataList.First(); Clear();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxChoice::AppendCommon( const wxString &item ) void wxChoice::AppendCommon( const wxString &item )
@@ -132,24 +126,24 @@ void wxChoice::AppendCommon( const wxString &item )
void wxChoice::Append( const wxString &item ) void wxChoice::Append( const wxString &item )
{ {
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxChoice::Append( const wxString &item, void *clientData ) void wxChoice::Append( const wxString &item, void *clientData )
{ {
if (clientData) m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) ); m_clientObjectList.Append( (wxObject*) NULL );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxChoice::Append( const wxString &item, wxClientData *clientData ) 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 ); AppendCommon( item );
} }
@@ -161,13 +155,7 @@ void wxChoice::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); node->SetData( (wxObject*) clientData );
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
} }
void* wxChoice::GetClientData( int n ) void* wxChoice::GetClientData( int n )
@@ -177,36 +165,31 @@ void* wxChoice::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL; if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data(); return node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
} }
void wxChoice::SetClientObject( int n, wxClientData* clientData ) void wxChoice::SetClientObject( int n, wxClientData* clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd; if (cd) delete cd;
node->SetData( (wxObject*) clientData ); node->SetData( (wxObject*) clientData );
} }
wxClientData* wxChoice::GetClientObject( int n ) wxClientData* wxChoice::GetClientObject( int n )
{ {
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" ); 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; if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data(); return (wxClientData*) node->Data();
} }
void wxChoice::Clear() void wxChoice::Clear()
{ {
@@ -216,13 +199,15 @@ void wxChoice::Clear()
GtkWidget *menu = gtk_menu_new(); GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientDataList.First(); wxNode *node = m_clientObjectList.First();
while (node) while (node)
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
node = node->Next(); node = node->Next();
} }
m_clientObjectList.Clear();
m_clientDataList.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] ); GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*)NULL );
m_clientObjectList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -148,24 +149,24 @@ void wxComboBox::AppendCommon( const wxString &item )
void wxComboBox::Append( const wxString &item ) void wxComboBox::Append( const wxString &item )
{ {
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxComboBox::Append( const wxString &item, void *clientData ) void wxComboBox::Append( const wxString &item, void *clientData )
{ {
if (clientData) m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) ); m_clientObjectList.Append( (wxObject*)NULL );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxComboBox::Append( const wxString &item, wxClientData *clientData ) 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 ); AppendCommon( item );
} }
@@ -177,13 +178,7 @@ void wxComboBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); node->SetData( (wxObject*) clientData );
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
} }
void* wxComboBox::GetClientData( int n ) void* wxComboBox::GetClientData( int n )
@@ -193,23 +188,19 @@ void* wxComboBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL; if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data(); return node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
} }
void wxComboBox::SetClientObject( int n, wxClientData* clientData ) void wxComboBox::SetClientObject( int n, wxClientData* clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd; if (cd) delete cd;
node->SetData( (wxObject*) clientData ); node->SetData( (wxObject*) clientData );
} }
@@ -230,13 +221,15 @@ void wxComboBox::Clear()
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() ); gtk_list_clear_items( GTK_LIST(list), 0, Number() );
wxNode *node = m_clientDataList.First(); wxNode *node = m_clientObjectList.First();
while (node) while (node)
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
node = node->Next(); node = node->Next();
} }
m_clientObjectList.Clear();
m_clientDataList.Clear(); m_clientDataList.Clear();
} }
@@ -258,15 +251,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list ); gtk_list_remove_items( listbox, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) if (node)
{
wxFAIL_MSG( "wrong index" );
}
else
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( 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++) for (int i = 0; i < n; i++)
{ {
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
GtkWidget *list_item; GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] ); list_item = gtk_list_item_new_with_label( choices[i] );
@@ -115,8 +118,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item ); ConnectWidget( list_item );
m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
@@ -138,14 +139,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
wxListBox::~wxListBox() wxListBox::~wxListBox()
{ {
wxNode *node = m_clientDataList.First(); Clear();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxListBox::AppendCommon( const wxString &item ) void wxListBox::AppendCommon( const wxString &item )
@@ -174,24 +168,24 @@ void wxListBox::AppendCommon( const wxString &item )
void wxListBox::Append( const wxString &item ) void wxListBox::Append( const wxString &item )
{ {
m_clientDataList.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxListBox::Append( const wxString &item, void *clientData ) void wxListBox::Append( const wxString &item, void *clientData )
{ {
if (clientData) m_clientDataList.Append( (wxObject*) clientData );
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) ); m_clientObjectList.Append( (wxObject*) NULL );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item ); AppendCommon( item );
} }
void wxListBox::Append( const wxString &item, wxClientData *clientData ) 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 ); AppendCommon( item );
} }
@@ -203,13 +197,7 @@ void wxListBox::SetClientData( int n, void* clientData )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); node->SetData( (wxObject*) clientData );
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
} }
void* wxListBox::GetClientData( int n ) void* wxListBox::GetClientData( int n )
@@ -219,18 +207,14 @@ void* wxListBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL; if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data(); return node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
} }
void wxListBox::SetClientObject( int n, wxClientData* clientData ) void wxListBox::SetClientObject( int n, wxClientData* clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) return; if (!node) return;
wxClientData *cd = (wxClientData*) node->Data(); wxClientData *cd = (wxClientData*) node->Data();
@@ -243,7 +227,7 @@ wxClientData* wxListBox::GetClientObject( int n )
{ {
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" ); 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; if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data(); return (wxClientData*) node->Data();
@@ -255,13 +239,15 @@ void wxListBox::Clear()
gtk_list_clear_items( m_list, 0, Number() ); gtk_list_clear_items( m_list, 0, Number() );
wxNode *node = m_clientDataList.First(); wxNode *node = m_clientObjectList.First();
while (node) while (node)
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
node = node->Next(); node = node->Next();
} }
m_clientObjectList.Clear();
m_clientDataList.Clear(); m_clientDataList.Clear();
} }
@@ -281,15 +267,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list ); gtk_list_remove_items( m_list, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientDataList.Nth( n ); wxNode *node = m_clientObjectList.Nth( n );
if (!node) if (node)
{
wxFAIL_MSG( "wrong index" );
}
else
{ {
wxClientData *cd = (wxClientData*)node->Data(); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd; if (cd) delete cd;
m_clientObjectList.DeleteNode( node );
}
node = m_clientDataList.Nth( n );
if (node)
{
m_clientDataList.DeleteNode( node ); m_clientDataList.DeleteNode( node );
} }
} }

View File

@@ -124,28 +124,28 @@ static guint32 gs_timeLastClick = 0;
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( gdk_event->area.x, win->m_updateRegion.Union( gdk_event->area.x,
gdk_event->area.y, gdk_event->area.y,
gdk_event->area.width, gdk_event->area.width,
gdk_event->area.height ); gdk_event->area.height );
if (gdk_event->count > 0) return; if (gdk_event->count > 0) return;
/* /*
printf( "OnExpose from " ); printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
win->m_updateRegion.Clear(); win->m_updateRegion.Clear();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -154,16 +154,16 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
wxPaintEvent event( win->GetId() ); wxPaintEvent event( win->GetId() );
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
win->m_updateRegion.Clear(); win->m_updateRegion.Clear();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -172,131 +172,131 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{ {
if (!win->HasVMT()) return FALSE; if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnDrag) return FALSE;
/* /*
printf( "OnKeyPress from " ); printf( "OnKeyPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
long key_code = 0; long key_code = 0;
switch (gdk_event->keyval) switch (gdk_event->keyval)
{
case GDK_BackSpace: key_code = WXK_BACK; break;
case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
case GDK_Clear: key_code = WXK_CLEAR; break;
case GDK_Return: key_code = WXK_RETURN; break;
case GDK_Pause: key_code = WXK_PAUSE; break;
case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
case GDK_Escape: key_code = WXK_ESCAPE; break;
case GDK_Delete: key_code = WXK_DELETE; break;
case GDK_Home: key_code = WXK_HOME; break;
case GDK_Left: key_code = WXK_LEFT; break;
case GDK_Up: key_code = WXK_UP; break;
case GDK_Right: key_code = WXK_RIGHT; break;
case GDK_Down: key_code = WXK_DOWN; break;
case GDK_Prior: key_code = WXK_PRIOR; break;
// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_Next: key_code = WXK_NEXT; break;
// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_End: key_code = WXK_END; break;
case GDK_Begin: key_code = WXK_HOME; break;
case GDK_Select: key_code = WXK_SELECT; break;
case GDK_Print: key_code = WXK_PRINT; break;
case GDK_Execute: key_code = WXK_EXECUTE; break;
case GDK_Insert: key_code = WXK_INSERT; break;
case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
case GDK_KP_Tab: key_code = WXK_TAB; break;
case GDK_KP_Enter: key_code = WXK_RETURN; break;
case GDK_KP_Home: key_code = WXK_HOME; break;
case GDK_KP_Left: key_code = WXK_LEFT; break;
case GDK_KP_Up: key_code = WXK_UP; break;
case GDK_KP_Right: key_code = WXK_RIGHT; break;
case GDK_KP_Down: key_code = WXK_DOWN; break;
case GDK_KP_Prior: key_code = WXK_PRIOR; break;
// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_KP_Next: key_code = WXK_NEXT; break;
// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_KP_End: key_code = WXK_END; break;
case GDK_KP_Begin: key_code = WXK_HOME; break;
case GDK_KP_Insert: key_code = WXK_INSERT; break;
case GDK_KP_Delete: key_code = WXK_DELETE; break;
case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break;
case GDK_KP_Add: key_code = WXK_ADD; break;
case GDK_KP_Separator: key_code = WXK_SEPARATOR; break;
case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break;
case GDK_KP_Decimal: key_code = WXK_DECIMAL; break;
case GDK_KP_Divide: key_code = WXK_DIVIDE; break;
case GDK_KP_0: key_code = WXK_NUMPAD0; break;
case GDK_KP_1: key_code = WXK_NUMPAD1; break;
case GDK_KP_2: key_code = WXK_NUMPAD2; break;
case GDK_KP_3: key_code = WXK_NUMPAD3; break;
case GDK_KP_4: key_code = WXK_NUMPAD4; break;
case GDK_KP_5: key_code = WXK_NUMPAD5; break;
case GDK_KP_6: key_code = WXK_NUMPAD6; break;
case GDK_KP_7: key_code = WXK_NUMPAD7; break;
case GDK_KP_8: key_code = WXK_NUMPAD7; break;
case GDK_KP_9: key_code = WXK_NUMPAD9; break;
case GDK_F1: key_code = WXK_F1; break;
case GDK_F2: key_code = WXK_F2; break;
case GDK_F3: key_code = WXK_F3; break;
case GDK_F4: key_code = WXK_F4; break;
case GDK_F5: key_code = WXK_F5; break;
case GDK_F6: key_code = WXK_F6; break;
case GDK_F7: key_code = WXK_F7; break;
case GDK_F8: key_code = WXK_F8; break;
case GDK_F9: key_code = WXK_F9; break;
case GDK_F10: key_code = WXK_F10; break;
case GDK_F11: key_code = WXK_F11; break;
case GDK_F12: key_code = WXK_F12; break;
default:
{ {
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) case GDK_BackSpace: key_code = WXK_BACK; break;
key_code = gdk_event->keyval; case GDK_Tab: key_code = WXK_TAB; break;
case GDK_Linefeed: key_code = WXK_RETURN; break;
case GDK_Clear: key_code = WXK_CLEAR; break;
case GDK_Return: key_code = WXK_RETURN; break;
case GDK_Pause: key_code = WXK_PAUSE; break;
case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
case GDK_Escape: key_code = WXK_ESCAPE; break;
case GDK_Delete: key_code = WXK_DELETE; break;
case GDK_Home: key_code = WXK_HOME; break;
case GDK_Left: key_code = WXK_LEFT; break;
case GDK_Up: key_code = WXK_UP; break;
case GDK_Right: key_code = WXK_RIGHT; break;
case GDK_Down: key_code = WXK_DOWN; break;
case GDK_Prior: key_code = WXK_PRIOR; break;
// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_Next: key_code = WXK_NEXT; break;
// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_End: key_code = WXK_END; break;
case GDK_Begin: key_code = WXK_HOME; break;
case GDK_Select: key_code = WXK_SELECT; break;
case GDK_Print: key_code = WXK_PRINT; break;
case GDK_Execute: key_code = WXK_EXECUTE; break;
case GDK_Insert: key_code = WXK_INSERT; break;
case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
case GDK_KP_Tab: key_code = WXK_TAB; break;
case GDK_KP_Enter: key_code = WXK_RETURN; break;
case GDK_KP_Home: key_code = WXK_HOME; break;
case GDK_KP_Left: key_code = WXK_LEFT; break;
case GDK_KP_Up: key_code = WXK_UP; break;
case GDK_KP_Right: key_code = WXK_RIGHT; break;
case GDK_KP_Down: key_code = WXK_DOWN; break;
case GDK_KP_Prior: key_code = WXK_PRIOR; break;
// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
case GDK_KP_Next: key_code = WXK_NEXT; break;
// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
case GDK_KP_End: key_code = WXK_END; break;
case GDK_KP_Begin: key_code = WXK_HOME; break;
case GDK_KP_Insert: key_code = WXK_INSERT; break;
case GDK_KP_Delete: key_code = WXK_DELETE; break;
case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break;
case GDK_KP_Add: key_code = WXK_ADD; break;
case GDK_KP_Separator: key_code = WXK_SEPARATOR; break;
case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break;
case GDK_KP_Decimal: key_code = WXK_DECIMAL; break;
case GDK_KP_Divide: key_code = WXK_DIVIDE; break;
case GDK_KP_0: key_code = WXK_NUMPAD0; break;
case GDK_KP_1: key_code = WXK_NUMPAD1; break;
case GDK_KP_2: key_code = WXK_NUMPAD2; break;
case GDK_KP_3: key_code = WXK_NUMPAD3; break;
case GDK_KP_4: key_code = WXK_NUMPAD4; break;
case GDK_KP_5: key_code = WXK_NUMPAD5; break;
case GDK_KP_6: key_code = WXK_NUMPAD6; break;
case GDK_KP_7: key_code = WXK_NUMPAD7; break;
case GDK_KP_8: key_code = WXK_NUMPAD7; break;
case GDK_KP_9: key_code = WXK_NUMPAD9; break;
case GDK_F1: key_code = WXK_F1; break;
case GDK_F2: key_code = WXK_F2; break;
case GDK_F3: key_code = WXK_F3; break;
case GDK_F4: key_code = WXK_F4; break;
case GDK_F5: key_code = WXK_F5; break;
case GDK_F6: key_code = WXK_F6; break;
case GDK_F7: key_code = WXK_F7; break;
case GDK_F8: key_code = WXK_F8; break;
case GDK_F9: key_code = WXK_F9; break;
case GDK_F10: key_code = WXK_F10; break;
case GDK_F11: key_code = WXK_F11; break;
case GDK_F12: key_code = WXK_F12; break;
default:
{
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
key_code = gdk_event->keyval;
}
} }
}
if (!key_code) return FALSE; if (!key_code) return FALSE;
wxKeyEvent event( wxEVT_CHAR ); wxKeyEvent event( wxEVT_CHAR );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_keyCode = key_code; event.m_keyCode = key_code;
event.m_x = 0; event.m_x = 0;
event.m_y = 0; event.m_y = 0;
event.SetEventObject( win ); event.SetEventObject( win );
bool ret = win->GetEventHandler()->ProcessEvent( event ); bool ret = win->GetEventHandler()->ProcessEvent( event );
if (!ret) if (!ret)
{
wxWindow *ancestor = win;
while (ancestor)
{ {
int command = ancestor->GetAcceleratorTable()->GetCommand( event ); wxWindow *ancestor = win;
if (command != -1) while (ancestor)
{ {
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); int command = ancestor->GetAcceleratorTable()->GetCommand( event );
ret = ancestor->GetEventHandler()->ProcessEvent( command_event ); if (command != -1)
break; {
} wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ancestor = ancestor->GetParent(); ret = ancestor->GetEventHandler()->ProcessEvent( command_event );
break;
}
ancestor = ancestor->GetParent();
}
} }
}
if (ret) if (ret)
{ {
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
} }
return ret; return ret;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -305,108 +305,108 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{ {
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow) if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
{ {
gtk_widget_grab_focus (win->m_wxwindow); if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
{
gtk_widget_grab_focus (win->m_wxwindow);
/* /*
printf( "GrabFocus from " ); printf( "GrabFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
*/
}
}
if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
} wxEventType event_type = wxEVT_LEFT_DOWN;
}
if (!win->HasVMT()) return TRUE; if (gdk_event->button == 1)
/*
printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
*/
wxEventType event_type = wxEVT_LEFT_DOWN;
if (gdk_event->button == 1)
{
switch (gdk_event->type)
{ {
case GDK_BUTTON_PRESS: event_type = wxEVT_LEFT_DOWN; break; switch (gdk_event->type)
case GDK_2BUTTON_PRESS: event_type = wxEVT_LEFT_DCLICK; break; {
default: break; case GDK_BUTTON_PRESS: event_type = wxEVT_LEFT_DOWN; break;
case GDK_2BUTTON_PRESS: event_type = wxEVT_LEFT_DCLICK; break;
default: break;
}
} }
} else if (gdk_event->button == 2)
else if (gdk_event->button == 2)
{
switch (gdk_event->type)
{ {
case GDK_BUTTON_PRESS: event_type = wxEVT_MIDDLE_DOWN; break; switch (gdk_event->type)
case GDK_2BUTTON_PRESS: event_type = wxEVT_MIDDLE_DCLICK; break; {
default: break; case GDK_BUTTON_PRESS: event_type = wxEVT_MIDDLE_DOWN; break;
case GDK_2BUTTON_PRESS: event_type = wxEVT_MIDDLE_DCLICK; break;
default: break;
}
} }
} else if (gdk_event->button == 3)
else if (gdk_event->button == 3)
{
switch (gdk_event->type)
{ {
case GDK_BUTTON_PRESS: event_type = wxEVT_RIGHT_DOWN; break; switch (gdk_event->type)
case GDK_2BUTTON_PRESS: event_type = wxEVT_RIGHT_DCLICK; break; {
default: break; case GDK_BUTTON_PRESS: event_type = wxEVT_RIGHT_DOWN; break;
case GDK_2BUTTON_PRESS: event_type = wxEVT_RIGHT_DCLICK; break;
default: break;
}
} }
}
wxMouseEvent event( event_type ); wxMouseEvent event( event_type );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
event.m_x = (long)gdk_event->x; event.m_x = (long)gdk_event->x;
event.m_y = (long)gdk_event->y; event.m_y = (long)gdk_event->y;
// Some control don't have their own X window and thus cannot get // Some control don't have their own X window and thus cannot get
// any events. // any events.
if (!g_capturing) if (!g_capturing)
{
wxNode *node = win->GetChildren()->First();
while (node)
{ {
wxWindow *child = (wxWindow*)node->Data(); wxNode *node = win->GetChildren()->First();
if ((child->m_x <= event.m_x) && while (node)
(child->m_y <= event.m_y) && {
(child->m_x+child->m_width >= event.m_x) && wxWindow *child = (wxWindow*)node->Data();
(child->m_y+child->m_height >= event.m_y)) if ((child->m_x <= event.m_x) &&
{ (child->m_y <= event.m_y) &&
win = child; (child->m_x+child->m_width >= event.m_x) &&
event.m_x -= child->m_x; (child->m_y+child->m_height >= event.m_y))
event.m_y -= child->m_y; {
break; win = child;
} event.m_x -= child->m_x;
node = node->Next(); event.m_y -= child->m_y;
break;
}
node = node->Next();
}
} }
}
event.SetEventObject( win ); event.SetEventObject( win );
gs_timeLastClick = gdk_event->time; gs_timeLastClick = gdk_event->time;
if (win->GetEventHandler()->ProcessEvent( event )) if (win->GetEventHandler()->ProcessEvent( event ))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" ); gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
return TRUE; return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -415,68 +415,68 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{ {
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE; if (!win->HasVMT()) return TRUE;
/* /*
printf( "OnButtonRelease from " ); printf( "OnButtonRelease from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
wxEventType event_type = wxEVT_NULL; wxEventType event_type = wxEVT_NULL;
switch (gdk_event->button) switch (gdk_event->button)
{
case 1: event_type = wxEVT_LEFT_UP; break;
case 2: event_type = wxEVT_MIDDLE_UP; break;
case 3: event_type = wxEVT_RIGHT_UP; break;
}
wxMouseEvent event( event_type );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
event.m_x = (long)gdk_event->x;
event.m_y = (long)gdk_event->y;
// Some control don't have their own X window and thus cannot get
// any events.
if (!g_capturing)
{
wxNode *node = win->GetChildren()->First();
while (node)
{ {
wxWindow *child = (wxWindow*)node->Data(); case 1: event_type = wxEVT_LEFT_UP; break;
if ((child->m_x <= event.m_x) && case 2: event_type = wxEVT_MIDDLE_UP; break;
(child->m_y <= event.m_y) && case 3: event_type = wxEVT_RIGHT_UP; break;
(child->m_x+child->m_width >= event.m_x) &&
(child->m_y+child->m_height >= event.m_y))
{
win = child;
event.m_x -= child->m_x;
event.m_y -= child->m_y;
break;
}
node = node->Next();
} }
}
event.SetEventObject( win ); wxMouseEvent event( event_type );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
event.m_x = (long)gdk_event->x;
event.m_y = (long)gdk_event->y;
if (win->GetEventHandler()->ProcessEvent( event )) // Some control don't have their own X window and thus cannot get
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" ); // any events.
return TRUE; if (!g_capturing)
{
wxNode *node = win->GetChildren()->First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
if ((child->m_x <= event.m_x) &&
(child->m_y <= event.m_y) &&
(child->m_x+child->m_width >= event.m_x) &&
(child->m_y+child->m_height >= event.m_y))
{
win = child;
event.m_x -= child->m_x;
event.m_y -= child->m_y;
break;
}
node = node->Next();
}
}
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -872,14 +872,14 @@ static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailab
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{ {
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget), GTK_WIDGET(child->m_widget),
child->m_x, child->m_x,
child->m_y ); child->m_y );
gtk_widget_set_usize( GTK_WIDGET(child->m_widget), gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
child->m_width, child->m_width,
child->m_height ); child->m_height );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -901,6 +901,7 @@ wxWindow::wxWindow()
m_wxwindow = (GtkWidget *) NULL; m_wxwindow = (GtkWidget *) NULL;
m_parent = (wxWindow *) NULL; m_parent = (wxWindow *) NULL;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
m_x = 0; m_x = 0;
m_y = 0; m_y = 0;
m_width = 0; m_width = 0;
@@ -909,35 +910,48 @@ wxWindow::wxWindow()
m_minHeight = -1; m_minHeight = -1;
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_retCode = 0; m_retCode = 0;
m_eventHandler = this; m_eventHandler = this;
m_windowValidator = (wxValidator *) NULL; m_windowValidator = (wxValidator *) NULL;
m_windowId = -1; m_windowId = -1;
m_cursor = (wxCursor *) NULL; m_cursor = (wxCursor *) NULL;
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
m_windowStyle = 0; m_windowStyle = 0;
m_windowName = "noname"; m_windowName = "noname";
m_constraints = (wxLayoutConstraints *) NULL; m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL; m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL; m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL; m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE; m_autoLayout = FALSE;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
m_hasScrolling = FALSE; m_hasScrolling = FALSE;
m_isScrolling = FALSE; m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL; m_hAdjust = (GtkAdjustment*) NULL;
m_vAdjust = (GtkAdjustment *) NULL; m_vAdjust = (GtkAdjustment*) NULL;
m_oldHorizontalPos = 0.0; m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0; m_oldVerticalPos = 0.0;
m_isShown = FALSE; m_isShown = FALSE;
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL;
m_dropTarget = (wxDropTarget*) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow; m_insertCallback = wxInsertChildInWindow;
m_clientObject = (wxClientData*) NULL;
m_clientData = NULL;
} }
wxWindow::wxWindow( wxWindow *parent, wxWindowID id, wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@@ -1104,6 +1118,8 @@ wxWindow::~wxWindow()
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if (m_windowValidator) delete m_windowValidator; if (m_windowValidator) delete m_windowValidator;
if (m_clientObject) delete m_clientObject;
} }
void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
@@ -1113,8 +1129,8 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
if (m_needParent && (parent == NULL)) if (m_needParent && (parent == NULL))
wxFatalError( "Need complete parent.", name ); wxFatalError( "Need complete parent.", name );
m_widget = (GtkWidget *) NULL; m_widget = (GtkWidget*) NULL;
m_wxwindow = (GtkWidget *) NULL; m_wxwindow = (GtkWidget*) NULL;
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_parent = parent; m_parent = parent;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
@@ -1145,34 +1161,46 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_minHeight = -1; m_minHeight = -1;
m_maxWidth = -1; m_maxWidth = -1;
m_maxHeight = -1; m_maxHeight = -1;
m_retCode = 0; m_retCode = 0;
m_eventHandler = this; m_eventHandler = this;
m_windowId = id; m_windowId = id;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_cursor = new wxCursor( wxCURSOR_ARROW ); m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE; // m_backgroundColour = wxWHITE;
// m_foregroundColour = wxBLACK; // m_foregroundColour = wxBLACK;
m_windowStyle = style; m_windowStyle = style;
m_windowName = name; m_windowName = name;
m_constraints = (wxLayoutConstraints *) NULL; m_constraints = (wxLayoutConstraints *) NULL;
m_constraintsInvolvedIn = (wxList *) NULL; m_constraintsInvolvedIn = (wxList *) NULL;
m_windowSizer = (wxSizer *) NULL; m_windowSizer = (wxSizer *) NULL;
m_sizerParent = (wxWindow *) NULL; m_sizerParent = (wxWindow *) NULL;
m_autoLayout = FALSE; m_autoLayout = FALSE;
m_hasScrolling = FALSE; m_hasScrolling = FALSE;
m_isScrolling = FALSE; m_isScrolling = FALSE;
m_hAdjust = (GtkAdjustment *) NULL; m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL; m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0; m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0; m_oldVerticalPos = 0.0;
m_isShown = FALSE; m_isShown = FALSE;
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL; m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL; m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
m_clientObject = (wxClientData*)NULL;
m_clientData = NULL;
} }
void wxWindow::PostCreation() void wxWindow::PostCreation()
@@ -1847,32 +1875,23 @@ void wxWindow::SetValidator( const wxValidator& validator )
void wxWindow::SetClientObject( wxClientData *data ) void wxWindow::SetClientObject( wxClientData *data )
{ {
if (m_clientData) delete m_clientData; if (m_clientObject) delete m_clientObject;
m_clientData = data; m_clientObject = data;
} }
wxClientData *wxWindow::GetClientObject() wxClientData *wxWindow::GetClientObject()
{ {
return m_clientData; return m_clientObject;
} }
void wxWindow::SetClientData( void *data ) void wxWindow::SetClientData( void *data )
{ {
if (m_clientData) delete m_clientData; m_clientData = data;
if (data)
m_clientData = new wxVoidClientData( data );
else
m_clientData = (wxClientData*) NULL;
} }
void *wxWindow::GetClientData() void *wxWindow::GetClientData()
{ {
if (!m_clientData) return NULL; return m_clientData;
wxVoidClientData *vd = (wxVoidClientData*) m_clientData;
return vd->GetData();
} }
bool wxWindow::IsBeingDeleted() bool wxWindow::IsBeingDeleted()