GameWindow.cpp 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792
  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: GameWindow.cpp ///////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: GameWindow.cpp
  36. //
  37. // Created: Dean Iverson, March 1998
  38. // Colin Day, June 2001
  39. //
  40. // Desc: Game window implementation
  41. //
  42. //-----------------------------------------------------------------------------
  43. ///////////////////////////////////////////////////////////////////////////////
  44. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  45. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  46. // USER INCLUDES //////////////////////////////////////////////////////////////
  47. #include "Common/AudioEventRTS.h"
  48. #include "Common/Language.h"
  49. #include "GameClient/WindowLayout.h"
  50. #include "GameClient/GameWindow.h"
  51. #include "GameClient/GameWindowManager.h"
  52. #include "GameClient/Gadget.h"
  53. #include "GameClient/DisplayStringManager.h"
  54. #include "GameClient/GadgetListBox.h"
  55. #include "GameClient/GadgetComboBox.h"
  56. #include "GameClient/GadgetTextEntry.h"
  57. #include "GameClient/GadgetStaticText.h"
  58. #include "GameClient/Mouse.h"
  59. #include "GameClient/SelectionXlat.h"
  60. #ifdef _INTERNAL
  61. // for occasional debugging...
  62. //#pragma optimize("", off)
  63. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  64. #endif
  65. // DEFINES ////////////////////////////////////////////////////////////////////
  66. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  67. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  68. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  69. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  70. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  71. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  72. // GameWindow::GameWindow =====================================================
  73. //=============================================================================
  74. GameWindow::GameWindow( void )
  75. {
  76. m_status = WIN_STATUS_NONE;
  77. m_size.x = 0;
  78. m_size.y = 0;
  79. m_region.lo.x = 0;
  80. m_region.lo.y = 0;
  81. m_region.hi.x = 0;
  82. m_region.hi.y = 0;
  83. m_cursorX = 0;
  84. m_cursorY = 0;
  85. m_userData = 0;
  86. m_inputData = NULL;
  87. winSetDrawFunc( TheWindowManager->getDefaultDraw() );
  88. winSetInputFunc( TheWindowManager->getDefaultInput() );
  89. winSetSystemFunc( TheWindowManager->getDefaultSystem() );
  90. // We use to set the default tooltip func to TheWindowManager->getDefaultTooltip()
  91. // but I removed this so that we can set in GUI edit a text string that will be the
  92. // default tool tip for a control.
  93. winSetTooltipFunc( NULL );
  94. m_next = NULL;
  95. m_prev = NULL;
  96. m_parent = NULL;
  97. m_child = NULL;
  98. m_nextLayout = NULL;
  99. m_prevLayout = NULL;
  100. m_layout = NULL;
  101. m_editData = NULL;
  102. } // end GameWindow
  103. // GameWindow::~GameWindow ====================================================
  104. //=============================================================================
  105. GameWindow::~GameWindow( void )
  106. {
  107. if( m_inputData )
  108. delete m_inputData;
  109. m_inputData = NULL;
  110. if( m_editData )
  111. delete m_editData;
  112. m_editData = NULL;
  113. } // end ~GameWindow
  114. // GameWindow::normalizeWindowRegion ==========================================
  115. /** Puts the upper left corner in the window's region.lo field */
  116. //=============================================================================
  117. void GameWindow::normalizeWindowRegion( void )
  118. {
  119. Int temp;
  120. if( m_region.lo.x > m_region.hi.x)
  121. {
  122. temp = m_region.lo.x;
  123. m_region.lo.x = m_region.hi.x;
  124. m_region.hi.x = temp;
  125. } // end if
  126. if( m_region.lo.y > m_region.hi.y )
  127. {
  128. temp = m_region.lo.y;
  129. m_region.lo.y = m_region.hi.y;
  130. m_region.hi.y = temp;
  131. } // end if
  132. } // end normalizeWindowRegion
  133. // GameWindow::findFirstLeaf ==================================================
  134. /** Returns the first leaf of the branch */
  135. //=============================================================================
  136. GameWindow *GameWindow::findFirstLeaf( void )
  137. {
  138. GameWindow *leaf = this;
  139. // Find the root of this branch
  140. while( leaf->m_parent )
  141. leaf = leaf->m_parent;
  142. // Find the first leaf
  143. while( leaf->m_child )
  144. leaf = leaf->m_child;
  145. return leaf;
  146. } // end findFirstLeaf
  147. // GameWindow::findLastLeaf ===================================================
  148. /** Returns the last leaf of the branch */
  149. //=============================================================================
  150. GameWindow *GameWindow::findLastLeaf( void )
  151. {
  152. GameWindow *leaf = this;
  153. // Find the root of this branch
  154. while( leaf->m_parent )
  155. leaf = leaf->m_parent;
  156. // Find the last leaf
  157. while( leaf->m_child )
  158. {
  159. leaf = leaf->m_child;
  160. while( leaf->m_next )
  161. leaf = leaf->m_next;
  162. } // end while
  163. return leaf;
  164. } // end findLastLeaf
  165. // GameWindow::findPrevLeaf ===================================================
  166. /** Returns the prev leaf of the tree */
  167. //=============================================================================
  168. GameWindow *GameWindow::findPrevLeaf( void )
  169. {
  170. GameWindow *leaf = this;
  171. if( leaf->m_prev )
  172. {
  173. leaf = leaf->m_prev;
  174. while( leaf->m_child &&
  175. BitTest( leaf->m_status, WIN_STATUS_TAB_STOP ) == FALSE )
  176. {
  177. leaf = leaf->m_child;
  178. while( leaf->m_next )
  179. leaf = leaf->m_next;
  180. } // end while
  181. return leaf;
  182. } // end if
  183. else
  184. {
  185. while( leaf->m_parent )
  186. {
  187. leaf = leaf->m_parent;
  188. if( leaf->m_parent && leaf->m_prev )
  189. {
  190. leaf = leaf->m_prev;
  191. while( leaf->m_child &&
  192. BitTest( leaf->m_status, WIN_STATUS_TAB_STOP ) == FALSE )
  193. {
  194. leaf = leaf->m_child;
  195. while( leaf->m_next )
  196. leaf = leaf->m_next;
  197. } // end while
  198. return leaf;
  199. } // end if
  200. } // end while
  201. if( leaf )
  202. return leaf->findLastLeaf();
  203. else
  204. return NULL;
  205. } // end else
  206. return NULL;
  207. } // end findPrevLeaf
  208. // GameWindow::findNextLeaf ===================================================
  209. /** Returns the next leaf of the tree */
  210. //=============================================================================
  211. GameWindow *GameWindow::findNextLeaf( void )
  212. {
  213. GameWindow *leaf = this;
  214. if( leaf->m_next )
  215. {
  216. if( leaf->m_next->m_status & WIN_STATUS_TAB_STOP )
  217. return leaf->m_next;
  218. for( leaf = leaf->m_next; leaf; leaf = leaf->m_child )
  219. if( leaf->m_child == NULL || BitTest( leaf->m_status,
  220. WIN_STATUS_TAB_STOP ) )
  221. return leaf;
  222. } // end if
  223. else
  224. {
  225. while( leaf->m_parent )
  226. {
  227. leaf = leaf->m_parent;
  228. if( leaf->m_parent && leaf->m_next )
  229. {
  230. for( leaf = leaf->m_next; leaf; leaf = leaf->m_child )
  231. if( leaf->m_child == NULL ||
  232. BitTest( leaf->m_status, WIN_STATUS_TAB_STOP ) )
  233. return leaf;
  234. } // end if
  235. } // end while
  236. if( leaf )
  237. return leaf->findFirstLeaf();
  238. else
  239. return NULL;
  240. } // end else
  241. return NULL;
  242. } // end findNextLeav
  243. // GameWindow::winNextTab =====================================================
  244. /** Go to next window in tab chain */
  245. //=============================================================================
  246. Int GameWindow::winNextTab( void )
  247. {
  248. /*
  249. GameWindow *newTab = this;
  250. Bool firstTry = TRUE;
  251. // Un-hilite the current window
  252. m_instData.m_state &= ~WIN_STATE_HILITED;
  253. do
  254. {
  255. if( m_parent == NULL && firstTry )
  256. {
  257. newTab = findLastLeaf( newTab );
  258. firstTry = FALSE;
  259. }
  260. else
  261. newTab = findPrevLeaf( newTab );
  262. } while( ( isEnabled( newTab ) == FALSE ) ||
  263. ( isHidden( newTab ) ) );
  264. newTab->instData.state |= WIN_STATE_HILITED;
  265. WinSetFocus( newTab );
  266. */
  267. return WIN_ERR_OK;
  268. } // end WinNextTab
  269. // GameWindow::winPrevTab =====================================================
  270. /** Go to previous window in tab chain */
  271. //=============================================================================
  272. Int GameWindow::winPrevTab( void )
  273. {
  274. /*
  275. GameWindow *newTab = this;
  276. Bool firstTry = TRUE;
  277. // Un-hilite the current window
  278. m_instData.m_state &= ~WIN_STATE_HILITED;
  279. do
  280. {
  281. if( m_parent == NULL && firstTry )
  282. {
  283. newTab = findFirstLeaf( newTab );
  284. firstTry = FALSE;
  285. } // end if
  286. else
  287. newTab = findNextLeaf( newTab );
  288. } while( ( isEnabled( newTab ) == FALSE ) ||
  289. ( isHidden( newTab ) ) );
  290. newTab->instData.state |= WIN_STATE_HILITED;
  291. WinSetFocus( newTab );
  292. */
  293. return WIN_ERR_OK;
  294. } // end WinPrevTab
  295. // GameWindow::winBringToTop ==================================================
  296. /** Bring this window to the top of the window list, if we have a parent
  297. * we will go to the top of the child list for that parent */
  298. //=============================================================================
  299. Int GameWindow::winBringToTop( void )
  300. {
  301. GameWindow *current;
  302. GameWindow *parent = winGetParent();
  303. if( parent )
  304. {
  305. TheWindowManager->unlinkChildWindow( this );
  306. TheWindowManager->addWindowToParent( this, parent );
  307. // TheWindowManager->addWindowToParentAtEnd( this, parent );
  308. } // end if
  309. else
  310. {
  311. // sanity, make sure this window is in the window list
  312. for( current = TheWindowManager->winGetWindowList();
  313. current != this;
  314. current = current->m_next)
  315. if (current == NULL)
  316. return WIN_ERR_INVALID_PARAMETER;
  317. // move to head of windowList
  318. TheWindowManager->unlinkWindow( this );
  319. TheWindowManager->linkWindow( this );
  320. } // end else
  321. //
  322. // if the window is part of a screen layout, move it to the top
  323. // of the screen layout to reflect the new position of the window
  324. // in the real window list (it's all about draw order :) )
  325. //
  326. if( m_layout )
  327. {
  328. WindowLayout *saveLayout = m_layout;
  329. //
  330. // note we must use saveScreen because removing the window from the
  331. // screen will clear the m_screen member (as it should for removing
  332. // a window from a screen)
  333. //
  334. saveLayout->removeWindow( this );
  335. saveLayout->addWindow( this );
  336. } // end if
  337. return WIN_ERR_OK;
  338. } // end winBringToTop
  339. // GameWindow::winActivate ====================================================
  340. /** Pop window to top of window list AND activate it */
  341. //=============================================================================
  342. Int GameWindow::winActivate( void )
  343. {
  344. Int returnCode;
  345. // bring window to top
  346. returnCode = winBringToTop();
  347. if( returnCode != WIN_ERR_OK )
  348. return returnCode;
  349. // activate it and unhide
  350. BitSet( m_status, WIN_STATUS_ACTIVE );
  351. winHide( FALSE );
  352. return WIN_ERR_OK;
  353. } // end WinActivate
  354. // GameWindow::winSetPosition =================================================
  355. /** Set the window's position */
  356. //=============================================================================
  357. Int GameWindow::winSetPosition( Int x, Int y )
  358. {
  359. m_region.lo.x = x;
  360. m_region.lo.y = y;
  361. m_region.hi.x = x + m_size.x;
  362. m_region.hi.y = y + m_size.y;
  363. normalizeWindowRegion();
  364. return WIN_ERR_OK;
  365. } // end WinSetPosition
  366. // WinGetPosition =============================================================
  367. /** Get the window's postion */
  368. //=============================================================================
  369. Int GameWindow::winGetPosition( Int *x, Int *y )
  370. {
  371. // sanity
  372. if( x == NULL || y == NULL )
  373. return WIN_ERR_INVALID_PARAMETER;
  374. *x = m_region.lo.x;
  375. *y = m_region.lo.y;
  376. return WIN_ERR_OK;
  377. } // end WinGetPosition
  378. // WinSetCursorPosition =============================================================
  379. /** Set the window's cursor postion */
  380. //=============================================================================
  381. Int GameWindow::winSetCursorPosition( Int x, Int y )
  382. {
  383. m_cursorX = x;
  384. m_cursorY = y;
  385. return WIN_ERR_OK;
  386. } // end WinSetCursorPosition
  387. // WinGetCursorPosition =============================================================
  388. /** Get the window's cursor postion */
  389. //=============================================================================
  390. Int GameWindow::winGetCursorPosition( Int *x, Int *y )
  391. {
  392. if ( x )
  393. {
  394. *x = m_cursorX;
  395. }
  396. if ( y )
  397. {
  398. *y = m_cursorY;
  399. }
  400. return WIN_ERR_OK;
  401. } // end WinGetPosition
  402. // GameWindow::winGetScreenPosition ===========================================
  403. /** Get the window's postion in screen coordinates */
  404. //=============================================================================
  405. Int GameWindow::winGetScreenPosition( Int *x, Int *y )
  406. {
  407. GameWindow *parent = m_parent;
  408. *x = m_region.lo.x;
  409. *y = m_region.lo.y;
  410. while( parent )
  411. {
  412. *x += parent->m_region.lo.x;
  413. *y += parent->m_region.lo.y;
  414. parent = parent->m_parent;
  415. } // end while
  416. return WIN_ERR_OK;
  417. } // end WinGetScreenPosition
  418. // GameWindow::winGetRegion ===================================================
  419. /** Get the window region */
  420. //=============================================================================
  421. Int GameWindow::winGetRegion( IRegion2D *region )
  422. {
  423. if( region )
  424. *region = m_region;
  425. return WIN_ERR_OK;
  426. } // end winGetRegion
  427. // GameWindow::winPointInWindow ===============================================
  428. /** Check to see if the given point is inside the window. Will
  429. * still return true if the point is actually in a child. */
  430. //=============================================================================
  431. Bool GameWindow::winPointInWindow( Int x, Int y )
  432. {
  433. Int winX, winY, width, height;
  434. winGetScreenPosition( &winX, &winY );
  435. winGetSize( &width, &height );
  436. if (x >= winX && x <= winX + width &&
  437. y >= winY && y <= winY + height)
  438. return TRUE;
  439. return FALSE;
  440. } // end WinPointInWindow
  441. // GameWindow::winSetSize =====================================================
  442. /** Set the window's size */
  443. //=============================================================================
  444. Int GameWindow::winSetSize( Int width, Int height )
  445. {
  446. m_size.x = width;
  447. m_size.y = height;
  448. m_region.hi.x = m_region.lo.x + width;
  449. m_region.hi.y = m_region.lo.y + height;
  450. TheWindowManager->winSendSystemMsg( this,
  451. GGM_RESIZED,
  452. (WindowMsgData)width,
  453. (WindowMsgData)height );
  454. return WIN_ERR_OK;
  455. } // end WinSetSize
  456. // GameWindow::winGetSize =====================================================
  457. /** Get the window's size */
  458. //=============================================================================
  459. Int GameWindow::winGetSize( Int *width, Int *height )
  460. {
  461. // sanity
  462. if( width == NULL || height == NULL )
  463. return WIN_ERR_INVALID_PARAMETER;
  464. *width = m_size.x;
  465. *height = m_size.y;
  466. return WIN_ERR_OK;
  467. } // end WinGetSize
  468. // GameWindow::winEnable ======================================================
  469. /** Enable or disable a window based on the enable parameter.
  470. * A disabled window can be seen but accepts no input. */
  471. //=============================================================================
  472. Int GameWindow::winEnable( Bool enable )
  473. {
  474. GameWindow *child;
  475. if( enable )
  476. BitSet( m_status, WIN_STATUS_ENABLED );
  477. else
  478. BitClear( m_status, WIN_STATUS_ENABLED );
  479. if( m_child )
  480. {
  481. for( child = m_child; child; child = child->m_next)
  482. child->winEnable( enable );
  483. } // end if
  484. return WIN_ERR_OK;
  485. } // end WinEnable
  486. // GameWindow::winHide ========================================================
  487. /** Hide or show a window based on the hide parameter.
  488. * A hidden window can't be seen and accepts no input. */
  489. //=============================================================================
  490. Int GameWindow::winHide( Bool hide )
  491. {
  492. if( hide )
  493. {
  494. //
  495. // if we're running in small game window mode and this window becomes
  496. // invisible then there's a good chance that the black border around
  497. // the game window needs redrawing
  498. //
  499. if( !BitTest( m_status, WIN_STATUS_NO_FLUSH ) )
  500. freeImages();
  501. BitSet( m_status, WIN_STATUS_HIDDEN );
  502. // notify the window manger we are hiding
  503. TheWindowManager->windowHiding( this );
  504. } // end if
  505. else
  506. {
  507. BitClear( m_status, WIN_STATUS_HIDDEN );
  508. } // end else
  509. return WIN_ERR_OK;
  510. } // end WinHide
  511. // GameWindow::winIsHidden ====================================================
  512. /** Am I hidden? */
  513. //=============================================================================
  514. Bool GameWindow::winIsHidden( void )
  515. {
  516. return BitTest( m_status, WIN_STATUS_HIDDEN );
  517. } // end WinIsHidden
  518. // GameWindow::winSetStatus ===================================================
  519. /** Allows the user to directly set a window's status flags. */
  520. //=============================================================================
  521. UnsignedInt GameWindow::winSetStatus( UnsignedInt status )
  522. {
  523. UnsignedInt oldStatus;
  524. oldStatus = m_status;
  525. BitSet( m_status, status );
  526. // m_status = status;
  527. return oldStatus;
  528. } // end WinSetStatus
  529. // GameWindow::winClearStatus =================================================
  530. /** Allows the user to directly clear a window's status flags. */
  531. //=============================================================================
  532. UnsignedInt GameWindow::winClearStatus( UnsignedInt status )
  533. {
  534. UnsignedInt oldStatus;
  535. oldStatus = m_status;
  536. BitClear( m_status, status );
  537. return oldStatus;
  538. } // end WinClearStatus
  539. // GameWindow::winGetStatus ===================================================
  540. /** Returns a window's status flags. */
  541. //=============================================================================
  542. UnsignedInt GameWindow::winGetStatus( void )
  543. {
  544. return m_status;
  545. } // end WinGetStatus
  546. // GameWindow::winGetStyle ====================================================
  547. /** Returns a window's style flags. */
  548. //=============================================================================
  549. UnsignedInt GameWindow::winGetStyle( void )
  550. {
  551. return m_instData.m_style;
  552. } // end WinGetStyle
  553. // GameWindow::winSetHiliteState ==============================================
  554. /** Set whether window is highlighted or not */
  555. //=============================================================================
  556. void GameWindow::winSetHiliteState( Bool state )
  557. {
  558. if( state )
  559. BitSet( m_instData.m_state, WIN_STATE_HILITED );
  560. else
  561. BitClear( m_instData.m_state, WIN_STATE_HILITED );
  562. } // end WinSetHiliteState
  563. // GameWindow::winSetDrawOffset ===============================================
  564. /** Set offset for drawing images */
  565. //=============================================================================
  566. void GameWindow::winSetDrawOffset( Int x, Int y )
  567. {
  568. m_instData.m_imageOffset.x = x;
  569. m_instData.m_imageOffset.y = y;
  570. } // end WinSetDrawOffset
  571. // GameWindow::winGetDrawOffset ===============================================
  572. /** Get offset for drawing images */
  573. //=============================================================================
  574. void GameWindow::winGetDrawOffset( Int *x, Int *y )
  575. {
  576. // sanity
  577. if( x == NULL || y == NULL )
  578. return;
  579. *x = m_instData.m_imageOffset.x;
  580. *y = m_instData.m_imageOffset.y;
  581. } // end WinGetDrawOffset
  582. // GameWindow::winSetText =====================================================
  583. /** Sets the text in a window */
  584. //=============================================================================
  585. Int GameWindow::winSetText( UnicodeString newText )
  586. {
  587. // copy text over
  588. m_instData.setText( newText );
  589. return WIN_ERR_OK;
  590. } // end WinSetText
  591. // GameWindow::winGetText =====================================================
  592. /** Get text from a window ... this works for static text windows and
  593. * edit boxes */
  594. //=============================================================================
  595. UnicodeString GameWindow::winGetText( void )
  596. {
  597. // return the contents of our text field
  598. return m_instData.getText();
  599. } // end WinGetText
  600. // GameWindow::winGetTextLength =====================================================
  601. //=============================================================================
  602. Int GameWindow::winGetTextLength()
  603. {
  604. // return the contents of our text field
  605. return m_instData.getTextLength();
  606. } // end WinGetText
  607. // GameWindow::winGetFont =====================================================
  608. /** Get the font being used by this window */
  609. //=============================================================================
  610. GameFont *GameWindow::winGetFont( void )
  611. {
  612. return m_instData.getFont();
  613. } // end WinGetFont
  614. // GameWindow::winSetFont =====================================================
  615. /** Set font for text in this window */
  616. //=============================================================================
  617. void GameWindow::winSetFont( GameFont *font )
  618. {
  619. // set font in window member
  620. m_instData.m_font = font;
  621. // set font for other display strings in special gadget window controls
  622. if( BitTest( m_instData.getStyle(), GWS_SCROLL_LISTBOX ) )
  623. GadgetListBoxSetFont( this, font );
  624. else if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  625. GadgetComboBoxSetFont( this, font );
  626. else if( BitTest( m_instData.getStyle(), GWS_ENTRY_FIELD ) )
  627. GadgetTextEntrySetFont( this, font );
  628. else if( BitTest( m_instData.getStyle(), GWS_STATIC_TEXT ) )
  629. GadgetStaticTextSetFont( this, font );
  630. else
  631. {
  632. DisplayString *dString;
  633. // set the font for the display strings all windows have
  634. dString = m_instData.getTextDisplayString();
  635. if( dString )
  636. dString->setFont( font );
  637. dString = m_instData.getTooltipDisplayString();
  638. if( dString )
  639. dString->setFont( font );
  640. } // end else
  641. } // end WinSetFont
  642. // GameWindow::winSetEnabledTextColors ========================================
  643. /** Set the text colors for the enabled state */
  644. //=============================================================================
  645. void GameWindow::winSetEnabledTextColors( Color color, Color borderColor )
  646. {
  647. m_instData.m_enabledText.color = color;
  648. m_instData.m_enabledText.borderColor = borderColor;
  649. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  650. GadgetComboBoxSetEnabledTextColors(this, color, borderColor );
  651. } // end winSetEnabledTextColors
  652. // GameWindow::winSetDisabledTextColors =======================================
  653. /** Set the text colors for the disabled state */
  654. //=============================================================================
  655. void GameWindow::winSetDisabledTextColors( Color color, Color borderColor )
  656. {
  657. m_instData.m_disabledText.color = color;
  658. m_instData.m_disabledText.borderColor = borderColor;
  659. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  660. GadgetComboBoxSetDisabledTextColors( this, color, borderColor );
  661. } // end winSetDisabledTextColors
  662. // GameWindow::winSetHiliteTextColors =========================================
  663. /** Set the text colors for the Hilite state */
  664. //=============================================================================
  665. void GameWindow::winSetHiliteTextColors( Color color, Color borderColor )
  666. {
  667. m_instData.m_hiliteText.color = color;
  668. m_instData.m_hiliteText.borderColor = borderColor;
  669. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  670. GadgetComboBoxSetHiliteTextColors( this, color, borderColor );
  671. } // end winSetHiliteTextColors
  672. // GameWindow::winSetIMECompositeTextColors =========================================
  673. /** Set the text colors for the IME Composite state */
  674. //=============================================================================
  675. void GameWindow::winSetIMECompositeTextColors( Color color, Color borderColor )
  676. {
  677. m_instData.m_imeCompositeText.color = color;
  678. m_instData.m_imeCompositeText.borderColor = borderColor;
  679. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  680. GadgetComboBoxSetIMECompositeTextColors( this, color, borderColor );
  681. } // end winSetIMECompositeTextColors
  682. // GameWindow::winGetEnabledTextColor =========================================
  683. /** Get the enabled text color */
  684. //=============================================================================
  685. Color GameWindow::winGetEnabledTextColor( void )
  686. {
  687. return m_instData.m_enabledText.color;
  688. } // end winGetEnabledTextColor
  689. // GameWindow::winGetEnabledTextBorderColor ===================================
  690. /** Get the enabled text color */
  691. //=============================================================================
  692. Color GameWindow::winGetEnabledTextBorderColor( void )
  693. {
  694. return m_instData.m_enabledText.borderColor;
  695. } // end winGetEnabledTextBorderColor
  696. // GameWindow::winGetDisabledTextColor ========================================
  697. /** Get the disabled text color */
  698. //=============================================================================
  699. Color GameWindow::winGetDisabledTextColor( void )
  700. {
  701. return m_instData.m_disabledText.color;
  702. } // end winGetDisabledTextColor
  703. // GameWindow::winGetDisabledTextBorderColor ==================================
  704. /** Get the disabled text color */
  705. //=============================================================================
  706. Color GameWindow::winGetDisabledTextBorderColor( void )
  707. {
  708. return m_instData.m_disabledText.borderColor;
  709. } // end winGetEnabledTextBorderColor
  710. // GameWindow::winGetIMECompositeTextColor ==========================================
  711. /** Get the IME composite text color */
  712. //=============================================================================
  713. Color GameWindow::winGetIMECompositeTextColor( void )
  714. {
  715. return m_instData.m_imeCompositeText.color;
  716. } // end winGetIMECompositeTextColor
  717. // GameWindow::winGetIMECompositeBorderColor ==========================================
  718. /** Get the IME composite border color */
  719. //=============================================================================
  720. Color GameWindow::winGetIMECompositeBorderColor( void )
  721. {
  722. return m_instData.m_imeCompositeText.borderColor;
  723. } // end winGetIMECompositeBorderColor
  724. // GameWindow::winGetHiliteTextColor ==========================================
  725. /** Get the hilite text color */
  726. //=============================================================================
  727. Color GameWindow::winGetHiliteTextColor( void )
  728. {
  729. return m_instData.m_hiliteText.color;
  730. } // end winGetHiliteTextColor
  731. // GameWindow::winGetHiliteTextBorderColor ====================================
  732. /** Get the hilite text color */
  733. //=============================================================================
  734. Color GameWindow::winGetHiliteTextBorderColor( void )
  735. {
  736. return m_instData.m_hiliteText.borderColor;
  737. } // end winGetHiliteTextBorderColor
  738. // GameWindow::winSetInstanceData =============================================
  739. /** Sets the window's instance data which includes parameters
  740. * such as background color. */
  741. //=============================================================================
  742. Int GameWindow::winSetInstanceData( WinInstanceData *data )
  743. {
  744. DisplayString *text, *tooltipText;
  745. // save our own instance of text and tooltip text display strings
  746. text = m_instData.m_text;
  747. tooltipText = m_instData.m_tooltip;
  748. // copy over all values from the inst data passed in
  749. // using memcpy is VERY VERY bad here, since the strings
  750. // must be copied 'correctly' or bad things will ensue
  751. m_instData = *data;
  752. // put our text instance pointers back
  753. m_instData.m_text = text;
  754. m_instData.m_tooltip = tooltipText;
  755. // make sure we didn't try to copy over a video buffer.
  756. m_instData.m_videoBuffer = NULL;
  757. // set our text display instance text if present
  758. if( data->getTextLength() )
  759. m_instData.setText( data->getText() );
  760. if( data->getTooltipTextLength() )
  761. m_instData.setTooltipText( data->getTooltipText() );
  762. return WIN_ERR_OK;
  763. } // end WinSetInstanceData
  764. // GameWindow::winGetInstanceData =============================================
  765. /** Return pointer to the instance data for this window */
  766. //=============================================================================
  767. WinInstanceData *GameWindow::winGetInstanceData( void )
  768. {
  769. return &m_instData;
  770. } // end WinGetInstanceData
  771. // GameWindow::winGetUserData =================================================
  772. /** Return the user data stored */
  773. //=============================================================================
  774. void *GameWindow::winGetUserData( void )
  775. {
  776. return m_userData;
  777. } // end WinGetUserData
  778. // GameWindow::winSetUserData =================================================
  779. /** Set the user data stored */
  780. //=============================================================================
  781. void GameWindow::winSetUserData( void *data )
  782. {
  783. m_userData = data;
  784. } // end WinSetUserData
  785. // GameWindow::winSetTooltip ==================================================
  786. /** Sets the window's tooltip text */
  787. //=============================================================================
  788. void GameWindow::winSetTooltip( UnicodeString tip )
  789. {
  790. m_instData.setTooltipText( tip );
  791. } // end WinSetTooltip
  792. // GameWindow::winSetWindowId =================================================
  793. /** Sets the window's id */
  794. //=============================================================================
  795. Int GameWindow::winSetWindowId( Int id )
  796. {
  797. m_instData.m_id = id;
  798. return WIN_ERR_OK;
  799. } // end WinSetWindowId
  800. // GameWindow::winGetWindowId =================================================
  801. /** Gets the window's id */
  802. //=============================================================================
  803. Int GameWindow::winGetWindowId( void )
  804. {
  805. return m_instData.m_id;
  806. } // end WinGetWindowId
  807. // GameWindow::winSetParent ===================================================
  808. /** Sets this window's parent */
  809. //=============================================================================
  810. Int GameWindow::winSetParent( GameWindow *parent )
  811. {
  812. if( m_parent == NULL)
  813. {
  814. // Top level window so unlink it
  815. TheWindowManager->unlinkWindow( this );
  816. }
  817. else
  818. {
  819. // A child window
  820. TheWindowManager->unlinkChildWindow( this );
  821. }
  822. if( parent == NULL )
  823. {
  824. // Want to make it a top level window so add to window list
  825. TheWindowManager->linkWindow( this );
  826. m_parent = NULL;
  827. }
  828. else
  829. {
  830. // Set it's new parent
  831. TheWindowManager->addWindowToParent( this, parent );
  832. }
  833. return WIN_ERR_OK;
  834. } // end WinSetParent
  835. // GameWindow::winGetParent ===================================================
  836. /** Gets the window's parent */
  837. //=============================================================================
  838. GameWindow *GameWindow::winGetParent( void )
  839. {
  840. return m_parent;
  841. } // end WinGetParent
  842. // GameWindow::winIsChild =====================================================
  843. /** Determins if a window is a child/grand-child of a parent */
  844. //=============================================================================
  845. Bool GameWindow::winIsChild( GameWindow *child )
  846. {
  847. while( child )
  848. {
  849. if( this == child->m_parent )
  850. return TRUE;
  851. // set up tree
  852. child = child->m_parent;
  853. } // end while
  854. return FALSE;
  855. } // end WinIsChild
  856. // GameWindow::winGetChild ====================================================
  857. /** Get the child window of this window */
  858. //=============================================================================
  859. GameWindow *GameWindow::winGetChild( void )
  860. {
  861. return m_child;
  862. } // end WinGetChild
  863. // GameWindow::winSetOwner ====================================================
  864. /** Sets the window's owner */
  865. //=============================================================================
  866. Int GameWindow::winSetOwner( GameWindow *owner )
  867. {
  868. if( owner == NULL )
  869. m_instData.m_owner = this;
  870. else
  871. m_instData.m_owner = owner;
  872. return WIN_ERR_OK;
  873. } // end WinSetOwner
  874. // GameWindow::winGetOwner ====================================================
  875. /** Gets the window's owner */
  876. //=============================================================================
  877. GameWindow *GameWindow::winGetOwner( void )
  878. {
  879. return m_instData.getOwner();
  880. } // end winGetOwner
  881. // GameWindow::winSetNext =====================================================
  882. /** Set next pointer */
  883. //=============================================================================
  884. void GameWindow::winSetNext( GameWindow *next )
  885. {
  886. m_next = next;
  887. } // end winSetNext
  888. // GameWindow::winGetNext =====================================================
  889. /** Gets the next window */
  890. //=============================================================================
  891. GameWindow *GameWindow::winGetNext( void )
  892. {
  893. return m_next;
  894. } // end winGetNext
  895. // GameWindow::winSetPrev =====================================================
  896. /** Set prev pointer */
  897. //=============================================================================
  898. void GameWindow::winSetPrev( GameWindow *prev )
  899. {
  900. m_prev = prev;
  901. } // end winSetPrev
  902. // GameWindow::winGetPrev =====================================================
  903. /** Get the previous window */
  904. //=============================================================================
  905. GameWindow *GameWindow::winGetPrev( void )
  906. {
  907. return m_prev;
  908. } // end winGetPrev
  909. // GameWindow::winSetNextInLayout =============================================
  910. /** Set next window in layout */
  911. //=============================================================================
  912. void GameWindow::winSetNextInLayout( GameWindow *next )
  913. {
  914. m_nextLayout = next;
  915. }
  916. // GameWindow::winSetPrevInLayout =============================================
  917. /** Set previous window in layout pointer */
  918. //=============================================================================
  919. void GameWindow::winSetPrevInLayout( GameWindow *prev )
  920. {
  921. m_prevLayout = prev;
  922. }
  923. // GameWindow::winSetLayout ===================================================
  924. /** Set this window as belonging to layout 'layout' */
  925. //=============================================================================
  926. void GameWindow::winSetLayout( WindowLayout *layout )
  927. {
  928. m_layout = layout;
  929. }
  930. // GameWindow::winGetLayout ===================================================
  931. /** Get layout this window is a part of, if any */
  932. //=============================================================================
  933. WindowLayout *GameWindow::winGetLayout( void )
  934. {
  935. return m_layout;
  936. }
  937. // GameWindow::winGetNextInLayout =============================================
  938. /** Get next window in layout list if any */
  939. //=============================================================================
  940. GameWindow *GameWindow::winGetNextInLayout( void )
  941. {
  942. return m_nextLayout;
  943. }
  944. // GameWindow::winGetPrevInLayout =============================================
  945. /** Get prev window in layout list if any */
  946. //=============================================================================
  947. GameWindow *GameWindow::winGetPrevInLayout( void )
  948. {
  949. return m_prevLayout;
  950. }
  951. // GameWindow::winSetSystemFunc ===============================================
  952. /** Sets the window's input, system, and redraw callback functions. */
  953. //=============================================================================
  954. Int GameWindow::winSetSystemFunc( GameWinSystemFunc system )
  955. {
  956. if( system )
  957. m_system = system;
  958. else
  959. m_system = TheWindowManager->getDefaultSystem();
  960. return WIN_ERR_OK;
  961. } // end WinSetSystemFunc
  962. // GameWindow::winSetInputFunc ================================================
  963. /** Sets the window's input callback functions. */
  964. //=============================================================================
  965. Int GameWindow::winSetInputFunc( GameWinInputFunc input )
  966. {
  967. if( input )
  968. m_input = input;
  969. else
  970. m_input = TheWindowManager->getDefaultInput();
  971. return WIN_ERR_OK;
  972. } // end WinSetInputFunc
  973. // GameWindow::winSetDrawFunc =================================================
  974. /** Sets the window's redraw callback functions. */
  975. //=============================================================================
  976. Int GameWindow::winSetDrawFunc( GameWinDrawFunc draw )
  977. {
  978. if( draw )
  979. m_draw = draw;
  980. else
  981. m_draw = TheWindowManager->getDefaultDraw();
  982. return WIN_ERR_OK;
  983. } // end WinSetDrawFunc
  984. // GameWindow::winSetTooltipFunc ==============================================
  985. /** Sets a window's tooltip callback */
  986. //=============================================================================
  987. Int GameWindow::winSetTooltipFunc( GameWinTooltipFunc tooltip )
  988. {
  989. m_tooltip = tooltip;
  990. return WIN_ERR_OK;
  991. } // end WinSetTooltipFunc
  992. // GameWindow::winSetCallbacks ================================================
  993. /** Sets the window's input, tooltip, and redraw callback functions. */
  994. //=============================================================================
  995. Int GameWindow::winSetCallbacks( GameWinInputFunc input,
  996. GameWinDrawFunc draw,
  997. GameWinTooltipFunc tooltip )
  998. {
  999. winSetInputFunc( input );
  1000. winSetDrawFunc( draw );
  1001. winSetTooltipFunc( tooltip );
  1002. return WIN_ERR_OK;
  1003. } // end WinSetCallbacks
  1004. // GameWindow::winDrawWindow ==================================================
  1005. /** Draws the default background for the specified window. */
  1006. //=============================================================================
  1007. Int GameWindow::winDrawWindow( void )
  1008. {
  1009. if( BitTest( m_status, WIN_STATUS_HIDDEN ) == FALSE && m_draw )
  1010. m_draw( this, &m_instData );
  1011. return WIN_ERR_OK;
  1012. } // end WinDrawWindow
  1013. // GameWindow::winPointInChild ================================================
  1014. /** Given a window and the mouse coordinates, return the child
  1015. * window which contains the mouse pointer. Child windows are
  1016. * relative to their parents */
  1017. //=============================================================================
  1018. GameWindow *GameWindow::winPointInChild( Int x, Int y, Bool ignoreEnableCheck, Bool playDisabledSound )
  1019. {
  1020. GameWindow *parent;
  1021. GameWindow *child;
  1022. ICoord2D origin;
  1023. for( child = m_child; child; child = child->m_next )
  1024. {
  1025. origin = child->m_region.lo;
  1026. parent = child->winGetParent();
  1027. while( parent )
  1028. {
  1029. origin.x += parent->m_region.lo.x;
  1030. origin.y += parent->m_region.lo.y;
  1031. parent = parent->m_parent;
  1032. } // end while
  1033. if( x >= origin.x && x <= origin.x + child->m_size.x &&
  1034. y >= origin.y && y <= origin.y + child->m_size.y )
  1035. {
  1036. Bool enabled = ignoreEnableCheck || BitTest( child->m_status, WIN_STATUS_ENABLED );
  1037. Bool hidden = BitTest( child->m_status, WIN_STATUS_HIDDEN );
  1038. if( !hidden )
  1039. {
  1040. if( enabled )
  1041. {
  1042. return child->winPointInChild( x, y, ignoreEnableCheck, playDisabledSound );
  1043. }
  1044. else if( playDisabledSound )
  1045. {
  1046. AudioEventRTS disabledClick( "GUIClickDisabled" );
  1047. if( TheAudio )
  1048. {
  1049. TheAudio->addAudioEvent( &disabledClick );
  1050. }
  1051. }
  1052. }
  1053. }
  1054. } // end for child
  1055. // not in any children, must be in parent
  1056. return this;
  1057. } // end WinPointInChild
  1058. // GameWindow::winPointInAnyChild =============================================
  1059. /** Find the child in which the cursor resides; regardless of
  1060. * whether or not the window is actually enabled */
  1061. //=============================================================================
  1062. GameWindow *GameWindow::winPointInAnyChild( Int x, Int y, Bool ignoreHidden, Bool ignoreEnableCheck )
  1063. {
  1064. GameWindow *parent;
  1065. GameWindow *child;
  1066. ICoord2D origin;
  1067. for( child = m_child; child; child = child->m_next )
  1068. {
  1069. origin = child->m_region.lo;
  1070. parent = child->m_parent;
  1071. while( parent )
  1072. {
  1073. origin.x += parent->m_region.lo.x;
  1074. origin.y += parent->m_region.lo.y;
  1075. parent = parent->m_parent;
  1076. } // end while
  1077. if( x >= origin.x && x <= origin.x + child->m_size.x &&
  1078. y >= origin.y && y <= origin.y + child->m_size.y )
  1079. {
  1080. if( !(ignoreHidden == TRUE && BitTest( child->m_status, WIN_STATUS_HIDDEN )) )
  1081. return child->winPointInChild( x, y, ignoreEnableCheck );
  1082. } // end if
  1083. } // end for child
  1084. // not in any children, must be in parent
  1085. return this;
  1086. } // end WinPointInAnyChild
  1087. //
  1088. // In release builds the default input and system functions are optimized
  1089. // to the same address since they take the same input and have the same
  1090. // body. Rather than fill them with bogus code we just want to make
  1091. // sure that different functions are actually created. If you change the
  1092. // body of one but not the other so they are different, please remove
  1093. // the dummy code
  1094. //
  1095. // GameWinDefaultInput ========================================================
  1096. /** The default input callback. Currently does nothing. */
  1097. //=============================================================================
  1098. WindowMsgHandledType GameWinDefaultInput( GameWindow *window, UnsignedInt msg,
  1099. WindowMsgData mData1, WindowMsgData mData2 )
  1100. {
  1101. return MSG_IGNORED;
  1102. } // end GameWinDefaultInput
  1103. ///< Input that blocks all (mouse) input like a wall, instead of passing like it wasn't there
  1104. WindowMsgHandledType GameWinBlockInput( GameWindow *window, UnsignedInt msg,
  1105. WindowMsgData mData1, WindowMsgData mData2 )
  1106. {
  1107. if (msg == GWM_CHAR || msg == GWM_MOUSE_POS)
  1108. return MSG_IGNORED;
  1109. //Added By Sadullah Nader
  1110. //Fix for drag selecting in the control bar
  1111. if (msg == GWM_LEFT_UP )//|| msg == GWM_LEFT_DRAG)
  1112. {
  1113. //stop drag selecting
  1114. TheSelectionTranslator->setLeftMouseButton(FALSE);
  1115. TheSelectionTranslator->setDragSelecting(FALSE);
  1116. TheTacticalView->setMouseLock( FALSE );
  1117. TheInGameUI->setSelecting( FALSE );
  1118. TheInGameUI->endAreaSelectHint(NULL);
  1119. }
  1120. return MSG_HANDLED;
  1121. } // end GameWinBlockInput
  1122. // GameWinDefaultSystem =======================================================
  1123. /** The default system callback. Currently does nothing. */
  1124. //=============================================================================
  1125. WindowMsgHandledType GameWinDefaultSystem( GameWindow *window, UnsignedInt msg,
  1126. WindowMsgData mData1, WindowMsgData mData2 )
  1127. {
  1128. return MSG_IGNORED;
  1129. } // end GameWinDefaultSystem
  1130. // GameWinDefaultTooltip ======================================================
  1131. /** Default tooltip callback */
  1132. //=============================================================================
  1133. void GameWinDefaultTooltip( GameWindow *window,
  1134. WinInstanceData *instData,
  1135. UnsignedInt mouse )
  1136. {
  1137. return;
  1138. } // end GameWinDefaultTooltip
  1139. // GameWinDefaultDraw =========================================================
  1140. /** Default draw, does nothing */
  1141. //=============================================================================
  1142. void GameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )
  1143. {
  1144. return;
  1145. } // end GameWinDefaultDraw
  1146. // GameWindow::winSetEnabledImage =============================================
  1147. /** Set an enabled image into the draw data for the enabled state */
  1148. //=============================================================================
  1149. Int GameWindow::winSetEnabledImage( Int index, const Image *image )
  1150. {
  1151. // sanity
  1152. if( index < 0 || index >= MAX_DRAW_DATA )
  1153. {
  1154. DEBUG_LOG(( "set enabled image, index out of range '%d'\n", index ));
  1155. assert( 0 );
  1156. return WIN_ERR_INVALID_PARAMETER;
  1157. } // end if
  1158. m_instData.m_enabledDrawData[ index ].image = image;
  1159. return WIN_ERR_OK;
  1160. } // end winSetEnabledImage
  1161. // GameWindow::winSetEnabledColor =============================================
  1162. /** set color for enabled state at index */
  1163. //=============================================================================
  1164. Int GameWindow::winSetEnabledColor( Int index, Color color )
  1165. {
  1166. // sanity
  1167. if( index < 0 || index >= MAX_DRAW_DATA )
  1168. {
  1169. DEBUG_LOG(( "set enabled color, index out of range '%d'\n", index ));
  1170. assert( 0 );
  1171. return WIN_ERR_INVALID_PARAMETER;
  1172. } // end if
  1173. m_instData.m_enabledDrawData[ index ].color = color;
  1174. return WIN_ERR_OK;
  1175. } // end winSetEnabledColor
  1176. // GameWindow::winSetEnabledBorderColor =======================================
  1177. /** set border color for state at this index */
  1178. //=============================================================================
  1179. Int GameWindow::winSetEnabledBorderColor( Int index, Color color )
  1180. {
  1181. // sanity
  1182. if( index < 0 || index >= MAX_DRAW_DATA )
  1183. {
  1184. DEBUG_LOG(( "set enabled border color, index out of range '%d'\n", index ));
  1185. assert( 0 );
  1186. return WIN_ERR_INVALID_PARAMETER;
  1187. } // end if
  1188. m_instData.m_enabledDrawData[ index ].borderColor = color;
  1189. return WIN_ERR_OK;
  1190. } // end winSetEnabledBorderColor
  1191. // GameWindow::winSetDisabledImage ============================================
  1192. /** Set an disabled image into the draw data for the disabled state */
  1193. //=============================================================================
  1194. Int GameWindow::winSetDisabledImage( Int index, const Image *image )
  1195. {
  1196. // sanity
  1197. if( index < 0 || index >= MAX_DRAW_DATA )
  1198. {
  1199. DEBUG_LOG(( "set disabled image, index out of range '%d'\n", index ));
  1200. assert( 0 );
  1201. return WIN_ERR_INVALID_PARAMETER;
  1202. } // end if
  1203. m_instData.m_disabledDrawData[ index ].image = image;
  1204. return WIN_ERR_OK;
  1205. } // end winSetDisabledImage
  1206. // GameWindow::winSetDisabledColor ============================================
  1207. /** set color for disabled state at index */
  1208. //=============================================================================
  1209. Int GameWindow::winSetDisabledColor( Int index, Color color )
  1210. {
  1211. // sanity
  1212. if( index < 0 || index >= MAX_DRAW_DATA )
  1213. {
  1214. DEBUG_LOG(( "set disabled color, index out of range '%d'\n", index ));
  1215. assert( 0 );
  1216. return WIN_ERR_INVALID_PARAMETER;
  1217. } // end if
  1218. m_instData.m_disabledDrawData[ index ].color = color;
  1219. return WIN_ERR_OK;
  1220. } // end winSetDisabledColor
  1221. // GameWindow::winSetDisabledBorderColor ======================================
  1222. /** set border color for state at this index */
  1223. //=============================================================================
  1224. Int GameWindow::winSetDisabledBorderColor( Int index, Color color )
  1225. {
  1226. // sanity
  1227. if( index < 0 || index >= MAX_DRAW_DATA )
  1228. {
  1229. DEBUG_LOG(( "set disabled border color, index out of range '%d'\n", index ));
  1230. assert( 0 );
  1231. return WIN_ERR_INVALID_PARAMETER;
  1232. } // end if
  1233. m_instData.m_disabledDrawData[ index ].borderColor = color;
  1234. return WIN_ERR_OK;
  1235. } // end winSetDisabledBorderColor
  1236. // GameWindow::winSetHiliteImage ==============================================
  1237. /** Set an hilite image into the draw data for the hilite state */
  1238. //=============================================================================
  1239. Int GameWindow::winSetHiliteImage( Int index, const Image *image )
  1240. {
  1241. // sanity
  1242. if( index < 0 || index >= MAX_DRAW_DATA )
  1243. {
  1244. DEBUG_LOG(( "set hilite image, index out of range '%d'\n", index ));
  1245. assert( 0 );
  1246. return WIN_ERR_INVALID_PARAMETER;
  1247. } // end if
  1248. m_instData.m_hiliteDrawData[ index ].image = image;
  1249. return WIN_ERR_OK;
  1250. } // end winSetHiliteImage
  1251. // GameWindow::winSetHiliteColor ==============================================
  1252. /** set color for hilite state at index */
  1253. //=============================================================================
  1254. Int GameWindow::winSetHiliteColor( Int index, Color color )
  1255. {
  1256. // sanity
  1257. if( index < 0 || index >= MAX_DRAW_DATA )
  1258. {
  1259. DEBUG_LOG(( "set hilite color, index out of range '%d'\n", index ));
  1260. assert( 0 );
  1261. return WIN_ERR_INVALID_PARAMETER;
  1262. } // end if
  1263. m_instData.m_hiliteDrawData[ index ].color = color;
  1264. return WIN_ERR_OK;
  1265. } // end winSetHiliteColor
  1266. // GameWindow::winSetHiliteBorderColor ========================================
  1267. /** set border color for state at this index */
  1268. //=============================================================================
  1269. Int GameWindow::winSetHiliteBorderColor( Int index, Color color )
  1270. {
  1271. // sanity
  1272. if( index < 0 || index >= MAX_DRAW_DATA )
  1273. {
  1274. DEBUG_LOG(( "set hilite border color, index out of range '%d'\n", index ));
  1275. assert( 0 );
  1276. return WIN_ERR_INVALID_PARAMETER;
  1277. } // end if
  1278. m_instData.m_hiliteDrawData[ index ].borderColor = color;
  1279. return WIN_ERR_OK;
  1280. } // end winSetHiliteBorderColor
  1281. // GameWindow::winGetInputFunc ================================================
  1282. //=============================================================================
  1283. GameWinInputFunc GameWindow::winGetInputFunc( void )
  1284. {
  1285. return m_input;
  1286. } // end winGetInputFunc
  1287. // GameWindow::winGetSystemFunc ===============================================
  1288. //=============================================================================
  1289. GameWinSystemFunc GameWindow::winGetSystemFunc( void )
  1290. {
  1291. return m_system;
  1292. } // end winGetSystemFunc
  1293. // GameWindow::winGetTooltipFunc ==============================================
  1294. //=============================================================================
  1295. GameWinTooltipFunc GameWindow::winGetTooltipFunc( void )
  1296. {
  1297. return m_tooltip;
  1298. } // end winGetTooltipFunc
  1299. // GameWindow::winGetDrawFunc =================================================
  1300. //=============================================================================
  1301. GameWinDrawFunc GameWindow::winGetDrawFunc( void )
  1302. {
  1303. return m_draw;
  1304. } // end winGetDrawFunc
  1305. // GameWindow::winSetEditData =================================================
  1306. //=============================================================================
  1307. void GameWindow::winSetEditData( GameWindowEditData *editData )
  1308. {
  1309. m_editData = editData;
  1310. } // end winSetEditData
  1311. // GameWindow::winGetEditData =================================================
  1312. //=============================================================================
  1313. GameWindowEditData *GameWindow::winGetEditData( void )
  1314. {
  1315. return m_editData;
  1316. } // end winGetEditData