GameWindowManager.cpp 144 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099
  1. /*
  2. ** Command & Conquer Generals(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: GameWindowManager.cpp ////////////////////////////////////////////////////////////////////
  24. // Created: Colin Day, June 2001
  25. // Dean Iverson, March 1998 (Original window code)
  26. // Desc: The game window manager is the singleton class that we interface
  27. // with to interact with the game windowing system.
  28. ///////////////////////////////////////////////////////////////////////////////////////////////////
  29. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  30. #include "Common/Debug.h"
  31. #include "Common/Language.h"
  32. #include "GameClient/Display.h"
  33. #include "GameClient/GameWindowManager.h"
  34. #include "GameClient/GameWindow.h"
  35. #include "GameClient/Mouse.h"
  36. #include "GameClient/DisplayStringManager.h"
  37. #include "Gameclient/WindowLayout.h"
  38. #include "GameClient/Gadget.h"
  39. #include "GameClient/GameWindowGlobal.h"
  40. #include "GameClient/GadgetListBox.h"
  41. #include "GameClient/GadgetComboBox.h"
  42. #include "GameClient/GadgetTabControl.h"
  43. #include "GameClient/GadgetProgressBar.h"
  44. #include "GameClient/GadgetStaticText.h"
  45. #include "GameClient/GadgetTextEntry.h"
  46. #include "GameClient/GadgetSlider.h"
  47. #include "GameClient/GadgetRadioButton.h"
  48. #include "GameClient/GadgetCheckBox.h"
  49. #include "GameClient/GlobalLanguage.h"
  50. #include "GameClient/GameWindowTransitions.h"
  51. #include "Common/NameKeyGenerator.h"
  52. // PUBLIC DATA ////////////////////////////////////////////////////////////////////////////////////
  53. GameWindowManager *TheWindowManager = NULL;
  54. UnsignedInt WindowLayoutCurrentVersion = 2;
  55. ///////////////////////////////////////////////////////////////////////////////////////////////////
  56. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////////////////////////
  57. ///////////////////////////////////////////////////////////////////////////////////////////////////
  58. #ifdef _INTERNAL
  59. // for occasional debugging...
  60. //#pragma optimize("", off)
  61. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  62. #endif
  63. //
  64. // with this statis set to true, the window system will propogate mouse position
  65. // messages to windows. You may want to disable this if you feel the mouse position
  66. // messages are "spamming" your window and making a particular debuggin situation
  67. // difficult. Make sure you do enable this before you check in again tho because
  68. // it is necessary for any code that needs to look at objects or anything under
  69. // the radar cursor
  70. //
  71. static Bool sendMousePosMessages = TRUE;
  72. //-------------------------------------------------------------------------------------------------
  73. /** Process windows waiting to be destroyed */
  74. //-------------------------------------------------------------------------------------------------
  75. void GameWindowManager::processDestroyList( void )
  76. {
  77. GameWindow *next;
  78. GameWindow *doDestroy;
  79. //
  80. // we need to pass the ownership of the destroy list so
  81. // if, while destroying a window, we need to add other windows
  82. // to the destroy list it won't cause problems.
  83. //
  84. doDestroy = m_destroyList;
  85. // set the list to empty
  86. m_destroyList = NULL;
  87. // do the destroys
  88. for( ; doDestroy; doDestroy = next )
  89. {
  90. next = doDestroy->m_next;
  91. // Check to see if this window is "special"
  92. if( m_mouseCaptor == doDestroy )
  93. winRelease( doDestroy );
  94. if( m_keyboardFocus == doDestroy )
  95. winSetFocus( NULL );
  96. if( (m_modalHead != NULL) && (doDestroy == m_modalHead->window) )
  97. winUnsetModal( m_modalHead->window );
  98. if( m_currMouseRgn == doDestroy )
  99. m_currMouseRgn = NULL;
  100. if( m_grabWindow == doDestroy )
  101. m_grabWindow = NULL;
  102. // send the destroy message to the window we're about to kill
  103. winSendSystemMsg( doDestroy, GWM_DESTROY, 0, 0 );
  104. // free the memory
  105. if (doDestroy)
  106. doDestroy->deleteInstance();
  107. } // end for
  108. } // end processDestroyList
  109. ///////////////////////////////////////////////////////////////////////////////////////////////////
  110. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
  111. ///////////////////////////////////////////////////////////////////////////////////////////////////
  112. //-------------------------------------------------------------------------------------------------
  113. /** Generic function to simply propagate only button press messages to parent and let it deal with it */
  114. //-------------------------------------------------------------------------------------------------
  115. WindowMsgHandledType PassSelectedButtonsToParentSystem( GameWindow *window, UnsignedInt msg,
  116. WindowMsgData mData1, WindowMsgData mData2 )
  117. {
  118. // sanity
  119. if( window == NULL )
  120. return MSG_IGNORED;
  121. if( (msg == GBM_SELECTED) || (msg == GBM_SELECTED_RIGHT) || (msg == GBM_MOUSE_ENTERING) || (msg == GBM_MOUSE_LEAVING) || (msg == GEM_EDIT_DONE))
  122. {
  123. GameWindow *parent = window->winGetParent();
  124. if( parent )
  125. return TheWindowManager->winSendSystemMsg( parent, msg, mData1, mData2 );
  126. } // end if
  127. return MSG_IGNORED;
  128. } // end PassSelectedButtonsToParentSystem
  129. //-------------------------------------------------------------------------------------------------
  130. /** Generic function to simply propagate only button press messages to parent and let it deal with it */
  131. //-------------------------------------------------------------------------------------------------
  132. WindowMsgHandledType PassMessagesToParentSystem( GameWindow *window, UnsignedInt msg,
  133. WindowMsgData mData1, WindowMsgData mData2 )
  134. {
  135. // sanity
  136. if( window == NULL )
  137. return MSG_IGNORED;
  138. GameWindow *parent = window->winGetParent();
  139. if( parent )
  140. return TheWindowManager->winSendSystemMsg( parent, msg, mData1, mData2 );
  141. return MSG_IGNORED;
  142. } // end PassSelectedButtonsToParentSystem
  143. //-------------------------------------------------------------------------------------------------
  144. //-------------------------------------------------------------------------------------------------
  145. GameWindowManager::GameWindowManager( void )
  146. {
  147. m_windowList = NULL; // list of all top level windows
  148. m_windowTail = NULL; // last in windowList
  149. m_destroyList = NULL; // list of windows to destroy
  150. m_currMouseRgn = NULL; // window that mouse is over
  151. m_mouseCaptor = NULL; // window that captured mouse
  152. m_keyboardFocus = NULL; // window that has input focus
  153. m_modalHead = NULL; // top of windows in the modal stack
  154. m_grabWindow = NULL; // window that grabbed the last down event
  155. m_loneWindow = NULL; // Set if we just opened a combo box
  156. m_cursorBitmap = NULL;
  157. m_captureFlags = 0;
  158. } // end GameWindowManger
  159. //-------------------------------------------------------------------------------------------------
  160. //-------------------------------------------------------------------------------------------------
  161. GameWindowManager::~GameWindowManager( void )
  162. {
  163. // destroy all windows
  164. winDestroyAll();
  165. freeStaticStrings();
  166. if(TheTransitionHandler)
  167. delete TheTransitionHandler;
  168. TheTransitionHandler = NULL;
  169. } // end ~GameWindowManager
  170. //-------------------------------------------------------------------------------------------------
  171. /** Initialize the game window manager system */
  172. //-------------------------------------------------------------------------------------------------
  173. void GameWindowManager::init( void )
  174. {
  175. if(!TheTransitionHandler)
  176. TheTransitionHandler = NEW GameWindowTransitionsHandler;
  177. TheTransitionHandler->load();
  178. TheTransitionHandler->init();
  179. } // end init
  180. //-------------------------------------------------------------------------------------------------
  181. /** Reset window system */
  182. //-------------------------------------------------------------------------------------------------
  183. void GameWindowManager::reset( void )
  184. {
  185. // destroy all windows left
  186. winDestroyAll();
  187. if(TheTransitionHandler)
  188. TheTransitionHandler->reset();
  189. } // end reset
  190. //-------------------------------------------------------------------------------------------------
  191. /** Update cycle for game widnow manager */
  192. //-------------------------------------------------------------------------------------------------
  193. void GameWindowManager::update( void )
  194. {
  195. // Process windows waiting to be destroyed
  196. processDestroyList();
  197. if(TheTransitionHandler)
  198. TheTransitionHandler->update();
  199. } // end update
  200. //-------------------------------------------------------------------------------------------------
  201. /** Puts a window at the head of the window list */
  202. //-------------------------------------------------------------------------------------------------
  203. void GameWindowManager::linkWindow( GameWindow *window )
  204. {
  205. GameWindow *lastModalWindow = NULL;
  206. GameWindow *tmp = m_windowList;
  207. while (tmp)
  208. {
  209. const ModalWindow *modal = m_modalHead;
  210. while (modal)
  211. {
  212. if (modal->window == tmp && modal->window != window)
  213. {
  214. lastModalWindow = tmp;
  215. }
  216. modal = modal->next;
  217. }
  218. tmp = tmp->m_next;
  219. }
  220. if (!lastModalWindow)
  221. {
  222. // Add to head of the top level window list
  223. window->m_prev = NULL;
  224. window->m_next = m_windowList;
  225. if( m_windowList )
  226. m_windowList->m_prev = window;
  227. else
  228. {
  229. // first on list is also the tail
  230. m_windowTail = window;
  231. }
  232. m_windowList = window;
  233. }
  234. else
  235. {
  236. // lastModalWindow points to a modal window - add behind it
  237. window->m_prev = lastModalWindow;
  238. window->m_next = lastModalWindow->m_next;
  239. lastModalWindow->m_next = window;
  240. if (window->m_next)
  241. {
  242. window->m_next->m_prev = window;
  243. }
  244. }
  245. } // end linkWindow
  246. //-------------------------------------------------------------------------------------------------
  247. /** Insert the window ahead of the the 'aheadOf' window. 'aheadOf' can
  248. * be a window in the master list or a child of any window in that master
  249. * list */
  250. //-------------------------------------------------------------------------------------------------
  251. void GameWindowManager::insertWindowAheadOf( GameWindow *window,
  252. GameWindow *aheadOf )
  253. {
  254. // sanity
  255. if( window == NULL )
  256. return;
  257. // we'll say that an aheadOf window means at the head of the list
  258. if( aheadOf == NULL )
  259. {
  260. linkWindow( window );
  261. return;
  262. } // end if
  263. // get parent of aheadOf
  264. GameWindow *aheadOfParent = aheadOf->winGetParent();
  265. //
  266. // if ahead of has no parent insert it in the master list just before
  267. // ahead of
  268. //
  269. if( aheadOfParent == NULL )
  270. {
  271. window->m_prev = aheadOf->m_prev;
  272. if( aheadOf->m_prev )
  273. aheadOf->m_prev->m_next = window;
  274. else
  275. m_windowList = window;
  276. aheadOf->m_prev = window;
  277. window->m_next = aheadOf;
  278. } // end if
  279. else
  280. {
  281. window->m_prev = aheadOf->m_prev;
  282. if( aheadOf->m_prev )
  283. aheadOf->m_prev->m_next = window;
  284. else
  285. aheadOfParent->m_child = window;
  286. aheadOf->m_prev = window;
  287. window->m_next = aheadOf;
  288. window->m_parent = aheadOfParent;
  289. } // end else
  290. } // end insertWindowAheadOf
  291. //-------------------------------------------------------------------------------------------------
  292. /** Takes a window off the window list */
  293. //-------------------------------------------------------------------------------------------------
  294. void GameWindowManager::unlinkWindow( GameWindow *window )
  295. {
  296. if( window->m_next )
  297. window->m_next->m_prev = window->m_prev;
  298. else
  299. {
  300. // no next means this is the tail
  301. m_windowTail = window->m_prev;
  302. }
  303. if( window->m_prev )
  304. window->m_prev->m_next = window->m_next;
  305. else
  306. m_windowList = window->m_next;
  307. } // end unlinkWindow
  308. //-------------------------------------------------------------------------------------------------
  309. /** Takes a child window off its parent's window list */
  310. //-------------------------------------------------------------------------------------------------
  311. void GameWindowManager::unlinkChildWindow( GameWindow *window )
  312. {
  313. if( window->m_prev )
  314. {
  315. window->m_prev->m_next = window->m_next;
  316. if( window->m_next )
  317. window->m_next->m_prev = window->m_prev;
  318. }
  319. else
  320. {
  321. if( window->m_next )
  322. {
  323. window->m_parent->m_child = window->m_next;
  324. window->m_next->m_prev = window->m_prev;
  325. window->m_next = NULL;
  326. }
  327. else
  328. {
  329. window->m_parent->m_child = NULL;
  330. }
  331. } // end else
  332. // remove the parent reference from this window
  333. window->m_parent = NULL;
  334. } // end unlinkChildWindow
  335. //-------------------------------------------------------------------------------------------------
  336. /** Check window and parents to see if this window is enabled */
  337. //-------------------------------------------------------------------------------------------------
  338. Bool GameWindowManager::isEnabled( GameWindow *win )
  339. {
  340. // sanity
  341. if( win == NULL )
  342. return FALSE;
  343. if( BitTest( win->m_status, WIN_STATUS_ENABLED ) == FALSE )
  344. {
  345. return FALSE;
  346. }
  347. while( win->m_parent )
  348. {
  349. win = win->m_parent;
  350. if( BitTest( win->m_status, WIN_STATUS_ENABLED ) == FALSE )
  351. {
  352. return FALSE;
  353. }
  354. }
  355. return TRUE;
  356. } // end isEnabled
  357. //-------------------------------------------------------------------------------------------------
  358. /** Check window and parents to see if this window is hidden */
  359. //-------------------------------------------------------------------------------------------------
  360. Bool GameWindowManager::isHidden( GameWindow *win )
  361. {
  362. // we'll allow for the idea that if a window doesn't exist it is hidden
  363. if( win == NULL )
  364. return TRUE;
  365. if( BitTest( win->m_status, WIN_STATUS_HIDDEN ))
  366. {
  367. return TRUE;
  368. }
  369. while( win->m_parent )
  370. {
  371. win = win->m_parent;
  372. if( BitTest( win->m_status, WIN_STATUS_HIDDEN ))
  373. {
  374. return TRUE;
  375. }
  376. }
  377. return FALSE;
  378. } // end isHidden
  379. //-------------------------------------------------------------------------------------------------
  380. // Adds a child window to its parent.
  381. //-------------------------------------------------------------------------------------------------
  382. void GameWindowManager::addWindowToParent( GameWindow *window,
  383. GameWindow *parent )
  384. {
  385. if( parent )
  386. {
  387. // add to parent's list of children
  388. window->m_prev = NULL;
  389. window->m_next = parent->m_child;
  390. if( parent->m_child )
  391. parent->m_child->m_prev = window;
  392. parent->m_child = window;
  393. window->m_parent = parent;
  394. }
  395. } // end addWindowToParent
  396. //-------------------------------------------------------------------------------------------------
  397. /** Add a child window to the parent, put place it at the end of the
  398. * parent window child list */
  399. //-------------------------------------------------------------------------------------------------
  400. void GameWindowManager::addWindowToParentAtEnd( GameWindow *window,
  401. GameWindow *parent )
  402. {
  403. if( parent )
  404. {
  405. window->m_prev = NULL;
  406. window->m_next = NULL;
  407. if( parent->m_child )
  408. {
  409. GameWindow *last;
  410. // wind down to last child in list
  411. last = parent->m_child;
  412. while( last->m_next != NULL )
  413. last = last->m_next;
  414. // tie to list
  415. last->m_next = window;
  416. window->m_prev = last;
  417. } // end if
  418. else
  419. parent->m_child = window;
  420. // assign the parent to the window
  421. window->m_parent = parent;
  422. } // end if
  423. } // end addWindowToParentAtEnd
  424. //-------------------------------------------------------------------------------------------------
  425. /** this gets called from winHide() when a window hides itself */
  426. //-------------------------------------------------------------------------------------------------
  427. void GameWindowManager::windowHiding( GameWindow *window )
  428. {
  429. // if this window has keyboard focus remove it
  430. if( m_keyboardFocus == window )
  431. m_keyboardFocus = NULL;
  432. // if this is the modal head, unset it
  433. if( m_modalHead && m_modalHead->window == window )
  434. winUnsetModal( window );
  435. // if this is the captor, it shall no longer be
  436. if( m_mouseCaptor == window )
  437. winCapture( NULL );
  438. //
  439. // since hiding a parent will also hide the children, when a parent
  440. // hides we must call this same method for all the children so they
  441. // each have a chance to go through this logic
  442. //
  443. GameWindow *child;
  444. for( child = window->winGetChild(); child; child = child->winGetNext() )
  445. windowHiding( child );
  446. } // end windowHiding
  447. //-------------------------------------------------------------------------------------------------
  448. /** Hide all windows in a certain range of id's (inclusive) */
  449. //-------------------------------------------------------------------------------------------------
  450. void GameWindowManager::hideWindowsInRange( GameWindow *baseWindow,
  451. Int first, Int last,
  452. Bool hideFlag )
  453. {
  454. Int i;
  455. GameWindow *window;
  456. for( i = first; i <= last; i++ )
  457. {
  458. window = winGetWindowFromId( baseWindow, i );
  459. if( window )
  460. window->winHide( hideFlag );
  461. } // end for i
  462. } // end hideWindowsInRange
  463. //-------------------------------------------------------------------------------------------------
  464. // Enable all windows in a certain range of id's (inclusive)
  465. //-------------------------------------------------------------------------------------------------
  466. void GameWindowManager::enableWindowsInRange( GameWindow *baseWindow,
  467. Int first, Int last,
  468. Bool enableFlag )
  469. {
  470. Int i;
  471. GameWindow *window;
  472. for( i =first; i <= last; i++ )
  473. {
  474. window = winGetWindowFromId( baseWindow, i );
  475. if( window )
  476. window->winEnable( enableFlag );
  477. } // end for i
  478. } // end enableWindowsInRange
  479. //-------------------------------------------------------------------------------------------------
  480. /** Captures the mouse capture. */
  481. //-------------------------------------------------------------------------------------------------
  482. Int GameWindowManager::winCapture( GameWindow *window )
  483. {
  484. if( m_mouseCaptor != NULL)
  485. return WIN_ERR_MOUSE_CAPTURED;
  486. m_mouseCaptor = window;
  487. return WIN_ERR_OK;
  488. } // end WinCapture
  489. //-------------------------------------------------------------------------------------------------
  490. /** Releases the mouse capture. */
  491. //-------------------------------------------------------------------------------------------------
  492. Int GameWindowManager::winRelease( GameWindow *window )
  493. {
  494. if( window == m_mouseCaptor )
  495. m_mouseCaptor = NULL;
  496. return WIN_ERR_OK;
  497. } // end WinRelease
  498. //-------------------------------------------------------------------------------------------------
  499. /** Returns the current mouse captor. */
  500. //-------------------------------------------------------------------------------------------------
  501. GameWindow *GameWindowManager::winGetCapture( void )
  502. {
  503. return m_mouseCaptor;
  504. } // end WinGetCapture
  505. //-------------------------------------------------------------------------------------------------
  506. /** Gets the window pointer from its id */
  507. //-------------------------------------------------------------------------------------------------
  508. GameWindow *GameWindowManager::winGetWindowFromId( GameWindow *window, Int id )
  509. {
  510. if( window == NULL )
  511. window = m_windowList;
  512. for( ; window; window = window->m_next )
  513. {
  514. if( window->winGetWindowId() == id)
  515. return window;
  516. else if( window->m_child )
  517. {
  518. GameWindow *child = winGetWindowFromId( window->m_child, id );
  519. if( child )
  520. return child;
  521. } // end else if
  522. } // end for
  523. return NULL;
  524. } // end WinGetWindowFromId
  525. //-------------------------------------------------------------------------------------------------
  526. /** Gets the Window List Pointer */
  527. //-------------------------------------------------------------------------------------------------
  528. GameWindow *GameWindowManager::winGetWindowList( void )
  529. {
  530. return m_windowList;
  531. } // end winGetWindowList
  532. //-------------------------------------------------------------------------------------------------
  533. /** Send a system message to the specified window */
  534. //-------------------------------------------------------------------------------------------------
  535. WindowMsgHandledType GameWindowManager::winSendSystemMsg( GameWindow *window,
  536. UnsignedInt msg,
  537. WindowMsgData mData1,
  538. WindowMsgData mData2 )
  539. {
  540. if( window == NULL)
  541. return MSG_IGNORED;
  542. if( msg != GWM_DESTROY && BitTest( window->m_status, WIN_STATUS_DESTROYED ) )
  543. return MSG_IGNORED;
  544. return window->m_system( window, msg, mData1, mData2 );
  545. } // end winSendSystemMsg
  546. //-------------------------------------------------------------------------------------------------
  547. /** Send a system message to the specified window */
  548. //-------------------------------------------------------------------------------------------------
  549. WindowMsgHandledType GameWindowManager::winSendInputMsg( GameWindow *window,
  550. UnsignedInt msg,
  551. WindowMsgData mData1,
  552. WindowMsgData mData2 )
  553. {
  554. if( window == NULL )
  555. return MSG_IGNORED;
  556. if( msg != GWM_DESTROY && BitTest( window->m_status, WIN_STATUS_DESTROYED ) )
  557. return MSG_IGNORED;
  558. return window->m_input( window, msg, mData1, mData2 );
  559. } // end winSendInputMsg
  560. //-------------------------------------------------------------------------------------------------
  561. /** Get the current input focus */
  562. //-------------------------------------------------------------------------------------------------
  563. GameWindow *GameWindowManager::winGetFocus( void )
  564. {
  565. return m_keyboardFocus;
  566. } // end WinGetFocus
  567. //-------------------------------------------------------------------------------------------------
  568. /** Set the current input focus */
  569. //-------------------------------------------------------------------------------------------------
  570. Int GameWindowManager::winSetFocus( GameWindow *window )
  571. {
  572. Bool wantsFocus = FALSE;
  573. // if a window doesn't want keyboard focus don't give it
  574. if( window )
  575. if( BitTest( window->winGetStatus(), WIN_STATUS_NO_FOCUS) )
  576. return 0;
  577. //
  578. // Tell current focus window that it's losing focus
  579. // unless we are trying to give focus to the current focus window
  580. //
  581. if( (m_keyboardFocus) && (m_keyboardFocus != window) )
  582. {
  583. Bool wf; // dummy var, ignored, but must be passed
  584. winSendSystemMsg( m_keyboardFocus, GWM_INPUT_FOCUS, FALSE, (WindowMsgData)&wf );
  585. }
  586. // Set focus to new window
  587. m_keyboardFocus = window;
  588. // Tell new focus window that it has focus
  589. if( m_keyboardFocus )
  590. {
  591. for (;;)
  592. {
  593. winSendSystemMsg( window, GWM_INPUT_FOCUS, TRUE, (WindowMsgData)&wantsFocus );
  594. if (wantsFocus)
  595. break;
  596. window = window->winGetParent();
  597. if( window == NULL )
  598. break;
  599. }
  600. } // end if
  601. // If new window doesn't want focus, set focus to NULL
  602. if( wantsFocus == FALSE )
  603. m_keyboardFocus = NULL;
  604. return WIN_ERR_OK;
  605. } // end WinSetFocus
  606. //-------------------------------------------------------------------------------------------------
  607. /** Process key press through the GUI. */
  608. //-------------------------------------------------------------------------------------------------
  609. WinInputReturnCode GameWindowManager::winProcessKey( UnsignedByte key,
  610. UnsignedByte state )
  611. {
  612. WinInputReturnCode returnCode = WIN_INPUT_NOT_USED;
  613. // Check for keyboard focus and a legal key for sanity
  614. if( m_keyboardFocus && (key != KEY_NONE) )
  615. {
  616. GameWindow *win = m_keyboardFocus;
  617. returnCode = WIN_INPUT_USED; // assume input will be used
  618. //
  619. // Pass the keystroke up the window hierarchy until it is
  620. // processed or we reach the top level window
  621. //
  622. while( winSendInputMsg( win, GWM_CHAR, key, state ) == MSG_IGNORED )
  623. {
  624. win = win->winGetParent();
  625. if( win == NULL )
  626. {
  627. returnCode = WIN_INPUT_NOT_USED; // oops, it wasn't used after all
  628. break;
  629. } // end if
  630. } // end while
  631. } // end if
  632. return returnCode;
  633. } // end winProcessKey
  634. //-------------------------------------------------------------------------------------------------
  635. /** Process a single mouse event through the window system */
  636. //-------------------------------------------------------------------------------------------------
  637. WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage msg,
  638. ICoord2D *mousePos,
  639. void *data )
  640. {
  641. WinInputReturnCode returnCode = WIN_INPUT_NOT_USED;
  642. Bool objectTooltip = FALSE;
  643. UnsignedInt packedMouseCoords;
  644. GameWindow *window = NULL;
  645. GameWindow *toolTipWindow = NULL;
  646. GameWindow *childWindow;
  647. Int dx, dy;
  648. Bool clearGrabWindow = FALSE;
  649. // pack mouse coords into one entity for message passing
  650. packedMouseCoords = SHORTTOLONG( mousePos->x, mousePos->y );
  651. // clear tooltip ... it will be reset if necessary
  652. TheMouse->setCursorTooltip( UnicodeString::TheEmptyString );
  653. // Check for mouse capture
  654. if( m_mouseCaptor )
  655. {
  656. // no window grabbed as of yet
  657. m_grabWindow = NULL;
  658. // what what window within the captured window are we in
  659. window = m_mouseCaptor->winPointInChild( mousePos->x, mousePos->y );
  660. //
  661. // send buttons, drags, wheels to the windows, we don't continually
  662. // send mouse positions
  663. //
  664. if( sendMousePosMessages == TRUE || msg != GWM_MOUSE_POS )
  665. {
  666. GameWindow *win = window;
  667. if( win )
  668. {
  669. while( win != NULL )
  670. {
  671. if( winSendInputMsg( win, msg, packedMouseCoords, 0 ) == MSG_HANDLED )
  672. {
  673. // if used clear the event
  674. returnCode = WIN_INPUT_USED;
  675. break;
  676. }
  677. // if we just tested mouseCaptor don't go any higher in the chain
  678. if( win == m_mouseCaptor )
  679. break;
  680. win = win->winGetParent();
  681. } // end while
  682. } // end if
  683. else
  684. {
  685. // if used clear the event
  686. if( winSendInputMsg( m_mouseCaptor, msg, packedMouseCoords, 0 ) == MSG_HANDLED )
  687. returnCode = WIN_INPUT_USED;
  688. } // end else
  689. } // end if
  690. } // end if, mouse captor window present
  691. else
  692. {
  693. if( m_grabWindow )
  694. {
  695. GameWindow *parent;
  696. switch( msg )
  697. {
  698. // --------------------------------------------------------------------
  699. case GWM_LEFT_UP:
  700. {
  701. //Play a beep sound if the window is disabled.
  702. m_grabWindow->winPointInChild( mousePos->x, mousePos->y, FALSE, TRUE );
  703. BitClear( m_grabWindow->m_status, WIN_STATUS_ACTIVE );
  704. if( m_grabWindow->winPointInWindow( mousePos->x, mousePos->y ) )
  705. winSendInputMsg( m_grabWindow, GWM_LEFT_UP, packedMouseCoords, 0 );
  706. else if( BitTest( m_grabWindow->m_status, WIN_STATUS_DRAGABLE ))
  707. {
  708. winSendInputMsg( m_grabWindow, GWM_LEFT_UP, packedMouseCoords, 0 );
  709. }
  710. clearGrabWindow = TRUE;
  711. break;
  712. } // end left up
  713. // --------------------------------------------------------------------
  714. case MOUSE_EVENT_NONE:
  715. case GWM_LEFT_DRAG:
  716. {
  717. if( BitTest( m_grabWindow->m_status, WIN_STATUS_DRAGABLE ) )
  718. {
  719. ICoord2D *mouseDelta = (ICoord2D *)data;
  720. dx = mouseDelta->x;
  721. dy = mouseDelta->y;
  722. // Clip window to parent
  723. if( m_grabWindow->winGetParent() )
  724. {
  725. parent = m_grabWindow->winGetParent();
  726. if( m_grabWindow->m_region.lo.x + dx < 0 )
  727. dx = 0 - m_grabWindow->m_region.lo.x;
  728. else if( m_grabWindow->m_region.hi.x + dx > parent->m_size.x )
  729. dx = parent->m_size.x - m_grabWindow->m_region.hi.x;
  730. if( m_grabWindow->m_region.lo.y + dy < 0 )
  731. dy = 0 - m_grabWindow->m_region.lo.y;
  732. else if( m_grabWindow->m_region.hi.y + dy > parent->m_size.y )
  733. dy = parent->m_size.y - m_grabWindow->m_region.hi.y;
  734. }
  735. // Move the window, but keep it completely visible within screen boundaries
  736. IRegion2D newRegion;
  737. ICoord2D grabSize;
  738. m_grabWindow->winGetPosition( &newRegion.lo.x, &newRegion.lo.y );
  739. m_grabWindow->winGetSize( &grabSize.x, &grabSize.y );
  740. newRegion.lo.x += dx;
  741. newRegion.lo.y += dy;
  742. if( newRegion.lo.x < 0 )
  743. newRegion.lo.x = 0;
  744. if( newRegion.lo.y < 0 )
  745. newRegion.lo.y = 0;
  746. newRegion.hi.x = newRegion.lo.x + grabSize.x;
  747. newRegion.hi.y = newRegion.lo.y + grabSize.y;
  748. if( newRegion.hi.x > (Int)TheDisplay->getWidth() )
  749. newRegion.hi.x = (Int)TheDisplay->getWidth();
  750. if( newRegion.hi.y > (Int)TheDisplay->getHeight() )
  751. newRegion.hi.y = (Int)TheDisplay->getHeight();
  752. newRegion.lo.x = newRegion.hi.x - grabSize.x;
  753. newRegion.lo.y = newRegion.hi.y - grabSize.y;
  754. m_grabWindow->winSetPosition( newRegion.lo.x, newRegion.lo.y );
  755. } // end if, draggable window
  756. // Send mouse drag message
  757. winSendInputMsg( m_grabWindow, msg, packedMouseCoords, 0 );
  758. break;
  759. } // end mouse event none or left drag
  760. } // end switch
  761. // mark event handled
  762. returnCode = WIN_INPUT_USED;
  763. } // end if, m_grabWindow
  764. else
  765. {
  766. if( m_modalHead && m_modalHead->window )
  767. {
  768. window = m_modalHead->window->winPointInChild( mousePos->x, mousePos->y );
  769. }
  770. else
  771. {
  772. /**@todo Colin, there are 3 cases here that are nearly identical code,
  773. break them up into functions with parameters */
  774. // search for top-level window which contains pointer
  775. for( window = m_windowList; window; window = window->m_next )
  776. {
  777. if( BitTest( window->m_status, WIN_STATUS_ABOVE ) &&
  778. !BitTest( window->m_status, WIN_STATUS_HIDDEN ) &&
  779. mousePos->x >= window->m_region.lo.x &&
  780. mousePos->x <= window->m_region.hi.x &&
  781. mousePos->y >= window->m_region.lo.y &&
  782. mousePos->y <= window->m_region.hi.y)
  783. {
  784. childWindow = window->winPointInAnyChild( mousePos->x, mousePos->y, TRUE, TRUE );
  785. if( toolTipWindow == NULL )
  786. {
  787. if( childWindow->m_tooltip ||
  788. childWindow->m_instData.getTooltipTextLength() )
  789. {
  790. toolTipWindow = childWindow;
  791. }
  792. }
  793. if( BitTest( window->m_status, WIN_STATUS_ENABLED ) )
  794. {
  795. // determine which child window the mouse is in
  796. window = window->winPointInChild( mousePos->x, mousePos->y );
  797. break; // exit for
  798. }
  799. } // end if
  800. } // end for window
  801. // check !above, below and hidden
  802. if( window == NULL )
  803. {
  804. for( window = m_windowList; window; window = window->m_next )
  805. {
  806. if( !BitTest( window->m_status, WIN_STATUS_ABOVE |
  807. WIN_STATUS_BELOW |
  808. WIN_STATUS_HIDDEN ) &&
  809. mousePos->x >= window->m_region.lo.x &&
  810. mousePos->x <= window->m_region.hi.x &&
  811. mousePos->y >= window->m_region.lo.y &&
  812. mousePos->y <= window->m_region.hi.y)
  813. {
  814. childWindow = window->winPointInAnyChild( mousePos->x, mousePos->y, TRUE, TRUE );
  815. if( toolTipWindow == NULL )
  816. {
  817. if( childWindow->m_tooltip ||
  818. childWindow->m_instData.getTooltipTextLength() )
  819. {
  820. toolTipWindow = childWindow;
  821. }
  822. }
  823. if( BitTest( window->m_status, WIN_STATUS_ENABLED ))
  824. {
  825. // determine which child window the mouse is in
  826. window = window->winPointInChild( mousePos->x, mousePos->y );
  827. break; // exit for
  828. }
  829. }
  830. }
  831. } // end if, window == NULL
  832. // check below and !hidden
  833. if( window == NULL )
  834. {
  835. for( window = m_windowList; window; window = window->m_next )
  836. {
  837. if( BitTest( window->m_status, WIN_STATUS_BELOW ) &&
  838. !BitTest( window->m_status, WIN_STATUS_HIDDEN ) &&
  839. mousePos->x >= window->m_region.lo.x &&
  840. mousePos->x <= window->m_region.hi.x &&
  841. mousePos->y >= window->m_region.lo.y &&
  842. mousePos->y <= window->m_region.hi.y)
  843. {
  844. childWindow = window->winPointInAnyChild( mousePos->x, mousePos->y, TRUE, TRUE );
  845. if( toolTipWindow == NULL )
  846. {
  847. if( childWindow->m_tooltip ||
  848. childWindow->m_instData.getTooltipTextLength() )
  849. {
  850. toolTipWindow = childWindow;
  851. }
  852. }
  853. if( BitTest( window->m_status, WIN_STATUS_ENABLED ))
  854. {
  855. // determine which child window the mouse is in
  856. window = window->winPointInChild( mousePos->x, mousePos->y );
  857. break; // exit for
  858. }
  859. }
  860. }
  861. } // end if
  862. } // end else, no modal head
  863. if( window )
  864. if( BitTest( window->m_status, WIN_STATUS_NO_INPUT ) )
  865. {
  866. if(window->winGetParent() && BitTest( window->winGetParent()->winGetInstanceData()->getStyle(), GWS_COMBO_BOX ))
  867. window = window->winGetParent();
  868. else
  869. window = NULL;
  870. }
  871. if( window )
  872. {
  873. GameWindow *tempWin;
  874. //
  875. // only send messages for button states, wheel states, we do not
  876. // continually send messages for mouse positions
  877. //
  878. if( sendMousePosMessages == TRUE || msg != GWM_MOUSE_POS )
  879. {
  880. tempWin = window;
  881. // Give everyone a chance to do something with the clicks
  882. GameWindow *oldLoneWindow = m_loneWindow;
  883. while( winSendInputMsg( tempWin, msg, packedMouseCoords, 0 ) == MSG_IGNORED )
  884. {
  885. tempWin = tempWin->m_parent;
  886. if( tempWin == NULL )
  887. break;
  888. } // end while
  889. // First check to see if m_loneWindow is set if so, close the window
  890. if( m_loneWindow && m_loneWindow == oldLoneWindow
  891. &&( msg == GWM_LEFT_UP || msg == GWM_MIDDLE_UP || msg == GWM_RIGHT_UP || tempWin))
  892. {
  893. if(!m_loneWindow->winIsChild(tempWin))
  894. winSetLoneWindow( NULL );
  895. /*
  896. ComboBoxData *cData = (ComboBoxData *)m_comboBoxOpen->winGetUserData();
  897. // verify that the window that ate the message wasn't one of our own
  898. if(cData->dropDownButton != tempWin &&
  899. cData->editBox != tempWin &&
  900. cData->listBox != tempWin &&
  901. cData->listboxData->upButton != tempWin &&
  902. cData->listboxData->downButton != tempWin &&
  903. cData->listboxData->slider != tempWin &&
  904. cData->listboxData->slider != tempWin->winGetParent())
  905. winSetOpenComboBoxWindow( NULL );*/
  906. }
  907. if( tempWin )
  908. {
  909. //
  910. // Someone cares, if this is a left button down event
  911. // it should get "grabbed"
  912. /// @todo should allow for left handed mouse configs here?
  913. //
  914. if( msg == GWM_LEFT_DOWN )
  915. {
  916. // if( tempWin != windowList )
  917. // WinActivate( tempWin );
  918. m_grabWindow = tempWin;
  919. } // end if
  920. // event is used
  921. returnCode = WIN_INPUT_USED;
  922. } // end if, tempWin
  923. } // end if
  924. } // end if( window )
  925. if( toolTipWindow == NULL )
  926. {
  927. if( isHidden( window ) == FALSE )
  928. toolTipWindow = window;
  929. } // end if
  930. // if tooltips are on set them into the window
  931. Bool tooltipsOn = TRUE;
  932. if( tooltipsOn )
  933. {
  934. // if( toolTipWindow && toolTipWindow->winGetParent() && BitTest( toolTipWindow->winGetParent()->winGetInstanceData()->getStyle(), GWS_COMBO_BOX ))
  935. // toolTipWindow = toolTipWindow->winGetParent();
  936. if( toolTipWindow )
  937. {
  938. // do we have a callback to call for the tooltip
  939. if( toolTipWindow->m_tooltip )
  940. toolTipWindow->m_tooltip( toolTipWindow,
  941. &toolTipWindow->m_instData,
  942. packedMouseCoords );
  943. // else, do we have a normal tooltip to set
  944. else if( toolTipWindow->m_instData.getTooltipTextLength() )
  945. TheMouse->setCursorTooltip( toolTipWindow->m_instData.getTooltipText(), toolTipWindow->m_instData.m_tooltipDelay );
  946. } // end if
  947. else
  948. {
  949. //
  950. // not pointing at a window... perhaps we are pointing at a valid
  951. // tooltip-able object in the game world ... let's set a flag so
  952. // during the object testing we can set the tooltip, we can do
  953. // whatever we like now that we know no other tooltip was set from
  954. // a window
  955. //
  956. objectTooltip = TRUE;
  957. } // end else
  958. } // end if
  959. } // end if grabWindow not present
  960. } // end else (mouseCaptor)
  961. //
  962. // check if new current window is different from the last
  963. // but only if both windows fall within the mouseCaptor if one exists
  964. //
  965. if( (m_grabWindow == NULL) && (window != m_currMouseRgn) )
  966. {
  967. if( m_mouseCaptor )
  968. {
  969. if( m_mouseCaptor->winIsChild( m_currMouseRgn ) )
  970. winSendInputMsg( m_currMouseRgn, GWM_MOUSE_LEAVING, packedMouseCoords, 0 );
  971. }
  972. else if( m_currMouseRgn )
  973. winSendInputMsg( m_currMouseRgn, GWM_MOUSE_LEAVING, packedMouseCoords, 0 );
  974. if( window )
  975. winSendInputMsg( window, GWM_MOUSE_ENTERING, packedMouseCoords, 0 );
  976. m_currMouseRgn = window;
  977. } // end if
  978. // clear grabWindow if necessary
  979. if( clearGrabWindow == TRUE )
  980. {
  981. m_grabWindow = NULL;
  982. clearGrabWindow = FALSE;
  983. } // end if
  984. return returnCode;
  985. } // end winProcessMouseEvent
  986. //-------------------------------------------------------------------------------------------------
  987. /** Draw a window and its children, in parent-first order.
  988. * Children's coordinates are relative to their parents.
  989. * Note that hidden windows automatically will not draw any
  990. * of their children ... but see-thru windows only will not
  991. * draw themselves, but will give their children an
  992. * opportunity to draw */
  993. //-------------------------------------------------------------------------------------------------
  994. Int GameWindowManager::drawWindow( GameWindow *window )
  995. {
  996. GameWindow *child;
  997. if( window == NULL )
  998. return WIN_ERR_INVALID_WINDOW;
  999. if( BitTest( window->m_status, WIN_STATUS_HIDDEN ) == FALSE )
  1000. {
  1001. if( !BitTest( window->m_status, WIN_STATUS_SEE_THRU ) && window->m_draw )
  1002. window->m_draw( window, &window->m_instData );
  1003. /// @todo visit list boxes and borders, this is stupid!
  1004. // for list boxes only draw the borders BEFORE the children
  1005. if( BitTest( window->winGetStyle(), GWS_SCROLL_LISTBOX ) )
  1006. if( BitTest( window->m_status, WIN_STATUS_BORDER ) == TRUE &&
  1007. !BitTest( window->m_status, WIN_STATUS_SEE_THRU ) )
  1008. window->winDrawBorder();
  1009. // draw children in reverse order just like the window list
  1010. child = window->m_child;
  1011. while( child && child->m_next )
  1012. child = child->m_next;
  1013. for( ; child; child = child->m_prev )
  1014. drawWindow( child );
  1015. //
  1016. // draw the border for the window AFTER the window contents AND the
  1017. // children contents have drawn
  1018. //
  1019. if( !BitTest( window->winGetStyle(), GWS_SCROLL_LISTBOX ) )
  1020. if( BitTest( window->m_status, WIN_STATUS_BORDER ) == TRUE &&
  1021. !BitTest( window->m_status, WIN_STATUS_SEE_THRU ) )
  1022. window->winDrawBorder();
  1023. } // end if
  1024. return WIN_ERR_OK;
  1025. } // end drawWindow
  1026. //-------------------------------------------------------------------------------------------------
  1027. /** Draw the GUI in reverse order to correlate with clicking priority */
  1028. //-------------------------------------------------------------------------------------------------
  1029. void GameWindowManager::winRepaint( void )
  1030. {
  1031. GameWindow *window, *next;
  1032. // draw below windows
  1033. for( window = m_windowTail; window; window = next )
  1034. {
  1035. next = window->m_prev;
  1036. if( BitTest( window->m_status, WIN_STATUS_BELOW ) )
  1037. drawWindow( window );
  1038. }
  1039. // draw non-above and non-below windows
  1040. for( window = m_windowTail; window; window = next )
  1041. {
  1042. next = window->m_prev;
  1043. if (BitTest( window->m_status, WIN_STATUS_ABOVE |
  1044. WIN_STATUS_BELOW ) == FALSE)
  1045. drawWindow( window );
  1046. }
  1047. // draw above windows
  1048. for( window = m_windowTail; window; window = next )
  1049. {
  1050. next = window->m_prev;
  1051. if( BitTest( window->m_status, WIN_STATUS_ABOVE ) )
  1052. drawWindow( window );
  1053. }
  1054. if(TheTransitionHandler)
  1055. TheTransitionHandler->draw();
  1056. } // end WinRepaint
  1057. //-------------------------------------------------------------------------------------------------
  1058. /** Dump information about all the windows for resource problems */
  1059. //-------------------------------------------------------------------------------------------------
  1060. void GameWindowManager::dumpWindow( GameWindow *window )
  1061. {
  1062. #ifndef FINAL
  1063. GameWindow *child;
  1064. if( window == NULL )
  1065. return;
  1066. DEBUG_LOG(( "ID: %d\tRedraw: 0x%08X\tUser Data: %d\n",
  1067. window->winGetWindowId(), window->m_draw, window->m_userData ));
  1068. for( child = window->m_child; child; child = child->m_next )
  1069. dumpWindow( child );
  1070. return;
  1071. #endif
  1072. } // end dumpWindow
  1073. //-------------------------------------------------------------------------------------------------
  1074. /** Create a new window by setting up its parameters and callbacks. */
  1075. //-------------------------------------------------------------------------------------------------
  1076. GameWindow *GameWindowManager::winCreate( GameWindow *parent,
  1077. UnsignedInt status,
  1078. Int x, Int y,
  1079. Int width, Int height,
  1080. GameWinSystemFunc system,
  1081. WinInstanceData *instData )
  1082. {
  1083. GameWindow *window;
  1084. // allocate new window
  1085. window = allocateNewWindow();
  1086. if( window == NULL )
  1087. {
  1088. DEBUG_LOG(( "WinCreate error: Could not allocate new window\n" ));
  1089. #ifndef FINAL
  1090. {
  1091. GameWindow *win;
  1092. for( win = m_windowList; win; win = win->m_next )
  1093. dumpWindow( win );
  1094. }
  1095. #endif
  1096. return NULL;
  1097. } // endif
  1098. // If this is a child window add it to the parent's window list
  1099. if( parent )
  1100. addWindowToParent( window, parent );
  1101. else
  1102. linkWindow( window );
  1103. window->m_status = status;
  1104. window->m_size.x = width;
  1105. window->m_size.y = height;
  1106. window->m_region.lo.x = x;
  1107. window->m_region.lo.y = y;
  1108. window->m_region.hi.x = x + width;
  1109. window->m_region.hi.y = y + height;
  1110. window->normalizeWindowRegion();
  1111. // set the system function and send a create message to window
  1112. window->winSetSystemFunc( system );
  1113. winSendSystemMsg( window, GWM_CREATE, 0, 0 );
  1114. // copy over instance data if present
  1115. if( instData )
  1116. window->winSetInstanceData( instData );
  1117. // set default font
  1118. if (TheGlobalLanguageData && TheGlobalLanguageData->m_defaultWindowFont.name.isNotEmpty())
  1119. { window->winSetFont( winFindFont(
  1120. TheGlobalLanguageData->m_defaultWindowFont.name,
  1121. TheGlobalLanguageData->m_defaultWindowFont.size,
  1122. TheGlobalLanguageData->m_defaultWindowFont.bold) );
  1123. }
  1124. else
  1125. window->winSetFont( winFindFont( AsciiString("Times New Roman"), 14, FALSE ) );
  1126. return window;
  1127. } // end WinCreate
  1128. //-------------------------------------------------------------------------------------------------
  1129. /** Take a window and its children off the top level list and free
  1130. * their allocation class data. */
  1131. //-------------------------------------------------------------------------------------------------
  1132. Int GameWindowManager::winDestroy( GameWindow *window )
  1133. {
  1134. GameWindow *child, *next;
  1135. if( window == NULL )
  1136. return WIN_ERR_INVALID_WINDOW;
  1137. //
  1138. // we should never have edit data allocated in the window code, it's
  1139. // completely handled by the editor ONLY
  1140. //
  1141. DEBUG_ASSERTCRASH( window->winGetEditData() == NULL,
  1142. ("winDestroy(): edit data should NOT be present!\n") );
  1143. if( BitTest( window->m_status, WIN_STATUS_DESTROYED ) )
  1144. return WIN_ERR_OK;
  1145. BitSet( window->m_status, WIN_STATUS_DESTROYED );
  1146. window->freeImages();
  1147. if( m_mouseCaptor == window )
  1148. winRelease( window );
  1149. if( m_keyboardFocus == window )
  1150. winSetFocus( NULL );
  1151. if( (m_modalHead != NULL) && (window == m_modalHead->window) )
  1152. winUnsetModal( m_modalHead->window );
  1153. if( m_currMouseRgn == window )
  1154. m_currMouseRgn = NULL;
  1155. if( m_grabWindow == window )
  1156. m_grabWindow = NULL;
  1157. for( child = window->m_child; child; child = next )
  1158. {
  1159. next = child->m_next;
  1160. winDestroy( child );
  1161. }
  1162. // Remove the top level window from list
  1163. if( window->m_parent == NULL )
  1164. unlinkWindow( window );
  1165. else
  1166. unlinkChildWindow( window );
  1167. // Add to head of the destroy list
  1168. window->m_prev = NULL;
  1169. window->m_next = m_destroyList;
  1170. m_destroyList = window;
  1171. //
  1172. // if this window is part of a layout screen, notify the screen that
  1173. // this window is going away
  1174. //
  1175. if( window->m_layout )
  1176. window->m_layout->removeWindow( window );
  1177. return WIN_ERR_OK;
  1178. } // winDestroy
  1179. //-------------------------------------------------------------------------------------------------
  1180. /** Destroy all windows on the window list IMMEDIATELY */
  1181. //-------------------------------------------------------------------------------------------------
  1182. Int GameWindowManager::winDestroyAll( void )
  1183. {
  1184. GameWindow *win, *next;
  1185. //
  1186. // NOTE that it is CRITICAL that the windows be destroyed this way,
  1187. // the editor has windows that are not on this main list that must
  1188. // exist throughout a reset of the system (copy/paste for instance)
  1189. // so DO NOT ever change this to a clever pool of memory for the
  1190. // windows and reset the _pool_ ... I will have to kill you! CBD
  1191. //
  1192. for( next = win = m_windowList; next; win = next)
  1193. {
  1194. next = win->m_next;
  1195. winDestroy( win );
  1196. } // end for
  1197. // Destroy All Windows just added to destroy list
  1198. processDestroyList();
  1199. return WIN_ERR_OK;
  1200. } // end WinDestroyAll
  1201. //-------------------------------------------------------------------------------------------------
  1202. /** Sets selected window into a modal state. This window will get
  1203. * put at the top of a modal stack */
  1204. //-------------------------------------------------------------------------------------------------
  1205. Int GameWindowManager::winSetModal( GameWindow *window )
  1206. {
  1207. ModalWindow *modal;
  1208. if( window == NULL )
  1209. return WIN_ERR_INVALID_WINDOW;
  1210. // verify requesting window is a root window
  1211. if( window->m_parent != NULL )
  1212. {
  1213. DEBUG_LOG(( "WinSetModal: Non Root window attempted to go modal." ));
  1214. return WIN_ERR_INVALID_PARAMETER; // return error if not
  1215. }
  1216. // Allocate new Modal Window Entry
  1217. modal = newInstance(ModalWindow);
  1218. if( modal == NULL )
  1219. {
  1220. DEBUG_LOG(( "WinSetModal: Unable to allocate space for Modal Entry." ));
  1221. return WIN_ERR_GENERAL_FAILURE;
  1222. }
  1223. // Put new entry at top of list
  1224. modal->window = window;
  1225. modal->next = m_modalHead;
  1226. m_modalHead = modal;
  1227. return WIN_ERR_OK;
  1228. } // end WinSetModal
  1229. //-------------------------------------------------------------------------------------------------
  1230. /** pops window off of the modal stack. If this window is not the top
  1231. * of the modal stack an error will occur. */
  1232. //-------------------------------------------------------------------------------------------------
  1233. Int GameWindowManager::winUnsetModal( GameWindow *window )
  1234. {
  1235. ModalWindow *next;
  1236. if( window == NULL )
  1237. return WIN_ERR_INVALID_WINDOW;
  1238. // verify entry is at top of list
  1239. if( (m_modalHead == NULL) || (m_modalHead->window != window) )
  1240. {
  1241. // return error if not
  1242. DEBUG_LOG(( "WinUnsetModal: Invalid window attempting to unset modal (%d)\n",
  1243. window->winGetWindowId() ));
  1244. return WIN_ERR_GENERAL_FAILURE;
  1245. } // end if
  1246. // remove from top of list
  1247. next = m_modalHead->next;
  1248. m_modalHead->deleteInstance();
  1249. m_modalHead = next;
  1250. return WIN_ERR_OK;
  1251. } // end WinUnsetModal
  1252. //-------------------------------------------------------------------------------------------------
  1253. /** Get the grabbed window */
  1254. //-------------------------------------------------------------------------------------------------
  1255. GameWindow *GameWindowManager::winGetGrabWindow( void )
  1256. {
  1257. return m_grabWindow;
  1258. } // end WinGetGrabWindow
  1259. //-------------------------------------------------------------------------------------------------
  1260. /** Explicitly set the grab window */
  1261. //-------------------------------------------------------------------------------------------------
  1262. void GameWindowManager::winSetGrabWindow( GameWindow *window )
  1263. {
  1264. m_grabWindow = window;
  1265. } // end winSetGrabWindow
  1266. //-------------------------------------------------------------------------------------------------
  1267. /** Explicitly set the grab window */
  1268. //-------------------------------------------------------------------------------------------------
  1269. void GameWindowManager::winSetLoneWindow( GameWindow *window )
  1270. {
  1271. // ignore if we're trying to set the same window
  1272. if( m_loneWindow == window )
  1273. return;
  1274. if( m_loneWindow )
  1275. TheWindowManager->winSendSystemMsg( m_loneWindow, GGM_CLOSE, 0, 0 );
  1276. m_loneWindow = window;
  1277. } // end winSetGrabWindow
  1278. //-------------------------------------------------------------------------------------------------
  1279. /** Create a Modal Message Box */
  1280. //-------------------------------------------------------------------------------------------------
  1281. GameWindow *GameWindowManager::gogoMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags,
  1282. UnicodeString titleString, UnicodeString bodyString,
  1283. GameWinMsgBoxFunc yesCallback,
  1284. GameWinMsgBoxFunc noCallback,
  1285. GameWinMsgBoxFunc okCallback,
  1286. GameWinMsgBoxFunc cancelCallback )
  1287. {
  1288. return gogoMessageBox(x,y, width,height,buttonFlags,titleString,bodyString,yesCallback,noCallback,okCallback,cancelCallback, FALSE);
  1289. }
  1290. GameWindow *GameWindowManager::gogoMessageBox(Int x, Int y, Int width, Int height, UnsignedShort buttonFlags,
  1291. UnicodeString titleString, UnicodeString bodyString,
  1292. GameWinMsgBoxFunc yesCallback,
  1293. GameWinMsgBoxFunc noCallback,
  1294. GameWinMsgBoxFunc okCallback,
  1295. GameWinMsgBoxFunc cancelCallback, Bool useLogo )
  1296. {
  1297. // first check to make sure we have some buttons to display
  1298. if(buttonFlags == 0 )
  1299. {
  1300. return NULL;
  1301. }
  1302. GameWindow *trueParent = NULL;
  1303. //Changed by Chris
  1304. if(useLogo)
  1305. trueParent = winCreateFromScript( AsciiString("Menus/QuitMessageBox.wnd") );
  1306. else
  1307. trueParent = winCreateFromScript( AsciiString("Menus/MessageBox.wnd") );
  1308. //Added By Chris
  1309. AsciiString menuName;
  1310. if(useLogo)
  1311. menuName.set("QuitMessageBox.wnd:");
  1312. else
  1313. menuName.set("MessageBox.wnd:");
  1314. AsciiString tempName;
  1315. GameWindow *parent = NULL;
  1316. tempName = menuName;
  1317. tempName.concat("MessageBoxParent");
  1318. parent = TheWindowManager->winGetWindowFromId(trueParent, TheNameKeyGenerator->nameToKey( tempName ));
  1319. TheWindowManager->winSetModal( trueParent );
  1320. TheWindowManager->winSetFocus( NULL ); // make sure we lose focus from other windows even if we refuse focus ourselves
  1321. TheWindowManager->winSetFocus( parent );
  1322. // If the user wants the size to be different then the default
  1323. float ratioX, ratioY = 1;
  1324. if( width > 0 && height > 0 )
  1325. {
  1326. ICoord2D temp;
  1327. //First grab the percent increase/decrease compaired to the default size
  1328. parent->winGetSize( &temp.x, &temp.y);
  1329. ratioX = (float)width / (float)temp.x;
  1330. ratioY = (float)height / (float)temp.y;
  1331. //Set the window's new size
  1332. parent->winSetSize( width, height);
  1333. //Resize/reposition all the children windows based off the ratio
  1334. GameWindow *child;
  1335. for( child = parent->winGetChild(); child; child = child->winGetNext() )
  1336. {
  1337. child->winGetSize(&temp.x, &temp.y);
  1338. temp.x =Int(temp.x * ratioX);
  1339. temp.y =Int(temp.y * ratioY);
  1340. child->winSetSize(temp.x, temp.y);
  1341. child->winGetPosition(&temp.x, &temp.y);
  1342. temp.x =Int(temp.x * ratioX);
  1343. temp.y =Int(temp.y * ratioY);
  1344. child->winSetPosition(temp.x, temp.y);
  1345. }
  1346. }
  1347. // If the user wants to position the message box somewhere other then default
  1348. if( x >= 0 && y >= 0)
  1349. parent->winSetPosition(x, y);
  1350. // Reposition the buttons
  1351. Int buttonX[3], buttonY[3];
  1352. //In the layout, buttonOk will be in the first button position
  1353. NameKeyType buttonOkID = NAMEKEY_INVALID;
  1354. tempName = menuName;
  1355. tempName.concat("ButtonOk");
  1356. buttonOkID = TheNameKeyGenerator->nameToKey( tempName );
  1357. GameWindow *buttonOk = TheWindowManager->winGetWindowFromId(parent, buttonOkID);
  1358. buttonOk->winGetPosition(&buttonX[0], &buttonY[0]);
  1359. tempName = menuName;
  1360. tempName.concat("ButtonYes");
  1361. NameKeyType buttonYesID = TheNameKeyGenerator->nameToKey( tempName );
  1362. GameWindow *buttonYes = TheWindowManager->winGetWindowFromId(parent, buttonYesID);
  1363. //buttonNo in the second position
  1364. tempName = menuName;
  1365. tempName.concat("ButtonNo");
  1366. NameKeyType buttonNoID = TheNameKeyGenerator->nameToKey(tempName);
  1367. GameWindow *buttonNo = TheWindowManager->winGetWindowFromId(parent, buttonNoID);
  1368. buttonNo->winGetPosition(&buttonX[1], &buttonY[1]);
  1369. //and buttonCancel in the third
  1370. tempName = menuName;
  1371. tempName.concat("ButtonCancel");
  1372. NameKeyType buttonCancelID = TheNameKeyGenerator->nameToKey( tempName );
  1373. GameWindow *buttonCancel = TheWindowManager->winGetWindowFromId(parent, buttonCancelID);
  1374. buttonCancel->winGetPosition(&buttonX[2], &buttonY[2]);
  1375. //we shouldn't have button OK and Yes on the same dialog
  1376. if((buttonFlags & (MSG_BOX_OK | MSG_BOX_YES)) == (MSG_BOX_OK | MSG_BOX_YES) )
  1377. {
  1378. DEBUG_ASSERTCRASH(false, ("Passed in MSG_BOX_OK and MSG_BOX_YES. Big No No."));
  1379. }
  1380. //Position the OK button if we have one
  1381. if( (buttonFlags & MSG_BOX_OK) == MSG_BOX_OK)
  1382. {
  1383. buttonOk->winSetPosition(buttonX[0], buttonY[0]);
  1384. buttonOk->winHide(FALSE);
  1385. }
  1386. else if( (buttonFlags & MSG_BOX_YES) == MSG_BOX_YES)
  1387. {
  1388. //Position the Yes if we have one
  1389. buttonYes->winSetPosition(buttonX[0], buttonY[0]);
  1390. buttonYes->winHide(FALSE);
  1391. }
  1392. if((buttonFlags & (MSG_BOX_NO | MSG_BOX_CANCEL)) == (MSG_BOX_NO | MSG_BOX_CANCEL) )
  1393. {
  1394. //If we have both the No and Cancel button, then the no should go in the middle position
  1395. buttonNo->winSetPosition(buttonX[1], buttonY[1]);
  1396. buttonCancel->winSetPosition(buttonX[2], buttonY[2]);
  1397. buttonNo->winHide(FALSE);
  1398. buttonCancel->winHide(FALSE);
  1399. }
  1400. else if( (buttonFlags & MSG_BOX_NO) == MSG_BOX_NO)
  1401. {
  1402. //if we just have the no button, then position it in the right most spot
  1403. buttonNo->winSetPosition(buttonX[2], buttonY[2]);
  1404. buttonNo->winHide(FALSE);
  1405. }
  1406. else if( (buttonFlags & MSG_BOX_CANCEL) == MSG_BOX_CANCEL)
  1407. {
  1408. //else if we just have the Cancel button, well, it should always go in the right spot
  1409. buttonCancel->winSetPosition(buttonX[2], buttonY[2]);
  1410. buttonCancel->winHide(FALSE);
  1411. }
  1412. // Fill the text into the text boxes
  1413. tempName = menuName;
  1414. tempName.concat("StaticTextTitle");
  1415. NameKeyType staticTextTitleID = TheNameKeyGenerator->nameToKey( tempName );
  1416. GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId(parent, staticTextTitleID);
  1417. GadgetStaticTextSetText(staticTextTitle,titleString);
  1418. tempName = menuName;
  1419. tempName.concat("StaticTextMessage");
  1420. NameKeyType staticTextMessageID = TheNameKeyGenerator->nameToKey( tempName );
  1421. GameWindow *staticTextMessage = TheWindowManager->winGetWindowFromId(parent, staticTextMessageID);
  1422. GadgetStaticTextSetText(staticTextMessage,bodyString);
  1423. // create a structure that will pass the functions to
  1424. WindowMessageBoxData *MsgBoxCallbacks = NEW WindowMessageBoxData;
  1425. MsgBoxCallbacks->cancelCallback = cancelCallback;
  1426. MsgBoxCallbacks->noCallback = noCallback;
  1427. MsgBoxCallbacks->okCallback = okCallback;
  1428. MsgBoxCallbacks->yesCallback = yesCallback;
  1429. //pass the structure to the dialog
  1430. trueParent->winSetUserData( MsgBoxCallbacks );
  1431. //make sure the dialog is showing and bring it to the top
  1432. parent->winHide(FALSE);
  1433. parent->winBringToTop();
  1434. //Changed By Chris
  1435. return trueParent;
  1436. }// gogoMessageBox
  1437. //-------------------------------------------------------------------------------------------------
  1438. /** Create a button GUI control */
  1439. //-------------------------------------------------------------------------------------------------
  1440. GameWindow *GameWindowManager::gogoGadgetPushButton( GameWindow *parent,
  1441. UnsignedInt status,
  1442. Int x, Int y,
  1443. Int width, Int height,
  1444. WinInstanceData *instData,
  1445. GameFont *defaultFont,
  1446. Bool defaultVisual )
  1447. {
  1448. GameWindow *button;
  1449. // we MUST have a push button style window to do this
  1450. if( BitTest( instData->getStyle(), GWS_PUSH_BUTTON ) == FALSE )
  1451. {
  1452. DEBUG_LOG(( "Cann't create button gadget, instance data not button type\n" ));
  1453. assert( 0 );
  1454. return NULL;
  1455. } // end if
  1456. // create the button window
  1457. button = TheWindowManager->winCreate( parent, status,
  1458. x, y, width, height,
  1459. GadgetPushButtonSystem,
  1460. instData );
  1461. if( button == NULL )
  1462. {
  1463. DEBUG_LOG(( "Unable to create button for push button gadget\n" ));
  1464. assert( 0 );
  1465. return NULL;
  1466. } // end if
  1467. // assign input function
  1468. button->winSetInputFunc( GadgetPushButtonInput );
  1469. //
  1470. // assign draw function, the draw functions must actually be implemented
  1471. // on the device level of the engine
  1472. //
  1473. if( BitTest( button->winGetStatus(), WIN_STATUS_IMAGE ) )
  1474. button->winSetDrawFunc( getPushButtonImageDrawFunc() );
  1475. else
  1476. button->winSetDrawFunc( getPushButtonDrawFunc() );
  1477. // set the owner to the parent, or if no parent it will be itself
  1478. button->winSetOwner( parent );
  1479. // Init the userdata to NULL
  1480. button->winSetUserData(NULL);
  1481. // assign the default images/colors
  1482. assignDefaultGadgetLook( button, defaultFont, defaultVisual );
  1483. // assign text from label
  1484. UnicodeString text = winTextLabelToText( instData->m_textLabelString );
  1485. if( text.getLength() )
  1486. GadgetButtonSetText( button, text );
  1487. return button;
  1488. } // end gogoGadgetPushButton
  1489. //-------------------------------------------------------------------------------------------------
  1490. /** Create a checkbox UI element */
  1491. //-------------------------------------------------------------------------------------------------
  1492. GameWindow *GameWindowManager::gogoGadgetCheckbox( GameWindow *parent,
  1493. UnsignedInt status,
  1494. Int x, Int y,
  1495. Int width, Int height,
  1496. WinInstanceData *instData,
  1497. GameFont *defaultFont,
  1498. Bool defaultVisual )
  1499. {
  1500. GameWindow *checkbox;
  1501. // we MUST have a push button style window to do this
  1502. if( BitTest( instData->getStyle(), GWS_CHECK_BOX ) == FALSE )
  1503. {
  1504. DEBUG_LOG(( "Cann't create checkbox gadget, instance data not checkbox type\n" ));
  1505. assert( 0 );
  1506. return NULL;
  1507. } // end if
  1508. // create the button window
  1509. checkbox = TheWindowManager->winCreate( parent, status,
  1510. x, y, width, height,
  1511. GadgetCheckBoxSystem,
  1512. instData );
  1513. if( checkbox == NULL )
  1514. {
  1515. DEBUG_LOG(( "Unable to create checkbox window\n" ));
  1516. assert( 0 );
  1517. return NULL;
  1518. } // end if
  1519. // assign input function
  1520. checkbox->winSetInputFunc( GadgetCheckBoxInput );
  1521. //
  1522. // assign draw function, the draw functions must actually be implemented
  1523. // on the device level of the engine
  1524. //
  1525. if( BitTest( checkbox->winGetStatus(), WIN_STATUS_IMAGE ) )
  1526. checkbox->winSetDrawFunc( getCheckBoxImageDrawFunc() );
  1527. else
  1528. checkbox->winSetDrawFunc( getCheckBoxDrawFunc() );
  1529. // set the owner to the parent, or if no parent it will be itself
  1530. checkbox->winSetOwner( parent );
  1531. // assign the default images/colors
  1532. assignDefaultGadgetLook( checkbox, defaultFont, defaultVisual );
  1533. // assign text from label
  1534. UnicodeString text = winTextLabelToText( instData->m_textLabelString );
  1535. if( text.getLength() )
  1536. GadgetCheckBoxSetText( checkbox, text );
  1537. return checkbox;
  1538. } // end gogoGadgetCheckbox
  1539. //-------------------------------------------------------------------------------------------------
  1540. /** Create a radio button GUI element */
  1541. //-------------------------------------------------------------------------------------------------
  1542. GameWindow *GameWindowManager::gogoGadgetRadioButton( GameWindow *parent,
  1543. UnsignedInt status,
  1544. Int x, Int y,
  1545. Int width, Int height,
  1546. WinInstanceData *instData,
  1547. RadioButtonData *rData,
  1548. GameFont *defaultFont,
  1549. Bool defaultVisual )
  1550. {
  1551. GameWindow *radioButton;
  1552. RadioButtonData *radioData;
  1553. // we MUST have a push button style window to do this
  1554. if( BitTest( instData->getStyle(), GWS_RADIO_BUTTON ) == FALSE )
  1555. {
  1556. DEBUG_LOG(( "Cann't create radioButton gadget, instance data not radioButton type\n" ));
  1557. assert( 0 );
  1558. return NULL;
  1559. } // end if
  1560. // create the button window
  1561. radioButton = TheWindowManager->winCreate( parent, status,
  1562. x, y, width, height,
  1563. GadgetRadioButtonSystem,
  1564. instData );
  1565. if( radioButton == NULL )
  1566. {
  1567. DEBUG_LOG(( "Unable to create radio button window\n" ));
  1568. assert( 0 );
  1569. return NULL;
  1570. } // end if
  1571. // allocate and store the radio button user data
  1572. radioData = NEW RadioButtonData;
  1573. memcpy( radioData, rData, sizeof( RadioButtonData ) );
  1574. radioButton->winSetUserData( radioData );
  1575. // assign input function
  1576. radioButton->winSetInputFunc( GadgetRadioButtonInput );
  1577. //
  1578. // assign draw function, the draw functions must actually be implemented
  1579. // on the device level of the engine
  1580. //
  1581. if( BitTest( radioButton->winGetStatus(), WIN_STATUS_IMAGE ) )
  1582. radioButton->winSetDrawFunc( getRadioButtonImageDrawFunc() );
  1583. else
  1584. radioButton->winSetDrawFunc( getRadioButtonDrawFunc() );
  1585. // set the owner to the parent, or if no parent it will be itself
  1586. radioButton->winSetOwner( parent );
  1587. // assign the default images/colors
  1588. assignDefaultGadgetLook( radioButton, defaultFont, defaultVisual );
  1589. // assign text from label
  1590. UnicodeString text = winTextLabelToText( instData->m_textLabelString );
  1591. if( text.getLength() )
  1592. GadgetRadioSetText( radioButton, text );
  1593. return radioButton;
  1594. } // end gogoGadgetRadioButton
  1595. //-------------------------------------------------------------------------------------------------
  1596. /** Create a tab control GUI element */
  1597. //-------------------------------------------------------------------------------------------------
  1598. GameWindow *GameWindowManager::gogoGadgetTabControl( GameWindow *parent,
  1599. UnsignedInt status,
  1600. Int x, Int y,
  1601. Int width, Int height,
  1602. WinInstanceData *instData,
  1603. TabControlData *tData,
  1604. GameFont *defaultFont,
  1605. Bool defaultVisual )
  1606. {
  1607. GameWindow *tabControl;
  1608. TabControlData *tabData;
  1609. // we MUST have a tab control style window to do this
  1610. if( BitTest( instData->getStyle(), GWS_TAB_CONTROL ) == FALSE )
  1611. {
  1612. DEBUG_LOG(( "Cann't create tabControl gadget, instance data not tabControl type\n" ));
  1613. assert( 0 );
  1614. return NULL;
  1615. } // end if
  1616. // create the tab control window
  1617. tabControl = TheWindowManager->winCreate( parent, status,
  1618. x, y, width, height,
  1619. GadgetTabControlSystem,
  1620. instData );
  1621. if( tabControl == NULL )
  1622. {
  1623. DEBUG_LOG(( "Unable to create tab control window\n" ));
  1624. assert( 0 );
  1625. return NULL;
  1626. } // end if
  1627. // allocate and store the tab control user data
  1628. tabData = NEW TabControlData;
  1629. memcpy( tabData, tData, sizeof( TabControlData ) );
  1630. tabControl->winSetUserData( tabData );
  1631. GadgetTabControlComputeTabRegion( tabControl );
  1632. GadgetTabControlCreateSubPanes( tabControl );
  1633. GadgetTabControlShowSubPane( tabControl, 0 );
  1634. // assign input function
  1635. tabControl->winSetInputFunc( GadgetTabControlInput );
  1636. //
  1637. // assign draw function, the draw functions must actually be implemented
  1638. // on the device level of the engine
  1639. //
  1640. if( BitTest( tabControl->winGetStatus(), WIN_STATUS_IMAGE ) )
  1641. tabControl->winSetDrawFunc( getTabControlImageDrawFunc() );
  1642. else
  1643. tabControl->winSetDrawFunc( getTabControlDrawFunc() );
  1644. // set the owner to the parent, or if no parent it will be itself
  1645. tabControl->winSetOwner( parent );
  1646. // assign the default images/colors
  1647. assignDefaultGadgetLook( tabControl, defaultFont, defaultVisual );
  1648. return tabControl;
  1649. } // end gogoGadgetTabControl
  1650. //-------------------------------------------------------------------------------------------------
  1651. /** Create a list box GUI control */
  1652. //-------------------------------------------------------------------------------------------------
  1653. GameWindow *GameWindowManager::gogoGadgetListBox( GameWindow *parent,
  1654. UnsignedInt status,
  1655. Int x, Int y,
  1656. Int width, Int height,
  1657. WinInstanceData *instData,
  1658. ListboxData *listboxDataTemplate,
  1659. GameFont *defaultFont,
  1660. Bool defaultVisual )
  1661. {
  1662. GameWindow *listbox;
  1663. ListboxData *listboxData;
  1664. Bool title = FALSE;
  1665. // we MUST have a push button style window to do this
  1666. if( BitTest( instData->getStyle(), GWS_SCROLL_LISTBOX ) == FALSE )
  1667. {
  1668. DEBUG_LOG(( "Cann't create listbox gadget, instance data not listbox type\n" ));
  1669. assert( 0 );
  1670. return NULL;
  1671. } // end if
  1672. // create the listbox
  1673. listbox = winCreate( parent, status, x, y, width, height,
  1674. GadgetListBoxSystem, instData );
  1675. if( listbox == NULL )
  1676. {
  1677. DEBUG_LOG(( "Unable to create listbox window\n" ));
  1678. assert( 0 );
  1679. return NULL;
  1680. } // end if
  1681. // allocate the listbox data, copy template data over and set it into box
  1682. listboxData = NEW ListboxData;
  1683. DEBUG_ASSERTCRASH(listboxDataTemplate, ("listboxDataTemplate not initialized"));
  1684. memcpy( listboxData, listboxDataTemplate, sizeof( ListboxData ) );
  1685. // Add the list box data struct to the window's class data
  1686. listbox->winSetUserData( listboxData );
  1687. // set the owner to the parent, or if no parent it will be itself
  1688. listbox->winSetOwner( parent );
  1689. // Adjust for list title if present
  1690. if( instData->getTextLength() )
  1691. title = TRUE;
  1692. // Set up list box redraw callbacks
  1693. if( BitTest( listbox->winGetStatus(), WIN_STATUS_IMAGE ))
  1694. listbox->winSetDrawFunc( getListBoxImageDrawFunc() );
  1695. else
  1696. listbox->winSetDrawFunc( getListBoxDrawFunc() );
  1697. // Set up list box input callbacks
  1698. if( listboxData->multiSelect )
  1699. listbox->winSetInputFunc( GadgetListBoxMultiInput );
  1700. else
  1701. listbox->winSetInputFunc( GadgetListBoxInput );
  1702. //
  1703. // allocate and set the list length, note that setting the list length will
  1704. // automatically allocate the selection entries that are needed for multi
  1705. // select list boxes etc.
  1706. //
  1707. Int length = listboxData->listLength;
  1708. listboxData->listLength = 0; // hacky!
  1709. GadgetListBoxSetListLength( listbox, length );
  1710. // store display height
  1711. listboxData->displayHeight = height;
  1712. if( title )
  1713. listboxData->displayHeight -= winFontHeight( instData->getFont() );
  1714. // Set display position to the top of the list
  1715. listboxData->displayPos = 0;
  1716. listboxData->selectPos = -1;
  1717. listboxData->doubleClickTime = 0;
  1718. listboxData->insertPos = 0;
  1719. listboxData->endPos = 0;
  1720. listboxData->totalHeight = 0;
  1721. // if this listbox has multiple selections prep it
  1722. //if( listboxData->multiSelect )
  1723. // GadgetListBoxAddMultiSelect( listbox );
  1724. // If ScrollBar was requested ... create it.
  1725. if( listboxData->scrollBar )
  1726. GadgetListboxCreateScrollbar( listbox );
  1727. //
  1728. // Setup listbox Columns
  1729. //
  1730. if( listboxData->columns == 1 )
  1731. {
  1732. listboxData->columnWidth = NEW Int;
  1733. listboxData->columnWidth[0] = width;
  1734. if( listboxData->slider )
  1735. {
  1736. ICoord2D sliderSize;
  1737. listboxData->slider->winGetSize( &sliderSize.x, &sliderSize.y );
  1738. listboxData->columnWidth[0] -= (sliderSize.x + 2);
  1739. } // end if
  1740. }// if
  1741. else
  1742. {
  1743. if( !listboxData->columnWidthPercentage )
  1744. return NULL;
  1745. listboxData->columnWidth = NEW Int[listboxData->columns];
  1746. if(!listboxData->columnWidth)
  1747. return NULL;
  1748. Int totalWidth = width;
  1749. if( listboxData->slider )
  1750. {
  1751. ICoord2D sliderSize;
  1752. listboxData->slider->winGetSize( &sliderSize.x, &sliderSize.y );
  1753. totalWidth -= (sliderSize.x + 2);
  1754. } // end if
  1755. for(Int i = 0; i < listboxData->columns; i++ )
  1756. {
  1757. listboxData->columnWidth[i] = listboxData->columnWidthPercentage[i] * totalWidth / 100;
  1758. }// for
  1759. }// else
  1760. // assign the default images/colors
  1761. assignDefaultGadgetLook( listbox, defaultFont, defaultVisual );
  1762. return listbox;
  1763. } // end gogoGadgetListBox
  1764. //-------------------------------------------------------------------------------------------------
  1765. /** Does all generic window creation, calls appropriate slider create
  1766. * function to set up slider-specific data */
  1767. //-------------------------------------------------------------------------------------------------
  1768. GameWindow *GameWindowManager::gogoGadgetSlider( GameWindow *parent,
  1769. UnsignedInt status,
  1770. Int x, Int y,
  1771. Int width, Int height,
  1772. WinInstanceData *instData,
  1773. SliderData *sliderData,
  1774. GameFont *defaultFont,
  1775. Bool defaultVisual )
  1776. {
  1777. GameWindow *slider;
  1778. GameWindow *button;
  1779. SliderData *data;
  1780. //
  1781. // All sliders need to have the tab stop status in order for
  1782. // the focus chain to work correctly.
  1783. //
  1784. BitSet( status, WIN_STATUS_TAB_STOP );
  1785. if( BitTest( instData->getStyle(), GWS_HORZ_SLIDER ) )
  1786. {
  1787. slider = winCreate( parent, status, x, y, width, height,
  1788. GadgetHorizontalSliderSystem, instData );
  1789. // Set up horizontal slider callbacks
  1790. slider->winSetInputFunc( GadgetHorizontalSliderInput );
  1791. if( BitTest( slider->winGetStatus(), WIN_STATUS_IMAGE ) )
  1792. slider->winSetDrawFunc( getHorizontalSliderImageDrawFunc() );
  1793. else
  1794. slider->winSetDrawFunc( getHorizontalSliderDrawFunc() );
  1795. } // end if
  1796. else if ( BitTest( instData->getStyle(), GWS_VERT_SLIDER ) )
  1797. {
  1798. slider = winCreate( parent, status, x, y, width, height,
  1799. GadgetVerticalSliderSystem, instData );
  1800. // Set up vertical slider callbacks
  1801. slider->winSetInputFunc( GadgetVerticalSliderInput );
  1802. if( BitTest( slider->winGetStatus(), WIN_STATUS_IMAGE ) && !(parent && BitTest(parent->winGetStyle(), GWS_SCROLL_LISTBOX)))
  1803. slider->winSetDrawFunc( getVerticalSliderImageDrawFunc() );
  1804. else
  1805. slider->winSetDrawFunc( getVerticalSliderDrawFunc() );
  1806. } // end else if
  1807. else
  1808. {
  1809. DEBUG_LOG(( "gogoGadgetSlider warning: unrecognized slider style.\n" ));
  1810. assert( 0 );
  1811. return NULL;
  1812. } // end else
  1813. // sanity
  1814. if( slider == NULL )
  1815. {
  1816. DEBUG_LOG(( "Unable to create slider control window\n" ));
  1817. assert( 0 );
  1818. return NULL;
  1819. } // end if
  1820. // set the owner to the parent, or if no parent it will be itself
  1821. slider->winSetOwner( parent );
  1822. // create the slider thumb button
  1823. WinInstanceData buttonInstData;
  1824. UnsignedInt statusFlags = status | WIN_STATUS_ENABLED | WIN_STATUS_DRAGABLE;
  1825. buttonInstData.init();
  1826. // if parent is hidden we don't need to be.
  1827. BitClear( statusFlags, WIN_STATUS_HIDDEN );
  1828. buttonInstData.m_owner = slider;
  1829. buttonInstData.m_style = GWS_PUSH_BUTTON;
  1830. // if slider tracks, so will this sub control
  1831. if( BitTest( instData->getStyle(), GWS_MOUSE_TRACK ) )
  1832. BitSet( buttonInstData.m_style, GWS_MOUSE_TRACK );
  1833. if( BitTest( instData->getStyle(), GWS_HORZ_SLIDER ) )
  1834. button = gogoGadgetPushButton( slider, statusFlags, 0, HORIZONTAL_SLIDER_THUMB_POSITION,
  1835. HORIZONTAL_SLIDER_THUMB_WIDTH, HORIZONTAL_SLIDER_THUMB_HEIGHT, &buttonInstData, NULL, TRUE );
  1836. else
  1837. button = gogoGadgetPushButton( slider, statusFlags, 0, 0,
  1838. width, width+1, &buttonInstData, NULL, TRUE );
  1839. // Protect against divide by zero
  1840. if( sliderData->maxVal == sliderData->minVal )
  1841. sliderData->maxVal = sliderData->minVal + 1;
  1842. if( BitTest( instData->getStyle(), GWS_HORZ_SLIDER ) )
  1843. {
  1844. sliderData->numTicks = (float)(width - HORIZONTAL_SLIDER_THUMB_WIDTH) /
  1845. (float)(sliderData->maxVal - sliderData->minVal);
  1846. } else
  1847. {
  1848. sliderData->numTicks = (float)(height - GADGET_SIZE) /
  1849. (float)(sliderData->maxVal - sliderData->minVal);
  1850. }
  1851. data = NEW SliderData;
  1852. memcpy( data, sliderData, sizeof(SliderData) );
  1853. // Add the slider data struct to the window's class data
  1854. slider->winSetUserData( data );
  1855. // assign the default images/colors
  1856. assignDefaultGadgetLook( slider, defaultFont, defaultVisual );
  1857. return slider;
  1858. } // end gogoGadgetSlider
  1859. //-------------------------------------------------------------------------------------------------
  1860. /** Create a Combo Box GUI element */
  1861. //-------------------------------------------------------------------------------------------------
  1862. GameWindow *GameWindowManager::gogoGadgetComboBox( GameWindow *parent,
  1863. UnsignedInt status,
  1864. Int x, Int y,
  1865. Int width, Int height,
  1866. WinInstanceData *instData,
  1867. ComboBoxData *comboBoxDataTemplate,
  1868. GameFont *defaultFont,
  1869. Bool defaultVisual )
  1870. {
  1871. GameWindow *comboBox;
  1872. ComboBoxData *comboBoxData;
  1873. Bool title = FALSE;
  1874. // we MUST have a push button style window to do this
  1875. if( BitTest( instData->getStyle(), GWS_COMBO_BOX) == FALSE )
  1876. {
  1877. DEBUG_LOG(( "Cann't create ComboBox gadget, instance data not ComboBox type\n" ));
  1878. assert( 0 );
  1879. return NULL;
  1880. } // end if
  1881. // create the listbox
  1882. comboBox = winCreate( parent, status, x, y, width, height,
  1883. GadgetComboBoxSystem, instData );
  1884. if( comboBox == NULL )
  1885. {
  1886. DEBUG_LOG(( "Unable to create ComboBox window\n" ));
  1887. assert( 0 );
  1888. return NULL;
  1889. } // end if
  1890. // begin here
  1891. // allocate the listbox data, copy template data over and set it into box
  1892. comboBoxData = NEW ComboBoxData;
  1893. memcpy( comboBoxData, comboBoxDataTemplate, sizeof( ComboBoxData ) );
  1894. // Add the list box data struct to the window's class data
  1895. comboBox->winSetUserData( comboBoxData );
  1896. // set the owner to the parent, or if no parent it will be itself
  1897. comboBox->winSetOwner( parent );
  1898. // Adjust for list title if present
  1899. if( instData->getTextLength() )
  1900. title = TRUE;
  1901. // Set up list box redraw callbacks
  1902. if( BitTest( comboBox->winGetStatus(), WIN_STATUS_IMAGE ))
  1903. comboBox->winSetDrawFunc( getComboBoxImageDrawFunc() );
  1904. else
  1905. comboBox->winSetDrawFunc( getComboBoxDrawFunc() );
  1906. // Set up list box input callbacks
  1907. comboBox->winSetInputFunc( GadgetComboBoxInput );
  1908. //Create the windows that make up
  1909. WinInstanceData winInstData;
  1910. Int buttonWidth, buttonHeight;
  1911. Int fontHeight;
  1912. Int top;
  1913. Int bottom;
  1914. // do we have a title
  1915. if( comboBox->winGetTextLength() )
  1916. title = TRUE;
  1917. // remove unwanted status bits.
  1918. status &= ~(WIN_STATUS_BORDER | WIN_STATUS_HIDDEN);
  1919. fontHeight = TheWindowManager->winFontHeight( comboBox->winGetFont() );
  1920. top = title ? (fontHeight + 1):0;
  1921. bottom = title ? (height - (fontHeight + 1)):height;
  1922. // intialize instData
  1923. winInstData.init();
  1924. // size of button
  1925. buttonWidth = 21;
  1926. buttonHeight = 22;
  1927. // ----------------------------------------------------------------------
  1928. // Create Drop Down Button
  1929. // ----------------------------------------------------------------------
  1930. winInstData.m_owner = comboBox;
  1931. winInstData.m_style = GWS_PUSH_BUTTON;
  1932. // if listbox tracks, so will this sub control
  1933. if( BitTest( comboBox->winGetStyle(), GWS_MOUSE_TRACK ) )
  1934. BitSet( winInstData.m_style, GWS_MOUSE_TRACK );
  1935. comboBoxData->dropDownButton =
  1936. TheWindowManager->gogoGadgetPushButton( comboBox,
  1937. status | WIN_STATUS_ACTIVE | WIN_STATUS_ENABLED,
  1938. width - buttonWidth, 0,
  1939. buttonWidth, height,
  1940. &winInstData, NULL, TRUE );
  1941. comboBoxData->dropDownButton->winSetTooltipFunc(comboBox->winGetTooltipFunc());
  1942. comboBoxData->dropDownButton->winSetTooltip(instData->getTooltipText());
  1943. comboBoxData->dropDownButton->setTooltipDelay(comboBox->getTooltipDelay());
  1944. // ----------------------------------------------------------------------
  1945. // Create text entry
  1946. // ----------------------------------------------------------------------
  1947. UnsignedInt statusTextEntry;
  1948. winInstData.init();
  1949. winInstData.m_owner = comboBox;
  1950. winInstData.m_style |= GWS_ENTRY_FIELD;
  1951. winInstData.m_textLabelString = "Entry";
  1952. if( BitTest( comboBox->winGetStyle(), GWS_MOUSE_TRACK ) )
  1953. BitSet( winInstData.m_style, GWS_MOUSE_TRACK );
  1954. if( comboBoxData->isEditable)
  1955. {
  1956. statusTextEntry = status;
  1957. }
  1958. else
  1959. {
  1960. statusTextEntry = status | WIN_STATUS_NO_INPUT ;//| WIN_STATUS_NO_FOCUS;
  1961. comboBoxData->entryData->drawTextFromStart = TRUE;
  1962. }
  1963. comboBoxData->editBox = TheWindowManager->gogoGadgetTextEntry( comboBox, statusTextEntry ,
  1964. 0,0 ,
  1965. width - buttonWidth , height ,
  1966. &winInstData, comboBoxData->entryData,
  1967. winInstData.m_font, FALSE );
  1968. comboBoxData->editBox->winSetTooltipFunc(comboBox->winGetTooltipFunc());
  1969. comboBoxData->editBox->winSetTooltip(instData->getTooltipText());
  1970. comboBoxData->editBox->setTooltipDelay(comboBox->getTooltipDelay());
  1971. delete (comboBoxData->entryData);
  1972. comboBoxData->entryData = (EntryData *)comboBoxData->editBox->winGetUserData();
  1973. // ----------------------------------------------------------------------
  1974. // Create list box
  1975. // ----------------------------------------------------------------------
  1976. winInstData.init();
  1977. winInstData.m_owner = comboBox;
  1978. if( BitTest( comboBox->winGetStyle(), GWS_MOUSE_TRACK ) )
  1979. BitSet( winInstData.m_style, GWS_MOUSE_TRACK );
  1980. BitSet( winInstData.m_style, WIN_STATUS_HIDDEN );
  1981. winInstData.m_style |= GWS_SCROLL_LISTBOX;
  1982. status &= ~(WIN_STATUS_IMAGE);
  1983. comboBoxData->listBox = TheWindowManager->gogoGadgetListBox( comboBox, status | WIN_STATUS_ABOVE | WIN_STATUS_ONE_LINE, 0, height,
  1984. width, height,
  1985. &winInstData, comboBoxData->listboxData,
  1986. winInstData.m_font, FALSE );
  1987. comboBoxData->listBox->winHide(TRUE);
  1988. delete(comboBoxData->listboxData);
  1989. comboBoxData->listboxData = (ListboxData *)comboBoxData->listBox->winGetUserData();
  1990. comboBoxData->listBox->winSetTooltipFunc(comboBox->winGetTooltipFunc());
  1991. comboBoxData->listBox->winSetTooltip(instData->getTooltipText());
  1992. comboBoxData->listBox->setTooltipDelay(comboBox->getTooltipDelay());
  1993. GadgetListBoxSetAudioFeedback(comboBoxData->listBox, TRUE);
  1994. // Initialize the ComboBox's variables and the controls with them
  1995. GadgetComboBoxSetIsEditable(comboBox, comboBoxData->isEditable);
  1996. GadgetComboBoxSetMaxChars( comboBox, comboBoxData->maxChars );
  1997. GadgetComboBoxSetMaxDisplay( comboBox, comboBoxData->maxDisplay );
  1998. //Initialize the control's text colors
  1999. Color color, border;
  2000. color = comboBox->winGetEnabledTextColor();
  2001. border = comboBox->winGetEnabledTextBorderColor();
  2002. if(comboBoxData->listBox)
  2003. comboBoxData->listBox->winSetEnabledTextColors( color,border);
  2004. if(comboBoxData->editBox)
  2005. comboBoxData->editBox->winSetEnabledTextColors(color,border);
  2006. color = comboBox->winGetDisabledTextColor();
  2007. border = comboBox->winGetDisabledTextBorderColor();
  2008. if(comboBoxData->listBox)
  2009. comboBoxData->listBox->winSetDisabledTextColors( color,border);
  2010. if(comboBoxData->editBox)
  2011. comboBoxData->editBox->winSetDisabledTextColors(color,border);
  2012. color = comboBox->winGetHiliteTextColor();
  2013. border = comboBox->winGetHiliteTextBorderColor();
  2014. if(comboBoxData->listBox)
  2015. comboBoxData->listBox->winSetHiliteTextColors( color,border);
  2016. if(comboBoxData->editBox)
  2017. comboBoxData->editBox->winSetHiliteTextColors(color,border);
  2018. comboBoxData->dontHide = FALSE;
  2019. // assign the default images/colors
  2020. assignDefaultGadgetLook( comboBox, defaultFont, defaultVisual );
  2021. return comboBox;
  2022. }
  2023. //-------------------------------------------------------------------------------------------------
  2024. /** Create a progress bar GUI element */
  2025. //-------------------------------------------------------------------------------------------------
  2026. GameWindow *GameWindowManager::gogoGadgetProgressBar( GameWindow *parent,
  2027. UnsignedInt status,
  2028. Int x, Int y,
  2029. Int width, Int height,
  2030. WinInstanceData *instData,
  2031. GameFont *defaultFont,
  2032. Bool defaultVisual )
  2033. {
  2034. GameWindow *progressBar;
  2035. // we MUST have a push button style window to do this
  2036. if( BitTest( instData->getStyle(), GWS_PROGRESS_BAR ) == FALSE )
  2037. {
  2038. DEBUG_LOG(( "Cann't create progressBar gadget, instance data not progressBar type\n" ));
  2039. assert( 0 );
  2040. return NULL;
  2041. } // end if
  2042. // create the button window
  2043. progressBar = TheWindowManager->winCreate( parent, status,
  2044. x, y, width, height,
  2045. GadgetProgressBarSystem,
  2046. instData );
  2047. if( progressBar == NULL )
  2048. {
  2049. DEBUG_LOG(( "Unable to create progress bar control\n" ));
  2050. assert( 0 );
  2051. return NULL;
  2052. } // end if
  2053. //
  2054. // assign draw function, the draw functions must actually be implemented
  2055. // on the device level of the engine
  2056. //
  2057. if( BitTest( progressBar->winGetStatus(), WIN_STATUS_IMAGE ) )
  2058. progressBar->winSetDrawFunc( getProgressBarImageDrawFunc() );
  2059. else
  2060. progressBar->winSetDrawFunc( getProgressBarDrawFunc() );
  2061. // set the owner to the parent, or if no parent it will be itself
  2062. progressBar->winSetOwner( parent );
  2063. // assign the default images/colors
  2064. assignDefaultGadgetLook( progressBar, defaultFont, defaultVisual );
  2065. return progressBar;
  2066. } // end gogoGadgetProgressBar
  2067. //-------------------------------------------------------------------------------------------------
  2068. /** Does all generic window creation, calls appropriate text field create
  2069. * function to set up specific data */
  2070. //-------------------------------------------------------------------------------------------------
  2071. GameWindow *GameWindowManager::gogoGadgetStaticText( GameWindow *parent,
  2072. UnsignedInt status,
  2073. Int x, Int y,
  2074. Int width, Int height,
  2075. WinInstanceData *instData,
  2076. TextData *textData,
  2077. GameFont *defaultFont,
  2078. Bool defaultVisual )
  2079. {
  2080. GameWindow *textWin;
  2081. TextData *data;
  2082. // Static Text can not be a Tab Stop
  2083. BitClear( instData->m_style, GWS_TAB_STOP );
  2084. if( BitTest( instData->getStyle(), GWS_STATIC_TEXT ) )
  2085. {
  2086. textWin = winCreate( parent, status, x, y, width, height,
  2087. GadgetStaticTextSystem, instData );
  2088. }
  2089. else
  2090. {
  2091. DEBUG_LOG(( "gogoGadgetText warning: unrecognized text style.\n" ));
  2092. return NULL;
  2093. }
  2094. if( textWin != NULL )
  2095. {
  2096. // set the owner to the parent, or if no parent it will be itself
  2097. textWin->winSetOwner( parent );
  2098. // assign callbacks
  2099. textWin->winSetInputFunc( GadgetStaticTextInput );
  2100. if( BitTest( textWin->winGetStatus(), WIN_STATUS_IMAGE ) )
  2101. textWin->winSetDrawFunc( getStaticTextImageDrawFunc() );
  2102. else
  2103. textWin->winSetDrawFunc( getStaticTextDrawFunc() );
  2104. data = NEW TextData;
  2105. assert( textData != NULL );
  2106. memcpy( data, textData, sizeof(TextData) );
  2107. // allocate a display string for the tet
  2108. data->text = TheDisplayStringManager->newDisplayString();
  2109. // set whether or not we center the wrapped text
  2110. data->text->setWordWrapCentered( BitTest( instData->getStatus(), WIN_STATUS_WRAP_CENTERED ));
  2111. // Add the entry field data struct to the window's class data
  2112. textWin->winSetUserData( data );
  2113. // assign the default images/colors
  2114. assignDefaultGadgetLook( textWin, defaultFont, defaultVisual );
  2115. // assign text from label
  2116. UnicodeString text = winTextLabelToText( instData->m_textLabelString );
  2117. if( text.getLength() )
  2118. GadgetStaticTextSetText( textWin, text );
  2119. } // end if
  2120. return textWin;
  2121. } // end gogoGadetStaticText
  2122. //-------------------------------------------------------------------------------------------------
  2123. /** Does all generic window creation, calls appropriate entry field create
  2124. * function to set up specific data */
  2125. //-------------------------------------------------------------------------------------------------
  2126. GameWindow *GameWindowManager::gogoGadgetTextEntry( GameWindow *parent,
  2127. UnsignedInt status,
  2128. Int x, Int y,
  2129. Int width, Int height,
  2130. WinInstanceData *instData,
  2131. EntryData *entryData,
  2132. GameFont *defaultFont,
  2133. Bool defaultVisual )
  2134. {
  2135. GameWindow *entry;
  2136. EntryData *data;
  2137. if( BitTest( instData->getStyle(), GWS_ENTRY_FIELD ) == FALSE )
  2138. {
  2139. DEBUG_LOG(( "Unable to create text entry, style not entry type\n" ));
  2140. assert( 0 );
  2141. return NULL;
  2142. } // end if
  2143. // create the window
  2144. entry = winCreate( parent, status, x, y, width, height,
  2145. GadgetTextEntrySystem, instData );
  2146. if( entry == NULL )
  2147. {
  2148. DEBUG_LOG(( "Unable to create text entry window\n" ));
  2149. assert( 0 );
  2150. return NULL;
  2151. } // end if
  2152. // set owner of this control
  2153. entry->winSetOwner( parent );
  2154. // assign callbacks
  2155. entry->winSetInputFunc( GadgetTextEntryInput );
  2156. if( BitTest( entry->winGetStatus(), WIN_STATUS_IMAGE ) )
  2157. entry->winSetDrawFunc( getTextEntryImageDrawFunc() );
  2158. else
  2159. entry->winSetDrawFunc( getTextEntryDrawFunc() );
  2160. // zero entry data
  2161. // memset( entryData->text, 0, ENTRY_TEXT_LEN );
  2162. // memset( entryData->constructText, 0, ENTRY_TEXT_LEN );
  2163. // initialize character positions, legths etc
  2164. if( entryData->text )
  2165. entryData->charPos = entryData->text->getTextLength();
  2166. else
  2167. entryData->charPos = 0;
  2168. entryData->conCharPos = 0;
  2169. entryData->receivedUnichar = FALSE;
  2170. if( entryData->maxTextLen >= ENTRY_TEXT_LEN )
  2171. entryData->maxTextLen = ENTRY_TEXT_LEN;
  2172. // allocate entry data
  2173. data = NEW EntryData;
  2174. // copy over data control
  2175. memcpy( data, entryData, sizeof(EntryData) );
  2176. // allocate new text display string
  2177. data->text = TheDisplayStringManager->newDisplayString();
  2178. data->sText = TheDisplayStringManager->newDisplayString();
  2179. data->constructText = TheDisplayStringManager->newDisplayString();
  2180. // set the max for the text lengths
  2181. // data->text->allocateFixed( ENTRY_TEXT_LEN );
  2182. // data->sText->allocateFixed( ENTRY_TEXT_LEN );
  2183. // do any real display string copies
  2184. if( entryData->text )
  2185. data->text->setText( entryData->text->getText() );
  2186. if( entryData->sText )
  2187. data->sText->setText( entryData->sText->getText() );
  2188. // set data into window
  2189. entry->winSetUserData( data );
  2190. // asian languages get to have list box kanji character completion
  2191. data->constructList = NULL;
  2192. if( OurLanguage == LANGUAGE_ID_KOREAN ||
  2193. OurLanguage == LANGUAGE_ID_JAPANESE )
  2194. {
  2195. // we need to create the construct listbox
  2196. WinInstanceData boxInstData;
  2197. ListboxData lData;
  2198. // intialize instData
  2199. boxInstData.init();
  2200. // define display region
  2201. memset( &lData, 0, sizeof(ListboxData) );
  2202. lData.listLength = 128;
  2203. lData.autoScroll = FALSE;
  2204. lData.scrollIfAtEnd = FALSE;
  2205. lData.autoPurge = TRUE;
  2206. lData.scrollBar = TRUE;
  2207. lData.multiSelect = FALSE;
  2208. lData.columns = 1;
  2209. lData.columnWidth = NULL;
  2210. boxInstData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK;
  2211. data->constructList = gogoGadgetListBox( NULL,
  2212. WIN_STATUS_ABOVE |
  2213. WIN_STATUS_HIDDEN |
  2214. WIN_STATUS_NO_FOCUS |
  2215. WIN_STATUS_ONE_LINE,
  2216. 0, height,
  2217. 110, 119,
  2218. &boxInstData,
  2219. &lData,
  2220. NULL,
  2221. TRUE );
  2222. if( data->constructList == NULL )
  2223. {
  2224. DEBUG_LOG(( "gogoGadgetEntry warning: Failed to create listbox.\n" ));
  2225. assert( 0 );
  2226. winDestroy( entry );
  2227. return NULL;
  2228. } // end if
  2229. } // end, korean or japanese
  2230. // assign the default images/colors
  2231. assignDefaultGadgetLook( entry, defaultFont, defaultVisual );
  2232. // assign text from label
  2233. UnicodeString text = winTextLabelToText( instData->m_textLabelString );
  2234. if( text.getLength() )
  2235. GadgetTextEntrySetText( entry, text );
  2236. return entry;
  2237. } // end gogoGadgetTextEntry
  2238. //-------------------------------------------------------------------------------------------------
  2239. /** Use this method to assign the default images/colors to gadgets as
  2240. * they area created */
  2241. //-------------------------------------------------------------------------------------------------
  2242. void GameWindowManager::assignDefaultGadgetLook( GameWindow *gadget,
  2243. GameFont *defaultFont,
  2244. Bool assignVisual )
  2245. {
  2246. UnsignedByte alpha = 255;
  2247. static Color red = TheWindowManager->winMakeColor( 255, 0, 0, alpha );
  2248. static Color darkRed = TheWindowManager->winMakeColor( 128, 0, 0, alpha );
  2249. static Color lightRed = TheWindowManager->winMakeColor( 255, 128, 128, alpha );
  2250. static Color green = TheWindowManager->winMakeColor( 0, 255, 0, alpha );
  2251. static Color darkGreen = TheWindowManager->winMakeColor( 0, 128, 0, alpha );
  2252. static Color lightGreen = TheWindowManager->winMakeColor( 128, 255, 128, alpha );
  2253. static Color blue = TheWindowManager->winMakeColor( 0, 0, 255, alpha );
  2254. static Color darkBlue = TheWindowManager->winMakeColor( 0, 0, 128, alpha );
  2255. static Color lightBlue = TheWindowManager->winMakeColor( 128, 128, 255, alpha );
  2256. static Color purple = TheWindowManager->winMakeColor( 255, 0, 255, alpha );
  2257. static Color darkPurple = TheWindowManager->winMakeColor( 128, 0, 128, alpha );
  2258. static Color lightPurple= TheWindowManager->winMakeColor( 255, 128, 255, alpha );
  2259. static Color yellow = TheWindowManager->winMakeColor( 255, 255, 0, alpha );
  2260. static Color darkYellow = TheWindowManager->winMakeColor( 128, 128, 0, alpha );
  2261. static Color lightYellow= TheWindowManager->winMakeColor( 255, 255, 128, alpha );
  2262. static Color cyan = TheWindowManager->winMakeColor( 0, 255, 255, alpha );
  2263. static Color darkCyan = TheWindowManager->winMakeColor( 64, 128, 128, alpha );
  2264. static Color lightCyan = TheWindowManager->winMakeColor( 128, 255, 255, alpha );
  2265. static Color gray = TheWindowManager->winMakeColor( 128, 128, 128, alpha );
  2266. static Color darkGray = TheWindowManager->winMakeColor( 64, 64, 64, alpha );
  2267. static Color lightGray = TheWindowManager->winMakeColor( 192, 192, 192, alpha );
  2268. static Color black = TheWindowManager->winMakeColor( 0, 0, 0, alpha );
  2269. static Color white = TheWindowManager->winMakeColor( 254, 254, 254, alpha );
  2270. static Color enabledText = white;
  2271. static Color enabledTextBorder = darkGray;
  2272. static Color disabledText = darkGray;
  2273. static Color disabledTextBorder = black;
  2274. static Color hiliteText = lightBlue;
  2275. static Color hiliteTextBorder = blue;
  2276. static Color imeCompositeText = green;
  2277. static Color imeCompositeTextBorder = blue;
  2278. WinInstanceData *instData;
  2279. // sanity
  2280. if( gadget == NULL )
  2281. return;
  2282. // get instance data
  2283. instData = gadget->winGetInstanceData();
  2284. // set default font
  2285. if( defaultFont )
  2286. gadget->winSetFont( defaultFont );
  2287. else
  2288. {
  2289. if (TheGlobalLanguageData && TheGlobalLanguageData->m_defaultWindowFont.name.isNotEmpty())
  2290. { gadget->winSetFont( TheWindowManager->winFindFont(
  2291. TheGlobalLanguageData->m_defaultWindowFont.name,
  2292. TheGlobalLanguageData->m_defaultWindowFont.size,
  2293. TheGlobalLanguageData->m_defaultWindowFont.bold) );
  2294. }
  2295. else
  2296. gadget->winSetFont( TheWindowManager->winFindFont( AsciiString("Times New Roman"), 14, FALSE ) );
  2297. }
  2298. // if we don't want to assign default colors/images get out of here
  2299. if( assignVisual == FALSE )
  2300. return;
  2301. // create images for the correct gadget type
  2302. if( BitTest( instData->getStyle(), GWS_PUSH_BUTTON ) )
  2303. {
  2304. // enabled background
  2305. GadgetButtonSetEnabledImage( gadget, winFindImage( "PushButtonEnabled" ) );
  2306. GadgetButtonSetEnabledColor( gadget, red );
  2307. GadgetButtonSetEnabledBorderColor( gadget, lightRed );
  2308. // enabled selected button
  2309. GadgetButtonSetEnabledSelectedImage( gadget, winFindImage( "PushButtonEnabledSelected" ) );
  2310. GadgetButtonSetEnabledSelectedColor( gadget, yellow );
  2311. GadgetButtonSetEnabledSelectedBorderColor( gadget, white );
  2312. // Disabled background
  2313. GadgetButtonSetDisabledImage( gadget, winFindImage( "PushButtonDisabled" ) );
  2314. GadgetButtonSetDisabledColor( gadget, gray );
  2315. GadgetButtonSetDisabledBorderColor( gadget, lightGray );
  2316. // Disabled selected button
  2317. GadgetButtonSetDisabledSelectedImage( gadget, winFindImage( "PushButtonDisabledSelected" ) );
  2318. GadgetButtonSetDisabledSelectedColor( gadget, lightGray );
  2319. GadgetButtonSetDisabledSelectedBorderColor( gadget, gray );
  2320. // Hilite background
  2321. GadgetButtonSetHiliteImage( gadget, winFindImage( "PushButtonHilite" ) );
  2322. GadgetButtonSetHiliteColor( gadget, green );
  2323. GadgetButtonSetHiliteBorderColor( gadget, darkGreen );
  2324. // Hilite selected button
  2325. GadgetButtonSetHiliteSelectedImage( gadget, winFindImage( "PushButtonHiliteSelected" ) );
  2326. GadgetButtonSetHiliteSelectedColor( gadget, yellow );
  2327. GadgetButtonSetHiliteSelectedBorderColor( gadget, white );
  2328. // set default text colors for the gadget
  2329. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2330. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2331. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2332. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2333. } // end if
  2334. else if( BitTest( instData->getStyle(), GWS_CHECK_BOX ) )
  2335. {
  2336. // enabled background
  2337. GadgetCheckBoxSetEnabledImage( gadget, winFindImage( "CheckBoxEnabled" ) );
  2338. GadgetCheckBoxSetEnabledColor( gadget, red );
  2339. GadgetCheckBoxSetEnabledBorderColor( gadget, lightRed );
  2340. // enabled CheckBox unselected
  2341. GadgetCheckBoxSetEnabledUncheckedBoxImage( gadget, winFindImage( "CheckBoxEnabledBoxUnselected" ) );
  2342. GadgetCheckBoxSetEnabledUncheckedBoxColor( gadget, WIN_COLOR_UNDEFINED );
  2343. GadgetCheckBoxSetEnabledUncheckedBoxBorderColor( gadget, lightBlue );
  2344. // enabled CheckBox selected
  2345. GadgetCheckBoxSetEnabledCheckedBoxImage( gadget, winFindImage( "CheckBoxEnabledBoxSelected" ) );
  2346. GadgetCheckBoxSetEnabledCheckedBoxColor( gadget, blue );
  2347. GadgetCheckBoxSetEnabledCheckedBoxBorderColor( gadget, lightBlue );
  2348. // disabled background
  2349. GadgetCheckBoxSetDisabledImage( gadget, winFindImage( "CheckBoxDisabled" ) );
  2350. GadgetCheckBoxSetDisabledColor( gadget, gray );
  2351. GadgetCheckBoxSetDisabledBorderColor( gadget, lightGray );
  2352. // Disabled CheckBox unselected
  2353. GadgetCheckBoxSetDisabledUncheckedBoxImage( gadget, winFindImage( "CheckBoxDisabledBoxUnselected" ) );
  2354. GadgetCheckBoxSetDisabledUncheckedBoxColor( gadget, WIN_COLOR_UNDEFINED );
  2355. GadgetCheckBoxSetDisabledUncheckedBoxBorderColor( gadget, lightGray );
  2356. // Disabled CheckBox selected
  2357. GadgetCheckBoxSetDisabledCheckedBoxImage( gadget, winFindImage( "CheckBoxDisabledBoxSelected" ) );
  2358. GadgetCheckBoxSetDisabledCheckedBoxColor( gadget, darkGray );
  2359. GadgetCheckBoxSetDisabledCheckedBoxBorderColor( gadget, white );
  2360. // Hilite background
  2361. GadgetCheckBoxSetHiliteImage( gadget, winFindImage( "CheckBoxHilite" ) );
  2362. GadgetCheckBoxSetHiliteColor( gadget, green );
  2363. GadgetCheckBoxSetHiliteBorderColor( gadget, lightGreen );
  2364. // Hilite CheckBox unselected
  2365. GadgetCheckBoxSetHiliteUncheckedBoxImage( gadget, winFindImage( "CheckBoxHiliteBoxUnselected" ) );
  2366. GadgetCheckBoxSetHiliteUncheckedBoxColor( gadget, WIN_COLOR_UNDEFINED );
  2367. GadgetCheckBoxSetHiliteUncheckedBoxBorderColor( gadget, lightBlue );
  2368. // Hilite CheckBox selected
  2369. GadgetCheckBoxSetHiliteCheckedBoxImage( gadget, winFindImage( "CheckBoxHiliteBoxSelected" ) );
  2370. GadgetCheckBoxSetHiliteCheckedBoxColor( gadget, yellow );
  2371. GadgetCheckBoxSetHiliteCheckedBoxBorderColor( gadget, white );
  2372. // set default text colors for the gadget
  2373. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2374. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2375. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2376. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2377. } // end else if
  2378. else if( BitTest( instData->getStyle(), GWS_RADIO_BUTTON ) )
  2379. {
  2380. // enabled background
  2381. GadgetRadioSetEnabledImage( gadget, winFindImage( "RadioButtonEnabled" ) );
  2382. GadgetRadioSetEnabledColor( gadget, red );
  2383. GadgetRadioSetEnabledBorderColor( gadget, lightRed );
  2384. // enabled radio unselected
  2385. GadgetRadioSetEnabledUncheckedBoxImage( gadget, winFindImage( "RadioButtonEnabledBoxUnselected" ) );
  2386. GadgetRadioSetEnabledUncheckedBoxColor( gadget, darkRed );
  2387. GadgetRadioSetEnabledUncheckedBoxBorderColor( gadget, black );
  2388. // enabled radio selected
  2389. GadgetRadioSetEnabledCheckedBoxImage( gadget, winFindImage( "RadioButtonEnabledBoxSelected" ) );
  2390. GadgetRadioSetEnabledCheckedBoxColor( gadget, blue );
  2391. GadgetRadioSetEnabledCheckedBoxBorderColor( gadget, lightBlue );
  2392. // disabled background
  2393. GadgetRadioSetDisabledImage( gadget, winFindImage( "RadioButtonDisabled" ) );
  2394. GadgetRadioSetDisabledColor( gadget, gray );
  2395. GadgetRadioSetDisabledBorderColor( gadget, lightGray );
  2396. // Disabled radio unselected
  2397. GadgetRadioSetDisabledUncheckedBoxImage( gadget, winFindImage( "RadioButtonDisabledBoxUnselected" ) );
  2398. GadgetRadioSetDisabledUncheckedBoxColor( gadget, gray );
  2399. GadgetRadioSetDisabledUncheckedBoxBorderColor( gadget, lightGray );
  2400. // Disabled radio selected
  2401. GadgetRadioSetDisabledCheckedBoxImage( gadget, winFindImage( "RadioButtonDisabledBoxSelected" ) );
  2402. GadgetRadioSetDisabledCheckedBoxColor( gadget, darkGray );
  2403. GadgetRadioSetDisabledCheckedBoxBorderColor( gadget, white );
  2404. // Hilite background
  2405. GadgetRadioSetHiliteImage( gadget, winFindImage( "RadioButtonHilite" ) );
  2406. GadgetRadioSetHiliteColor( gadget, green );
  2407. GadgetRadioSetHiliteBorderColor( gadget, lightGreen );
  2408. // Hilite radio unselected
  2409. GadgetRadioSetHiliteUncheckedBoxImage( gadget, winFindImage( "RadioButtonHiliteBoxUnselected" ) );
  2410. GadgetRadioSetHiliteUncheckedBoxColor( gadget, darkGreen );
  2411. GadgetRadioSetHiliteUncheckedBoxBorderColor( gadget, lightGreen );
  2412. // Hilite radio selected
  2413. GadgetRadioSetHiliteCheckedBoxImage( gadget, winFindImage( "RadioButtonHiliteBoxSelected" ) );
  2414. GadgetRadioSetHiliteCheckedBoxColor( gadget, yellow );
  2415. GadgetRadioSetHiliteCheckedBoxBorderColor( gadget, white );
  2416. // set default text colors for the gadget
  2417. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2418. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2419. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2420. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2421. } // end else if
  2422. else if( BitTest( instData->getStyle(), GWS_HORZ_SLIDER ) )
  2423. {
  2424. // enabled
  2425. GadgetSliderSetEnabledImageLeft( gadget, winFindImage( "HSliderEnabledLeftEnd" ) );
  2426. GadgetSliderSetEnabledImageRight( gadget, winFindImage( "HSliderEnabledRightEnd" ) );
  2427. GadgetSliderSetEnabledImageCenter( gadget, winFindImage( "HSliderEnabledRepeatingCenter" ) );
  2428. GadgetSliderSetEnabledImageSmallCenter( gadget, winFindImage( "HSliderEnabledSmallRepeatingCenter" ) );
  2429. GadgetSliderSetEnabledColor( gadget, red );
  2430. GadgetSliderSetEnabledBorderColor( gadget, lightRed );
  2431. // disabled
  2432. GadgetSliderSetDisabledImageLeft( gadget, winFindImage( "HSliderDisabledLeftEnd" ) );
  2433. GadgetSliderSetDisabledImageRight( gadget, winFindImage( "HSliderDisabledRightEnd" ) );
  2434. GadgetSliderSetDisabledImageCenter( gadget, winFindImage( "HSliderDisabledRepeatingCenter" ) );
  2435. GadgetSliderSetDisabledImageSmallCenter( gadget, winFindImage( "HSliderDisabledSmallRepeatingCenter" ) );
  2436. GadgetSliderSetDisabledColor( gadget, red );
  2437. GadgetSliderSetDisabledBorderColor( gadget, lightRed );
  2438. // hilite
  2439. GadgetSliderSetHiliteImageLeft( gadget, winFindImage( "HSliderHiliteLeftEnd" ) );
  2440. GadgetSliderSetHiliteImageRight( gadget, winFindImage( "HSliderHiliteRightEnd" ) );
  2441. GadgetSliderSetHiliteImageCenter( gadget, winFindImage( "HSliderHiliteRepeatingCenter" ) );
  2442. GadgetSliderSetHiliteImageSmallCenter( gadget, winFindImage( "HSliderHiliteSmallRepeatingCenter" ) );
  2443. GadgetSliderSetHiliteColor( gadget, red );
  2444. GadgetSliderSetHiliteBorderColor( gadget, lightRed );
  2445. // set default text colors for the gadget
  2446. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2447. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2448. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2449. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2450. //
  2451. // set the default colors and images for the slider thumb
  2452. //
  2453. // enabled
  2454. GadgetSliderSetEnabledThumbImage( gadget, winFindImage( "HSliderThumbEnabled" ) );
  2455. GadgetSliderSetEnabledThumbColor( gadget, GadgetSliderGetEnabledColor( gadget ) );
  2456. GadgetSliderSetEnabledThumbBorderColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) );
  2457. GadgetSliderSetEnabledSelectedThumbImage( gadget, winFindImage( "HSliderThumbEnabled" ) );
  2458. GadgetSliderSetEnabledSelectedThumbColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) );
  2459. GadgetSliderSetEnabledSelectedThumbBorderColor( gadget, GadgetSliderGetEnabledColor( gadget ) );
  2460. // disabled
  2461. GadgetSliderSetDisabledThumbImage( gadget, winFindImage( "HSliderThumbDisabled" ) );
  2462. GadgetSliderSetDisabledThumbColor( gadget, GadgetSliderGetDisabledColor( gadget ) );
  2463. GadgetSliderSetDisabledThumbBorderColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) );
  2464. GadgetSliderSetDisabledSelectedThumbImage( gadget, winFindImage( "HSliderThumbDisabled" ) );
  2465. GadgetSliderSetDisabledSelectedThumbColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) );
  2466. GadgetSliderSetDisabledSelectedThumbBorderColor( gadget, GadgetSliderGetDisabledColor( gadget ) );
  2467. // hilite
  2468. GadgetSliderSetHiliteThumbImage( gadget, winFindImage( "HSliderThumbHilite" ) );
  2469. GadgetSliderSetHiliteThumbColor( gadget, GadgetSliderGetHiliteColor( gadget ) );
  2470. GadgetSliderSetHiliteThumbBorderColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) );
  2471. GadgetSliderSetHiliteSelectedThumbImage( gadget, winFindImage( "HSliderThumbHiliteSelected" ) );
  2472. GadgetSliderSetHiliteSelectedThumbColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) );
  2473. GadgetSliderSetHiliteSelectedThumbBorderColor( gadget, GadgetSliderGetHiliteColor( gadget ) );
  2474. } // end if
  2475. else if( BitTest( instData->getStyle(), GWS_VERT_SLIDER ) )
  2476. {
  2477. // enabled
  2478. GadgetSliderSetEnabledImageTop( gadget, winFindImage( "VSliderEnabledTopEnd" ) );
  2479. GadgetSliderSetEnabledImageBottom( gadget, winFindImage( "VSliderEnabledBottomEnd" ) );
  2480. GadgetSliderSetEnabledImageCenter( gadget, winFindImage( "VSliderEnabledRepeatingCenter" ) );
  2481. GadgetSliderSetEnabledImageSmallCenter( gadget, winFindImage( "VSliderEnabledSmallRepeatingCenter" ) );
  2482. GadgetSliderSetEnabledColor( gadget, red );
  2483. GadgetSliderSetEnabledBorderColor( gadget, lightRed );
  2484. // disabled
  2485. GadgetSliderSetDisabledImageTop( gadget, winFindImage( "VSliderDisabledTopEnd" ) );
  2486. GadgetSliderSetDisabledImageBottom( gadget, winFindImage( "VSliderDisabledBottomEnd" ) );
  2487. GadgetSliderSetDisabledImageCenter( gadget, winFindImage( "VSliderDisabledRepeatingCenter" ) );
  2488. GadgetSliderSetDisabledImageSmallCenter( gadget, winFindImage( "VSliderDisabledSmallRepeatingCenter" ) );
  2489. GadgetSliderSetDisabledColor( gadget, red );
  2490. GadgetSliderSetDisabledBorderColor( gadget, lightRed );
  2491. // hilite
  2492. GadgetSliderSetHiliteImageTop( gadget, winFindImage( "VSliderHiliteTopEnd" ) );
  2493. GadgetSliderSetHiliteImageBottom( gadget, winFindImage( "VSliderHiliteBottomEnd" ) );
  2494. GadgetSliderSetHiliteImageCenter( gadget, winFindImage( "VSliderHiliteRepeatingCenter" ) );
  2495. GadgetSliderSetHiliteImageSmallCenter( gadget, winFindImage( "VSliderHiliteSmallRepeatingCenter" ) );
  2496. GadgetSliderSetHiliteColor( gadget, red );
  2497. GadgetSliderSetHiliteBorderColor( gadget, lightRed );
  2498. // set default text colors for the gadget
  2499. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2500. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2501. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2502. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2503. //
  2504. // set the default colors and images for the slider thumb
  2505. //
  2506. // enabled
  2507. GadgetSliderSetEnabledThumbImage( gadget, winFindImage( "VSliderThumbEnabled" ) );
  2508. GadgetSliderSetEnabledThumbColor( gadget, GadgetSliderGetEnabledColor( gadget ) );
  2509. GadgetSliderSetEnabledThumbBorderColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) );
  2510. GadgetSliderSetEnabledSelectedThumbImage( gadget, winFindImage( "VSliderThumbEnabled" ) );
  2511. GadgetSliderSetEnabledSelectedThumbColor( gadget, GadgetSliderGetEnabledBorderColor( gadget ) );
  2512. GadgetSliderSetEnabledSelectedThumbBorderColor( gadget, GadgetSliderGetEnabledColor( gadget ) );
  2513. // disabled
  2514. GadgetSliderSetDisabledThumbImage( gadget, winFindImage( "VSliderThumbDisabled" ) );
  2515. GadgetSliderSetDisabledThumbColor( gadget, GadgetSliderGetDisabledColor( gadget ) );
  2516. GadgetSliderSetDisabledThumbBorderColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) );
  2517. GadgetSliderSetDisabledSelectedThumbImage( gadget, winFindImage( "VSliderThumbDisabled" ) );
  2518. GadgetSliderSetDisabledSelectedThumbColor( gadget, GadgetSliderGetDisabledBorderColor( gadget ) );
  2519. GadgetSliderSetDisabledSelectedThumbBorderColor( gadget, GadgetSliderGetDisabledColor( gadget ) );
  2520. // hilite
  2521. GadgetSliderSetHiliteThumbImage( gadget, winFindImage( "VSliderThumbHilite" ) );
  2522. GadgetSliderSetHiliteThumbColor( gadget, GadgetSliderGetHiliteColor( gadget ) );
  2523. GadgetSliderSetHiliteThumbBorderColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) );
  2524. GadgetSliderSetHiliteSelectedThumbImage( gadget, winFindImage( "VSliderThumbHiliteSelected" ) );
  2525. GadgetSliderSetHiliteSelectedThumbColor( gadget, GadgetSliderGetHiliteBorderColor( gadget ) );
  2526. GadgetSliderSetHiliteSelectedThumbBorderColor( gadget, GadgetSliderGetHiliteColor( gadget ) );
  2527. } // end else if
  2528. else if( BitTest( instData->getStyle(), GWS_SCROLL_LISTBOX ) )
  2529. {
  2530. ListboxData *listboxData = (ListboxData *)gadget->winGetUserData();
  2531. // set the colors
  2532. GadgetListBoxSetColors( gadget,
  2533. red, // enabled
  2534. lightRed, // enabled border
  2535. yellow, // enabled selected item
  2536. white, // enabled selected item border
  2537. gray, // disabled
  2538. lightGray, // disabled border
  2539. lightGray, // disabled selected item
  2540. white, // disabled selected item border
  2541. green, // hilite
  2542. darkGreen, // hilite border
  2543. white, // hilite selected item
  2544. darkGreen ); // hilite selected item border
  2545. // now set the images
  2546. // enabled
  2547. GadgetListBoxSetEnabledImage( gadget, winFindImage( "ListBoxEnabled" ) );
  2548. GadgetListBoxSetEnabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxEnabledSelectedItemLeftEnd" ) );
  2549. GadgetListBoxSetEnabledSelectedItemImageRight( gadget, winFindImage( "ListBoxEnabledSelectedItemRightEnd" ) );
  2550. GadgetListBoxSetEnabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemRepeatingCenter" ) );
  2551. GadgetListBoxSetEnabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemSmallRepeatingCenter" ) );
  2552. // disabled
  2553. GadgetListBoxSetDisabledImage( gadget, winFindImage( "ListBoxDisabled" ) );
  2554. GadgetListBoxSetDisabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxDisabledSelectedItemLeftEnd" ) );
  2555. GadgetListBoxSetDisabledSelectedItemImageRight( gadget, winFindImage( "ListBoxDisabledSelectedItemRightEnd" ) );
  2556. GadgetListBoxSetDisabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemRepeatingCenter" ) );
  2557. GadgetListBoxSetDisabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemSmallRepeatingCenter" ) );
  2558. // hilited
  2559. GadgetListBoxSetHiliteImage( gadget, winFindImage( "ListBoxHilite" ) );
  2560. GadgetListBoxSetHiliteSelectedItemImageLeft( gadget, winFindImage( "ListBoxHiliteSelectedItemLeftEnd" ) );
  2561. GadgetListBoxSetHiliteSelectedItemImageRight( gadget, winFindImage( "ListBoxHiliteSelectedItemRightEnd" ) );
  2562. GadgetListBoxSetHiliteSelectedItemImageCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemRepeatingCenter" ) );
  2563. GadgetListBoxSetHiliteSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemSmallRepeatingCenter" ) );
  2564. // assign default slider colors and images as part of the list box
  2565. GameWindow *slider = listboxData->slider;
  2566. if( slider )
  2567. {
  2568. GameWindow *upButton = listboxData->upButton;
  2569. GameWindow *downButton = listboxData->downButton;
  2570. // slider and slider thumb ----------------------------------------------
  2571. // enabled
  2572. GadgetSliderSetEnabledImageTop( slider, winFindImage( "VSliderLargeEnabledTopEnd" ) );
  2573. GadgetSliderSetEnabledImageBottom( slider, winFindImage( "VSliderLargeEnabledBottomEnd" ) );
  2574. GadgetSliderSetEnabledImageCenter( slider, winFindImage( "VSliderLargeEnabledRepeatingCenter" ) );
  2575. GadgetSliderSetEnabledImageSmallCenter( slider, winFindImage( "VSliderLargeEnabledSmallRepeatingCenter" ) );
  2576. GadgetSliderSetEnabledThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) );
  2577. GadgetSliderSetEnabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) );
  2578. // disabled
  2579. GadgetSliderSetDisabledImageTop( slider, winFindImage( "VSliderLargeDisabledTopEnd" ) );
  2580. GadgetSliderSetDisabledImageBottom( slider, winFindImage( "VSliderLargeDisabledBottomEnd" ) );
  2581. GadgetSliderSetDisabledImageCenter( slider, winFindImage( "VSliderLargeDisabledRepeatingCenter" ) );
  2582. GadgetSliderSetDisabledImageSmallCenter( slider, winFindImage( "VSliderLargeDisabledSmallRepeatingCenter" ) );
  2583. GadgetSliderSetDisabledThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) );
  2584. GadgetSliderSetDisabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) );
  2585. // hilite
  2586. GadgetSliderSetHiliteImageTop( slider, winFindImage( "VSliderLargeHiliteTopEnd" ) );
  2587. GadgetSliderSetHiliteImageBottom( slider, winFindImage( "VSliderLargeHiliteBottomEnd" ) );
  2588. GadgetSliderSetHiliteImageCenter( slider, winFindImage( "VSliderLargeHiliteRepeatingCenter" ) );
  2589. GadgetSliderSetHiliteImageSmallCenter( slider, winFindImage( "VSliderLargeHiliteSmallRepeatingCenter" ) );
  2590. GadgetSliderSetHiliteThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) );
  2591. GadgetSliderSetHiliteSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) );
  2592. // up button ------------------------------------------------------------
  2593. // enabled
  2594. GadgetButtonSetEnabledImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) );
  2595. GadgetButtonSetEnabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) );
  2596. // disabled
  2597. GadgetButtonSetDisabledImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) );
  2598. GadgetButtonSetDisabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) );
  2599. // hilite
  2600. GadgetButtonSetHiliteImage( upButton, winFindImage( "VSliderLargeUpButtonHilite" ) );
  2601. GadgetButtonSetHiliteSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonHiliteSelected" ) );
  2602. // down button ----------------------------------------------------------
  2603. // enabled
  2604. GadgetButtonSetEnabledImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) );
  2605. GadgetButtonSetEnabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) );
  2606. // disabled
  2607. GadgetButtonSetDisabledImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) );
  2608. GadgetButtonSetDisabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) );
  2609. // hilite
  2610. GadgetButtonSetHiliteImage( downButton, winFindImage( "VSliderLargeDownButtonHilite" ) );
  2611. GadgetButtonSetHiliteSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonHiliteSelected" ) );
  2612. } // end if
  2613. } // end else if
  2614. else if( BitTest( instData->getStyle(), GWS_COMBO_BOX ) )
  2615. {
  2616. // ComboBoxData *comboBoxData = (ComboBoxData *)gadget->winGetUserData();
  2617. GadgetComboBoxSetColors( gadget,
  2618. red, // enabled
  2619. lightRed, // enabled border
  2620. yellow, // enabled selected item
  2621. white, // enabled selected item border
  2622. gray, // disabled
  2623. lightGray, // disabled border
  2624. lightGray, // disabled selected item
  2625. white, // disabled selected item border
  2626. green, // hilite
  2627. darkGreen, // hilite border
  2628. white, // hilite selected item
  2629. darkGreen ); // hilite selected item border
  2630. // enabled
  2631. GadgetComboBoxSetEnabledImage( gadget, winFindImage( "ListBoxEnabled" ) );
  2632. GadgetComboBoxSetEnabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxEnabledSelectedItemLeftEnd" ) );
  2633. GadgetComboBoxSetEnabledSelectedItemImageRight( gadget, winFindImage( "ListBoxEnabledSelectedItemRightEnd" ) );
  2634. GadgetComboBoxSetEnabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemRepeatingCenter" ) );
  2635. GadgetComboBoxSetEnabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxEnabledSelectedItemSmallRepeatingCenter" ) );
  2636. // disabled
  2637. GadgetComboBoxSetDisabledImage( gadget, winFindImage( "ListBoxDisabled" ) );
  2638. GadgetComboBoxSetDisabledSelectedItemImageLeft( gadget, winFindImage( "ListBoxDisabledSelectedItemLeftEnd" ) );
  2639. GadgetComboBoxSetDisabledSelectedItemImageRight( gadget, winFindImage( "ListBoxDisabledSelectedItemRightEnd" ) );
  2640. GadgetComboBoxSetDisabledSelectedItemImageCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemRepeatingCenter" ) );
  2641. GadgetComboBoxSetDisabledSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxDisabledSelectedItemSmallRepeatingCenter" ) );
  2642. // hilited
  2643. GadgetComboBoxSetHiliteImage( gadget, winFindImage( "ListBoxHilite" ) );
  2644. GadgetComboBoxSetHiliteSelectedItemImageLeft( gadget, winFindImage( "ListBoxHiliteSelectedItemLeftEnd" ) );
  2645. GadgetComboBoxSetHiliteSelectedItemImageRight( gadget, winFindImage( "ListBoxHiliteSelectedItemRightEnd" ) );
  2646. GadgetComboBoxSetHiliteSelectedItemImageCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemRepeatingCenter" ) );
  2647. GadgetComboBoxSetHiliteSelectedItemImageSmallCenter( gadget, winFindImage( "ListBoxHiliteSelectedItemSmallRepeatingCenter" ) );
  2648. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2649. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2650. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2651. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2652. GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( gadget );
  2653. if ( dropDownButton )
  2654. {
  2655. // enabled background
  2656. GadgetButtonSetEnabledImage( dropDownButton, winFindImage( "PushButtonEnabled" ) );
  2657. // enabled selected button
  2658. GadgetButtonSetEnabledSelectedImage( dropDownButton, winFindImage( "PushButtonEnabledSelected" ) );
  2659. // Disabled background
  2660. GadgetButtonSetDisabledImage( dropDownButton, winFindImage( "PushButtonDisabled" ) );
  2661. // Disabled selected button
  2662. GadgetButtonSetDisabledSelectedImage( dropDownButton, winFindImage( "PushButtonDisabledSelected" ) );
  2663. // Hilite background
  2664. GadgetButtonSetHiliteImage( dropDownButton, winFindImage( "PushButtonHilite" ) );
  2665. // Hilite selected button
  2666. GadgetButtonSetHiliteSelectedImage( dropDownButton, winFindImage( "PushButtonHiliteSelected" ) );
  2667. }
  2668. GameWindow *editBox = GadgetComboBoxGetEditBox( gadget );
  2669. if ( editBox )
  2670. {
  2671. // enabled
  2672. GadgetTextEntrySetEnabledImageLeft( editBox, winFindImage( "TextEntryEnabledLeftEnd" ) );
  2673. GadgetTextEntrySetEnabledImageRight( editBox, winFindImage( "TextEntryEnabledRightEnd" ) );
  2674. GadgetTextEntrySetEnabledImageCenter( editBox, winFindImage( "TextEntryEnabledRepeatingCenter" ) );
  2675. GadgetTextEntrySetEnabledImageSmallCenter( editBox, winFindImage( "TextEntryEnabledSmallRepeatingCenter" ) );
  2676. // disabled
  2677. GadgetTextEntrySetDisabledImageLeft( editBox, winFindImage( "TextEntryDisabledLeftEnd" ) );
  2678. GadgetTextEntrySetDisabledImageRight( editBox, winFindImage( "TextEntryDisabledRightEnd" ) );
  2679. GadgetTextEntrySetDisabledImageCenter( editBox, winFindImage( "TextEntryDisabledRepeatingCenter" ) );
  2680. GadgetTextEntrySetDisabledImageSmallCenter( editBox, winFindImage( "TextEntryDisabledSmallRepeatingCenter" ) );
  2681. // hilited
  2682. GadgetTextEntrySetHiliteImageLeft( editBox, winFindImage( "TextEntryHiliteLeftEnd" ) );
  2683. GadgetTextEntrySetHiliteImageRight( editBox, winFindImage( "TextEntryHiliteRightEnd" ) );
  2684. GadgetTextEntrySetHiliteImageCenter( editBox, winFindImage( "TextEntryHiliteRepeatingCenter" ) );
  2685. GadgetTextEntrySetHiliteImageSmallCenter( editBox, winFindImage( "TextEntryHiliteSmallRepeatingCenter" ) );
  2686. }
  2687. GameWindow * listBox = GadgetComboBoxGetListBox( gadget );
  2688. if ( listBox )
  2689. {
  2690. // now set the images
  2691. // enabled
  2692. GadgetListBoxSetEnabledImage( listBox, winFindImage( "ListBoxEnabled" ) );
  2693. GadgetListBoxSetEnabledSelectedItemImageLeft( listBox, winFindImage( "ListBoxEnabledSelectedItemLeftEnd" ) );
  2694. GadgetListBoxSetEnabledSelectedItemImageRight( listBox, winFindImage( "ListBoxEnabledSelectedItemRightEnd" ) );
  2695. GadgetListBoxSetEnabledSelectedItemImageCenter( listBox, winFindImage( "ListBoxEnabledSelectedItemRepeatingCenter" ) );
  2696. GadgetListBoxSetEnabledSelectedItemImageSmallCenter( listBox, winFindImage( "ListBoxEnabledSelectedItemSmallRepeatingCenter" ) );
  2697. // disabled
  2698. GadgetListBoxSetDisabledImage( listBox, winFindImage( "ListBoxDisabled" ) );
  2699. GadgetListBoxSetDisabledSelectedItemImageLeft( listBox, winFindImage( "ListBoxDisabledSelectedItemLeftEnd" ) );
  2700. GadgetListBoxSetDisabledSelectedItemImageRight( listBox, winFindImage( "ListBoxDisabledSelectedItemRightEnd" ) );
  2701. GadgetListBoxSetDisabledSelectedItemImageCenter( listBox, winFindImage( "ListBoxDisabledSelectedItemRepeatingCenter" ) );
  2702. GadgetListBoxSetDisabledSelectedItemImageSmallCenter( listBox, winFindImage( "ListBoxDisabledSelectedItemSmallRepeatingCenter" ) );
  2703. // hilited
  2704. GadgetListBoxSetHiliteImage( listBox, winFindImage( "ListBoxHilite" ) );
  2705. GadgetListBoxSetHiliteSelectedItemImageLeft( listBox, winFindImage( "ListBoxHiliteSelectedItemLeftEnd" ) );
  2706. GadgetListBoxSetHiliteSelectedItemImageRight( listBox, winFindImage( "ListBoxHiliteSelectedItemRightEnd" ) );
  2707. GadgetListBoxSetHiliteSelectedItemImageCenter( listBox, winFindImage( "ListBoxHiliteSelectedItemRepeatingCenter" ) );
  2708. GadgetListBoxSetHiliteSelectedItemImageSmallCenter( listBox, winFindImage( "ListBoxHiliteSelectedItemSmallRepeatingCenter" ) );
  2709. // assign default slider colors and images as part of the list box
  2710. GameWindow *slider = GadgetListBoxGetSlider( listBox );
  2711. if( slider )
  2712. {
  2713. GameWindow *upButton = GadgetListBoxGetUpButton( listBox );
  2714. GameWindow *downButton = GadgetListBoxGetDownButton( listBox );
  2715. // slider and slider thumb ----------------------------------------------
  2716. // enabled
  2717. GadgetSliderSetEnabledImageTop( slider, winFindImage( "VSliderLargeEnabledTopEnd" ) );
  2718. GadgetSliderSetEnabledImageBottom( slider, winFindImage( "VSliderLargeEnabledBottomEnd" ) );
  2719. GadgetSliderSetEnabledImageCenter( slider, winFindImage( "VSliderLargeEnabledRepeatingCenter" ) );
  2720. GadgetSliderSetEnabledImageSmallCenter( slider, winFindImage( "VSliderLargeEnabledSmallRepeatingCenter" ) );
  2721. GadgetSliderSetEnabledThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) );
  2722. GadgetSliderSetEnabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbEnabled" ) );
  2723. // disabled
  2724. GadgetSliderSetDisabledImageTop( slider, winFindImage( "VSliderLargeDisabledTopEnd" ) );
  2725. GadgetSliderSetDisabledImageBottom( slider, winFindImage( "VSliderLargeDisabledBottomEnd" ) );
  2726. GadgetSliderSetDisabledImageCenter( slider, winFindImage( "VSliderLargeDisabledRepeatingCenter" ) );
  2727. GadgetSliderSetDisabledImageSmallCenter( slider, winFindImage( "VSliderLargeDisabledSmallRepeatingCenter" ) );
  2728. GadgetSliderSetDisabledThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) );
  2729. GadgetSliderSetDisabledSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbDisabled" ) );
  2730. // hilite
  2731. GadgetSliderSetHiliteImageTop( slider, winFindImage( "VSliderLargeHiliteTopEnd" ) );
  2732. GadgetSliderSetHiliteImageBottom( slider, winFindImage( "VSliderLargeHiliteBottomEnd" ) );
  2733. GadgetSliderSetHiliteImageCenter( slider, winFindImage( "VSliderLargeHiliteRepeatingCenter" ) );
  2734. GadgetSliderSetHiliteImageSmallCenter( slider, winFindImage( "VSliderLargeHiliteSmallRepeatingCenter" ) );
  2735. GadgetSliderSetHiliteThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) );
  2736. GadgetSliderSetHiliteSelectedThumbImage( slider, winFindImage( "VSliderLargeThumbHilite" ) );
  2737. // up button ------------------------------------------------------------
  2738. // enabled
  2739. GadgetButtonSetEnabledImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) );
  2740. GadgetButtonSetEnabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonEnabled" ) );
  2741. // disabled
  2742. GadgetButtonSetDisabledImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) );
  2743. GadgetButtonSetDisabledSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonDisabled" ) );
  2744. // hilite
  2745. GadgetButtonSetHiliteImage( upButton, winFindImage( "VSliderLargeUpButtonHilite" ) );
  2746. GadgetButtonSetHiliteSelectedImage( upButton, winFindImage( "VSliderLargeUpButtonHiliteSelected" ) );
  2747. // down button ----------------------------------------------------------
  2748. // enabled
  2749. GadgetButtonSetEnabledImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) );
  2750. GadgetButtonSetEnabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonEnabled" ) );
  2751. // disabled
  2752. GadgetButtonSetDisabledImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) );
  2753. GadgetButtonSetDisabledSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonDisabled" ) );
  2754. // hilite
  2755. GadgetButtonSetHiliteImage( downButton, winFindImage( "VSliderLargeDownButtonHilite" ) );
  2756. GadgetButtonSetHiliteSelectedImage( downButton, winFindImage( "VSliderLargeDownButtonHiliteSelected" ) );
  2757. } // end if
  2758. }
  2759. } // end else if
  2760. else if( BitTest( instData->getStyle(), GWS_PROGRESS_BAR ) )
  2761. {
  2762. // enabled
  2763. GadgetProgressBarSetEnabledColor( gadget, red );
  2764. GadgetProgressBarSetEnabledBorderColor( gadget, lightRed );
  2765. GadgetProgressBarSetEnabledImageLeft( gadget, winFindImage( "ProgressBarEnabledLeftEnd" ) );
  2766. GadgetProgressBarSetEnabledImageRight( gadget, winFindImage( "ProgressBarEnabledRightEnd" ) );
  2767. GadgetProgressBarSetEnabledImageCenter( gadget, winFindImage( "ProgressBarEnabledRepeatingCenter" ) );
  2768. GadgetProgressBarSetEnabledImageSmallCenter( gadget, winFindImage( "ProgressBarEnabledSmallRepeatingCenter" ) );
  2769. GadgetProgressBarSetEnabledBarColor( gadget, yellow );
  2770. GadgetProgressBarSetEnabledBarBorderColor( gadget, white );
  2771. GadgetProgressBarSetEnabledBarImageLeft( gadget, winFindImage( "ProgressBarEnabledBarLeftEnd" ) );
  2772. GadgetProgressBarSetEnabledBarImageRight( gadget, winFindImage( "ProgressBarEnabledBarRightEnd" ) );
  2773. GadgetProgressBarSetEnabledBarImageCenter( gadget, winFindImage( "ProgressBarEnabledBarRepeatingCenter" ) );
  2774. GadgetProgressBarSetEnabledBarImageSmallCenter( gadget, winFindImage( "ProgressBarEnabledBarSmallRepeatingCenter" ) );
  2775. // disabled
  2776. GadgetProgressBarSetDisabledColor( gadget, darkGray );
  2777. GadgetProgressBarSetDisabledBorderColor( gadget, lightGray );
  2778. GadgetProgressBarSetDisabledImageLeft( gadget, winFindImage( "ProgressBarDisabledLeftEnd" ) );
  2779. GadgetProgressBarSetDisabledImageRight( gadget, winFindImage( "ProgressBarDisabledRightEnd" ) );
  2780. GadgetProgressBarSetDisabledImageCenter( gadget, winFindImage( "ProgressBarDisabledRepeatingCenter" ) );
  2781. GadgetProgressBarSetDisabledImageSmallCenter( gadget, winFindImage( "ProgressBarDisabledSmallRepeatingCenter" ) );
  2782. GadgetProgressBarSetDisabledBarColor( gadget, lightGray );
  2783. GadgetProgressBarSetDisabledBarBorderColor( gadget, white );
  2784. GadgetProgressBarSetDisabledBarImageLeft( gadget, winFindImage( "ProgressBarDisabledBarLeftEnd" ) );
  2785. GadgetProgressBarSetDisabledBarImageRight( gadget, winFindImage( "ProgressBarDisabledBarRightEnd" ) );
  2786. GadgetProgressBarSetDisabledBarImageCenter( gadget, winFindImage( "ProgressBarDisabledBarRepeatingCenter" ) );
  2787. GadgetProgressBarSetDisabledBarImageSmallCenter( gadget, winFindImage( "ProgressBarDisabledBarSmallRepeatingCenter" ) );
  2788. // Hilite
  2789. GadgetProgressBarSetHiliteColor( gadget, green );
  2790. GadgetProgressBarSetHiliteBorderColor( gadget, darkGreen );
  2791. GadgetProgressBarSetHiliteImageLeft( gadget, winFindImage( "ProgressBarHiliteLeftEnd" ) );
  2792. GadgetProgressBarSetHiliteImageRight( gadget, winFindImage( "ProgressBarHiliteRightEnd" ) );
  2793. GadgetProgressBarSetHiliteImageCenter( gadget, winFindImage( "ProgressBarHiliteRepeatingCenter" ) );
  2794. GadgetProgressBarSetHiliteImageSmallCenter( gadget, winFindImage( "ProgressBarHiliteSmallRepeatingCenter" ) );
  2795. GadgetProgressBarSetHiliteBarColor( gadget, yellow );
  2796. GadgetProgressBarSetHiliteBarBorderColor( gadget, white );
  2797. GadgetProgressBarSetHiliteBarImageLeft( gadget, winFindImage( "ProgressBarHiliteBarLeftEnd" ) );
  2798. GadgetProgressBarSetHiliteBarImageRight( gadget, winFindImage( "ProgressBarHiliteBarRightEnd" ) );
  2799. GadgetProgressBarSetHiliteBarImageCenter( gadget, winFindImage( "ProgressBarHiliteBarRepeatingCenter" ) );
  2800. GadgetProgressBarSetHiliteBarImageSmallCenter( gadget, winFindImage( "ProgressBarHiliteBarSmallRepeatingCenter" ) );
  2801. } // end else if
  2802. else if( BitTest( instData->getStyle(), GWS_STATIC_TEXT ) )
  2803. {
  2804. // enabled
  2805. GadgetStaticTextSetEnabledImage( gadget, winFindImage( "StaticTextEnabled" ) );
  2806. GadgetStaticTextSetEnabledColor( gadget, red );
  2807. GadgetStaticTextSetEnabledBorderColor( gadget, lightRed );
  2808. // disabled
  2809. GadgetStaticTextSetDisabledImage( gadget, winFindImage( "StaticTextDisabled" ) );
  2810. GadgetStaticTextSetDisabledColor( gadget, darkGray );
  2811. GadgetStaticTextSetDisabledBorderColor( gadget, lightGray );
  2812. // hilite
  2813. GadgetStaticTextSetHiliteImage( gadget, winFindImage( "StaticTextHilite" ) );
  2814. GadgetStaticTextSetHiliteColor( gadget, darkGreen );
  2815. GadgetStaticTextSetHiliteBorderColor( gadget, lightGreen );
  2816. // set default text colors for the gadget
  2817. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2818. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2819. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2820. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2821. } // end else if
  2822. else if( BitTest( instData->getStyle(), GWS_ENTRY_FIELD ) )
  2823. {
  2824. // enabled
  2825. GadgetTextEntrySetEnabledImageLeft( gadget, winFindImage( "TextEntryEnabledLeftEnd" ) );
  2826. GadgetTextEntrySetEnabledImageRight( gadget, winFindImage( "TextEntryEnabledRightEnd" ) );
  2827. GadgetTextEntrySetEnabledImageCenter( gadget, winFindImage( "TextEntryEnabledRepeatingCenter" ) );
  2828. GadgetTextEntrySetEnabledImageSmallCenter( gadget, winFindImage( "TextEntryEnabledSmallRepeatingCenter" ) );
  2829. GadgetTextEntrySetEnabledColor( gadget, red );
  2830. GadgetTextEntrySetEnabledBorderColor( gadget, lightRed );
  2831. // disabled
  2832. GadgetTextEntrySetDisabledImageLeft( gadget, winFindImage( "TextEntryDisabledLeftEnd" ) );
  2833. GadgetTextEntrySetDisabledImageRight( gadget, winFindImage( "TextEntryDisabledRightEnd" ) );
  2834. GadgetTextEntrySetDisabledImageCenter( gadget, winFindImage( "TextEntryDisabledRepeatingCenter" ) );
  2835. GadgetTextEntrySetDisabledImageSmallCenter( gadget, winFindImage( "TextEntryDisabledSmallRepeatingCenter" ) );
  2836. GadgetTextEntrySetDisabledColor( gadget, gray );
  2837. GadgetTextEntrySetDisabledBorderColor( gadget, black );
  2838. // hilited
  2839. GadgetTextEntrySetHiliteImageLeft( gadget, winFindImage( "TextEntryHiliteLeftEnd" ) );
  2840. GadgetTextEntrySetHiliteImageRight( gadget, winFindImage( "TextEntryHiliteRightEnd" ) );
  2841. GadgetTextEntrySetHiliteImageCenter( gadget, winFindImage( "TextEntryHiliteRepeatingCenter" ) );
  2842. GadgetTextEntrySetHiliteImageSmallCenter( gadget, winFindImage( "TextEntryHiliteSmallRepeatingCenter" ) );
  2843. GadgetTextEntrySetHiliteColor( gadget, green );
  2844. GadgetTextEntrySetHiliteBorderColor( gadget, darkGreen );
  2845. // set default text colors for the gadget
  2846. gadget->winSetEnabledTextColors( enabledText, enabledTextBorder );
  2847. gadget->winSetDisabledTextColors( disabledText, disabledTextBorder );
  2848. gadget->winSetHiliteTextColors( hiliteText, hiliteTextBorder );
  2849. gadget->winSetIMECompositeTextColors( imeCompositeText, imeCompositeTextBorder );
  2850. } // end else if
  2851. } // end assignDefaultGadgetLook
  2852. //-------------------------------------------------------------------------------------------------
  2853. /** Given a text label, retreive the real localized text associated
  2854. * with that label */
  2855. //-------------------------------------------------------------------------------------------------
  2856. UnicodeString GameWindowManager::winTextLabelToText( AsciiString label )
  2857. {
  2858. // sanity
  2859. if( label.isEmpty() )
  2860. return UnicodeString::TheEmptyString;
  2861. /// @todo we need to write the string manager here, this is TEMPORARY!!!
  2862. UnicodeString tmp;
  2863. tmp.translate(label);
  2864. return tmp;
  2865. } // end winTextLabelToText
  2866. //-------------------------------------------------------------------------------------------------
  2867. /** find the top window at the given coordinates */
  2868. //-------------------------------------------------------------------------------------------------
  2869. GameWindow *GameWindowManager::getWindowUnderCursor( Int x, Int y, Bool ignoreEnabled )
  2870. {
  2871. if( m_mouseCaptor )
  2872. {
  2873. // in what what window within the captured window are we?
  2874. return m_mouseCaptor->winPointInChild( x, y, ignoreEnabled );
  2875. }
  2876. if( m_grabWindow )
  2877. {
  2878. // in what what window within the grabbed window are we?
  2879. return m_grabWindow->winPointInChild( x, y, ignoreEnabled );
  2880. }
  2881. GameWindow *window = NULL;
  2882. if( m_modalHead && m_modalHead->window )
  2883. {
  2884. return m_modalHead->window->winPointInChild( x, y, ignoreEnabled );
  2885. }
  2886. else
  2887. {
  2888. // search for top-level window which contains pointer
  2889. for( window = m_windowList; window; window = window->m_next )
  2890. {
  2891. if( BitTest( window->m_status, WIN_STATUS_ABOVE ) &&
  2892. !BitTest( window->m_status, WIN_STATUS_HIDDEN ) &&
  2893. x >= window->m_region.lo.x &&
  2894. x <= window->m_region.hi.x &&
  2895. y >= window->m_region.lo.y &&
  2896. y <= window->m_region.hi.y)
  2897. {
  2898. if( BitTest( window->m_status, WIN_STATUS_ENABLED ) || ignoreEnabled )
  2899. {
  2900. // determine which child window the mouse is in
  2901. window = window->winPointInChild( x, y, ignoreEnabled );
  2902. break; // exit for
  2903. }
  2904. } // end if
  2905. } // end for window
  2906. // check !above, below and hidden
  2907. if( window == NULL )
  2908. {
  2909. for( window = m_windowList; window; window = window->m_next )
  2910. {
  2911. if( !BitTest( window->m_status, WIN_STATUS_ABOVE |
  2912. WIN_STATUS_BELOW |
  2913. WIN_STATUS_HIDDEN ) &&
  2914. x >= window->m_region.lo.x &&
  2915. x <= window->m_region.hi.x &&
  2916. y >= window->m_region.lo.y &&
  2917. y <= window->m_region.hi.y)
  2918. {
  2919. if( BitTest( window->m_status, WIN_STATUS_ENABLED )|| ignoreEnabled)
  2920. {
  2921. // determine which child window the mouse is in
  2922. window = window->winPointInChild( x, y, ignoreEnabled );
  2923. break; // exit for
  2924. }
  2925. }
  2926. }
  2927. } // end if, window == NULL
  2928. // check below and !hidden
  2929. if( window == NULL )
  2930. {
  2931. for( window = m_windowList; window; window = window->m_next )
  2932. {
  2933. if( BitTest( window->m_status, WIN_STATUS_BELOW ) &&
  2934. !BitTest( window->m_status, WIN_STATUS_HIDDEN ) &&
  2935. x >= window->m_region.lo.x &&
  2936. x <= window->m_region.hi.x &&
  2937. y >= window->m_region.lo.y &&
  2938. y <= window->m_region.hi.y)
  2939. {
  2940. if( BitTest( window->m_status, WIN_STATUS_ENABLED )|| ignoreEnabled)
  2941. {
  2942. // determine which child window the mouse is in
  2943. window = window->winPointInChild( x, y, ignoreEnabled );
  2944. break; // exit for
  2945. }
  2946. }
  2947. }
  2948. } // end if
  2949. } // end else, no modal head
  2950. if( window )
  2951. {
  2952. if( BitTest( window->m_status, WIN_STATUS_NO_INPUT ))
  2953. {
  2954. // this window does not accept input, discard
  2955. window = NULL;
  2956. }
  2957. else if( ignoreEnabled && !( BitTest( window->m_status, WIN_STATUS_ENABLED ) ))
  2958. {
  2959. window = NULL;
  2960. }
  2961. }
  2962. return window;
  2963. }
  2964. ///////////////////////////////////////////////////////////////////////////////
  2965. ///////////////////////////////////////////////////////////////////////////////
  2966. ///////////////////////////////////////////////////////////////////////////////
  2967. ///////////////////////////////////////////////////////////////////////////////
  2968. ///////////////////////////////////////////////////////////////////////////////
  2969. //-------------------------------------------------------------------------------------------------
  2970. //-------------------------------------------------------------------------------------------------
  2971. static WindowMsgHandledType testGrab( GameWindow *window, UnsignedInt msg,
  2972. WindowMsgData mData1, WindowMsgData mData2 )
  2973. {
  2974. switch( msg )
  2975. {
  2976. case GWM_LEFT_DOWN: return MSG_HANDLED; // use it
  2977. }
  2978. return MSG_IGNORED;
  2979. }
  2980. //-------------------------------------------------------------------------------------------------
  2981. /** Just for testing */
  2982. //-------------------------------------------------------------------------------------------------
  2983. Bool GameWindowManager::initTestGUI( void )
  2984. {
  2985. // winCreateFromScript( "_ATest.wnd" );
  2986. return TRUE;
  2987. // UnsignedByte alpha = 200;
  2988. GameWindow *window;
  2989. UnsignedInt statusFlags = WIN_STATUS_ENABLED | WIN_STATUS_DRAGABLE | WIN_STATUS_IMAGE;
  2990. WinInstanceData instData;
  2991. // make some windows inside each other in the upper left
  2992. window = TheWindowManager->winCreate( NULL, statusFlags, 0, 0, 100, 100, NULL, NULL );
  2993. window->winSetInputFunc( testGrab );
  2994. window->winSetEnabledColor( 0, TheWindowManager->winMakeColor( 255, 254, 255, 255 ) );
  2995. window->winSetEnabledBorderColor( 0 , TheWindowManager->winMakeColor( 0, 0, 0, 255 ) );
  2996. window = TheWindowManager->winCreate( window, statusFlags, 10, 10, 50, 50, NULL, NULL );
  2997. window->winSetInputFunc( testGrab );
  2998. window->winSetEnabledColor( 0, TheWindowManager->winMakeColor( 128, 128, 128, 255 ) );
  2999. window->winSetEnabledBorderColor( 0 , TheWindowManager->winMakeColor( 0, 0, 0, 255 ) );
  3000. // make a push button
  3001. instData.init();
  3002. BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK );
  3003. instData.m_textLabelString = "What Up?";
  3004. window = TheWindowManager->gogoGadgetPushButton( NULL,
  3005. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3006. 200, 100,
  3007. 100, 30,
  3008. &instData, NULL, TRUE );
  3009. // make a push button
  3010. instData.init();
  3011. BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK );
  3012. instData.m_textLabelString = "Enabled";
  3013. window = TheWindowManager->gogoGadgetPushButton( NULL,
  3014. WIN_STATUS_ENABLED,
  3015. 330, 100,
  3016. 100, 30,
  3017. &instData, NULL, TRUE );
  3018. // make a push button
  3019. instData.init();
  3020. BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK );
  3021. instData.m_textLabelString = "Disabled";
  3022. window = TheWindowManager->gogoGadgetPushButton( NULL,
  3023. 0,
  3024. 450, 100,
  3025. 100, 30,
  3026. &instData, NULL, TRUE );
  3027. // make a check box
  3028. instData.init();
  3029. instData.m_style = GWS_CHECK_BOX | GWS_MOUSE_TRACK;
  3030. instData.m_textLabelString = "Check";
  3031. window = TheWindowManager->gogoGadgetCheckbox( NULL,
  3032. WIN_STATUS_ENABLED |
  3033. WIN_STATUS_IMAGE,
  3034. 200, 150,
  3035. 100, 30,
  3036. &instData, NULL, TRUE );
  3037. // make a check box
  3038. instData.init();
  3039. instData.m_style = GWS_CHECK_BOX | GWS_MOUSE_TRACK;
  3040. instData.m_textLabelString = "Check";
  3041. window = TheWindowManager->gogoGadgetCheckbox( NULL,
  3042. WIN_STATUS_ENABLED,
  3043. 330, 150,
  3044. 100, 30,
  3045. &instData, NULL, TRUE );
  3046. // make window to hold radio buttons
  3047. window = TheWindowManager->winCreate( NULL, WIN_STATUS_ENABLED | WIN_STATUS_DRAGABLE,
  3048. 200, 200, 250, 45, NULL );
  3049. window->winSetInputFunc( testGrab );
  3050. window->winSetEnabledColor( 0, TheWindowManager->winMakeColor( 50, 50, 50, 200 ) );
  3051. window->winSetEnabledBorderColor( 0, TheWindowManager->winMakeColor( 254, 254, 254, 255 ) );
  3052. // make a radio button
  3053. GameWindow *radio;
  3054. RadioButtonData rData;
  3055. instData.init();
  3056. instData.m_style = GWS_RADIO_BUTTON | GWS_MOUSE_TRACK;
  3057. instData.m_textLabelString = "Mama Said!";
  3058. rData.group = 1;
  3059. radio = TheWindowManager->gogoGadgetRadioButton( window,
  3060. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3061. 10, 10,
  3062. 100, 30,
  3063. &instData,
  3064. &rData, NULL, TRUE );
  3065. // make a radio button
  3066. instData.init();
  3067. instData.m_style = GWS_RADIO_BUTTON | GWS_MOUSE_TRACK;
  3068. instData.m_textLabelString = "On the Run";
  3069. radio = TheWindowManager->gogoGadgetRadioButton( window,
  3070. WIN_STATUS_ENABLED,
  3071. 130, 10,
  3072. 100, 30,
  3073. &instData,
  3074. &rData, NULL, TRUE );
  3075. GadgetRadioSetEnabledColor( radio, GameMakeColor( 0, 0, 255, 255 ) );
  3076. GadgetRadioSetEnabledBorderColor( radio, GameMakeColor( 0, 0, 255, 255 ) );
  3077. // make a listbox
  3078. ListboxData listData;
  3079. memset( &listData, 0, sizeof( ListboxData ) );
  3080. listData.listLength = 8;
  3081. listData.autoScroll = 1;
  3082. listData.scrollIfAtEnd = FALSE;
  3083. listData.autoPurge = 1;
  3084. listData.scrollBar = 1;
  3085. listData.multiSelect = 1;
  3086. listData.forceSelect = 0;
  3087. listData.columns = 1;
  3088. listData.columnWidth = NULL;
  3089. instData.init();
  3090. instData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK;
  3091. window = TheWindowManager->gogoGadgetListBox( NULL,
  3092. WIN_STATUS_ENABLED,
  3093. 200, 250,
  3094. 100, 100,
  3095. &instData,
  3096. &listData, NULL, TRUE );
  3097. GadgetListBoxAddEntryText( window, UnicodeString(L"Listbox text"),
  3098. TheWindowManager->winMakeColor( 255, 255, 255, 255 ), -1, 0 );
  3099. GadgetListBoxAddEntryText( window, UnicodeString(L"More text"),
  3100. TheWindowManager->winMakeColor( 105, 105, 255, 255 ), -1, 0 );
  3101. GadgetListBoxAddEntryText( window, UnicodeString(L"Nothing"),
  3102. TheWindowManager->winMakeColor( 105, 105, 255, 255 ), -1, 0 );
  3103. GadgetListBoxAddEntryText( window, UnicodeString(L"Seasons"),
  3104. TheWindowManager->winMakeColor( 105, 205, 255, 255 ), -1, 0 );
  3105. GadgetListBoxAddEntryText( window, UnicodeString(L"Misery"),
  3106. TheWindowManager->winMakeColor( 235, 105, 255, 255 ), -1, 0 );
  3107. GadgetListBoxAddEntryText( window, UnicodeString(L"Natural"),
  3108. TheWindowManager->winMakeColor( 105, 205, 45, 255 ), -1, 0 );
  3109. window->winSetFont( TheFontLibrary->getFont( AsciiString("Times New Roman"), 12, FALSE ) );
  3110. // make a listbox
  3111. memset( &listData, 0, sizeof( ListboxData ) );
  3112. listData.listLength = 8;
  3113. listData.autoScroll = 1;
  3114. listData.scrollIfAtEnd = FALSE;
  3115. listData.autoPurge = 1;
  3116. listData.scrollBar = 1;
  3117. listData.multiSelect = 0;
  3118. listData.forceSelect = 0;
  3119. listData.columns = 1;
  3120. listData.columnWidth = NULL;
  3121. instData.init();
  3122. instData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK;
  3123. window = TheWindowManager->gogoGadgetListBox( NULL,
  3124. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3125. 75, 250,
  3126. 100, 100,
  3127. &instData,
  3128. &listData, NULL, TRUE );
  3129. GadgetListBoxAddEntryText( window, UnicodeString(L"Listbox text"),
  3130. TheWindowManager->winMakeColor( 255, 255, 255, 255 ), -1, -1 );
  3131. GadgetListBoxAddEntryText( window, UnicodeString(L"More text"),
  3132. TheWindowManager->winMakeColor( 105, 105, 255, 255 ), -1, -1 );
  3133. GadgetListBoxAddEntryText( window, UnicodeString(L"Nothing"),
  3134. TheWindowManager->winMakeColor( 105, 105, 255, 255 ), -1, -1 );
  3135. GadgetListBoxAddEntryText( window, UnicodeString(L"Seasons"),
  3136. TheWindowManager->winMakeColor( 105, 205, 255, 255 ), -1, -1 );
  3137. GadgetListBoxAddEntryText( window, UnicodeString(L"Misery"),
  3138. TheWindowManager->winMakeColor( 235, 105, 255, 255 ), -1, -1 );
  3139. GadgetListBoxAddEntryText( window, UnicodeString(L"Natural"),
  3140. TheWindowManager->winMakeColor( 105, 205, 45, 255 ), -1, -1 );
  3141. // make a vert slider
  3142. SliderData sliderData;
  3143. memset( &sliderData, 0, sizeof( sliderData ) );
  3144. sliderData.maxVal = 100;
  3145. sliderData.minVal = 0;
  3146. sliderData.numTicks = 100;
  3147. sliderData.position = 0;
  3148. instData.init();
  3149. instData.m_style = GWS_VERT_SLIDER | GWS_MOUSE_TRACK;
  3150. window = TheWindowManager->gogoGadgetSlider( NULL,
  3151. WIN_STATUS_ENABLED,
  3152. 360, 250,
  3153. 11, 100,
  3154. &instData,
  3155. &sliderData, NULL, TRUE );
  3156. // make a vert slider
  3157. memset( &sliderData, 0, sizeof( sliderData ) );
  3158. sliderData.maxVal = 100;
  3159. sliderData.minVal = 0;
  3160. sliderData.numTicks = 100;
  3161. sliderData.position = 0;
  3162. instData.init();
  3163. instData.m_style = GWS_VERT_SLIDER | GWS_MOUSE_TRACK;
  3164. window = TheWindowManager->gogoGadgetSlider( NULL,
  3165. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3166. 400, 250,
  3167. 11, 100,
  3168. &instData,
  3169. &sliderData, NULL, TRUE );
  3170. // make a horizontal slider
  3171. memset( &sliderData, 0, sizeof( sliderData ) );
  3172. sliderData.maxVal = 100;
  3173. sliderData.minVal = 0;
  3174. sliderData.numTicks = 100;
  3175. sliderData.position = 0;
  3176. instData.init();
  3177. instData.m_style = GWS_HORZ_SLIDER | GWS_MOUSE_TRACK;
  3178. window = TheWindowManager->gogoGadgetSlider( NULL,
  3179. WIN_STATUS_ENABLED,
  3180. 200, 400,
  3181. 200, 11,
  3182. &instData,
  3183. &sliderData, NULL, TRUE );
  3184. // make a horizontal slider
  3185. memset( &sliderData, 0, sizeof( sliderData ) );
  3186. sliderData.maxVal = 100;
  3187. sliderData.minVal = 0;
  3188. sliderData.numTicks = 100;
  3189. sliderData.position = 0;
  3190. instData.init();
  3191. instData.m_style = GWS_HORZ_SLIDER | GWS_MOUSE_TRACK;
  3192. window = TheWindowManager->gogoGadgetSlider( NULL,
  3193. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3194. 200, 420,
  3195. 200, 11,
  3196. &instData,
  3197. &sliderData, NULL, TRUE );
  3198. // make a progress bar
  3199. instData.init();
  3200. instData.m_style = GWS_PROGRESS_BAR | GWS_MOUSE_TRACK;
  3201. window = TheWindowManager->gogoGadgetProgressBar( NULL,
  3202. WIN_STATUS_ENABLED,
  3203. 200, 450,
  3204. 250, 15,
  3205. &instData, NULL, TRUE );
  3206. // make a progress bar
  3207. instData.init();
  3208. instData.m_style = GWS_PROGRESS_BAR | GWS_MOUSE_TRACK;
  3209. window = TheWindowManager->gogoGadgetProgressBar( NULL,
  3210. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3211. 200, 470,
  3212. 250, 15,
  3213. &instData, NULL, TRUE );
  3214. // make some static text
  3215. TextData textData;
  3216. textData.centered = 1;
  3217. instData.init();
  3218. instData.m_style = GWS_STATIC_TEXT | GWS_MOUSE_TRACK;
  3219. instData.m_textLabelString = "Centered Static Text";
  3220. window = TheWindowManager->gogoGadgetStaticText( NULL,
  3221. WIN_STATUS_ENABLED,
  3222. 200, 490,
  3223. 300, 25,
  3224. &instData,
  3225. &textData, NULL, TRUE );
  3226. // make some static text
  3227. textData.centered = 0;
  3228. instData.init();
  3229. instData.m_style = GWS_STATIC_TEXT | GWS_MOUSE_TRACK;
  3230. instData.m_textLabelString = "Not Centered Static Text";
  3231. window = TheWindowManager->gogoGadgetStaticText( NULL,
  3232. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3233. 200, 520,
  3234. 300, 25,
  3235. &instData,
  3236. &textData, NULL, TRUE );
  3237. window->winSetEnabledTextColors( TheWindowManager->winMakeColor( 128, 128, 255, 255 ),
  3238. TheWindowManager->winMakeColor( 255, 255, 255, 255 ) );
  3239. // make some entry text
  3240. EntryData entryData;
  3241. memset( &entryData, 0, sizeof( entryData ) );
  3242. entryData.maxTextLen = 30;
  3243. instData.init();
  3244. instData.m_style = GWS_ENTRY_FIELD | GWS_MOUSE_TRACK;
  3245. instData.m_textLabelString = "Entry";
  3246. window = TheWindowManager->gogoGadgetTextEntry( NULL,
  3247. WIN_STATUS_ENABLED,
  3248. 450, 270,
  3249. 400, 30,
  3250. &instData,
  3251. &entryData, NULL, TRUE );
  3252. // make some entry text
  3253. memset( &entryData, 0, sizeof( entryData ) );
  3254. entryData.maxTextLen = 30;
  3255. instData.init();
  3256. instData.m_style = GWS_ENTRY_FIELD | GWS_MOUSE_TRACK;
  3257. instData.m_textLabelString = "Entry";
  3258. window = TheWindowManager->gogoGadgetTextEntry( NULL,
  3259. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  3260. 450, 310,
  3261. 400, 30,
  3262. &instData,
  3263. &entryData, NULL, TRUE );
  3264. return TRUE;
  3265. } // end initTestGUI
  3266. void GameWindowManager::winNextTab( GameWindow *window )
  3267. {
  3268. if(m_tabList.size() == 0|| m_modalHead)
  3269. return;
  3270. GameWindowList::iterator it = m_tabList.begin();
  3271. while( it != m_tabList.end())
  3272. {
  3273. if(*it == window)
  3274. {
  3275. it++;
  3276. break;
  3277. }
  3278. it++;
  3279. }
  3280. if(it != m_tabList.end())
  3281. winSetFocus(*it);
  3282. else
  3283. {
  3284. winSetFocus(*m_tabList.begin());
  3285. }
  3286. winSetLoneWindow(NULL);
  3287. }
  3288. void GameWindowManager::winPrevTab( GameWindow *window )
  3289. {
  3290. if(m_tabList.size() == 0 || m_modalHead)
  3291. return;
  3292. GameWindowList::reverse_iterator it = m_tabList.rbegin();
  3293. while( it != m_tabList.rend())
  3294. {
  3295. if(*it == window)
  3296. {
  3297. it++;
  3298. break;
  3299. }
  3300. it++;
  3301. }
  3302. if(it != m_tabList.rend())
  3303. winSetFocus(*it);
  3304. else
  3305. {
  3306. winSetFocus(*m_tabList.rbegin());
  3307. }
  3308. winSetLoneWindow(NULL);
  3309. }
  3310. void GameWindowManager::registerTabList( GameWindowList tabList )
  3311. {
  3312. m_tabList.clear();
  3313. m_tabList = tabList;
  3314. }
  3315. void GameWindowManager::clearTabList( void )
  3316. {
  3317. m_tabList.clear();
  3318. }