From 307f16e829979a22bf00b699b5b2e852cd4eb59e Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 9 Oct 1999 09:06:35 +0000 Subject: [PATCH] Changed SetToolBar() to behave a bit smarter. Untested. Removed some unused variables. More tests in scroll sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/frame.h | 2 +- include/wx/gtk/window.h | 6 ------ include/wx/gtk1/frame.h | 2 +- include/wx/gtk1/window.h | 6 ------ samples/scroll/scroll.cpp | 25 ++++++++++++++++++++----- src/gtk/frame.cpp | 20 ++++++++++++++++++++ src/gtk/textctrl.cpp | 4 +--- src/gtk1/frame.cpp | 20 ++++++++++++++++++++ src/gtk1/textctrl.cpp | 4 +--- 9 files changed, 64 insertions(+), 25 deletions(-) diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 497343f54f..0268757d71 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -78,7 +78,7 @@ public: const wxString& name = wxToolBarNameStr); virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name ); virtual wxToolBar *GetToolBar() const; - void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } + void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR virtual void SetMenuBar( wxMenuBar *menuBar ); diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index cb221b82fb..ae02499808 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -196,13 +196,7 @@ public: bool m_delayedFont:1; bool m_delayedForegroundColour:1; bool m_delayedBackgroundColour:1; - bool m_delayedCursor:1; - // the cursor is set in OnInternalIdle(). this fields holds - // a reference to the cursor currently set in theGdk window - // so that we don't have to set it more than once - wxCursor m_currentGdkCursor; - // contains GTK's widgets internal information about non-default widget // font and colours. we create one for each widget that gets any // non-default attribute set via SetFont() or SetForegroundColour() / diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 497343f54f..0268757d71 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -78,7 +78,7 @@ public: const wxString& name = wxToolBarNameStr); virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name ); virtual wxToolBar *GetToolBar() const; - void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } + void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR virtual void SetMenuBar( wxMenuBar *menuBar ); diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index cb221b82fb..ae02499808 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -196,13 +196,7 @@ public: bool m_delayedFont:1; bool m_delayedForegroundColour:1; bool m_delayedBackgroundColour:1; - bool m_delayedCursor:1; - // the cursor is set in OnInternalIdle(). this fields holds - // a reference to the cursor currently set in theGdk window - // so that we don't have to set it more than once - wxCursor m_currentGdkCursor; - // contains GTK's widgets internal information about non-default widget // font and colours. we create one for each widget that gets any // non-default attribute set via SetFont() or SetForegroundColour() / diff --git a/samples/scroll/scroll.cpp b/samples/scroll/scroll.cpp index 67c936293b..0d20a0aed6 100644 --- a/samples/scroll/scroll.cpp +++ b/samples/scroll/scroll.cpp @@ -38,6 +38,7 @@ public: MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size ); ~MyCanvas(); void OnPaint( wxPaintEvent &event ); + void OnQueryPosition( wxCommandEvent &event ); void OnAddButton( wxCommandEvent &event ); void OnDeleteButton( wxCommandEvent &event ); void OnMoveButton( wxCommandEvent &event ); @@ -84,6 +85,7 @@ IMPLEMENT_APP(MyApp) #define ID_DELBUTTON 2 #define ID_MOVEBUTTON 3 #define ID_SCROLLWIN 4 +#define ID_QUERYPOS 5 #define ID_NEWBUTTON 10 @@ -92,7 +94,8 @@ IMPLEMENT_APP(MyApp) IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow) BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) - EVT_PAINT( MyCanvas::OnPaint) + EVT_PAINT( MyCanvas::OnPaint) + EVT_BUTTON( ID_QUERYPOS, MyCanvas::OnQueryPosition) EVT_BUTTON( ID_ADDBUTTON, MyCanvas::OnAddButton) EVT_BUTTON( ID_DELBUTTON, MyCanvas::OnDeleteButton) EVT_BUTTON( ID_MOVEBUTTON, MyCanvas::OnMoveButton) @@ -117,7 +120,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, "examples." }; - m_button = new wxButton( this, -1, "wxButton", wxPoint(10,110) ); + m_button = new wxButton( this, ID_QUERYPOS, "Query position", wxPoint(10,110) ); (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,150) ); @@ -171,15 +174,25 @@ MyCanvas::~MyCanvas() { } +void MyCanvas::OnQueryPosition( wxCommandEvent &WXUNUSED(event) ) +{ + wxPoint pt( m_button->GetPosition() ); + wxLogMessage( """wxButton"" position %d %d", pt.x, pt.y ); + if ((pt.x == 10) && (pt.y == 110)) + wxLogMessage( "-> Correct." ); + else + wxLogMessage( "-> Incorrect." ); +} + void MyCanvas::OnAddButton( wxCommandEvent &WXUNUSED(event) ) { - wxLogMessage( "Inserting button at position 50,50" ); - (void) new wxButton( this, ID_NEWBUTTON, "new button", wxPoint(50,50) ); + wxLogMessage( "Inserting button at position 10,70..." ); + (void) new wxButton( this, ID_NEWBUTTON, "new button", wxPoint(10,70), wxSize(80,25) ); } void MyCanvas::OnDeleteButton( wxCommandEvent &event ) { - wxLogMessage( "deleting button inserted with ""add button""" ); + wxLogMessage( "Deleting button inserted with ""Add button""..." ); wxWindow *win = FindWindow( ID_NEWBUTTON ); if (win) win->Destroy(); @@ -209,6 +222,8 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.DrawText( "Some text", 140, 140 ); + dc.DrawRectangle( 10, 70, 80, 25 ); + dc.DrawRectangle( 100, 160, 200, 200 ); } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 9cc4171c2d..c0d27bd464 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -942,6 +942,26 @@ wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); } +void wxFrame::SetToolBar(wxToolBar *toolbar) +{ + m_frameToolBar = toolbar; + if (m_frameToolBar) + { + /* insert into toolbar area if not already there */ + if (m_frameToolBar->m_widget->parent != m_mainWidget) + { + gtk_widget_ref( m_frameToolBar->m_widget ); + gtk_widget_unparent( m_frameToolBar->m_widget ); + + m_insertInClientArea = TRUE; + wxInsertChildInFrame( this, m_frameToolBar ); + m_insertInClientArea = FALSE; + + gtk_widget_unref( m_frameToolBar->m_widget ); + } + } +} + wxToolBar *wxFrame::GetToolBar() const { return m_frameToolBar; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index db100d48ec..66fbb33bd5 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -931,10 +931,8 @@ void wxTextCtrl::OnInternalIdle() wxCursor cursor = m_cursor; if (g_globalCursor.Ok()) cursor = g_globalCursor; - if (cursor.Ok() && m_currentGdkCursor != cursor) + if (cursor.Ok()) { - m_currentGdkCursor = cursor; - GdkWindow *window = (GdkWindow*) NULL; if (HasFlag(wxTE_MULTILINE)) window = GTK_TEXT(m_text)->text_area; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 9cc4171c2d..c0d27bd464 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -942,6 +942,26 @@ wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); } +void wxFrame::SetToolBar(wxToolBar *toolbar) +{ + m_frameToolBar = toolbar; + if (m_frameToolBar) + { + /* insert into toolbar area if not already there */ + if (m_frameToolBar->m_widget->parent != m_mainWidget) + { + gtk_widget_ref( m_frameToolBar->m_widget ); + gtk_widget_unparent( m_frameToolBar->m_widget ); + + m_insertInClientArea = TRUE; + wxInsertChildInFrame( this, m_frameToolBar ); + m_insertInClientArea = FALSE; + + gtk_widget_unref( m_frameToolBar->m_widget ); + } + } +} + wxToolBar *wxFrame::GetToolBar() const { return m_frameToolBar; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index db100d48ec..66fbb33bd5 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -931,10 +931,8 @@ void wxTextCtrl::OnInternalIdle() wxCursor cursor = m_cursor; if (g_globalCursor.Ok()) cursor = g_globalCursor; - if (cursor.Ok() && m_currentGdkCursor != cursor) + if (cursor.Ok()) { - m_currentGdkCursor = cursor; - GdkWindow *window = (GdkWindow*) NULL; if (HasFlag(wxTE_MULTILINE)) window = GTK_TEXT(m_text)->text_area; -- 2.45.2