]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/mdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "mdi.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 static void gtk_page_size_callback( GtkWidget
*WXUNUSED(widget
), GtkAllocation
* alloc
, wxWindow
*win
)
23 if ((win
->m_x
== alloc
->x
) &&
24 (win
->m_y
== alloc
->y
) &&
25 (win
->m_width
== alloc
->width
) &&
26 (win
->m_height
== alloc
->height
))
31 win
->SetSize( alloc
->x
, alloc
->y
, alloc
->width
, alloc
->height
);
34 //-----------------------------------------------------------------------------
36 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
,wxFrame
)
38 wxMDIParentFrame::wxMDIParentFrame(void)
40 m_clientWindow
= NULL
;
41 m_currentChild
= NULL
;
42 m_parentFrameActive
= TRUE
;
45 wxMDIParentFrame::wxMDIParentFrame( wxWindow
*parent
,
46 wxWindowID id
, const wxString
& title
,
47 const wxPoint
& pos
, const wxSize
& size
,
48 long style
, const wxString
& name
)
50 m_clientWindow
= NULL
;
51 m_currentChild
= NULL
;
52 m_parentFrameActive
= TRUE
;
53 Create( parent
, id
, title
, pos
, size
, style
, name
);
56 wxMDIParentFrame::~wxMDIParentFrame(void)
60 bool wxMDIParentFrame::Create( wxWindow
*parent
,
61 wxWindowID id
, const wxString
& title
,
62 const wxPoint
& pos
, const wxSize
& size
,
63 long style
, const wxString
& name
)
65 wxFrame::Create( parent
, id
, title
, pos
, size
, style
, name
);
72 void wxMDIParentFrame::OnSize( wxSizeEvent
& event
)
74 wxFrame::OnSize( event
);
77 void wxMDIParentFrame::OnActivate( wxActivateEvent
& WXUNUSED(event
) )
81 void wxMDIParentFrame::SetMenuBar( wxMenuBar
*menu_bar
)
83 wxFrame::SetMenuBar( menu_bar
);
86 void wxMDIParentFrame::GetClientSize(int *width
, int *height
) const
88 wxFrame::GetClientSize( width
, height
);
91 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild(void) const
93 return m_currentChild
;
96 wxMDIClientWindow
*wxMDIParentFrame::GetClientWindow(void) const
98 return m_clientWindow
;
101 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient(void)
103 m_clientWindow
= new wxMDIClientWindow( this );
104 return m_clientWindow
;
107 void wxMDIParentFrame::ActivateNext(void)
111 void wxMDIParentFrame::ActivatePrevious(void)
115 void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent
& WXUNUSED(event
) )
119 //-----------------------------------------------------------------------------
121 //-----------------------------------------------------------------------------
123 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
,wxPanel
)
125 wxMDIChildFrame::wxMDIChildFrame(void)
129 wxMDIChildFrame::wxMDIChildFrame( wxMDIParentFrame
*parent
,
130 wxWindowID id
, const wxString
& title
,
131 const wxPoint
& WXUNUSED(pos
), const wxSize
& size
,
132 long style
, const wxString
& name
)
134 Create( parent
, id
, title
, wxDefaultPosition
, size
, style
, name
);
137 wxMDIChildFrame::~wxMDIChildFrame(void)
141 bool wxMDIChildFrame::Create( wxMDIParentFrame
*parent
,
142 wxWindowID id
, const wxString
& title
,
143 const wxPoint
& WXUNUSED(pos
), const wxSize
& size
,
144 long style
, const wxString
& name
)
147 return wxPanel::Create( parent
->GetClientWindow(), id
, wxDefaultPosition
, size
, style
, name
);
150 void wxMDIChildFrame::SetMenuBar( wxMenuBar
*WXUNUSED(menu_bar
) )
154 void wxMDIChildFrame::Activate(void)
158 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
162 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
,wxWindow
)
164 wxMDIClientWindow::wxMDIClientWindow(void)
168 wxMDIClientWindow::wxMDIClientWindow( wxMDIParentFrame
*parent
, long style
)
170 CreateClient( parent
, style
);
173 wxMDIClientWindow::~wxMDIClientWindow(void)
177 bool wxMDIClientWindow::CreateClient( wxMDIParentFrame
*parent
, long style
)
181 PreCreation( parent
, -1, wxPoint(10,10), wxSize(100,100), style
, "wxMDIClientWindow" );
183 m_widget
= gtk_notebook_new();
192 void wxMDIClientWindow::AddChild( wxWindow
*child
)
194 m_children
.Append( child
);
198 if (child
->IsKindOf(CLASSINFO(wxMDIChildFrame
)))
200 wxMDIChildFrame
* mdi_child
= (wxMDIChildFrame
*) child
;
201 s
= mdi_child
->m_title
;
204 if (s
.IsNull()) s
= "MDI child";
206 GtkWidget
*label_widget
;
207 label_widget
= gtk_label_new( s
);
208 gtk_misc_set_alignment( GTK_MISC(label_widget
), 0.0, 0.5 );
210 gtk_signal_connect( GTK_OBJECT(child
->m_widget
), "size_allocate",
211 GTK_SIGNAL_FUNC(gtk_page_size_callback
), (gpointer
)child
);
213 gtk_notebook_append_page( GTK_NOTEBOOK(m_widget
), child
->m_widget
, label_widget
);