Some work on tabbing and menu accels,

Added a missing "Activate()" to docvwmdi sample.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4271 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-10-30 15:08:33 +00:00
parent cb36238601
commit 354aa1e366
18 changed files with 292 additions and 156 deletions

View File

@ -30,7 +30,7 @@ public:
~wxMenuItem();
// implement base class virtuals
virtual void SetText( const wxString& str ) { DoSetText(str); }
virtual void SetText( const wxString& str );
virtual void Enable( bool enable = TRUE );
virtual void Check( bool check = TRUE );
virtual bool IsChecked() const;
@ -38,6 +38,7 @@ public:
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }
wxString GetFactoryPath() const;
wxString GetHotKey() const { return m_hotKey; }

View File

@ -30,7 +30,7 @@ public:
~wxMenuItem();
// implement base class virtuals
virtual void SetText( const wxString& str ) { DoSetText(str); }
virtual void SetText( const wxString& str );
virtual void Enable( bool enable = TRUE );
virtual void Check( bool check = TRUE );
virtual bool IsChecked() const;
@ -38,6 +38,7 @@ public:
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }
wxString GetFactoryPath() const;
wxString GetHotKey() const { return m_hotKey; }

View File

@ -407,10 +407,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
wxPanel *panel = new wxPanel(m_notebook);
m_listbox = new wxListBox( panel, ID_LISTBOX,
wxPoint(10,10), wxSize(120,70),
5, choices, wxLB_ALWAYS_SB | wxLB_MULTIPLE );
5, choices, wxLB_ALWAYS_SB );
m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
wxPoint(10,90), wxSize(120,70),
5, choices, wxLB_SORT | wxLB_EXTENDED );
5, choices, wxLB_SORT );
SetControlClientData("listbox", m_listbox);
SetControlClientData("listbox", m_listboxSorted);

View File

@ -871,10 +871,13 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
{
// start drag operation
wxTextDataObject textData(m_strText);
wxDropSource source(textData, this,
wxCURSOR_PENCIL, // for copy
wxDropSource source(textData, this
#ifdef __WXMSW__
,wxCURSOR_PENCIL, // for copy
wxCURSOR_SPRAYCAN, // for move
wxCURSOR_QUESTION_ARROW); // for nothing
wxCURSOR_QUESTION_ARROW // for nothing
#endif
);
const char *pc;

View File

@ -57,6 +57,7 @@ bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
frame->SetSize(-1, -1, x, y);
#endif
frame->Show(TRUE);
Activate(TRUE);
return TRUE;
}

View File

@ -20,19 +20,20 @@
class MyCanvas: public wxScrolledWindow
{
public:
public:
wxView *view;
MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
virtual void OnDraw(wxDC& dc);
void OnMouseEvent(wxMouseEvent& event);
DECLARE_EVENT_TABLE()
private:
DECLARE_EVENT_TABLE()
};
class MyTextWindow: public wxTextCtrl
{
public:
public:
wxView *view;
MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
@ -40,40 +41,41 @@ class MyTextWindow: public wxTextCtrl
class DrawingView: public wxView
{
DECLARE_DYNAMIC_CLASS(DrawingView)
private:
public:
wxFrame *frame;
MyCanvas *canvas;
public:
wxFrame *frame;
MyCanvas *canvas;
DrawingView(void) { canvas = (MyCanvas *) NULL; frame = (wxFrame *) NULL; };
~DrawingView(void) {};
DrawingView() { canvas = (MyCanvas *) NULL; frame = (wxFrame *) NULL; }
~DrawingView() {}
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
bool OnClose(bool deleteWindow = TRUE);
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
bool OnClose(bool deleteWindow = TRUE);
void OnCut(wxCommandEvent& event);
void OnCut(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
private:
DECLARE_DYNAMIC_CLASS(DrawingView)
DECLARE_EVENT_TABLE()
};
class TextEditView: public wxView
{
DECLARE_DYNAMIC_CLASS(TextEditView)
private:
public:
wxFrame *frame;
MyTextWindow *textsw;
public:
wxFrame *frame;
MyTextWindow *textsw;
TextEditView(): wxView() { frame = (wxFrame *) NULL; textsw = (MyTextWindow *) NULL; }
~TextEditView(void) {}
TextEditView(): wxView() { frame = (wxFrame *) NULL; textsw = (MyTextWindow *) NULL; }
~TextEditView() {}
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
bool OnClose(bool deleteWindow = TRUE);
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
bool OnClose(bool deleteWindow = TRUE);
private:
DECLARE_DYNAMIC_CLASS(TextEditView)
};
#endif

View File

@ -80,16 +80,37 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
return FALSE;
}
m_widget = gtk_button_new_with_label( "" );
/*
wxString label2( label );
for (size_t i = 0; i < label2.Len(); i++)
{
if (label2.GetChar(i) == wxT('&'))
label2.SetChar(i,wxT('_'));
}
GtkWidget *accel_label = gtk_accel_label_new( label2.mb_str() );
gtk_widget_show( accel_label );
m_widget = gtk_button_new();
gtk_container_add( GTK_CONTAINER(m_widget), accel_label );
gtk_accel_label_set_accel_widget( GTK_ACCEL_LABEL(accel_label), m_widget );
guint accel_key = gtk_label_parse_uline (GTK_LABEL(accel_label), label2.mb_str() );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(accel_label) );
wxControl::SetLabel( label );
*/
m_widget = gtk_button_new_with_label("");
SetLabel( label );
#if (GTK_MINOR_VERSION > 0)
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
#endif
SetLabel(label);
int x = 0; int y = 0;
wxFont new_font( parent->GetFont() );
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );

View File

@ -26,12 +26,9 @@
#include "wx/tooltip.h"
#endif
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// idle system
@ -170,32 +167,52 @@ gtk_listbox_button_press_callback( GtkWidget *widget,
// "key_press_event"
//-----------------------------------------------------------------------------
#if wxUSE_CHECKLISTBOX
static gint
gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxListBox *listbox )
{
if (g_isIdle) wxapp_install_idle_handler();
if (g_isIdle)
wxapp_install_idle_handler();
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnDrag)
return FALSE;
if (!listbox->m_hasVMT) return FALSE;
bool ret = FALSE;
if (gdk_event->keyval != ' ') return FALSE;
if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
{
wxNavigationKeyEvent new_event;
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetCurrentFocus( listbox );
ret = listbox->GetEventHandler()->ProcessEvent( new_event );
}
#if wxUSE_CHECKLISTBOX
if ((gdk_event->keyval != ' ') && (listbox->m_hasCheckBoxes) && (!ret))
{
int sel = listbox->GtkGetIndex( widget );
int sel = listbox->GtkGetIndex( widget );
wxCheckListBox *clb = (wxCheckListBox *)listbox;
wxCheckListBox *clb = (wxCheckListBox *)listbox;
clb->Check( sel, !clb->IsChecked(sel) );
clb->Check( sel, !clb->IsChecked(sel) );
wxCommandEvent new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
new_event.SetEventObject( listbox );
new_event.SetInt( sel );
ret = listbox->GetEventHandler()->ProcessEvent( new_event );
}
#endif // wxUSE_CHECKLISTBOX
wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
event.SetEventObject( listbox );
event.SetInt( sel );
listbox->GetEventHandler()->ProcessEvent( event );
if (ret)
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
return TRUE;
}
return FALSE;
}
#endif // wxUSE_CHECKLISTBOX
//-----------------------------------------------------------------------------
// "select" and "deselect"
@ -461,15 +478,10 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
(GtkSignalFunc)gtk_listbox_button_release_callback,
(gpointer) this );
#if wxUSE_CHECKLISTBOX
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
gtk_signal_connect( GTK_OBJECT(list_item),
"key_press_event",
(GtkSignalFunc)gtk_listbox_key_press_callback,
(gpointer)this );
}
#endif // wxUSE_CHECKLISTBOX
gtk_widget_show( list_item );

View File

@ -561,7 +561,6 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
m_menuItem = (GtkWidget *) NULL;
// call it after initializing m_menuItem to NULL
DoSetText(text);
}
@ -570,6 +569,23 @@ wxMenuItem::~wxMenuItem()
// don't delete menu items, the menus take care of that
}
void wxMenuItem::SetText( const wxString& str )
{
DoSetText(str);
if (m_menuItem)
{
GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
/* set new text */
gtk_label_set( label, m_text.mb_str());
/* reparse key accel */
guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
}
}
// it's valid for this function to be called even if m_menuItem == NULL
void wxMenuItem::DoSetText( const wxString& str )
{
@ -593,7 +609,7 @@ void wxMenuItem::DoSetText( const wxString& str )
#endif
}
else
m_text << *pc;
m_text << *pc;
}
/* only GTK 1.2 knows about hot keys */
@ -605,12 +621,6 @@ void wxMenuItem::DoSetText( const wxString& str )
m_hotKey = pc;
}
#endif
if (m_menuItem)
{
GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
gtk_label_set( label, m_text.mb_str());
}
}
void wxMenuItem::Check( bool check )
@ -644,6 +654,19 @@ bool wxMenuItem::IsChecked() const
return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
}
wxString wxMenuItem::GetFactoryPath() const
{
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString path( wxT("<main>/") );
for ( const wxChar *pc = m_text; *pc != wxT('\0'); pc++ )
{
while (*pc == wxT('_')) pc++; /* skip it */
path << *pc;
}
return path;
}
//-----------------------------------------------------------------------------
// wxMenu
//-----------------------------------------------------------------------------
@ -848,20 +871,13 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool
strncpy(s_accel, GetHotKey(*mitem).mb_str(), WXSIZEOF(s_accel));
entry.accelerator = s_accel;
#else
entry.accelerator = NULL;
entry.accelerator = (char*) NULL;
#endif
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString s = wxT("<main>/");
for ( const wxChar *pc = text; *pc != wxT('\0'); pc++ )
{
while (*pc == wxT('_')) pc++; /* skip it */
s << *pc;
}
GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, s.mb_str() );
wxString path( mitem->GetFactoryPath() );
GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() );
#else
@ -911,15 +927,8 @@ void wxMenu::Append( int id, const wxString &item, wxMenu *subMenu, const wxStri
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString s = wxT("<main>/");
for ( const wxChar *pc = text; *pc != wxT('\0'); pc++ )
{
if (*pc == wxT('_')) pc++; /* skip it */
s << *pc;
}
GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, s.mb_str() );
wxString path( mitem->GetFactoryPath() );
GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() );
#else
@ -990,6 +999,8 @@ void wxMenu::Delete( int id )
wxMenuItem *item = (wxMenuItem*)node->Data();
if (item->GetId() == id)
{
/* TODO: this code doesn't delete the item factory item and
this seems impossible as of GTK 1.2.6. */
gtk_widget_destroy( item->GetMenuItem() );
m_items.DeleteNode( node );
return;

View File

@ -20,6 +20,7 @@
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
@ -117,7 +118,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_pizza_put( GTK_PIZZA(m_parent->m_wxwindow),
GTK_WIDGET(m_radio),

View File

@ -97,6 +97,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& name)
{
m_needParent = TRUE;
m_acceptsFocus = TRUE;
wxSize new_size = size;
if (new_size.y == -1)

View File

@ -2486,19 +2486,37 @@ void wxWindow::SetFocus()
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget)
wxNode *node = m_children.First();
while (node)
{
if (GTK_WIDGET_CAN_FOCUS(connect_widget) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus())
{
child->SetFocus();
return;
}
node = node->Next();
}
if (m_wxwindow)
{
gtk_widget_grab_focus (m_wxwindow);
return;
}
if (m_widget)
{
if (GTK_WIDGET_CAN_FOCUS(m_widget) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
{
gtk_widget_grab_focus (connect_widget);
gtk_widget_grab_focus (m_widget);
}
else if (GTK_IS_CONTAINER(connect_widget))
else if (GTK_IS_CONTAINER(m_widget))
{
gtk_container_focus( GTK_CONTAINER(connect_widget), GTK_DIR_TAB_FORWARD );
gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
}
else
{
// ?
}
}
}

View File

@ -80,16 +80,37 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
return FALSE;
}
m_widget = gtk_button_new_with_label( "" );
/*
wxString label2( label );
for (size_t i = 0; i < label2.Len(); i++)
{
if (label2.GetChar(i) == wxT('&'))
label2.SetChar(i,wxT('_'));
}
GtkWidget *accel_label = gtk_accel_label_new( label2.mb_str() );
gtk_widget_show( accel_label );
m_widget = gtk_button_new();
gtk_container_add( GTK_CONTAINER(m_widget), accel_label );
gtk_accel_label_set_accel_widget( GTK_ACCEL_LABEL(accel_label), m_widget );
guint accel_key = gtk_label_parse_uline (GTK_LABEL(accel_label), label2.mb_str() );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(accel_label) );
wxControl::SetLabel( label );
*/
m_widget = gtk_button_new_with_label("");
SetLabel( label );
#if (GTK_MINOR_VERSION > 0)
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
#endif
SetLabel(label);
int x = 0; int y = 0;
wxFont new_font( parent->GetFont() );
GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font );

View File

@ -26,12 +26,9 @@
#include "wx/tooltip.h"
#endif
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// idle system
@ -170,32 +167,52 @@ gtk_listbox_button_press_callback( GtkWidget *widget,
// "key_press_event"
//-----------------------------------------------------------------------------
#if wxUSE_CHECKLISTBOX
static gint
gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxListBox *listbox )
{
if (g_isIdle) wxapp_install_idle_handler();
if (g_isIdle)
wxapp_install_idle_handler();
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnDrag)
return FALSE;
if (!listbox->m_hasVMT) return FALSE;
bool ret = FALSE;
if (gdk_event->keyval != ' ') return FALSE;
if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
{
wxNavigationKeyEvent new_event;
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetCurrentFocus( listbox );
ret = listbox->GetEventHandler()->ProcessEvent( new_event );
}
#if wxUSE_CHECKLISTBOX
if ((gdk_event->keyval != ' ') && (listbox->m_hasCheckBoxes) && (!ret))
{
int sel = listbox->GtkGetIndex( widget );
int sel = listbox->GtkGetIndex( widget );
wxCheckListBox *clb = (wxCheckListBox *)listbox;
wxCheckListBox *clb = (wxCheckListBox *)listbox;
clb->Check( sel, !clb->IsChecked(sel) );
clb->Check( sel, !clb->IsChecked(sel) );
wxCommandEvent new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
new_event.SetEventObject( listbox );
new_event.SetInt( sel );
ret = listbox->GetEventHandler()->ProcessEvent( new_event );
}
#endif // wxUSE_CHECKLISTBOX
wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
event.SetEventObject( listbox );
event.SetInt( sel );
listbox->GetEventHandler()->ProcessEvent( event );
if (ret)
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
return TRUE;
}
return FALSE;
}
#endif // wxUSE_CHECKLISTBOX
//-----------------------------------------------------------------------------
// "select" and "deselect"
@ -461,15 +478,10 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
(GtkSignalFunc)gtk_listbox_button_release_callback,
(gpointer) this );
#if wxUSE_CHECKLISTBOX
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
gtk_signal_connect( GTK_OBJECT(list_item),
"key_press_event",
(GtkSignalFunc)gtk_listbox_key_press_callback,
(gpointer)this );
}
#endif // wxUSE_CHECKLISTBOX
gtk_widget_show( list_item );

View File

@ -561,7 +561,6 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
m_menuItem = (GtkWidget *) NULL;
// call it after initializing m_menuItem to NULL
DoSetText(text);
}
@ -570,6 +569,23 @@ wxMenuItem::~wxMenuItem()
// don't delete menu items, the menus take care of that
}
void wxMenuItem::SetText( const wxString& str )
{
DoSetText(str);
if (m_menuItem)
{
GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
/* set new text */
gtk_label_set( label, m_text.mb_str());
/* reparse key accel */
guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
}
}
// it's valid for this function to be called even if m_menuItem == NULL
void wxMenuItem::DoSetText( const wxString& str )
{
@ -593,7 +609,7 @@ void wxMenuItem::DoSetText( const wxString& str )
#endif
}
else
m_text << *pc;
m_text << *pc;
}
/* only GTK 1.2 knows about hot keys */
@ -605,12 +621,6 @@ void wxMenuItem::DoSetText( const wxString& str )
m_hotKey = pc;
}
#endif
if (m_menuItem)
{
GtkLabel *label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
gtk_label_set( label, m_text.mb_str());
}
}
void wxMenuItem::Check( bool check )
@ -644,6 +654,19 @@ bool wxMenuItem::IsChecked() const
return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
}
wxString wxMenuItem::GetFactoryPath() const
{
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString path( wxT("<main>/") );
for ( const wxChar *pc = m_text; *pc != wxT('\0'); pc++ )
{
while (*pc == wxT('_')) pc++; /* skip it */
path << *pc;
}
return path;
}
//-----------------------------------------------------------------------------
// wxMenu
//-----------------------------------------------------------------------------
@ -848,20 +871,13 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool
strncpy(s_accel, GetHotKey(*mitem).mb_str(), WXSIZEOF(s_accel));
entry.accelerator = s_accel;
#else
entry.accelerator = NULL;
entry.accelerator = (char*) NULL;
#endif
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString s = wxT("<main>/");
for ( const wxChar *pc = text; *pc != wxT('\0'); pc++ )
{
while (*pc == wxT('_')) pc++; /* skip it */
s << *pc;
}
GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, s.mb_str() );
wxString path( mitem->GetFactoryPath() );
GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() );
#else
@ -911,15 +927,8 @@ void wxMenu::Append( int id, const wxString &item, wxMenu *subMenu, const wxStri
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString s = wxT("<main>/");
for ( const wxChar *pc = text; *pc != wxT('\0'); pc++ )
{
if (*pc == wxT('_')) pc++; /* skip it */
s << *pc;
}
GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, s.mb_str() );
wxString path( mitem->GetFactoryPath() );
GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() );
#else
@ -990,6 +999,8 @@ void wxMenu::Delete( int id )
wxMenuItem *item = (wxMenuItem*)node->Data();
if (item->GetId() == id)
{
/* TODO: this code doesn't delete the item factory item and
this seems impossible as of GTK 1.2.6. */
gtk_widget_destroy( item->GetMenuItem() );
m_items.DeleteNode( node );
return;

View File

@ -20,6 +20,7 @@
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
@ -117,7 +118,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_pizza_put( GTK_PIZZA(m_parent->m_wxwindow),
GTK_WIDGET(m_radio),

View File

@ -97,6 +97,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& name)
{
m_needParent = TRUE;
m_acceptsFocus = TRUE;
wxSize new_size = size;
if (new_size.y == -1)

View File

@ -2486,19 +2486,37 @@ void wxWindow::SetFocus()
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget)
wxNode *node = m_children.First();
while (node)
{
if (GTK_WIDGET_CAN_FOCUS(connect_widget) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus())
{
child->SetFocus();
return;
}
node = node->Next();
}
if (m_wxwindow)
{
gtk_widget_grab_focus (m_wxwindow);
return;
}
if (m_widget)
{
if (GTK_WIDGET_CAN_FOCUS(m_widget) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
{
gtk_widget_grab_focus (connect_widget);
gtk_widget_grab_focus (m_widget);
}
else if (GTK_IS_CONTAINER(connect_widget))
else if (GTK_IS_CONTAINER(m_widget))
{
gtk_container_focus( GTK_CONTAINER(connect_widget), GTK_DIR_TAB_FORWARD );
gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
}
else
{
// ?
}
}
}