ParameterCtrls.cpp 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/ParameterCtrls.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 10/27/01 5:16p $*
  29. * *
  30. * $Revision:: 36 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "parameterctrls.h"
  37. #include "simpleparameter.h"
  38. #include "utils.h"
  39. #include "filemgr.h"
  40. #include "vector3.h"
  41. #include "PhysObjectEditDialog.h"
  42. #include "definitionfactory.h"
  43. #include "definitionfactorymgr.h"
  44. #include "presetmgr.h"
  45. #include "preset.h"
  46. #include "icons.h"
  47. #include "ScriptEditDialog.h"
  48. #include "PresetListDialog.h"
  49. #include "EditScript.h"
  50. #include "ScriptMgr.h"
  51. #include "combatchunkid.h"
  52. #include "parameterctrls.h"
  53. #include "zoneeditdialog.h"
  54. #include "specsheet.h"
  55. #include "phys.h"
  56. #include "definitionutils.h"
  57. #include "editfilenamelistdialog.h"
  58. #include "colorpickerdialogclass.h"
  59. ///////////////////////////////////////////////////////////////////////////////////////////
  60. // Local inlines
  61. ///////////////////////////////////////////////////////////////////////////////////////////
  62. inline int
  63. Get_Ctrl_Height (HWND hdlg, int dlg_units)
  64. {
  65. RECT temp_rect;
  66. temp_rect.left = 0;
  67. temp_rect.top = 0;
  68. temp_rect.right = dlg_units;
  69. temp_rect.bottom = dlg_units;
  70. ::MapDialogRect (::GetParent (hdlg), &temp_rect);
  71. return temp_rect.bottom - temp_rect.top;
  72. }
  73. inline void
  74. Get_String_Size (HWND parent_wnd, LPCTSTR text, LPSIZE text_size)
  75. {
  76. HDC hdc = ::GetDC (parent_wnd);
  77. HFONT hold_font = (HFONT)::SelectObject (hdc, (HFONT)::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  78. GetTextExtentPoint32 (hdc, text, ::lstrlen (text), text_size);
  79. ::SelectObject (hdc, hold_font);
  80. ::ReleaseDC (parent_wnd, hdc);
  81. return ;
  82. }
  83. ///////////////////////////////////////////////////////////////////////////////////////////
  84. // Local prototypes
  85. ///////////////////////////////////////////////////////////////////////////////////////////
  86. void Create_Float_Ctrls (CWnd *parent_wnd, CEdit &edit_ctrl, CSpinButtonCtrl &spin_ctrl, const CRect &rect, int id1, int id2);
  87. /////////////////////////////////////////////////////////////////////////////
  88. //
  89. // Constants
  90. //
  91. /////////////////////////////////////////////////////////////////////////////
  92. static const int BORDER_WIDTH = 10;
  93. static const int SPACE_WIDTH = 5;
  94. static const int TEXT_HEIGHT = 10;
  95. static const int CTRL_HEIGHT = 13;
  96. //*******************************************************************************************//
  97. //
  98. // Local utility functions
  99. //
  100. //*******************************************************************************************//
  101. //////////////////////////////////////////////////////////////////////
  102. //
  103. // Create_Static_Text_Controls
  104. //
  105. //////////////////////////////////////////////////////////////////////
  106. void
  107. Create_Static_Text_Controls
  108. (
  109. HWND parent_wnd,
  110. const CRect & control_rect,
  111. CStatic * left_text,
  112. LPCTSTR param_name,
  113. CStatic * right_text,
  114. LPCTSTR units_name,
  115. CRect * remaining_rect
  116. )
  117. {
  118. //
  119. // Determine the dimensions of the parameter name
  120. //
  121. CSize text_size;
  122. Get_String_Size (parent_wnd, param_name, &text_size);
  123. //
  124. // Build a rectangle which will contain the parameter name
  125. //
  126. int ctrl_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  127. CRect text_rect = control_rect;
  128. text_rect.right = text_rect.left + text_size.cx + 2;
  129. text_rect.top += ((ctrl_height >> 1) - (text_size.cy >> 1));
  130. text_rect.bottom = text_rect.top + text_size.cy;
  131. //
  132. // Create the left static text control (showing the param name)
  133. //
  134. left_text->Create ( param_name,
  135. WS_CHILD | WS_VISIBLE | SS_LEFT,
  136. text_rect,
  137. CWnd::FromHandle (parent_wnd));
  138. left_text->SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  139. //
  140. // Build a rectangle that represents the left over control area
  141. //
  142. remaining_rect->left = text_rect.right + SPACE_WIDTH;
  143. remaining_rect->right = control_rect.right;
  144. remaining_rect->top = control_rect.top;
  145. remaining_rect->bottom = control_rect.top + ctrl_height;
  146. //
  147. // Do we need to create a 'units' control?
  148. //
  149. if (right_text != NULL) {
  150. //
  151. // Calculate the width of the units string
  152. //
  153. Get_String_Size (parent_wnd, units_name, &text_size);
  154. CRect text2_rect = text_rect;
  155. text2_rect.left = control_rect.right - (text_size.cx + 2);
  156. text2_rect.right = control_rect.right;
  157. //
  158. // Create the right static text control (showing the param units)
  159. //
  160. right_text->Create ( units_name,
  161. WS_CHILD | WS_VISIBLE | SS_LEFT,
  162. text2_rect,
  163. CWnd::FromHandle (parent_wnd));
  164. right_text->SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  165. //
  166. // Shorten the remaining rectangle
  167. //
  168. remaining_rect->right = text2_rect.left - SPACE_WIDTH;
  169. }
  170. return;
  171. }
  172. //////////////////////////////////////////////////////////////////////
  173. //
  174. // Resize_Controls
  175. //
  176. //////////////////////////////////////////////////////////////////////
  177. void
  178. Resize_Controls
  179. (
  180. const CRect & rect,
  181. CWnd & left_wnd,
  182. CWnd & middle_wnd,
  183. CWnd & right_wnd
  184. )
  185. {
  186. //
  187. // Get the current bounding boxes of the controls
  188. //
  189. CRect old_rect1;
  190. CRect old_rect2;
  191. CRect old_rect3;
  192. left_wnd.GetWindowRect (&old_rect1);
  193. middle_wnd.GetWindowRect (&old_rect2);
  194. right_wnd.GetWindowRect (&old_rect3);
  195. HWND parent_wnd = ::GetParent (left_wnd);
  196. ::ScreenToClient (parent_wnd, (LPPOINT)&old_rect2);
  197. ::ScreenToClient (parent_wnd, ((LPPOINT)&old_rect2)+1);
  198. ::ScreenToClient (parent_wnd, (LPPOINT)&old_rect3);
  199. ::ScreenToClient (parent_wnd, ((LPPOINT)&old_rect3)+1);
  200. //
  201. // Resize the middle control and reposition the right control
  202. //
  203. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH + old_rect3.Width () + SPACE_WIDTH);
  204. middle_wnd.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  205. right_wnd.SetWindowPos (NULL, old_rect2.left + new_width + SPACE_WIDTH, old_rect3.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  206. return ;
  207. }
  208. //*******************************************************************************************//
  209. //
  210. // Start of FileParameterCtrlClass
  211. //
  212. //*******************************************************************************************//
  213. //////////////////////////////////////////////////////////////////////
  214. //
  215. // Create
  216. //
  217. //////////////////////////////////////////////////////////////////////
  218. int
  219. FileParameterCtrlClass::Create
  220. (
  221. HWND parent_wnd,
  222. int id_start,
  223. LPRECT pos
  224. )
  225. {
  226. int text_height = ::Get_Ctrl_Height (parent_wnd, TEXT_HEIGHT);
  227. int picker_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  228. CRect text_rect = *pos;
  229. text_rect.bottom += text_height;
  230. //
  231. // Create the static text control
  232. //
  233. m_StaticText.Create (m_Parameter->Get_Name (),
  234. WS_CHILD | WS_VISIBLE | SS_LEFT,
  235. text_rect,
  236. CWnd::FromHandle (parent_wnd));
  237. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  238. CRect picker_rect = *pos;
  239. picker_rect.top = text_rect.bottom;
  240. picker_rect.bottom = picker_rect.top + picker_height;
  241. //
  242. // Create the file picker control
  243. //
  244. m_FilePicker.Create_Picker ( WS_CHILD | WS_TABSTOP | WS_VISIBLE,
  245. picker_rect,
  246. CWnd::FromHandle (parent_wnd),
  247. id_start);
  248. m_FilePicker.SetWindowText (m_Parameter->Get_String ());
  249. CString filter_string;
  250. filter_string.Format ("%s (*%s)|*%s|All Files (*.*)|*.*||", m_Parameter->Get_Description (), m_Parameter->Get_Extension (), m_Parameter->Get_Extension ());
  251. m_FilePicker.Set_Filter_String (filter_string);
  252. pos->bottom = picker_rect.bottom;
  253. if (m_IsReadOnly) {
  254. m_FilePicker.Set_Read_Only (true);
  255. m_FilePicker.EnableWindow (false);
  256. }
  257. id_start ++;
  258. return id_start;
  259. }
  260. //////////////////////////////////////////////////////////////////////
  261. //
  262. // Resize
  263. //
  264. //////////////////////////////////////////////////////////////////////
  265. void
  266. FileParameterCtrlClass::Resize (const CRect &rect)
  267. {
  268. CRect old_rect1;
  269. CRect old_rect2;
  270. m_StaticText.GetWindowRect (&old_rect1);
  271. m_FilePicker.GetWindowRect (&old_rect2);
  272. m_StaticText.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect1.Height (), SWP_NOZORDER | SWP_NOMOVE);
  273. m_FilePicker.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  274. return ;
  275. }
  276. //////////////////////////////////////////////////////////////////////
  277. //
  278. // Is_Modified
  279. //
  280. //////////////////////////////////////////////////////////////////////
  281. bool
  282. FileParameterCtrlClass::Is_Modified (void) const
  283. {
  284. bool retval = false;
  285. if (m_Parameter != NULL) {
  286. //
  287. // Simply compare the current and original values
  288. //
  289. CString curr_value;
  290. Get_Current_Value (curr_value);
  291. CString orig_value = m_Parameter->Get_String ();
  292. retval = (orig_value.CompareNoCase (curr_value) != 0);
  293. }
  294. return retval;
  295. }
  296. //////////////////////////////////////////////////////////////////////
  297. //
  298. // Read_Data
  299. //
  300. //////////////////////////////////////////////////////////////////////
  301. void
  302. FileParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  303. {
  304. CString path;
  305. Get_Current_Value (path);
  306. if (::Get_File_Mgr ()->Is_Empty_Path (path) == false) {
  307. m_Parameter->Set_String ((LPCTSTR)path);
  308. } else {
  309. m_Parameter->Set_String ("");
  310. }
  311. return ;
  312. }
  313. //////////////////////////////////////////////////////////////////////
  314. //
  315. // Get_Current_Value
  316. //
  317. //////////////////////////////////////////////////////////////////////
  318. void
  319. FileParameterCtrlClass::Get_Current_Value (CString &value) const
  320. {
  321. CString filename;
  322. m_FilePicker.GetWindowText (filename);
  323. value = ::Get_File_Mgr ()->Make_Full_Path (filename);
  324. value = ::Get_File_Mgr ()->Make_Relative_Path (value);
  325. return ;
  326. }
  327. //*******************************************************************************************//
  328. //
  329. // Start of StringsDBEntryParameterCtrlClass
  330. //
  331. //*******************************************************************************************//
  332. //////////////////////////////////////////////////////////////////////
  333. //
  334. // Create
  335. //
  336. //////////////////////////////////////////////////////////////////////
  337. int
  338. StringsDBEntryParameterCtrlClass::Create
  339. (
  340. HWND parent_wnd,
  341. int id_start,
  342. LPRECT pos
  343. )
  344. {
  345. int text_height = ::Get_Ctrl_Height (parent_wnd, TEXT_HEIGHT);
  346. int picker_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT) + 4;
  347. CRect text_rect = *pos;
  348. text_rect.bottom += text_height;
  349. //
  350. // Create the static text control
  351. //
  352. m_StaticText.Create (m_Parameter->Get_Name (),
  353. WS_CHILD | WS_VISIBLE | SS_LEFT,
  354. text_rect,
  355. CWnd::FromHandle (parent_wnd));
  356. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  357. CRect picker_rect = *pos;
  358. picker_rect.top = text_rect.bottom;
  359. picker_rect.bottom = picker_rect.top + picker_height;
  360. //
  361. // Create the file picker control
  362. //
  363. m_StringPicker.Create_Picker ( WS_CHILD | WS_TABSTOP | WS_VISIBLE,
  364. picker_rect,
  365. CWnd::FromHandle (parent_wnd),
  366. id_start);
  367. m_StringPicker.Set_Entry (m_Parameter->Get_Value ());
  368. m_StringPicker.Set_Read_Only (true);
  369. pos->bottom = picker_rect.bottom;
  370. if (m_IsReadOnly) {
  371. m_StringPicker.EnableWindow (false);
  372. }
  373. id_start ++;
  374. return id_start;
  375. }
  376. //////////////////////////////////////////////////////////////////////
  377. //
  378. // Resize
  379. //
  380. //////////////////////////////////////////////////////////////////////
  381. void
  382. StringsDBEntryParameterCtrlClass::Resize (const CRect &rect)
  383. {
  384. CRect old_rect1;
  385. CRect old_rect2;
  386. m_StaticText.GetWindowRect (&old_rect1);
  387. m_StringPicker.GetWindowRect (&old_rect2);
  388. m_StaticText.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect1.Height (), SWP_NOZORDER | SWP_NOMOVE);
  389. m_StringPicker.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  390. return ;
  391. }
  392. //////////////////////////////////////////////////////////////////////
  393. //
  394. // Read_Data
  395. //
  396. //////////////////////////////////////////////////////////////////////
  397. void
  398. StringsDBEntryParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  399. {
  400. m_Parameter->Set_Value (m_StringPicker.Get_Entry ());
  401. return ;
  402. }
  403. //*******************************************************************************************//
  404. //
  405. // Start of SoundFileParameterCtrlClass
  406. //
  407. //*******************************************************************************************//
  408. //////////////////////////////////////////////////////////////////////
  409. //
  410. // Create
  411. //
  412. //////////////////////////////////////////////////////////////////////
  413. int
  414. SoundFileParameterCtrlClass::Create
  415. (
  416. HWND parent_wnd,
  417. int id_start,
  418. LPRECT pos
  419. )
  420. {
  421. FileParameterCtrlClass::Create (parent_wnd, id_start, pos);
  422. m_FilePicker.Set_Filter_String ("Sound Files (*.wav,*.mp3)|*.wav;*.mp3|All Files (*.*)|*.*||");
  423. return id_start;
  424. }
  425. //*******************************************************************************************//
  426. //
  427. // Start of StringParameterCtrlClass
  428. //
  429. //*******************************************************************************************//
  430. //////////////////////////////////////////////////////////////////////
  431. //
  432. // Create
  433. //
  434. //////////////////////////////////////////////////////////////////////
  435. int
  436. StringParameterCtrlClass::Create
  437. (
  438. HWND parent_wnd,
  439. int id_start,
  440. LPRECT pos
  441. )
  442. {
  443. int text_height = ::Get_Ctrl_Height (parent_wnd, TEXT_HEIGHT);
  444. int edit_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  445. CRect text_rect = *pos;
  446. text_rect.bottom += text_height;
  447. //
  448. // Create the static text control
  449. //
  450. m_StaticText.Create (m_Parameter->Get_Name (),
  451. WS_CHILD | WS_VISIBLE | SS_LEFT,
  452. text_rect,
  453. CWnd::FromHandle (parent_wnd));
  454. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  455. CRect edit_rect = *pos;
  456. edit_rect.top = text_rect.bottom;
  457. edit_rect.bottom = edit_rect.top + edit_height;
  458. //
  459. // Create the edit control
  460. //
  461. m_EditCtrl.Create ( WS_CHILD | WS_TABSTOP | WS_VISIBLE,
  462. edit_rect,
  463. CWnd::FromHandle (parent_wnd),
  464. id_start ++);
  465. m_EditCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  466. m_EditCtrl.ModifyStyleEx (0, WS_EX_CLIENTEDGE, 0);
  467. m_EditCtrl.SetWindowText (m_Parameter->Get_String ());
  468. pos->bottom = edit_rect.bottom;
  469. if (m_IsReadOnly) {
  470. m_EditCtrl.EnableWindow (false);
  471. }
  472. id_start ++;
  473. return id_start;
  474. }
  475. //////////////////////////////////////////////////////////////////////
  476. //
  477. // Resize
  478. //
  479. //////////////////////////////////////////////////////////////////////
  480. void
  481. StringParameterCtrlClass::Resize (const CRect &rect)
  482. {
  483. CRect old_rect1;
  484. CRect old_rect2;
  485. m_StaticText.GetWindowRect (&old_rect1);
  486. m_EditCtrl.GetWindowRect (&old_rect2);
  487. m_StaticText.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect1.Height (), SWP_NOZORDER | SWP_NOMOVE);
  488. m_EditCtrl.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  489. return ;
  490. }
  491. //////////////////////////////////////////////////////////////////////
  492. //
  493. // Read_Data
  494. //
  495. //////////////////////////////////////////////////////////////////////
  496. void
  497. StringParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  498. {
  499. CString text;
  500. m_EditCtrl.GetWindowText (text);
  501. m_Parameter->Set_String ((LPCTSTR)text);
  502. return ;
  503. }
  504. //*******************************************************************************************//
  505. //
  506. // Start of IntParameterCtrlClass
  507. //
  508. //*******************************************************************************************//
  509. //////////////////////////////////////////////////////////////////////
  510. //
  511. // Create
  512. //
  513. //////////////////////////////////////////////////////////////////////
  514. int
  515. IntParameterCtrlClass::Create
  516. (
  517. HWND parent_wnd,
  518. int id_start,
  519. LPRECT pos
  520. )
  521. {
  522. CString param_name = m_Parameter->Get_Name ();
  523. CString units_name = m_Parameter->Get_Units_Name ();
  524. //
  525. // Create the static text controls
  526. //
  527. CRect edit_rect;
  528. Create_Static_Text_Controls ( parent_wnd,
  529. *pos,
  530. &m_StaticText1,
  531. param_name,
  532. &m_StaticText2,
  533. units_name,
  534. &edit_rect);
  535. //
  536. // Create the edit control
  537. //
  538. m_EditCtrl.Create ( WS_CHILD | WS_TABSTOP | WS_VISIBLE,
  539. edit_rect,
  540. CWnd::FromHandle (parent_wnd),
  541. id_start ++);
  542. m_EditCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  543. m_EditCtrl.ModifyStyleEx (0, WS_EX_CLIENTEDGE, 0);
  544. ::Make_Edit_Int_Ctrl (m_EditCtrl);
  545. //
  546. // Create the spin control
  547. //
  548. m_SpinCtrl.Create ( UDS_ARROWKEYS | UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_NOTHOUSANDS | WS_CHILD | WS_VISIBLE,
  549. CRect (0, 0, 50, 20),
  550. CWnd::FromHandle (parent_wnd),
  551. id_start ++);
  552. m_SpinCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  553. m_SpinCtrl.SetRange32 (m_Parameter->Get_Min (), m_Parameter->Get_Max ());
  554. CString text;
  555. text.Format ("%d", m_Parameter->Get_Value ());
  556. m_EditCtrl.SetWindowText (text);
  557. if (m_IsReadOnly) {
  558. m_EditCtrl.EnableWindow (false);
  559. m_SpinCtrl.EnableWindow (false);
  560. }
  561. pos->bottom = edit_rect.bottom;
  562. return id_start;
  563. }
  564. //////////////////////////////////////////////////////////////////////
  565. //
  566. // Resize
  567. //
  568. //////////////////////////////////////////////////////////////////////
  569. void
  570. IntParameterCtrlClass::Resize (const CRect &rect)
  571. {
  572. Resize_Controls (rect, m_StaticText1, m_EditCtrl, m_StaticText2);
  573. m_SpinCtrl.SetBuddy (&m_EditCtrl);
  574. return ;
  575. }
  576. //////////////////////////////////////////////////////////////////////
  577. //
  578. // Read_Data
  579. //
  580. //////////////////////////////////////////////////////////////////////
  581. void
  582. IntParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  583. {
  584. CString text_value;
  585. m_EditCtrl.GetWindowText (text_value);
  586. m_Parameter->Set_Value (::atol (text_value));
  587. return ;
  588. }
  589. //*******************************************************************************************//
  590. //
  591. // Start of FloatParameterCtrlClass
  592. //
  593. //*******************************************************************************************//
  594. //////////////////////////////////////////////////////////////////////
  595. //
  596. // Create
  597. //
  598. //////////////////////////////////////////////////////////////////////
  599. int
  600. FloatParameterCtrlClass::Create
  601. (
  602. HWND parent_wnd,
  603. int id_start,
  604. LPRECT pos
  605. )
  606. {
  607. CString param_name = m_Parameter->Get_Name ();
  608. CString units_name = m_Parameter->Get_Units_Name ();
  609. //
  610. // Create the static text controls
  611. //
  612. CRect edit_rect;
  613. Create_Static_Text_Controls ( parent_wnd,
  614. *pos,
  615. &m_StaticText1,
  616. param_name,
  617. &m_StaticText2,
  618. units_name,
  619. &edit_rect);
  620. //
  621. // Create the float controls
  622. //
  623. ::Create_Float_Ctrls ( CWnd::FromHandle (parent_wnd),
  624. m_EditCtrl,
  625. m_SpinCtrl,
  626. edit_rect,
  627. id_start++,
  628. id_start ++);
  629. ::SetWindowFloat (m_EditCtrl, m_Parameter->Get_Value ());
  630. m_SpinCtrl.SetRange32 (m_Parameter->Get_Min () * 100, m_Parameter->Get_Max () * 100);
  631. if (m_IsReadOnly) {
  632. m_EditCtrl.EnableWindow (false);
  633. m_SpinCtrl.EnableWindow (false);
  634. }
  635. pos->bottom = edit_rect.bottom;
  636. return id_start;
  637. }
  638. //////////////////////////////////////////////////////////////////////
  639. //
  640. // Resize
  641. //
  642. //////////////////////////////////////////////////////////////////////
  643. void
  644. FloatParameterCtrlClass::Resize (const CRect &rect)
  645. {
  646. Resize_Controls (rect, m_StaticText1, m_EditCtrl, m_StaticText2);
  647. m_SpinCtrl.SetBuddy (&m_EditCtrl);
  648. return ;
  649. }
  650. //////////////////////////////////////////////////////////////////////
  651. //
  652. // Read_Data
  653. //
  654. //////////////////////////////////////////////////////////////////////
  655. void
  656. FloatParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  657. {
  658. m_Parameter->Set_Value (GetWindowFloat (m_EditCtrl, true));
  659. return ;
  660. }
  661. //*******************************************************************************************//
  662. //
  663. // Start of AngleParameterCtrlClass
  664. //
  665. //*******************************************************************************************//
  666. //////////////////////////////////////////////////////////////////////
  667. //
  668. // Create
  669. //
  670. //////////////////////////////////////////////////////////////////////
  671. int
  672. AngleParameterCtrlClass::Create
  673. (
  674. HWND parent_wnd,
  675. int id_start,
  676. LPRECT pos
  677. )
  678. {
  679. CString param_name = m_Parameter->Get_Name ();
  680. CString units_name = m_Parameter->Get_Units_Name ();
  681. //
  682. // Create the static text controls
  683. //
  684. CRect edit_rect;
  685. Create_Static_Text_Controls ( parent_wnd,
  686. *pos,
  687. &m_StaticText1,
  688. param_name,
  689. &m_StaticText2,
  690. units_name,
  691. &edit_rect);
  692. //
  693. // Create the float controls
  694. //
  695. ::Create_Float_Ctrls ( CWnd::FromHandle (parent_wnd),
  696. m_EditCtrl,
  697. m_SpinCtrl,
  698. edit_rect,
  699. id_start++,
  700. id_start ++);
  701. //
  702. // Set the initial value of the control
  703. //
  704. ::SetWindowFloat (m_EditCtrl, RAD_TO_DEG (m_Parameter->Get_Value ()));
  705. //
  706. // Set the ranges on the spinner
  707. //
  708. float min_ang = RAD_TO_DEG (m_Parameter->Get_Min ());
  709. float max_ang = RAD_TO_DEG (m_Parameter->Get_Max ());
  710. m_SpinCtrl.SetRange32 (min_ang * 100, max_ang * 100);
  711. //
  712. // Make the controls read-only if necessary
  713. //
  714. if (m_IsReadOnly) {
  715. m_EditCtrl.EnableWindow (false);
  716. m_SpinCtrl.EnableWindow (false);
  717. }
  718. pos->bottom = edit_rect.bottom;
  719. return id_start;
  720. }
  721. //////////////////////////////////////////////////////////////////////
  722. //
  723. // Resize
  724. //
  725. //////////////////////////////////////////////////////////////////////
  726. void
  727. AngleParameterCtrlClass::Resize (const CRect &rect)
  728. {
  729. Resize_Controls (rect, m_StaticText1, m_EditCtrl, m_StaticText2);
  730. m_SpinCtrl.SetBuddy (&m_EditCtrl);
  731. return ;
  732. }
  733. //////////////////////////////////////////////////////////////////////
  734. //
  735. // Read_Data
  736. //
  737. //////////////////////////////////////////////////////////////////////
  738. void
  739. AngleParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  740. {
  741. m_Parameter->Set_Value (DEG_TO_RAD (::GetWindowFloat (m_EditCtrl, true)));
  742. return ;
  743. }
  744. //*******************************************************************************************//
  745. //
  746. // Start of BoolParameterCtrlClass
  747. //
  748. //*******************************************************************************************//
  749. //////////////////////////////////////////////////////////////////////
  750. //
  751. // Create
  752. //
  753. //////////////////////////////////////////////////////////////////////
  754. int
  755. BoolParameterCtrlClass::Create
  756. (
  757. HWND parent_wnd,
  758. int id_start,
  759. LPRECT pos
  760. )
  761. {
  762. CString param_name = m_Parameter->Get_Name ();
  763. //
  764. // Determine the checkbox's dimensions
  765. //
  766. CRect check_rect = *pos;
  767. check_rect.bottom = check_rect.top + ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  768. //
  769. // Create the edit control
  770. //
  771. m_CheckBoxCtrl.Create ( param_name,
  772. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_AUTOCHECKBOX,
  773. check_rect,
  774. CWnd::FromHandle (parent_wnd),
  775. id_start ++);
  776. m_CheckBoxCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  777. m_CheckBoxCtrl.SetCheck (m_Parameter->Get_Value ());
  778. if (m_IsReadOnly) {
  779. m_CheckBoxCtrl.EnableWindow (false);
  780. }
  781. pos->bottom = check_rect.bottom;
  782. return id_start;
  783. }
  784. //////////////////////////////////////////////////////////////////////
  785. //
  786. // Resize
  787. //
  788. //////////////////////////////////////////////////////////////////////
  789. void
  790. BoolParameterCtrlClass::Resize (const CRect &rect)
  791. {
  792. CRect old_rect;
  793. m_CheckBoxCtrl.GetWindowRect (&old_rect);
  794. //int new_width = rect.Width () - (old_rect.Width () + SPACE_WIDTH);
  795. m_CheckBoxCtrl.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect.Height (), SWP_NOZORDER | SWP_NOMOVE);
  796. return ;
  797. }
  798. //////////////////////////////////////////////////////////////////////
  799. //
  800. // Read_Data
  801. //
  802. //////////////////////////////////////////////////////////////////////
  803. void
  804. BoolParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  805. {
  806. m_Parameter->Set_Value (bool(m_CheckBoxCtrl.GetCheck () == 1));
  807. return ;
  808. }
  809. //*******************************************************************************************//
  810. //
  811. // Start of Vector3ParameterCtrlClass
  812. //
  813. //*******************************************************************************************//
  814. //////////////////////////////////////////////////////////////////////
  815. //
  816. // Create
  817. //
  818. //////////////////////////////////////////////////////////////////////
  819. int
  820. Vector3ParameterCtrlClass::Create
  821. (
  822. HWND parent_wnd,
  823. int id_start,
  824. LPRECT pos
  825. )
  826. {
  827. int text_height = ::Get_Ctrl_Height (parent_wnd, TEXT_HEIGHT);
  828. int edit_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  829. CRect group_rect = *pos;
  830. group_rect.bottom += edit_height + text_height + SPACE_WIDTH + SPACE_WIDTH;
  831. //
  832. // Create the static text control
  833. //
  834. m_GroupBox.Create ( m_Parameter->Get_Name (),
  835. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_GROUPBOX,
  836. group_rect,
  837. CWnd::FromHandle (parent_wnd),
  838. id_start ++);
  839. m_GroupBox.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  840. //
  841. // Create the labels, don't worry about their position, they will be moved later.
  842. //
  843. m_TextCtrls[0].Create ("X:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  844. m_TextCtrls[1].Create ("Y:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  845. m_TextCtrls[2].Create ("Z:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  846. m_TextCtrls[0].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  847. m_TextCtrls[1].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  848. m_TextCtrls[2].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  849. //
  850. // Create the float controls
  851. //
  852. int y_pos = group_rect.top + SPACE_WIDTH + (group_rect.Height () >> 1) - (edit_height >> 1);
  853. for (int index = 0; index < 3; index ++) {
  854. ::Create_Float_Ctrls ( CWnd::FromHandle (parent_wnd),
  855. m_EditCtrls[index],
  856. m_SpinCtrls[index],
  857. CRect (0, y_pos, 10, y_pos + edit_height),
  858. id_start++,
  859. id_start ++);
  860. }
  861. Vector3 value = m_Parameter->Get_Value ();
  862. ::SetWindowFloat (m_EditCtrls[0], value.X);
  863. ::SetWindowFloat (m_EditCtrls[1], value.Y);
  864. ::SetWindowFloat (m_EditCtrls[2], value.Z);
  865. CRect parent_rect;
  866. ::GetClientRect (parent_wnd, &parent_rect);
  867. Resize (parent_rect);
  868. if (m_IsReadOnly) {
  869. m_EditCtrls[0].EnableWindow (false);
  870. m_EditCtrls[1].EnableWindow (false);
  871. m_EditCtrls[2].EnableWindow (false);
  872. m_SpinCtrls[0].EnableWindow (false);
  873. m_SpinCtrls[1].EnableWindow (false);
  874. m_SpinCtrls[2].EnableWindow (false);
  875. }
  876. pos->bottom = group_rect.bottom;
  877. return id_start;
  878. }
  879. //////////////////////////////////////////////////////////////////////
  880. //
  881. // Resize
  882. //
  883. //////////////////////////////////////////////////////////////////////
  884. void
  885. Vector3ParameterCtrlClass::Resize (const CRect &rect)
  886. {
  887. //
  888. // Resize the group box
  889. //
  890. CRect group_rect;
  891. m_GroupBox.GetClientRect (&group_rect);
  892. group_rect.left = 0;
  893. group_rect.right = rect.Width ();
  894. m_GroupBox.SetWindowPos (NULL, 0, 0, group_rect.Width (), group_rect.Height (), SWP_NOZORDER | SWP_NOMOVE);
  895. //
  896. // Determine the dimensions of the labels
  897. //
  898. HWND parent_wnd = ::GetParent (m_GroupBox);
  899. CSize text_size;
  900. Get_String_Size (parent_wnd, "XX: ", &text_size);
  901. //
  902. // Resize the edit controls
  903. //
  904. CRect edit_rect;
  905. m_EditCtrls[0].GetWindowRect (&edit_rect);
  906. ::ScreenToClient (parent_wnd, (LPPOINT)&edit_rect);
  907. ::ScreenToClient (parent_wnd, ((LPPOINT)&edit_rect)+1);
  908. int width = (group_rect.Width () - (BORDER_WIDTH * 2) - (text_size.cx * 3)) / 3;
  909. edit_rect.left = group_rect.left + BORDER_WIDTH;
  910. edit_rect.right = edit_rect.left + text_size.cx + width;
  911. for (int index = 0; index < 3; index ++) {
  912. int y = edit_rect.top + (edit_rect.Height () >> 1) - (text_size.cy >> 1);
  913. m_TextCtrls[index].SetWindowPos (NULL, edit_rect.left, y, text_size.cx, text_size.cy, SWP_NOZORDER);
  914. edit_rect.left += text_size.cx;
  915. m_EditCtrls[index].SetWindowPos (NULL, edit_rect.left, edit_rect.top, edit_rect.Width (), edit_rect.Height (), SWP_NOZORDER);
  916. m_SpinCtrls[index].SetBuddy (&m_EditCtrls[index]);
  917. edit_rect.left += width;
  918. edit_rect.right += (text_size.cx + width);
  919. }
  920. return ;
  921. }
  922. //////////////////////////////////////////////////////////////////////
  923. //
  924. // Read_Data
  925. //
  926. //////////////////////////////////////////////////////////////////////
  927. void
  928. Vector3ParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  929. {
  930. Vector3 value;
  931. value.X = ::GetWindowFloat (m_EditCtrls[0], true);
  932. value.Y = ::GetWindowFloat (m_EditCtrls[1], true);
  933. value.Z = ::GetWindowFloat (m_EditCtrls[2], true);
  934. m_Parameter->Set_Value (value);
  935. return ;
  936. }
  937. //*******************************************************************************************//
  938. //
  939. // Start of Vector2ParameterCtrlClass
  940. //
  941. //*******************************************************************************************//
  942. //////////////////////////////////////////////////////////////////////
  943. //
  944. // Create
  945. //
  946. //////////////////////////////////////////////////////////////////////
  947. int
  948. Vector2ParameterCtrlClass::Create
  949. (
  950. HWND parent_wnd,
  951. int id_start,
  952. LPRECT pos
  953. )
  954. {
  955. int text_height = ::Get_Ctrl_Height (parent_wnd, TEXT_HEIGHT);
  956. int edit_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  957. CRect group_rect = *pos;
  958. group_rect.bottom += edit_height + text_height + SPACE_WIDTH + SPACE_WIDTH;
  959. //
  960. // Create the static text control
  961. //
  962. m_GroupBox.Create ( m_Parameter->Get_Name (),
  963. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_GROUPBOX,
  964. group_rect,
  965. CWnd::FromHandle (parent_wnd),
  966. id_start ++);
  967. m_GroupBox.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  968. //
  969. // Create the labels, don't worry about their position, they will be moved later.
  970. //
  971. m_TextCtrls[0].Create ("X:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  972. m_TextCtrls[1].Create ("Y:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  973. m_TextCtrls[0].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  974. m_TextCtrls[1].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  975. //
  976. // Create the float controls
  977. //
  978. int y_pos = group_rect.top + SPACE_WIDTH + (group_rect.Height () >> 1) - (edit_height >> 1);
  979. for (int index = 0; index < 2; index ++) {
  980. ::Create_Float_Ctrls ( CWnd::FromHandle (parent_wnd),
  981. m_EditCtrls[index],
  982. m_SpinCtrls[index],
  983. CRect (0, y_pos, 10, y_pos + edit_height),
  984. id_start++,
  985. id_start ++);
  986. }
  987. Vector2 value = m_Parameter->Get_Value ();
  988. ::SetWindowFloat (m_EditCtrls[0], value.X);
  989. ::SetWindowFloat (m_EditCtrls[1], value.Y);
  990. CRect parent_rect;
  991. ::GetClientRect (parent_wnd, &parent_rect);
  992. Resize (parent_rect);
  993. if (m_IsReadOnly) {
  994. m_EditCtrls[0].EnableWindow (false);
  995. m_EditCtrls[1].EnableWindow (false);
  996. m_SpinCtrls[0].EnableWindow (false);
  997. m_SpinCtrls[1].EnableWindow (false);
  998. }
  999. pos->bottom = group_rect.bottom;
  1000. return id_start;
  1001. }
  1002. //////////////////////////////////////////////////////////////////////
  1003. //
  1004. // Resize
  1005. //
  1006. //////////////////////////////////////////////////////////////////////
  1007. void
  1008. Vector2ParameterCtrlClass::Resize (const CRect &rect)
  1009. {
  1010. //
  1011. // Resize the group box
  1012. //
  1013. CRect group_rect;
  1014. m_GroupBox.GetClientRect (&group_rect);
  1015. group_rect.left = 0;
  1016. group_rect.right = rect.Width ();
  1017. m_GroupBox.SetWindowPos (NULL, 0, 0, group_rect.Width (), group_rect.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1018. //
  1019. // Determine the dimensions of the labels
  1020. //
  1021. HWND parent_wnd = ::GetParent (m_GroupBox);
  1022. CSize text_size;
  1023. Get_String_Size (parent_wnd, "XX: ", &text_size);
  1024. //
  1025. // Resize the edit controls
  1026. //
  1027. CRect edit_rect;
  1028. m_EditCtrls[0].GetWindowRect (&edit_rect);
  1029. ::ScreenToClient (parent_wnd, (LPPOINT)&edit_rect);
  1030. ::ScreenToClient (parent_wnd, ((LPPOINT)&edit_rect)+1);
  1031. int width = (group_rect.Width () - (BORDER_WIDTH * 3) - (text_size.cx * 2)) / 2;
  1032. edit_rect.left = group_rect.left + BORDER_WIDTH;
  1033. edit_rect.right = edit_rect.left + text_size.cx + width;
  1034. for (int index = 0; index < 2; index ++) {
  1035. int y = edit_rect.top + (edit_rect.Height () >> 1) - (text_size.cy >> 1);
  1036. m_TextCtrls[index].SetWindowPos (NULL, edit_rect.left, y, text_size.cx, text_size.cy, SWP_NOZORDER);
  1037. edit_rect.left += text_size.cx;
  1038. m_EditCtrls[index].SetWindowPos (NULL, edit_rect.left, edit_rect.top, edit_rect.Width (), edit_rect.Height (), SWP_NOZORDER);
  1039. m_SpinCtrls[index].SetBuddy (&m_EditCtrls[index]);
  1040. edit_rect.left += width;
  1041. edit_rect.right += (text_size.cx + width);
  1042. }
  1043. return ;
  1044. }
  1045. //////////////////////////////////////////////////////////////////////
  1046. //
  1047. // Read_Data
  1048. //
  1049. //////////////////////////////////////////////////////////////////////
  1050. void
  1051. Vector2ParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1052. {
  1053. Vector2 value;
  1054. value.X = ::GetWindowFloat (m_EditCtrls[0], true);
  1055. value.Y = ::GetWindowFloat (m_EditCtrls[1], true);
  1056. m_Parameter->Set_Value (value);
  1057. return ;
  1058. }
  1059. //*******************************************************************************************//
  1060. //
  1061. // Start of RectParameterCtrlClass
  1062. //
  1063. //*******************************************************************************************//
  1064. //////////////////////////////////////////////////////////////////////
  1065. //
  1066. // Create
  1067. //
  1068. //////////////////////////////////////////////////////////////////////
  1069. int
  1070. RectParameterCtrlClass::Create
  1071. (
  1072. HWND parent_wnd,
  1073. int id_start,
  1074. LPRECT pos
  1075. )
  1076. {
  1077. int text_height = ::Get_Ctrl_Height (parent_wnd, TEXT_HEIGHT);
  1078. int edit_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  1079. CRect group_rect = *pos;
  1080. group_rect.bottom += edit_height + text_height + SPACE_WIDTH + SPACE_WIDTH;
  1081. //
  1082. // Create the static text control
  1083. //
  1084. m_GroupBox.Create ( m_Parameter->Get_Name (),
  1085. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_GROUPBOX,
  1086. group_rect,
  1087. CWnd::FromHandle (parent_wnd),
  1088. id_start ++);
  1089. m_GroupBox.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1090. //
  1091. // Create the labels, don't worry about their position, they will be moved later.
  1092. //
  1093. m_TextCtrls[0].Create ("X1:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  1094. m_TextCtrls[1].Create ("Y1:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  1095. m_TextCtrls[2].Create ("X2:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  1096. m_TextCtrls[3].Create ("Y2:", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect (0, 0, 10, 10), CWnd::FromHandle (parent_wnd));
  1097. m_TextCtrls[0].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1098. m_TextCtrls[1].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1099. m_TextCtrls[2].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1100. m_TextCtrls[3].SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1101. //
  1102. // Create the float controls
  1103. //
  1104. int y_pos = group_rect.top + SPACE_WIDTH + (group_rect.Height () >> 1) - (edit_height >> 1);
  1105. for (int index = 0; index < 4; index ++) {
  1106. ::Create_Float_Ctrls ( CWnd::FromHandle (parent_wnd),
  1107. m_EditCtrls[index],
  1108. m_SpinCtrls[index],
  1109. CRect (0, y_pos, 10, y_pos + edit_height),
  1110. id_start++,
  1111. id_start ++);
  1112. }
  1113. RectClass value = m_Parameter->Get_Value ();
  1114. ::SetWindowFloat (m_EditCtrls[0], value.Left);
  1115. ::SetWindowFloat (m_EditCtrls[1], value.Top);
  1116. ::SetWindowFloat (m_EditCtrls[2], value.Right);
  1117. ::SetWindowFloat (m_EditCtrls[3], value.Bottom);
  1118. CRect parent_rect;
  1119. ::GetClientRect (parent_wnd, &parent_rect);
  1120. Resize (parent_rect);
  1121. if (m_IsReadOnly) {
  1122. m_EditCtrls[0].EnableWindow (false);
  1123. m_EditCtrls[1].EnableWindow (false);
  1124. m_EditCtrls[2].EnableWindow (false);
  1125. m_EditCtrls[3].EnableWindow (false);
  1126. m_SpinCtrls[0].EnableWindow (false);
  1127. m_SpinCtrls[1].EnableWindow (false);
  1128. m_SpinCtrls[2].EnableWindow (false);
  1129. m_SpinCtrls[3].EnableWindow (false);
  1130. }
  1131. pos->bottom = group_rect.bottom;
  1132. return id_start;
  1133. }
  1134. //////////////////////////////////////////////////////////////////////
  1135. //
  1136. // Resize
  1137. //
  1138. //////////////////////////////////////////////////////////////////////
  1139. void
  1140. RectParameterCtrlClass::Resize (const CRect &rect)
  1141. {
  1142. //
  1143. // Resize the group box
  1144. //
  1145. CRect group_rect;
  1146. m_GroupBox.GetClientRect (&group_rect);
  1147. group_rect.left = 0;
  1148. group_rect.right = rect.Width ();
  1149. m_GroupBox.SetWindowPos (NULL, 0, 0, group_rect.Width (), group_rect.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1150. //
  1151. // Determine the dimensions of the labels
  1152. //
  1153. HWND parent_wnd = ::GetParent (m_GroupBox);
  1154. CSize text_size;
  1155. Get_String_Size (parent_wnd, "XX: ", &text_size);
  1156. //
  1157. // Resize the edit controls
  1158. //
  1159. CRect edit_rect;
  1160. m_EditCtrls[0].GetWindowRect (&edit_rect);
  1161. ::ScreenToClient (parent_wnd, (LPPOINT)&edit_rect);
  1162. ::ScreenToClient (parent_wnd, ((LPPOINT)&edit_rect)+1);
  1163. int width = (group_rect.Width () - (BORDER_WIDTH * 5) - (text_size.cx * 4)) / 4;
  1164. edit_rect.left = group_rect.left + BORDER_WIDTH;
  1165. edit_rect.right = edit_rect.left + text_size.cx + width;
  1166. for (int index = 0; index < 4; index ++) {
  1167. int y = edit_rect.top + (edit_rect.Height () >> 1) - (text_size.cy >> 1);
  1168. m_TextCtrls[index].SetWindowPos (NULL, edit_rect.left, y, text_size.cx, text_size.cy, SWP_NOZORDER);
  1169. edit_rect.left += text_size.cx;
  1170. m_EditCtrls[index].SetWindowPos (NULL, edit_rect.left, edit_rect.top, edit_rect.Width (), edit_rect.Height (), SWP_NOZORDER);
  1171. m_SpinCtrls[index].SetBuddy (&m_EditCtrls[index]);
  1172. edit_rect.left += width + BORDER_WIDTH;
  1173. edit_rect.right += (text_size.cx + width) + BORDER_WIDTH;
  1174. }
  1175. return ;
  1176. }
  1177. //////////////////////////////////////////////////////////////////////
  1178. //
  1179. // Read_Data
  1180. //
  1181. //////////////////////////////////////////////////////////////////////
  1182. void
  1183. RectParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1184. {
  1185. RectClass value;
  1186. value.Left = ::GetWindowFloat (m_EditCtrls[0], true);
  1187. value.Top = ::GetWindowFloat (m_EditCtrls[1], true);
  1188. value.Right = ::GetWindowFloat (m_EditCtrls[2], true);
  1189. value.Bottom = ::GetWindowFloat (m_EditCtrls[3], true);
  1190. m_Parameter->Set_Value (value);
  1191. return ;
  1192. }
  1193. //////////////////////////////////////////////////////////////////////
  1194. //
  1195. // Create_Float_Ctrls
  1196. //
  1197. //////////////////////////////////////////////////////////////////////
  1198. void
  1199. Create_Float_Ctrls
  1200. (
  1201. CWnd * parent_wnd,
  1202. CEdit & edit_ctrl,
  1203. CSpinButtonCtrl & spin_ctrl,
  1204. const CRect & rect,
  1205. int id1,
  1206. int id2
  1207. )
  1208. {
  1209. //
  1210. // Create the edit control
  1211. //
  1212. edit_ctrl.Create (WS_CHILD | WS_TABSTOP | WS_VISIBLE, rect, parent_wnd, id1);
  1213. edit_ctrl.SendMessage (WM_SETFONT, ::SendMessage (*parent_wnd, WM_GETFONT, 0, 0L));
  1214. edit_ctrl.ModifyStyleEx (0, WS_EX_CLIENTEDGE, 0);
  1215. ::Make_Edit_Float_Ctrl (edit_ctrl);
  1216. //
  1217. // Create the spin control
  1218. //
  1219. spin_ctrl.Create ( UDS_ARROWKEYS | UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS | UDS_ALIGNRIGHT | WS_CHILD | WS_VISIBLE,
  1220. CRect (0, 0, 50, 20),
  1221. parent_wnd,
  1222. id2);
  1223. spin_ctrl.SendMessage (WM_SETFONT, ::SendMessage (*parent_wnd, WM_GETFONT, 0, 0L));
  1224. //
  1225. // Set the float control ranges
  1226. //
  1227. spin_ctrl.SetRange32 (-1000000, 1000000);
  1228. return ;
  1229. }
  1230. //*******************************************************************************************//
  1231. //
  1232. // Start of EnumParameterCtrlClass
  1233. //
  1234. //*******************************************************************************************//
  1235. //////////////////////////////////////////////////////////////////////
  1236. //
  1237. // Create
  1238. //
  1239. //////////////////////////////////////////////////////////////////////
  1240. int
  1241. EnumParameterCtrlClass::Create
  1242. (
  1243. HWND parent_wnd,
  1244. int id_start,
  1245. LPRECT pos
  1246. )
  1247. {
  1248. CString param_name = m_Parameter->Get_Name ();
  1249. //
  1250. // Determine the dimensions of the title
  1251. //
  1252. CSize text_size;
  1253. Get_String_Size (parent_wnd, param_name, &text_size);
  1254. int combo_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  1255. CRect text_rect = *pos;
  1256. text_rect.right = text_rect.left + text_size.cx + 2;
  1257. text_rect.top += ((combo_height >> 1) - (text_size.cy >> 1));
  1258. text_rect.bottom = text_rect.top + text_size.cy;
  1259. //
  1260. // Create the static text control
  1261. //
  1262. m_StaticText.Create (param_name,
  1263. WS_CHILD | WS_VISIBLE | SS_LEFT,
  1264. text_rect,
  1265. CWnd::FromHandle (parent_wnd));
  1266. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1267. //
  1268. // Determine the edit control's dimensions
  1269. //
  1270. CRect combo_rect = *pos;
  1271. combo_rect.left = text_rect.right + SPACE_WIDTH;
  1272. combo_rect.bottom = combo_rect.top + (combo_height * 10);
  1273. //
  1274. // Create the edit control
  1275. //
  1276. m_ComboBox.Create ( WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST,
  1277. combo_rect,
  1278. CWnd::FromHandle (parent_wnd),
  1279. id_start ++);
  1280. m_ComboBox.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1281. //m_ComboBox.ModifyStyleEx (0, WS_EX_CLIENTEDGE, 0);
  1282. //
  1283. // Fill in the list of enumerated values
  1284. //
  1285. int count = m_Parameter->Get_Count ();
  1286. for (int index = 0; index < count; index ++) {
  1287. LPCTSTR name = m_Parameter->Get_Entry_Name (index);
  1288. int value = m_Parameter->Get_Entry_Value (index);
  1289. int combo_index = m_ComboBox.AddString (name);
  1290. m_ComboBox.SetItemData (combo_index, value);
  1291. if (value == m_Parameter->Get_Selected_Value ()) {
  1292. m_ComboBox.SetCurSel (combo_index);
  1293. }
  1294. }
  1295. if (m_IsReadOnly) {
  1296. m_ComboBox.EnableWindow (false);
  1297. }
  1298. pos->bottom = combo_rect.top + combo_height;
  1299. return id_start;
  1300. }
  1301. //////////////////////////////////////////////////////////////////////
  1302. //
  1303. // Resize
  1304. //
  1305. //////////////////////////////////////////////////////////////////////
  1306. void
  1307. EnumParameterCtrlClass::Resize (const CRect &rect)
  1308. {
  1309. CRect old_rect1;
  1310. CRect old_rect2;
  1311. m_StaticText.GetWindowRect (&old_rect1);
  1312. m_ComboBox.GetWindowRect (&old_rect2);
  1313. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  1314. m_ComboBox.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1315. return ;
  1316. }
  1317. //////////////////////////////////////////////////////////////////////
  1318. //
  1319. // Read_Data
  1320. //
  1321. //////////////////////////////////////////////////////////////////////
  1322. void
  1323. EnumParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1324. {
  1325. int cur_sel = m_ComboBox.GetCurSel ();
  1326. if (cur_sel >= 0) {
  1327. int value = m_ComboBox.GetItemData (cur_sel);
  1328. m_Parameter->Set_Selected_Value (value);
  1329. }
  1330. return ;
  1331. }
  1332. //*******************************************************************************************//
  1333. //
  1334. // Start of ColorParameterCtrlClass
  1335. //
  1336. //*******************************************************************************************//
  1337. //////////////////////////////////////////////////////////////////////
  1338. //
  1339. // Create
  1340. //
  1341. //////////////////////////////////////////////////////////////////////
  1342. int
  1343. ColorParameterCtrlClass::Create
  1344. (
  1345. HWND parent_wnd,
  1346. int id_start,
  1347. LPRECT pos
  1348. )
  1349. {
  1350. CString param_name = m_Parameter->Get_Name ();
  1351. //
  1352. // Determine the dimensions of the title
  1353. //
  1354. CSize text_size;
  1355. Get_String_Size (parent_wnd, param_name, &text_size);
  1356. int button_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  1357. CRect text_rect = *pos;
  1358. text_rect.right = text_rect.left + text_size.cx + 2;
  1359. text_rect.top += ((button_height >> 1) - (text_size.cy >> 1));
  1360. text_rect.bottom = text_rect.top + text_size.cy;
  1361. //
  1362. // Create the static text control
  1363. //
  1364. m_StaticText.Create (param_name,
  1365. WS_CHILD | WS_VISIBLE | SS_LEFT,
  1366. text_rect,
  1367. CWnd::FromHandle (parent_wnd));
  1368. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1369. //
  1370. // Determine the control's dimensions
  1371. //
  1372. CRect button_rect = *pos;
  1373. button_rect.left = text_rect.right + SPACE_WIDTH;
  1374. button_rect.bottom = button_rect.top + button_height;
  1375. //
  1376. // Create the edit control
  1377. //
  1378. m_ButtonID = id_start ++;
  1379. m_Button.Create ( "",
  1380. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON | BS_OWNERDRAW,
  1381. button_rect,
  1382. CWnd::FromHandle (parent_wnd),
  1383. m_ButtonID);
  1384. m_Button.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1385. if (m_IsReadOnly) {
  1386. m_Button.EnableWindow (false);
  1387. }
  1388. pos->bottom = button_rect.bottom;
  1389. return id_start;
  1390. }
  1391. //////////////////////////////////////////////////////////////////////
  1392. //
  1393. // Resize
  1394. //
  1395. //////////////////////////////////////////////////////////////////////
  1396. void
  1397. ColorParameterCtrlClass::Resize (const CRect &rect)
  1398. {
  1399. CRect old_rect1;
  1400. CRect old_rect2;
  1401. m_StaticText.GetWindowRect (&old_rect1);
  1402. m_Button.GetWindowRect (&old_rect2);
  1403. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  1404. m_Button.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1405. return ;
  1406. }
  1407. //////////////////////////////////////////////////////////////////////
  1408. //
  1409. // Read_Data
  1410. //
  1411. //////////////////////////////////////////////////////////////////////
  1412. void
  1413. ColorParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1414. {
  1415. return ;
  1416. }
  1417. //////////////////////////////////////////////////////////////////////
  1418. //
  1419. // On_Command
  1420. //
  1421. //////////////////////////////////////////////////////////////////////
  1422. bool
  1423. ColorParameterCtrlClass::On_Command
  1424. (
  1425. HWND parent_wnd,
  1426. WPARAM wparam,
  1427. LPARAM lparam
  1428. )
  1429. {
  1430. bool retval = false;
  1431. if ( LOWORD (wparam) == m_ButtonID &&
  1432. HIWORD (wparam) == BN_CLICKED )
  1433. {
  1434. //
  1435. // Get the current color fron the control
  1436. //
  1437. Vector3 color = m_Parameter->Get_Value ();
  1438. int red = color.X * 255;
  1439. int green = color.Y * 255;
  1440. int blue = color.Z * 255;
  1441. //
  1442. // Show the color picker to the user
  1443. //
  1444. if (::Show_Color_Picker (&red, &green, &blue)) {
  1445. //
  1446. // Store the new color
  1447. //
  1448. color.X = ((float)red) / 255.0F;
  1449. color.Y = ((float)green) / 255.0F;
  1450. color.Z = ((float)blue) / 255.0F;
  1451. m_Parameter->Set_Value (color);
  1452. ::InvalidateRect (::GetDlgItem (parent_wnd, m_ButtonID), NULL, TRUE);
  1453. ::UpdateWindow (::GetDlgItem (parent_wnd, m_ButtonID));
  1454. }
  1455. retval = true;
  1456. }
  1457. return retval;
  1458. }
  1459. //////////////////////////////////////////////////////////////////////
  1460. //
  1461. // On_DrawItem
  1462. //
  1463. //////////////////////////////////////////////////////////////////////
  1464. bool
  1465. ColorParameterCtrlClass::On_DrawItem
  1466. (
  1467. HWND parent_wnd,
  1468. WPARAM wparam,
  1469. LPARAM lparam
  1470. )
  1471. {
  1472. bool retval = false;
  1473. //
  1474. // Is this the right control?
  1475. //
  1476. if ((int)wparam == m_ButtonID) {
  1477. LPDRAWITEMSTRUCT drawitem_info = (LPDRAWITEMSTRUCT)lparam;
  1478. // Determine what color to paint the button
  1479. Vector3 color = m_Parameter->Get_Value ();
  1480. // Determine what state to draw the button in (pushed or normal)
  1481. UINT state = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT;
  1482. if (drawitem_info->itemState & ODS_SELECTED) {
  1483. state |= DFCS_PUSHED;
  1484. }
  1485. // Draw the button's outline
  1486. CRect rect = drawitem_info->rcItem;
  1487. ::DrawFrameControl (drawitem_info->hDC, rect, DFC_BUTTON, state);
  1488. // Fill the button with the appropriate color
  1489. CDC temp_dc;
  1490. temp_dc.Attach (drawitem_info->hDC);
  1491. temp_dc.FillSolidRect (&rect, RGB (int(color.X * 255), int(color.Y * 255), int(color.Z * 255)));
  1492. temp_dc.Detach ();
  1493. // Draw the focus rectangle if necessary
  1494. if (drawitem_info->itemState & ODS_FOCUS) {
  1495. ::DrawFocusRect (drawitem_info->hDC, &rect);
  1496. }
  1497. retval = true;
  1498. }
  1499. return retval;
  1500. }
  1501. //*******************************************************************************************//
  1502. //
  1503. // Start of PhysDefParameterCtrlClass
  1504. //
  1505. //*******************************************************************************************//
  1506. //////////////////////////////////////////////////////////////////////
  1507. //
  1508. // Create
  1509. //
  1510. //////////////////////////////////////////////////////////////////////
  1511. int
  1512. PhysDefParameterCtrlClass::Create
  1513. (
  1514. HWND parent_wnd,
  1515. int id_start,
  1516. LPRECT pos
  1517. )
  1518. {
  1519. CString param_name = m_Parameter->Get_Name ();
  1520. //
  1521. // Determine the dimensions of the title
  1522. //
  1523. CSize text_size;
  1524. Get_String_Size (parent_wnd, param_name, &text_size);
  1525. int button_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  1526. CRect text_rect = *pos;
  1527. text_rect.right = text_rect.left + text_size.cx + 2;
  1528. text_rect.top += ((button_height >> 1) - (text_size.cy >> 1));
  1529. text_rect.bottom = text_rect.top + text_size.cy;
  1530. //
  1531. // Create the static text control
  1532. //
  1533. m_StaticText.Create (param_name,
  1534. WS_CHILD | WS_VISIBLE | SS_LEFT,
  1535. text_rect,
  1536. CWnd::FromHandle (parent_wnd));
  1537. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1538. //
  1539. // Determine the control's dimensions
  1540. //
  1541. CRect button_rect = *pos;
  1542. button_rect.left = text_rect.right + SPACE_WIDTH;
  1543. button_rect.bottom = button_rect.top + button_height;
  1544. //
  1545. // Create the edit control
  1546. //
  1547. m_ButtonID = id_start ++;
  1548. m_Button.Create ( "Edit Phyiscs Object...",
  1549. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
  1550. button_rect,
  1551. CWnd::FromHandle (parent_wnd),
  1552. m_ButtonID);
  1553. m_Button.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1554. if (m_IsReadOnly) {
  1555. m_Button.EnableWindow (false);
  1556. }
  1557. pos->bottom = button_rect.bottom;
  1558. return id_start;
  1559. }
  1560. //////////////////////////////////////////////////////////////////////
  1561. //
  1562. // Resize
  1563. //
  1564. //////////////////////////////////////////////////////////////////////
  1565. void
  1566. PhysDefParameterCtrlClass::Resize (const CRect &rect)
  1567. {
  1568. CRect old_rect1;
  1569. CRect old_rect2;
  1570. m_StaticText.GetWindowRect (&old_rect1);
  1571. m_Button.GetWindowRect (&old_rect2);
  1572. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  1573. m_Button.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1574. return ;
  1575. }
  1576. //////////////////////////////////////////////////////////////////////
  1577. //
  1578. // Read_Data
  1579. //
  1580. //////////////////////////////////////////////////////////////////////
  1581. void
  1582. PhysDefParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1583. {
  1584. return ;
  1585. }
  1586. //////////////////////////////////////////////////////////////////////
  1587. //
  1588. // On_Command
  1589. //
  1590. //////////////////////////////////////////////////////////////////////
  1591. bool
  1592. PhysDefParameterCtrlClass::On_Command
  1593. (
  1594. HWND parent_wnd,
  1595. WPARAM wparam,
  1596. LPARAM lparam
  1597. )
  1598. {
  1599. bool retval = false;
  1600. if ( LOWORD (wparam) == m_ButtonID &&
  1601. HIWORD (wparam) == BN_CLICKED)
  1602. {
  1603. //
  1604. // Setup the dialog's parameters
  1605. //
  1606. PhysObjectEditDialogClass dialog (CWnd::FromHandle (parent_wnd));
  1607. dialog.Set_Definition_ID (m_Parameter->Get_Value ());
  1608. dialog.Set_Filter (m_Parameter->Get_Base_Class ());
  1609. dialog.Set_Is_Temp (m_IsTemp);
  1610. //
  1611. // Show the dialog
  1612. //
  1613. if (dialog.DoModal () == IDOK) {
  1614. m_Parameter->Set_Value (dialog.Get_Definition_ID ());
  1615. }
  1616. retval = true;
  1617. }
  1618. return retval;
  1619. }
  1620. //*******************************************************************************************//
  1621. //
  1622. // Start of DefParameterCtrlClass
  1623. //
  1624. //*******************************************************************************************//
  1625. //////////////////////////////////////////////////////////////////////
  1626. //
  1627. // Create
  1628. //
  1629. //////////////////////////////////////////////////////////////////////
  1630. int
  1631. DefParameterCtrlClass::Create
  1632. (
  1633. HWND parent_wnd,
  1634. int id_start,
  1635. LPRECT pos
  1636. )
  1637. {
  1638. CString param_name = Get_Parameter ()->Get_Name ();
  1639. //
  1640. // Determine the dimensions of the title
  1641. //
  1642. CSize text_size;
  1643. Get_String_Size (parent_wnd, param_name, &text_size);
  1644. int picker_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT) + 4;
  1645. CRect text_rect = *pos;
  1646. text_rect.right = text_rect.left + text_size.cx + 2;
  1647. text_rect.top += ((picker_height >> 1) - (text_size.cy >> 1));
  1648. text_rect.bottom = text_rect.top + text_size.cy;
  1649. //
  1650. // Create the static text control
  1651. //
  1652. m_StaticText.Create (param_name,
  1653. WS_CHILD | WS_VISIBLE | SS_LEFT,
  1654. text_rect,
  1655. CWnd::FromHandle (parent_wnd));
  1656. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1657. //
  1658. // Determine the edit control's dimensions
  1659. //
  1660. CRect picker_rect = *pos;
  1661. picker_rect.left = text_rect.right + SPACE_WIDTH;
  1662. picker_rect.bottom = picker_rect.top + picker_height;
  1663. //
  1664. // Create the preset picker control
  1665. //
  1666. m_PresetPicker.Create_Picker ( WS_CHILD | WS_TABSTOP | WS_VISIBLE,
  1667. picker_rect,
  1668. CWnd::FromHandle (parent_wnd),
  1669. id_start);
  1670. //
  1671. // Pass the current preset onto the control
  1672. //
  1673. PresetClass *preset = PresetMgrClass::Find_Preset (m_Parameter->Get_Value ());
  1674. m_PresetPicker.Set_Preset (preset);
  1675. m_PresetPicker.Set_Read_Only (true);
  1676. m_PresetPicker.Set_Class_ID (Get_Def_Class_ID ());
  1677. m_PresetPicker.Set_Icon_Index (Get_Def_Icon ());
  1678. //
  1679. // Make the controls read-only (if necessary)
  1680. //
  1681. if (m_IsReadOnly) {
  1682. m_PresetPicker.EnableWindow (false);
  1683. }
  1684. pos->bottom = picker_rect.top + picker_height;
  1685. return id_start;
  1686. }
  1687. //////////////////////////////////////////////////////////////////////
  1688. //
  1689. // Resize
  1690. //
  1691. //////////////////////////////////////////////////////////////////////
  1692. void
  1693. DefParameterCtrlClass::Resize (const CRect &rect)
  1694. {
  1695. CRect old_rect1;
  1696. CRect old_rect2;
  1697. m_StaticText.GetWindowRect (&old_rect1);
  1698. m_PresetPicker.GetWindowRect (&old_rect2);
  1699. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  1700. m_PresetPicker.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1701. return ;
  1702. }
  1703. //////////////////////////////////////////////////////////////////////
  1704. //
  1705. // On_Destroy
  1706. //
  1707. //////////////////////////////////////////////////////////////////////
  1708. void
  1709. DefParameterCtrlClass::On_Destroy (void)
  1710. {
  1711. return ;
  1712. }
  1713. //////////////////////////////////////////////////////////////////////
  1714. //
  1715. // Read_Data
  1716. //
  1717. //////////////////////////////////////////////////////////////////////
  1718. void
  1719. DefParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1720. {
  1721. PresetClass *preset = (PresetClass *)m_PresetPicker.Get_Preset ();
  1722. if (preset != NULL) {
  1723. m_Parameter->Set_Value (preset->Get_ID ());
  1724. } else {
  1725. m_Parameter->Set_Value (0);
  1726. }
  1727. return ;
  1728. }
  1729. //*******************************************************************************************//
  1730. //
  1731. // Start of ScriptParameterCtrlClass
  1732. //
  1733. //*******************************************************************************************//
  1734. //////////////////////////////////////////////////////////////////////
  1735. //
  1736. // Create
  1737. //
  1738. //////////////////////////////////////////////////////////////////////
  1739. int
  1740. ScriptParameterCtrlClass::Create
  1741. (
  1742. HWND parent_wnd,
  1743. int id_start,
  1744. LPRECT pos
  1745. )
  1746. {
  1747. CString param_name = m_Parameter->Get_Name ();
  1748. //
  1749. // Determine the dimensions of the title
  1750. //
  1751. CSize text_size;
  1752. Get_String_Size (parent_wnd, param_name, &text_size);
  1753. int button_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  1754. CRect text_rect = *pos;
  1755. text_rect.right = text_rect.left + text_size.cx + 32;
  1756. text_rect.top += ((button_height >> 1) - (text_size.cy >> 1));
  1757. text_rect.bottom = text_rect.top + text_size.cy;
  1758. //
  1759. // Create the static text control
  1760. //
  1761. m_CheckBoxCtrl.Create ( param_name,
  1762. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_AUTOCHECKBOX,
  1763. text_rect,
  1764. CWnd::FromHandle (parent_wnd),
  1765. id_start ++);
  1766. m_CheckBoxCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1767. //
  1768. // Determine the control's dimensions
  1769. //
  1770. CRect button_rect = *pos;
  1771. button_rect.left = text_rect.right + SPACE_WIDTH;
  1772. button_rect.bottom = button_rect.top + button_height;
  1773. //
  1774. // Create the edit control
  1775. //
  1776. m_ButtonID = id_start ++;
  1777. CString button_text;
  1778. button_text.Format ("Edit Script (%s)...", m_Parameter->Get_Script_Name ());
  1779. m_Button.Create ( button_text,
  1780. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
  1781. button_rect,
  1782. CWnd::FromHandle (parent_wnd),
  1783. m_ButtonID);
  1784. m_Button.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1785. pos->bottom = button_rect.bottom;
  1786. m_CheckBoxCtrl.SetCheck (::lstrlen (m_Parameter->Get_Script_Name ()) > 0);
  1787. m_Button.EnableWindow (m_CheckBoxCtrl.GetCheck ());
  1788. if (m_IsReadOnly) {
  1789. m_CheckBoxCtrl.EnableWindow (false);
  1790. m_Button.EnableWindow (false);
  1791. }
  1792. return id_start;
  1793. }
  1794. //////////////////////////////////////////////////////////////////////
  1795. //
  1796. // Resize
  1797. //
  1798. //////////////////////////////////////////////////////////////////////
  1799. void
  1800. ScriptParameterCtrlClass::Resize (const CRect &rect)
  1801. {
  1802. CRect old_rect1;
  1803. CRect old_rect2;
  1804. m_CheckBoxCtrl.GetWindowRect (&old_rect1);
  1805. m_Button.GetWindowRect (&old_rect2);
  1806. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  1807. m_Button.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1808. return ;
  1809. }
  1810. //////////////////////////////////////////////////////////////////////
  1811. //
  1812. // Read_Data
  1813. //
  1814. //////////////////////////////////////////////////////////////////////
  1815. void
  1816. ScriptParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1817. {
  1818. //
  1819. // Clear the data if necessary
  1820. //
  1821. if (m_CheckBoxCtrl.GetCheck () == false) {
  1822. m_Parameter->Set_Script_Name ("");
  1823. m_Parameter->Set_Params ("");
  1824. }
  1825. return ;
  1826. }
  1827. //////////////////////////////////////////////////////////////////////
  1828. //
  1829. // On_Command
  1830. //
  1831. //////////////////////////////////////////////////////////////////////
  1832. bool
  1833. ScriptParameterCtrlClass::On_Command
  1834. (
  1835. HWND parent_wnd,
  1836. WPARAM wparam,
  1837. LPARAM lparam
  1838. )
  1839. {
  1840. bool retval = false;
  1841. if ( LOWORD (wparam) == m_ButtonID &&
  1842. HIWORD (wparam) == BN_CLICKED)
  1843. {
  1844. //
  1845. // Setup the dialog's parameters
  1846. //
  1847. ScriptEditDialogClass dialog (CWnd::FromHandle (parent_wnd));
  1848. //
  1849. // Initialize the dialog with the current script settings
  1850. //
  1851. EditScriptClass *template_script = ScriptMgrClass::Find_Script (m_Parameter->Get_Script_Name ());
  1852. if (template_script != NULL) {
  1853. EditScriptClass temp_script = *template_script;
  1854. temp_script.Set_Composite_Values (m_Parameter->Get_Params ());
  1855. dialog.Set_Script (temp_script);
  1856. }
  1857. //
  1858. // Show the dialog
  1859. //
  1860. if (dialog.DoModal () == IDOK) {
  1861. //
  1862. // Record the settings
  1863. //
  1864. EditScriptClass &script = dialog.Get_Script ();
  1865. m_Parameter->Set_Script_Name (script.Get_Name ());
  1866. m_Parameter->Set_Params (script.Get_Composite_String ());
  1867. //
  1868. // Rename the button
  1869. //
  1870. CString button_text;
  1871. button_text.Format ("Edit Script (%s)...", script.Get_Name ());
  1872. m_Button.SetWindowText (button_text);
  1873. //
  1874. // Update the window
  1875. //
  1876. m_CheckBoxCtrl.SetCheck (::lstrlen (m_Parameter->Get_Script_Name ()) > 0);
  1877. }
  1878. retval = true;
  1879. } else if ( LOWORD (wparam) == ::GetWindowLong (m_CheckBoxCtrl, GWL_ID) &&
  1880. HIWORD (wparam) == BN_CLICKED)
  1881. {
  1882. m_Button.EnableWindow (m_CheckBoxCtrl.GetCheck ());
  1883. }
  1884. return retval;
  1885. }
  1886. //*******************************************************************************************//
  1887. //
  1888. // Start of DefIDListParameterCtrlClass
  1889. //
  1890. //*******************************************************************************************//
  1891. //////////////////////////////////////////////////////////////////////
  1892. //
  1893. // Create
  1894. //
  1895. //////////////////////////////////////////////////////////////////////
  1896. int
  1897. DefIDListParameterCtrlClass::Create
  1898. (
  1899. HWND parent_wnd,
  1900. int id_start,
  1901. LPRECT pos
  1902. )
  1903. {
  1904. CString param_name = m_Parameter->Get_Name ();
  1905. //
  1906. // Determine the dimensions of the title
  1907. //
  1908. CSize text_size;
  1909. Get_String_Size (parent_wnd, param_name, &text_size);
  1910. int button_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  1911. CRect text_rect = *pos;
  1912. text_rect.right = text_rect.left + text_size.cx + 32;
  1913. text_rect.top += ((button_height >> 1) - (text_size.cy >> 1));
  1914. text_rect.bottom = text_rect.top + text_size.cy;
  1915. //
  1916. // Create the static text control
  1917. //
  1918. m_StaticText.Create (param_name,
  1919. WS_CHILD | WS_VISIBLE | SS_LEFT,
  1920. text_rect,
  1921. CWnd::FromHandle (parent_wnd));
  1922. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1923. //
  1924. // Determine the control's dimensions
  1925. //
  1926. CRect button_rect = *pos;
  1927. button_rect.left = text_rect.right + SPACE_WIDTH;
  1928. button_rect.bottom = button_rect.top + button_height;
  1929. //
  1930. // Create the edit control
  1931. //
  1932. m_ButtonID = id_start ++;
  1933. m_Button.Create ( "Pick Presets...",
  1934. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
  1935. button_rect,
  1936. CWnd::FromHandle (parent_wnd),
  1937. m_ButtonID);
  1938. m_Button.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  1939. pos->bottom = button_rect.bottom;
  1940. if (m_IsReadOnly) {
  1941. m_StaticText.EnableWindow (false);
  1942. m_Button.EnableWindow (false);
  1943. }
  1944. return id_start;
  1945. }
  1946. //////////////////////////////////////////////////////////////////////
  1947. //
  1948. // Resize
  1949. //
  1950. //////////////////////////////////////////////////////////////////////
  1951. void
  1952. DefIDListParameterCtrlClass::Resize (const CRect &rect)
  1953. {
  1954. CRect old_rect1;
  1955. CRect old_rect2;
  1956. m_StaticText.GetWindowRect (&old_rect1);
  1957. m_Button.GetWindowRect (&old_rect2);
  1958. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  1959. m_Button.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  1960. return ;
  1961. }
  1962. //////////////////////////////////////////////////////////////////////
  1963. //
  1964. // Read_Data
  1965. //
  1966. //////////////////////////////////////////////////////////////////////
  1967. void
  1968. DefIDListParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  1969. {
  1970. return ;
  1971. }
  1972. //////////////////////////////////////////////////////////////////////
  1973. //
  1974. // On_Command
  1975. //
  1976. //////////////////////////////////////////////////////////////////////
  1977. bool
  1978. DefIDListParameterCtrlClass::On_Command
  1979. (
  1980. HWND parent_wnd,
  1981. WPARAM wparam,
  1982. LPARAM lparam
  1983. )
  1984. {
  1985. bool retval = false;
  1986. if ( LOWORD (wparam) == m_ButtonID &&
  1987. HIWORD (wparam) == BN_CLICKED)
  1988. {
  1989. //
  1990. // Setup the dialog's parameters
  1991. //
  1992. PresetListDialogClass dialog (CWnd::FromHandle (parent_wnd));
  1993. //
  1994. // What class-id should we let the user pick from?
  1995. //
  1996. uint32 root_class_id = m_Parameter->Get_Class_ID ();
  1997. uint32 selected_class_id = 0;
  1998. uint32 *class_id_ptr = m_Parameter->Get_Selected_Class_ID ();
  1999. if (class_id_ptr != NULL) {
  2000. selected_class_id = (*class_id_ptr);
  2001. }
  2002. //
  2003. // Configure the dialog
  2004. //
  2005. DynamicVectorClass<int> &list = m_Parameter->Get_List ();
  2006. dialog.Set_Preset_List (&list);
  2007. dialog.Set_Class_ID (root_class_id);
  2008. dialog.Set_Selected_Class_ID (selected_class_id);
  2009. dialog.Enable_Type_Selection (class_id_ptr != NULL);
  2010. //
  2011. // Display the dialog
  2012. //
  2013. if (dialog.DoModal () == IDOK) {
  2014. if (class_id_ptr != NULL) {
  2015. (*class_id_ptr) = dialog.Get_Selected_Class_ID ();
  2016. m_Parameter->Set_Modified ();
  2017. }
  2018. }
  2019. retval = true;
  2020. }
  2021. return retval;
  2022. }
  2023. //*******************************************************************************************//
  2024. //
  2025. // Start of ZoneParameterCtrlClass
  2026. //
  2027. //*******************************************************************************************//
  2028. //////////////////////////////////////////////////////////////////////
  2029. //
  2030. // Create
  2031. //
  2032. //////////////////////////////////////////////////////////////////////
  2033. int
  2034. ZoneParameterCtrlClass::Create
  2035. (
  2036. HWND parent_wnd,
  2037. int id_start,
  2038. LPRECT pos
  2039. )
  2040. {
  2041. CString param_name = m_Parameter->Get_Name ();
  2042. //
  2043. // Determine the dimensions of the title
  2044. //
  2045. CSize text_size;
  2046. Get_String_Size (parent_wnd, param_name, &text_size);
  2047. int button_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  2048. CRect text_rect = *pos;
  2049. text_rect.right = text_rect.left + text_size.cx + 32;
  2050. text_rect.top += ((button_height >> 1) - (text_size.cy >> 1));
  2051. text_rect.bottom = text_rect.top + text_size.cy;
  2052. //
  2053. // Create the static text control
  2054. //
  2055. m_StaticText.Create (param_name,
  2056. WS_CHILD | WS_VISIBLE | SS_LEFT,
  2057. text_rect,
  2058. CWnd::FromHandle (parent_wnd));
  2059. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  2060. //
  2061. // Determine the control's dimensions
  2062. //
  2063. CRect button_rect = *pos;
  2064. button_rect.left = text_rect.right + SPACE_WIDTH;
  2065. button_rect.bottom = button_rect.top + button_height;
  2066. //
  2067. // Create the edit control
  2068. //
  2069. m_ButtonID = id_start ++;
  2070. m_Button.Create ( "Edit Zone...",
  2071. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
  2072. button_rect,
  2073. CWnd::FromHandle (parent_wnd),
  2074. m_ButtonID);
  2075. m_Button.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  2076. pos->bottom = button_rect.bottom;
  2077. if (m_IsReadOnly) {
  2078. m_StaticText.EnableWindow (false);
  2079. m_Button.EnableWindow (false);
  2080. }
  2081. return id_start;
  2082. }
  2083. //////////////////////////////////////////////////////////////////////
  2084. //
  2085. // Resize
  2086. //
  2087. //////////////////////////////////////////////////////////////////////
  2088. void
  2089. ZoneParameterCtrlClass::Resize (const CRect &rect)
  2090. {
  2091. CRect old_rect1;
  2092. CRect old_rect2;
  2093. m_StaticText.GetWindowRect (&old_rect1);
  2094. m_Button.GetWindowRect (&old_rect2);
  2095. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  2096. m_Button.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  2097. return ;
  2098. }
  2099. //////////////////////////////////////////////////////////////////////
  2100. //
  2101. // Read_Data
  2102. //
  2103. //////////////////////////////////////////////////////////////////////
  2104. void
  2105. ZoneParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  2106. {
  2107. return ;
  2108. }
  2109. //////////////////////////////////////////////////////////////////////
  2110. //
  2111. // On_Command
  2112. //
  2113. //////////////////////////////////////////////////////////////////////
  2114. bool
  2115. ZoneParameterCtrlClass::On_Command
  2116. (
  2117. HWND parent_wnd,
  2118. WPARAM wparam,
  2119. LPARAM lparam
  2120. )
  2121. {
  2122. bool retval = false;
  2123. return retval;
  2124. }
  2125. //*******************************************************************************************//
  2126. //
  2127. // Start of FilenameListParameterCtrlClass
  2128. //
  2129. //*******************************************************************************************//
  2130. //////////////////////////////////////////////////////////////////////
  2131. //
  2132. // Create
  2133. //
  2134. //////////////////////////////////////////////////////////////////////
  2135. int
  2136. FilenameListParameterCtrlClass::Create
  2137. (
  2138. HWND parent_wnd,
  2139. int id_start,
  2140. LPRECT pos
  2141. )
  2142. {
  2143. CString param_name = m_Parameter->Get_Name ();
  2144. //
  2145. // Determine the dimensions of the title
  2146. //
  2147. CSize text_size;
  2148. Get_String_Size (parent_wnd, param_name, &text_size);
  2149. int button_height = ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  2150. CRect text_rect = *pos;
  2151. text_rect.right = text_rect.left + text_size.cx + 32;
  2152. text_rect.top += ((button_height >> 1) - (text_size.cy >> 1));
  2153. text_rect.bottom = text_rect.top + text_size.cy;
  2154. //
  2155. // Create the static text control
  2156. //
  2157. m_StaticText.Create (param_name,
  2158. WS_CHILD | WS_VISIBLE | SS_LEFT,
  2159. text_rect,
  2160. CWnd::FromHandle (parent_wnd));
  2161. m_StaticText.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  2162. //
  2163. // Determine the control's dimensions
  2164. //
  2165. CRect button_rect = *pos;
  2166. button_rect.left = text_rect.right + SPACE_WIDTH;
  2167. button_rect.bottom = button_rect.top + button_height;
  2168. //
  2169. // Create the edit control
  2170. //
  2171. m_ButtonID = id_start ++;
  2172. m_Button.Create ( "Edit File List...",
  2173. WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
  2174. button_rect,
  2175. CWnd::FromHandle (parent_wnd),
  2176. m_ButtonID);
  2177. m_Button.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  2178. pos->bottom = button_rect.bottom;
  2179. if (m_IsReadOnly) {
  2180. m_StaticText.EnableWindow (false);
  2181. m_Button.EnableWindow (false);
  2182. }
  2183. return id_start;
  2184. }
  2185. //////////////////////////////////////////////////////////////////////
  2186. //
  2187. // Resize
  2188. //
  2189. //////////////////////////////////////////////////////////////////////
  2190. void
  2191. FilenameListParameterCtrlClass::Resize (const CRect &rect)
  2192. {
  2193. CRect old_rect1;
  2194. CRect old_rect2;
  2195. m_StaticText.GetWindowRect (&old_rect1);
  2196. m_Button.GetWindowRect (&old_rect2);
  2197. int new_width = rect.Width () - (old_rect1.Width () + SPACE_WIDTH);
  2198. m_Button.SetWindowPos (NULL, 0, 0, new_width, old_rect2.Height (), SWP_NOZORDER | SWP_NOMOVE);
  2199. return ;
  2200. }
  2201. //////////////////////////////////////////////////////////////////////
  2202. //
  2203. // Read_Data
  2204. //
  2205. //////////////////////////////////////////////////////////////////////
  2206. void
  2207. FilenameListParameterCtrlClass::Read_Data (HWND /*parent_wnd*/)
  2208. {
  2209. return ;
  2210. }
  2211. //////////////////////////////////////////////////////////////////////
  2212. //
  2213. // On_Command
  2214. //
  2215. //////////////////////////////////////////////////////////////////////
  2216. bool
  2217. FilenameListParameterCtrlClass::On_Command
  2218. (
  2219. HWND parent_wnd,
  2220. WPARAM wparam,
  2221. LPARAM lparam
  2222. )
  2223. {
  2224. bool retval = false;
  2225. if ( LOWORD (wparam) == m_ButtonID &&
  2226. HIWORD (wparam) == BN_CLICKED)
  2227. {
  2228. //
  2229. // Setup the dialog's parameters
  2230. //
  2231. EditFilenameListDialogClass dialog (CWnd::FromHandle (parent_wnd));
  2232. DynamicVectorClass<StringClass> &filename_list = m_Parameter->Get_List ();
  2233. dialog.Set_List (filename_list);
  2234. //
  2235. // Display the dialog
  2236. //
  2237. if (dialog.DoModal () == IDOK) {
  2238. filename_list = dialog.Get_List ();
  2239. m_Parameter->Set_Modified ();
  2240. }
  2241. retval = true;
  2242. }
  2243. return retval;
  2244. }
  2245. //*******************************************************************************************//
  2246. //
  2247. // Start of SeparatorParameterCtrlClass
  2248. //
  2249. //*******************************************************************************************//
  2250. //////////////////////////////////////////////////////////////////////
  2251. //
  2252. // Create
  2253. //
  2254. //////////////////////////////////////////////////////////////////////
  2255. int
  2256. SeparatorParameterCtrlClass::Create
  2257. (
  2258. HWND parent_wnd,
  2259. int id_start,
  2260. LPRECT pos
  2261. )
  2262. {
  2263. CString param_name = m_Parameter->Get_Name ();
  2264. //
  2265. // Determine the ctrl's dimensions
  2266. //
  2267. CRect ctrl_rect = *pos;
  2268. ctrl_rect.top += BORDER_WIDTH / 2;
  2269. ctrl_rect.bottom = ctrl_rect.top + ::Get_Ctrl_Height (parent_wnd, CTRL_HEIGHT);
  2270. //
  2271. // Determine the text's dimensions
  2272. //
  2273. CSize size;
  2274. ::Get_String_Size (parent_wnd, param_name, &size);
  2275. //
  2276. // Create the frame control
  2277. //
  2278. CRect frame_rect = ctrl_rect;
  2279. frame_rect.top = ctrl_rect.top + (size.cy / 2);
  2280. frame_rect.bottom = frame_rect.top + 5;
  2281. m_FrameCtrl.Create ( param_name,
  2282. WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ,
  2283. frame_rect,
  2284. CWnd::FromHandle (parent_wnd),
  2285. id_start ++);
  2286. m_FrameCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  2287. //
  2288. // Create the static text control
  2289. //
  2290. ctrl_rect.left += BORDER_WIDTH;
  2291. ctrl_rect.right = ctrl_rect.left + size.cx + 1;
  2292. m_TextCtrl.Create ( param_name,
  2293. WS_CHILD | WS_VISIBLE | SS_LEFT,
  2294. ctrl_rect,
  2295. CWnd::FromHandle (parent_wnd),
  2296. id_start ++);
  2297. m_TextCtrl.SendMessage (WM_SETFONT, ::SendMessage (parent_wnd, WM_GETFONT, 0, 0L));
  2298. pos->bottom = ctrl_rect.bottom;
  2299. return id_start;
  2300. }
  2301. //////////////////////////////////////////////////////////////////////
  2302. //
  2303. // Resize
  2304. //
  2305. //////////////////////////////////////////////////////////////////////
  2306. void
  2307. SeparatorParameterCtrlClass::Resize (const CRect &rect)
  2308. {
  2309. CRect old_rect;
  2310. m_FrameCtrl.GetWindowRect (&old_rect);
  2311. m_FrameCtrl.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect.Height (), SWP_NOZORDER | SWP_NOMOVE);
  2312. //m_TextCtrl.GetWindowRect (&old_rect);
  2313. //m_TextCtrl.SetWindowPos (NULL, 0, 0, rect.Width (), old_rect.Height (), SWP_NOZORDER | SWP_NOMOVE);
  2314. return ;
  2315. }