1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        univ/frame.cpp 
   3 // Purpose:     wxFrame class for wxUniversal 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) 
   9 // Licence:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // =========================================================================== 
  14 // =========================================================================== 
  16 // --------------------------------------------------------------------------- 
  18 // --------------------------------------------------------------------------- 
  20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  21     #pragma implementation "univframe.h" 
  24 // For compilers that support precompilation, includes "wx.h". 
  25 #include "wx/wxprec.h" 
  34     #include "wx/statusbr.h" 
  35     #include "wx/settings.h" 
  36     #include "wx/toolbar.h" 
  39 // ============================================================================ 
  41 // ============================================================================ 
  43 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
) 
  44     EVT_SIZE(wxFrame::OnSize
) 
  45     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
) 
  48 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
) 
  50 // ---------------------------------------------------------------------------- 
  52 // ---------------------------------------------------------------------------- 
  54 bool wxFrame::Create(wxWindow 
*parent
, 
  56                 const wxString
& title
, 
  62     if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) ) 
  65     SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
  70 // Responds to colour changes, and passes event on to children. 
  71 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
) 
  73     SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
)); 
  79 // ---------------------------------------------------------------------------- 
  81 // ---------------------------------------------------------------------------- 
  83 void wxFrame::OnSize(wxSizeEvent
& event
) 
  90 #endif // wxUSE_STATUSBAR 
  93 #endif // wxUSE_TOOLBAR 
  98 void wxFrame::SendSizeEvent() 
 100     wxSizeEvent 
event(GetSize(), GetId()); 
 101     event
.SetEventObject(this); 
 102     GetEventHandler()->ProcessEvent(event
); 
 107 void wxFrame::PositionMenuBar() 
 109     if ( m_frameMenuBar 
) 
 111         // the menubar is positioned above the client size, hence the negative 
 113         wxCoord heightMbar 
= m_frameMenuBar
->GetSize().y
; 
 115         wxCoord heightTbar 
= 0; 
 118         if ( m_frameToolBar 
) 
 119             heightTbar 
= m_frameToolBar
->GetSize().y
; 
 120 #endif // wxUSE_TOOLBAR 
 122         m_frameMenuBar
->SetSize(0, 
 123 #ifdef __WXPM__   // FIXME -- remove this, make wxOS2/Univ behave as 
 124                  //          the rest of the world!!! 
 125                                 GetClientSize().y 
- heightMbar 
- heightTbar
, 
 127                                 - (heightMbar 
+ heightTbar
), 
 129                                 GetClientSize().x
, heightMbar
); 
 133 void wxFrame::DetachMenuBar() 
 135     wxFrameBase::DetachMenuBar(); 
 139 void wxFrame::AttachMenuBar(wxMenuBar 
*menubar
) 
 141     wxFrameBase::AttachMenuBar(menubar
); 
 145 #endif // wxUSE_MENUS 
 149 void wxFrame::PositionStatusBar() 
 151     if ( m_frameStatusBar 
) 
 153         wxSize size 
= GetClientSize(); 
 154         m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, wxDefaultCoord
); 
 158 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
, 
 159                                       wxWindowID id
, const wxString
& name
) 
 161     wxStatusBar 
*bar 
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
); 
 166 #endif // wxUSE_STATUSBAR 
 170 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
) 
 172     if ( wxFrameBase::CreateToolBar(style
, id
, name
) ) 
 177     return m_frameToolBar
; 
 180 void wxFrame::PositionToolBar() 
 182     if ( m_frameToolBar 
) 
 184         wxSize size 
= GetClientSize(); 
 188         m_frameToolBar
->GetSize(&tw
, &th
); 
 189         if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL 
) 
 200         m_frameToolBar
->SetSize(tx
, ty
, tw
, th
); 
 203 #endif // wxUSE_TOOLBAR 
 205 wxPoint 
wxFrame::GetClientAreaOrigin() const 
 207     wxPoint pt 
= wxFrameBase::GetClientAreaOrigin(); 
 209 #if wxUSE_MENUS && !defined(__WXPM__) 
 210     if ( m_frameMenuBar 
) 
 212         pt
.y 
+= m_frameMenuBar
->GetSize().y
; 
 214 #endif // wxUSE_MENUS 
 217     if ( m_frameToolBar 
) 
 219         if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL 
) 
 220             pt
.x 
+= m_frameToolBar
->GetSize().x
; 
 222             pt
.y 
+= m_frameToolBar
->GetSize().y
; 
 224 #endif // wxUSE_TOOLBAR 
 229 void wxFrame::DoGetClientSize(int *width
, int *height
) const 
 231     wxFrameBase::DoGetClientSize(width
, height
); 
 234     if ( m_frameMenuBar 
&& height 
) 
 236         (*height
) -= m_frameMenuBar
->GetSize().y
; 
 238 #endif // wxUSE_MENUS 
 241     if ( m_frameStatusBar 
&& height 
) 
 243         (*height
) -= m_frameStatusBar
->GetSize().y
; 
 245 #endif // wxUSE_STATUSBAR 
 248     if ( m_frameToolBar 
) 
 250         if ( width 
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) ) 
 251             (*width
) -= m_frameToolBar
->GetSize().x
; 
 253             (*height
) -= m_frameToolBar
->GetSize().y
; 
 255 #endif // wxUSE_TOOLBAR 
 258 void wxFrame::DoSetClientSize(int width
, int height
) 
 261     if ( m_frameMenuBar 
) 
 263         height 
+= m_frameMenuBar
->GetSize().y
; 
 265 #endif // wxUSE_MENUS 
 268     if ( m_frameStatusBar 
) 
 270         height 
+= m_frameStatusBar
->GetSize().y
; 
 272 #endif // wxUSE_STATUSBAR 
 275     if ( m_frameToolBar 
) 
 278         height 
+= m_frameStatusBar
->GetSize().y
; 
 279 #endif // wxUSE_STATUSBAR 
 281         if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL 
) 
 282             width 
+= m_frameToolBar
->GetSize().x
; 
 284             height 
+= m_frameToolBar
->GetSize().y
; 
 286 #endif // wxUSE_TOOLBAR 
 288     wxFrameBase::DoSetClientSize(width
, height
); 
 291 int wxFrame::GetMinWidth() const 
 294     if ( m_frameMenuBar 
) 
 296         return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth()); 
 299 #endif // wxUSE_MENUS 
 300         return wxFrameBase::GetMinWidth(); 
 303 int wxFrame::GetMinHeight() const 
 308     if ( m_frameMenuBar 
) 
 310         height 
+= m_frameMenuBar
->GetSize().y
; 
 312 #endif // wxUSE_MENUS 
 315     if ( m_frameToolBar 
) 
 317         height 
+= m_frameToolBar
->GetSize().y
; 
 319 #endif // wxUSE_TOOLBAR 
 322     if ( m_frameStatusBar 
) 
 324         height 
+= m_frameStatusBar
->GetSize().y
; 
 326 #endif // wxUSE_STATUSBAR 
 329         return height 
+ wxMax(0, wxFrameBase::GetMinHeight()); 
 331         return wxFrameBase::GetMinHeight(); 
 334 bool wxFrame::Enable(bool enable
) 
 336     if (!wxFrameBase::Enable(enable
)) 
 338 #ifdef __WXMICROWIN__ 
 340         m_frameMenuBar
->Enable(enable
);