added wxMenu::Append( wxMenuItem )
added keyboard hooks to glcanvas fixed probs with slider/spin button etc git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -98,6 +98,7 @@ public:
|
|||||||
const wxString &helpStr = "", bool checkable = FALSE);
|
const wxString &helpStr = "", bool checkable = FALSE);
|
||||||
void Append(int id, const wxString &item,
|
void Append(int id, const wxString &item,
|
||||||
wxMenu *subMenu, const wxString &helpStr = "" );
|
wxMenu *subMenu, const wxString &helpStr = "" );
|
||||||
|
void Append(wxMenuItem *pItem);
|
||||||
void Break() {};
|
void Break() {};
|
||||||
|
|
||||||
// find item by name/id
|
// find item by name/id
|
||||||
|
@@ -98,6 +98,7 @@ public:
|
|||||||
const wxString &helpStr = "", bool checkable = FALSE);
|
const wxString &helpStr = "", bool checkable = FALSE);
|
||||||
void Append(int id, const wxString &item,
|
void Append(int id, const wxString &item,
|
||||||
wxMenu *subMenu, const wxString &helpStr = "" );
|
wxMenu *subMenu, const wxString &helpStr = "" );
|
||||||
|
void Append(wxMenuItem *pItem);
|
||||||
void Break() {};
|
void Break() {};
|
||||||
|
|
||||||
// find item by name/id
|
// find item by name/id
|
||||||
|
@@ -62,7 +62,7 @@ wxMenuBar::wxMenuBar()
|
|||||||
|
|
||||||
m_menubar = gtk_menu_bar_new();
|
m_menubar = gtk_menu_bar_new();
|
||||||
|
|
||||||
m_widget = GTK_WIDGET(m_menubar);
|
m_widget = GTK_WIDGET(m_menubar);
|
||||||
|
|
||||||
PostCreation();
|
PostCreation();
|
||||||
|
|
||||||
@@ -494,9 +494,9 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
|
|||||||
wxMenuItem *mitem = new wxMenuItem();
|
wxMenuItem *mitem = new wxMenuItem();
|
||||||
mitem->SetId(id);
|
mitem->SetId(id);
|
||||||
mitem->SetText(text);
|
mitem->SetText(text);
|
||||||
|
mitem->SetHelp(helpStr);
|
||||||
|
|
||||||
GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText());
|
GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText());
|
||||||
mitem->SetHelp(helpStr);
|
|
||||||
mitem->SetMenuItem(menuItem);
|
mitem->SetMenuItem(menuItem);
|
||||||
mitem->SetSubMenu(subMenu);
|
mitem->SetSubMenu(subMenu);
|
||||||
|
|
||||||
@@ -514,6 +514,43 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
|
|||||||
m_items.Append( mitem );
|
m_items.Append( mitem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMenu::Append( wxMenuItem *item )
|
||||||
|
{
|
||||||
|
m_items.Append( item );
|
||||||
|
|
||||||
|
GtkWidget *menuItem = (GtkWidget*) NULL;
|
||||||
|
|
||||||
|
if (item->IsSeparator())
|
||||||
|
menuItem = gtk_menu_item_new();
|
||||||
|
else if (item->IsSubMenu())
|
||||||
|
menuItem = gtk_menu_item_new_with_label(item->GetText());
|
||||||
|
else
|
||||||
|
menuItem = item->IsCheckable() ? gtk_check_menu_item_new_with_label(item->GetText())
|
||||||
|
: gtk_menu_item_new_with_label(item->GetText());
|
||||||
|
|
||||||
|
if (!item->IsSeparator())
|
||||||
|
{
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
|
||||||
|
if (!item->IsSubMenu())
|
||||||
|
{
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_menu_append( GTK_MENU(m_menu), menuItem );
|
||||||
|
gtk_widget_show( menuItem );
|
||||||
|
item->SetMenuItem(menuItem);
|
||||||
|
}
|
||||||
|
|
||||||
int wxMenu::FindItem( const wxString itemString ) const
|
int wxMenu::FindItem( const wxString itemString ) const
|
||||||
{
|
{
|
||||||
wxString s( itemString );
|
wxString s( itemString );
|
||||||
|
@@ -37,6 +37,7 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi
|
|||||||
|
|
||||||
float diff = win->m_adjust->value - win->m_oldPos;
|
float diff = win->m_adjust->value - win->m_oldPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldPos = win->m_adjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
|
|||||||
|
|
||||||
float diff = win->m_adjust->value - win->m_oldPos;
|
float diff = win->m_adjust->value - win->m_oldPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldPos = win->m_adjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -56,11 +57,11 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
|
|||||||
|
|
||||||
wxScrollEvent event( command, win->GetId(), value, orient );
|
wxScrollEvent event( command, win->GetId(), value, orient );
|
||||||
event.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
win->ProcessEvent( event );
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
|
||||||
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
|
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
|
||||||
cevent.SetEventObject( win );
|
cevent.SetEventObject( win );
|
||||||
win->ProcessEvent( cevent );
|
win->GetEventHandler()->ProcessEvent( cevent );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -33,9 +33,10 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
|
|||||||
{
|
{
|
||||||
if (!win->HasVMT()) return;
|
if (!win->HasVMT()) return;
|
||||||
if (g_blockEventsOnDrag) return;
|
if (g_blockEventsOnDrag) return;
|
||||||
|
|
||||||
float diff = win->m_adjust->value - win->m_oldPos;
|
float diff = win->m_adjust->value - win->m_oldPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldPos = win->m_adjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
|
|||||||
event.SetOrientation( wxVERTICAL );
|
event.SetOrientation( wxVERTICAL );
|
||||||
event.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
|
|
||||||
win->ProcessEvent( event );
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -300,6 +300,7 @@ void wxTextCtrl::WriteText( const wxString &text )
|
|||||||
{
|
{
|
||||||
/* this moves the cursor pos to behind the inserted text */
|
/* this moves the cursor pos to behind the inserted text */
|
||||||
gint len = GTK_EDITABLE(m_text)->current_pos;
|
gint len = GTK_EDITABLE(m_text)->current_pos;
|
||||||
|
|
||||||
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
|
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
|
||||||
|
|
||||||
/* bring editable's cursor uptodate. bug in GTK. */
|
/* bring editable's cursor uptodate. bug in GTK. */
|
||||||
|
@@ -1081,6 +1081,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
|
|||||||
|
|
||||||
float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
|
float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldVerticalPos = win->m_vAdjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -1128,6 +1129,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
|
|||||||
|
|
||||||
float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
|
float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldHorizontalPos = win->m_hAdjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -2835,7 +2837,9 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
|
|||||||
void wxWindow::SetFont( const wxFont &font )
|
void wxWindow::SetFont( const wxFont &font )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, "invalid window" );
|
wxCHECK_RET( m_widget != NULL, "invalid window" );
|
||||||
|
|
||||||
|
if (m_font == font) return;
|
||||||
|
|
||||||
if (((wxFont*)&font)->Ok())
|
if (((wxFont*)&font)->Ok())
|
||||||
m_font = font;
|
m_font = font;
|
||||||
else
|
else
|
||||||
|
@@ -62,7 +62,7 @@ wxMenuBar::wxMenuBar()
|
|||||||
|
|
||||||
m_menubar = gtk_menu_bar_new();
|
m_menubar = gtk_menu_bar_new();
|
||||||
|
|
||||||
m_widget = GTK_WIDGET(m_menubar);
|
m_widget = GTK_WIDGET(m_menubar);
|
||||||
|
|
||||||
PostCreation();
|
PostCreation();
|
||||||
|
|
||||||
@@ -494,9 +494,9 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
|
|||||||
wxMenuItem *mitem = new wxMenuItem();
|
wxMenuItem *mitem = new wxMenuItem();
|
||||||
mitem->SetId(id);
|
mitem->SetId(id);
|
||||||
mitem->SetText(text);
|
mitem->SetText(text);
|
||||||
|
mitem->SetHelp(helpStr);
|
||||||
|
|
||||||
GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText());
|
GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText());
|
||||||
mitem->SetHelp(helpStr);
|
|
||||||
mitem->SetMenuItem(menuItem);
|
mitem->SetMenuItem(menuItem);
|
||||||
mitem->SetSubMenu(subMenu);
|
mitem->SetSubMenu(subMenu);
|
||||||
|
|
||||||
@@ -514,6 +514,43 @@ void wxMenu::Append( int id, const wxString &text, wxMenu *subMenu, const wxStri
|
|||||||
m_items.Append( mitem );
|
m_items.Append( mitem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMenu::Append( wxMenuItem *item )
|
||||||
|
{
|
||||||
|
m_items.Append( item );
|
||||||
|
|
||||||
|
GtkWidget *menuItem = (GtkWidget*) NULL;
|
||||||
|
|
||||||
|
if (item->IsSeparator())
|
||||||
|
menuItem = gtk_menu_item_new();
|
||||||
|
else if (item->IsSubMenu())
|
||||||
|
menuItem = gtk_menu_item_new_with_label(item->GetText());
|
||||||
|
else
|
||||||
|
menuItem = item->IsCheckable() ? gtk_check_menu_item_new_with_label(item->GetText())
|
||||||
|
: gtk_menu_item_new_with_label(item->GetText());
|
||||||
|
|
||||||
|
if (!item->IsSeparator())
|
||||||
|
{
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
|
||||||
|
if (!item->IsSubMenu())
|
||||||
|
{
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_menu_append( GTK_MENU(m_menu), menuItem );
|
||||||
|
gtk_widget_show( menuItem );
|
||||||
|
item->SetMenuItem(menuItem);
|
||||||
|
}
|
||||||
|
|
||||||
int wxMenu::FindItem( const wxString itemString ) const
|
int wxMenu::FindItem( const wxString itemString ) const
|
||||||
{
|
{
|
||||||
wxString s( itemString );
|
wxString s( itemString );
|
||||||
|
@@ -37,6 +37,7 @@ static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *wi
|
|||||||
|
|
||||||
float diff = win->m_adjust->value - win->m_oldPos;
|
float diff = win->m_adjust->value - win->m_oldPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldPos = win->m_adjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
|
|||||||
|
|
||||||
float diff = win->m_adjust->value - win->m_oldPos;
|
float diff = win->m_adjust->value - win->m_oldPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldPos = win->m_adjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -56,11 +57,11 @@ static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
|
|||||||
|
|
||||||
wxScrollEvent event( command, win->GetId(), value, orient );
|
wxScrollEvent event( command, win->GetId(), value, orient );
|
||||||
event.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
win->ProcessEvent( event );
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
|
||||||
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
|
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() );
|
||||||
cevent.SetEventObject( win );
|
cevent.SetEventObject( win );
|
||||||
win->ProcessEvent( cevent );
|
win->GetEventHandler()->ProcessEvent( cevent );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -33,9 +33,10 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
|
|||||||
{
|
{
|
||||||
if (!win->HasVMT()) return;
|
if (!win->HasVMT()) return;
|
||||||
if (g_blockEventsOnDrag) return;
|
if (g_blockEventsOnDrag) return;
|
||||||
|
|
||||||
float diff = win->m_adjust->value - win->m_oldPos;
|
float diff = win->m_adjust->value - win->m_oldPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldPos = win->m_adjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
|
|||||||
event.SetOrientation( wxVERTICAL );
|
event.SetOrientation( wxVERTICAL );
|
||||||
event.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
|
|
||||||
win->ProcessEvent( event );
|
win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -300,6 +300,7 @@ void wxTextCtrl::WriteText( const wxString &text )
|
|||||||
{
|
{
|
||||||
/* this moves the cursor pos to behind the inserted text */
|
/* this moves the cursor pos to behind the inserted text */
|
||||||
gint len = GTK_EDITABLE(m_text)->current_pos;
|
gint len = GTK_EDITABLE(m_text)->current_pos;
|
||||||
|
|
||||||
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
|
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
|
||||||
|
|
||||||
/* bring editable's cursor uptodate. bug in GTK. */
|
/* bring editable's cursor uptodate. bug in GTK. */
|
||||||
|
@@ -1081,6 +1081,7 @@ static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
|
|||||||
|
|
||||||
float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
|
float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldVerticalPos = win->m_vAdjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -1128,6 +1129,7 @@ static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *
|
|||||||
|
|
||||||
float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
|
float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
|
||||||
if (fabs(diff) < 0.2) return;
|
if (fabs(diff) < 0.2) return;
|
||||||
|
win->m_oldHorizontalPos = win->m_hAdjust->value;
|
||||||
|
|
||||||
wxEventType command = wxEVT_NULL;
|
wxEventType command = wxEVT_NULL;
|
||||||
|
|
||||||
@@ -2835,7 +2837,9 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
|
|||||||
void wxWindow::SetFont( const wxFont &font )
|
void wxWindow::SetFont( const wxFont &font )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, "invalid window" );
|
wxCHECK_RET( m_widget != NULL, "invalid window" );
|
||||||
|
|
||||||
|
if (m_font == font) return;
|
||||||
|
|
||||||
if (((wxFont*)&font)->Ok())
|
if (((wxFont*)&font)->Ok())
|
||||||
m_font = font;
|
m_font = font;
|
||||||
else
|
else
|
||||||
|
@@ -227,6 +227,9 @@ bool wxGLCanvas::Create( wxWindow *parent, wxWindowID id,
|
|||||||
gtk_signal_connect( GTK_OBJECT(m_glWidget), "draw",
|
gtk_signal_connect( GTK_OBJECT(m_glWidget), "draw",
|
||||||
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
|
||||||
|
|
||||||
|
/* connect to key press and mouse handlers etc. */
|
||||||
|
ConnectWidget( m_glWidget );
|
||||||
|
|
||||||
gtk_widget_show( m_glWidget );
|
gtk_widget_show( m_glWidget );
|
||||||
|
|
||||||
m_glContext = new wxGLContext( TRUE, this, palette );
|
m_glContext = new wxGLContext( TRUE, this, palette );
|
||||||
|
Reference in New Issue
Block a user