GUIEdit.cpp 161 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: GUIEdit.cpp //////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: GUIEdit.cpp
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: GUI Edit and window layout entry point
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  44. #include <stdlib.h>
  45. #include <windows.h>
  46. #include <commctrl.h>
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. #include "Common/Debug.h"
  49. #include "Common/NameKeyGenerator.h"
  50. #include "Common/GameEngine.h"
  51. #include "Common/GlobalData.h"
  52. #include "GameClient/GlobalLanguage.h"
  53. #include "Common/PlayerList.h"
  54. #include "GameLogic/RankInfo.h"
  55. #include "Common/FileSystem.h"
  56. #include "Common/LocalFileSystem.h"
  57. #include "Common/ArchiveFileSystem.h"
  58. #include "GameClient/GadgetTextEntry.h"
  59. #include "GameClient/GadgetPushButton.h"
  60. #include "GameClient/GadgetProgressBar.h"
  61. #include "GameClient/GadgetRadioButton.h"
  62. #include "GameClient/GadgetStaticText.h"
  63. #include "GameClient/GadgetListBox.h"
  64. #include "GameClient/GadgetComboBox.h"
  65. #include "GameClient/GadgetSlider.h"
  66. #include "GameClient/GadgetCheckBox.h"
  67. #include "GameClient/GameText.h"
  68. #include "GameClient/GadgetTabControl.h"
  69. #include "GameClient/IMEManager.h"
  70. #include "GameClient/InGameUI.h"
  71. #include "GameClient/WindowXlat.h"
  72. #include "GameClient/HeaderTemplate.h"
  73. #include "W3DDevice/Common/W3DFunctionLexicon.h"
  74. #include "W3DDevice/GameClient/W3DGameWindowManager.h"
  75. #include "W3DDevice/GameClient/W3DDisplay.h"
  76. #include "W3DDevice/GameClient/W3DGameWindowManager.h"
  77. #include "W3DDevice/GameClient/W3DGameFont.h"
  78. #include "W3DDevice/GameClient/W3DDisplayStringManager.h"
  79. #include "GameClient/Keyboard.h"
  80. #include "Win32Device/GameClient/Win32Mouse.h"
  81. #include "Win32Device/GameClient/Win32DIKeyboard.h"
  82. #include "Win32Device/Common/Win32LocalFileSystem.h"
  83. #include "Win32Device/Common/Win32BIGFileSystem.h"
  84. #include "Resource.h"
  85. #include "WinMain.h"
  86. #include "GUIEdit.h"
  87. #include "HierarchyView.h"
  88. #include "EditWindow.h"
  89. #include "GUIEditWindowManager.h"
  90. #include "GUIEditDisplay.H"
  91. #include "DialogProc.h"
  92. #include "LayoutScheme.h"
  93. ///////////////////////////////////////////////////////////////////////////////
  94. // DEFINES ////////////////////////////////////////////////////////////////////
  95. ///////////////////////////////////////////////////////////////////////////////
  96. #define GUIEDIT_CONFIG_VERSION 4
  97. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  98. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  99. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  100. GUIEdit *TheEditor = NULL;
  101. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  102. ///////////////////////////////////////////////////////////////////////////////
  103. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  104. ///////////////////////////////////////////////////////////////////////////////
  105. // GUIEdit::saveAsDialog ======================================================
  106. /** Bring up the standard windows browser save as dialog and return
  107. * filename selected */
  108. //=============================================================================
  109. char *GUIEdit::saveAsDialog( void )
  110. {
  111. static char filename[ _MAX_PATH ];
  112. OPENFILENAME ofn;
  113. Bool returnCode;
  114. char filter[] = "Window Files (*.wnd)\0*.wnd\0" \
  115. "All Files (*.*)\0*.*\0\0" ;
  116. ofn.lStructSize = sizeof( OPENFILENAME );
  117. ofn.hwndOwner = m_appHWnd;
  118. ofn.hInstance = NULL;
  119. ofn.lpstrFilter = filter;
  120. ofn.lpstrCustomFilter = NULL;
  121. ofn.nMaxCustFilter = 0;
  122. ofn.nFilterIndex = 0;
  123. ofn.lpstrFile = filename;
  124. ofn.nMaxFile = _MAX_PATH;
  125. ofn.lpstrFileTitle = NULL;
  126. ofn.nMaxFileTitle = 0;
  127. ofn.lpstrInitialDir = NULL;
  128. ofn.lpstrTitle = NULL;
  129. ofn.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
  130. ofn.nFileOffset = 0;
  131. ofn.nFileExtension = 0;
  132. ofn.lpstrDefExt = "wnd";
  133. ofn.lCustData = 0L ;
  134. ofn.lpfnHook = NULL ;
  135. ofn.lpTemplateName = NULL ;
  136. returnCode = GetSaveFileName( &ofn );
  137. if( returnCode )
  138. return filename;
  139. else
  140. return NULL;
  141. } // end saveAsDialog
  142. // GUIEdit::openDialog ========================================================
  143. /** Bring up the standard windows browser open dialog and return
  144. * filename selected */
  145. //=============================================================================
  146. char *GUIEdit::openDialog( void )
  147. {
  148. static char filename[ _MAX_PATH ];
  149. OPENFILENAME ofn;
  150. Bool returnCode;
  151. char filter[] = "Window Files (*.wnd)\0*.wnd\0" \
  152. "All Files (*.*)\0*.*\0\0" ;
  153. ofn.lStructSize = sizeof( OPENFILENAME );
  154. ofn.hwndOwner = m_appHWnd;
  155. ofn.hInstance = NULL;
  156. ofn.lpstrFilter = filter;
  157. ofn.lpstrCustomFilter = NULL;
  158. ofn.nMaxCustFilter = 0;
  159. ofn.nFilterIndex = 0;
  160. ofn.lpstrFile = filename;
  161. ofn.nMaxFile = _MAX_PATH;
  162. ofn.lpstrFileTitle = NULL;
  163. ofn.nMaxFileTitle = 0;
  164. ofn.lpstrInitialDir = NULL;
  165. ofn.lpstrTitle = NULL;
  166. ofn.Flags = OFN_NOREADONLYRETURN | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
  167. ofn.nFileOffset = 0;
  168. ofn.nFileExtension = 0;
  169. ofn.lpstrDefExt = "wnd";
  170. ofn.lCustData = 0L ;
  171. ofn.lpfnHook = NULL ;
  172. ofn.lpTemplateName = NULL ;
  173. returnCode = GetOpenFileName( &ofn );
  174. if( returnCode )
  175. return filename;
  176. else
  177. return NULL;
  178. } // end openDialog
  179. // GUIEdit::setUnsaved ========================================================
  180. /** Set the current contents of the editor as either saved or unsaved,
  181. * when we're entering an unsaved state we will put a marker in the title
  182. * bar of the app, when leaving an unsaved state we will remove
  183. * that marker */
  184. //=============================================================================
  185. void GUIEdit::setUnsaved( Bool unsaved )
  186. {
  187. // char *saveStatus = " *";
  188. char *unsavedFilename = "New File";
  189. char *filename;
  190. // which filename to use in title bar
  191. if( strlen( m_saveFilename ) == 0 )
  192. filename = unsavedFilename;
  193. else
  194. filename = m_saveFilename;
  195. // if( m_unsaved == FALSE && unsaved == TRUE )
  196. if( unsaved == TRUE )
  197. {
  198. char title[ 256 ];
  199. // entering unsaved state, place '*' in title bar
  200. sprintf( title, "GUIEdit: %s *", filename );
  201. SetWindowText( m_appHWnd, title );
  202. } // end if
  203. //else if( m_unsaved == TRUE && unsaved == FALSE )
  204. else
  205. {
  206. char title[ 256 ];
  207. // leaving unsaved state, place '*' in title bar
  208. sprintf( title, "GUIEdit: %s", filename );
  209. SetWindowText( m_appHWnd, title );
  210. } // end else
  211. // save the new state we're in
  212. m_unsaved = unsaved;
  213. } // end setUnsaved
  214. // GUIEdit::setSaveFile =======================================================
  215. /** Set our member variables for the full path and filename passed in
  216. * to this method. We will also extract the filename only from the
  217. * full path and save that separately */
  218. //=============================================================================
  219. void GUIEdit::setSaveFile( char *fullPathAndFilename )
  220. {
  221. char *ptr;
  222. // copy over the full path and filename
  223. strcpy( m_savePathAndFilename, fullPathAndFilename );
  224. //
  225. // copy everything after the last '\' from the full path, this will
  226. // be just the filename with extension
  227. //
  228. ptr = strrchr( fullPathAndFilename, '\\' ) + 1;
  229. strcpy( m_saveFilename, ptr );
  230. } // end setSaveFile
  231. // GUIEdit::validateParentForCreate ===========================================
  232. /** This method is used when creating new windows and gadgets, if a
  233. * parent is present, that parent cannot be a GUI gadget because those
  234. * gadgets are atomic units, they can not contain user defined children */
  235. //=============================================================================
  236. Bool GUIEdit::validateParentForCreate( GameWindow *parent )
  237. {
  238. //
  239. // if there is a parent, that parent cannot be a gadget control,
  240. // gadgets are units themselves and should have no user defined
  241. // children
  242. //
  243. if( parent && TheEditor->windowIsGadget( parent ) )
  244. {
  245. MessageBox( TheEditor->getWindowHandle(),
  246. "You cannot make a new window as a child to a GUI Gadget Control",
  247. "Illegal Parent", MB_OK );
  248. return FALSE;
  249. } // end if
  250. return TRUE; // ok
  251. } // end validateParentForCreate
  252. // GUIEdit::findSelectionEntry ================================================
  253. /** Find selection entry for this window */
  254. //=============================================================================
  255. WindowSelectionEntry *GUIEdit::findSelectionEntry( GameWindow *window )
  256. {
  257. WindowSelectionEntry *entry;
  258. // sanity
  259. if( window == NULL )
  260. return NULL;
  261. // search the list
  262. entry = m_selectList;
  263. while( entry )
  264. {
  265. if( entry->window == window )
  266. return entry;
  267. // next entry
  268. entry = entry->next;
  269. } // end while
  270. return NULL; // not found
  271. } // end findSelectionEntry
  272. // GUIEdit::normalizeRegion ===================================================
  273. /** Normalize the region so that lo and hi are actually lo and hi */
  274. //=============================================================================
  275. void GUIEdit::normalizeRegion( IRegion2D *region )
  276. {
  277. ICoord2D temp;
  278. if( region->hi.x < region->lo.x )
  279. {
  280. if( region->hi.y < region->lo.y )
  281. {
  282. temp = region->hi;
  283. region->hi = region->lo;
  284. region->lo = temp;
  285. } // end if
  286. else
  287. {
  288. temp = region->hi;
  289. region->hi.x = region->lo.x;
  290. region->lo.x = temp.x;
  291. } // end else
  292. } // end if
  293. else if( region->hi.y < region->lo.y )
  294. {
  295. temp = region->hi;
  296. region->hi.y = region->lo.y;
  297. region->lo.y = temp.y;
  298. } // end if
  299. } // end normalizeRegion
  300. // GUIEdit::selectWindowsInRegion =============================================
  301. /** Select all the windows that are fully in the region */
  302. //=============================================================================
  303. void GUIEdit::selectWindowsInRegion( IRegion2D *region )
  304. {
  305. GameWindow *window;
  306. ICoord2D origin, size;
  307. // sanity
  308. if( region == NULL )
  309. return;
  310. // unselect everything selected
  311. clearSelections();
  312. // normalize the region if needed
  313. normalizeRegion( region );
  314. // get the window list
  315. window = TheWindowManager->winGetWindowList();
  316. while( window )
  317. {
  318. // get the screen position and size of window
  319. window->winGetScreenPosition( &origin.x, &origin.y );
  320. window->winGetSize( &size.x, &size.y );
  321. // compare window extents to selection region
  322. if( origin.x >= region->lo.x &&
  323. origin.y >= region->lo.y &&
  324. origin.x + size.x <= region->hi.x &&
  325. origin.y + size.y <= region->hi.y )
  326. {
  327. // add to selection list
  328. selectWindow( window );
  329. } // end if
  330. // go to next window
  331. window = window->winGetNext();
  332. } // end while
  333. } // end selectWindowsInRegion
  334. ///////////////////////////////////////////////////////////////////////////////
  335. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  336. ///////////////////////////////////////////////////////////////////////////////
  337. // GUIEdit::GUIEdit ===========================================================
  338. /** */
  339. //=============================================================================
  340. GUIEdit::GUIEdit( void )
  341. {
  342. m_appInst = 0;
  343. m_appHWnd = NULL;
  344. m_statusBarHWnd = NULL;
  345. m_toolbarHWnd = NULL;
  346. m_unsaved = FALSE;
  347. m_mode = MODE_UNDEFINED;
  348. strcpy( m_savePathAndFilename, "" );
  349. strcpy( m_saveFilename, "" );
  350. m_selectList = NULL;
  351. m_propertyTarget = NULL;
  352. m_gridVisible = TRUE;
  353. m_snapToGrid = TRUE;
  354. m_gridResolution = 8;
  355. m_gridColor.red = 112;
  356. m_gridColor.green = 112;
  357. m_gridColor.blue = 112;
  358. m_gridColor.alpha = 64;
  359. m_showHiddenOutlines = TRUE;
  360. m_showSeeThruOutlines = TRUE;
  361. m_layoutInitString = GUIEDIT_NONE_STRING;
  362. m_layoutUpdateString = GUIEDIT_NONE_STRING;
  363. m_layoutShutdownString = GUIEDIT_NONE_STRING;
  364. } // end GUIEdit
  365. // GUIEdit::~GUIEdit ==========================================================
  366. /** */
  367. //=============================================================================
  368. GUIEdit::~GUIEdit( void )
  369. {
  370. if (TheHeaderTemplateManager)
  371. {
  372. delete TheHeaderTemplateManager;
  373. TheHeaderTemplateManager = NULL;
  374. }
  375. if (TheGameText)
  376. {
  377. delete TheGameText;
  378. TheGameText = NULL;
  379. }
  380. // delete the IME Manager
  381. // if ( TheIMEManager )
  382. // {
  383. // delete TheIMEManager;
  384. // TheIMEManager = NULL;
  385. // }
  386. // all the shutdown routine
  387. shutdown();
  388. } // end ~GUIEdit
  389. // GUIEdit::init ==============================================================
  390. /** Initialize all the GUI edit data */
  391. //=============================================================================
  392. void GUIEdit::init( void )
  393. {
  394. //
  395. // save the couple of globals for our app main window as locals for
  396. // convenient access
  397. //
  398. m_appInst = ApplicationHInstance;
  399. m_appHWnd = ApplicationHWnd;
  400. // add status bar to the bottom
  401. createStatusBar();
  402. // create the name key generator
  403. TheNameKeyGenerator = new NameKeyGenerator;
  404. TheNameKeyGenerator->init();
  405. // create file system
  406. TheFileSystem = new FileSystem;
  407. TheLocalFileSystem = new Win32LocalFileSystem;
  408. TheArchiveFileSystem = new Win32BIGFileSystem;
  409. TheFileSystem->init();
  410. TheGlobalLanguageData = new GlobalLanguage;
  411. TheGlobalLanguageData->init();
  412. //---------------------------------------------------------------------------
  413. // GUI tool specific initializations ----------------------------------------
  414. //---------------------------------------------------------------------------
  415. //
  416. // create the window for the rendered GUI interaction, the GUIEdit
  417. // program MUST run in the same resolution that the window files are
  418. // created in, we have chosen 800x600 for all our GUI creation (CDay)
  419. //
  420. TheEditWindow = new EditWindow;
  421. // TheEditWindow->init( 640, 480 );
  422. TheEditWindow->init( 800, 600 );
  423. // TheEditWindow->init( 1024, 768 );
  424. // create hierarchy view
  425. TheHierarchyView = new HierarchyView;
  426. TheHierarchyView->init();
  427. //---------------------------------------------------------------------------
  428. // Game engine specific initializations -------------------------------------
  429. //---------------------------------------------------------------------------
  430. // create the name key generator
  431. TheWritableGlobalData = new GlobalData;
  432. TheWritableGlobalData->init();
  433. // create the message stream
  434. TheMessageStream = new MessageStream;
  435. TheMessageStream->init();
  436. TheMessageStream->attachTranslator( new WindowTranslator, 10 );
  437. // create the command list
  438. TheCommandList = new CommandList;
  439. // create the function lexicon
  440. TheFunctionLexicon = new W3DFunctionLexicon;
  441. TheFunctionLexicon->init();
  442. TheFunctionLexicon->validate();
  443. // create the font library
  444. TheFontLibrary = new W3DFontLibrary;
  445. TheFontLibrary->init();
  446. // load the set of GUIEdit default fonts for controls
  447. loadGUIEditFontLibrary( TheFontLibrary );
  448. // create GUI image collection
  449. TheMappedImageCollection = new ImageCollection;
  450. TheMappedImageCollection->init();
  451. TheMappedImageCollection->load( 512 );
  452. // create display string manager
  453. TheDisplayStringManager = new W3DDisplayStringManager;
  454. TheDisplayStringManager->init();
  455. // create the window manager
  456. TheWindowManager = new GUIEditWindowManager;
  457. TheWindowManager->init();
  458. TheRankInfoStore = new RankInfoStore;
  459. TheRankInfoStore->init();
  460. ThePlayerList = new PlayerList;
  461. ThePlayerList->init();
  462. TheKeyboard = new DirectInputKeyboard;
  463. //
  464. // in order to easily expose the new methods for our own internal editor
  465. // use we will keep a pointer to what we KNOW to be a gui edit window man.
  466. //
  467. TheGUIEditWindowManager = static_cast<GUIEditWindowManager *>(TheWindowManager);
  468. // create the display
  469. TheDisplay = new GUIEditDisplay;
  470. TheDisplay->init();
  471. ICoord2D size;
  472. TheEditWindow->getSize( &size );
  473. TheDisplay->setWidth( size.x );
  474. TheDisplay->setHeight( size.y );
  475. // set our initial mode
  476. setMode( MODE_EDIT );
  477. // create the default scheme, this must be done after image collections are loaded
  478. TheDefaultScheme = new LayoutScheme;
  479. TheDefaultScheme->init();
  480. // read our configuration file
  481. readConfigFile( GUIEDIT_CONFIG_FILENAME );
  482. // read the available font definitions
  483. readFontFile( GUIEDIT_FONT_FILENAME );
  484. // create the mouse
  485. TheWin32Mouse = new Win32Mouse;
  486. TheMouse = TheWin32Mouse;
  487. TheMouse->init();
  488. // lastly just for testing
  489. TheWindowManager->initTestGUI();
  490. // load the layout scheme now read in from the cofig file
  491. TheDefaultScheme->loadScheme( TheDefaultScheme->getSchemeFilename() );
  492. // create the localized game text interface
  493. TheGameText = CreateGameTextInterface();
  494. if ( TheGameText )
  495. {
  496. TheGameText->init();
  497. }
  498. TheHeaderTemplateManager = new HeaderTemplateManager;
  499. if(TheHeaderTemplateManager)
  500. TheHeaderTemplateManager->init();
  501. // create the IME manager
  502. // TheIMEManager = CreateIMEManagerInterface();
  503. // if ( TheIMEManager )
  504. // {
  505. // TheIMEManager->init();
  506. // }
  507. } // end init
  508. // GUIEdit::shutdown ==========================================================
  509. /** Shutdown our GUI edit application */
  510. //=============================================================================
  511. void GUIEdit::shutdown( void )
  512. {
  513. // write our configuration file
  514. writeConfigFile( GUIEDIT_CONFIG_FILENAME );
  515. // write our loaded fonts into the font file if we can
  516. writeFontFile( GUIEDIT_FONT_FILENAME );
  517. // delete all the selection entries
  518. clearSelections();
  519. // delete the display
  520. delete TheDisplay;
  521. TheDisplay = NULL;
  522. // delete all windows properly in the editor
  523. deleteAllWindows();
  524. // delete the mouse
  525. delete TheMouse;
  526. TheMouse = NULL;
  527. TheWin32Mouse = NULL;
  528. delete ThePlayerList;
  529. ThePlayerList = NULL;
  530. delete TheRankInfoStore;
  531. TheRankInfoStore = NULL;
  532. // delete the window manager
  533. delete TheWindowManager;
  534. TheWindowManager = NULL;
  535. TheGUIEditWindowManager = NULL;
  536. // delete display string manager
  537. delete TheDisplayStringManager;
  538. TheDisplayStringManager = NULL;
  539. // delete image collection
  540. delete TheMappedImageCollection;
  541. TheMappedImageCollection = NULL;
  542. // delete the font library
  543. delete TheFontLibrary;
  544. TheFontLibrary = NULL;
  545. delete TheCommandList;
  546. TheCommandList = NULL;
  547. delete TheMessageStream;
  548. TheMessageStream = NULL;
  549. // delete the function lexicon
  550. delete TheFunctionLexicon;
  551. TheFunctionLexicon = NULL;
  552. // delete name key generator
  553. delete TheNameKeyGenerator;
  554. TheNameKeyGenerator = NULL;
  555. delete TheGlobalLanguageData;
  556. TheGlobalLanguageData = NULL;
  557. // delete file system
  558. delete TheFileSystem;
  559. TheFileSystem = NULL;
  560. delete TheLocalFileSystem;
  561. TheLocalFileSystem = NULL;
  562. delete TheArchiveFileSystem;
  563. TheArchiveFileSystem = NULL;
  564. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  565. // delete the hierarchy view
  566. delete TheHierarchyView;
  567. TheHierarchyView = NULL;
  568. // destroy the edit window
  569. delete TheEditWindow;
  570. TheEditWindow = NULL;
  571. delete TheKeyboard;
  572. TheKeyboard = NULL;
  573. } // end shutdown
  574. // GUIEdit::update ============================================================
  575. /** Update method for our GUI edit application */
  576. //=============================================================================
  577. void GUIEdit::update( void )
  578. {
  579. // update mouse info
  580. TheMouse->update();
  581. // process the mouse if we're in test mode
  582. if( TheEditor->getMode() == MODE_TEST_RUN )
  583. {
  584. // send input through the window system and clear all messages after
  585. TheMouse->createStreamMessages();
  586. TheMessageStream->propagateMessages();
  587. TheCommandList->reset();
  588. } // end if
  589. // update the window manager itself
  590. TheWindowManager->update();
  591. // draw the edit window
  592. TheEditWindow->draw();
  593. } // end update
  594. // GUIEdit::writeConfigFile ===================================================
  595. /** Write the guiedit config file */
  596. //=============================================================================
  597. Bool GUIEdit::writeConfigFile( char *filename )
  598. {
  599. FILE *fp;
  600. // open the file
  601. fp = fopen( filename, "w" );
  602. if( fp == NULL )
  603. {
  604. DEBUG_LOG(( "writeConfigFile: Unable to open file '%s'\n", filename ));
  605. assert( 0 );
  606. return FALSE;
  607. } // end if
  608. // version
  609. fprintf( fp, "GUIEdit Config file version '%d'\n", GUIEDIT_CONFIG_VERSION );
  610. // edit window background color
  611. RGBColorReal backColor = TheEditWindow->getBackgroundColor();
  612. fprintf( fp, "BACKGROUNDCOLOR = %f %f %f %f\n",
  613. backColor.red, backColor.green, backColor.blue, backColor.alpha );
  614. // grid settings
  615. fprintf( fp, "GRIDRESOLUTION = %d\n", TheEditor->getGridResolution() );
  616. RGBColorInt *gridColor = TheEditor->getGridColor();
  617. fprintf( fp, "GRIDCOLOR = %d %d %d %d\n",
  618. gridColor->red, gridColor->green, gridColor->blue, gridColor->alpha );
  619. fprintf( fp, "SNAPTOGRID = %d\n", TheEditor->isGridSnapOn() );
  620. fprintf( fp, "GRIDVISIBLE = %d\n", TheEditor->isGridVisible() );
  621. // write hierarchy position and size
  622. ICoord2D pos, size;
  623. TheHierarchyView->getDialogPos( &pos );
  624. TheHierarchyView->getDialogSize( &size );
  625. fprintf( fp, "HIERARCHYPOSITION = %d %d\n", pos.x, pos.y );
  626. fprintf( fp, "HIERARCHYSIZE = %d %d\n", size.x, size.y );
  627. // hidden and see thru options
  628. fprintf( fp, "SHOWSEETHRUOUTLINES = %d\n", getShowSeeThruOutlines() );
  629. fprintf( fp, "SHOWHIDDENOUTLINES = %d\n", getShowHiddenOutlines() );
  630. // scheme file
  631. fprintf( fp, "SCHEMEFILE = %s\n", TheDefaultScheme->getSchemeFilename() );
  632. // close the file
  633. fclose( fp );
  634. return TRUE;
  635. } // end writeConfigFile
  636. // GUIEdit::readConfigFile ====================================================
  637. /** Read the guiedit config file */
  638. //=============================================================================
  639. Bool GUIEdit::readConfigFile( char *filename )
  640. {
  641. FILE *fp;
  642. // open the file
  643. fp = fopen( filename, "r" );
  644. if( fp == NULL )
  645. return TRUE;
  646. // version
  647. Int version;
  648. fscanf( fp, "GUIEdit Config file version '%d'\n", &version );
  649. if( version != GUIEDIT_CONFIG_VERSION )
  650. return FALSE; // version has changed, use defaults again
  651. // edit window background color
  652. RGBColorReal backColor;
  653. fscanf( fp, "BACKGROUNDCOLOR = %f %f %f %f\n",
  654. &backColor.red, &backColor.green, &backColor.blue, &backColor.alpha );
  655. TheEditWindow->setBackgroundColor( backColor );
  656. // grid settings
  657. Int intData;
  658. fscanf( fp, "GRIDRESOLUTION = %d\n", &intData );
  659. TheEditor->setGridResolution( intData );
  660. RGBColorInt gridColor;
  661. fscanf( fp, "GRIDCOLOR = %d %d %d %d\n",
  662. &gridColor.red, &gridColor.green, &gridColor.blue, &gridColor.alpha );
  663. TheEditor->setGridColor( &gridColor );
  664. fscanf( fp, "SNAPTOGRID = %d\n", &intData );
  665. TheEditor->setGridSnap( intData );
  666. fscanf( fp, "GRIDVISIBLE = %d\n", &intData );
  667. TheEditor->setGridVisible( intData );
  668. // hierarchy view
  669. ICoord2D pos, size;
  670. fscanf( fp, "HIERARCHYPOSITION = %d %d\n", &pos.x, &pos.y );
  671. fscanf( fp, "HIERARCHYSIZE = %d %d\n", &size.x, &size.y );
  672. TheHierarchyView->setDialogPos( &pos );
  673. TheHierarchyView->setDialogSize( &size );
  674. // hidden and see thru options
  675. Int show;
  676. fscanf( fp, "SHOWSEETHRUOUTLINES = %d\n", &show );
  677. setShowSeeThruOutlines( show );
  678. fscanf( fp, "SHOWHIDDENOUTLINES = %d\n", &show );
  679. setShowHiddenOutlines( show );
  680. // scheme file
  681. char file[ _MAX_PATH ];
  682. if (fscanf( fp, "SCHEMEFILE = %s\n", file ) == 1)
  683. {
  684. TheDefaultScheme->setSchemeFilename( file );
  685. }
  686. // close the file
  687. fclose( fp );
  688. return TRUE;
  689. } // end readConfigFile
  690. // GUIEdit::readFontFile ======================================================
  691. /** Read the font file defintitions and load them */
  692. //=============================================================================
  693. void GUIEdit::readFontFile( char *filename )
  694. {
  695. FILE *fp;
  696. // sanity
  697. if( filename == NULL )
  698. return;
  699. // open the file
  700. fp = fopen( filename, "r" );
  701. if( fp == NULL )
  702. return;
  703. // read how many entries follow
  704. Int fontCount;
  705. fscanf( fp, "AVAILABLE_FONT_COUNT = %d\n", &fontCount );
  706. for( Int i = 0; i < fontCount; i++ )
  707. {
  708. // read all the font defitions
  709. char fontBuffer[ 512 ];
  710. Int size, bold;
  711. char c = fgetc( fp );
  712. // skip past the first quote
  713. while( c != '\"' )
  714. c = fgetc( fp );
  715. c = fgetc( fp ); // the quote itself
  716. // copy the name till the next quote is read
  717. Int index = 0;
  718. while( c != '\"' )
  719. {
  720. fontBuffer[ index++ ] = c;
  721. c = fgetc( fp );
  722. } // end while
  723. fontBuffer[ index ] = '\0';
  724. c = fgetc( fp ); // the end quite itself
  725. // read the size and bold data elements
  726. fscanf( fp, " Size: %d Bold: %d\n", &size, &bold );
  727. // set the font
  728. GameFont *font = TheFontLibrary->getFont( AsciiString(fontBuffer), size, bold );
  729. if( font == NULL )
  730. {
  731. char buffer[ 1024 ];
  732. sprintf( buffer, "Warning: The font '%s' Size: '%d' Bold: '%d', specified in the config file could not be loaded. Does that font exist?",
  733. fontBuffer, size, bold );
  734. MessageBox( m_appHWnd, buffer, "Cannot Load Font", MB_OK );
  735. } // end if
  736. } // end for i
  737. // close the file
  738. fclose( fp );
  739. } // end readFontFile
  740. // GUIEdit::writeFontFile =====================================================
  741. /** If we can, write a file containing a definition of all the fonts
  742. * we have loaded */
  743. //=============================================================================
  744. void GUIEdit::writeFontFile( char *filename )
  745. {
  746. FILE *fp;
  747. // sanity
  748. if( filename == NULL )
  749. return;
  750. // open the file
  751. fp = fopen( filename, "w" );
  752. if( fp == NULL )
  753. return; // dont bother making an error, it's likely to be read only a lot
  754. // available fonts
  755. Int count = TheFontLibrary->getCount();
  756. fprintf( fp, "AVAILABLE_FONT_COUNT = %d\n", count );
  757. GameFont *font;
  758. for( font = TheFontLibrary->firstFont();
  759. font;
  760. font = TheFontLibrary->nextFont( font ) )
  761. {
  762. fprintf( fp, "AVAILABLEFONT = \"%s\" Size: %d Bold: %d\n",
  763. font->nameString.str(), font->pointSize, font->bold );
  764. } // end for
  765. // close the file
  766. fclose( fp );
  767. } // end writeFontFile
  768. // GUIEdit::setMode ===========================================================
  769. /** Set a new mode for the editor */
  770. //=============================================================================
  771. void GUIEdit::setMode( EditMode mode )
  772. {
  773. static TranslatorID transID = 0;
  774. // if same mode do nothing
  775. if( m_mode == mode )
  776. return;
  777. // if leaving test mode, remove the translator for test input
  778. if( m_mode == MODE_TEST_RUN )
  779. {
  780. TheMessageStream->removeTranslator( transID );
  781. transID = 0;
  782. } // end if
  783. // assign new mode
  784. m_mode = mode;
  785. // uncheck menu item for test mode by default
  786. unCheckMenuItem( MENU_TEST_MODE );
  787. // update status message
  788. switch( m_mode )
  789. {
  790. // ------------------------------------------------------------------------
  791. case MODE_TEST_RUN:
  792. statusMessage( STATUS_MODE, "Mode: Test Run" );
  793. // check menu item for test mode
  794. checkMenuItem( MENU_TEST_MODE );
  795. // attach window translator to stream for testing
  796. transID = TheMessageStream->attachTranslator( new WindowTranslator, 10 );
  797. break;
  798. // ------------------------------------------------------------------------
  799. case MODE_EDIT:
  800. setCursor( CURSOR_NORMAL );
  801. statusMessage( STATUS_MODE, "Ready" );
  802. break;
  803. // ------------------------------------------------------------------------
  804. case MODE_DRAG_MOVE:
  805. setCursor( CURSOR_MOVE );
  806. statusMessage( STATUS_MODE, "Drag window with mouse" );
  807. break;
  808. // ------------------------------------------------------------------------
  809. case MODE_KEYBOARD_MOVE:
  810. //setCursor( CURSOR_MOVE );
  811. statusMessage( STATUS_MODE, "Hit enter to accept or Esc to cancel" );
  812. break;
  813. // ------------------------------------------------------------------------
  814. case MODE_RESIZE_TOP_LEFT:
  815. setCursor( CURSOR_SIZE_NWSE );
  816. statusMessage( STATUS_MODE, "Drag top left corner to resize" );
  817. break;
  818. // ------------------------------------------------------------------------
  819. case MODE_RESIZE_TOP_RIGHT:
  820. setCursor( CURSOR_SIZE_NESW );
  821. statusMessage( STATUS_MODE, "Drag top right corner to resize" );
  822. break;
  823. // ------------------------------------------------------------------------
  824. case MODE_RESIZE_BOTTOM_RIGHT:
  825. setCursor( CURSOR_SIZE_NWSE );
  826. statusMessage( STATUS_MODE, "Drag bottom right corner to resize" );
  827. break;
  828. // ------------------------------------------------------------------------
  829. case MODE_RESIZE_BOTTOM_LEFT:
  830. setCursor( CURSOR_SIZE_NESW );
  831. statusMessage( STATUS_MODE, "Drag bottom left corner to resize" );
  832. break;
  833. // ------------------------------------------------------------------------
  834. case MODE_RESIZE_TOP:
  835. setCursor( CURSOR_SIZE_NS );
  836. statusMessage( STATUS_MODE, "Drag top to resize" );
  837. break;
  838. // ------------------------------------------------------------------------
  839. case MODE_RESIZE_BOTTOM:
  840. setCursor( CURSOR_SIZE_NS );
  841. statusMessage( STATUS_MODE, "Drag bottom to resize" );
  842. break;
  843. // ------------------------------------------------------------------------
  844. case MODE_RESIZE_LEFT:
  845. setCursor( CURSOR_SIZE_WE );
  846. statusMessage( STATUS_MODE, "Drag left to resize" );
  847. break;
  848. // ------------------------------------------------------------------------
  849. case MODE_RESIZE_RIGHT:
  850. setCursor( CURSOR_SIZE_WE );
  851. statusMessage( STATUS_MODE, "Drag right to resize" );
  852. break;
  853. } // end switch
  854. } // end setMode
  855. // GUIEdit::setCursor =========================================================
  856. /** Set the cursor to the specified type */
  857. //=============================================================================
  858. void GUIEdit::setCursor( CursorType type )
  859. {
  860. char *identifier;
  861. switch( type )
  862. {
  863. // ------------------------------------------------------------------------
  864. case CURSOR_NORMAL:
  865. identifier = IDC_ARROW;
  866. break;
  867. // ------------------------------------------------------------------------
  868. case CURSOR_MOVE:
  869. identifier = IDC_SIZEALL;
  870. break;
  871. // ------------------------------------------------------------------------
  872. case CURSOR_SIZE_NESW:
  873. identifier = IDC_SIZENESW;
  874. break;
  875. // ------------------------------------------------------------------------
  876. case CURSOR_SIZE_NS:
  877. identifier = IDC_SIZENS;
  878. break;
  879. // ------------------------------------------------------------------------
  880. case CURSOR_SIZE_NWSE:
  881. identifier = IDC_SIZENWSE;
  882. break;
  883. // ------------------------------------------------------------------------
  884. case CURSOR_SIZE_WE:
  885. identifier = IDC_SIZEWE;
  886. break;
  887. // ------------------------------------------------------------------------
  888. case CURSOR_WAIT:
  889. identifier = IDC_WAIT;
  890. break;
  891. } // end switchType
  892. // set the new cursor
  893. SetCursor( LoadCursor( NULL, identifier ) );
  894. } // end setCursor
  895. // pointInChild ===============================================================
  896. /** Given a mouse position, get the topmost window at that location. We needed
  897. to pull this out into it's own special case function since the standard
  898. winPointInAnyChild is used by the game and we needed a special case to
  899. select a disabled control in GUIEdit */
  900. //=============================================================================
  901. static GameWindow *pointInChild( Int x, Int y , GameWindow *win)
  902. {
  903. GameWindow *parent;
  904. GameWindow *child;
  905. ICoord2D origin;
  906. IRegion2D tempRegion;
  907. Int tempX, tempY;
  908. for( child = win->winGetChild(); child; child = child->winGetNext() )
  909. {
  910. child->winGetRegion(&tempRegion);
  911. origin = tempRegion.lo;
  912. parent = child->winGetParent();
  913. while( parent )
  914. {
  915. parent->winGetRegion(&tempRegion);
  916. origin.x += tempRegion.lo.x;
  917. origin.y += tempRegion.lo.y;
  918. parent = parent->winGetParent();
  919. } // end while
  920. child->winGetSize(&tempX,&tempY);
  921. if( x >= origin.x && x <= origin.x + tempX &&
  922. y >= origin.y && y <= origin.y + tempY &&
  923. BitTest( child->winGetStatus(), WIN_STATUS_HIDDEN ) == FALSE)
  924. return child->winPointInChild( x, y );
  925. } // end for child
  926. // not in any children, must be in parent
  927. return win;
  928. } // end pointInChild
  929. // pointInAnyChild ============================================================
  930. /** Given a mouse position, get the topmost window at that location. We needed
  931. to pull this out into it's own special case function since the standard
  932. winPointInAnyChild is used by the game and we needed a special case to
  933. select a disabled control in GUIEdit */
  934. //=============================================================================
  935. static GameWindow *pointInAnyChild( Int x, Int y, Bool ignoreHidden, GameWindow *win )
  936. {
  937. GameWindow *parent;
  938. GameWindow *child;
  939. ICoord2D origin;
  940. IRegion2D tempRegion;
  941. Int tempX, tempY;
  942. for( child = win->winGetChild(); child; child = child->winGetNext() )
  943. {
  944. child->winGetRegion(&tempRegion);
  945. origin = tempRegion.lo;
  946. parent = child->winGetParent();
  947. while( parent )
  948. {
  949. parent->winGetRegion(&tempRegion);
  950. origin.x += tempRegion.lo.x;
  951. origin.y += tempRegion.lo.y;
  952. parent = parent->winGetParent();
  953. } // end while
  954. child->winGetSize(&tempX,&tempY);
  955. if( x >= origin.x && x <= origin.x + tempX &&
  956. y >= origin.y && y <= origin.y + tempY )
  957. {
  958. if( !(ignoreHidden == TRUE && BitTest( child->winGetStatus(), WIN_STATUS_HIDDEN )) )
  959. return pointInChild( x, y , child);
  960. } // end if
  961. } // end for child
  962. // not in any children, must be in parent
  963. return win;
  964. } // end pointInAnyChild
  965. // GUIEdit::getWindowAtPos ====================================================
  966. /** Given a mouse position, get the topmost window at that location */
  967. //=============================================================================
  968. GameWindow *GUIEdit::getWindowAtPos( Int x, Int y )
  969. {
  970. GameWindow *window;
  971. GameWindow *pick = NULL;
  972. IRegion2D region;
  973. for( window = TheWindowManager->winGetWindowList();
  974. window;
  975. window = window->winGetNext() )
  976. {
  977. // get window region
  978. window->winGetRegion( &region );
  979. if( x >= region.lo.x && x <= region.hi.x &&
  980. y >= region.lo.y && y <= region.hi.y )
  981. {
  982. pick = pointInAnyChild( x, y, FALSE, window );
  983. break; // exit for
  984. } // end if
  985. } // end for
  986. //
  987. // gadget controls are just composed of generic windows and buttons,
  988. // we will not allow you to select these componenets themselves in a gadget
  989. // because the gadget is the atomic "unit" as far as GUI editing goes.
  990. // If we've picked a gadget component we will instead just return the gadget
  991. // itself
  992. //
  993. if( pick )
  994. {
  995. GameWindow *parent = pick->winGetParent();
  996. //
  997. // all gadget components are children of their parent, therefore they
  998. // all have a parent
  999. //
  1000. if( parent )
  1001. {
  1002. if( BitTest( parent->winGetStyle(), GWS_VERT_SLIDER |
  1003. GWS_HORZ_SLIDER |
  1004. GWS_SCROLL_LISTBOX |
  1005. GWS_COMBO_BOX |
  1006. GWS_TAB_CONTROL
  1007. )
  1008. )
  1009. {
  1010. // the parent is what we care about
  1011. pick = parent;
  1012. //
  1013. // the parent is the thing we want to return here, unless we clicked
  1014. // on the thumb of a scroll list box, that element is implemented as
  1015. // a slider, therefore in that situation only we want to return the
  1016. // parent of the slider
  1017. //
  1018. if( BitTest( parent->winGetStyle(), GWS_HORZ_SLIDER |
  1019. GWS_VERT_SLIDER ) )
  1020. {
  1021. GameWindow *grandParent = parent->winGetParent();
  1022. if( grandParent && BitTest( grandParent->winGetStyle(),
  1023. GWS_SCROLL_LISTBOX ) )
  1024. pick = grandParent;
  1025. } // end if
  1026. //must check to see of the parent of a scroll box is a combo box
  1027. if(BitTest(pick->winGetStyle(), GWS_SCROLL_LISTBOX))
  1028. {
  1029. GameWindow *grandParent = pick->winGetParent();
  1030. if( grandParent && BitTest( grandParent->winGetStyle(), GWS_COMBO_BOX))
  1031. pick = grandParent;
  1032. }
  1033. } // end if
  1034. } // end if
  1035. } // end if
  1036. return pick;
  1037. } // end getWindowAtPos
  1038. // GUIEdit::clipCreationParamsToParent ========================================
  1039. /** when creating child windows we don't want them to exist outside the
  1040. * parent so we use this to clip them to the the parent size and
  1041. * locations */
  1042. //=============================================================================
  1043. void GUIEdit::clipCreationParamsToParent( GameWindow *parent,
  1044. Int *x, Int *y,
  1045. Int *width, Int *height )
  1046. {
  1047. IRegion2D parentScreenRegion;
  1048. ICoord2D parentSize;
  1049. ICoord2D parentPos;
  1050. Int newX, newY,
  1051. newWidth, newHeight;
  1052. // sanity
  1053. if( parent == NULL ||
  1054. x == NULL || y == NULL ||
  1055. width == NULL || height == NULL )
  1056. return;
  1057. // get parent screen region and size
  1058. parent->winGetScreenPosition( &parentPos.x, &parentPos.y );
  1059. parent->winGetSize( &parentSize.x, &parentSize.y );
  1060. //
  1061. // compute the screen region, note this is NOT the same as the region
  1062. // that comes back from winGetRegion, those regions are relative to their
  1063. // parents
  1064. //
  1065. parentScreenRegion.lo.x = parentPos.x;
  1066. parentScreenRegion.lo.y = parentPos.y;
  1067. parentScreenRegion.hi.x = parentPos.x + parentSize.x;
  1068. parentScreenRegion.hi.y = parentPos.y + parentSize.y;
  1069. //
  1070. // the new window position is really the difference between where
  1071. // we clicked and the parent location
  1072. //
  1073. newX = *x - parentScreenRegion.lo.x;
  1074. newY = *y - parentScreenRegion.lo.y;
  1075. // new child windows must stay contained within their parent
  1076. newWidth = *width;
  1077. if( *x + *width > parentScreenRegion.hi.x )
  1078. newWidth = parentSize.x - newX;
  1079. newHeight = *height;
  1080. if( *y + *height > parentScreenRegion.hi.y )
  1081. newHeight = parentSize.y - newY;
  1082. *x = newX;
  1083. *y = newY;
  1084. *width = newWidth;
  1085. *height= newHeight;
  1086. } // end clipcreationParamsToParent
  1087. ///////////////////////////////////////////////////////////////////////////////
  1088. ///////////////////////////////////////////////////////////////////////////////
  1089. ///////////////////////////////////////////////////////////////////////////////
  1090. // GUIEdit::deleteAllWindows ==================================================
  1091. /** Delete all windows in the editor */
  1092. //=============================================================================
  1093. void GUIEdit::deleteAllWindows( void )
  1094. {
  1095. GameWindow *window, *next;
  1096. window = TheWindowManager->winGetWindowList();
  1097. while( window )
  1098. {
  1099. next = window->winGetNext();
  1100. deleteWindow( window );
  1101. window = next;
  1102. } // end while
  1103. } // end deleteAllWindows
  1104. // GUIEdit::removeWindowCleanup ===============================================
  1105. /** This is called on each window before it is deleted or removed from
  1106. * the active windows in the editor to allow the system to
  1107. * cleanup before the delete */
  1108. //=============================================================================
  1109. void GUIEdit::removeWindowCleanup( GameWindow *window )
  1110. {
  1111. // end of recursion
  1112. if( window == NULL )
  1113. return;
  1114. //
  1115. // unselect the window if selected, this should be done first as further
  1116. // operations like deleting the tree entry change selections
  1117. //
  1118. unSelectWindow( window );
  1119. // remove this window from the hierarchy
  1120. TheHierarchyView->removeWindow( window );
  1121. // take this out of the property target if present
  1122. if( m_propertyTarget == window )
  1123. m_propertyTarget = NULL;
  1124. // notify the edit window this is going away
  1125. TheEditWindow->notifyWindowDeleted( window );
  1126. //
  1127. // any children of this window will be destroyed as well, do cleanup
  1128. // for them as well
  1129. //
  1130. GameWindow *child;
  1131. for( child = window->winGetChild(); child; child = child->winGetNext() )
  1132. removeWindowCleanup( child );
  1133. } // end removeWindowCleanup
  1134. // GUIEdit::deleteWindow ======================================================
  1135. /** Delete the window from the editor */
  1136. //=============================================================================
  1137. void GUIEdit::deleteWindow( GameWindow *window )
  1138. {
  1139. // have the editor cleanup all references to this window
  1140. removeWindowCleanup( window );
  1141. // destroy the game winodow
  1142. TheWindowManager->winDestroy( window );
  1143. // we've changed contents
  1144. setUnsaved( TRUE );
  1145. } // end deleteWindow
  1146. // GUIEdit::newWindow =========================================================
  1147. /** Create a new window of the specified type. This is the single creation
  1148. * point for all windows created in the editor */
  1149. //=============================================================================
  1150. GameWindow *GUIEdit::newWindow( UnsignedInt windowStyle,
  1151. GameWindow *parent,
  1152. Int x, Int y,
  1153. Int width, Int height )
  1154. {
  1155. GameWindow *window = NULL;
  1156. // create the appropriate window based on style bit passed in
  1157. switch( windowStyle )
  1158. {
  1159. // ------------------------------------------------------------------------
  1160. case GWS_USER_WINDOW:
  1161. window = newUserWindow( parent, x, y, width, height );
  1162. break;
  1163. // ------------------------------------------------------------------------
  1164. case GWS_PUSH_BUTTON:
  1165. window = newPushButton( parent, x, y, width, height );
  1166. break;
  1167. // ------------------------------------------------------------------------
  1168. case GWS_CHECK_BOX:
  1169. window = newCheckBox( parent, x, y, width, height );
  1170. break;
  1171. // ------------------------------------------------------------------------
  1172. case GWS_RADIO_BUTTON:
  1173. window = newRadioButton( parent, x, y, width, height );
  1174. break;
  1175. // ------------------------------------------------------------------------
  1176. case GWS_TAB_CONTROL:
  1177. window = newTabControl( parent, x, y, width, height );
  1178. break;
  1179. // ------------------------------------------------------------------------
  1180. case GWS_HORZ_SLIDER:
  1181. window = newHorizontalSlider( parent, x, y, width, height );
  1182. break;
  1183. // ------------------------------------------------------------------------
  1184. case GWS_VERT_SLIDER:
  1185. window = newVerticalSlider( parent, x, y, width, height );
  1186. break;
  1187. // ------------------------------------------------------------------------
  1188. case GWS_SCROLL_LISTBOX:
  1189. window = newListbox( parent, x, y, width, height );
  1190. break;
  1191. // ------------------------------------------------------------------------
  1192. case GWS_COMBO_BOX:
  1193. window = newComboBox( parent, x, y, width, height );
  1194. break;
  1195. // ------------------------------------------------------------------------
  1196. case GWS_PROGRESS_BAR:
  1197. window = newProgressBar( parent, x, y, width, height );
  1198. break;
  1199. // ------------------------------------------------------------------------
  1200. case GWS_ENTRY_FIELD:
  1201. window = newTextEntry( parent, x, y, width, height );
  1202. break;
  1203. // ------------------------------------------------------------------------
  1204. case GWS_STATIC_TEXT:
  1205. window = newStaticText( parent, x, y, width, height );
  1206. break;
  1207. // ------------------------------------------------------------------------
  1208. default:
  1209. MessageBox( m_appHWnd, "Unknown window type to newWindow()", "ERROR",
  1210. MB_OK | MB_ICONERROR );
  1211. break;
  1212. } // end switch
  1213. return window;
  1214. } // end newWindow
  1215. // GUIEdit::newUserWindow =====================================================
  1216. /** Create a new window at the given location */
  1217. //=============================================================================
  1218. GameWindow *GUIEdit::newUserWindow( GameWindow *parent, Int x, Int y,
  1219. Int width, Int height )
  1220. {
  1221. UnsignedInt status = WIN_STATUS_ENABLED;
  1222. GameWindow *window;
  1223. // validate the parent to disallow illegal relationships
  1224. if( validateParentForCreate( parent ) == FALSE )
  1225. return NULL;
  1226. //
  1227. // if there is a parent present we need to translate the screen x and y
  1228. // location to coords that are local to the parent window
  1229. //
  1230. if( parent )
  1231. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1232. // create the new window
  1233. window = TheWindowManager->winCreate( parent, status,
  1234. x, y,
  1235. width, height,
  1236. NULL, NULL );
  1237. // a window created in the editor here is a user window
  1238. WinInstanceData *instData = window->winGetInstanceData();
  1239. BitSet( instData->m_style, GWS_USER_WINDOW );
  1240. // set default colors based on the default scheme
  1241. ImageAndColorInfo *info;
  1242. info = TheDefaultScheme->getImageAndColor( GENERIC_ENABLED );
  1243. window->winSetEnabledImage( 0, info->image );
  1244. window->winSetEnabledColor( 0, info->color );
  1245. window->winSetEnabledBorderColor( 0, info->borderColor );
  1246. info = TheDefaultScheme->getImageAndColor( GENERIC_DISABLED );
  1247. window->winSetDisabledImage( 0, info->image );
  1248. window->winSetDisabledColor( 0, info->color );
  1249. window->winSetDisabledBorderColor( 0, info->borderColor );
  1250. info = TheDefaultScheme->getImageAndColor( GENERIC_HILITE );
  1251. window->winSetHiliteImage( 0, info->image );
  1252. window->winSetHiliteColor( 0, info->color );
  1253. window->winSetHiliteBorderColor( 0, info->borderColor );
  1254. // contents have changed
  1255. setUnsaved( TRUE );
  1256. // notify the editor of the new window
  1257. notifyNewWindow( window );
  1258. return window;
  1259. } // end newUserWindow
  1260. // GUIEdit::newPushButton =====================================================
  1261. /** Create a new push button */
  1262. //=============================================================================
  1263. GameWindow *GUIEdit::newPushButton( GameWindow *parent,
  1264. Int x, Int y, Int width, Int height )
  1265. {
  1266. GameWindow *window;
  1267. WinInstanceData instData;
  1268. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1269. // validate the parent to disallow illegal relationships
  1270. if( validateParentForCreate( parent ) == FALSE )
  1271. return NULL;
  1272. // keep the button inside a parent if present
  1273. if( parent )
  1274. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1275. // initialize inst data
  1276. instData.init();
  1277. instData.m_style = GWS_PUSH_BUTTON | GWS_MOUSE_TRACK;
  1278. instData.m_textLabelString = "Button";
  1279. window = TheWindowManager->gogoGadgetPushButton( parent,
  1280. status,
  1281. x, y,
  1282. width, height,
  1283. &instData,
  1284. NULL,
  1285. TRUE );
  1286. // set default colors based on the default scheme
  1287. if( window )
  1288. {
  1289. ImageAndColorInfo *info;
  1290. info = TheDefaultScheme->getImageAndColor( BUTTON_ENABLED );
  1291. GadgetButtonSetEnabledImage( window, info->image );
  1292. GadgetButtonSetEnabledColor( window, info->color );
  1293. GadgetButtonSetEnabledBorderColor( window, info->borderColor );
  1294. info = TheDefaultScheme->getImageAndColor( BUTTON_ENABLED_PUSHED );
  1295. GadgetButtonSetEnabledSelectedImage( window, info->image );
  1296. GadgetButtonSetEnabledSelectedColor( window, info->color );
  1297. GadgetButtonSetEnabledSelectedBorderColor( window, info->borderColor );
  1298. info = TheDefaultScheme->getImageAndColor( BUTTON_DISABLED );
  1299. GadgetButtonSetDisabledImage( window, info->image );
  1300. GadgetButtonSetDisabledColor( window, info->color );
  1301. GadgetButtonSetDisabledBorderColor( window, info->borderColor );
  1302. info = TheDefaultScheme->getImageAndColor( BUTTON_DISABLED_PUSHED );
  1303. GadgetButtonSetDisabledSelectedImage( window, info->image );
  1304. GadgetButtonSetDisabledSelectedColor( window, info->color );
  1305. GadgetButtonSetDisabledSelectedBorderColor( window, info->borderColor );
  1306. info = TheDefaultScheme->getImageAndColor( BUTTON_HILITE );
  1307. GadgetButtonSetHiliteImage( window, info->image );
  1308. GadgetButtonSetHiliteColor( window, info->color );
  1309. GadgetButtonSetHiliteBorderColor( window, info->borderColor );
  1310. info = TheDefaultScheme->getImageAndColor( BUTTON_HILITE_PUSHED );
  1311. GadgetButtonSetHiliteSelectedImage( window, info->image );
  1312. GadgetButtonSetHiliteSelectedColor( window, info->color );
  1313. GadgetButtonSetHiliteSelectedBorderColor( window, info->borderColor );
  1314. Color color, border;
  1315. color = TheDefaultScheme->getEnabledTextColor();
  1316. border = TheDefaultScheme->getEnabledTextBorderColor();
  1317. window->winSetEnabledTextColors( color, border );
  1318. color = TheDefaultScheme->getDisabledTextColor();
  1319. border = TheDefaultScheme->getDisabledTextBorderColor();
  1320. window->winSetDisabledTextColors( color, border );
  1321. color = TheDefaultScheme->getHiliteTextColor();
  1322. border = TheDefaultScheme->getHiliteTextBorderColor();
  1323. window->winSetHiliteTextColors( color, border );
  1324. // set default font
  1325. window->winSetFont( TheDefaultScheme->getFont() );
  1326. } // end if
  1327. // contents have changed
  1328. setUnsaved( TRUE );
  1329. // notify the editor of the new window
  1330. notifyNewWindow( window );
  1331. return window;
  1332. } // end newPushButton
  1333. // GUIEdit::newCheckBox =======================================================
  1334. /** Create a new check box */
  1335. //=============================================================================
  1336. GameWindow *GUIEdit::newCheckBox( GameWindow *parent,
  1337. Int x, Int y, Int width, Int height )
  1338. {
  1339. GameWindow *window;
  1340. WinInstanceData instData;
  1341. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1342. // validate the parent to disallow illegal relationships
  1343. if( validateParentForCreate( parent ) == FALSE )
  1344. return NULL;
  1345. // keep inside a parent if present
  1346. if( parent )
  1347. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1348. // initialize inst data
  1349. instData.init();
  1350. instData.m_style = GWS_CHECK_BOX | GWS_MOUSE_TRACK;
  1351. instData.m_textLabelString = "Check";
  1352. // create gadget
  1353. window = TheWindowManager->gogoGadgetCheckbox( parent,
  1354. status,
  1355. x, y,
  1356. width, height,
  1357. &instData,
  1358. NULL,
  1359. TRUE );
  1360. // set default colors based on the default scheme
  1361. if( window )
  1362. {
  1363. ImageAndColorInfo *info;
  1364. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_ENABLED );
  1365. GadgetCheckBoxSetEnabledImage( window, info->image );
  1366. GadgetCheckBoxSetEnabledColor( window, info->color );
  1367. GadgetCheckBoxSetEnabledBorderColor( window, info->borderColor );
  1368. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_ENABLED_UNCHECKED_BOX );
  1369. GadgetCheckBoxSetEnabledUncheckedBoxImage( window, info->image );
  1370. GadgetCheckBoxSetEnabledUncheckedBoxColor( window, info->color );
  1371. GadgetCheckBoxSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
  1372. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_ENABLED_CHECKED_BOX );
  1373. GadgetCheckBoxSetEnabledCheckedBoxImage( window, info->image );
  1374. GadgetCheckBoxSetEnabledCheckedBoxColor( window, info->color );
  1375. GadgetCheckBoxSetEnabledCheckedBoxBorderColor( window, info->borderColor );
  1376. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_DISABLED );
  1377. GadgetCheckBoxSetDisabledImage( window, info->image );
  1378. GadgetCheckBoxSetDisabledColor( window, info->color );
  1379. GadgetCheckBoxSetDisabledBorderColor( window, info->borderColor );
  1380. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_DISABLED_UNCHECKED_BOX );
  1381. GadgetCheckBoxSetDisabledUncheckedBoxImage( window, info->image );
  1382. GadgetCheckBoxSetDisabledUncheckedBoxColor( window, info->color );
  1383. GadgetCheckBoxSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
  1384. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_DISABLED_CHECKED_BOX );
  1385. GadgetCheckBoxSetDisabledCheckedBoxImage( window, info->image );
  1386. GadgetCheckBoxSetDisabledCheckedBoxColor( window, info->color );
  1387. GadgetCheckBoxSetDisabledCheckedBoxBorderColor( window, info->borderColor );
  1388. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_HILITE );
  1389. GadgetCheckBoxSetHiliteImage( window, info->image );
  1390. GadgetCheckBoxSetHiliteColor( window, info->color );
  1391. GadgetCheckBoxSetHiliteBorderColor( window, info->borderColor );
  1392. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_HILITE_UNCHECKED_BOX );
  1393. GadgetCheckBoxSetHiliteUncheckedBoxImage( window, info->image );
  1394. GadgetCheckBoxSetHiliteUncheckedBoxColor( window, info->color );
  1395. GadgetCheckBoxSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
  1396. info = TheDefaultScheme->getImageAndColor( CHECK_BOX_HILITE_CHECKED_BOX );
  1397. GadgetCheckBoxSetHiliteCheckedBoxImage( window, info->image );
  1398. GadgetCheckBoxSetHiliteCheckedBoxColor( window, info->color );
  1399. GadgetCheckBoxSetHiliteCheckedBoxBorderColor( window, info->borderColor );
  1400. Color color, border;
  1401. color = TheDefaultScheme->getEnabledTextColor();
  1402. border = TheDefaultScheme->getEnabledTextBorderColor();
  1403. window->winSetEnabledTextColors( color, border );
  1404. color = TheDefaultScheme->getDisabledTextColor();
  1405. border = TheDefaultScheme->getDisabledTextBorderColor();
  1406. window->winSetDisabledTextColors( color, border );
  1407. color = TheDefaultScheme->getHiliteTextColor();
  1408. border = TheDefaultScheme->getHiliteTextBorderColor();
  1409. window->winSetHiliteTextColors( color, border );
  1410. // set default font
  1411. window->winSetFont( TheDefaultScheme->getFont() );
  1412. } // end if
  1413. // contents have changed
  1414. setUnsaved( TRUE );
  1415. // notify the editor of the new window
  1416. notifyNewWindow( window );
  1417. return window;
  1418. } // end newCheckBox
  1419. // GUIEdit::newRadioButton ====================================================
  1420. /** Create a new radio button */
  1421. //=============================================================================
  1422. GameWindow *GUIEdit::newRadioButton( GameWindow *parent,
  1423. Int x, Int y, Int width, Int height )
  1424. {
  1425. RadioButtonData radioData;
  1426. GameWindow *window;
  1427. WinInstanceData instData;
  1428. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1429. // validate the parent to disallow illegal relationships
  1430. if( validateParentForCreate( parent ) == FALSE )
  1431. return NULL;
  1432. // keep inside a parent if present
  1433. if( parent )
  1434. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1435. // initialize inst data
  1436. instData.init();
  1437. instData.m_style = GWS_RADIO_BUTTON | GWS_MOUSE_TRACK;
  1438. memset( &radioData, 0, sizeof( radioData ) );
  1439. instData.m_textLabelString = "Radio";
  1440. // create gadget
  1441. window = TheWindowManager->gogoGadgetRadioButton( parent,
  1442. status,
  1443. x, y,
  1444. width, height,
  1445. &instData,
  1446. &radioData,
  1447. NULL,
  1448. TRUE );
  1449. // set default colors based on the default scheme
  1450. if( window )
  1451. {
  1452. ImageAndColorInfo *info;
  1453. info = TheDefaultScheme->getImageAndColor( RADIO_ENABLED );
  1454. GadgetRadioSetEnabledImage( window, info->image );
  1455. GadgetRadioSetEnabledColor( window, info->color );
  1456. GadgetRadioSetEnabledBorderColor( window, info->borderColor );
  1457. info = TheDefaultScheme->getImageAndColor( RADIO_ENABLED_UNCHECKED_BOX );
  1458. GadgetRadioSetEnabledUncheckedBoxImage( window, info->image );
  1459. GadgetRadioSetEnabledUncheckedBoxColor( window, info->color );
  1460. GadgetRadioSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
  1461. info = TheDefaultScheme->getImageAndColor( RADIO_ENABLED_CHECKED_BOX );
  1462. GadgetRadioSetEnabledCheckedBoxImage( window, info->image );
  1463. GadgetRadioSetEnabledCheckedBoxColor( window, info->color );
  1464. GadgetRadioSetEnabledCheckedBoxBorderColor( window, info->borderColor );
  1465. info = TheDefaultScheme->getImageAndColor( RADIO_DISABLED );
  1466. GadgetRadioSetDisabledImage( window, info->image );
  1467. GadgetRadioSetDisabledColor( window, info->color );
  1468. GadgetRadioSetDisabledBorderColor( window, info->borderColor );
  1469. info = TheDefaultScheme->getImageAndColor( RADIO_DISABLED_UNCHECKED_BOX );
  1470. GadgetRadioSetDisabledUncheckedBoxImage( window, info->image );
  1471. GadgetRadioSetDisabledUncheckedBoxColor( window, info->color );
  1472. GadgetRadioSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
  1473. info = TheDefaultScheme->getImageAndColor( RADIO_DISABLED_CHECKED_BOX );
  1474. GadgetRadioSetDisabledCheckedBoxImage( window, info->image );
  1475. GadgetRadioSetDisabledCheckedBoxColor( window, info->color );
  1476. GadgetRadioSetDisabledCheckedBoxBorderColor( window, info->borderColor );
  1477. info = TheDefaultScheme->getImageAndColor( RADIO_HILITE );
  1478. GadgetRadioSetHiliteImage( window, info->image );
  1479. GadgetRadioSetHiliteColor( window, info->color );
  1480. GadgetRadioSetHiliteBorderColor( window, info->borderColor );
  1481. info = TheDefaultScheme->getImageAndColor( RADIO_HILITE_UNCHECKED_BOX );
  1482. GadgetRadioSetHiliteUncheckedBoxImage( window, info->image );
  1483. GadgetRadioSetHiliteUncheckedBoxColor( window, info->color );
  1484. GadgetRadioSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
  1485. info = TheDefaultScheme->getImageAndColor( RADIO_HILITE_CHECKED_BOX );
  1486. GadgetRadioSetHiliteCheckedBoxImage( window, info->image );
  1487. GadgetRadioSetHiliteCheckedBoxColor( window, info->color );
  1488. GadgetRadioSetHiliteCheckedBoxBorderColor( window, info->borderColor );
  1489. Color color, border;
  1490. color = TheDefaultScheme->getEnabledTextColor();
  1491. border = TheDefaultScheme->getEnabledTextBorderColor();
  1492. window->winSetEnabledTextColors( color, border );
  1493. color = TheDefaultScheme->getDisabledTextColor();
  1494. border = TheDefaultScheme->getDisabledTextBorderColor();
  1495. window->winSetDisabledTextColors( color, border );
  1496. color = TheDefaultScheme->getHiliteTextColor();
  1497. border = TheDefaultScheme->getHiliteTextBorderColor();
  1498. window->winSetHiliteTextColors( color, border );
  1499. // set default font
  1500. window->winSetFont( TheDefaultScheme->getFont() );
  1501. } // end if
  1502. // contents have changed
  1503. setUnsaved( TRUE );
  1504. // notify the editor of the new window
  1505. notifyNewWindow( window );
  1506. return window;
  1507. } // end newRadioButton
  1508. // GUIEdit::newTabControl ====================================================
  1509. /** Create a tab control gadget */
  1510. //=============================================================================
  1511. GameWindow *GUIEdit::newTabControl( GameWindow *parent,
  1512. Int x, Int y, Int width, Int height )
  1513. {
  1514. TabControlData tabControlData;
  1515. GameWindow *window;
  1516. WinInstanceData instData;
  1517. UnsignedInt status = WIN_STATUS_ENABLED;
  1518. // validate the parent to disallow illegal relationships
  1519. if( validateParentForCreate( parent ) == FALSE )
  1520. return NULL;
  1521. // keep inside a parent if present
  1522. if( parent )
  1523. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1524. // initialize inst data
  1525. instData.init();
  1526. instData.m_style = GWS_TAB_CONTROL | GWS_MOUSE_TRACK;
  1527. memset( &tabControlData, 0, sizeof( tabControlData ) );
  1528. tabControlData.tabOrientation = TP_TOPLEFT;
  1529. tabControlData.tabEdge = TP_TOP_SIDE;
  1530. tabControlData.tabWidth = 50;
  1531. tabControlData.tabHeight = 25;
  1532. tabControlData.tabCount = 2;
  1533. tabControlData.paneBorder = 5;
  1534. // create gadget
  1535. window = TheWindowManager->gogoGadgetTabControl( parent,
  1536. status,
  1537. x, y,
  1538. width, height,
  1539. &instData,
  1540. &tabControlData,
  1541. NULL,
  1542. TRUE );
  1543. // set default colors based on the default scheme
  1544. if( window )
  1545. {
  1546. ImageAndColorInfo *info;
  1547. info = TheDefaultScheme->getImageAndColor( TC_TAB_0_ENABLED );
  1548. GadgetTabControlSetEnabledImageTabZero( window, info->image );
  1549. GadgetTabControlSetEnabledColorTabZero( window, info->color );
  1550. GadgetTabControlSetEnabledBorderColorTabZero( window, info->borderColor );
  1551. info = TheDefaultScheme->getImageAndColor( TC_TAB_1_ENABLED );
  1552. GadgetTabControlSetEnabledImageTabOne( window, info->image );
  1553. GadgetTabControlSetEnabledColorTabOne( window, info->color );
  1554. GadgetTabControlSetEnabledBorderColorTabOne( window, info->borderColor );
  1555. info = TheDefaultScheme->getImageAndColor( TC_TAB_2_ENABLED );
  1556. GadgetTabControlSetEnabledImageTabTwo( window, info->image );
  1557. GadgetTabControlSetEnabledColorTabTwo( window, info->color );
  1558. GadgetTabControlSetEnabledBorderColorTabTwo( window, info->borderColor );
  1559. info = TheDefaultScheme->getImageAndColor( TC_TAB_3_ENABLED );
  1560. GadgetTabControlSetEnabledImageTabThree( window, info->image );
  1561. GadgetTabControlSetEnabledColorTabThree( window, info->color );
  1562. GadgetTabControlSetEnabledBorderColorTabThree( window, info->borderColor );
  1563. info = TheDefaultScheme->getImageAndColor( TC_TAB_4_ENABLED );
  1564. GadgetTabControlSetEnabledImageTabFour( window, info->image );
  1565. GadgetTabControlSetEnabledColorTabFour( window, info->color );
  1566. GadgetTabControlSetEnabledBorderColorTabFour( window, info->borderColor );
  1567. info = TheDefaultScheme->getImageAndColor( TC_TAB_5_ENABLED );
  1568. GadgetTabControlSetEnabledImageTabFive( window, info->image );
  1569. GadgetTabControlSetEnabledColorTabFive( window, info->color );
  1570. GadgetTabControlSetEnabledBorderColorTabFive( window, info->borderColor );
  1571. info = TheDefaultScheme->getImageAndColor( TC_TAB_6_ENABLED );
  1572. GadgetTabControlSetEnabledImageTabSix( window, info->image );
  1573. GadgetTabControlSetEnabledColorTabSix( window, info->color );
  1574. GadgetTabControlSetEnabledBorderColorTabSix( window, info->borderColor );
  1575. info = TheDefaultScheme->getImageAndColor( TC_TAB_7_ENABLED );
  1576. GadgetTabControlSetEnabledImageTabSeven( window, info->image );
  1577. GadgetTabControlSetEnabledColorTabSeven( window, info->color );
  1578. GadgetTabControlSetEnabledBorderColorTabSeven( window, info->borderColor );
  1579. info = TheDefaultScheme->getImageAndColor( TAB_CONTROL_ENABLED );
  1580. GadgetTabControlSetEnabledImageBackground( window, info->image );
  1581. GadgetTabControlSetEnabledColorBackground( window, info->color );
  1582. GadgetTabControlSetEnabledBorderColorBackground( window, info->borderColor );
  1583. info = TheDefaultScheme->getImageAndColor( TC_TAB_0_DISABLED );
  1584. GadgetTabControlSetDisabledImageTabZero( window, info->image );
  1585. GadgetTabControlSetDisabledColorTabZero( window, info->color );
  1586. GadgetTabControlSetDisabledBorderColorTabZero( window, info->borderColor );
  1587. info = TheDefaultScheme->getImageAndColor( TC_TAB_1_DISABLED );
  1588. GadgetTabControlSetDisabledImageTabOne( window, info->image );
  1589. GadgetTabControlSetDisabledColorTabOne( window, info->color );
  1590. GadgetTabControlSetDisabledBorderColorTabOne( window, info->borderColor );
  1591. info = TheDefaultScheme->getImageAndColor( TC_TAB_2_DISABLED );
  1592. GadgetTabControlSetDisabledImageTabTwo( window, info->image );
  1593. GadgetTabControlSetDisabledColorTabTwo( window, info->color );
  1594. GadgetTabControlSetDisabledBorderColorTabTwo( window, info->borderColor );
  1595. info = TheDefaultScheme->getImageAndColor( TC_TAB_3_DISABLED );
  1596. GadgetTabControlSetDisabledImageTabThree( window, info->image );
  1597. GadgetTabControlSetDisabledColorTabThree( window, info->color );
  1598. GadgetTabControlSetDisabledBorderColorTabThree( window, info->borderColor );
  1599. info = TheDefaultScheme->getImageAndColor( TC_TAB_4_DISABLED );
  1600. GadgetTabControlSetDisabledImageTabFour( window, info->image );
  1601. GadgetTabControlSetDisabledColorTabFour( window, info->color );
  1602. GadgetTabControlSetDisabledBorderColorTabFour( window, info->borderColor );
  1603. info = TheDefaultScheme->getImageAndColor( TC_TAB_5_DISABLED );
  1604. GadgetTabControlSetDisabledImageTabFive( window, info->image );
  1605. GadgetTabControlSetDisabledColorTabFive( window, info->color );
  1606. GadgetTabControlSetDisabledBorderColorTabFive( window, info->borderColor );
  1607. info = TheDefaultScheme->getImageAndColor( TC_TAB_6_DISABLED );
  1608. GadgetTabControlSetDisabledImageTabSix( window, info->image );
  1609. GadgetTabControlSetDisabledColorTabSix( window, info->color );
  1610. GadgetTabControlSetDisabledBorderColorTabSix( window, info->borderColor );
  1611. info = TheDefaultScheme->getImageAndColor( TC_TAB_7_DISABLED );
  1612. GadgetTabControlSetDisabledImageTabSeven( window, info->image );
  1613. GadgetTabControlSetDisabledColorTabSeven( window, info->color );
  1614. GadgetTabControlSetDisabledBorderColorTabSeven( window, info->borderColor );
  1615. info = TheDefaultScheme->getImageAndColor( TAB_CONTROL_DISABLED );
  1616. GadgetTabControlSetDisabledImageBackground( window, info->image );
  1617. GadgetTabControlSetDisabledColorBackground( window, info->color );
  1618. GadgetTabControlSetDisabledBorderColorBackground( window, info->borderColor );
  1619. info = TheDefaultScheme->getImageAndColor( TC_TAB_0_HILITE );
  1620. GadgetTabControlSetHiliteImageTabZero( window, info->image );
  1621. GadgetTabControlSetHiliteColorTabZero( window, info->color );
  1622. GadgetTabControlSetHiliteBorderColorTabZero( window, info->borderColor );
  1623. info = TheDefaultScheme->getImageAndColor( TC_TAB_1_HILITE );
  1624. GadgetTabControlSetHiliteImageTabOne( window, info->image );
  1625. GadgetTabControlSetHiliteColorTabOne( window, info->color );
  1626. GadgetTabControlSetHiliteBorderColorTabOne( window, info->borderColor );
  1627. info = TheDefaultScheme->getImageAndColor( TC_TAB_2_HILITE );
  1628. GadgetTabControlSetHiliteImageTabTwo( window, info->image );
  1629. GadgetTabControlSetHiliteColorTabTwo( window, info->color );
  1630. GadgetTabControlSetHiliteBorderColorTabTwo( window, info->borderColor );
  1631. info = TheDefaultScheme->getImageAndColor( TC_TAB_3_HILITE );
  1632. GadgetTabControlSetHiliteImageTabThree( window, info->image );
  1633. GadgetTabControlSetHiliteColorTabThree( window, info->color );
  1634. GadgetTabControlSetHiliteBorderColorTabThree( window, info->borderColor );
  1635. info = TheDefaultScheme->getImageAndColor( TC_TAB_4_HILITE );
  1636. GadgetTabControlSetHiliteImageTabFour( window, info->image );
  1637. GadgetTabControlSetHiliteColorTabFour( window, info->color );
  1638. GadgetTabControlSetHiliteBorderColorTabFour( window, info->borderColor );
  1639. info = TheDefaultScheme->getImageAndColor( TC_TAB_5_HILITE );
  1640. GadgetTabControlSetHiliteImageTabFive( window, info->image );
  1641. GadgetTabControlSetHiliteColorTabFive( window, info->color );
  1642. GadgetTabControlSetHiliteBorderColorTabFive( window, info->borderColor );
  1643. info = TheDefaultScheme->getImageAndColor( TC_TAB_6_HILITE );
  1644. GadgetTabControlSetHiliteImageTabSix( window, info->image );
  1645. GadgetTabControlSetHiliteColorTabSix( window, info->color );
  1646. GadgetTabControlSetHiliteBorderColorTabSix( window, info->borderColor );
  1647. info = TheDefaultScheme->getImageAndColor( TC_TAB_7_HILITE );
  1648. GadgetTabControlSetHiliteImageTabSeven( window, info->image );
  1649. GadgetTabControlSetHiliteColorTabSeven( window, info->color );
  1650. GadgetTabControlSetHiliteBorderColorTabSeven( window, info->borderColor );
  1651. info = TheDefaultScheme->getImageAndColor( TAB_CONTROL_HILITE );
  1652. GadgetTabControlSetHiliteImageBackground( window, info->image );
  1653. GadgetTabControlSetHiliteColorBackground( window, info->color );
  1654. GadgetTabControlSetHiliteBorderColorBackground( window, info->borderColor );
  1655. } // end if
  1656. // contents have changed
  1657. setUnsaved( TRUE );
  1658. // notify the editor of the new window
  1659. notifyNewWindow( window );
  1660. return window;
  1661. } // end newTabControl
  1662. // GUIEdit::newHorizontalSlider ===============================================
  1663. /** Create a new horizontal slider*/
  1664. //=============================================================================
  1665. GameWindow *GUIEdit::newHorizontalSlider( GameWindow *parent,
  1666. Int x, Int y,
  1667. Int width, Int height )
  1668. {
  1669. GameWindow *window;
  1670. WinInstanceData instData;
  1671. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1672. // validate the parent to disallow illegal relationships
  1673. if( validateParentForCreate( parent ) == FALSE )
  1674. return NULL;
  1675. // keep inside a parent if present
  1676. if( parent )
  1677. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1678. // initialize inst data
  1679. instData.init();
  1680. instData.m_style = GWS_HORZ_SLIDER | GWS_MOUSE_TRACK;
  1681. // initialize slider data
  1682. SliderData sliderData;
  1683. memset( &sliderData, 0, sizeof( sliderData ) );
  1684. sliderData.maxVal = 100;
  1685. sliderData.minVal = 0;
  1686. sliderData.numTicks = 100;
  1687. sliderData.position = 0;
  1688. // make control
  1689. window = TheWindowManager->gogoGadgetSlider( parent,
  1690. status,
  1691. x, y,
  1692. width, height,
  1693. &instData,
  1694. &sliderData,
  1695. NULL,
  1696. TRUE );
  1697. // set default colors based on the default scheme
  1698. if( window )
  1699. {
  1700. ImageAndColorInfo *info;
  1701. info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_LEFT );
  1702. GadgetSliderSetEnabledImageLeft( window, info->image );
  1703. GadgetSliderSetEnabledColor( window, info->color );
  1704. GadgetSliderSetEnabledBorderColor( window, info->borderColor );
  1705. info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_RIGHT );
  1706. GadgetSliderSetEnabledImageRight( window, info->image );
  1707. info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_CENTER );
  1708. GadgetSliderSetEnabledImageCenter( window, info->image );
  1709. info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_SMALL_CENTER );
  1710. GadgetSliderSetEnabledImageSmallCenter( window, info->image );
  1711. info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_LEFT );
  1712. GadgetSliderSetDisabledImageLeft( window, info->image );
  1713. GadgetSliderSetDisabledColor( window, info->color );
  1714. GadgetSliderSetDisabledBorderColor( window, info->borderColor );
  1715. info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_RIGHT );
  1716. GadgetSliderSetDisabledImageRight( window, info->image );
  1717. info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_CENTER );
  1718. GadgetSliderSetDisabledImageCenter( window, info->image );
  1719. info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_SMALL_CENTER );
  1720. GadgetSliderSetDisabledImageSmallCenter( window, info->image );
  1721. info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_LEFT );
  1722. GadgetSliderSetHiliteImageLeft( window, info->image );
  1723. GadgetSliderSetHiliteColor( window, info->color );
  1724. GadgetSliderSetHiliteBorderColor( window, info->borderColor );
  1725. info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_RIGHT );
  1726. GadgetSliderSetHiliteImageRight( window, info->image );
  1727. info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_CENTER );
  1728. GadgetSliderSetHiliteImageCenter( window, info->image );
  1729. info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_SMALL_CENTER );
  1730. GadgetSliderSetHiliteImageSmallCenter( window, info->image );
  1731. info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_ENABLED );
  1732. GadgetSliderSetEnabledThumbImage( window, info->image );
  1733. GadgetSliderSetEnabledThumbColor( window, info->color );
  1734. GadgetSliderSetEnabledThumbBorderColor( window, info->borderColor );
  1735. info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_ENABLED_PUSHED );
  1736. GadgetSliderSetEnabledSelectedThumbImage( window, info->image );
  1737. GadgetSliderSetEnabledSelectedThumbColor( window, info->color );
  1738. GadgetSliderSetEnabledSelectedThumbBorderColor( window, info->borderColor );
  1739. info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_DISABLED );
  1740. GadgetSliderSetDisabledThumbImage( window, info->image );
  1741. GadgetSliderSetDisabledThumbColor( window, info->color );
  1742. GadgetSliderSetDisabledThumbBorderColor( window, info->borderColor );
  1743. info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_DISABLED_PUSHED );
  1744. GadgetSliderSetDisabledSelectedThumbImage( window, info->image );
  1745. GadgetSliderSetDisabledSelectedThumbColor( window, info->color );
  1746. GadgetSliderSetDisabledSelectedThumbBorderColor( window, info->borderColor );
  1747. info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_HILITE );
  1748. GadgetSliderSetHiliteThumbImage( window, info->image );
  1749. GadgetSliderSetHiliteThumbColor( window, info->color );
  1750. GadgetSliderSetHiliteThumbBorderColor( window, info->borderColor );
  1751. info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_HILITE_PUSHED );
  1752. GadgetSliderSetHiliteSelectedThumbImage( window, info->image );
  1753. GadgetSliderSetHiliteSelectedThumbColor( window, info->color );
  1754. GadgetSliderSetHiliteSelectedThumbBorderColor( window, info->borderColor );
  1755. // set default font
  1756. window->winSetFont( TheDefaultScheme->getFont() );
  1757. } // end if
  1758. // contents have changed
  1759. setUnsaved( TRUE );
  1760. // notify the editor of the new window
  1761. notifyNewWindow( window );
  1762. return window;
  1763. } // end newHorizontalSlider
  1764. // GUIEdit::newVerticlaSlider =================================================
  1765. /** Create a new vertical slider */
  1766. //=============================================================================
  1767. GameWindow *GUIEdit::newVerticalSlider( GameWindow *parent,
  1768. Int x, Int y,
  1769. Int width, Int height )
  1770. {
  1771. GameWindow *window;
  1772. WinInstanceData instData;
  1773. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1774. // validate the parent to disallow illegal relationships
  1775. if( validateParentForCreate( parent ) == FALSE )
  1776. return NULL;
  1777. // keep inside a parent if present
  1778. if( parent )
  1779. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1780. // initialize inst data
  1781. instData.init();
  1782. instData.m_style = GWS_VERT_SLIDER | GWS_MOUSE_TRACK;
  1783. // initialize slider data
  1784. SliderData sliderData;
  1785. memset( &sliderData, 0, sizeof( sliderData ) );
  1786. sliderData.maxVal = 100;
  1787. sliderData.minVal = 0;
  1788. sliderData.numTicks = 100;
  1789. sliderData.position = 0;
  1790. // make control
  1791. window = TheWindowManager->gogoGadgetSlider( parent,
  1792. status,
  1793. x, y,
  1794. width, height,
  1795. &instData,
  1796. &sliderData,
  1797. NULL,
  1798. TRUE );
  1799. // set default colors based on the default scheme
  1800. if( window )
  1801. {
  1802. ImageAndColorInfo *info;
  1803. info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_TOP );
  1804. GadgetSliderSetEnabledImageLeft( window, info->image );
  1805. GadgetSliderSetEnabledColor( window, info->color );
  1806. GadgetSliderSetEnabledBorderColor( window, info->borderColor );
  1807. info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_BOTTOM );
  1808. GadgetSliderSetEnabledImageRight( window, info->image );
  1809. info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_CENTER );
  1810. GadgetSliderSetEnabledImageCenter( window, info->image );
  1811. info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_SMALL_CENTER );
  1812. GadgetSliderSetEnabledImageSmallCenter( window, info->image );
  1813. info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_TOP );
  1814. GadgetSliderSetDisabledImageLeft( window, info->image );
  1815. GadgetSliderSetDisabledColor( window, info->color );
  1816. GadgetSliderSetDisabledBorderColor( window, info->borderColor );
  1817. info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_BOTTOM );
  1818. GadgetSliderSetDisabledImageRight( window, info->image );
  1819. info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_CENTER );
  1820. GadgetSliderSetDisabledImageCenter( window, info->image );
  1821. info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_SMALL_CENTER );
  1822. GadgetSliderSetDisabledImageSmallCenter( window, info->image );
  1823. info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_TOP );
  1824. GadgetSliderSetHiliteImageLeft( window, info->image );
  1825. GadgetSliderSetHiliteColor( window, info->color );
  1826. GadgetSliderSetHiliteBorderColor( window, info->borderColor );
  1827. info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_BOTTOM );
  1828. GadgetSliderSetHiliteImageRight( window, info->image );
  1829. info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_CENTER );
  1830. GadgetSliderSetHiliteImageCenter( window, info->image );
  1831. info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_SMALL_CENTER );
  1832. GadgetSliderSetHiliteImageSmallCenter( window, info->image );
  1833. info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_ENABLED );
  1834. GadgetSliderSetEnabledThumbImage( window, info->image );
  1835. GadgetSliderSetEnabledThumbColor( window, info->color );
  1836. GadgetSliderSetEnabledThumbBorderColor( window, info->borderColor );
  1837. info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_ENABLED_PUSHED );
  1838. GadgetSliderSetEnabledSelectedThumbImage( window, info->image );
  1839. GadgetSliderSetEnabledSelectedThumbColor( window, info->color );
  1840. GadgetSliderSetEnabledSelectedThumbBorderColor( window, info->borderColor );
  1841. info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_DISABLED );
  1842. GadgetSliderSetDisabledThumbImage( window, info->image );
  1843. GadgetSliderSetDisabledThumbColor( window, info->color );
  1844. GadgetSliderSetDisabledThumbBorderColor( window, info->borderColor );
  1845. info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_DISABLED_PUSHED );
  1846. GadgetSliderSetDisabledSelectedThumbImage( window, info->image );
  1847. GadgetSliderSetDisabledSelectedThumbColor( window, info->color );
  1848. GadgetSliderSetDisabledSelectedThumbBorderColor( window, info->borderColor );
  1849. info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_HILITE );
  1850. GadgetSliderSetHiliteThumbImage( window, info->image );
  1851. GadgetSliderSetHiliteThumbColor( window, info->color );
  1852. GadgetSliderSetHiliteThumbBorderColor( window, info->borderColor );
  1853. info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_HILITE_PUSHED );
  1854. GadgetSliderSetHiliteSelectedThumbImage( window, info->image );
  1855. GadgetSliderSetHiliteSelectedThumbColor( window, info->color );
  1856. GadgetSliderSetHiliteSelectedThumbBorderColor( window, info->borderColor );
  1857. // set default font
  1858. window->winSetFont( TheDefaultScheme->getFont() );
  1859. } // end if
  1860. // contents have changed
  1861. setUnsaved( TRUE );
  1862. // notify the editor of the new window
  1863. notifyNewWindow( window );
  1864. return window;
  1865. } // end newVerticalSlider
  1866. // GUIEdit::newProgressBar ====================================================
  1867. /** Create a new progress bar */
  1868. //=============================================================================
  1869. GameWindow *GUIEdit::newProgressBar( GameWindow *parent,
  1870. Int x, Int y,
  1871. Int width, Int height )
  1872. {
  1873. GameWindow *window;
  1874. WinInstanceData instData;
  1875. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1876. // validate the parent to disallow illegal relationships
  1877. if( validateParentForCreate( parent ) == FALSE )
  1878. return NULL;
  1879. // keep inside a parent if present
  1880. if( parent )
  1881. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1882. // initialize inst data
  1883. instData.init();
  1884. instData.m_style = GWS_PROGRESS_BAR | GWS_MOUSE_TRACK;
  1885. // make control
  1886. window = TheWindowManager->gogoGadgetProgressBar( parent,
  1887. status,
  1888. x, y,
  1889. width, height,
  1890. &instData,
  1891. NULL,
  1892. TRUE );
  1893. // set default colors based on the default scheme
  1894. if( window )
  1895. {
  1896. ImageAndColorInfo *info;
  1897. //-------------------------------------------------------------------------
  1898. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_LEFT );
  1899. GadgetProgressBarSetEnabledImageLeft( window, info->image );
  1900. GadgetProgressBarSetEnabledColor( window, info->color );
  1901. GadgetProgressBarSetEnabledBorderColor( window, info->borderColor );
  1902. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_RIGHT );
  1903. GadgetProgressBarSetEnabledImageRight( window, info->image );
  1904. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_CENTER );
  1905. GadgetProgressBarSetEnabledImageCenter( window, info->image );
  1906. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_SMALL_CENTER );
  1907. GadgetProgressBarSetEnabledImageSmallCenter( window, info->image );
  1908. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_LEFT );
  1909. GadgetProgressBarSetEnabledBarImageLeft( window, info->image );
  1910. GadgetProgressBarSetEnabledBarColor( window, info->color );
  1911. GadgetProgressBarSetEnabledBarBorderColor( window, info->borderColor );
  1912. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_RIGHT );
  1913. GadgetProgressBarSetEnabledBarImageRight( window, info->image );
  1914. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_CENTER );
  1915. GadgetProgressBarSetEnabledBarImageCenter( window, info->image );
  1916. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_SMALL_CENTER );
  1917. GadgetProgressBarSetEnabledBarImageSmallCenter( window, info->image );
  1918. //-------------------------------------------------------------------------
  1919. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_LEFT );
  1920. GadgetProgressBarSetDisabledImageLeft( window, info->image );
  1921. GadgetProgressBarSetDisabledColor( window, info->color );
  1922. GadgetProgressBarSetDisabledBorderColor( window, info->borderColor );
  1923. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_RIGHT );
  1924. GadgetProgressBarSetDisabledImageRight( window, info->image );
  1925. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_CENTER );
  1926. GadgetProgressBarSetDisabledImageCenter( window, info->image );
  1927. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_SMALL_CENTER );
  1928. GadgetProgressBarSetDisabledImageSmallCenter( window, info->image );
  1929. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_LEFT );
  1930. GadgetProgressBarSetDisabledBarImageLeft( window, info->image );
  1931. GadgetProgressBarSetDisabledBarColor( window, info->color );
  1932. GadgetProgressBarSetDisabledBarBorderColor( window, info->borderColor );
  1933. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_RIGHT );
  1934. GadgetProgressBarSetDisabledBarImageRight( window, info->image );
  1935. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_CENTER );
  1936. GadgetProgressBarSetDisabledBarImageCenter( window, info->image );
  1937. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_SMALL_CENTER );
  1938. GadgetProgressBarSetDisabledBarImageSmallCenter( window, info->image );
  1939. //-------------------------------------------------------------------------
  1940. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_LEFT );
  1941. GadgetProgressBarSetHiliteImageLeft( window, info->image );
  1942. GadgetProgressBarSetHiliteColor( window, info->color );
  1943. GadgetProgressBarSetHiliteBorderColor( window, info->borderColor );
  1944. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_RIGHT );
  1945. GadgetProgressBarSetHiliteImageRight( window, info->image );
  1946. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_CENTER );
  1947. GadgetProgressBarSetHiliteImageCenter( window, info->image );
  1948. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_SMALL_CENTER );
  1949. GadgetProgressBarSetHiliteImageSmallCenter( window, info->image );
  1950. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_LEFT );
  1951. GadgetProgressBarSetHiliteBarImageLeft( window, info->image );
  1952. GadgetProgressBarSetHiliteBarColor( window, info->color );
  1953. GadgetProgressBarSetHiliteBarBorderColor( window, info->borderColor );
  1954. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_RIGHT );
  1955. GadgetProgressBarSetHiliteBarImageRight( window, info->image );
  1956. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_CENTER );
  1957. GadgetProgressBarSetHiliteBarImageCenter( window, info->image );
  1958. info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_SMALL_CENTER );
  1959. GadgetProgressBarSetHiliteBarImageSmallCenter( window, info->image );
  1960. Color color, border;
  1961. color = TheDefaultScheme->getEnabledTextColor();
  1962. border = TheDefaultScheme->getEnabledTextBorderColor();
  1963. window->winSetEnabledTextColors( color, border );
  1964. color = TheDefaultScheme->getDisabledTextColor();
  1965. border = TheDefaultScheme->getDisabledTextBorderColor();
  1966. window->winSetDisabledTextColors( color, border );
  1967. color = TheDefaultScheme->getHiliteTextColor();
  1968. border = TheDefaultScheme->getHiliteTextBorderColor();
  1969. window->winSetHiliteTextColors( color, border );
  1970. // set default font
  1971. window->winSetFont( TheDefaultScheme->getFont() );
  1972. } // end if
  1973. // contents have changed
  1974. setUnsaved( TRUE );
  1975. // notify the editor of the new window
  1976. notifyNewWindow( window );
  1977. return window;
  1978. } // end newProgressBar
  1979. // GUIEdit::newListbox ========================================================
  1980. /** Create a new list box */
  1981. //=============================================================================
  1982. GameWindow *GUIEdit::newComboBox( GameWindow *parent,
  1983. Int x, Int y,
  1984. Int width, Int height )
  1985. {
  1986. GameWindow *window;
  1987. WinInstanceData instData;
  1988. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  1989. // validate the parent to disallow illegal relationships
  1990. if( validateParentForCreate( parent ) == FALSE )
  1991. return NULL;
  1992. // keep inside a parent if present
  1993. if( parent )
  1994. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  1995. // initialize inst data
  1996. instData.init();
  1997. instData.m_style = GWS_COMBO_BOX | GWS_MOUSE_TRACK;
  1998. //initialize combo box data
  1999. ComboBoxData *comboData = new ComboBoxData;
  2000. memset ( comboData, 0, sizeof(comboData));
  2001. comboData->entryData = new EntryData;
  2002. memset ( comboData->entryData, 0, sizeof(EntryData));
  2003. comboData->listboxData = new ListboxData;
  2004. memset ( comboData->listboxData, 0, sizeof(ListboxData));
  2005. //initialize combo box data
  2006. comboData->isEditable = TRUE;
  2007. comboData->maxChars = 16;
  2008. comboData->maxDisplay = 5;
  2009. comboData->entryCount = 0;
  2010. comboData->dontHide = FALSE;
  2011. comboData->asciiOnly = FALSE;
  2012. comboData->lettersAndNumbersOnly = FALSE;
  2013. //initialize entry data
  2014. comboData->entryData->maxTextLen = 16;
  2015. comboData->entryData->alphaNumericalOnly = FALSE;
  2016. comboData->entryData->aSCIIOnly = FALSE;
  2017. comboData->entryData->numericalOnly = FALSE;
  2018. //initialize listbox data
  2019. comboData->listboxData->listLength = 10;
  2020. comboData->listboxData->autoScroll = 0;
  2021. comboData->listboxData->scrollIfAtEnd = FALSE;
  2022. comboData->listboxData->autoPurge = 0;
  2023. comboData->listboxData->scrollBar = 1;
  2024. comboData->listboxData->multiSelect = 0;
  2025. comboData->listboxData->forceSelect = 1;
  2026. comboData->listboxData->columns = 1;
  2027. comboData->listboxData->columnWidth = NULL;
  2028. comboData->listboxData->columnWidthPercentage = NULL;
  2029. //create the control
  2030. window = TheWindowManager->gogoGadgetComboBox( parent,
  2031. status,
  2032. x, y,
  2033. width, height,
  2034. &instData,
  2035. comboData,
  2036. NULL,
  2037. TRUE );
  2038. // set default colors based on the default scheme
  2039. if( window )
  2040. {
  2041. ImageAndColorInfo *info;
  2042. info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED );
  2043. GadgetComboBoxSetEnabledImage( window, info->image );
  2044. GadgetComboBoxSetEnabledColor( window, info->color );
  2045. GadgetComboBoxSetEnabledBorderColor( window, info->borderColor );
  2046. info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_LEFT );
  2047. GadgetComboBoxSetEnabledSelectedItemImageLeft( window, info->image );
  2048. GadgetComboBoxSetEnabledSelectedItemColor( window, info->color );
  2049. GadgetComboBoxSetEnabledSelectedItemBorderColor( window, info->borderColor );
  2050. info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_RIGHT );
  2051. GadgetComboBoxSetEnabledSelectedItemImageRight( window, info->image );
  2052. info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_CENTER );
  2053. GadgetComboBoxSetEnabledSelectedItemImageCenter( window, info->image );
  2054. info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
  2055. GadgetComboBoxSetEnabledSelectedItemImageSmallCenter( window, info->image );
  2056. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED );
  2057. GadgetComboBoxSetDisabledImage( window, info->image );
  2058. GadgetComboBoxSetDisabledColor( window, info->color );
  2059. GadgetComboBoxSetDisabledBorderColor( window, info->borderColor );
  2060. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_LEFT );
  2061. GadgetComboBoxSetDisabledSelectedItemImageLeft( window, info->image );
  2062. GadgetComboBoxSetDisabledSelectedItemColor( window, info->color );
  2063. GadgetComboBoxSetDisabledSelectedItemBorderColor( window, info->borderColor );
  2064. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_RIGHT );
  2065. GadgetComboBoxSetDisabledSelectedItemImageRight( window, info->image );
  2066. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_CENTER );
  2067. GadgetComboBoxSetDisabledSelectedItemImageCenter( window, info->image );
  2068. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
  2069. GadgetComboBoxSetDisabledSelectedItemImageSmallCenter( window, info->image );
  2070. info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE );
  2071. GadgetComboBoxSetHiliteImage( window, info->image );
  2072. GadgetComboBoxSetHiliteColor( window, info->color );
  2073. GadgetComboBoxSetHiliteBorderColor( window, info->borderColor );
  2074. info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_LEFT );
  2075. GadgetComboBoxSetHiliteSelectedItemImageLeft( window, info->image );
  2076. GadgetComboBoxSetHiliteSelectedItemColor( window, info->color );
  2077. GadgetComboBoxSetHiliteSelectedItemBorderColor( window, info->borderColor );
  2078. info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_RIGHT );
  2079. GadgetComboBoxSetHiliteSelectedItemImageRight( window, info->image );
  2080. info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_CENTER );
  2081. GadgetComboBoxSetHiliteSelectedItemImageCenter( window, info->image );
  2082. info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
  2083. GadgetComboBoxSetHiliteSelectedItemImageSmallCenter( window, info->image );
  2084. GameWindow *editBox = GadgetComboBoxGetEditBox( window );
  2085. if(editBox)
  2086. {
  2087. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_LEFT );
  2088. GadgetTextEntrySetEnabledImageLeft( editBox, info->image );
  2089. GadgetTextEntrySetEnabledColor( editBox, info->color );
  2090. GadgetTextEntrySetEnabledBorderColor( editBox, info->borderColor );
  2091. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_RIGHT );
  2092. GadgetTextEntrySetEnabledImageRight( editBox, info->image );
  2093. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_CENTER );
  2094. GadgetTextEntrySetEnabledImageCenter( editBox, info->image );
  2095. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_SMALL_CENTER );
  2096. GadgetTextEntrySetEnabledImageSmallCenter( editBox, info->image );
  2097. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_LEFT );
  2098. GadgetTextEntrySetDisabledImageLeft( editBox, info->image );
  2099. GadgetTextEntrySetDisabledColor( editBox, info->color );
  2100. GadgetTextEntrySetDisabledBorderColor( editBox, info->borderColor );
  2101. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_RIGHT );
  2102. GadgetTextEntrySetDisabledImageRight( editBox, info->image );
  2103. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_CENTER );
  2104. GadgetTextEntrySetDisabledImageCenter( editBox, info->image );
  2105. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_SMALL_CENTER );
  2106. GadgetTextEntrySetDisabledImageSmallCenter( editBox, info->image );
  2107. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_LEFT );
  2108. GadgetTextEntrySetHiliteImageLeft( editBox, info->image );
  2109. GadgetTextEntrySetHiliteColor( window, info->color );
  2110. GadgetTextEntrySetHiliteBorderColor( editBox, info->borderColor );
  2111. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_RIGHT );
  2112. GadgetTextEntrySetHiliteImageRight( editBox, info->image );
  2113. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_CENTER );
  2114. GadgetTextEntrySetHiliteImageCenter( editBox, info->image );
  2115. info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_SMALL_CENTER );
  2116. GadgetTextEntrySetHiliteImageSmallCenter( editBox, info->image );
  2117. }
  2118. GameWindow *listBox = GadgetComboBoxGetListBox( window );
  2119. if(listBox)
  2120. {
  2121. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED );
  2122. GadgetListBoxSetEnabledImage( listBox, info->image );
  2123. GadgetListBoxSetEnabledColor( listBox, info->color );
  2124. GadgetListBoxSetEnabledBorderColor( listBox, info->borderColor );
  2125. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
  2126. GadgetListBoxSetEnabledSelectedItemImageLeft( listBox, info->image );
  2127. GadgetListBoxSetEnabledSelectedItemColor( listBox, info->color );
  2128. GadgetListBoxSetEnabledSelectedItemBorderColor( listBox, info->borderColor );
  2129. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_RIGHT );
  2130. GadgetListBoxSetEnabledSelectedItemImageRight( listBox, info->image );
  2131. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_CENTER );
  2132. GadgetListBoxSetEnabledSelectedItemImageCenter( listBox, info->image );
  2133. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
  2134. GadgetListBoxSetEnabledSelectedItemImageSmallCenter( listBox, info->image );
  2135. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED );
  2136. GadgetListBoxSetDisabledImage( listBox, info->image );
  2137. GadgetListBoxSetDisabledColor( listBox, info->color );
  2138. GadgetListBoxSetDisabledBorderColor( listBox, info->borderColor );
  2139. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
  2140. GadgetListBoxSetDisabledSelectedItemImageLeft( listBox, info->image );
  2141. GadgetListBoxSetDisabledSelectedItemColor( listBox, info->color );
  2142. GadgetListBoxSetDisabledSelectedItemBorderColor( listBox, info->borderColor );
  2143. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_RIGHT );
  2144. GadgetListBoxSetDisabledSelectedItemImageRight( listBox, info->image );
  2145. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_CENTER );
  2146. GadgetListBoxSetDisabledSelectedItemImageCenter( listBox, info->image );
  2147. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
  2148. GadgetListBoxSetDisabledSelectedItemImageSmallCenter( listBox, info->image );
  2149. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE );
  2150. GadgetListBoxSetHiliteImage( listBox, info->image );
  2151. GadgetListBoxSetHiliteColor( listBox, info->color );
  2152. GadgetListBoxSetHiliteBorderColor( listBox, info->borderColor );
  2153. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_LEFT );
  2154. GadgetListBoxSetHiliteSelectedItemImageLeft( listBox, info->image );
  2155. GadgetListBoxSetHiliteSelectedItemColor( listBox, info->color );
  2156. GadgetListBoxSetHiliteSelectedItemBorderColor( listBox, info->borderColor );
  2157. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_RIGHT );
  2158. GadgetListBoxSetHiliteSelectedItemImageRight( listBox, info->image );
  2159. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_CENTER );
  2160. GadgetListBoxSetHiliteSelectedItemImageCenter( listBox, info->image );
  2161. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
  2162. GadgetListBoxSetHiliteSelectedItemImageSmallCenter( listBox, info->image );
  2163. GameWindow *upButton = GadgetListBoxGetUpButton( listBox );
  2164. if( upButton )
  2165. {
  2166. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED );
  2167. GadgetButtonSetEnabledImage( upButton, info->image );
  2168. GadgetButtonSetEnabledColor( upButton, info->color );
  2169. GadgetButtonSetEnabledBorderColor( upButton, info->borderColor );
  2170. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED_PUSHED );
  2171. GadgetButtonSetEnabledSelectedImage( upButton, info->image );
  2172. GadgetButtonSetEnabledSelectedColor( upButton, info->color );
  2173. GadgetButtonSetEnabledSelectedBorderColor( upButton, info->borderColor );
  2174. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED );
  2175. GadgetButtonSetDisabledImage( upButton, info->image );
  2176. GadgetButtonSetDisabledColor( upButton, info->color );
  2177. GadgetButtonSetDisabledBorderColor( upButton, info->borderColor );
  2178. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED_PUSHED );
  2179. GadgetButtonSetDisabledSelectedImage( upButton, info->image );
  2180. GadgetButtonSetDisabledSelectedColor( upButton, info->color );
  2181. GadgetButtonSetDisabledSelectedBorderColor( upButton, info->borderColor );
  2182. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE );
  2183. GadgetButtonSetHiliteImage( upButton, info->image );
  2184. GadgetButtonSetHiliteColor( upButton, info->color );
  2185. GadgetButtonSetHiliteBorderColor( upButton, info->borderColor );
  2186. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE_PUSHED );
  2187. GadgetButtonSetHiliteSelectedImage( upButton, info->image );
  2188. GadgetButtonSetHiliteSelectedColor( upButton, info->color );
  2189. GadgetButtonSetHiliteSelectedBorderColor( upButton, info->borderColor );
  2190. } // end if
  2191. GameWindow *downButton = GadgetListBoxGetDownButton( listBox );
  2192. if( downButton )
  2193. {
  2194. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED );
  2195. GadgetButtonSetEnabledImage( downButton, info->image );
  2196. GadgetButtonSetEnabledColor( downButton, info->color );
  2197. GadgetButtonSetEnabledBorderColor( downButton, info->borderColor );
  2198. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
  2199. GadgetButtonSetEnabledSelectedImage( downButton, info->image );
  2200. GadgetButtonSetEnabledSelectedColor( downButton, info->color );
  2201. GadgetButtonSetEnabledSelectedBorderColor( downButton, info->borderColor );
  2202. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED );
  2203. GadgetButtonSetDisabledImage( downButton, info->image );
  2204. GadgetButtonSetDisabledColor( downButton, info->color );
  2205. GadgetButtonSetDisabledBorderColor( downButton, info->borderColor );
  2206. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
  2207. GadgetButtonSetDisabledSelectedImage( downButton, info->image );
  2208. GadgetButtonSetDisabledSelectedColor( downButton, info->color );
  2209. GadgetButtonSetDisabledSelectedBorderColor( downButton, info->borderColor );
  2210. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE );
  2211. GadgetButtonSetHiliteImage( downButton, info->image );
  2212. GadgetButtonSetHiliteColor( downButton, info->color );
  2213. GadgetButtonSetHiliteBorderColor( downButton, info->borderColor );
  2214. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
  2215. GadgetButtonSetHiliteSelectedImage( downButton, info->image );
  2216. GadgetButtonSetHiliteSelectedColor( downButton, info->color );
  2217. GadgetButtonSetHiliteSelectedBorderColor( downButton, info->borderColor );
  2218. } // end if
  2219. GameWindow *slider = GadgetListBoxGetSlider( listBox );
  2220. if( slider )
  2221. {
  2222. // ----------------------------------------------------------------------
  2223. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_TOP );
  2224. GadgetSliderSetEnabledImageTop( slider, info->image );
  2225. GadgetSliderSetEnabledColor( slider, info->color );
  2226. GadgetSliderSetEnabledBorderColor( slider, info->borderColor );
  2227. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_BOTTOM );
  2228. GadgetSliderSetEnabledImageBottom( slider, info->image );
  2229. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_CENTER );
  2230. GadgetSliderSetEnabledImageCenter( slider, info->image );
  2231. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
  2232. GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
  2233. // ----------------------------------------------------------------------
  2234. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_TOP );
  2235. GadgetSliderSetDisabledImageTop( slider, info->image );
  2236. GadgetSliderSetDisabledColor( slider, info->color );
  2237. GadgetSliderSetDisabledBorderColor( slider, info->borderColor );
  2238. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_BOTTOM );
  2239. GadgetSliderSetDisabledImageBottom( slider, info->image );
  2240. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_CENTER );
  2241. GadgetSliderSetDisabledImageCenter( slider, info->image );
  2242. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
  2243. GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
  2244. // ----------------------------------------------------------------------
  2245. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_TOP );
  2246. GadgetSliderSetHiliteImageTop( slider, info->image );
  2247. GadgetSliderSetHiliteColor( slider, info->color );
  2248. GadgetSliderSetHiliteBorderColor( slider, info->borderColor );
  2249. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_BOTTOM );
  2250. GadgetSliderSetHiliteImageBottom( slider, info->image );
  2251. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_CENTER );
  2252. GadgetSliderSetHiliteImageCenter( slider, info->image );
  2253. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_SMALL_CENTER );
  2254. GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
  2255. //-----------------------------------------------------------------------
  2256. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED );
  2257. GadgetSliderSetEnabledThumbImage( slider, info->image );
  2258. GadgetSliderSetEnabledThumbColor( slider, info->color );
  2259. GadgetSliderSetEnabledThumbBorderColor( slider, info->borderColor );
  2260. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
  2261. GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
  2262. GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
  2263. GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
  2264. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED );
  2265. GadgetSliderSetDisabledThumbImage( slider, info->image );
  2266. GadgetSliderSetDisabledThumbColor( slider, info->color );
  2267. GadgetSliderSetDisabledThumbBorderColor( slider, info->borderColor );
  2268. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
  2269. GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
  2270. GadgetSliderSetDisabledSelectedThumbColor( slider, info->color );
  2271. GadgetSliderSetDisabledSelectedThumbBorderColor( slider, info->borderColor );
  2272. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE );
  2273. GadgetSliderSetHiliteThumbImage( slider, info->image );
  2274. GadgetSliderSetHiliteThumbColor( slider, info->color );
  2275. GadgetSliderSetHiliteThumbBorderColor( slider, info->borderColor );
  2276. info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
  2277. GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
  2278. GadgetSliderSetHiliteSelectedThumbColor( slider, info->color );
  2279. GadgetSliderSetHiliteSelectedThumbBorderColor( slider, info->borderColor );
  2280. }
  2281. } //end listbox if
  2282. GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( window );
  2283. if( dropDownButton )
  2284. {
  2285. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED );
  2286. GadgetButtonSetEnabledImage( dropDownButton, info->image );
  2287. GadgetButtonSetEnabledColor( dropDownButton, info->color );
  2288. GadgetButtonSetEnabledBorderColor( dropDownButton, info->borderColor );
  2289. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED_PUSHED );
  2290. GadgetButtonSetEnabledSelectedImage( dropDownButton, info->image );
  2291. GadgetButtonSetEnabledSelectedColor( dropDownButton, info->color );
  2292. GadgetButtonSetEnabledSelectedBorderColor( dropDownButton, info->borderColor );
  2293. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED );
  2294. GadgetButtonSetDisabledImage( dropDownButton, info->image );
  2295. GadgetButtonSetDisabledColor( dropDownButton, info->color );
  2296. GadgetButtonSetDisabledBorderColor( dropDownButton, info->borderColor );
  2297. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED_PUSHED );
  2298. GadgetButtonSetDisabledSelectedImage( dropDownButton, info->image );
  2299. GadgetButtonSetDisabledSelectedColor( dropDownButton, info->color );
  2300. GadgetButtonSetDisabledSelectedBorderColor( dropDownButton, info->borderColor );
  2301. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE );
  2302. GadgetButtonSetHiliteImage( dropDownButton, info->image );
  2303. GadgetButtonSetHiliteColor( dropDownButton, info->color );
  2304. GadgetButtonSetHiliteBorderColor( dropDownButton, info->borderColor );
  2305. info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE_PUSHED );
  2306. GadgetButtonSetHiliteSelectedImage( dropDownButton, info->image );
  2307. GadgetButtonSetHiliteSelectedColor( dropDownButton, info->color );
  2308. GadgetButtonSetHiliteSelectedBorderColor( dropDownButton, info->borderColor );
  2309. } // end if
  2310. Color color, border;
  2311. color = TheDefaultScheme->getEnabledTextColor();
  2312. border = TheDefaultScheme->getEnabledTextBorderColor();
  2313. window->winSetEnabledTextColors( color, border );
  2314. color = TheDefaultScheme->getDisabledTextColor();
  2315. border = TheDefaultScheme->getDisabledTextBorderColor();
  2316. window->winSetDisabledTextColors( color, border );
  2317. color = TheDefaultScheme->getHiliteTextColor();
  2318. border = TheDefaultScheme->getHiliteTextBorderColor();
  2319. window->winSetHiliteTextColors( color, border );
  2320. /// @TODO: We still need to set the IME Composite Text colors in TheDefaultScheme
  2321. window->winSetIMECompositeTextColors( color, border );
  2322. // set default font
  2323. window->winSetFont( TheDefaultScheme->getFont() );
  2324. }// end if
  2325. // contents have changed
  2326. setUnsaved( TRUE );
  2327. // notify the editor of the new window
  2328. notifyNewWindow( window );
  2329. return window;
  2330. } // end newComboBox
  2331. // GUIEdit::newListbox ========================================================
  2332. /** Create a new list box */
  2333. //=============================================================================
  2334. GameWindow *GUIEdit::newListbox( GameWindow *parent,
  2335. Int x, Int y,
  2336. Int width, Int height )
  2337. {
  2338. GameWindow *window;
  2339. WinInstanceData instData;
  2340. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  2341. // validate the parent to disallow illegal relationships
  2342. if( validateParentForCreate( parent ) == FALSE )
  2343. return NULL;
  2344. // keep inside a parent if present
  2345. if( parent )
  2346. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  2347. // initialize inst data
  2348. instData.init();
  2349. instData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK;
  2350. // initialize listbox data
  2351. ListboxData listData;
  2352. memset( &listData, 0, sizeof( listData ) );
  2353. listData.listLength = 10;
  2354. listData.autoScroll = 0;
  2355. listData.scrollIfAtEnd = FALSE;
  2356. listData.autoPurge = 0;
  2357. listData.scrollBar = 1;
  2358. listData.multiSelect = 0;
  2359. listData.forceSelect = 0;
  2360. listData.columns = 1;
  2361. listData.columnWidth = NULL;
  2362. listData.columnWidthPercentage = NULL;
  2363. // make control
  2364. window = TheWindowManager->gogoGadgetListBox( parent,
  2365. status,
  2366. x, y,
  2367. width, height,
  2368. &instData,
  2369. &listData,
  2370. NULL,
  2371. TRUE );
  2372. // set default colors based on the default scheme
  2373. if( window )
  2374. {
  2375. ImageAndColorInfo *info;
  2376. info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED );
  2377. GadgetListBoxSetEnabledImage( window, info->image );
  2378. GadgetListBoxSetEnabledColor( window, info->color );
  2379. GadgetListBoxSetEnabledBorderColor( window, info->borderColor );
  2380. info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
  2381. GadgetListBoxSetEnabledSelectedItemImageLeft( window, info->image );
  2382. GadgetListBoxSetEnabledSelectedItemColor( window, info->color );
  2383. GadgetListBoxSetEnabledSelectedItemBorderColor( window, info->borderColor );
  2384. info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_RIGHT );
  2385. GadgetListBoxSetEnabledSelectedItemImageRight( window, info->image );
  2386. info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_CENTER );
  2387. GadgetListBoxSetEnabledSelectedItemImageCenter( window, info->image );
  2388. info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
  2389. GadgetListBoxSetEnabledSelectedItemImageSmallCenter( window, info->image );
  2390. info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED );
  2391. GadgetListBoxSetDisabledImage( window, info->image );
  2392. GadgetListBoxSetDisabledColor( window, info->color );
  2393. GadgetListBoxSetDisabledBorderColor( window, info->borderColor );
  2394. info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
  2395. GadgetListBoxSetDisabledSelectedItemImageLeft( window, info->image );
  2396. GadgetListBoxSetDisabledSelectedItemColor( window, info->color );
  2397. GadgetListBoxSetDisabledSelectedItemBorderColor( window, info->borderColor );
  2398. info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_RIGHT );
  2399. GadgetListBoxSetDisabledSelectedItemImageRight( window, info->image );
  2400. info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_CENTER );
  2401. GadgetListBoxSetDisabledSelectedItemImageCenter( window, info->image );
  2402. info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
  2403. GadgetListBoxSetDisabledSelectedItemImageSmallCenter( window, info->image );
  2404. info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE );
  2405. GadgetListBoxSetHiliteImage( window, info->image );
  2406. GadgetListBoxSetHiliteColor( window, info->color );
  2407. GadgetListBoxSetHiliteBorderColor( window, info->borderColor );
  2408. info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_LEFT );
  2409. GadgetListBoxSetHiliteSelectedItemImageLeft( window, info->image );
  2410. GadgetListBoxSetHiliteSelectedItemColor( window, info->color );
  2411. GadgetListBoxSetHiliteSelectedItemBorderColor( window, info->borderColor );
  2412. info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_RIGHT );
  2413. GadgetListBoxSetHiliteSelectedItemImageRight( window, info->image );
  2414. info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_CENTER );
  2415. GadgetListBoxSetHiliteSelectedItemImageCenter( window, info->image );
  2416. info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
  2417. GadgetListBoxSetHiliteSelectedItemImageSmallCenter( window, info->image );
  2418. GameWindow *upButton = GadgetListBoxGetUpButton( window );
  2419. if( upButton )
  2420. {
  2421. info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_ENABLED );
  2422. GadgetButtonSetEnabledImage( upButton, info->image );
  2423. GadgetButtonSetEnabledColor( upButton, info->color );
  2424. GadgetButtonSetEnabledBorderColor( upButton, info->borderColor );
  2425. info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_ENABLED_PUSHED );
  2426. GadgetButtonSetEnabledSelectedImage( upButton, info->image );
  2427. GadgetButtonSetEnabledSelectedColor( upButton, info->color );
  2428. GadgetButtonSetEnabledSelectedBorderColor( upButton, info->borderColor );
  2429. info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_DISABLED );
  2430. GadgetButtonSetDisabledImage( upButton, info->image );
  2431. GadgetButtonSetDisabledColor( upButton, info->color );
  2432. GadgetButtonSetDisabledBorderColor( upButton, info->borderColor );
  2433. info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_DISABLED_PUSHED );
  2434. GadgetButtonSetDisabledSelectedImage( upButton, info->image );
  2435. GadgetButtonSetDisabledSelectedColor( upButton, info->color );
  2436. GadgetButtonSetDisabledSelectedBorderColor( upButton, info->borderColor );
  2437. info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_HILITE );
  2438. GadgetButtonSetHiliteImage( upButton, info->image );
  2439. GadgetButtonSetHiliteColor( upButton, info->color );
  2440. GadgetButtonSetHiliteBorderColor( upButton, info->borderColor );
  2441. info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_HILITE_PUSHED );
  2442. GadgetButtonSetHiliteSelectedImage( upButton, info->image );
  2443. GadgetButtonSetHiliteSelectedColor( upButton, info->color );
  2444. GadgetButtonSetHiliteSelectedBorderColor( upButton, info->borderColor );
  2445. } // end if
  2446. GameWindow *downButton = GadgetListBoxGetDownButton( window );
  2447. if( downButton )
  2448. {
  2449. info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED );
  2450. GadgetButtonSetEnabledImage( downButton, info->image );
  2451. GadgetButtonSetEnabledColor( downButton, info->color );
  2452. GadgetButtonSetEnabledBorderColor( downButton, info->borderColor );
  2453. info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
  2454. GadgetButtonSetEnabledSelectedImage( downButton, info->image );
  2455. GadgetButtonSetEnabledSelectedColor( downButton, info->color );
  2456. GadgetButtonSetEnabledSelectedBorderColor( downButton, info->borderColor );
  2457. info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED );
  2458. GadgetButtonSetDisabledImage( downButton, info->image );
  2459. GadgetButtonSetDisabledColor( downButton, info->color );
  2460. GadgetButtonSetDisabledBorderColor( downButton, info->borderColor );
  2461. info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
  2462. GadgetButtonSetDisabledSelectedImage( downButton, info->image );
  2463. GadgetButtonSetDisabledSelectedColor( downButton, info->color );
  2464. GadgetButtonSetDisabledSelectedBorderColor( downButton, info->borderColor );
  2465. info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_HILITE );
  2466. GadgetButtonSetHiliteImage( downButton, info->image );
  2467. GadgetButtonSetHiliteColor( downButton, info->color );
  2468. GadgetButtonSetHiliteBorderColor( downButton, info->borderColor );
  2469. info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
  2470. GadgetButtonSetHiliteSelectedImage( downButton, info->image );
  2471. GadgetButtonSetHiliteSelectedColor( downButton, info->color );
  2472. GadgetButtonSetHiliteSelectedBorderColor( downButton, info->borderColor );
  2473. } // end if
  2474. GameWindow *slider = GadgetListBoxGetSlider( window );
  2475. if( slider )
  2476. {
  2477. // ----------------------------------------------------------------------
  2478. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_TOP );
  2479. GadgetSliderSetEnabledImageTop( slider, info->image );
  2480. GadgetSliderSetEnabledColor( slider, info->color );
  2481. GadgetSliderSetEnabledBorderColor( slider, info->borderColor );
  2482. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_BOTTOM );
  2483. GadgetSliderSetEnabledImageBottom( slider, info->image );
  2484. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_CENTER );
  2485. GadgetSliderSetEnabledImageCenter( slider, info->image );
  2486. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
  2487. GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
  2488. // ----------------------------------------------------------------------
  2489. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_TOP );
  2490. GadgetSliderSetDisabledImageTop( slider, info->image );
  2491. GadgetSliderSetDisabledColor( slider, info->color );
  2492. GadgetSliderSetDisabledBorderColor( slider, info->borderColor );
  2493. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_BOTTOM );
  2494. GadgetSliderSetDisabledImageBottom( slider, info->image );
  2495. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_CENTER );
  2496. GadgetSliderSetDisabledImageCenter( slider, info->image );
  2497. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
  2498. GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
  2499. // ----------------------------------------------------------------------
  2500. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_TOP );
  2501. GadgetSliderSetHiliteImageTop( slider, info->image );
  2502. GadgetSliderSetHiliteColor( slider, info->color );
  2503. GadgetSliderSetHiliteBorderColor( slider, info->borderColor );
  2504. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_BOTTOM );
  2505. GadgetSliderSetHiliteImageBottom( slider, info->image );
  2506. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_CENTER );
  2507. GadgetSliderSetHiliteImageCenter( slider, info->image );
  2508. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_SMALL_CENTER );
  2509. GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
  2510. //-----------------------------------------------------------------------
  2511. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED );
  2512. GadgetSliderSetEnabledThumbImage( slider, info->image );
  2513. GadgetSliderSetEnabledThumbColor( slider, info->color );
  2514. GadgetSliderSetEnabledThumbBorderColor( slider, info->borderColor );
  2515. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
  2516. GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
  2517. GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
  2518. GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
  2519. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED );
  2520. GadgetSliderSetDisabledThumbImage( slider, info->image );
  2521. GadgetSliderSetDisabledThumbColor( slider, info->color );
  2522. GadgetSliderSetDisabledThumbBorderColor( slider, info->borderColor );
  2523. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
  2524. GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
  2525. GadgetSliderSetDisabledSelectedThumbColor( slider, info->color );
  2526. GadgetSliderSetDisabledSelectedThumbBorderColor( slider, info->borderColor );
  2527. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_HILITE );
  2528. GadgetSliderSetHiliteThumbImage( slider, info->image );
  2529. GadgetSliderSetHiliteThumbColor( slider, info->color );
  2530. GadgetSliderSetHiliteThumbBorderColor( slider, info->borderColor );
  2531. info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
  2532. GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
  2533. GadgetSliderSetHiliteSelectedThumbColor( slider, info->color );
  2534. GadgetSliderSetHiliteSelectedThumbBorderColor( slider, info->borderColor );
  2535. } // end if, slider
  2536. Color color, border;
  2537. color = TheDefaultScheme->getEnabledTextColor();
  2538. border = TheDefaultScheme->getEnabledTextBorderColor();
  2539. window->winSetEnabledTextColors( color, border );
  2540. color = TheDefaultScheme->getDisabledTextColor();
  2541. border = TheDefaultScheme->getDisabledTextBorderColor();
  2542. window->winSetDisabledTextColors( color, border );
  2543. color = TheDefaultScheme->getHiliteTextColor();
  2544. border = TheDefaultScheme->getHiliteTextBorderColor();
  2545. window->winSetHiliteTextColors( color, border );
  2546. // set default font
  2547. window->winSetFont( TheDefaultScheme->getFont() );
  2548. } // end if
  2549. // contents have changed
  2550. setUnsaved( TRUE );
  2551. // notify the editor of the new window
  2552. notifyNewWindow( window );
  2553. return window;
  2554. } // end newListbox
  2555. // GUIEdit::newTextEntry ======================================================
  2556. /** Create a new text entry */
  2557. //=============================================================================
  2558. GameWindow *GUIEdit::newTextEntry( GameWindow *parent,
  2559. Int x, Int y,
  2560. Int width, Int height )
  2561. {
  2562. GameWindow *window;
  2563. WinInstanceData instData;
  2564. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  2565. // validate the parent to disallow illegal relationships
  2566. if( validateParentForCreate( parent ) == FALSE )
  2567. return NULL;
  2568. // keep inside a parent if present
  2569. if( parent )
  2570. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  2571. // initialize inst data
  2572. instData.init();
  2573. instData.m_style = GWS_ENTRY_FIELD | GWS_MOUSE_TRACK;
  2574. instData.m_textLabelString = "Entry";
  2575. // initialize listbox data
  2576. EntryData entryData;
  2577. memset( &entryData, 0, sizeof( entryData ) );
  2578. entryData.maxTextLen = 64;
  2579. // make control
  2580. window = TheWindowManager->gogoGadgetTextEntry( parent,
  2581. status,
  2582. x, y,
  2583. width, height,
  2584. &instData,
  2585. &entryData,
  2586. NULL,
  2587. TRUE );
  2588. // set default colors based on the default scheme
  2589. if( window )
  2590. {
  2591. ImageAndColorInfo *info;
  2592. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_LEFT );
  2593. GadgetTextEntrySetEnabledImageLeft( window, info->image );
  2594. GadgetTextEntrySetEnabledColor( window, info->color );
  2595. GadgetTextEntrySetEnabledBorderColor( window, info->borderColor );
  2596. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_RIGHT );
  2597. GadgetTextEntrySetEnabledImageRight( window, info->image );
  2598. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_CENTER );
  2599. GadgetTextEntrySetEnabledImageCenter( window, info->image );
  2600. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_SMALL_CENTER );
  2601. GadgetTextEntrySetEnabledImageSmallCenter( window, info->image );
  2602. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_LEFT );
  2603. GadgetTextEntrySetDisabledImageLeft( window, info->image );
  2604. GadgetTextEntrySetDisabledColor( window, info->color );
  2605. GadgetTextEntrySetDisabledBorderColor( window, info->borderColor );
  2606. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_RIGHT );
  2607. GadgetTextEntrySetDisabledImageRight( window, info->image );
  2608. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_CENTER );
  2609. GadgetTextEntrySetDisabledImageCenter( window, info->image );
  2610. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_SMALL_CENTER );
  2611. GadgetTextEntrySetDisabledImageSmallCenter( window, info->image );
  2612. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_LEFT );
  2613. GadgetTextEntrySetHiliteImageLeft( window, info->image );
  2614. GadgetTextEntrySetHiliteColor( window, info->color );
  2615. GadgetTextEntrySetHiliteBorderColor( window, info->borderColor );
  2616. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_RIGHT );
  2617. GadgetTextEntrySetHiliteImageRight( window, info->image );
  2618. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_CENTER );
  2619. GadgetTextEntrySetHiliteImageCenter( window, info->image );
  2620. info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_SMALL_CENTER );
  2621. GadgetTextEntrySetHiliteImageSmallCenter( window, info->image );
  2622. Color color, border;
  2623. color = TheDefaultScheme->getEnabledTextColor();
  2624. border = TheDefaultScheme->getEnabledTextBorderColor();
  2625. window->winSetEnabledTextColors( color, border );
  2626. color = TheDefaultScheme->getDisabledTextColor();
  2627. border = TheDefaultScheme->getDisabledTextBorderColor();
  2628. window->winSetDisabledTextColors( color, border );
  2629. color = TheDefaultScheme->getHiliteTextColor();
  2630. border = TheDefaultScheme->getHiliteTextBorderColor();
  2631. window->winSetHiliteTextColors( color, border );
  2632. // set default font
  2633. window->winSetFont( TheDefaultScheme->getFont() );
  2634. } // end if
  2635. // contents have changed
  2636. setUnsaved( TRUE );
  2637. // notify the editor of the new window
  2638. notifyNewWindow( window );
  2639. return window;
  2640. } // end newTextEntry
  2641. // GUIEdit::newStaticText =====================================================
  2642. /** Create a new static text*/
  2643. //=============================================================================
  2644. GameWindow *GUIEdit::newStaticText( GameWindow *parent,
  2645. Int x, Int y,
  2646. Int width, Int height )
  2647. {
  2648. GameWindow *window;
  2649. WinInstanceData instData;
  2650. UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
  2651. // validate the parent to disallow illegal relationships
  2652. if( validateParentForCreate( parent ) == FALSE )
  2653. return NULL;
  2654. // keep inside a parent if present
  2655. if( parent )
  2656. clipCreationParamsToParent( parent, &x, &y, &width, &height );
  2657. // initialize inst data
  2658. instData.init();
  2659. instData.m_style = GWS_STATIC_TEXT | GWS_MOUSE_TRACK;
  2660. instData.m_textLabelString = "Static Text";
  2661. // initialize listbox data
  2662. TextData textData;
  2663. memset( &textData, 0, sizeof( textData ) );
  2664. textData.centered = TRUE;
  2665. // make control
  2666. window = TheWindowManager->gogoGadgetStaticText( parent,
  2667. status,
  2668. x, y,
  2669. width, height,
  2670. &instData,
  2671. &textData,
  2672. NULL,
  2673. TRUE );
  2674. // set default colors based on the default scheme
  2675. if( window )
  2676. {
  2677. ImageAndColorInfo *info;
  2678. info = TheDefaultScheme->getImageAndColor( STATIC_TEXT_ENABLED );
  2679. GadgetStaticTextSetEnabledImage( window, info->image );
  2680. GadgetStaticTextSetEnabledColor( window, info->color );
  2681. GadgetStaticTextSetEnabledBorderColor( window, info->borderColor );
  2682. info = TheDefaultScheme->getImageAndColor( STATIC_TEXT_DISABLED );
  2683. GadgetStaticTextSetDisabledImage( window, info->image );
  2684. GadgetStaticTextSetDisabledColor( window, info->color );
  2685. GadgetStaticTextSetDisabledBorderColor( window, info->borderColor );
  2686. info = TheDefaultScheme->getImageAndColor( STATIC_TEXT_DISABLED );
  2687. GadgetStaticTextSetDisabledImage( window, info->image );
  2688. GadgetStaticTextSetDisabledColor( window, info->color );
  2689. GadgetStaticTextSetDisabledBorderColor( window, info->borderColor );
  2690. Color color, border;
  2691. color = TheDefaultScheme->getEnabledTextColor();
  2692. border = TheDefaultScheme->getEnabledTextBorderColor();
  2693. window->winSetEnabledTextColors( color, border );
  2694. color = TheDefaultScheme->getDisabledTextColor();
  2695. border = TheDefaultScheme->getDisabledTextBorderColor();
  2696. window->winSetDisabledTextColors( color, border );
  2697. color = TheDefaultScheme->getHiliteTextColor();
  2698. border = TheDefaultScheme->getHiliteTextBorderColor();
  2699. window->winSetHiliteTextColors( color, border );
  2700. // set default font
  2701. window->winSetFont( TheDefaultScheme->getFont() );
  2702. } // end if
  2703. // contents have changed
  2704. setUnsaved( TRUE );
  2705. // notify the editor of the new window
  2706. notifyNewWindow( window );
  2707. return window;
  2708. } // end newStaticText
  2709. // GUIEdit::createStatusBar ===================================================
  2710. /** Create a status bar at the bottom of the editor */
  2711. //=============================================================================
  2712. void GUIEdit::createStatusBar( void )
  2713. {
  2714. RECT rect;
  2715. Int width;
  2716. Int sizes[ STATUS_NUM_PARTS ];
  2717. // create the bar
  2718. m_statusBarHWnd = CreateStatusWindow( WS_CHILD |
  2719. WS_VISIBLE |
  2720. WS_CLIPSIBLINGS |
  2721. CCS_BOTTOM |
  2722. SBARS_SIZEGRIP,
  2723. "Ready",
  2724. m_appHWnd,
  2725. STATUS_BAR_ID );
  2726. // get size of status bar
  2727. GetWindowRect( m_statusBarHWnd, &rect );
  2728. width = rect.right - rect.left;
  2729. //
  2730. // split the bar up into segments so we can put different text in
  2731. // each of them
  2732. //
  2733. for( Int i = 0; i < STATUS_NUM_PARTS - 1; i++ )
  2734. {
  2735. sizes[ i ] = (i + 1) * (width / STATUS_NUM_PARTS);
  2736. } // end for i
  2737. sizes[ STATUS_NUM_PARTS - 1 ] = -1; // right edge
  2738. SendMessage( m_statusBarHWnd, SB_SETPARTS, STATUS_NUM_PARTS, (LPARAM)sizes );
  2739. } // end createStatusBar
  2740. // GUIEdit::statusMessage =====================================================
  2741. /** Set a message in the status bar */
  2742. //=============================================================================
  2743. void GUIEdit::statusMessage( StatusPart part, char *message )
  2744. {
  2745. // check for out of bounds part
  2746. if( part < 0 || part >= STATUS_NUM_PARTS )
  2747. {
  2748. DEBUG_LOG(( "Status message part out of range '%d', '%s'\n", part, message ));
  2749. assert( 0 );
  2750. return;
  2751. } // end if
  2752. if( m_statusBarHWnd )
  2753. SendMessage( m_statusBarHWnd, SB_SETTEXT, part, (LPARAM)message );
  2754. } // end statusMessage
  2755. // GUIEdit::createToolbar =====================================================
  2756. /** Create the toolbar for the editor */
  2757. //=============================================================================
  2758. void GUIEdit::createToolbar( void )
  2759. {
  2760. } // end createToolbar
  2761. ///////////////////////////////////////////////////////////////////////////////
  2762. ///////////////////////////////////////////////////////////////////////////////
  2763. ///////////////////////////////////////////////////////////////////////////////
  2764. // GUIEdit::newLayout =========================================================
  2765. /** Reset the editor for a new layout */
  2766. //=============================================================================
  2767. Bool GUIEdit::newLayout( void )
  2768. {
  2769. // delete all windows
  2770. deleteAllWindows();
  2771. // we are now fresh and new, like when everything was green and good
  2772. setUnsaved( FALSE );
  2773. // remove layout entries
  2774. m_layoutInitString = GUIEDIT_NONE_STRING;
  2775. m_layoutUpdateString = GUIEDIT_NONE_STRING;
  2776. m_layoutShutdownString = GUIEDIT_NONE_STRING;
  2777. return TRUE;
  2778. } // end newLayout
  2779. // GUIEdit::menuExit ==========================================================
  2780. /** The user clicked on exit in the menu and wishes to exit the editor */
  2781. //=============================================================================
  2782. Bool GUIEdit::menuExit( void )
  2783. {
  2784. Int result;
  2785. //
  2786. // if the contents of the editor are unsaved ask the user if they want
  2787. // to save before quitting
  2788. //
  2789. if( m_unsaved )
  2790. {
  2791. result = MessageBox( m_appHWnd, "Save file before quitting?",
  2792. "Save?", MB_YESNOCANCEL );
  2793. if( result == IDCANCEL )
  2794. return TRUE; // no error
  2795. else if( result == IDYES )
  2796. {
  2797. Bool success;
  2798. // save all our data
  2799. success = TheEditor->menuSave();
  2800. //
  2801. // if we were unable to save file ask them if it's still OK to
  2802. // quit and lose the data
  2803. //
  2804. if( success == FALSE )
  2805. MessageBox( m_appHWnd,
  2806. "File not saved. If you continue to exit all data will be LOST!",
  2807. "File Not Saved", MB_OK );
  2808. } // end if
  2809. } // end if
  2810. // ask them if they really want to quit
  2811. result = MessageBox( m_appHWnd, "Exit GUIEdit?", "Really Quit?", MB_YESNO );
  2812. if( result == IDYES )
  2813. DestroyWindow( m_appHWnd );
  2814. return TRUE;
  2815. } // end menuExit
  2816. // GUIEdit::menuNew ===========================================================
  2817. /** file->new menu option */
  2818. //=============================================================================
  2819. Bool GUIEdit::menuNew( void )
  2820. {
  2821. //
  2822. // if the current data is unsaved ask the user if they want to save
  2823. // before proceeding with a new layout
  2824. //
  2825. if( m_unsaved == TRUE )
  2826. {
  2827. Int result;
  2828. result = MessageBox( m_appHWnd,
  2829. "Current data is not saved. Save before proceeding?",
  2830. "Save?",
  2831. MB_YESNOCANCEL );
  2832. if( result == IDCANCEL )
  2833. return TRUE; // no error
  2834. else if( result == IDYES )
  2835. {
  2836. Bool success;
  2837. // do the save
  2838. success = menuSave();
  2839. // save failed, ask to proceed anyway with new layout
  2840. if( success == FALSE )
  2841. {
  2842. result = MessageBox( m_appHWnd,
  2843. "File not saved. Proceed with new layout anyway? Current layout will be LOST!",
  2844. "File Not Saved",
  2845. MB_YESNO );
  2846. if( result == IDNO )
  2847. return TRUE; // they chose to proceed anyway, no error
  2848. } // end if
  2849. } // end if
  2850. } // end if
  2851. // reset the layout in the editor
  2852. strcpy( m_savePathAndFilename, "" );
  2853. strcpy( m_saveFilename, "" );
  2854. newLayout();
  2855. return TRUE;
  2856. } // end menuNew
  2857. // GUIEdit::stripNameDecorations ==============================================
  2858. /** Strip name decorations of the entire tree of windows */
  2859. //=============================================================================
  2860. void GUIEdit::stripNameDecorations( GameWindow *root )
  2861. {
  2862. // end of recursion
  2863. if( root == NULL )
  2864. return;
  2865. // strip off this name if present
  2866. WinInstanceData *instData = root->winGetInstanceData();
  2867. if( !instData->m_decoratedNameString.isEmpty() )
  2868. {
  2869. char nameOnly[ MAX_WINDOW_NAME_LEN ];
  2870. char *c;
  2871. // skip past the "filename.wnd:" to the name only
  2872. c = strchr( instData->m_decoratedNameString.str(), ':' );
  2873. if( c )
  2874. {
  2875. // skip beyong the scope resolution colon
  2876. c++;
  2877. // copy the name
  2878. strcpy( nameOnly, c );
  2879. // put the name only in the decoration field
  2880. instData->m_decoratedNameString = nameOnly;
  2881. } // end if
  2882. } // end if
  2883. // strip from children
  2884. GameWindow *child;
  2885. for( child = root->winGetChild(); child; child = child->winGetChild() )
  2886. stripNameDecorations( child );
  2887. // onto the next
  2888. stripNameDecorations( root->winGetNext() );
  2889. } // end stripNameDecorations
  2890. //=============================================================================
  2891. /** After a load, we will restore default callbacks to all user windows
  2892. * loaded from the file */
  2893. //=============================================================================
  2894. void GUIEdit::revertDefaultCallbacks( GameWindow *root )
  2895. {
  2896. // end recursion
  2897. if( root == NULL )
  2898. return;
  2899. // if this is a user window, set the default callbacks
  2900. if( windowIsGadget( root ) == FALSE )
  2901. {
  2902. root->winSetSystemFunc( TheWindowManager->getDefaultSystem() );
  2903. root->winSetInputFunc( TheWindowManager->getDefaultInput() );
  2904. root->winSetTooltipFunc( TheWindowManager->getDefaultTooltip() );
  2905. root->winSetDrawFunc( TheWindowManager->getDefaultDraw() );
  2906. } // end if
  2907. // do the children
  2908. revertDefaultCallbacks( root->winGetChild() );
  2909. // do the next window
  2910. revertDefaultCallbacks( root->winGetNext() );
  2911. } // end revertDefaultCallbacks
  2912. // GUIEdit::menuOpen ==========================================================
  2913. /** User has clicked on file->open */
  2914. //=============================================================================
  2915. Bool GUIEdit::menuOpen( void )
  2916. {
  2917. char *filePath;
  2918. //
  2919. // if the current data is unsaved ask the user if they want to save
  2920. // before proceeding with a new layout
  2921. //
  2922. if( m_unsaved == TRUE )
  2923. {
  2924. Int result;
  2925. result = MessageBox( m_appHWnd,
  2926. "Current data is not saved. Save before proceeding?",
  2927. "Save?",
  2928. MB_YESNOCANCEL );
  2929. if( result == IDCANCEL )
  2930. return TRUE; // no error
  2931. else if( result == IDYES )
  2932. {
  2933. Bool success;
  2934. // do the save
  2935. success = menuSave();
  2936. // save failed, ask to proceed anyway with new layout
  2937. if( success == FALSE )
  2938. {
  2939. result = MessageBox( m_appHWnd,
  2940. "File not saved. Proceed with open layout anyway? Current layout will be LOST!",
  2941. "File Not Saved",
  2942. MB_YESNO );
  2943. if( result == IDNO )
  2944. return TRUE; // they chose to proceed anyway, no error
  2945. } // end if
  2946. } // end if
  2947. } // end if
  2948. // open the standard window file browser
  2949. filePath = openDialog();
  2950. // if no filename came back they cancelled this operation
  2951. if( filePath == NULL )
  2952. return FALSE; // file not opened
  2953. //
  2954. // OK, given the full path to the file, save that full path and
  2955. // just the filename in members of the editor
  2956. //
  2957. setSaveFile( filePath );
  2958. // clear the contents of the editor
  2959. newLayout();
  2960. // load the new layout file
  2961. WindowLayoutInfo info;
  2962. TheWindowManager->winCreateFromScript( AsciiString(filePath), &info );
  2963. // save the strings loaded for the layout callbacks
  2964. setLayoutInit( info.initNameString );
  2965. setLayoutUpdate( info.updateNameString );
  2966. setLayoutShutdown( info.shutdownNameString );
  2967. //
  2968. // strip off all the decorations on each window name, they are
  2969. // unnecessary complication in the editor
  2970. //
  2971. stripNameDecorations( TheWindowManager->winGetWindowList() );
  2972. //
  2973. // remove the user callbacks and set them to default draw, input, etc ...
  2974. // we COULD use the real ones, but then we'd have to be assured that
  2975. // every one we wrote would behave if in the editor or the game.
  2976. // It's just easier to not worry about that, and the defaults are
  2977. // good enough for general purpose in all situations
  2978. //
  2979. revertDefaultCallbacks( TheWindowManager->winGetWindowList() );
  2980. // reset the tree view and add all the windows loaded
  2981. TheHierarchyView->reset();
  2982. GameWindow *window;
  2983. for( window = TheWindowManager->winGetWindowList();
  2984. window;
  2985. window = window->winGetNext() )
  2986. TheHierarchyView->addWindow( window, HIERARCHY_ADD_AT_BOTTOM );
  2987. /** @todo should probably make the window manager interface for
  2988. this a little nicer to tell us success and whatnot */
  2989. return TRUE;
  2990. } // end menuOpen
  2991. // GUIEdit::menuSave ==========================================================
  2992. /** file->save menu option */
  2993. //=============================================================================
  2994. Bool GUIEdit::menuSave( void )
  2995. {
  2996. Bool success;
  2997. // if no filename is yet specified then go through the save as logic
  2998. if( strlen( m_savePathAndFilename ) == 0 )
  2999. return menuSaveAs();
  3000. // save all our data to the specified filename
  3001. success = saveData( m_savePathAndFilename, m_saveFilename );
  3002. if( success == TRUE )
  3003. {
  3004. // our contents are now considered "unchanged"
  3005. setUnsaved( FALSE );
  3006. } // end if
  3007. else
  3008. {
  3009. MessageBox( m_appHWnd, "Layout not saved!", "Error", MB_OK );
  3010. } // end else
  3011. return success;
  3012. } // end menuSave
  3013. // GUIEdit::menuSaveAs ========================================================
  3014. /** file->saveAs menu option */
  3015. //=============================================================================
  3016. Bool GUIEdit::menuSaveAs( void )
  3017. {
  3018. char *filePath;
  3019. Bool success;
  3020. // open the standard window file browser
  3021. filePath = saveAsDialog();
  3022. // if no filename came back they cancelled this operation
  3023. if( filePath == NULL )
  3024. return FALSE; // save not done
  3025. // OK, save the filename we're going to use
  3026. setSaveFile( filePath );
  3027. // save all our data to the specified filename
  3028. success = saveData( m_savePathAndFilename, m_saveFilename );
  3029. if( success == TRUE )
  3030. {
  3031. // our contents are now considered "unchanged"
  3032. setUnsaved( FALSE );
  3033. } // end if
  3034. else
  3035. {
  3036. MessageBox( m_appHWnd, "Layout not saved!", "Error", MB_OK );
  3037. } // end else
  3038. return success;
  3039. } // end menuSaveAs
  3040. // GUIEdit::menuCopy ==========================================================
  3041. /** Copy selected windows into clipboard */
  3042. //=============================================================================
  3043. Bool GUIEdit::menuCopy( void )
  3044. {
  3045. WindowSelectionEntry *select;
  3046. // trivial case, nothing selected
  3047. select = getSelectList();
  3048. if( select == NULL )
  3049. {
  3050. MessageBox( m_appHWnd, "You must have windows selected before you can copy them.",
  3051. "No Windows Selected", MB_OK );
  3052. return TRUE;
  3053. } // end if
  3054. //
  3055. // cut the selected windows out of the current window system, and
  3056. // into the clipboard
  3057. //
  3058. TheGUIEditWindowManager->copySelectedToClipboard();
  3059. return TRUE;
  3060. } // end menuCopy
  3061. // GUIEdit::menuPaste =========================================================
  3062. /** Paste contents of clipboard into current layout */
  3063. //=============================================================================
  3064. Bool GUIEdit::menuPaste( void )
  3065. {
  3066. TheGUIEditWindowManager->pasteClipboard();
  3067. return TRUE;
  3068. } // end menuPaste
  3069. // GUIEdit::menuCut ===========================================================
  3070. /** Cut selected windows into the clipboard */
  3071. //=============================================================================
  3072. Bool GUIEdit::menuCut( void )
  3073. {
  3074. WindowSelectionEntry *select;
  3075. // trivial case, nothing selected
  3076. select = getSelectList();
  3077. if( select == NULL )
  3078. {
  3079. MessageBox( m_appHWnd, "You must have windows selected before you can cut.",
  3080. "No Windows Selected", MB_OK );
  3081. return TRUE;
  3082. } // end if
  3083. //
  3084. // cut the selected windows out of the current window system, and
  3085. // into the clipboard
  3086. //
  3087. TheGUIEditWindowManager->cutSelectedToClipboard();
  3088. return TRUE;
  3089. } // end menuCut
  3090. ///////////////////////////////////////////////////////////////////////////////
  3091. ///////////////////////////////////////////////////////////////////////////////
  3092. ///////////////////////////////////////////////////////////////////////////////
  3093. // GUIEdit::isWindowSelected ==================================================
  3094. /** Is the window selected */
  3095. //=============================================================================
  3096. Bool GUIEdit::isWindowSelected( GameWindow *window )
  3097. {
  3098. WindowSelectionEntry *entry;
  3099. // sanity
  3100. if( window == NULL )
  3101. return FALSE;
  3102. // find entry
  3103. entry = findSelectionEntry( window );
  3104. if( entry )
  3105. return TRUE;
  3106. else
  3107. return FALSE;
  3108. } // end isWindowSelected
  3109. // GUIEdit::selectWindow ======================================================
  3110. /** Add window to selection list */
  3111. //=============================================================================
  3112. void GUIEdit::selectWindow( GameWindow *window )
  3113. {
  3114. WindowSelectionEntry *entry;
  3115. // sanity
  3116. if( window == NULL )
  3117. return;
  3118. // do not add to list if already on it
  3119. if( isWindowSelected( window ) == TRUE )
  3120. return;
  3121. // allocate new entry and add to list
  3122. entry = new WindowSelectionEntry;
  3123. if( entry == NULL )
  3124. {
  3125. DEBUG_LOG(( "Unable to allocate selection entry for window\n" ));
  3126. assert( 0 );
  3127. return;
  3128. } // end if
  3129. // fill out information and tie to head of list
  3130. entry->window = window;
  3131. entry->prev = NULL;
  3132. entry->next = m_selectList;
  3133. if( m_selectList )
  3134. m_selectList->prev = entry;
  3135. m_selectList = entry;
  3136. // select this window in the hierarchy if there is only one selected
  3137. if( selectionCount() == 1 )
  3138. TheHierarchyView->selectWindow( window );
  3139. } // end selectWindow
  3140. // GUIEdit::unSelectWindow ====================================================
  3141. /** Remove window from the selection list */
  3142. //=============================================================================
  3143. void GUIEdit::unSelectWindow( GameWindow *window )
  3144. {
  3145. WindowSelectionEntry *entry;
  3146. // sanity
  3147. if( window == NULL )
  3148. return;
  3149. // find entry
  3150. entry = findSelectionEntry( window );
  3151. if( entry )
  3152. {
  3153. // remove from list
  3154. if( entry->next )
  3155. entry->next->prev = entry->prev;
  3156. if( entry->prev )
  3157. entry->prev->next = entry->next;
  3158. else
  3159. m_selectList = entry->next;
  3160. // delete the entry
  3161. delete entry;
  3162. } // end if
  3163. } // end unSelectWindow
  3164. // GUIEdit::clearSelections ===================================================
  3165. /** Clear the entire selection list */
  3166. //=============================================================================
  3167. void GUIEdit::clearSelections( void )
  3168. {
  3169. while( m_selectList )
  3170. unSelectWindow( m_selectList->window );
  3171. } // end clearSelections
  3172. // GUIEdit::selectionCount ====================================================
  3173. /** How many items are selected */
  3174. //=============================================================================
  3175. Int GUIEdit::selectionCount( void )
  3176. {
  3177. WindowSelectionEntry *select;
  3178. Int count = 0;
  3179. select = m_selectList;
  3180. while( select )
  3181. {
  3182. count++;
  3183. select = select->next;
  3184. } // end while
  3185. return count;
  3186. } // end selectionCount
  3187. // GUIEdit::notifyNewWindow ===================================================
  3188. /** The passed in window has just been added into the GUI layout. It
  3189. * It may also contain children which we will recursively call upon
  3190. * so that every window gets a chance to run through this method */
  3191. //=============================================================================
  3192. void GUIEdit::notifyNewWindow( GameWindow *window )
  3193. {
  3194. // end of recursion
  3195. if( window == NULL )
  3196. return;
  3197. //
  3198. // add this window to the hierarchy view at the top, we're adding it
  3199. // at the bottom because presumabely this method was called directly after
  3200. // the window was placed in the world, and it now resides on the top
  3201. // of the window chain, therefore at the bottom of the hierarchy, drawn last
  3202. //
  3203. TheHierarchyView->addWindow( window, HIERARCHY_ADD_AT_TOP );
  3204. //
  3205. // call this notification method for any children we might have, we
  3206. // do NOT notify for the children of gadget controls since those are
  3207. // an "atomic" unit, (except for the Tab Control, which has window children)
  3208. //
  3209. if( (windowIsGadget( window ) == FALSE) || (window->winGetStyle() & GWS_TAB_CONTROL) )
  3210. {
  3211. GameWindow *child;
  3212. for( child = window->winGetChild(); child; child = child->winGetNext() )
  3213. notifyNewWindow( child );
  3214. } // end if
  3215. } // end notifyNewWindow
  3216. // GUIEdit::deleteSelected ====================================================
  3217. /** Delete the windows in the selection list */
  3218. //=============================================================================
  3219. void GUIEdit::deleteSelected( void )
  3220. {
  3221. Int count = TheEditor->selectionCount();
  3222. Int i;
  3223. GameWindow **deleteList;
  3224. WindowSelectionEntry *select;
  3225. //
  3226. // the act of deleting things can actually change selections, like when
  3227. // removing a hierarchy item, the selection is moved ... to avoid any
  3228. // confusion we will build a list of windows to be deleted, independent
  3229. // of the select list and delete those
  3230. //
  3231. deleteList = new GameWindow *[ count ];
  3232. if( deleteList == NULL )
  3233. {
  3234. DEBUG_LOG(( "Cannot allocate delete list!\n" ));
  3235. assert( 0 );
  3236. return;
  3237. } // end if
  3238. // fill out the delete list
  3239. for( i = 0, select = m_selectList; i < count; i++, select = select->next )
  3240. deleteList[ i ] = select->window;
  3241. // delete them all
  3242. for( i = 0; i < count; i++ )
  3243. deleteWindow( deleteList[ i ] );
  3244. // free memory for the delete list
  3245. delete [] deleteList;
  3246. } // end deleteSelected
  3247. // GUIEdit::bringSelectedToTop ================================================
  3248. /** Bring the selected windows to the top so they draw on top of
  3249. * other windows. For window with no parents this brings them to
  3250. * the top of the window stack for all windows, for child windows it will
  3251. * bring them to the top of the child list for their parent */
  3252. //=============================================================================
  3253. void GUIEdit::bringSelectedToTop( void )
  3254. {
  3255. Int count = TheEditor->selectionCount();
  3256. // no-op
  3257. if( count == 0 )
  3258. return;
  3259. //
  3260. // build a list of selections to operate on, we need to do this
  3261. // because the process of changing the hierarchy view will change the
  3262. // select list on us
  3263. //
  3264. GameWindow **snapshot;
  3265. snapshot = new GameWindow *[ count ];
  3266. if( snapshot == NULL )
  3267. {
  3268. DEBUG_LOG(( "bringSelectedToTop: Unabled to allocate selectList\n" ));
  3269. assert( 0 );
  3270. return;
  3271. } // end if
  3272. // take the snapshot
  3273. Int i;
  3274. WindowSelectionEntry *select;
  3275. for( i = 0, select = m_selectList; i < count; i++, select = select->next )
  3276. snapshot[ i ] = select->window;
  3277. // bring all the selected windows to the top
  3278. for( i = 0; i < count; i++ )
  3279. {
  3280. // bring window to the top
  3281. snapshot[ i ]->winBringToTop();
  3282. // update the hierarchy to have the new window on the top
  3283. TheHierarchyView->bringWindowToTop( snapshot[ i ] );
  3284. } // end for i
  3285. // delete the snapshot list
  3286. delete [] snapshot;
  3287. } // end bringSelectedToTop
  3288. // GUIEdit::dragMoveSelectedWindows ===========================================
  3289. /** Move all the windows in the selection list from a drag move, note
  3290. * that we are keeping the positions within the screen and parent
  3291. * windows */
  3292. //=============================================================================
  3293. void GUIEdit::dragMoveSelectedWindows( ICoord2D *dragOrigin,
  3294. ICoord2D *dragDest )
  3295. {
  3296. WindowSelectionEntry *select;
  3297. GameWindow *window;
  3298. ICoord2D moveLoc, safeLoc;
  3299. ICoord2D origin;
  3300. // sanity
  3301. if( dragOrigin == NULL || dragDest == NULL )
  3302. return;
  3303. // traverse selection list
  3304. select = m_selectList;
  3305. while( select )
  3306. {
  3307. // get window info
  3308. window = select->window;
  3309. window->winGetScreenPosition( &origin.x, &origin.y );
  3310. // compute new location
  3311. moveLoc.x = origin.x + (dragDest->x - dragOrigin->x);
  3312. moveLoc.y = origin.y + (dragDest->y - dragOrigin->y);
  3313. // snap move location to grid if on
  3314. if( (TheEditor->getMode() == MODE_DRAG_MOVE) && TheEditor->isGridSnapOn() )
  3315. TheEditor->gridSnapLocation( &moveLoc, &moveLoc );
  3316. // kee the location legal
  3317. computeSafeLocation( window, moveLoc.x, moveLoc.y, &safeLoc.x, &safeLoc.y );
  3318. // move the window
  3319. moveWindowTo( window, safeLoc.x, safeLoc.y );
  3320. // goto next selected window
  3321. select = select->next;
  3322. } // end while
  3323. } // end dragMoveSelectedWindows
  3324. // GUIEdit::getSelectList =====================================================
  3325. /** Return the selection list */
  3326. //=============================================================================
  3327. WindowSelectionEntry *GUIEdit::getSelectList( void )
  3328. {
  3329. return m_selectList;
  3330. } // end getSelectList
  3331. // GUIEdit::getFirstSelected ==================================================
  3332. /** Get the first GameWindow * from the selection list */
  3333. //=============================================================================
  3334. GameWindow *GUIEdit::getFirstSelected( void )
  3335. {
  3336. if( m_selectList )
  3337. return m_selectList->window;
  3338. return NULL;
  3339. } // end getFirstSelected
  3340. // GUIEdit::computeSafeLocation ===============================================
  3341. /** If we attempt to move the window to the given (x,y) it may result
  3342. * in that location being either outside of the screen or outside of
  3343. * the parent. This method will compute a location as close to the
  3344. * desired (x,y) as possible but still remain within the parent
  3345. * and on the screen */
  3346. //=============================================================================
  3347. void GUIEdit::computeSafeLocation( GameWindow *window,
  3348. Int x, Int y, Int *safeX, Int *safeY )
  3349. {
  3350. Int dx, dy;
  3351. ICoord2D origin, size;
  3352. GameWindow *parent;
  3353. IRegion2D region;
  3354. // get window position and size
  3355. window->winGetScreenPosition( &origin.x, &origin.y );
  3356. window->winGetSize( &size.x, &size.y );
  3357. // get region of the window in question
  3358. window->winGetRegion( &region );
  3359. // how far from window current position to new one
  3360. dx = x - origin.x;
  3361. dy = y - origin.y;
  3362. // clip window to parent if there is one
  3363. parent = window->winGetParent();
  3364. if( parent )
  3365. {
  3366. ICoord2D parentSize;
  3367. // get parent size
  3368. parent->winGetSize( &parentSize.x, &parentSize.y );
  3369. if( region.lo.x + dx < 0 )
  3370. dx = 0 - region.lo.x;
  3371. else if( region.hi.x + dx > parentSize.x )
  3372. dx = parentSize.x - region.hi.x;
  3373. if( region.lo.y + dy < 0 )
  3374. dy = 0 - region.lo.y;
  3375. else if( region.hi.y + dy > parentSize.y )
  3376. dy = parentSize.y - region.hi.y;
  3377. } // end else if, parent
  3378. // Move the window, but keep it completely visible within screen boundaries
  3379. IRegion2D newRegion;
  3380. ICoord2D grabSize;
  3381. window->winGetPosition( &newRegion.lo.x, &newRegion.lo.y );
  3382. window->winGetSize( &grabSize.x, &grabSize.y );
  3383. newRegion.lo.x += dx;
  3384. newRegion.lo.y += dy;
  3385. if( newRegion.lo.x < 0 )
  3386. newRegion.lo.x = 0;
  3387. if( newRegion.lo.y < 0 )
  3388. newRegion.lo.y = 0;
  3389. newRegion.hi.x = newRegion.lo.x + grabSize.x;
  3390. newRegion.hi.y = newRegion.lo.y + grabSize.y;
  3391. if( newRegion.hi.x > (Int)TheDisplay->getWidth() )
  3392. newRegion.hi.x = (Int)TheDisplay->getWidth();
  3393. if( newRegion.hi.y > (Int)TheDisplay->getHeight() )
  3394. newRegion.hi.y = (Int)TheDisplay->getHeight();
  3395. // compute new position
  3396. newRegion.lo.x = newRegion.hi.x - grabSize.x;
  3397. newRegion.lo.y = newRegion.hi.y - grabSize.y;
  3398. // safe position is now all figured out
  3399. *safeX = newRegion.lo.x;
  3400. *safeY = newRegion.lo.y;
  3401. } // end computeSafeLocation
  3402. // GUIEdit::computeSafeSizeLocation ===========================================
  3403. /** Like the method computeSafeLocation, this method also takes into
  3404. * account the new position AND size, keeping them within the
  3405. * screen and within any parents
  3406. *
  3407. * NOTE: this assumes it is for the resizing code which assumes that
  3408. * the resize will not invert across the anchor point so we're
  3409. * only checking origin points and sizes compared to parents
  3410. * and the screen;
  3411. *
  3412. * Location returned is relative to parent window if present
  3413. */
  3414. //=============================================================================
  3415. void GUIEdit::computeSafeSizeLocation( GameWindow *window,
  3416. Int newX, Int newY,
  3417. Int newWidth, Int newHeight,
  3418. Int *safeX, Int *safeY,
  3419. Int *safeWidth, Int *safeHeight )
  3420. {
  3421. GameWindow *parent;
  3422. ICoord2D parentLoc;
  3423. ICoord2D parentSize;
  3424. ICoord2D topLeftLimit;
  3425. ICoord2D bottomRightLimit;
  3426. // get parent window and data is present
  3427. parent = window->winGetParent();
  3428. if( parent )
  3429. {
  3430. parent->winGetScreenPosition( &parentLoc.x, &parentLoc.y );
  3431. parent->winGetSize( &parentSize.x, &parentSize.y );
  3432. } // end if
  3433. // upper left corner must be in screen or in parent
  3434. topLeftLimit.x = 0; // screen top left
  3435. topLeftLimit.y = 0; // screen top left
  3436. if( parent )
  3437. topLeftLimit = parentLoc;
  3438. if( newX < topLeftLimit.x )
  3439. {
  3440. newWidth = newWidth - (topLeftLimit.x - newX);
  3441. newX = topLeftLimit.x;
  3442. }
  3443. if( newY < topLeftLimit.y )
  3444. {
  3445. newHeight = newHeight - (topLeftLimit.y - newY);
  3446. newY = topLeftLimit.y;
  3447. }
  3448. // check size at new position compared to parent or screen
  3449. bottomRightLimit.x = TheDisplay->getWidth();
  3450. bottomRightLimit.y = TheDisplay->getHeight();
  3451. if( parent )
  3452. {
  3453. bottomRightLimit.x = parentLoc.x + parentSize.x;
  3454. bottomRightLimit.y = parentLoc.y + parentSize.y;
  3455. } // end if
  3456. if( newX + newWidth > bottomRightLimit.x )
  3457. newWidth = bottomRightLimit.x - newX;
  3458. if( newY + newHeight > bottomRightLimit.y )
  3459. newHeight = bottomRightLimit.y - newY;
  3460. // all done, return location and width relative to parent
  3461. *safeWidth = newWidth;
  3462. *safeHeight = newHeight;
  3463. *safeX = newX;
  3464. *safeY = newY;
  3465. if( parent )
  3466. {
  3467. *safeX = *safeX - parentLoc.x;
  3468. *safeY = *safeY - parentLoc.y;
  3469. }
  3470. } // end computeSafeSizeLocation
  3471. // GUIEdit::computeResizeLocation =============================================
  3472. /** Given the current resize drag mode, the selected window to resize,
  3473. * the start location of the drag, and the end location of the drag,
  3474. * figure out what the upper left corner location and the size of the
  3475. * window should be */
  3476. //=============================================================================
  3477. void GUIEdit::computeResizeLocation( EditMode resizeMode,
  3478. GameWindow *window,
  3479. ICoord2D *resizeOrigin,
  3480. ICoord2D *resizeDest,
  3481. ICoord2D *resultLoc,
  3482. ICoord2D *resultSize )
  3483. {
  3484. Int newX, newY, newSizeX, newSizeY;
  3485. Int sizeLimit = 5;
  3486. // sanity
  3487. if( window == NULL || resizeOrigin == NULL || resizeDest == NULL ||
  3488. resultLoc == NULL || resultSize == NULL )
  3489. return;
  3490. // get the current position and size of the window
  3491. ICoord2D origin, size, bottomRight;
  3492. window->winGetScreenPosition( &origin.x, &origin.y );
  3493. window->winGetSize( &size.x, &size.y );
  3494. bottomRight.x = origin.x + size.x;
  3495. bottomRight.y = origin.y + size.y;
  3496. //
  3497. // compute new size and width based on which resize mode we're
  3498. // using for the anchor point of the window
  3499. //
  3500. switch( resizeMode )
  3501. {
  3502. // ------------------------------------------------------------------------
  3503. case MODE_RESIZE_TOP_LEFT:
  3504. // bottom right is the anchor
  3505. newX = origin.x + (resizeDest->x - resizeOrigin->x);
  3506. newY = origin.y + (resizeDest->y - resizeOrigin->y);
  3507. // don't let it become too small or inverted
  3508. if( newX >= bottomRight.x - sizeLimit )
  3509. newX = bottomRight.x - sizeLimit;
  3510. if( newY >= bottomRight.y - sizeLimit )
  3511. newY = bottomRight.y - sizeLimit;
  3512. // compute new size
  3513. newSizeX = bottomRight.x - newX;
  3514. newSizeY = bottomRight.y - newY;
  3515. break;
  3516. // ------------------------------------------------------------------------
  3517. case MODE_RESIZE_TOP_RIGHT:
  3518. // bottom left is the anchor
  3519. newX = origin.x;
  3520. newY = resizeDest->y;
  3521. // don't let it become too small or inverted
  3522. if( newY >= bottomRight.y - sizeLimit )
  3523. newY = bottomRight.y - sizeLimit;
  3524. // compute new size
  3525. newSizeX = resizeDest->x - origin.x;
  3526. newSizeY = (origin.y + size.y) - resizeDest->y;
  3527. // don't let it invert
  3528. if( newSizeX < sizeLimit )
  3529. newSizeX = sizeLimit;
  3530. if( newSizeY < sizeLimit )
  3531. newSizeY = sizeLimit;
  3532. break;
  3533. // ------------------------------------------------------------------------
  3534. case MODE_RESIZE_BOTTOM_RIGHT:
  3535. // top left is anchor
  3536. newX = origin.x;
  3537. newY = origin.y;
  3538. newSizeX = resizeDest->x - origin.x;
  3539. newSizeY = resizeDest->y - origin.y;
  3540. // don't let it invert or get too small
  3541. if( newSizeX < sizeLimit )
  3542. newSizeX = sizeLimit;
  3543. if( newSizeY < sizeLimit )
  3544. newSizeY = sizeLimit;
  3545. break;
  3546. // ------------------------------------------------------------------------
  3547. case MODE_RESIZE_BOTTOM_LEFT:
  3548. // top right is the anchor
  3549. newX = resizeDest->x;
  3550. newY = origin.y;
  3551. // don't let it get too small or inverted
  3552. if( newX >= bottomRight.x - sizeLimit )
  3553. newX = bottomRight.x - sizeLimit;
  3554. // compute new size
  3555. newSizeX = bottomRight.x - newX;
  3556. newSizeY = resizeDest->y - origin.y;
  3557. // don't let it go inverted
  3558. if( newSizeY < sizeLimit )
  3559. newSizeY = sizeLimit;
  3560. break;
  3561. // ------------------------------------------------------------------------
  3562. case MODE_RESIZE_TOP:
  3563. // bottom SIDE is the anchor
  3564. newX = origin.x;
  3565. newY = resizeDest->y;
  3566. // don't let it invert
  3567. if( newY >= bottomRight.y - sizeLimit )
  3568. newY = bottomRight.y - sizeLimit;
  3569. // compute new size
  3570. newSizeX = size.x;
  3571. newSizeY = bottomRight.y - newY;
  3572. break;
  3573. // ------------------------------------------------------------------------
  3574. case MODE_RESIZE_RIGHT:
  3575. // left SIDE is the anchor
  3576. newX = origin.x;
  3577. newY = origin.y;
  3578. // compute new size
  3579. newSizeX = resizeDest->x - origin.x;
  3580. newSizeY = size.y;
  3581. // don't let it invert or get too small
  3582. if( newSizeX < sizeLimit )
  3583. newSizeX = sizeLimit;
  3584. break;
  3585. // ------------------------------------------------------------------------
  3586. case MODE_RESIZE_BOTTOM:
  3587. // top SIDE is the anchor
  3588. newX = origin.x;
  3589. newY = origin.y;
  3590. // compute new size
  3591. newSizeX = size.x;
  3592. newSizeY = resizeDest->y - origin.y;
  3593. // dont' let it invert or get too small
  3594. if( newSizeY < sizeLimit )
  3595. newSizeY = sizeLimit;
  3596. break;
  3597. // ------------------------------------------------------------------------
  3598. case MODE_RESIZE_LEFT:
  3599. // right SIDE is the anchor
  3600. newX = resizeDest->x;
  3601. newY = origin.y;
  3602. // don't let it invert or get to small
  3603. if( newX >= bottomRight.x - sizeLimit )
  3604. newX = bottomRight.x - sizeLimit;
  3605. // compute new size
  3606. newSizeX = bottomRight.x - newX;
  3607. newSizeY = size.y;
  3608. break;
  3609. } // end switch( resizeMode )
  3610. // to finalize the size we must now clip to any parent or the screen
  3611. computeSafeSizeLocation( window,
  3612. newX, newY,
  3613. newSizeX, newSizeY,
  3614. &resultLoc->x, &resultLoc->y,
  3615. &resultSize->x, &resultSize->y );
  3616. } // end computeResizeLocation
  3617. // GUIEdit::moveWindowTo ======================================================
  3618. /** Move the window passed into the the absolute position (x,y),
  3619. * note that there is NO SAFE checking done on that position */
  3620. //=============================================================================
  3621. void GUIEdit::moveWindowTo( GameWindow *window, Int x, Int y )
  3622. {
  3623. // set the position
  3624. window->winSetPosition( x, y );
  3625. // we've now made a change
  3626. TheEditor->setUnsaved( TRUE );
  3627. } // end moveWindowTo
  3628. // GUIEdit::windowIsGadget ====================================================
  3629. /** Return TRUE if this window is one of our predefined gadtet types */
  3630. //=============================================================================
  3631. Bool GUIEdit::windowIsGadget( GameWindow *window )
  3632. {
  3633. // sanity
  3634. if( window == NULL )
  3635. return FALSE;
  3636. return BitTest( window->winGetStyle(), GWS_GADGET_WINDOW );
  3637. } // end windowIsGadget
  3638. // GUIEdit::gridSnapLocation ==================================================
  3639. /** Given the source input point, return in 'snapped' the closest grid
  3640. * point */
  3641. //=============================================================================
  3642. void GUIEdit::gridSnapLocation( ICoord2D *source, ICoord2D *snapped )
  3643. {
  3644. // sanity
  3645. if( source == NULL || snapped == NULL )
  3646. return;
  3647. snapped->x = (source->x / m_gridResolution) * m_gridResolution;
  3648. snapped->y = (source->y / m_gridResolution) * m_gridResolution;
  3649. } // end gridSnapLocation
  3650. // GUIEdit::checkMenuItem =====================================================
  3651. /** Check the menu item from the guiedit main menu */
  3652. //=============================================================================
  3653. void GUIEdit::checkMenuItem( Int item )
  3654. {
  3655. HMENU menu = GetMenu( m_appHWnd );
  3656. // sanity
  3657. if( menu == NULL )
  3658. return;
  3659. // check it
  3660. CheckMenuItem( menu, item, MF_CHECKED );
  3661. } // end checkMenuItem
  3662. // GUIEdit::unCheckMenuItem ===================================================
  3663. /** Un-check the menu item from the guiedit main menu */
  3664. //=============================================================================
  3665. void GUIEdit::unCheckMenuItem( Int item )
  3666. {
  3667. HMENU menu = GetMenu( m_appHWnd );
  3668. // sanity
  3669. if( menu == NULL )
  3670. return;
  3671. // check it
  3672. CheckMenuItem( menu, item, MF_UNCHECKED );
  3673. } // end unCheckMenuItem
  3674. // GUIEdit::isNameDuplicate ===================================================
  3675. /** Is the name passed in found as the name of any window in in the
  3676. * tree starting at root ... but we will ignore the window 'ignore'
  3677. * if present */
  3678. //=============================================================================
  3679. Bool GUIEdit::isNameDuplicate( GameWindow *root, GameWindow *ignore, AsciiString name )
  3680. {
  3681. WinInstanceData *instData;
  3682. // end of recursion, sanity for name, and empty name ("") is always OK
  3683. if( root == NULL || name.isEmpty() )
  3684. return FALSE; // name is a-ok! :)
  3685. // get instance data
  3686. instData = root->winGetInstanceData();
  3687. // compare name
  3688. if( root != ignore )
  3689. if( instData->m_decoratedNameString == name )
  3690. return TRUE; // no need to search anymore
  3691. //You only call this on the first child since the call right after it will handle siblings (depth first)
  3692. GameWindow *child = root->winGetChild();
  3693. if( isNameDuplicate( child, ignore, name ) == TRUE )
  3694. return TRUE; //duplicate was found
  3695. // check the next window in the list
  3696. return isNameDuplicate( root->winGetNext(), ignore, name );
  3697. } // end isNameDuplicate
  3698. // GUIEdit::loadGUIEditFontLibrary ============================================
  3699. /** Load the set of fonts that we will make available to users in
  3700. * in the editor */
  3701. //=============================================================================
  3702. void GUIEdit::loadGUIEditFontLibrary( FontLibrary *library )
  3703. {
  3704. // sanity
  3705. if( library == NULL )
  3706. return;
  3707. AsciiString fixedSys("FixedSys");
  3708. AsciiString times("Times New Roman");
  3709. library->getFont( fixedSys, 12, FALSE );
  3710. library->getFont( times, 14, FALSE );
  3711. library->getFont( times, 14, TRUE );
  3712. library->getFont( times, 12, FALSE );
  3713. library->getFont( times, 12, TRUE );
  3714. library->getFont( times, 10, FALSE );
  3715. library->getFont( times, 10, TRUE );
  3716. } // end loadGUIEditFontLibrary
  3717. // GUIEdit::setShowHiddenOutlines =============================================
  3718. //=============================================================================
  3719. void GUIEdit::setShowHiddenOutlines( Bool show )
  3720. {
  3721. m_showHiddenOutlines = show;
  3722. if( m_showHiddenOutlines )
  3723. CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_HIDDEN_OUTLINES, MF_CHECKED );
  3724. else
  3725. CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_HIDDEN_OUTLINES, MF_UNCHECKED );
  3726. } // end setShowHiddenOutlines
  3727. // GUIEdit::setShowSeeThruOutlines ============================================
  3728. //=============================================================================
  3729. void GUIEdit::setShowSeeThruOutlines( Bool show )
  3730. {
  3731. m_showSeeThruOutlines = show;
  3732. if( m_showSeeThruOutlines )
  3733. CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_SEE_THRU_OUTLINES, MF_CHECKED );
  3734. else
  3735. CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_SEE_THRU_OUTLINES, MF_UNCHECKED );
  3736. } // end setShowSeeThruOutlines