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
This commit is contained in:
Robert Roebling
1999-10-09 09:06:35 +00:00
parent ca43a38c0f
commit 307f16e829
9 changed files with 64 additions and 25 deletions

View File

@@ -78,7 +78,7 @@ public:
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name ); virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name );
virtual wxToolBar *GetToolBar() const; virtual wxToolBar *GetToolBar() const;
void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } void SetToolBar(wxToolBar *toolbar);
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
virtual void SetMenuBar( wxMenuBar *menuBar ); virtual void SetMenuBar( wxMenuBar *menuBar );

View File

@@ -196,13 +196,7 @@ public:
bool m_delayedFont:1; bool m_delayedFont:1;
bool m_delayedForegroundColour:1; bool m_delayedForegroundColour:1;
bool m_delayedBackgroundColour: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 // contains GTK's widgets internal information about non-default widget
// font and colours. we create one for each widget that gets any // font and colours. we create one for each widget that gets any
// non-default attribute set via SetFont() or SetForegroundColour() / // non-default attribute set via SetFont() or SetForegroundColour() /

View File

@@ -78,7 +78,7 @@ public:
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name ); virtual wxToolBar *OnCreateToolBar( long style, wxWindowID id, const wxString& name );
virtual wxToolBar *GetToolBar() const; virtual wxToolBar *GetToolBar() const;
void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } void SetToolBar(wxToolBar *toolbar);
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
virtual void SetMenuBar( wxMenuBar *menuBar ); virtual void SetMenuBar( wxMenuBar *menuBar );

View File

@@ -196,13 +196,7 @@ public:
bool m_delayedFont:1; bool m_delayedFont:1;
bool m_delayedForegroundColour:1; bool m_delayedForegroundColour:1;
bool m_delayedBackgroundColour: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 // contains GTK's widgets internal information about non-default widget
// font and colours. we create one for each widget that gets any // font and colours. we create one for each widget that gets any
// non-default attribute set via SetFont() or SetForegroundColour() / // non-default attribute set via SetFont() or SetForegroundColour() /

View File

@@ -38,6 +38,7 @@ public:
MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size ); MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size );
~MyCanvas(); ~MyCanvas();
void OnPaint( wxPaintEvent &event ); void OnPaint( wxPaintEvent &event );
void OnQueryPosition( wxCommandEvent &event );
void OnAddButton( wxCommandEvent &event ); void OnAddButton( wxCommandEvent &event );
void OnDeleteButton( wxCommandEvent &event ); void OnDeleteButton( wxCommandEvent &event );
void OnMoveButton( wxCommandEvent &event ); void OnMoveButton( wxCommandEvent &event );
@@ -84,6 +85,7 @@ IMPLEMENT_APP(MyApp)
#define ID_DELBUTTON 2 #define ID_DELBUTTON 2
#define ID_MOVEBUTTON 3 #define ID_MOVEBUTTON 3
#define ID_SCROLLWIN 4 #define ID_SCROLLWIN 4
#define ID_QUERYPOS 5
#define ID_NEWBUTTON 10 #define ID_NEWBUTTON 10
@@ -92,7 +94,8 @@ IMPLEMENT_APP(MyApp)
IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow) IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(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_ADDBUTTON, MyCanvas::OnAddButton)
EVT_BUTTON( ID_DELBUTTON, MyCanvas::OnDeleteButton) EVT_BUTTON( ID_DELBUTTON, MyCanvas::OnDeleteButton)
EVT_BUTTON( ID_MOVEBUTTON, MyCanvas::OnMoveButton) EVT_BUTTON( ID_MOVEBUTTON, MyCanvas::OnMoveButton)
@@ -117,7 +120,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
"examples." "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) ); (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) ) void MyCanvas::OnAddButton( wxCommandEvent &WXUNUSED(event) )
{ {
wxLogMessage( "Inserting button at position 50,50" ); wxLogMessage( "Inserting button at position 10,70..." );
(void) new wxButton( this, ID_NEWBUTTON, "new button", wxPoint(50,50) ); (void) new wxButton( this, ID_NEWBUTTON, "new button", wxPoint(10,70), wxSize(80,25) );
} }
void MyCanvas::OnDeleteButton( wxCommandEvent &event ) void MyCanvas::OnDeleteButton( wxCommandEvent &event )
{ {
wxLogMessage( "deleting button inserted with ""add button""" ); wxLogMessage( "Deleting button inserted with ""Add button""..." );
wxWindow *win = FindWindow( ID_NEWBUTTON ); wxWindow *win = FindWindow( ID_NEWBUTTON );
if (win) if (win)
win->Destroy(); win->Destroy();
@@ -209,6 +222,8 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.DrawText( "Some text", 140, 140 ); dc.DrawText( "Some text", 140, 140 );
dc.DrawRectangle( 10, 70, 80, 25 );
dc.DrawRectangle( 100, 160, 200, 200 ); dc.DrawRectangle( 100, 160, 200, 200 );
} }

View File

@@ -942,6 +942,26 @@ wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString&
return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); 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 wxToolBar *wxFrame::GetToolBar() const
{ {
return m_frameToolBar; return m_frameToolBar;

View File

@@ -931,10 +931,8 @@ void wxTextCtrl::OnInternalIdle()
wxCursor cursor = m_cursor; wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor; if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (cursor.Ok() && m_currentGdkCursor != cursor) if (cursor.Ok())
{ {
m_currentGdkCursor = cursor;
GdkWindow *window = (GdkWindow*) NULL; GdkWindow *window = (GdkWindow*) NULL;
if (HasFlag(wxTE_MULTILINE)) if (HasFlag(wxTE_MULTILINE))
window = GTK_TEXT(m_text)->text_area; window = GTK_TEXT(m_text)->text_area;

View File

@@ -942,6 +942,26 @@ wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString&
return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); 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 wxToolBar *wxFrame::GetToolBar() const
{ {
return m_frameToolBar; return m_frameToolBar;

View File

@@ -931,10 +931,8 @@ void wxTextCtrl::OnInternalIdle()
wxCursor cursor = m_cursor; wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor; if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (cursor.Ok() && m_currentGdkCursor != cursor) if (cursor.Ok())
{ {
m_currentGdkCursor = cursor;
GdkWindow *window = (GdkWindow*) NULL; GdkWindow *window = (GdkWindow*) NULL;
if (HasFlag(wxTE_MULTILINE)) if (HasFlag(wxTE_MULTILINE))
window = GTK_TEXT(m_text)->text_area; window = GTK_TEXT(m_text)->text_area;