From 6bc8a1c80bd02b418107ba089f0026125c43e39b Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 22 May 1999 15:13:18 +0000 Subject: [PATCH] GTK 1.0 compilation (not tested) toolbars can now get inserted in the client area as well (as normal windows) Menu accels can be functions keys Made DialogEd work again (with wxGTK :-) ) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/frame.h | 1 + include/wx/gtk1/frame.h | 1 + samples/controls/controls.cpp | 8 ++++---- src/gtk/frame.cpp | 25 ++++++++++++++----------- src/gtk/menu.cpp | 10 ++++++++-- src/gtk/window.cpp | 26 ++++++++++++++++++++++++++ src/gtk1/frame.cpp | 25 ++++++++++++++----------- src/gtk1/menu.cpp | 10 ++++++++-- src/gtk1/window.cpp | 26 ++++++++++++++++++++++++++ utils/dialoged/src/reseditr.cpp | 12 ------------ utils/dialoged/src/reseditr.h | 1 - 11 files changed, 102 insertions(+), 43 deletions(-) diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 70bb8392b6..13a543e0fe 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -114,6 +114,7 @@ public: GtkWidget *m_mainWidget; bool m_menuBarDetached; bool m_toolBarDetached; + bool m_insertInClientArea; /* not from within OnCreateXXX */ protected: virtual void DoSetSize(int x, int y, diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 70bb8392b6..13a543e0fe 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -114,6 +114,7 @@ public: GtkWidget *m_mainWidget; bool m_menuBarDetached; bool m_toolBarDetached; + bool m_insertInClientArea; /* not from within OnCreateXXX */ protected: virtual void DoSetSize(int x, int y, diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 3e76a41b2d..eb24f789a6 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -183,17 +183,17 @@ bool MyApp::OnInit() frame->SetIcon( wxICON(mondrian) ); wxMenu *file_menu = new wxMenu; - file_menu->Append(MINIMAL_ABOUT, "&About"); - file_menu->Append(MINIMAL_QUIT, "E&xit"); + file_menu->Append(MINIMAL_ABOUT, "&About\tF1"); + file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample"); wxMenuBar *menu_bar = new wxMenuBar( wxMB_DOCKABLE ); menu_bar->Append(file_menu, "&File"); #if wxUSE_TOOLTIPS wxMenu *tooltip_menu = new wxMenu; - tooltip_menu->Append(MINIMAL_SET_TOOLTIP_DELAY, "Set &delay"); + tooltip_menu->Append(MINIMAL_SET_TOOLTIP_DELAY, "Set &delay\tCtrl-D"); tooltip_menu->AppendSeparator(); - tooltip_menu->Append(MINIMAL_ENABLE_TOOLTIPS, "&Toggle tooltips", + tooltip_menu->Append(MINIMAL_ENABLE_TOOLTIPS, "&Toggle tooltips\tCrtl-T", "enable/disable tooltips", TRUE); tooltip_menu->Check(MINIMAL_ENABLE_TOOLTIPS, TRUE); menu_bar->Append(tooltip_menu, "&Tooltips"); diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index e2b3321531..b4195914f8 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -249,13 +249,10 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) * virtual function here as wxWindows requires different ways to insert * a child in container classes. */ -static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) +static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) { - if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar)) + if (!parent->m_insertInClientArea) { - /* actually, menubars are never inserted here, but this - may change one day */ - /* these are outside the client area */ wxFrame* frame = (wxFrame*) parent; gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget), @@ -318,7 +315,8 @@ wxFrame::wxFrame() m_mainWidget = (GtkWidget*) NULL; m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; - m_insertCallback = wxInsertChildInFrame; + m_insertCallback = (wxInsertChildFunction) NULL; + m_insertInClientArea = TRUE; } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -334,7 +332,8 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, m_mainWidget = (GtkWidget*) NULL; m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; - m_insertCallback = wxInsertChildInFrame; + m_insertCallback = (wxInsertChildFunction) NULL; + m_insertInClientArea = TRUE; Create( parent, id, title, pos, size, style, name ); } @@ -350,7 +349,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, m_title = title; - m_insertCallback = wxInsertChildInFrame; + m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; @@ -752,7 +751,7 @@ void wxFrame::OnInternalIdle() DoMenuUpdates(); } -void wxFrame::OnCloseWindow( wxCloseEvent& event ) +void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) { Destroy(); } @@ -887,15 +886,19 @@ void wxFrame::OnMenuHighlight(wxMenuEvent& event) } } -wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) +wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) { wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") ); wxCHECK_MSG( m_frameToolBar == NULL, FALSE, _T("recreating toolbar in wxFrame") ); + m_insertInClientArea = FALSE; + m_frameToolBar = OnCreateToolBar( style, id, name ); - GetChildren().DeleteObject( m_frameToolBar ); + if (m_frameToolBar) GetChildren().DeleteObject( m_frameToolBar ); + + m_insertInClientArea = TRUE; m_sizeSet = FALSE; diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 6907fe1d68..fd67e5ee80 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -488,9 +488,9 @@ void wxMenuItem::SetName( const wxString& str ) #if (GTK_MINOR_VERSION > 0) m_text << _T('_'); } else - if (*pc == _T('/')) + if (*pc == _T('/')) /* we have to filter out slashes ... */ { - m_text << _T('\\'); + m_text << _T('\\'); /* ... and replace them with back slashes */ #endif } else @@ -677,6 +677,12 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool entry.accelerator = hotbuf; break; } + case _T('F'): /* function keys */ + { + strcpy( hotbuf, hotkey.mb_str() ); + entry.accelerator = hotbuf; + break; + } default: { } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 7821833663..f7059d2e7c 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -44,6 +44,10 @@ #include "gdk/gdkkeysyms.h" #include "wx/gtk/win_gtk.h" +#if (GTK_MINOR_VERSION == 0) +#include "gdk/gdkx.h" +#endif + //----------------------------------------------------------------------------- // documentation on internals //----------------------------------------------------------------------------- @@ -185,6 +189,22 @@ extern bool g_isIdle; // key event conversion routines //----------------------------------------------------------------------------- +#if (GTK_MINOR_VERSION == 0) +static guint +gdk_keyval_to_upper (guint keyval) +{ + if (keyval) + { + KeySym lower_val = 0; + KeySym upper_val = 0; + + XConvertCase (keyval, &lower_val, &upper_val); + return upper_val; + } + return 0; +} +#endif + static long map_to_unmodified_wx_keysym( KeySym keysym ) { guint key_code = 0; @@ -638,6 +658,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ret = win->GetEventHandler()->ProcessEvent( new_event ); } +#if (GTK_MINOR_VERSION > 0) /* pressing F10 will activate the menu bar of the top frame */ if ( (!ret) && (gdk_event->keyval == GDK_F10) ) @@ -665,6 +686,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ancestor = ancestor->GetParent(); } } +#endif /* Damn, I forgot why this didn't work, but it didn't work. @@ -1232,7 +1254,9 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() ); wxMouseEvent event( wxEVT_ENTER_WINDOW ); +#if (GTK_MINOR_VERSION > 0) event.SetTimestamp( gdk_event->time ); +#endif event.SetEventObject( win ); int x = 0; @@ -1279,7 +1303,9 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); wxMouseEvent event( wxEVT_LEAVE_WINDOW ); +#if (GTK_MINOR_VERSION > 0) event.SetTimestamp( gdk_event->time ); +#endif event.SetEventObject( win ); int x = 0; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index e2b3321531..b4195914f8 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -249,13 +249,10 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) * virtual function here as wxWindows requires different ways to insert * a child in container classes. */ -static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child ) +static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) { - if (wxIS_KIND_OF(child,wxToolBar) || wxIS_KIND_OF(child,wxMenuBar)) + if (!parent->m_insertInClientArea) { - /* actually, menubars are never inserted here, but this - may change one day */ - /* these are outside the client area */ wxFrame* frame = (wxFrame*) parent; gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget), @@ -318,7 +315,8 @@ wxFrame::wxFrame() m_mainWidget = (GtkWidget*) NULL; m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; - m_insertCallback = wxInsertChildInFrame; + m_insertCallback = (wxInsertChildFunction) NULL; + m_insertInClientArea = TRUE; } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -334,7 +332,8 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, m_mainWidget = (GtkWidget*) NULL; m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; - m_insertCallback = wxInsertChildInFrame; + m_insertCallback = (wxInsertChildFunction) NULL; + m_insertInClientArea = TRUE; Create( parent, id, title, pos, size, style, name ); } @@ -350,7 +349,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, m_title = title; - m_insertCallback = wxInsertChildInFrame; + m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; @@ -752,7 +751,7 @@ void wxFrame::OnInternalIdle() DoMenuUpdates(); } -void wxFrame::OnCloseWindow( wxCloseEvent& event ) +void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) ) { Destroy(); } @@ -887,15 +886,19 @@ void wxFrame::OnMenuHighlight(wxMenuEvent& event) } } -wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) +wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) { wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") ); wxCHECK_MSG( m_frameToolBar == NULL, FALSE, _T("recreating toolbar in wxFrame") ); + m_insertInClientArea = FALSE; + m_frameToolBar = OnCreateToolBar( style, id, name ); - GetChildren().DeleteObject( m_frameToolBar ); + if (m_frameToolBar) GetChildren().DeleteObject( m_frameToolBar ); + + m_insertInClientArea = TRUE; m_sizeSet = FALSE; diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 6907fe1d68..fd67e5ee80 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -488,9 +488,9 @@ void wxMenuItem::SetName( const wxString& str ) #if (GTK_MINOR_VERSION > 0) m_text << _T('_'); } else - if (*pc == _T('/')) + if (*pc == _T('/')) /* we have to filter out slashes ... */ { - m_text << _T('\\'); + m_text << _T('\\'); /* ... and replace them with back slashes */ #endif } else @@ -677,6 +677,12 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool entry.accelerator = hotbuf; break; } + case _T('F'): /* function keys */ + { + strcpy( hotbuf, hotkey.mb_str() ); + entry.accelerator = hotbuf; + break; + } default: { } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 7821833663..f7059d2e7c 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -44,6 +44,10 @@ #include "gdk/gdkkeysyms.h" #include "wx/gtk/win_gtk.h" +#if (GTK_MINOR_VERSION == 0) +#include "gdk/gdkx.h" +#endif + //----------------------------------------------------------------------------- // documentation on internals //----------------------------------------------------------------------------- @@ -185,6 +189,22 @@ extern bool g_isIdle; // key event conversion routines //----------------------------------------------------------------------------- +#if (GTK_MINOR_VERSION == 0) +static guint +gdk_keyval_to_upper (guint keyval) +{ + if (keyval) + { + KeySym lower_val = 0; + KeySym upper_val = 0; + + XConvertCase (keyval, &lower_val, &upper_val); + return upper_val; + } + return 0; +} +#endif + static long map_to_unmodified_wx_keysym( KeySym keysym ) { guint key_code = 0; @@ -638,6 +658,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ret = win->GetEventHandler()->ProcessEvent( new_event ); } +#if (GTK_MINOR_VERSION > 0) /* pressing F10 will activate the menu bar of the top frame */ if ( (!ret) && (gdk_event->keyval == GDK_F10) ) @@ -665,6 +686,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e ancestor = ancestor->GetParent(); } } +#endif /* Damn, I forgot why this didn't work, but it didn't work. @@ -1232,7 +1254,9 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() ); wxMouseEvent event( wxEVT_ENTER_WINDOW ); +#if (GTK_MINOR_VERSION > 0) event.SetTimestamp( gdk_event->time ); +#endif event.SetEventObject( win ); int x = 0; @@ -1279,7 +1303,9 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); wxMouseEvent event( wxEVT_LEAVE_WINDOW ); +#if (GTK_MINOR_VERSION > 0) event.SetTimestamp( gdk_event->time ); +#endif event.SetEventObject( win ); int x = 0; diff --git a/utils/dialoged/src/reseditr.cpp b/utils/dialoged/src/reseditr.cpp index 34a5dd365c..55a60b962c 100644 --- a/utils/dialoged/src/reseditr.cpp +++ b/utils/dialoged/src/reseditr.cpp @@ -2188,7 +2188,6 @@ void wxResourceEditorFrame::OnCloseWindow(wxCloseEvent& event) */ BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow, wxScrolledWindow) - EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll) EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint) END_EVENT_TABLE() @@ -2207,17 +2206,6 @@ wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow() { } -void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent& event) -{ - wxScrolledWindow::OnScroll(event); - - int x, y; - ViewStart(& x, & y); - - if (m_childWindow) - m_childWindow->Move(m_marginX + (- x * 10), m_marginY + (- y * 10)); -} - void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); diff --git a/utils/dialoged/src/reseditr.h b/utils/dialoged/src/reseditr.h index 5a87b10d06..56e17c1adf 100644 --- a/utils/dialoged/src/reseditr.h +++ b/utils/dialoged/src/reseditr.h @@ -382,7 +382,6 @@ class wxResourceEditorScrolledWindow: public wxScrolledWindow long style = 0); ~wxResourceEditorScrolledWindow(); - void OnScroll(wxScrollEvent& event); void OnPaint(wxPaintEvent& event); void DrawTitle(wxDC& dc);