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