int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
- // the item's text
- void SetText(const wxString& str);
- const wxString& GetText() const { return m_text; }
+ // the item's text = name
+ void SetName(const wxString& str);
+ const wxString& GetName() const { return m_text; }
// what kind of menu item we are
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
virtual bool OnClose();
virtual void AddChild( wxWindow *child );
- wxList *GetChildren();
+ wxList& GetChildren() const;
virtual void RemoveChild( wxWindow *child );
void SetReturnCode( int retCode );
int GetReturnCode();
int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
- // the item's text
- void SetText(const wxString& str);
- const wxString& GetText() const { return m_text; }
+ // the item's text = name
+ void SetName(const wxString& str);
+ const wxString& GetName() const { return m_text; }
// what kind of menu item we are
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
virtual bool OnClose();
virtual void AddChild( wxWindow *child );
- wxList *GetChildren();
+ wxList& GetChildren() const;
virtual void RemoveChild( wxWindow *child );
void SetReturnCode( int retCode );
int GetReturnCode();
if (!data_object) return;
- if (data_object->GetDataSize() == 0) return;
+ if (data_object->GetDataSize() == 0) return;
+
+
gint len = data_object->GetDataSize();
guchar *bin_data = (guchar*) malloc( len );
data_object->GetDataHere( (void*)bin_data );
- if (selection_data->target == GDK_SELECTION_TYPE_STRING)
+ if (selection_data->target == GDK_TARGET_STRING)
{
gtk_selection_data_set(
selection_data, GDK_SELECTION_TYPE_STRING, 8*sizeof(gchar), bin_data, len );
}
+/*
else if (selection_data->target == g_textAtom)
{
gtk_selection_data_set(
selection_data, g_textAtom, 8*sizeof(gchar), bin_data, len );
}
+*/
free( bin_data );
}
wxClipboard::wxClipboard()
{
m_data = (wxDataObject*) NULL;
- m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
- gtk_widget_realize( m_clipboardWidget );
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_clear_event",
if (m_data)
{
+ if (gdk_selection_owner_get( g_clipboardAtom) == m_clipboardWidget->window)
+ {
+ gtk_selection_owner_set( (GtkWidget*) NULL, g_clipboardAtom, GDK_CURRENT_TIME );
+ }
+
delete m_data;
- gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
+ m_data = (wxDataObject*) NULL;
}
m_receivedSize = 0;
void wxClipboard::SetData( wxDataObject *data )
{
+ Clear();
+
+/*
+ GTK 1.0.X cannot remove a target from a widget so if a widget
+ at first offers text and then a bitmap (and no longer text) to
+ the clipboard, we seem too have to delete it.
+*/
+
+ if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+
+ m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
+ gtk_widget_realize( m_clipboardWidget );
+
+
if (m_data) delete m_data;
m_data = data;
if (!m_data) return;
case wxDF_TEXT:
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
- g_textAtom,
+ // g_textAtom,
+ GDK_TARGET_STRING,
selection_handler,
NULL );
break;
else
{
// no child: go out !
- if (!GetChildren()->First()) return;
+ if (!GetChildren().First()) return;
// do we have exactly one child?
wxWindow *child = (wxWindow *) NULL;
- for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+ for(wxNode *node = GetChildren().First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog))
else
{
// no child: go out !
- if (!GetChildren()->First()) return;
+ if (!GetChildren().First()) return;
// do we have exactly one child?
wxWindow *child = (wxWindow *) NULL;
- for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+ for(wxNode *node = GetChildren().First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)
m_frameToolBar = OnCreateToolBar( style, id, name );
- GetChildren()->DeleteObject( m_frameToolBar );
+ GetChildren().DeleteObject( m_frameToolBar );
if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height );
}
//-----------------------------------------------------------------------------
-// wxMenu
+// wxMenuItem
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)
m_menuItem = (GtkWidget *) NULL;
}
-void wxMenuItem::SetText(const wxString& str)
+void wxMenuItem::SetName(const wxString& str)
{
+ wxCHECK_RET( m_menuItem, "invalid menu item" );
+
m_text = "";
- for ( const char *pc = str; *pc != '\0'; pc++ ) {
+ for ( const char *pc = str; *pc != '\0'; pc++ )
+ {
if ( *pc == '&' )
pc++; // skip it
m_text << *pc;
}
+
+ GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
+
+ gtk_label_set( label, m_text.c_str());
}
void wxMenuItem::Check( bool check )
{
+ wxCHECK_RET( m_menuItem, "invalid menu item" );
+
wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" )
m_isChecked = check;
void wxMenuItem::Enable( bool enable )
{
+ wxCHECK_RET( m_menuItem, "invalid menu item" );
+
gtk_widget_set_sensitive( m_menuItem, enable );
m_isEnabled = enable;
}
bool wxMenuItem::IsChecked() const
{
+ wxCHECK_MSG( m_menuItem, FALSE, "invalid menu item" );
+
wxCHECK( IsCheckable(), FALSE ); // can't get state of uncheckable item!
bool bIsChecked = ((GtkCheckMenuItem*)m_menuItem)->active != 0;
return bIsChecked;
}
+//-----------------------------------------------------------------------------
+// wxMenuItem
+//-----------------------------------------------------------------------------
+
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
wxMenu::wxMenu( const wxString& title, const wxFunction func )
if (!g_capturing)
{
- wxNode *node = win->GetChildren()->First();
+ wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
if (!g_capturing)
{
- wxNode *node = win->GetChildren()->First();
+ wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
if (!g_capturing)
{
- wxNode *node = win->GetChildren()->First();
+ wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
bool wxWindow::DestroyChildren()
{
- if (GetChildren())
+ wxNode *node;
+ while ((node = m_children.First()) != (wxNode *)NULL)
{
- wxNode *node;
- while ((node = GetChildren()->First()) != (wxNode *)NULL)
+ wxWindow *child;
+ if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
{
- wxWindow *child;
- if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
- {
- delete child;
- if (GetChildren()->Member(child)) delete node;
- }
+ delete child;
+ if (m_children.Member(child)) delete node;
}
}
return TRUE;
int maxX = 0;
int maxY = 0;
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_childrenFirst();
while ( node )
{
wxWindow *win = (wxWindow *)node->Data();
m_children.Append( child );
}
-wxList *wxWindow::GetChildren()
+wxList& wxWindow::GetChildren() const
{
- return (&m_children);
+ return m_children;
}
wxWindow *wxWindow::ReParent( wxWindow *newParent )
void wxWindow::RemoveChild( wxWindow *child )
{
- if (GetChildren()) GetChildren()->DeleteObject( child );
+ m_children.DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
{
noChanges = 0;
noFailures = 0;
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.first();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
constr->centreX.SetDone(FALSE);
constr->centreY.SetDone(FALSE);
}
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *win = (wxWindow *)node->Data();
if (recurse)
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *win = (wxWindow *)node->Data();
if (!data_object) return;
- if (data_object->GetDataSize() == 0) return;
+ if (data_object->GetDataSize() == 0) return;
+
+
gint len = data_object->GetDataSize();
guchar *bin_data = (guchar*) malloc( len );
data_object->GetDataHere( (void*)bin_data );
- if (selection_data->target == GDK_SELECTION_TYPE_STRING)
+ if (selection_data->target == GDK_TARGET_STRING)
{
gtk_selection_data_set(
selection_data, GDK_SELECTION_TYPE_STRING, 8*sizeof(gchar), bin_data, len );
}
+/*
else if (selection_data->target == g_textAtom)
{
gtk_selection_data_set(
selection_data, g_textAtom, 8*sizeof(gchar), bin_data, len );
}
+*/
free( bin_data );
}
wxClipboard::wxClipboard()
{
m_data = (wxDataObject*) NULL;
- m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
- gtk_widget_realize( m_clipboardWidget );
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_clear_event",
if (m_data)
{
+ if (gdk_selection_owner_get( g_clipboardAtom) == m_clipboardWidget->window)
+ {
+ gtk_selection_owner_set( (GtkWidget*) NULL, g_clipboardAtom, GDK_CURRENT_TIME );
+ }
+
delete m_data;
- gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
+ m_data = (wxDataObject*) NULL;
}
m_receivedSize = 0;
void wxClipboard::SetData( wxDataObject *data )
{
+ Clear();
+
+/*
+ GTK 1.0.X cannot remove a target from a widget so if a widget
+ at first offers text and then a bitmap (and no longer text) to
+ the clipboard, we seem too have to delete it.
+*/
+
+ if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+
+ m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
+ gtk_widget_realize( m_clipboardWidget );
+
+
if (m_data) delete m_data;
m_data = data;
if (!m_data) return;
case wxDF_TEXT:
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
- g_textAtom,
+ // g_textAtom,
+ GDK_TARGET_STRING,
selection_handler,
NULL );
break;
else
{
// no child: go out !
- if (!GetChildren()->First()) return;
+ if (!GetChildren().First()) return;
// do we have exactly one child?
wxWindow *child = (wxWindow *) NULL;
- for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+ for(wxNode *node = GetChildren().First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog))
else
{
// no child: go out !
- if (!GetChildren()->First()) return;
+ if (!GetChildren().First()) return;
// do we have exactly one child?
wxWindow *child = (wxWindow *) NULL;
- for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+ for(wxNode *node = GetChildren().First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)
m_frameToolBar = OnCreateToolBar( style, id, name );
- GetChildren()->DeleteObject( m_frameToolBar );
+ GetChildren().DeleteObject( m_frameToolBar );
if (m_sizeSet) GtkOnSize( m_x, m_y, m_width, m_height );
}
//-----------------------------------------------------------------------------
-// wxMenu
+// wxMenuItem
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)
m_menuItem = (GtkWidget *) NULL;
}
-void wxMenuItem::SetText(const wxString& str)
+void wxMenuItem::SetName(const wxString& str)
{
+ wxCHECK_RET( m_menuItem, "invalid menu item" );
+
m_text = "";
- for ( const char *pc = str; *pc != '\0'; pc++ ) {
+ for ( const char *pc = str; *pc != '\0'; pc++ )
+ {
if ( *pc == '&' )
pc++; // skip it
m_text << *pc;
}
+
+ GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
+
+ gtk_label_set( label, m_text.c_str());
}
void wxMenuItem::Check( bool check )
{
+ wxCHECK_RET( m_menuItem, "invalid menu item" );
+
wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" )
m_isChecked = check;
void wxMenuItem::Enable( bool enable )
{
+ wxCHECK_RET( m_menuItem, "invalid menu item" );
+
gtk_widget_set_sensitive( m_menuItem, enable );
m_isEnabled = enable;
}
bool wxMenuItem::IsChecked() const
{
+ wxCHECK_MSG( m_menuItem, FALSE, "invalid menu item" );
+
wxCHECK( IsCheckable(), FALSE ); // can't get state of uncheckable item!
bool bIsChecked = ((GtkCheckMenuItem*)m_menuItem)->active != 0;
return bIsChecked;
}
+//-----------------------------------------------------------------------------
+// wxMenuItem
+//-----------------------------------------------------------------------------
+
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
wxMenu::wxMenu( const wxString& title, const wxFunction func )
if (!g_capturing)
{
- wxNode *node = win->GetChildren()->First();
+ wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
if (!g_capturing)
{
- wxNode *node = win->GetChildren()->First();
+ wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
if (!g_capturing)
{
- wxNode *node = win->GetChildren()->First();
+ wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
bool wxWindow::DestroyChildren()
{
- if (GetChildren())
+ wxNode *node;
+ while ((node = m_children.First()) != (wxNode *)NULL)
{
- wxNode *node;
- while ((node = GetChildren()->First()) != (wxNode *)NULL)
+ wxWindow *child;
+ if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
{
- wxWindow *child;
- if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
- {
- delete child;
- if (GetChildren()->Member(child)) delete node;
- }
+ delete child;
+ if (m_children.Member(child)) delete node;
}
}
return TRUE;
int maxX = 0;
int maxY = 0;
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_childrenFirst();
while ( node )
{
wxWindow *win = (wxWindow *)node->Data();
m_children.Append( child );
}
-wxList *wxWindow::GetChildren()
+wxList& wxWindow::GetChildren() const
{
- return (&m_children);
+ return m_children;
}
wxWindow *wxWindow::ReParent( wxWindow *newParent )
void wxWindow::RemoveChild( wxWindow *child )
{
- if (GetChildren()) GetChildren()->DeleteObject( child );
+ m_children.DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
{
noChanges = 0;
noFailures = 0;
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.first();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
constr->centreX.SetDone(FALSE);
constr->centreY.SetDone(FALSE);
}
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *win = (wxWindow *)node->Data();
if (recurse)
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = m_children.First();
while (node)
{
wxWindow *win = (wxWindow *)node->Data();