wxArt2D
styledialg.h
Go to the documentation of this file.
1 /*! \file wx/canvas/styledialg.h
2  \brief dialog for defining style on an a2dCanvasObject
3  \author Probably Klaas Holwerda
4 
5  Copyright: 2001-2004 (C) Probably Klaas Holwerda
6 
7  Licence: wxWidgets Licence
8 
9  RCS-ID: $Id: styledialg.h,v 1.11 2008/08/19 23:17:12 titato Exp $
10 */
11 
12 #ifndef __WDR_styledialg_H__
13 #define __WDR_styledialg_H__
14 
15 // Include wxWindows' headers
16 
17 #ifndef WX_PRECOMP
18 #include <wx/wx.h>
19 #endif
20 
21 #include <wx/statline.h>
22 #include <wx/spinbutt.h>
23 #include <wx/spinctrl.h>
24 #include <wx/listctrl.h>
25 #include <wx/odcombo.h>
26 
27 #include <wx/colordlg.h>
28 
29 #include <wx/canvas/strucdlg.h>
30 #include <wx/artbase/stylebase.h>
31 #include <wx/canvas/layerinf.h>
32 
33 // Declare window functions
34 
35 #define ID_STYLENAME 10000
36 #define ID_BLUE 10002
37 #define ID_SLIDER_RED 10007
38 #define ID_SLIDER_GREEN 10008
39 #define ID_SLIDER_BLUE 10009
40 #define ID_RED 10004
41 #define ID_GREEN 10005
42 #define ID_FILLCOLOR 10006
43 #define ID_STROKECOLOR 10019
44 #define ID_TEXT 10010
45 #define ID_PIXELWIDTH 10011
46 #define ID_PIXELSTROKE 10012
47 #define ID_STIPPLEBITMAP 10013
48 #define ID_FILLSTYLE 10015
49 #define ID_STROKESTYLE 10016
50 #define ID_COLOURS 10017
51 #define ID_MODEL_BUTTON_OK 10018
52 
53 //! general style dialog to edit a2dCanvasObject style
54 /*!
55  The a2dFill, a2dStroke an a2dContour can be modified interactive with this dialog.
56  It sents the new style in idle time as commands to the global a2dCentralCanvasCommandProcessor,
57  and they end up in the a2dCanvasCommandProcessor of the current document.
58  If there is a current a2dCanvasObject is set for the last, the new style will be set to that object.
59 */
60 class A2DCANVASDLLEXP a2dStyleDialog: public wxDialog
61 {
62  DECLARE_EVENT_TABLE()
63 
64 public:
65 
66  a2dStyleDialog( a2dHabitat* habitat, wxWindow* parent, long style = wxDEFAULT_DIALOG_STYLE, bool modal = false, bool setCentralStyle = true );
67 
68  ~a2dStyleDialog();
69 
70  void SetColor( wxSpinEvent& spinevent );
71 
72  void ColorSelect( wxCommandEvent& event );
73 
74  void OnSpinCtrlText( wxCommandEvent& event );
75 
76  void OnSliderUpdate( wxScrollEvent& event );
77 
78  void OnColourBitmap( wxCommandEvent& event );
79 
80  void OnStippleBitmap( wxCommandEvent& event );
81 
82  void OnFillStyle( wxCommandEvent& event );
83 
84  void OnStrokeStyle( wxCommandEvent& event );
85 
86  void OnPixelWidth( wxCommandEvent& event );
87 
88  void OnPixelWidthSpin( wxSpinEvent& event );
89 
90  void OnPixelStroke( wxCommandEvent& event );
91 
92  //! Close window
93  void OnCloseWindow( wxCloseEvent& event );
94 
95  void OnIdle( wxIdleEvent& idleEvent );
96 
97  void SentStyle( bool fill = true, bool stroke = true );
98 
99  a2dFill& GetFill() { return m_fill; }
100  void SetFill( const a2dFill& fill );
101 
102  a2dStroke& GetStroke() { return m_stroke; }
103  void SetStroke( const a2dStroke& stroke );
104 
105 protected:
106 
107  void OnUndoEvent( a2dCommandProcessorEvent& event );
108 
109  void OnDoEvent( a2dCommandProcessorEvent& event );
110 
111  void OnSize( wxSizeEvent& WXUNUSED( event ) );
112 
113  void OnComEvent( a2dComEvent& event );
114 
115  void CmOk( wxCommandEvent& event );
116 
117  a2dFill m_fill;
118  a2dFill m_oneColFill;
119  a2dFill m_hatchTwoColFill;
120  a2dFill m_PattFill;
121  a2dFill m_linGrad;
122  a2dFill m_radGrad;
123  a2dFill m_dropGrad;
124 
125  a2dStroke m_stroke;
126  a2dStroke m_oneColStroke;
127  a2dStroke m_pattStroke;
128 
129  wxColour m_colorFill1;
130 
131  wxColour m_colorFill2;
132 
133  wxColour m_colorStroke;
134 
135  //! the color that is under modification
136  wxColour* m_color;
137 
138  wxBitmap m_fillstippleb;
139 
140  wxBitmapButton* m_colourfillshow;
141  wxBitmapButton* m_colourstrokeshow;
142  wxBitmapButton* m_fillstipple;
143 
144  wxSlider* m_sliderred;
145 
146  wxSlider* m_slidergreen;
147 
148  wxSlider* m_sliderblue;
149 
150  wxSpinCtrl* m_spinred;
151 
152  wxSpinCtrl* m_spingreen;
153 
154  wxSpinCtrl* m_spinblue;
155 
156 
157  //! colour data for colour dialog
158  wxColourData* m_cdata;
159 
160  //! color dialog for color bitmap button sample
161  wxColourDialog* m_cd;
162 
163  FillPatterns* m_fillpatterns;
164 
165  wxBitmap m_fillpatternmono;
166 
167  wxChoice* m_fillstyles;
168 
169  wxSpinCtrl* m_pixelwidth;
170 
171  wxCheckBox* m_pixelstroke;
172 
173  wxChoice* m_strokestyles;
174 
175  bool m_skipspinevent;
176 
177  //! When canvas event, this is set to prevent sending commands.
179 
180  bool m_modal;
181 
182  bool m_setCentralStyle;
183 
184  bool m_needsUpdate;
185 
186  bool m_fillCommand;
187  bool m_strokeCommand;
188 
189  a2dHabitat* m_habitat;
190 };
191 
192 
193 //===========================================================================
194 // a2dCustomColors
195 //===========================================================================
196 
198 {
199 public:
200  a2dCustomColors();
201 
202  void Init();
203 
204  void Set(const wxColourData &colData);
205  void Get(wxColourData *pColData) const;
206 
207  void Set(int i, const wxColour &color);
208  wxColour Get(int i) const;
209 
210  bool operator==(const a2dCustomColors& rhs);
211  bool operator!=(const a2dCustomColors& rhs);
212 
213 private:
214  wxColour m_Color[wxColourData::NUM_CUSTOM];
215 };
216 
217 
218 //===========================================================================
219 // a2dColorComboBox - combobox for selection of a RGB color (or transparent):
220 //===========================================================================
221 
222 class a2dColorComboBox : public wxOwnerDrawnComboBox
223 {
224  static const wxArrayString TChoices(bool bAllowTransparent);
225 public:
226  //! pCustCol is an optional pointer to custom colors, which will be modified directly!
227  a2dColorComboBox(wxWindow *parent, wxWindowID id, bool bAllowTransparent = true, a2dCustomColors *pCustCol = 0, const wxSize &size = wxDefaultSize);
228  virtual ~a2dColorComboBox() {}
229 
230  void SetColor(const wxColour &color);
231  bool IsColorSelected() const { return (GetSelection() > -1) ? true : false; }
232  wxColour GetColor() const { return m_Color; }
233 
234  virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
235  virtual wxCoord OnMeasureItem(size_t item) const;
236 
237 private:
238  void SelectColor();
239 
240  //========================================================
241  // Event handler:
242  //--------------------------------------------------------
243  void OnSelected(wxCommandEvent& event);
244 
245  DECLARE_EVENT_TABLE()
246 
247 private:
248  bool m_bAllowTransparent;
249  a2dCustomColors *m_pCustomColors;
250  wxColour m_Color;
251 };
252 
253 
254 //===========================================================================
255 // a2dStrokeStyleComboBox - combobox for selection of stroke styles:
256 //===========================================================================
257 
258 class A2DCANVASDLLEXP a2dStrokeStyleComboBox : public wxOwnerDrawnComboBox
259 {
260  static const wxArrayString TChoices(bool bAllowLayerStyle);
261 public:
262  a2dStrokeStyleComboBox(wxWindow *parent, wxWindowID id, bool bAllowLayerStyle = false, const wxSize &size = wxDefaultSize);
263  virtual ~a2dStrokeStyleComboBox() {}
264 
265  void SetStyle(const a2dStrokeStyle &style);
266  bool IsStyleSelected() const { return (GetSelection() > -1) ? true : false; }
267  a2dStrokeStyle GetStyle() const { return m_Style; }
268 
269  virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
270  virtual wxCoord OnMeasureItem(size_t item) const;
271 
272 private:
273  //========================================================
274  // Event handler:
275  //--------------------------------------------------------
276  void OnSelected(wxCommandEvent& event);
277 
278  DECLARE_EVENT_TABLE()
279 
280 private:
281  bool m_bAllowLayerStyle;
282  a2dStrokeStyle m_Style;
283 };
284 
285 
286 //===========================================================================
287 // a2dFillComboBox - combobox for selection of a fill (or transparent):
288 //===========================================================================
289 
290 class A2DCANVASDLLEXP a2dFillComboBox : public wxOwnerDrawnComboBox
291 {
292  static const wxArrayString TChoices(bool bAllowLayerStyle);
293 public:
294  //! pCustCol is an optional pointer to custom colors, which will be modified directly!
295  a2dFillComboBox(wxWindow *parent, wxWindowID id, bool bAllowLayerStyle = false, a2dCustomColors *pCustCol = 0, const wxSize &size = wxDefaultSize);
296  virtual ~a2dFillComboBox() {}
297 
298  void SetFill(const a2dFill &fill);
299  bool IsFillSelected() const { return (GetSelection() > -1) ? true : false; }
300  a2dFill GetFill() const { return m_Fill; }
301 
302  virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const;
303  virtual wxCoord OnMeasureItem(size_t item) const;
304 
305 private:
306  void SelectColor();
307 
308  //========================================================
309  // Event handler:
310  //--------------------------------------------------------
311  void OnSelected(wxCommandEvent& event);
312 
313  DECLARE_EVENT_TABLE()
314 
315 private:
316  bool m_bAllowLayerStyle;
317  a2dCustomColors *m_pCustomColors;
318  a2dFill m_Fill;
319 };
320 
321 
322 //===========================================================================
323 // a2dDialogStyle - dialog for defining style on an a2dCanvasObject:
324 //===========================================================================
325 class wxBitmapToggleButton; // forward declaration
326 
327 /*! simple style dialog
328  This style dialog works on a group of selected objects, and what they have in common is shown in the style dialog.
329  What is different is blank in the dialog, but can still be set.
330 */
331 class A2DCANVASDLLEXP a2dDialogStyle : public wxDialog
332 {
333 public:
334  // bGlobal ... global settings (show info in title bar)
335  // bFill ... enable fill combobox
336  // bAllowLayerStyle ... allows selection for using layer style
337  a2dDialogStyle(wxWindow *parent, bool bGlobal, bool bFill, bool bAllowLayerStyle = false);
338 
339  // Number that defines the physical dimension (in millimeters) of document units.
340  void SetUnitsScale(double scale) { m_UnitsScale = scale; }
341 
342  void SetCustomColors(const a2dCustomColors& colors) { m_CustomColors = colors; }
343  const a2dCustomColors& GetCustomColors() const { return m_CustomColors; }
344 
345  const a2dExtStroke& GetExtStroke() const { return m_ExtStroke; }
346  void SetExtStroke(const a2dExtStroke& extStroke) { m_ExtStroke = extStroke; }
347 
348  const a2dExtFill& GetExtFill() const { return m_ExtFill; }
349  void SetExtFill(const a2dExtFill& extFill) { m_ExtFill = extFill; }
350 
351 private:
352  void CreateControls(bool bAllowLayerStyle);
353  void UpdateStrokeData(bool bGetFromDlg);
354  void SetJoin(wxPenJoin join);
355  void SetCap(wxPenCap cap);
356 
357  //========================================================
358  // Event handler:
359  //--------------------------------------------------------
360  void OnInitDialog(wxInitDialogEvent& event);
361  void OnStrokeStyle(wxCommandEvent& event);
362  void OnJoin(wxCommandEvent& event);
363  void OnCap(wxCommandEvent& event);
364  void OnOk(wxCommandEvent& event);
365 
366  DECLARE_EVENT_TABLE()
367 
368 private:
369  bool m_bFill;
370  double m_UnitsScale;
371  a2dCustomColors m_CustomColors;
372  a2dExtStroke m_ExtStroke;
373  a2dExtFill m_ExtFill;
374 
375  a2dStrokeStyleComboBox *m_pSrokeStyleBox;
376  wxBitmapToggleButton *m_pJoinMiterBt;
377  wxBitmapToggleButton *m_pJoinBevelBt;
378  wxBitmapToggleButton *m_pJoinRoundBt;
379  a2dColorComboBox *m_pStrokeColorBox;
380  wxBitmapToggleButton *m_pCapButtBt;
381  wxBitmapToggleButton *m_pCapProjectingBt;
382  wxBitmapToggleButton *m_pCapRoundBt;
383  wxSpinCtrlDouble *m_pStrokeWidthCtrl;
384  a2dFillComboBox *m_pFillBox;
385 };
386 
387 extern wxUint32 a2dSetExtFill( a2dExtFill& returned, a2dCanvasObjectList* objects, a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::SELECTED, a2dLayers* layersetup = NULL );
388 extern wxUint32 a2dSetExtStroke( a2dExtStroke& returned, a2dCanvasObjectList* objects, a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::SELECTED, a2dLayers* layersetup = NULL );
389 
390 #endif
391 
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
Stroke and fill base classes.
bool m_doSentCommand
When canvas event, this is set to prevent sending commands.
Definition: styledialg.h:178
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
Definition: candefs.h:152
general style dialog to edit a2dCanvasObject style
Definition: styledialg.h:60
wxColourDialog * m_cd
color dialog for color bitmap button sample
Definition: styledialg.h:161
layer settings for a a2dCanvasDocument Holds layers settings classes
static const a2dCanvasObjectFlagsMask SELECTED
Definition: candefs.h:180
defines common settinsg for a habitat for a set of a2dCameleons.
Definition: canglob.h:439
for choosing a a2dCanvasObject from a list.
wxColourData * m_cdata
colour data for colour dialog
Definition: styledialg.h:158
wxColour * m_color
the color that is under modification
Definition: styledialg.h:136
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
see a2dComEvent
Definition: gen.h:371
a2dColorComboBox(wxWindow *parent, wxWindowID id, bool bAllowTransparent=true, a2dCustomColors *pCustCol=0, const wxSize &size=wxDefaultSize)
pCustCol is an optional pointer to custom colors, which will be modified directly! ...
a2dStrokeStyle
stroke styles for a2dStroke
Definition: stylebase.h:298
styledialg.h Source File -- Sun Oct 12 2014 17:04:26 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation