]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: samples/docview/docview.h | |
3 | // Purpose: Document/view demo | |
4 | // Author: Julian Smart | |
5 | // Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Julian Smart | |
9 | // (c) 2008 Vadim Zeitlin | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_SAMPLES_DOCVIEW_DOCVIEW_H_ | |
14 | #define _WX_SAMPLES_DOCVIEW_DOCVIEW_H_ | |
15 | ||
16 | #include "wx/docview.h" | |
17 | ||
18 | class MyFrame; | |
19 | class MyCanvas; | |
20 | class DrawingView; | |
21 | ||
22 | // Define a new application | |
23 | class MyApp : public wxApp | |
24 | { | |
25 | public: | |
26 | // this sample can be launched in several different ways: | |
27 | enum Mode | |
28 | { | |
29 | #if wxUSE_MDI_ARCHITECTURE | |
30 | Mode_MDI, // MDI mode: multiple documents, single top level window | |
31 | #endif // wxUSE_MDI_ARCHITECTURE | |
32 | Mode_SDI, // SDI mode: multiple documents, multiple top level windows | |
33 | Mode_Single // single document mode (and hence single top level window) | |
34 | }; | |
35 | ||
36 | MyApp(); | |
37 | ||
38 | // override some wxApp virtual methods | |
39 | virtual bool OnInit(); | |
40 | virtual int OnExit(); | |
41 | ||
42 | virtual void OnInitCmdLine(wxCmdLineParser& parser); | |
43 | virtual bool OnCmdLineParsed(wxCmdLineParser& parser); | |
44 | ||
45 | // our specific methods | |
46 | Mode GetMode() const { return m_mode; } | |
47 | wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas); | |
48 | ||
49 | // these accessors should only be called in single document mode, otherwise | |
50 | // the pointers are NULL and an assert is triggered | |
51 | MyCanvas *GetMainWindowCanvas() const | |
52 | { wxASSERT(m_canvas); return m_canvas; } | |
53 | wxMenu *GetMainWindowEditMenu() const | |
54 | { wxASSERT(m_menuEdit); return m_menuEdit; } | |
55 | ||
56 | private: | |
57 | // append the standard document-oriented menu commands to this menu | |
58 | void AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting); | |
59 | ||
60 | // create the edit menu for drawing documents | |
61 | wxMenu *CreateDrawingEditMenu(); | |
62 | ||
63 | // create and associate with the given frame the menu bar containing the | |
64 | // given file and edit (possibly NULL) menus as well as the standard help | |
65 | // one | |
66 | void CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit); | |
67 | ||
68 | ||
69 | // show the about box: as we can have different frames it's more | |
70 | // convenient, even if somewhat less usual, to handle this in the | |
71 | // application object itself | |
72 | void OnAbout(wxCommandEvent& event); | |
73 | ||
74 | ||
75 | // the currently used mode | |
76 | Mode m_mode; | |
77 | ||
78 | // only used if m_mode == Mode_Single | |
79 | MyCanvas *m_canvas; | |
80 | wxMenu *m_menuEdit; | |
81 | ||
82 | DECLARE_EVENT_TABLE() | |
83 | DECLARE_NO_COPY_CLASS(MyApp) | |
84 | }; | |
85 | ||
86 | DECLARE_APP(MyApp) | |
87 | ||
88 | #endif // _WX_SAMPLES_DOCVIEW_DOCVIEW_H_ |