wxArt2D
canedit.h
Go to the documentation of this file.
1 /*! \file wx/editor/canedit.h
2  \brief ready made editing class for a a2dCanvas and/or a2dCanvasView
3  \author Klaas Holwerda
4 
5  Copyright: 2000-2004 (c) Klaas Holwerda
6 
7  Licence: wxWidgets Licence
8 
9  RCS-ID: $Id: canedit.h,v 1.37 2009/09/26 19:01:05 titato Exp $
10 */
11 
12 #ifndef __A2DCANVASEDIT_H__
13 #define __A2DCANVASEDIT_H__
14 
15 
16 #ifndef WX_PRECOMP
17 #include "wx/wx.h"
18 #endif
19 
20 #include "a2dprivate.h"
21 
22 #include "wx/canvas/canmod.h"
23 #include "wx/canvas/sttool.h"
24 #include "wx/canvas/edit.h"
25 #include "wx/editor/candoc.h"
26 
27 //! Creates and Connect a wxEditorFrame + a2dCanvas with a view.
29 {
30  DECLARE_CLASS( a2dEditorMultiFrameViewConnector )
31  DECLARE_EVENT_TABLE()
32 
33 public:
34 
35  a2dEditorMultiFrameViewConnector( wxClassInfo* EditorClassInfo = ( wxClassInfo* ) NULL );
36 
37  void OnPostCreateDocument( a2dTemplateEvent& event );
38 
39  //! Creates a a2dEditorFrame and sets its its a2dCanvas as the DisplayWindow for the view.
40  void OnPostCreateView( a2dTemplateEvent& event );
41 
42  //! For dynamic creation of appropriate instances.
43  wxClassInfo* m_editorClassInfo;
44 };
45 
46 // ID for the menu commands
47 extern const long TOOLOPTION_FIRST;
48 extern const long TOOLOPTION_ONTOP;
49 extern const long TOOLOPTION_RECTANGLE;
50 extern const long TOOLOPTION_REDRAW;
51 extern const long TOOLOPTION_COPY;
52 
53 extern const long TOOLOPTION_FILLED;
54 extern const long TOOLOPTION_WIRE;
55 extern const long TOOLOPTION_INVERT;
56 extern const long TOOLOPTION_WIRE_ZERO_WIDTH;
57 extern const long TOOLOPTION_INVERT_ZERO_WIDTH;
58 extern const long TOOLOPTION_LAST;
59 
60 
61 extern const long MSHOW_T;
62 extern const long MSHOW_FIRST;
63 extern const long MSHOW_LIBPOINTS;
64 extern const long MSHOW_LIB;
65 extern const long MSHOW_LAST;
66 //extern const long MTOOL_PlaceFromLibByRef;
67 //extern const long MTOOL_PlaceFromLibByCopy;
68 
69 extern const long Layer_view;
70 
71 extern const long a2dShapeClipboard_Copy;
72 extern const long a2dShapeClipboard_Paste;
73 extern const long a2dShapeClipboard_Drag;
74 
75 
76 class A2DEDITORDLLEXP a2dEditorFrame;
77 
78 //! used to theme a a2dEditorFrame
79 /*!
80  The event Object is a a2dEditorFrame, and it can be intercepted to
81  overrule the default theming ( menu's menubar etc. )
82 
83  \ingroup docview docviewevents events
84 */
85 class A2DGENERALDLLEXP a2dEditorFrameEvent: public wxEvent
86 {
87 public:
88  a2dEditorFrameEvent( a2dEditorFrame* editorFrame, wxEventType type, int id = 0 );
89 
90  a2dEditorFrame* GetEditorFrame() const;
91 
92  wxEvent* Clone( void ) const;
93 };
94 
95 BEGIN_DECLARE_EVENT_TYPES()
96 //! see a2dEditorFrameEvent \ingroup eventid
97 DECLARE_EXPORTED_EVENT_TYPE( A2DEDITORDLLEXP, a2dEVT_THEME_EVENT, 1 )
98 DECLARE_EXPORTED_EVENT_TYPE( A2DEDITORDLLEXP, a2dEVT_INIT_EVENT, 1 )
99 END_DECLARE_EVENT_TYPES()
100 
101 typedef void ( wxEvtHandler::*a2dEditorFrameEventFunction ) ( a2dEditorFrameEvent& );
102 
103 #define a2dEditorFrameEventHandler(func) \
104  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(a2dEditorFrameEventFunction, &func)
105 
106 /*! \addtogroup eventhandlers
107 * @{
108 */
109 
110 //! static wxEvtHandler for theme event, send from a2dEditorFrame
111 #define EVT_THEME_EVENT(func) wx__DECLARE_EVT0( a2dEVT_THEME_EVENT, a2dEditorFrameEventHandler( func ))
112 #define EVT_INIT_EVENT(func) wx__DECLARE_EVT0( a2dEVT_INIT_EVENT, a2dEditorFrameEventHandler( func ))
113 //! @} eventhandlers
114 
115 
116 //! sepcialized Frame for editor of a2dCanvas
117 class A2DEDITORDLLEXP a2dEditorFrame : public a2dDocumentFrame
118 {
119 
120 public:
121 
122  typedef void ( a2dEditorFrame::*wxObjectEventFunctionM )( wxCommandEvent& );
123 
124 public:
125 
126  DECLARE_DYNAMIC_CLASS( a2dEditorFrame )
127 
128  //! this makes dynamic creation possible ( e.g. a derived a2dEditorFrame )
129  /*!
130  Can be used by connectors ( e.g. a2dEditorMultiFrameViewConnector ) to create
131  a derived a2dEditorFrame class using the ClassInfo.
132  This makes one connector class enough for all derived a2dEditorFrame's.
133  This constructor is used in combination with Create() to initilize the a2dEditorFrame.
134  */
135  a2dEditorFrame();
136 
137  a2dEditorFrame( bool isParent, wxFrame* parent,
138  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE );
139 
140  //! delayed creation of window.
141  /*!
142 
143  */
144  bool Create( bool createCanvas, bool isParent, wxFrame* parent,
145  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE );
146 
147  //! initialize
148  void Init();
149  //! setup menu
150  void Theme( const wxString& themeName = wxT( "default" ) );
151 
152  ~a2dEditorFrame();
153 
154  virtual void CreateStatusBarThemed( const wxString& themeName = wxT( "default" ) );
155 
156  void SetupToolbar();
157 
158  //! return edit menu to set Undo and Redo commands
159  wxMenu* GetEditMenu() { return m_editMenu; }
160 
161  void Update();
162 
163  void ConnectDocument( a2dCanvasDocument* doc, a2dCanvasView* drawer = NULL );
164 
165  a2dDrawingPart* GetDrawingPart() { return m_drawingPart; }
166 
167  void SetDrawingPart( a2dDrawingPart* part ) { m_drawingPart = part; }
168 
169  //! get active controller set on a a2dCanvasView in this frame
170  a2dStToolContr* GetToolController() { return m_contr; }
171 
172  //! set active controller set on a a2dCanvasView in this frame
173  void SetToolController( a2dStToolContr* contr ) { m_contr = contr; }
174 
175  //! add a menu which executes a function
176  /*!
177  \param id wxID_ANY is non specific for use in func
178  \param text text of menu
179  \param helpString help for menu
180  \param func function in this are derived class to be called.
181  */
182  void AddFunctionToMenu( int id, wxMenu* parentMenu, const wxString& text, const wxString& helpString, wxObjectEventFunctionM func, bool check = false );
183 
184  void RemoveFromMenu( int id, wxMenu* parentMenu, wxObjectEventFunctionM func );
185 
186  void SetToolDragingMode( wxCommandEvent& event );
187 
188  void SetToolDrawingMode( wxCommandEvent& event );
189 
190  void OnUndoEvent( a2dCommandProcessorEvent& event );
191 
192  void OnDoEvent( a2dCommandProcessorEvent& event );
193 
194  //!intercepted to initialize redo and undo menu's
195  void OnActivate( wxActivateEvent& event );
196 
197  //! handler for event to set undo redo menustrings
198  void OnSetmenuStrings( a2dCommandProcessorEvent& event );
199 
200  //! called on Close window
201  void OnCloseWindow( wxCloseEvent& event );
202 
203  void OnComEvent( a2dComEvent& event );
204 
205  //! tool controller to be defined by user
207 
208  void OnUndo( wxCommandEvent& event );
209  void OnRedo( wxCommandEvent& event );
210 
211  void Quit( wxCommandEvent& event );
212 
213  void OnAbout( wxCommandEvent& event );
214 
215  void ShowLibs( wxCommandEvent& event );
216 
217  void PlaceFromLibByRef();
218  void PlaceFromLibByCopy();
219 
220  void OnMenu( wxCommandEvent& event );
221 
222  void CreateThemeTest();
223  void CreateThemeDefault();
224  void CreateThemeXRC();
225 
226 
227 protected:
228 
229  void OnCopyShape(wxCommandEvent& event);
230  void OnPasteShape(wxCommandEvent& event);
231  void OnUpdatePasteShape( wxUpdateUIEvent& event );
232  void OnUpdateCopyShape( wxUpdateUIEvent& event );
233 
234  void OnDragSimulate(wxCommandEvent& event);
235 
236  void FillData( wxCommandEvent& event );
237 
238  void OnUpdateUI( wxUpdateUIEvent& event );
239 
240  void OnTheme( a2dEditorFrameEvent& themeEvent );
241 
242  void OnInit( a2dEditorFrameEvent& initEvent );
243 
244  void OnActivateViewSentFromChild( a2dViewEvent& viewevent );
245 
246  a2dDrawingPart* m_drawingPart;
247 
248  wxMenuBar* m_menuBar;
249 
250  //! to hold undo redo menu's which are reinitialized at activation of view
251  wxMenu* m_editMenu;
252 
253  bool m_initialized;
254 
255  DECLARE_EVENT_TABLE()
256 };
257 
258 
259 
260 
261 
262 #endif /* __A2DCANVASEDIT_H__ */
263 
264 
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
void SetToolController(a2dStToolContr *contr)
set active controller set on a a2dCanvasView in this frame
Definition: canedit.h:173
View on a a2dCanvasDocument.
Definition: candoc.h:212
wxClassInfo * m_editorClassInfo
For dynamic creation of appropriate instances.
Definition: canedit.h:43
void OnCloseWindow(wxCloseEvent &event)
default for closing this frame via close button.
a2dView event, to report events in the a2dView class
Definition: docviewref.h:424
wxMenu * GetEditMenu()
return edit menu to set Undo and Redo commands
Definition: canedit.h:159
used to theme a a2dEditorFrame
Definition: canedit.h:85
event sent to a2dViewConnector
Definition: docviewref.h:870
void(wxEvtHandler::* a2dEditorFrameEventFunction)(a2dEditorFrameEvent &)
see a2dEditorFrameEvent
Definition: canedit.h:101
bool Create(bool parentFrame, wxWindow *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("frame"))
Constructor for two-step-creation (2nd step)
The a2dStToolContr is a Tool Controller specialized for working with a2dCanvasView.
Definition: sttool.h:485
The a2dDocumentFrame class provides a default frame for displaying documents.
Definition: docviewref.h:3357
Creates and Connect a wxEditorFrame + a2dCanvas with a view.
Definition: canedit.h:28
uses a wxFrame to hold new views or to create child wxFrame's to hold new views.
Definition: docviewref.h:2997
wxMenu * m_editMenu
to hold undo redo menu's which are reinitialized at activation of view
Definition: canedit.h:251
sepcialized Frame for editor of a2dCanvas
Definition: canedit.h:117
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
editing tool for a2dCanvasObject's
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
see a2dComEvent
Definition: gen.h:371
all headers of the canvas module
a2dStToolContr * GetToolController()
get active controller set on a a2dCanvasView in this frame
Definition: canedit.h:170
stack based tools controller and tools for drawing and editing.
a2dSmrtPtr< a2dStToolContr > m_contr
tool controller to be defined by user
Definition: canedit.h:206
void OnActivateViewSentFromChild(a2dViewEvent &viewevent)
sets m_view to the current active view, generate by a2dView::Activate()
canedit.h Source File -- Sun Oct 12 2014 17:04:13 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation