1 /*
2 Copyright (C) 2019-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: WxdkdrawDlgMiterLimit.wxc
12 */
13 
14 /**	@file WxdkdrawDlgMiterLimit.cpp The WxdkdrawDlgMiterLimit module.
15 */
16 
17 
18 #ifndef	WXDKDRAWDLGMITERLIMIT_H_INCLUDED
19 #include <wxdkdraw/WxdkdrawDlgMiterLimit.h>
20 #endif
21 
22 
23 
24 
25 
26 
27 
28 #if	wxCHECK_VERSION(3,0,0)
wxBEGIN_EVENT_TABLE(WxdkdrawDlgMiterLimit,wxDialog)29 wxBEGIN_EVENT_TABLE(WxdkdrawDlgMiterLimit,wxDialog)
30 #else
31 BEGIN_EVENT_TABLE(WxdkdrawDlgMiterLimit,wxDialog)
32 #endif
33 	EVT_BUTTON(\
34 		wxID_OK,\
35 		WxdkdrawDlgMiterLimit::OnOK\
36 	)
37 	EVT_BUTTON(\
38 		wxID_CANCEL,\
39 		WxdkdrawDlgMiterLimit::OnCancel\
40 	)
41 	EVT_SPINCTRL(\
42 		WxdkdrawDlgMiterLimit::WXD_ID_SL_ML,\
43 		WxdkdrawDlgMiterLimit::OnSpin\
44 	)
45 #if	wxCHECK_VERSION(3,0,0)
46 wxEND_EVENT_TABLE()
47 #else
48 END_EVENT_TABLE()
49 #endif
50 
51 
52 WxdkdrawDlgMiterLimit::WxdkdrawDlgMiterLimit(
53 	WxdkdrawFrame			*pParent,
54 	Wxd_object_t			*pObject,
55 	wxChar const * const	*pTexts,
56 	bool					 bDrwElem
57 ) : wxDialog(
58 	pParent, wxID_ANY, pTexts[238],
59 	wxDefaultPosition, wxDefaultSize,
60 	(
61 		(wxDEFAULT_DIALOG_STYLE)
62 		& (~(wxRESIZE_BORDER))
63 		& (~(wxCLOSE_BOX))
64 		& (~(wxSYSTEM_MENU))
65 	)
66 )
67 {
68 	m_pParent	= pParent;
69 	m_pObject	= pObject;
70 	m_bDrwElem	= bDrwElem;
71 	m_uLimitOriginal = pObject->ml;
72 	m_uLimitCurrent = m_uLimitOriginal;
73   dkctGUILayoutOK = false;
74   sizerHorizontal = NULL;
75   sizerVertical = NULL;
76   sizerInput = NULL;
77   sizerButtons = NULL;
78   labelValue = NULL;
79   spinValue = NULL;
80   buttonOK = NULL;
81   buttonCancel = NULL;
82   sizerHorizontal = new wxBoxSizer(
83     wxHORIZONTAL
84   );
85   if(!(sizerHorizontal)) {
86     goto dkctGUILayoutFinished;
87   }
88   sizerHorizontal->Add(10, 10, 0);
89   sizerVertical = new wxBoxSizer(
90     wxVERTICAL
91   );
92   if(!(sizerVertical)) {
93     goto dkctGUILayoutFinished;
94   }
95   sizerVertical->Add(10, 10, 0);
96   sizerInput = new wxBoxSizer(
97     wxHORIZONTAL
98   );
99   if(!(sizerInput)) {
100     goto dkctGUILayoutFinished;
101   }
102   labelValue = new wxStaticText(
103     this,
104     wxID_ANY,
105     pTexts[239]
106   );
107   if(!(labelValue)) {
108     goto dkctGUILayoutFinished;
109   }
110   sizerInput->Add(
111     labelValue,
112     0,
113     wxALIGN_CENTER_VERTICAL
114   );
115   sizerInput->Add(10, 10, 0);
116   spinValue = new wxSpinCtrl(
117     this,
118     WXD_ID_SL_ML,
119     wxEmptyString,
120     wxDefaultPosition,
121     wxDefaultSize,
122     0,
123     1,
124     255,
125     8
126   );
127   if(!(spinValue)) {
128     goto dkctGUILayoutFinished;
129   }
130   spinValue->SetToolTip(pTexts[240]);
131   sizerInput->Add(
132     spinValue,
133     0,
134     wxALIGN_CENTER_VERTICAL
135   );
136   sizerVertical->Add(
137     sizerInput,
138     0,
139     wxALIGN_CENTER_HORIZONTAL
140   );
141   sizerVertical->Add(10, 10, 0);
142   sizerButtons = new wxStdDialogButtonSizer(
143   );
144   if(!(sizerButtons)) {
145     goto dkctGUILayoutFinished;
146   }
147   buttonOK = new wxButton(
148     this,
149     wxID_OK,
150     pTexts[241]
151   );
152   if(!(buttonOK)) {
153     goto dkctGUILayoutFinished;
154   }
155   buttonOK->SetToolTip(pTexts[242]);
156   sizerButtons->AddButton(
157     buttonOK
158   );
159   buttonCancel = new wxButton(
160     this,
161     wxID_CANCEL,
162     pTexts[243]
163   );
164   if(!(buttonCancel)) {
165     goto dkctGUILayoutFinished;
166   }
167   buttonCancel->SetToolTip(pTexts[244]);
168   sizerButtons->AddButton(
169     buttonCancel
170   );
171   sizerButtons->Realize();
172   sizerVertical->Add(
173     sizerButtons,
174     0,
175     wxALIGN_CENTER_HORIZONTAL
176   );
177   sizerVertical->Add(10, 10, 0);
178   sizerHorizontal->Add(
179     sizerVertical
180   );
181   sizerHorizontal->Add(10, 10, 0);
182   SetSizer(sizerHorizontal);
183   dkctGUILayoutOK = true;
184   dkctGUILayoutFinished:
185   if(dkctGUILayoutOK) {
186     sizerHorizontal->Fit(this);
187     sizerHorizontal->SetSizeHints(this);
188   }
189 	if (dkctGUILayoutOK) {
190 		wxSize	minsize = GetMinSize();
191 		SetMaxSize(minsize);
192 		spinValue->SetValue(m_uLimitCurrent);
193 	}
194 }
195 
196 
197 
198 
199 void
OnOK(wxCommandEvent & WXUNUSED (event))200 WxdkdrawDlgMiterLimit::OnOK(wxCommandEvent & WXUNUSED(event))
201 {
202 	bool	bDoRefresh = false;
203 
204 	m_uLimitCurrent = (uint8_t)(spinValue->GetValue());
205 	if ((m_bDrwElem) && (m_uLimitCurrent != m_pObject->ml)) {
206 		bDoRefresh = true;
207 	}
208 	m_pObject->ml = m_uLimitCurrent;
209 	if (bDoRefresh) {
210 		m_pParent->RequireRedraw(WXD_REFRESH_DRAWING);
211 	}
212 	if(IsModal()) {
213 		EndModal(wxID_OK);
214 	}
215 	else {
216 		SetReturnCode(wxID_OK);
217 		Show(false);
218 	}
219 }
220 
221 
222 
223 void
OnCancel(wxCommandEvent & WXUNUSED (event))224 WxdkdrawDlgMiterLimit::OnCancel(wxCommandEvent & WXUNUSED(event))
225 {
226 	bool	bDoRefresh = false;
227 	m_uLimitCurrent = m_uLimitOriginal;
228 	if ((m_bDrwElem) && (m_pObject->ml != m_uLimitCurrent)) {
229 		bDoRefresh = true;
230 	}
231 	m_pObject->ml = m_uLimitCurrent;
232 	if (bDoRefresh) {
233 		m_pParent->RequireRedraw(WXD_REFRESH_DRAWING);
234 	}
235 	if(IsModal()) {
236 		EndModal(wxID_CANCEL);
237 	}
238 	else {
239 		SetReturnCode(wxID_CANCEL);
240 		Show(false);
241 	}
242 }
243 
244 
245 
246 void
OnSpin(wxSpinEvent & WXUNUSED (event))247 WxdkdrawDlgMiterLimit::OnSpin(wxSpinEvent & WXUNUSED(event))
248 {
249 	bool		bDoRefresh = false;
250 
251 	m_uLimitCurrent = (uint8_t)(spinValue->GetValue());
252 	if ((m_bDrwElem) && (m_uLimitCurrent != m_pObject->ml)) {
253 		bDoRefresh = true;
254 	}
255 	m_pObject->ml = m_uLimitCurrent;
256 	if (bDoRefresh) {
257 		m_pParent->RequireRedraw(WXD_REFRESH_DRAWING);
258 	}
259 
260 }
261 
262 
263 
264 /* vim: set ai sw=4 ts=4 : */
265 
266