1 /////////////////////////////////////////////////////////////////////////////
2 // Name: settingsdlg.cpp
3 // Purpose: Settings dialog for Frame Layout
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "settingsdlg.cpp"
14 #pragma interface "settingsdlg.cpp"
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
29 #include "settingsdlg.h"
31 /***** Implementation for class SettingsDlg *****/
33 #define ID_NOTES ( wxEVT_FIRST + 1000 )
34 #define ID_HINTANIM_CHECK ( ID_NOTES + 1 )
35 #define ID_RTUPDATES_CHECK ( ID_NOTES + 2 )
37 BEGIN_EVENT_TABLE( SettingsDlg
, wxDialog
)
39 EVT_BUTTON( wxID_APPLY
, SettingsDlg::OnApply
)
40 EVT_BUTTON( ID_NOTES
, SettingsDlg::OnNotes
)
42 EVT_CHECKBOX( ID_HINTANIM_CHECK
, SettingsDlg::OnHintAnimCheck
)
43 EVT_CHECKBOX( ID_RTUPDATES_CHECK
, SettingsDlg::OnRTUpdatesCheck
)
47 SettingsDlg::SettingsDlg( wxWindow
* pParent
)
49 : wxDialog( pParent
, -1, "Active Layout Settings...",
52 wxDIALOG_MODAL
| wxCAPTION
)
56 int lBoxMargin
= lMargin
- 20;
67 mpRTU_Check
= new wxCheckBox( this, ID_RTUPDATES_CHECK
,
69 wxPoint( lMargin
, curY
) );
73 mpOPD_Check
= new wxCheckBox( this, -1, "&Out of Pane drag",
74 wxPoint( lMargin
, curY
) );
78 mpEDP_Check
= new wxCheckBox( this, -1, "&Exact docking prediction",
79 wxPoint( lMargin
, curY
) );
83 mpNDF_Check
= new wxCheckBox( this, -1, "Non-destructive bar &friction",
84 wxPoint( lMargin
, curY
) );
88 mpSPB_Check
= new wxCheckBox( this, -1, "&Shaded pane borders",
89 wxPoint( lMargin
, curY
) );
91 curY
+= checkHeight
+ lastItemGap
;
93 wxStaticBox
* pDNDBox
= new wxStaticBox( this, -1, "Drag && Drop settings",
94 wxPoint( lBoxMargin
, topY
),
95 wxSize( boxWidth
, curY
- topY
) );
99 ////////////////////////////////////////////////////////////////////
105 mpHAP_Check
= new wxCheckBox( this, ID_HINTANIM_CHECK
,
106 "&Hint-Rect animation plugin",
107 wxPoint( lMargin
, curY
) );
111 mpGCU_Check
= new wxCheckBox( this, -1, "\"Garbage collecting\" &Updates-Mgr.",
112 wxPoint( lMargin
, curY
) );
116 mpAFP_Check
= new wxCheckBox( this, -1, "&Antiflicker plugin",
117 wxPoint( lMargin
, curY
) );
121 mpCSP_Check
= new wxCheckBox( this, -1, "C&ustomization plugin",
122 wxPoint( lMargin
, curY
) );
124 curY
+= checkHeight
+ lastItemGap
;
126 wxStaticBox
* pPBox
= new wxStaticBox( this, -1, "Plugins",
127 wxPoint( lBoxMargin
, topY
),
128 wxSize( boxWidth
, curY
- topY
) );
132 ////////////////////////////////////////////////////////////////////
134 wxSize
fieldSz( 30,20 );
135 int fieldHeight
= 20;
136 int fieldCapMargin
= lMargin
+ fieldSz
.x
+ 5;
143 mpRWInput
= new wxTextCtrl ( this, -1, "",
144 wxPoint( lMargin
, curY
),
147 mpRWLabel
= new wxStaticText ( this, -1, "Resizing sash width(height)",
148 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
153 mpPTMInput
= new wxTextCtrl ( this, -1, "",
154 wxPoint( lMargin
, curY
),
157 mpPTMLabel
= new wxStaticText( this, -1, "Pene's top margin",
158 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
164 mpPBMInput
= new wxTextCtrl ( this, -1, "",
165 wxPoint( lMargin
, curY
),
168 mpPBMLabel
= new wxStaticText( this, -1, "Pene's bottom margin",
169 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
175 mpPLMInput
= new wxTextCtrl ( this, -1, "",
176 wxPoint( lMargin
, curY
),
179 mpPLMLabel
= new wxStaticText( this, -1, "Pane's left margin",
180 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
186 mpPRMInput
= new wxTextCtrl ( this, -1, "",
187 wxPoint( lMargin
, curY
),
190 mpPRMLabel
= new wxStaticText( this, -1, "Pane's right margin",
191 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
193 curY
+= fieldHeight
+ lastItemGap
;
195 wxStaticBox
* pCPPBox
= new wxStaticBox( this, -1, "Common Pane properties",
196 wxPoint( lBoxMargin
, topY
),
197 wxSize( boxWidth
, curY
- topY
) );
201 ////////////////////////////////////////////////////////////////////
208 fieldCapMargin
= lMargin
+ fieldSz
.x
+ 10;
210 mpDCInput
= new wxTextCtrl ( this, -1, "",
211 wxPoint( lMargin
, curY
),
214 mpDCLabel
= new wxStaticText ( this, -1, "Dark Color (hex-RGB)",
215 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
219 mpLCInput
= new wxTextCtrl ( this, -1, "",
220 wxPoint( lMargin
, curY
),
223 mpLCLabel
= new wxStaticText ( this, -1, "Light Color (hex-RGB)",
224 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
228 mpGCInput
= new wxTextCtrl ( this, -1, "",
229 wxPoint( lMargin
, curY
),
232 mpGCLabel
= new wxStaticText ( this, -1, "Gray Color (hex-RGB)",
233 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
237 mpBCInput
= new wxTextCtrl ( this, -1, "",
238 wxPoint( lMargin
, curY
),
241 mpBCLabel
= new wxStaticText ( this, -1, "Pane border Color (hex-RGB)",
242 wxPoint( fieldCapMargin
, curY
+ fieldCapOfs
) );
244 curY
+= fieldHeight
+ lastItemGap
;
246 wxStaticBox
* pCSPBox
= new wxStaticBox( this, -1, "Coluor sheme properties",
247 wxPoint( lBoxMargin
, topY
),
248 wxSize( boxWidth
, curY
- topY
) );
250 curY
+= interBoxGap
; /*button ofs*/;
252 ////////////////////////////////////////////////////////////////////////////////
259 wxButton
* mpApplyBtn
= new wxButton( this, wxID_APPLY
, "A&pply",
260 wxPoint( lBtnMargin
, curY
),
261 wxSize( btnWidth
, btnHeight
) );
263 wxButton
* mpCancelBtn
= new wxButton( this, wxID_CANCEL
, "&Cancel",
264 wxPoint( lBtnMargin
+ btnWidth
+ btnGap
, curY
),
265 wxSize( btnWidth
, btnHeight
) );
267 wxButton
* mpNotesBtn
= new wxButton( this, ID_NOTES
, "&Notes...",
268 wxPoint( lBtnMargin
+ 2*btnWidth
+ 2*btnGap
, curY
),
269 wxSize( btnWidth
, btnHeight
) );
271 mpApplyBtn
->SetDefault();
272 mpApplyBtn
->SetFocus();
277 void SettingsDlg::ExchangeFields( bool toDialog
)
281 ExchgCheck( mpRTU_Check
, mRealTimeUpdatesOn
);
282 ExchgCheck( mpOPD_Check
, mOutOfPaneDragOn
);
283 ExchgCheck( mpEDP_Check
, mExactDockingPredictionOn
);
284 ExchgCheck( mpNDF_Check
, mNonDestructFrictionOn
);
285 ExchgCheck( mpSPB_Check
, m3DShadesOn
);
287 ExchgCheck( mpHAP_Check
, mHintRectAnimationOn
);
288 ExchgCheck( mpGCU_Check
, mGCUpdatesMgrOn
);
289 ExchgCheck( mpAFP_Check
, mAntiflickerPluginOn
);
290 ExchgCheck( mpCSP_Check
, mCustomizationPluginOn
);
292 ExchgIntField( mpRWInput
, mSashWidth
);
293 ExchgIntField( mpPTMInput
, mTopMargin
);
294 ExchgIntField( mpPBMInput
, mBottomMargin
);
295 ExchgIntField( mpPLMInput
, mLeftMargin
);
296 ExchgIntField( mpPRMInput
, mRightMargin
);
298 ExchgColourField( mpDCInput
, mDarkCol
);
299 ExchgColourField( mpLCInput
, mLightCol
);
300 ExchgColourField( mpGCInput
, mGrayCol
);
301 ExchgColourField( mpBCInput
, mBorderCol
);
304 void SettingsDlg::OnApply( wxCommandEvent
& event
)
306 ExchangeFields( FALSE
);
307 EndModal( wxID_APPLY
);
310 void SettingsDlg::OnNotes( wxCommandEvent
& event
)
312 wxMessageBox("Notes go here...(TBD)");
315 void SettingsDlg::OnRTUpdatesCheck( wxCommandEvent
& event
)
317 if ( mpRTU_Check
->GetValue() == TRUE
)
319 // user probably wants to see how the real-time drag & drop
320 // works -- so we "let 'im know" that animation is N/A when
321 // real-time option is on
323 mpHAP_Check
->SetValue(FALSE
);
324 mpHAP_Check
->Refresh();
328 void SettingsDlg::OnHintAnimCheck( wxCommandEvent
& event
)
330 if ( mpHAP_Check
->GetValue() == TRUE
)
332 // user probably wants to see some animation effects,
333 // but he/she forgot to turn off "real-time updates"
334 // setting -- so we do it for you :-)
336 mpRTU_Check
->SetValue(FALSE
);
337 mpRTU_Check
->Refresh();
341 void SettingsDlg::ExchgCheck( wxCheckBox
* pChk
, bool& value
)
343 if ( mToDlg
) pChk
->SetValue( value
);
345 else value
= pChk
->GetValue();
348 void SettingsDlg::ExchgIntField( wxTextCtrl
* pFld
, int& value
)
354 sprintf( buf
, "%d", value
);
355 pFld
->SetValue( buf
);
359 wxString txt
= pFld
->GetLineText( 0 );
364 void SettingsDlg::ExchgColourField( wxTextCtrl
* pFld
, wxColour
& value
)
370 rgbVal
= ( value
.Red() & 0x0000FF ) |
371 ( (value
.Green() << 8 ) & 0x00FF00 ) |
372 ( (value
.Blue() << 16 ) & 0xFF0000 );
376 sprintf( buf
, "0x%06X", rgbVal
);
378 pFld
->SetValue( buf
);
382 wxString txt
= pFld
->GetLineText( 0 );
384 sscanf( txt
, "0x%06X", &rgbVal
);
386 value
.Set( rgbVal
& 0xFF,
387 ( rgbVal
>> 8 ) & 0xFF,
388 ( rgbVal
>> 16 ) & 0xFF );
392 bool SettingsDlg::TransferDataToWindow()
394 ExchangeFields( TRUE
);
399 bool SettingsDlg::TransferDataFromWindow()
401 ExchangeFields( FALSE
);
406 #include "controlbar.h"
407 #include "rowlayoutpl.h"
408 #include "antiflickpl.h"
409 #include "bardragpl.h"
410 #include "cbcustom.h"
412 #include "gcupdatesmgr.h"
413 #include "hintanimpl.h"
415 void SettingsDlg::ReadLayoutSettings( wxFrameLayout
& fl
)
417 cbDockPane
& pane
= *fl
.GetPane( wxTOP
);
418 cbCommonPaneProperties
& props
= pane
.mProps
;
420 mRealTimeUpdatesOn
= props
.mRealTimeUpdatesOn
;
421 mOutOfPaneDragOn
= props
.mOutOfPaneDragOn
;
422 mExactDockingPredictionOn
= props
.mExactDockPredictionOn
;
423 mNonDestructFrictionOn
= props
.mNonDestructFirctionOn
;
424 m3DShadesOn
= props
.mShow3DPaneBorderOn
;
426 mHintRectAnimationOn
= fl
.FindPlugin( CLASSINFO( cbHintAnimationPlugin
) ) != NULL
;
427 mAntiflickerPluginOn
= fl
.FindPlugin( CLASSINFO( cbAntiflickerPlugin
) ) != NULL
;
428 mCustomizationPluginOn
= fl
.FindPlugin( CLASSINFO( cbSimpleCustomizationPlugin
) ) != NULL
;
429 mGCUpdatesMgrOn
= fl
.GetUpdatesManager().GetClassInfo()
430 == CLASSINFO( cbGCUpdatesMgr
);
432 mSashWidth
= props
.mResizeHandleSize
;
434 mTopMargin
= pane
.mTopMargin
;
435 mBottomMargin
= pane
.mBottomMargin
;
436 mLeftMargin
= pane
.mLeftMargin
;
437 mRightMargin
= pane
.mRightMargin
;
439 mDarkCol
= fl
.mDarkPen
.GetColour();
440 mLightCol
= fl
.mLightPen
.GetColour();
441 mGrayCol
= fl
.mGrayPen
.GetColour();
442 mBorderCol
= fl
.mBorderPen
.GetColour();
445 void SettingsDlg::ApplyLayoutSettings( wxFrameLayout
& fl
)
447 cbCommonPaneProperties props
;
449 props
.mRealTimeUpdatesOn
= mRealTimeUpdatesOn
;
450 props
.mOutOfPaneDragOn
= mOutOfPaneDragOn
;
451 props
.mExactDockPredictionOn
= mExactDockingPredictionOn
;
452 props
.mNonDestructFirctionOn
= mNonDestructFrictionOn
;
453 props
.mShow3DPaneBorderOn
= m3DShadesOn
;
455 props
.mResizeHandleSize
= mSashWidth
;
457 fl
.SetPaneProperties( props
, wxALL_PANES
);
459 if ( mHintRectAnimationOn
) fl
.AddPlugin ( CLASSINFO( cbHintAnimationPlugin
) );
460 else fl
.RemovePlugin( CLASSINFO( cbHintAnimationPlugin
) );
462 if ( mAntiflickerPluginOn
) fl
.AddPlugin ( CLASSINFO( cbAntiflickerPlugin
) );
463 else fl
.RemovePlugin( CLASSINFO( cbAntiflickerPlugin
) );
465 if ( mCustomizationPluginOn
) fl
.AddPlugin ( CLASSINFO( cbSimpleCustomizationPlugin
) );
466 else fl
.RemovePlugin( CLASSINFO( cbSimpleCustomizationPlugin
) );
468 // FOR NOW:: unfortunatelly, currently pane marin-information is currently
469 // placed into cbDockPane, instead of cbCommonPaneProperties
471 fl
.SetMargins( mTopMargin
, mBottomMargin
,
472 mLeftMargin
, mRightMargin
, wxALL_PANES
);
474 fl
.mDarkPen
.SetColour( mDarkCol
);
475 fl
.mLightPen
.SetColour( mLightCol
);
476 fl
.mGrayPen
.SetColour( mGrayCol
);
477 fl
.mBorderPen
.SetColour( mBorderCol
);
479 fl
.RecalcLayout( TRUE
);
481 // NOTE:: currently it's bit tricky changing updates-manager
482 // in future, updates-manager will become a normal plugin
483 // and more convenient methods (Add/FindPlugin) will be used
485 if ( mGCUpdatesMgrOn
&&
486 fl
.GetUpdatesManager().GetClassInfo() != CLASSINFO( cbGCUpdatesMgr
)
489 fl
.SetUpdatesManager( new cbGCUpdatesMgr( &fl
) );
491 if ( !mGCUpdatesMgrOn
&&
492 fl
.GetUpdatesManager().GetClassInfo() == CLASSINFO( cbGCUpdatesMgr
)
495 fl
.SetUpdatesManager( new cbSimpleUpdatesMgr( &fl
) );