]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/mdi.cpp
wxStream: wxInputStream and wxOutputStream don't inherit from wxObject anymore.
[wxWidgets.git] / src / gtk1 / mdi.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mdi.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "mdi.h"
13 #endif
14
15 #include "wx/mdi.h"
16
17 //-----------------------------------------------------------------------------
18 // wxMDIParentFrame
19 //-----------------------------------------------------------------------------
20
21 static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
22 {
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))
27 {
28 return;
29 };
30
31 win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
32 };
33
34 //-----------------------------------------------------------------------------
35
36 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
37
38 wxMDIParentFrame::wxMDIParentFrame(void)
39 {
40 m_clientWindow = NULL;
41 m_currentChild = NULL;
42 m_parentFrameActive = TRUE;
43 };
44
45 wxMDIParentFrame::wxMDIParentFrame( wxWindow *parent,
46 wxWindowID id, const wxString& title,
47 const wxPoint& pos, const wxSize& size,
48 long style, const wxString& name )
49 {
50 m_clientWindow = NULL;
51 m_currentChild = NULL;
52 m_parentFrameActive = TRUE;
53 Create( parent, id, title, pos, size, style, name );
54 };
55
56 wxMDIParentFrame::~wxMDIParentFrame(void)
57 {
58 };
59
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 )
64 {
65 wxFrame::Create( parent, id, title, pos, size, style, name );
66
67 OnCreateClient();
68
69 return TRUE;
70 };
71
72 void wxMDIParentFrame::OnSize( wxSizeEvent& event )
73 {
74 wxFrame::OnSize( event );
75 };
76
77 void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
78 {
79 };
80
81 void wxMDIParentFrame::SetMenuBar( wxMenuBar *menu_bar )
82 {
83 wxFrame::SetMenuBar( menu_bar );
84 };
85
86 void wxMDIParentFrame::GetClientSize(int *width, int *height ) const
87 {
88 wxFrame::GetClientSize( width, height );
89 };
90
91 wxMDIChildFrame *wxMDIParentFrame::GetActiveChild(void) const
92 {
93 return m_currentChild;
94 };
95
96 wxMDIClientWindow *wxMDIParentFrame::GetClientWindow(void) const
97 {
98 return m_clientWindow;
99 };
100
101 wxMDIClientWindow *wxMDIParentFrame::OnCreateClient(void)
102 {
103 m_clientWindow = new wxMDIClientWindow( this );
104 return m_clientWindow;
105 };
106
107 void wxMDIParentFrame::ActivateNext(void)
108 {
109 };
110
111 void wxMDIParentFrame::ActivatePrevious(void)
112 {
113 };
114
115 void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(event) )
116 {
117 };
118
119 //-----------------------------------------------------------------------------
120 // wxMDIChildFrame
121 //-----------------------------------------------------------------------------
122
123 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel)
124
125 wxMDIChildFrame::wxMDIChildFrame(void)
126 {
127 };
128
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 )
133 {
134 Create( parent, id, title, wxDefaultPosition, size, style, name );
135 };
136
137 wxMDIChildFrame::~wxMDIChildFrame(void)
138 {
139 };
140
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 )
145 {
146 m_title = title;
147 return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
148 };
149
150 void wxMDIChildFrame::SetMenuBar( wxMenuBar *WXUNUSED(menu_bar) )
151 {
152 };
153
154 void wxMDIChildFrame::Activate(void)
155 {
156 };
157
158 //-----------------------------------------------------------------------------
159 // wxMDIClientWindow
160 //-----------------------------------------------------------------------------
161
162 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow,wxWindow)
163
164 wxMDIClientWindow::wxMDIClientWindow(void)
165 {
166 };
167
168 wxMDIClientWindow::wxMDIClientWindow( wxMDIParentFrame *parent, long style )
169 {
170 CreateClient( parent, style );
171 };
172
173 wxMDIClientWindow::~wxMDIClientWindow(void)
174 {
175 };
176
177 bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
178 {
179 m_needParent = TRUE;
180
181 PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" );
182
183 m_widget = gtk_notebook_new();
184
185 PostCreation();
186
187 Show( TRUE );
188
189 return TRUE;
190 };
191
192 void wxMDIClientWindow::AddChild( wxWindow *child )
193 {
194 m_children.Append( child );
195
196 wxString s;
197
198 if (child->IsKindOf(CLASSINFO(wxMDIChildFrame)))
199 {
200 wxMDIChildFrame* mdi_child = (wxMDIChildFrame*) child;
201 s = mdi_child->m_title;
202 };
203
204 if (s.IsNull()) s = "MDI child";
205
206 GtkWidget *label_widget;
207 label_widget = gtk_label_new( s );
208 gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
209
210 gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
211 GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
212
213 gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), child->m_widget, label_widget );
214 };
215
216