1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 // base_dialog.cpp : implementation file
24 #include "georges_edit.h"
25 #include "georges_edit_doc.h"
26 #include "georges_edit_view.h"
27 #include "base_dialog.h"
32 /////////////////////////////////////////////////////////////////////////////
35 CBaseDialog::CBaseDialog(int accelResource
)
36 : CDialog(CBaseDialog::IDD
)
38 //{{AFX_DATA_INIT(CBaseDialog)
39 // NOTE: the ClassWizard will add member initialization here
41 Accelerator
= LoadAccelerators ( theApp
.m_hInstance
, MAKEINTRESOURCE (accelResource
) );
45 void CBaseDialog::DoDataExchange(CDataExchange
* pDX
)
47 CDialog::DoDataExchange(pDX
);
48 //{{AFX_DATA_MAP(CBaseDialog)
49 // NOTE: the ClassWizard will add DDX and DDV calls here
54 BEGIN_MESSAGE_MAP(CBaseDialog
, CDialog
)
55 //{{AFX_MSG_MAP(CBaseDialog)
60 BEGIN_MESSAGE_MAP(CDoomyControl
, CStatic
)
61 //{{AFX_MSG_MAP(CDoomyControl)
66 /////////////////////////////////////////////////////////////////////////////
67 // CBaseDialog message handlers
69 BOOL
CBaseDialog::OnInitDialog()
71 CDialog::OnInitDialog();
73 return TRUE
; // return TRUE unless you set the focus to a control
74 // EXCEPTION: OCX Property Pages should return FALSE
77 void CBaseDialog::OnSize(UINT nType
, int cx
, int cy
)
79 CDialog::OnSize(nType
, cx
, cy
);
83 void CBaseDialog::getFirstItemPos (RECT
&rect
)
89 void CBaseDialog::setComboSize (RECT
&rect
, uint width
, uint height
)
91 rect
.right
= rect
.left
+ width
;
92 rect
.bottom
= rect
.top
+ height
;
95 void CBaseDialog::setComboSpinSize (RECT
&rect
)
97 rect
.right
= rect
.left
+ SmallWidget
-SpinWidth
;
98 rect
.bottom
= rect
.top
+ ComboHeight
;
101 void CBaseDialog::setComboBrowseSize (RECT
&rect
)
103 rect
.right
= rect
.left
+ SmallWidget
-BrowseWidth
;
104 rect
.bottom
= rect
.top
+ ComboHeight
;
107 void CBaseDialog::adjusteComboSize (RECT
&rect
)
109 rect
.bottom
+= ComboDropDownHeight
;
112 void CBaseDialog::setStaticSize (RECT
&rect
)
114 rect
.right
= rect
.left
+ SmallWidget
;
115 rect
.bottom
= rect
.top
+ StaticHeight
;
118 void CBaseDialog::setEditSize (RECT
&rect
, uint width
, uint height
)
120 rect
.right
= rect
.left
+ width
;
121 rect
.bottom
= rect
.top
+ height
;
124 void CBaseDialog::setColorSize (RECT
&rect
, uint width
, uint height
)
126 rect
.right
= rect
.left
+ width
- ResetColorWidth
;
127 rect
.bottom
= rect
.top
+ height
;
130 void CBaseDialog::setBigEditSize (RECT
&rect
, uint width
, uint height
)
132 rect
.right
= rect
.left
+ width
;
133 rect
.bottom
= rect
.top
+ height
;
136 void CBaseDialog::getNextPos (RECT
&rect
)
138 rect
.top
= rect
.bottom
+ WidgetSpaceHeight
;
141 void CBaseDialog::getNextPosLabel (RECT
&rect
)
143 rect
.top
= rect
.bottom
+ LabelSpaceHeight
;
146 void CBaseDialog::initWidget (CWnd
&wnd
)
148 CFont
* font
= GetFont ();
150 wnd
.ShowWindow (SW_SHOW
);
153 void CBaseDialog::setListSize (RECT
&rect
, uint width
, uint height
)
155 rect
.right
= rect
.left
+ width
;
156 rect
.bottom
= rect
.top
+ height
;
159 void CBaseDialog::setEditSpinSize (RECT
&rect
, uint width
, uint height
)
161 rect
.right
= rect
.left
+ width
;
162 rect
.bottom
= rect
.top
+ height
;
165 void CBaseDialog::setSpinSize (RECT
&rect
, uint width
, uint height
)
167 rect
.right
= rect
.left
+ width
;
168 rect
.bottom
= rect
.top
+ height
;
171 void CBaseDialog::setBrowseSize (RECT
&rect
, uint width
, uint height
)
173 rect
.right
= rect
.left
+ width
;
174 rect
.bottom
= rect
.top
+ height
;
177 void CBaseDialog::setResetColorSize (RECT
&rect
, uint width
, uint height
)
179 rect
.right
= rect
.left
+ width
;
180 rect
.bottom
= rect
.top
+ height
;
183 void CBaseDialog::getNextColumn (RECT
&rect
)
185 rect
.left
+= SmallWidgetNotLimited
+ WidgetSpaceWidth
;
189 void CBaseDialog::getFirstColumn (RECT
&rect
)
194 void CBaseDialog::getNextSpinPos (RECT
&rect
)
196 rect
.left
= rect
.right
;
199 void CBaseDialog::getNextBrowsePos (RECT
&rect
)
201 rect
.left
= rect
.right
;
204 void CBaseDialog::getNextColorPos (RECT
&rect
)
206 rect
.left
= rect
.right
;
209 void CBaseDialog::setButtonSize (RECT
&rect
, uint width
, uint height
)
211 rect
.right
= rect
.left
+ width
;
212 rect
.bottom
= rect
.top
+ height
;
215 void CBaseDialog::OnOK ()
220 void CBaseDialog::OnCancel ()
222 ((CMainFrame
*)theApp
.m_pMainWnd
)->showOutputConsole (false);
225 BOOL
CBaseDialog::PreTranslateMessage(MSG
* pMsg
)
227 // Check if it is a hotkey
228 /*if ( TranslateAccelerator (theApp.m_pMainWnd->m_hWnd, Accelerator, pMsg) )
230 if (theApp
.m_pMainWnd
->PreTranslateMessage(pMsg
))
233 return CDialog::PreTranslateMessage(pMsg
);
236 void CBaseDialog::setEditTextMultiLine (CEdit
&edit
, const char *text
)
238 edit
.SetWindowText (nlUtf8ToTStr(NLMISC::addSlashR(text
)));
241 void CBaseDialog::onOpenSelected()
245 void CBaseDialog::registerLastControl ()
247 RECT rect
= {0, 0, 0, 0};
248 DummyStatic0
.Create (_T("Coucou"), WS_CHILD
|WS_VISIBLE
|WS_TABSTOP
, rect
, this, 30);
249 DummyStatic0
.Dlg
= this;
250 DummyStatic0
.Index
= 0;
251 DummyStatic1
.Create (_T("Coucou"), WS_CHILD
|WS_VISIBLE
|WS_TABSTOP
, rect
, this, 31);
252 DummyStatic1
.Dlg
= this;
253 DummyStatic1
.Index
= 1;
256 void CBaseDialog::unRegisterLastControl ()
258 if (IsWindow (DummyStatic0
))
260 DummyStatic0
.DestroyWindow ();
262 if (IsWindow (DummyStatic1
))
264 DummyStatic1
.DestroyWindow ();
268 void CDoomyControl::OnSetFocus( CWnd
* pOldWnd
)
273 Dlg
->onFirstFocus ();
276 void CBaseDialog::setFocusLastWidget ()
278 CWnd
*wnd
= GetNextDlgTabItem ( &DummyStatic0
, TRUE
);
283 void CBaseDialog::resizeWidgets (uint virtualWidth
, uint evaluatedHeight
)
285 // Get the window size
287 View
->GetClientRect (&rect
);
288 int height
= rect
.bottom
- rect
.top
- View
->WidgetTopMargin
- View
->WidgetBottomMargin
;
289 AdjusteHeight
= (uint
)std::max (0, (int)(height
- evaluatedHeight
));
291 Width
= virtualWidth
- View
->WidgetRightMargin
- View
->WidgetLeftMargin
;
292 SmallWidget
= std::min ( (Width
-WidgetSpaceWidth
) /2, (uint
)MaxWidgetWidth
);
293 SmallWidgetNotLimited
= (Width
-WidgetSpaceWidth
) /2;