From 028003016290b62becb31873c38a202d6e61eec4 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 27 Oct 1998 17:58:46 +0000 Subject: [PATCH] Motif wxNotebook about done; added print/preview to OGLEdit sample git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/tabg.h | 18 +++---- include/wx/motif/notebook.h | 19 ++----- samples/mdi/mdi.cpp | 1 + samples/notebook/test.cpp | 10 ++++ src/generic/listctrl.cpp | 6 +-- src/generic/tabg.cpp | 29 ++++++++--- src/motif/listbox.cpp | 33 +++++++++++- src/motif/notebook.cpp | 84 ++++++++++++++++++++++++------ src/motif/settings.cpp | 3 +- src/motif/textctrl.cpp | 36 +++++++++++++ src/motif/window.cpp | 18 ++++++- src/msw/app.cpp | 2 +- src/msw/control.cpp | 2 +- src/msw/frame.cpp | 2 +- src/msw/menu.cpp | 2 +- src/msw/notebook.cpp | 4 +- src/msw/spinbutt.cpp | 2 +- src/msw/textctrl.cpp | 4 +- src/msw/window.cpp | 2 +- utils/ogl/samples/ogledit/view.cpp | 78 +++++++++++++++++++++++++-- 20 files changed, 290 insertions(+), 65 deletions(-) diff --git a/include/wx/generic/tabg.h b/include/wx/generic/tabg.h index 5a1b934d26..e937b156b1 100644 --- a/include/wx/generic/tabg.h +++ b/include/wx/generic/tabg.h @@ -40,8 +40,8 @@ public: inline void SetLabel(const wxString& str) { m_controlLabel = str; } inline wxString GetLabel(void) const { return m_controlLabel; } - inline void SetFont(wxFont *f) { m_labelFont = f; } - inline wxFont *GetFont(void) const { return m_labelFont; } + inline void SetFont(const wxFont& f) { m_labelFont = f; } + inline wxFont *GetFont(void) const { return (wxFont*) & m_labelFont; } inline void SetSelected(bool sel) { m_isSelected = sel; } inline bool IsSelected(void) const { return m_isSelected; } @@ -68,7 +68,7 @@ protected: wxTabView* m_view; wxString m_controlLabel; bool m_isSelected; - wxFont* m_labelFont; + wxFont m_labelFont; int m_offsetX; // Offsets from top-left of tab view area (the area below the tabs) int m_offsetY; int m_width; @@ -188,11 +188,11 @@ public: inline void SetVerticalTabTextSpacing(int s) { m_tabVerticalTextSpacing = s; } inline int GetVerticalTabTextSpacing() const { return m_tabVerticalTextSpacing; } - inline wxFont *GetTabFont() const { return m_tabFont; } - inline void SetTabFont(wxFont *f) { m_tabFont = f; } + inline wxFont *GetTabFont() const { return (wxFont*) & m_tabFont; } + inline void SetTabFont(const wxFont& f) { m_tabFont = f; } - inline wxFont *GetSelectedTabFont() const { return m_tabSelectedFont; } - inline void SetSelectedTabFont(wxFont *f) { m_tabSelectedFont = f; } + inline wxFont *GetSelectedTabFont() const { return (wxFont*) & m_tabSelectedFont; } + inline void SetSelectedTabFont(const wxFont& f) { m_tabSelectedFont = f; } // Find the node and the column at which this control is positioned. wxNode *FindTabNodeAndColumn(wxTabControl *control, int *col) const ; @@ -253,8 +253,8 @@ protected: wxPen* m_backgroundPen; wxBrush* m_backgroundBrush; - wxFont* m_tabFont; - wxFont* m_tabSelectedFont; + wxFont m_tabFont; + wxFont m_tabSelectedFont; int m_noTabs; diff --git a/include/wx/motif/notebook.h b/include/wx/motif/notebook.h index d21311e216..734d17fc05 100644 --- a/include/wx/motif/notebook.h +++ b/include/wx/motif/notebook.h @@ -49,6 +49,9 @@ public: int GetSelection() const { return m_nSel; } int GetOldSelection() const { return m_nOldSel; } + void SetSelection(int sel) { m_nSel = sel; } + void SetOldSelection(int oldSel) { m_nOldSel = oldSel; } + private: int m_nSel, // currently selected page m_nOldSel; // previously selected page @@ -73,22 +76,7 @@ public: // Called when a tab is activated virtual void OnTabActivate(int activateId, int deactivateId); -/* - // Specific to this class - void AddTabWindow(int id, wxWindow *window); - wxWindow *GetTabWindow(int id) const ; - void ClearWindows(bool deleteWindows = TRUE); - inline wxWindow *GetCurrentWindow() const { return m_currentWindow; } - void ShowWindowForTab(int id); -*/ - protected: -/* - // List of panels, one for each tab. Indexed - // by tab ID. - wxList m_tabWindows; - wxWindow* m_currentWindow; -*/ wxNotebook* m_notebook; }; @@ -204,6 +192,7 @@ public: virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); + virtual wxRect GetAvailableClientSize(); protected: // common part of all ctors diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index e52b33de8e..a1ac5a7ec1 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -190,6 +190,7 @@ END_EVENT_TABLE() MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size): wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL) { + SetBackgroundColour(wxColour("WHITE")); } // Define the repainting behaviour diff --git a/samples/notebook/test.cpp b/samples/notebook/test.cpp index 3358e36552..f86b14b797 100644 --- a/samples/notebook/test.cpp +++ b/samples/notebook/test.cpp @@ -81,12 +81,14 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window) // Add some panels wxPanel *panel1 = new wxPanel(notebook, -1); + // panel1->SetBackgroundColour(wxColour("RED")); (void)new wxButton(panel1, -1, "Press me", wxPoint(10, 10)); (void)new wxTextCtrl(panel1, -1, "1234", wxPoint(10, 40), wxSize(120, 150)); notebook->AddPage(panel1, "Cat"); wxPanel *panel2 = new wxPanel(notebook, -1); + panel2->SetBackgroundColour(wxColour("BLUE")); wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" }; (void)new wxListBox(panel2, -1, wxPoint(5, 5), wxSize(170, 80), 5, animals); @@ -95,6 +97,14 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window) wxTE_MULTILINE); notebook->AddPage(panel2, "Dog"); + + wxPanel *panel3 = new wxPanel(notebook, -1); + panel3->SetBackgroundColour(wxColour("WHITE")); + notebook->AddPage(panel3, "Goat"); + + wxPanel *panel4 = new wxPanel(notebook, -1); + panel4->SetBackgroundColour(wxColour("YELLOW")); + notebook->AddPage(panel4, "Sheep"); } BEGIN_EVENT_TABLE(MyDialog, wxDialog) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index ed022c17ce..eb6ae8bde3 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1087,7 +1087,7 @@ void wxListMainWindow::OnRenameAccept() void wxListMainWindow::OnMouse( wxMouseEvent &event ) { - if (GetParent()->ProcessEvent( event)) return; + if (GetParent()->GetEventHandler()->ProcessEvent( event)) return; if (!m_current) return; if (m_dirty) return; @@ -1402,7 +1402,7 @@ void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() ); event.SetEventObject( GetParent() ); - GetParent()->ProcessEvent( event ); + GetParent()->GetEventHandler()->ProcessEvent( event ); } void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) ) @@ -2054,7 +2054,7 @@ void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data ) bool wxListMainWindow::OnListNotify( wxListEvent &event ) { - if (GetParent()) GetParent()->ProcessEvent( event ); + if (GetParent()) GetParent()->GetEventHandler()->ProcessEvent( event ); return FALSE; } diff --git a/src/generic/tabg.cpp b/src/generic/tabg.cpp index 5adc584c4c..fe7590fd50 100644 --- a/src/generic/tabg.cpp +++ b/src/generic/tabg.cpp @@ -43,7 +43,6 @@ wxTabControl::wxTabControl(wxTabView *v) { m_view = v; m_isSelected = FALSE; - m_labelFont = (wxFont *) NULL; m_offsetX = 0; m_offsetY = 0; m_width = 0; @@ -86,7 +85,11 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) dc.SetBrush(*m_view->GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. +#ifdef __WXMOTIF__ + dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); +#else dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); +#endif } // Draw highlight and shadow @@ -152,6 +155,10 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) if ( GetRowPosition() < (maxPositions - 1) ) topY = tabY + GetHeight() + tabHeightInc; +#ifdef __WXMOTIF__ + topY -= 1; +#endif + // Shadow dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); // Draw black line to emphasize shadow @@ -170,6 +177,10 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); +#ifdef __WXMOTIF__ + subtractThis += 1; +#endif + // Draw only to next tab down. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); @@ -185,9 +196,9 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; if (m_isSelected) - dc.SetFont(*m_view->GetSelectedTabFont()); + dc.SetFont(* m_view->GetSelectedTabFont()); else - dc.SetFont(*GetFont()); + dc.SetFont(* GetFont()); wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); @@ -510,13 +521,14 @@ wxTabView::wxTabView(long style) m_shadowPen = wxGREY_PEN; m_backgroundPen = wxLIGHT_GREY_PEN; m_backgroundBrush = wxLIGHT_GREY_BRUSH; - m_tabFont = wxTheFontList->FindOrCreateFont(9, wxSWISS, wxNORMAL, wxNORMAL); - m_tabSelectedFont = wxTheFontList->FindOrCreateFont(9, wxSWISS, wxNORMAL, wxBOLD); + m_tabFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + m_tabSelectedFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); m_window = (wxWindow *) NULL; } wxTabView::~wxTabView() { + ClearTabs(TRUE); } // Automatically positions tabs @@ -578,7 +590,7 @@ wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *exi tabControl->SetSize(GetTabWidth(), GetTabHeight()); tabControl->SetId(id); tabControl->SetLabel(label); - tabControl->SetFont(GetTabFont()); + tabControl->SetFont(* GetTabFont()); tabLayer->Append(tabControl); m_noTabs ++; @@ -779,7 +791,12 @@ void wxTabView::Draw(wxDC& dc) dc.DrawLine( (GetViewRect().x), (GetViewRect().y + GetViewRect().height + 1), +#if defined(__WXMOTIF__) + (GetViewRect().x + GetViewRect().width + 1), +#else (GetViewRect().x + GetViewRect().width + 2), +#endif + (GetViewRect().y + GetViewRect().height + 1) ); diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index 2952cadbab..3d864f49d5 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -112,8 +112,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height); - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW); - ChangeBackgroundColour(); return TRUE; @@ -751,10 +749,41 @@ void wxListBox::ChangeFont(bool keepOriginalSize) void wxListBox::ChangeBackgroundColour() { wxWindow::ChangeBackgroundColour(); + + Widget parent = XtParent ((Widget) m_mainWidget); + Widget hsb, vsb; + + XtVaGetValues (parent, + XmNhorizontalScrollBar, &hsb, + XmNverticalScrollBar, &vsb, + NULL); + + /* TODO: should scrollbars be affected? Should probably have separate + * function to change them (by default, taken from wxSystemSettings) + DoChangeBackgroundColour((WXWidget) hsb, m_backgroundColour, TRUE); + DoChangeBackgroundColour((WXWidget) vsb, m_backgroundColour, TRUE); + */ + + DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); } void wxListBox::ChangeForegroundColour() { wxWindow::ChangeForegroundColour(); + + Widget parent = XtParent ((Widget) m_mainWidget); + Widget hsb, vsb; + + XtVaGetValues (parent, + XmNhorizontalScrollBar, &hsb, + XmNverticalScrollBar, &vsb, + NULL); + /* TODO: should scrollbars be affected? Should probably have separate + * function to change them (by default, taken from wxSystemSettings) + DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); + DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); + DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); + */ } + diff --git a/src/motif/notebook.cpp b/src/motif/notebook.cpp index 7b520792b9..ba296eb4d0 100644 --- a/src/motif/notebook.cpp +++ b/src/motif/notebook.cpp @@ -26,6 +26,9 @@ #include #include +#include +#include + // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -96,16 +99,9 @@ bool wxNotebook::Create(wxWindow *parent, { // base init SetName(name); - SetParent(parent); m_windowId = id == -1 ? NewControlId() : id; - // style - m_windowStyle = style; - - if ( parent != NULL ) - parent->AddChild(this); - // It's like a normal window... if (!wxWindow::Create(parent, id, pos, size, style, name)) return FALSE; @@ -137,6 +133,9 @@ int wxNotebook::GetRowCount() const int wxNotebook::SetSelection(int nPage) { + if (nPage == -1) + return 0; + wxASSERT( IS_VALID_PAGE(nPage) ); ChangePage(m_nSelection, nPage); @@ -250,6 +249,7 @@ bool wxNotebook::InsertPage(int nPage, wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); m_tabView->AddTab(nPage, strText); + pPage->Show(FALSE); /* if (bSelect) @@ -323,9 +323,13 @@ void wxNotebook::OnSize(wxSizeEvent& event) unsigned int nCount = m_aPages.Count(); for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_aPages[nPage]; - pPage->SetSize(rect.x + 2, rect.y + 2, rect.width - 2, rect.height - 2); - if ( pPage->GetAutoLayout() ) - pPage->Layout(); + if (pPage->IsShown()) + { + wxRect clientRect = GetAvailableClientSize(); + pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height); + if ( pPage->GetAutoLayout() ) + pPage->Layout(); + } } Refresh(); } @@ -401,12 +405,20 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) if ( nOldSel != -1 ) { m_aPages[nOldSel]->Show(FALSE); + m_aPages[nOldSel]->Lower(); } wxNotebookPage *pPage = m_aPages[nSel]; + + wxRect clientRect = GetAvailableClientSize(); + pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height); + pPage->Show(TRUE); + pPage->Raise(); pPage->SetFocus(); + Refresh(); + m_nSelection = nSel; } @@ -438,6 +450,23 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event) ) m_tabView->Draw(dc); } +wxRect wxNotebook::GetAvailableClientSize() +{ + int cw, ch; + GetClientSize(& cw, & ch); + + int tabHeight = m_tabView->GetTotalTabHeight(); + + // TODO: these margins should be configurable. + wxRect rect; + rect.x = 6; + rect.y = tabHeight + 6; + rect.width = cw - 12; + rect.height = ch - 4 - rect.y ; + + return rect; +} + /* * wxNotebookTabView */ @@ -448,8 +477,6 @@ wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabVie { m_notebook = notebook; -// m_currentWindow = (wxWindow *) NULL; - m_notebook->SetTabView(this); SetWindow(m_notebook); @@ -457,7 +484,6 @@ wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabVie wxNotebookTabView::~wxNotebookTabView(void) { -// ClearWindows(TRUE); } // Called when a tab is activated @@ -465,16 +491,44 @@ void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId) { if (!m_notebook) return; - + + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId()); + event.SetEventObject(m_notebook); + event.SetSelection(activateId); + event.SetOldSelection(deactivateId); + m_notebook->GetEventHandler()->ProcessEvent(event); + + /* wxWindow *oldWindow = ((deactivateId == -1) ? 0 : m_notebook->GetPage(deactivateId)); wxWindow *newWindow = m_notebook->GetPage(activateId); if (oldWindow) + { oldWindow->Show(FALSE); + oldWindow->Lower(); + } if (newWindow) + { newWindow->Show(TRUE); - + newWindow->Raise(); + + int cw, ch; + m_notebook->GetClientSize(& cw, & ch); + + int tabHeight = GetTotalTabHeight(); + wxRect rect; + rect.x = 4; + rect.y = tabHeight + 4; + rect.width = cw - 8; + rect.height = ch - 4 - rect.y ; + + newWindow->SetSize(rect.x + 2, rect.y + 2, rect.width - 2, rect.height - 2); + newWindow->Refresh(); + } + + // TODO: only refresh the tab area. m_notebook->Refresh(); +*/ } #if 0 diff --git a/src/motif/settings.cpp b/src/motif/settings.cpp index 9bfe3411ca..1c639007d8 100644 --- a/src/motif/settings.cpp +++ b/src/motif/settings.cpp @@ -74,7 +74,8 @@ wxColour wxSystemSettings::GetSystemColour(int index) case wxSYS_COLOUR_INFOBK: case wxSYS_COLOUR_APPWORKSPACE: { - return *wxWHITE; + return wxColour("LIGHT GREY"); + // return *wxWHITE; } } return *wxWHITE; diff --git a/src/motif/textctrl.cpp b/src/motif/textctrl.cpp index ba5066934a..3d7c94d2e4 100644 --- a/src/motif/textctrl.cpp +++ b/src/motif/textctrl.cpp @@ -646,11 +646,47 @@ void wxTextCtrl::ChangeFont(bool keepOriginalSize) void wxTextCtrl::ChangeBackgroundColour() { wxWindow::ChangeBackgroundColour(); + + Widget parent = XtParent ((Widget) m_mainWidget); + Widget hsb, vsb; + + XtVaGetValues (parent, + XmNhorizontalScrollBar, &hsb, + XmNverticalScrollBar, &vsb, + NULL); + + /* TODO: should scrollbars be affected? Should probably have separate + * function to change them (by default, taken from wxSystemSettings) + if (hsb) + DoChangeBackgroundColour((WXWidget) hsb, m_backgroundColour, TRUE); + if (vsb) + DoChangeBackgroundColour((WXWidget) vsb, m_backgroundColour, TRUE); + */ + + DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); } void wxTextCtrl::ChangeForegroundColour() { wxWindow::ChangeForegroundColour(); + + + Widget parent = XtParent ((Widget) m_mainWidget); + Widget hsb, vsb; + + XtVaGetValues (parent, + XmNhorizontalScrollBar, &hsb, + XmNverticalScrollBar, &vsb, + NULL); + + /* TODO: should scrollbars be affected? Should probably have separate + * function to change them (by default, taken from wxSystemSettings) + if (hsb) + DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); + if (vsb) + DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); + */ + DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); } static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr) diff --git a/src/motif/window.cpp b/src/motif/window.cpp index d29ed01e4a..4274c6513a 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -740,6 +740,8 @@ bool wxWindow::Show(bool show) { if (m_borderWidget || m_scrolledWindow) { + if (m_drawingArea) + XtMapWidget((Widget) m_drawingArea); XtMapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); } else @@ -751,6 +753,8 @@ bool wxWindow::Show(bool show) { if (m_borderWidget || m_scrolledWindow) { + if (m_drawingArea) + XtUnmapWidget((Widget) m_drawingArea); XtUnmapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); } else @@ -1387,7 +1391,18 @@ void wxWindow::RemoveChild(wxWindow *child) void wxWindow::DestroyChildren() { - if (GetChildren()) { + if (GetChildren()) + { + wxNode *node = GetChildren()->First(); + while (node) + { + wxNode* next = node->Next(); + wxWindow* child = (wxWindow*) node->Data(); + delete child; + node = next; + } + GetChildren()->Clear(); +#if 0 wxNode *node; while ((node = GetChildren()->First()) != (wxNode *)NULL) { wxWindow *child; @@ -1397,6 +1412,7 @@ void wxWindow::DestroyChildren() delete node; } } /* while */ +#endif } } diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 7d5b43fe2c..1f4e55c3de 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -854,7 +854,7 @@ bool wxApp::SendIdleEvents(wxWindow* win) wxIdleEvent event; event.SetEventObject(win); - win->ProcessEvent(event); + win->GetEventHandler()->ProcessEvent(event); if (event.MoreRequested()) needMore = TRUE; diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 76c80cad36..8d4f4b718d 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -242,7 +242,7 @@ bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) event.SetEventType(eventType); event.SetEventObject(this); - if ( !ProcessEvent(event) ) + if ( !GetEventHandler()->ProcessEvent(event) ) return FALSE; return TRUE; #else diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 2f1ab01bf2..7f7b49f294 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -544,7 +544,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { wxSysColourChangedEvent event2; event2.SetEventObject( m_frameStatusBar ); - m_frameStatusBar->ProcessEvent(event2); + m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); } // Propagate the event to the non-top-level children diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index b46c88c3ed..7ac19a8ddd 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -508,7 +508,7 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) // Try the window the menu was popped up from (and up // through the hierarchy) if ( !processed && GetInvokingWindow()) - processed = GetInvokingWindow()->ProcessEvent(event); + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); } extern wxMenu *wxCurrentPopupMenu; diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 04278992fb..788da296c5 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -398,7 +398,7 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) // pass to the parent if ( GetParent() ) { event.SetCurrentFocus(this); - GetParent()->ProcessEvent(event); + GetParent()->GetEventHandler()->ProcessEvent(event); } } } @@ -453,7 +453,7 @@ bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) event.SetEventObject(this); event.SetInt(LOWORD(wParam)); - return ProcessEvent(event); + return GetEventHandler()->ProcessEvent(event); } // ---------------------------------------------------------------------------- diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index 56d537619e..462d0513e0 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -252,7 +252,7 @@ bool wxSpinButton::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) event.eventObject = this; event.SetEventType(eventType); - if ( !ProcessEvent(event) ) + if ( !GetEventHandler()->ProcessEvent(event) ) return FALSE; */ return TRUE; diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index dc70319e75..210c08d785 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1034,7 +1034,7 @@ bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) : wxEVT_SET_FOCUS, m_windowId); event.SetEventObject( this ); - ProcessEvent(event); + GetEventHandler()->ProcessEvent(event); } break; @@ -1083,7 +1083,7 @@ bool wxTextCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) event.SetEventObject( this ); event.SetEventType(eventType); - if ( !ProcessEvent(event) ) + if ( !GetEventHandler()->ProcessEvent(event) ) return FALSE; return TRUE; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index e80c644769..6ed701daed 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3575,7 +3575,7 @@ void wxWindow::OnChar(wxKeyEvent& event) // propagate the TABs to the parent - it's up to it to decide what // to do with it if ( GetParent() ) { - if ( GetParent()->ProcessEvent(event) ) + if ( GetParent()->GetEventHandler()->ProcessEvent(event) ) return; } } diff --git a/utils/ogl/samples/ogledit/view.cpp b/utils/ogl/samples/ogledit/view.cpp index 701b1fce27..9ce5b7c332 100644 --- a/utils/ogl/samples/ogledit/view.cpp +++ b/utils/ogl/samples/ogledit/view.cpp @@ -66,10 +66,81 @@ bool DiagramView::OnCreate(wxDocument *doc, long flags) return TRUE; } +#define CENTER FALSE // Place the drawing to the center of the page + + // Sneakily gets used for default print/preview -// as well as drawing on the screen. -void DiagramView::OnDraw(wxDC *dc) -{ +// as well as drawing on the screen. +void DiagramView::OnDraw(wxDC *dc) +{ + + /* You might use THIS code if you were scaling + * graphics of known size to fit on the page. + */ + float w, h; + + // We need to adjust for the graphic size, a formula will be added + float maxX = 900; + float maxY = 700; + // A better way of find the maxium values would be to search through + // the linked list + + // Let's have at least 10 device units margin + float marginX = 10; + float marginY = 10; + + // Add the margin to the graphic size + maxX += (2 * marginX); + maxY += (2 * marginY); + + // Get the size of the DC in pixels + dc->GetSize (&w, &h); + + // Calculate a suitable scaling factor + float scaleX = (float) (w / maxX); + float scaleY = (float) (h / maxY); + + // Use x or y scaling factor, whichever fits on the DC + float actualScale = wxMin (scaleX, scaleY); + + float posX, posY; + // Calculate the position on the DC for centring the graphic + if (CENTER == TRUE) // center the drawing + { + posX = (float) ((w - (200 * actualScale)) / 2.0); + posY = (float) ((h - (200 * actualScale)) / 2.0); + } + else // Use defined presets + { + posX = 10; + posY = 35; + } + + + // Set the scale and origin + dc->SetUserScale (actualScale, actualScale); + dc->SetDeviceOrigin (posX, posY); + + // This part was added to preform the print preview and printing functions + + dc->BeginDrawing(); // Allows optimization of drawing code under MS Windows. + wxDiagram *diagram_p=((DiagramDocument*)GetDocument())->GetDiagram(); // Get the current diagram + if (diagram_p->GetShapeList()) + { + wxCursor *old_cursor = NULL; + wxNode *current = diagram_p->GetShapeList()->First(); + + while (current) // Loop through the entire list of shapes + { + wxShape *object = (wxShape *)current->Data(); + if (!object->GetParent()) + { + object->Draw(* dc); // Draw the shape onto our printing dc + } + current = current->Next(); // Procede to the next shape in the list + } + } + dc->EndDrawing(); // Allows optimization of drawing code under MS Windows. } void DiagramView::OnUpdate(wxView *sender, wxObject *hint) @@ -167,6 +238,7 @@ void DiagramView::OnEditLabel(wxCommandEvent& event) } } + /* * Window implementations */ -- 2.45.2