wxArt2D
luawrap.h
1 /*! \file wx/canextobj/canext.h
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: luawrap.h,v 1.49 2009/09/26 19:01:07 titato Exp $
9 */
10 
11 #ifndef __WXLUAWRAPS_H__
12 #define __WXLUAWRAPS_H__
13 
14 #ifndef WX_PRECOMP
15 #include "wx/wx.h"
16 #endif
17 
18 #include "wx/canvas/canobj.h"
19 #include "wx/canvas/canprim.h"
20 #include "wx/editor/candoc.h"
21 #include "wx/canvas/sttool.h"
22 #include "wx/editor/candocproc.h"
23 #include "wx/canvas/tooldlg.h"
24 #include "wx/canvas/styledialg.h"
25 #include "wx/canvas/layerdlg.h"
26 #include "wx/editor/canedit.h"
27 
28 #include "wxbind/include/wxcore_bind.h"
29 
30 #include "wxlua/wxlstate.h"
31 #include "wxlua/wxlbind.h"
32 
33 
34 #include "wx/luawraps/wxledit.h"
35 
36 #define a2dLUAWRAP_VERSION "1.0"
37 
38 #ifdef A2DLUAWRAPMAKINGDLL
39 #define A2DLUAWRAPDLLEXP WXEXPORT
40 #define A2DLUAWRAPDLLEXP_DATA(type) WXEXPORT type
41 #define A2DLUAWRAPDLLEXP_CTORFN
42 #elif defined(WXART2D_USINGDLL)
43 #define A2DLUAWRAPDLLEXP WXIMPORT
44 #define A2DLUAWRAPDLLEXP_DATA(type) WXIMPORT type
45 #define A2DLUAWRAPDLLEXP_CTORFN
46 #else // not making nor using DLL
47 #define A2DLUAWRAPDLLEXP
48 #define A2DLUAWRAPDLLEXP_DATA(type) type
49 #define A2DLUAWRAPDLLEXP_CTORFN
50 #endif
51 
52 
53 //! Lua script used to draw the object
54 /*!
55  \ingroup canvasobject
56 */
57 class A2DLUAWRAPDLLEXP a2dCanvasObjectLua: public a2dCanvasObject
58 {
59 public:
60 
61  //!construct at given position
62  /*!
63  \param x X position
64  \param y Y position
65  */
66  a2dCanvasObjectLua( double x = 0 , double y = 0, const wxString& script = wxT( "" ), const wxString& function = wxT( "" ) );
67 
68  a2dCanvasObjectLua( const a2dCanvasObjectLua& other, CloneOptions options, a2dRefMap* refs = NULL );
69 
70  //!destructor
71  virtual ~a2dCanvasObjectLua();
72 
73  DECLARE_DYNAMIC_CLASS( a2dCanvasObjectLua )
74 
75  DECLARE_EVENT_TABLE()
76 
77 protected:
78 
79  void SetField( wxLuaState lst, const wxString& field, const wxString& value );
80  void SetField( wxLuaState lst, const wxString& field, long value );
81  void SetField( wxLuaState lst, const wxString& field, double value );
82  void SetField( wxLuaState lst, const wxString& field, bool value );
83  void SetField( wxLuaState lst, const wxString& name, wxColour value );
84 
85  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
86 
87 #if wxART2D_USE_CVGIO
88  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
89 
90  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
91 #endif //wxART2D_USE_CVGIO
92 
93  void DoRender( a2dIterC& ic, OVERLAP clipparent );
94 
95  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
96 
97  wxString m_function;
98 
99  wxString m_script;
100 
101 private:
102 
103  bool m_run;
104 
105  double m_xoffset;
106  double m_yoffset;
107 
108  //!this is a not implemented copy constructor that avoids automatic creation of one
109  a2dCanvasObjectLua( const a2dCanvasObjectLua& other );
110 
111 };
112 
113 class A2DLUAWRAPDLLEXP a2dLuaConsole;
114 class A2DLUAWRAPDLLEXP a2dLuaExecDlg;
116 
117 //----------------------------------------------------------------------------
118 // a2dLuaConsole
119 //----------------------------------------------------------------------------
120 
121 class A2DLUAWRAPDLLEXP a2dLuaConsole : public wxLuaIDE
122 {
123 public:
124  a2dLuaConsole( a2dLuaCentralCommandProcessor* cmdh, wxWindow* parent, int id,
125  const wxPoint& pos = wxDefaultPosition,
126  const wxSize& size = wxDefaultSize,
127  long style = 0,
128  long options = WXLUAIDE_DEFAULT,
129  const wxString& name = wxT( "a2dLuaConsole" ) );
130 
131  void OnLua( wxLuaEvent& event );
132 
133  ~a2dLuaConsole();
134 
135 private:
136 
138 
139  DECLARE_EVENT_TABLE();
140  DECLARE_ABSTRACT_CLASS( a2dLuaConsole )
141 };
142 
143 class A2DLUAWRAPDLLEXP a2dLuaExecDlg: public wxDialog
144 {
145 public:
146 
147  // Constructor.
148  a2dLuaExecDlg( a2dLuaCentralCommandProcessor* commandProcessor, wxFrame* parent, const wxString& title = wxT( "commandline" ),
149  long style = ( wxDEFAULT_DIALOG_STYLE ), const wxString& name = _T( "frame" ) );
150 
151  // Destructor.
152  ~a2dLuaExecDlg();
153 
154  // Close window if EXIT-button is pressed.
155  void OnCloseWindow( wxCloseEvent& event );
156 
157 protected:
158 
159  void OnRecord( a2dCommandEvent& event );
160 
161  void OnUndoEvent( a2dCommandProcessorEvent& event );
162 
163  void OnDoEvent( a2dCommandProcessorEvent& event );
164 
165  void OnCharHook( wxKeyEvent& event );
166 
167  a2dLuaCentralCommandProcessor* m_commandProcessor;
168 
169  // Pointer to mainwindow.
170  wxFrame* m_parent;
171 
172  a2dLuaConsole* m_luaConsole;
173 
174  // Declare used events.
175  DECLARE_EVENT_TABLE()
176 
177 };
178 
179 class A2DLUAWRAPDLLEXP a2dLuaEditorFrame;
180 
181 
183 {
184 
185  DECLARE_CLASS( a2dLuaCentralCommandProcessor )
186 
187 public:
188 
189  static const a2dCommandId COMID_ShowLuaExecDlg;
190 
191 public:
192 
193  //! \see a2dDocumentCommandProcessor
194  a2dLuaCentralCommandProcessor( long flags = a2dDEFAULT_DOCUMENT_FLAGS,
195  bool initialize = true,
196  int maxCommands = -1 );
197  //! initilize with lower level command processor
199 
200 
201  //! destructor
203 
204  //! if active view has as display frame a a2dLuaEditorFrame, return it.
205  a2dLuaEditorFrame* GetActiveEditorFrame();
206 
207  //! cleaup modeless dialogs created from here
208  virtual void OnExit();
209 
210  bool Execute( const wxString& commandsString, bool withUndo = TRUE );
211 
212  virtual bool ExecuteF( bool withUndo, wxChar* Format, ... );
213 
214  bool ExecuteFile( const wxString& fileName );
215 
216  bool ShowDlg( const a2dCommandId* comID, bool modal, bool onTop );
217 
218  bool FileNew();
219 
220  bool FileOpen( const wxString& path );
221 
222  a2dError FileOpen( a2dDocumentPtr& doc, wxFileName& path );
223 
224  bool FileSaveAs( const wxString& path, bool silent = true );
225 
226  bool FileImport( const wxString& path, const wxString& description );
227 
228  bool FileExport( const wxString& path, const wxString& description, bool silent = true );
229 
230  a2dBaseTool* PopTool();
231  bool PushTool( const a2dCommandId& which, bool shiftadd = false, bool oneshot = false );
232 
233  bool SetDocumentLayers( const wxString& propertyname, const wxString& value );
234 
235  a2dLayers* GetLayersDocument();
236  a2dLayers* LoadLayers( const wxString& filename );
237  a2dLayers* GetLayersGlobal();
238 
239  bool SetLayersDocument( a2dLayers* layers );
240  bool SetLayersGlobal( a2dLayers* layers );
241 
242  bool SaveLayersDocument( const wxString& filename );
243  bool SaveLayersGlobal( const wxString& filename );
244 
245  bool SetLayer( wxUint16 layer );
246 
247  bool SetTarget( wxUint16 target );
248 
249  bool ClearGroup( const wxString& group );
250 
251  bool UnGroup( bool selected, bool deep );
252 
253  bool DeleteGroupA();
254 
255  bool MoveGroupA();
256 
257  bool CopyGroupA();
258  bool ConvertToArcsGroupA( bool detectCircle = false );
259  bool ConvertPolygonToArcsGroupA( bool detectCircle = false );
260  bool ConvertToPolygonPolylinesWithArcsGroupA();
261  bool ConvertToPolygonPolylinesWithoutArcsGroupA();
262  bool ConvertPolylineToArcsGroupA();
263  bool ConvertToVPathsGroupA();
264  bool ConvertLinesArcsGroupA();
265  bool ConvertToPolylinesGroupA();
266  bool DetectSmallGroupA();
267  bool RemoveRedundantGroupA();
268 
269  void AddGroupA( wxUint16 layer );
270  void AddGroupB( wxUint16 layer );
271  void SetSelectedOnlyA( bool selectedOnlyA );
272  bool GetSelectedOnlyA();
273  void SetSelectedOnlyB( bool selectedOnlyB );
274  bool GetSelectedOnlyB();
275 
276 
277 #if wxART2D_USE_KBOOL
278  bool BoolOperation_GroupAB( a2dCommand_GroupAB::a2dDoWhat operation, bool clearTarget, bool selectedA, bool selectedB );
279 #endif //wxART2D_USE_KBOOL
280 
281  bool Message( const wxString& message );
282 
283  bool SetVariable( const wxString& varname, const wxString& varvalue );
284 
285  wxString GetVariable( const wxString& varname );
286 
287  void AddConfigPath( const wxString& path );
288 
289  void AddLayersPath( const wxString& path );
290 
291  void AddFontPath( const wxString& path );
292 
293  void AddImagePath( const wxString& path );
294 
295  void AddIconPath( const wxString& path );
296 
297  bool SetSnap( bool snap );
298 
299  bool SetSnapFeatures( wxUint32 features );
300 
301  void SetCursor( double x, double y );
302 
303  bool Find( const wxString& objectname );
304 
305  bool Ask( const wxString& variablename, const wxString& mes );
306 
307  bool AskFile( const wxString& storeInVariable,
308  const wxString& message = _( "Give Name of file" ),
309  const wxString& defaultDir = _T( "./" ),
310  const wxString& extension = _T( "*" ),
311  const wxString& fileFilter = _T( "*" )
312  );
313 
314  wxFileName AskFile2(
315  const wxString& message = _( "Give Name of file" ),
316  const wxString& defaultDir = _T( "./" ),
317  const wxString& extension = _T( "*" ),
318  const wxString& fileFilter = _T( "*" )
319  );
320 
321  bool ShowVariable( const wxString& variableName, const wxString& message );
322 
323  bool ViewAsImageAdv( const wxFileName& file, wxBitmapType type, bool onView = false );
324 
325  bool DrawWireFrame( bool onOff = true );
326  bool DrawGridLines( bool onOff = true );
327  bool DrawGridAtFront( bool onOff = true );
328  bool DrawGrid( bool onOff = true );
329  bool ZoomOut();
330  bool Refresh();
331  bool InsertGroupRef( double x, double y );
332  bool AddGroupObject( const wxString& groupName, double x = 0, double y = 0, wxUint16 layer = 0 );
333  bool NewPin( double x, double y, const wxString& groupname );
334  bool PushInto( const wxString& name );
335  bool SelectAll();
336  bool DeSelectAll();
337  bool SelectedChangeLayer( long layer );
338  bool SetFillStrokeSelected();
339  bool ToTop();
340  bool ToBack();
341  bool DeleteSelected();
342  bool MoveSelected( double x, double y, long layer );
343  bool CopySelected( double x, double y, long layer );
344  bool TransformSelected( const wxString& str );
345  bool Group();
346  bool UnGroup();
347  bool SetUrl();
348 
349  //! add specific object
350  a2dCanvasObject* Add_a2dCanvasObject( double x = 0, double y = 0 );
351 
352  //! add specific object
353  a2dCanvasObjectReference* Add_a2dCanvasObjectReference( double x, double y, a2dCanvasObject* obj );
354 
355  //a2dNameReference* Add_a2dNameReference( double x, double y, a2dCanvasObject* obj, const wxString &text, double size, double angle );
356 
357  //! add specific object
358  a2dOrigin* Add_a2dOrigin( double w, double h );
359 
360  //! add specific object
361  a2dRectC* Add_a2dRectC( double xc, double yc, double w, double h, double angle = 0 , double radius = 0 );
362 
363  //! add specific object
364  a2dArrow* Add_a2dArrow( double xt, double yt, double l1, double l2, double b, bool spline = false );
365 
366  //! add specific object
367  a2dRect* Add_a2dRect( double x, double y, double w, double h , double radius = 0 );
368 
369  //! add specific object
370  a2dCircle* Add_a2dCircle( double x, double y, double radius );
371 
372  //! add specific object
373  a2dEllipse* Add_a2dEllipse( double xc, double yc, double width, double height );
374 
375  //! add specific object
376  a2dEllipticArc* Add_a2dEllipticArc( double xc, double yc, double width, double height, double start, double end );
377 
378  //! add specific object
379  a2dArc* Add_a2dArc( double xc, double yc, double radius, double start, double end );
380 
381  //! add specific object
382  a2dSLine* Add_a2dSLine( double x1, double y1, double x2, double y2 );
383 
384  //! add specific object
385  a2dEndsLine* Add_a2dEndsLine( double x1, double y1, double x2, double y2 );
386 
387  //! add specific object
388  a2dImage* Add_a2dImage( const wxImage& image, double xc, double yc, double w, double h );
389 
390  //! add specific object
391  a2dImage* Add_a2dImage( const wxString& imagefile, wxBitmapType type, double xc, double yc, double w, double h );
392 
393  //! add specific object
394  a2dText* Add_a2dText( const wxString& text, double x, double y, double angle, const a2dFont& font );
395 
396  //! add specific object
397  a2dPolygonL* Add_a2dPolygonL( a2dVertexList* points, bool spline = false );
398 
399  //! add specific object
400  a2dPolylineL* Add_a2dPolylineL( a2dVertexList* points, bool spline = false );
401 
402  bool Add_Point( double x, double y );
403 
404  bool Move_Point( int index , double x, double y );
405 
406  wxLuaState& GetLuaState() { return m_interp; }
407 
408  //! if m_luaExecDlg is visible or not
409  bool IsShowna2dLuaExecDlg();
410 
411 protected:
412 
413  a2dPropertyIdList m_listOfIdforAddPrims;
414 
415  wxLuaState m_interp;
416 
417  bool ShowLuaExecDlg();
418 
419  a2dLuaExecDlg* m_luaExecDlg;
420 };
421 
422 extern a2dLuaCentralCommandProcessor* a2dLuaWP;
423 extern a2dLuaCentralCommandProcessor* a2dGetLuaWP();
424 
425 extern const long SCRIPT_lua_script;
426 extern const long EXECDLG_lua;
427 
428 //! sepcialized Frame for editor of a2dCanvas
429 class A2DLUAWRAPDLLEXP a2dLuaEditorFrame : public a2dEditorFrame
430 {
431  DECLARE_EVENT_TABLE()
432 
433 public:
434 
435  DECLARE_DYNAMIC_CLASS( a2dLuaEditorFrame )
436 
437  //! this makes dynamic creation possible ( e.g. a derived a2dLuaEditorFrame )
438  /*!
439  Can be used by connectors ( e.g. a2dEditorMultiFrameViewConnector ) to create
440  a derived a2dLuaEditorFrame class using the ClassInfo.
441  This makes one connector class enough for all derived a2dLuaEditorFrame's.
442  This constructor is used in combination with Create() to initilize the a2dLuaEditorFrame.
443  */
445 
446  a2dLuaEditorFrame( bool isParent, wxFrame* parent,
447  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE );
448 
450 
451 protected:
452 
453  bool CallLuaScriptThemeFunction( const wxString& fileName, const wxString& function );
454 
455  void OnUpdateUI( wxUpdateUIEvent& event );
456 
457  void OnShowExecDlg2( wxCommandEvent& event );
458 
459  void OnRunScript( wxCommandEvent& event );
460 
461  void OnTheme( a2dEditorFrameEvent& themeEvent );
462 
463  void OnInit( a2dEditorFrameEvent& initEvent );
464 };
465 
466 
467 #endif
468 
a2dCircle at x,y, and with radius
Definition: canprim.h:554
wxString AskFile(const wxString &message, const wxString &default_path="", const wxString &default_filename="", const wxString &default_extension="", const wxString &wildcard="*.*", int flags=0, int x=-1, int y=-1)
ask for a file using a file selector.
Definition: doccom.h:294
all basic primitives derived from a2dCanvasObject
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
Definition: recur.h:53
The a2dBaseTool is used to derive tools from that are controlled by.
Definition: tools.h:379
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: canobj.cpp:1426
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
dialog for defining style on an a2dCanvasObject
polygon defined with list of points.
Definition: polygon.h:45
a2dError FileOpen(a2dDocumentPtr &doc, const wxFileName &file=wxFileName(wxT("")), a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE|a2dTemplateFlag::LOAD)
Creates a new document and reads in the selected file.
Definition: doccom.cpp:553
Ref Counted base object.
Definition: gen.h:1045
see a2dCommandEvent
Definition: doccom.h:79
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
a2dRectC is a centered rectangle
Definition: canprim.h:99
The base class for all drawable objects in a a2dCanvasDocument.
a2dError FileNew(a2dDocumentPtr &doc, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE)
Creates a document from a list of templates (if more than one template).
Definition: doccom.cpp:535
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
vertex list of line and arc segments.
Definition: polyver.h:600
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
used to theme a a2dEditorFrame
Definition: canedit.h:85
layer dialog for changing layer settings.
a2dText is an abstract base class.
Definition: cantext.h:93
a2dOrigin stays at World Coordinate Zero (0,0) not matter what.
Definition: canprim.h:31
a2dEllipse centered at x,y.
Definition: canprim.h:635
polyline defined with list of points.
Definition: polygon.h:332
bool FileSaveAs(const wxFileName &file=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Calls wxDocument::SaveAs for the current document.
Definition: doccom.cpp:766
One object of this class may be created in an application, to manage all the templates and documents...
Definition: doccom.h:242
a2dImage (will scale/rotate image when needed)
Definition: canimage.h:33
a2dSLine
Definition: canprim.h:987
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
a2dBaseTool * PopTool()
pop a tool from the tool stack of the current active a2dCanvasView
Definition: cancom.cpp:1585
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
holds the central a2dCentralCanvasCommandProcessor which is
bool FileImport(const wxFileName &file=wxFileName(wxT("")), const wxString &description=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Calls a2dDocument::Import for the current document.
Definition: doccom.cpp:900
a2dArrow is used for having line begin and ends on specific objects.
Definition: canprim.h:198
void Refresh()
refresh what is documents and shown on views
Definition: cancom.cpp:1015
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
sepcialized Frame for editor of a2dCanvas
Definition: luawrap.h:429
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
ready made editing class for a a2dCanvas and/or a2dCanvasView
a2dDoWhat
defines what to do
Definition: drawing.h:2601
bool FileExport(const wxFileName &file=wxFileName(wxT("")), const wxString &description=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Calls a2dDocument::Export for the current document.
Definition: doccom.cpp:789
Lua script used to draw the object.
Definition: luawrap.h:57
sepcialized Frame for editor of a2dCanvas
Definition: canedit.h:117
virtual void OnExit()
cleaup modeless dialogs created from here
Definition: cancom.cpp:1765
a2dEndsLine with begin and/or end object.
Definition: canprim.h:1174
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
dialog for choosing a tool
a2dRect
Definition: canprim.h:440
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
a2dArc centered at x,y
Definition: canprim.h:823
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canobj.cpp:5098
a command wrapper specially designed to work with wxArt2D docview classes and rest.
Definition: cancom.h:100
holds one error report.
Definition: gen.h:623
stack based tools controller and tools for drawing and editing.
list of a2dObject's
Definition: gen.h:3157
CloneOptions
options for cloning
Definition: gen.h:1200
a2dEllipticArc centered at x,y
Definition: canprim.h:697
luawrap.h Source File -- Sun Oct 12 2014 17:04:22 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation