]> git.saurik.com Git - wxWidgets.git/commitdiff
Motif wxNotebook about done; added print/preview to OGLEdit sample
authorJulian Smart <julian@anthemion.co.uk>
Tue, 27 Oct 1998 17:58:46 +0000 (17:58 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 27 Oct 1998 17:58:46 +0000 (17:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

20 files changed:
include/wx/generic/tabg.h
include/wx/motif/notebook.h
samples/mdi/mdi.cpp
samples/notebook/test.cpp
src/generic/listctrl.cpp
src/generic/tabg.cpp
src/motif/listbox.cpp
src/motif/notebook.cpp
src/motif/settings.cpp
src/motif/textctrl.cpp
src/motif/window.cpp
src/msw/app.cpp
src/msw/control.cpp
src/msw/frame.cpp
src/msw/menu.cpp
src/msw/notebook.cpp
src/msw/spinbutt.cpp
src/msw/textctrl.cpp
src/msw/window.cpp
utils/ogl/samples/ogledit/view.cpp

index 5a1b934d26f3c3651105771845c84f88c373359b..e937b156b18586113c45683538fe9e59cf192300 100644 (file)
@@ -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;
 
index d21311e21686f6313b2b064049ded46f711bbdf4..734d17fc05de67105e3b397405458f72d4310684 100644 (file)
@@ -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
index e52b33de8e4ff7247827ee3729ba8f013b83c620..a1ac5a7ec17313caeb2b554ff59d6d5ab9a657f2 100644 (file)
@@ -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
index 3358e3655211e7759359f8c3abd653086e22fcc8..f86b14b7971669b05eaef24c513e3a917985f45c 100644 (file)
@@ -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)
index ed022c17cef3b50b9a4a35da09313cc39653dc89..eb6ae8bde348c38832b3a01e0c79cf5f95fb4518 100644 (file)
@@ -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;
 }
 
index 5adc584c4c8ba48386dcf83d19bc405d82636138..fe7590fd50dea95c0e9fc714c48358e92b84a887 100644 (file)
@@ -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)
                                );
 
index 2952cadbab5c7050576a4e58e1ad28fe36fe8dbb..3d864f49d51758f739ba78b428e9caef5dd418b6 100644 (file)
@@ -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);
+    */
 }
 
+
index 7b520792b90622286e93800511d6a998cd6727fa..ba296eb4d07eb18e1c139b0188270158e8275778 100644 (file)
@@ -26,6 +26,9 @@
 #include  <wx/notebook.h>
 #include  <wx/dcclient.h>
 
+#include  <Xm/Xm.h>
+#include  <wx/motif/private.h>
+
 // ----------------------------------------------------------------------------
 // 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
index 9bfe3411ca7646c8e03645f49d4098792f3a54c4..1c639007d86841d21af17eea2314c559ff4b9575 100644 (file)
@@ -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;
index ba5066934a1cd270f076e048b638e905fb664619..3d7c94d2e4f17c380391758d8849c032d7e2863e 100644 (file)
@@ -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)
index d29ed01e4a3676a9fdf4edaaaeef54aea43ba763..4274c6513a85cf739b62a10e3a1250f309899319 100644 (file)
@@ -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
   }
 }
 
index 7d5b43fe2c32d8047020120278d35d753c8492f5..1f4e55c3de7b394016040c3be0672f180d369104 100644 (file)
@@ -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;
index 76c80cad360f9ce630fc5ed18e52ce910b2121dc..8d4f4b718d58e65abc8b24abc3d9b64fbac295b6 100644 (file)
@@ -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
index 2f1ab01bf24f52223a5d2da41cf43521d20649bf..7f7b49f2944d76a5f1dc7ece6250bfbaa8353b9b 100644 (file)
@@ -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
index b46c88c3ed1bdfc000f74fe4567f67c110b8345e..7ac19a8ddd5dad79d0b6cc906855cfc73065ca9d 100644 (file)
@@ -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;
index 04278992fb676140853980076033de2df3121e0c..788da296c5cf3b8b373252202cc9e4e2529e8813 100644 (file)
@@ -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);
 }
 
 // ----------------------------------------------------------------------------
index 56d537619e8380f03866f7bfd1059bf8505f75f6..462d0513e0c838a4996ada8b0bbb0fd9806c8647 100644 (file)
@@ -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;
index dc70319e757c3a7c804e0024ba155fa57e0d681a..210c08d785cf788fc3570d7b214a6430acca6f0e 100644 (file)
@@ -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;
index e80c6447698317a736b1d72a199d99ee3b3416fe..6ed701daed3aa3b446e27759c221954ff546ba7d 100644 (file)
@@ -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;
         }
     }
index 701b1fce27ccfb975d3000229ce781197649afc4..9ce5b7c332d4c9d9986814ad6174c9a8c6cf82e2 100644 (file)
@@ -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
  */