GameWindow.cpp 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: 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::winGetEnabled ======================================================
  487. /** Enable or disable a window based on the enable parameter.
  488. * A disabled window can be seen but accepts no input. */
  489. //=============================================================================
  490. Bool GameWindow::winGetEnabled( void )
  491. {
  492. return BitTest( m_status, WIN_STATUS_ENABLED );
  493. } // end winGetEnabled
  494. // GameWindow::winHide ========================================================
  495. /** Hide or show a window based on the hide parameter.
  496. * A hidden window can't be seen and accepts no input. */
  497. //=============================================================================
  498. Int GameWindow::winHide( Bool hide )
  499. {
  500. if( hide )
  501. {
  502. //
  503. // if we're running in small game window mode and this window becomes
  504. // invisible then there's a good chance that the black border around
  505. // the game window needs redrawing
  506. //
  507. if( !BitTest( m_status, WIN_STATUS_NO_FLUSH ) )
  508. freeImages();
  509. BitSet( m_status, WIN_STATUS_HIDDEN );
  510. // notify the window manger we are hiding
  511. TheWindowManager->windowHiding( this );
  512. } // end if
  513. else
  514. {
  515. BitClear( m_status, WIN_STATUS_HIDDEN );
  516. } // end else
  517. return WIN_ERR_OK;
  518. } // end WinHide
  519. // GameWindow::winIsHidden ====================================================
  520. /** Am I hidden? */
  521. //=============================================================================
  522. Bool GameWindow::winIsHidden( void )
  523. {
  524. return BitTest( m_status, WIN_STATUS_HIDDEN );
  525. } // end WinIsHidden
  526. // GameWindow::winSetStatus ===================================================
  527. /** Allows the user to directly set a window's status flags. */
  528. //=============================================================================
  529. UnsignedInt GameWindow::winSetStatus( UnsignedInt status )
  530. {
  531. UnsignedInt oldStatus;
  532. oldStatus = m_status;
  533. BitSet( m_status, status );
  534. // m_status = status;
  535. return oldStatus;
  536. } // end WinSetStatus
  537. // GameWindow::winClearStatus =================================================
  538. /** Allows the user to directly clear a window's status flags. */
  539. //=============================================================================
  540. UnsignedInt GameWindow::winClearStatus( UnsignedInt status )
  541. {
  542. UnsignedInt oldStatus;
  543. oldStatus = m_status;
  544. BitClear( m_status, status );
  545. return oldStatus;
  546. } // end WinClearStatus
  547. // GameWindow::winGetStatus ===================================================
  548. /** Returns a window's status flags. */
  549. //=============================================================================
  550. UnsignedInt GameWindow::winGetStatus( void )
  551. {
  552. return m_status;
  553. } // end WinGetStatus
  554. // GameWindow::winGetStyle ====================================================
  555. /** Returns a window's style flags. */
  556. //=============================================================================
  557. UnsignedInt GameWindow::winGetStyle( void )
  558. {
  559. return m_instData.m_style;
  560. } // end WinGetStyle
  561. // GameWindow::winSetHiliteState ==============================================
  562. /** Set whether window is highlighted or not */
  563. //=============================================================================
  564. void GameWindow::winSetHiliteState( Bool state )
  565. {
  566. if( state )
  567. BitSet( m_instData.m_state, WIN_STATE_HILITED );
  568. else
  569. BitClear( m_instData.m_state, WIN_STATE_HILITED );
  570. } // end WinSetHiliteState
  571. // GameWindow::winSetDrawOffset ===============================================
  572. /** Set offset for drawing images */
  573. //=============================================================================
  574. void GameWindow::winSetDrawOffset( Int x, Int y )
  575. {
  576. m_instData.m_imageOffset.x = x;
  577. m_instData.m_imageOffset.y = y;
  578. } // end WinSetDrawOffset
  579. // GameWindow::winGetDrawOffset ===============================================
  580. /** Get offset for drawing images */
  581. //=============================================================================
  582. void GameWindow::winGetDrawOffset( Int *x, Int *y )
  583. {
  584. // sanity
  585. if( x == NULL || y == NULL )
  586. return;
  587. *x = m_instData.m_imageOffset.x;
  588. *y = m_instData.m_imageOffset.y;
  589. } // end WinGetDrawOffset
  590. // GameWindow::winSetText =====================================================
  591. /** Sets the text in a window */
  592. //=============================================================================
  593. Int GameWindow::winSetText( UnicodeString newText )
  594. {
  595. // copy text over
  596. m_instData.setText( newText );
  597. return WIN_ERR_OK;
  598. } // end WinSetText
  599. // GameWindow::winGetText =====================================================
  600. /** Get text from a window ... this works for static text windows and
  601. * edit boxes */
  602. //=============================================================================
  603. UnicodeString GameWindow::winGetText( void )
  604. {
  605. // return the contents of our text field
  606. return m_instData.getText();
  607. } // end WinGetText
  608. // GameWindow::winGetTextLength =====================================================
  609. //=============================================================================
  610. Int GameWindow::winGetTextLength()
  611. {
  612. // return the contents of our text field
  613. return m_instData.getTextLength();
  614. } // end WinGetText
  615. // GameWindow::winGetFont =====================================================
  616. /** Get the font being used by this window */
  617. //=============================================================================
  618. GameFont *GameWindow::winGetFont( void )
  619. {
  620. return m_instData.getFont();
  621. } // end WinGetFont
  622. // GameWindow::winSetFont =====================================================
  623. /** Set font for text in this window */
  624. //=============================================================================
  625. void GameWindow::winSetFont( GameFont *font )
  626. {
  627. // set font in window member
  628. m_instData.m_font = font;
  629. // set font for other display strings in special gadget window controls
  630. if( BitTest( m_instData.getStyle(), GWS_SCROLL_LISTBOX ) )
  631. GadgetListBoxSetFont( this, font );
  632. else if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  633. GadgetComboBoxSetFont( this, font );
  634. else if( BitTest( m_instData.getStyle(), GWS_ENTRY_FIELD ) )
  635. GadgetTextEntrySetFont( this, font );
  636. else if( BitTest( m_instData.getStyle(), GWS_STATIC_TEXT ) )
  637. GadgetStaticTextSetFont( this, font );
  638. else
  639. {
  640. DisplayString *dString;
  641. // set the font for the display strings all windows have
  642. dString = m_instData.getTextDisplayString();
  643. if( dString )
  644. dString->setFont( font );
  645. dString = m_instData.getTooltipDisplayString();
  646. if( dString )
  647. dString->setFont( font );
  648. } // end else
  649. } // end WinSetFont
  650. // GameWindow::winSetEnabledTextColors ========================================
  651. /** Set the text colors for the enabled state */
  652. //=============================================================================
  653. void GameWindow::winSetEnabledTextColors( Color color, Color borderColor )
  654. {
  655. m_instData.m_enabledText.color = color;
  656. m_instData.m_enabledText.borderColor = borderColor;
  657. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  658. GadgetComboBoxSetEnabledTextColors(this, color, borderColor );
  659. } // end winSetEnabledTextColors
  660. // GameWindow::winSetDisabledTextColors =======================================
  661. /** Set the text colors for the disabled state */
  662. //=============================================================================
  663. void GameWindow::winSetDisabledTextColors( Color color, Color borderColor )
  664. {
  665. m_instData.m_disabledText.color = color;
  666. m_instData.m_disabledText.borderColor = borderColor;
  667. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  668. GadgetComboBoxSetDisabledTextColors( this, color, borderColor );
  669. } // end winSetDisabledTextColors
  670. // GameWindow::winSetHiliteTextColors =========================================
  671. /** Set the text colors for the Hilite state */
  672. //=============================================================================
  673. void GameWindow::winSetHiliteTextColors( Color color, Color borderColor )
  674. {
  675. m_instData.m_hiliteText.color = color;
  676. m_instData.m_hiliteText.borderColor = borderColor;
  677. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  678. GadgetComboBoxSetHiliteTextColors( this, color, borderColor );
  679. } // end winSetHiliteTextColors
  680. // GameWindow::winSetIMECompositeTextColors =========================================
  681. /** Set the text colors for the IME Composite state */
  682. //=============================================================================
  683. void GameWindow::winSetIMECompositeTextColors( Color color, Color borderColor )
  684. {
  685. m_instData.m_imeCompositeText.color = color;
  686. m_instData.m_imeCompositeText.borderColor = borderColor;
  687. if( BitTest( m_instData.getStyle(), GWS_COMBO_BOX ) )
  688. GadgetComboBoxSetIMECompositeTextColors( this, color, borderColor );
  689. } // end winSetIMECompositeTextColors
  690. // GameWindow::winGetEnabledTextColor =========================================
  691. /** Get the enabled text color */
  692. //=============================================================================
  693. Color GameWindow::winGetEnabledTextColor( void )
  694. {
  695. return m_instData.m_enabledText.color;
  696. } // end winGetEnabledTextColor
  697. // GameWindow::winGetEnabledTextBorderColor ===================================
  698. /** Get the enabled text color */
  699. //=============================================================================
  700. Color GameWindow::winGetEnabledTextBorderColor( void )
  701. {
  702. return m_instData.m_enabledText.borderColor;
  703. } // end winGetEnabledTextBorderColor
  704. // GameWindow::winGetDisabledTextColor ========================================
  705. /** Get the disabled text color */
  706. //=============================================================================
  707. Color GameWindow::winGetDisabledTextColor( void )
  708. {
  709. return m_instData.m_disabledText.color;
  710. } // end winGetDisabledTextColor
  711. // GameWindow::winGetDisabledTextBorderColor ==================================
  712. /** Get the disabled text color */
  713. //=============================================================================
  714. Color GameWindow::winGetDisabledTextBorderColor( void )
  715. {
  716. return m_instData.m_disabledText.borderColor;
  717. } // end winGetEnabledTextBorderColor
  718. // GameWindow::winGetIMECompositeTextColor ==========================================
  719. /** Get the IME composite text color */
  720. //=============================================================================
  721. Color GameWindow::winGetIMECompositeTextColor( void )
  722. {
  723. return m_instData.m_imeCompositeText.color;
  724. } // end winGetIMECompositeTextColor
  725. // GameWindow::winGetIMECompositeBorderColor ==========================================
  726. /** Get the IME composite border color */
  727. //=============================================================================
  728. Color GameWindow::winGetIMECompositeBorderColor( void )
  729. {
  730. return m_instData.m_imeCompositeText.borderColor;
  731. } // end winGetIMECompositeBorderColor
  732. // GameWindow::winGetHiliteTextColor ==========================================
  733. /** Get the hilite text color */
  734. //=============================================================================
  735. Color GameWindow::winGetHiliteTextColor( void )
  736. {
  737. return m_instData.m_hiliteText.color;
  738. } // end winGetHiliteTextColor
  739. // GameWindow::winGetHiliteTextBorderColor ====================================
  740. /** Get the hilite text color */
  741. //=============================================================================
  742. Color GameWindow::winGetHiliteTextBorderColor( void )
  743. {
  744. return m_instData.m_hiliteText.borderColor;
  745. } // end winGetHiliteTextBorderColor
  746. // GameWindow::winSetInstanceData =============================================
  747. /** Sets the window's instance data which includes parameters
  748. * such as background color. */
  749. //=============================================================================
  750. Int GameWindow::winSetInstanceData( WinInstanceData *data )
  751. {
  752. DisplayString *text, *tooltipText;
  753. // save our own instance of text and tooltip text display strings
  754. text = m_instData.m_text;
  755. tooltipText = m_instData.m_tooltip;
  756. // copy over all values from the inst data passed in
  757. // using memcpy is VERY VERY bad here, since the strings
  758. // must be copied 'correctly' or bad things will ensue
  759. m_instData = *data;
  760. // put our text instance pointers back
  761. m_instData.m_text = text;
  762. m_instData.m_tooltip = tooltipText;
  763. // make sure we didn't try to copy over a video buffer.
  764. m_instData.m_videoBuffer = NULL;
  765. // set our text display instance text if present
  766. if( data->getTextLength() )
  767. m_instData.setText( data->getText() );
  768. if( data->getTooltipTextLength() )
  769. m_instData.setTooltipText( data->getTooltipText() );
  770. return WIN_ERR_OK;
  771. } // end WinSetInstanceData
  772. // GameWindow::winGetInstanceData =============================================
  773. /** Return pointer to the instance data for this window */
  774. //=============================================================================
  775. WinInstanceData *GameWindow::winGetInstanceData( void )
  776. {
  777. return &m_instData;
  778. } // end WinGetInstanceData
  779. // GameWindow::winGetUserData =================================================
  780. /** Return the user data stored */
  781. //=============================================================================
  782. void *GameWindow::winGetUserData( void )
  783. {
  784. return m_userData;
  785. } // end WinGetUserData
  786. // GameWindow::winSetUserData =================================================
  787. /** Set the user data stored */
  788. //=============================================================================
  789. void GameWindow::winSetUserData( void *data )
  790. {
  791. m_userData = data;
  792. } // end WinSetUserData
  793. // GameWindow::winSetTooltip ==================================================
  794. /** Sets the window's tooltip text */
  795. //=============================================================================
  796. void GameWindow::winSetTooltip( UnicodeString tip )
  797. {
  798. m_instData.setTooltipText( tip );
  799. } // end WinSetTooltip
  800. // GameWindow::winSetWindowId =================================================
  801. /** Sets the window's id */
  802. //=============================================================================
  803. Int GameWindow::winSetWindowId( Int id )
  804. {
  805. m_instData.m_id = id;
  806. return WIN_ERR_OK;
  807. } // end WinSetWindowId
  808. // GameWindow::winGetWindowId =================================================
  809. /** Gets the window's id */
  810. //=============================================================================
  811. Int GameWindow::winGetWindowId( void )
  812. {
  813. return m_instData.m_id;
  814. } // end WinGetWindowId
  815. // GameWindow::winSetParent ===================================================
  816. /** Sets this window's parent */
  817. //=============================================================================
  818. Int GameWindow::winSetParent( GameWindow *parent )
  819. {
  820. if( m_parent == NULL)
  821. {
  822. // Top level window so unlink it
  823. TheWindowManager->unlinkWindow( this );
  824. }
  825. else
  826. {
  827. // A child window
  828. TheWindowManager->unlinkChildWindow( this );
  829. }
  830. if( parent == NULL )
  831. {
  832. // Want to make it a top level window so add to window list
  833. TheWindowManager->linkWindow( this );
  834. m_parent = NULL;
  835. }
  836. else
  837. {
  838. // Set it's new parent
  839. TheWindowManager->addWindowToParent( this, parent );
  840. }
  841. return WIN_ERR_OK;
  842. } // end WinSetParent
  843. // GameWindow::winGetParent ===================================================
  844. /** Gets the window's parent */
  845. //=============================================================================
  846. GameWindow *GameWindow::winGetParent( void )
  847. {
  848. return m_parent;
  849. } // end WinGetParent
  850. // GameWindow::winIsChild =====================================================
  851. /** Determins if a window is a child/grand-child of a parent */
  852. //=============================================================================
  853. Bool GameWindow::winIsChild( GameWindow *child )
  854. {
  855. while( child )
  856. {
  857. if( this == child->m_parent )
  858. return TRUE;
  859. // set up tree
  860. child = child->m_parent;
  861. } // end while
  862. return FALSE;
  863. } // end WinIsChild
  864. // GameWindow::winGetChild ====================================================
  865. /** Get the child window of this window */
  866. //=============================================================================
  867. GameWindow *GameWindow::winGetChild( void )
  868. {
  869. return m_child;
  870. } // end WinGetChild
  871. // GameWindow::winSetOwner ====================================================
  872. /** Sets the window's owner */
  873. //=============================================================================
  874. Int GameWindow::winSetOwner( GameWindow *owner )
  875. {
  876. if( owner == NULL )
  877. m_instData.m_owner = this;
  878. else
  879. m_instData.m_owner = owner;
  880. return WIN_ERR_OK;
  881. } // end WinSetOwner
  882. // GameWindow::winGetOwner ====================================================
  883. /** Gets the window's owner */
  884. //=============================================================================
  885. GameWindow *GameWindow::winGetOwner( void )
  886. {
  887. return m_instData.getOwner();
  888. } // end winGetOwner
  889. // GameWindow::winSetNext =====================================================
  890. /** Set next pointer */
  891. //=============================================================================
  892. void GameWindow::winSetNext( GameWindow *next )
  893. {
  894. m_next = next;
  895. } // end winSetNext
  896. // GameWindow::winGetNext =====================================================
  897. /** Gets the next window */
  898. //=============================================================================
  899. GameWindow *GameWindow::winGetNext( void )
  900. {
  901. return m_next;
  902. } // end winGetNext
  903. // GameWindow::winSetPrev =====================================================
  904. /** Set prev pointer */
  905. //=============================================================================
  906. void GameWindow::winSetPrev( GameWindow *prev )
  907. {
  908. m_prev = prev;
  909. } // end winSetPrev
  910. // GameWindow::winGetPrev =====================================================
  911. /** Get the previous window */
  912. //=============================================================================
  913. GameWindow *GameWindow::winGetPrev( void )
  914. {
  915. return m_prev;
  916. } // end winGetPrev
  917. // GameWindow::winSetNextInLayout =============================================
  918. /** Set next window in layout */
  919. //=============================================================================
  920. void GameWindow::winSetNextInLayout( GameWindow *next )
  921. {
  922. m_nextLayout = next;
  923. }
  924. // GameWindow::winSetPrevInLayout =============================================
  925. /** Set previous window in layout pointer */
  926. //=============================================================================
  927. void GameWindow::winSetPrevInLayout( GameWindow *prev )
  928. {
  929. m_prevLayout = prev;
  930. }
  931. // GameWindow::winSetLayout ===================================================
  932. /** Set this window as belonging to layout 'layout' */
  933. //=============================================================================
  934. void GameWindow::winSetLayout( WindowLayout *layout )
  935. {
  936. m_layout = layout;
  937. }
  938. // GameWindow::winGetLayout ===================================================
  939. /** Get layout this window is a part of, if any */
  940. //=============================================================================
  941. WindowLayout *GameWindow::winGetLayout( void )
  942. {
  943. return m_layout;
  944. }
  945. // GameWindow::winGetNextInLayout =============================================
  946. /** Get next window in layout list if any */
  947. //=============================================================================
  948. GameWindow *GameWindow::winGetNextInLayout( void )
  949. {
  950. return m_nextLayout;
  951. }
  952. // GameWindow::winGetPrevInLayout =============================================
  953. /** Get prev window in layout list if any */
  954. //=============================================================================
  955. GameWindow *GameWindow::winGetPrevInLayout( void )
  956. {
  957. return m_prevLayout;
  958. }
  959. // GameWindow::winSetSystemFunc ===============================================
  960. /** Sets the window's input, system, and redraw callback functions. */
  961. //=============================================================================
  962. Int GameWindow::winSetSystemFunc( GameWinSystemFunc system )
  963. {
  964. if( system )
  965. m_system = system;
  966. else
  967. m_system = TheWindowManager->getDefaultSystem();
  968. return WIN_ERR_OK;
  969. } // end WinSetSystemFunc
  970. // GameWindow::winSetInputFunc ================================================
  971. /** Sets the window's input callback functions. */
  972. //=============================================================================
  973. Int GameWindow::winSetInputFunc( GameWinInputFunc input )
  974. {
  975. if( input )
  976. m_input = input;
  977. else
  978. m_input = TheWindowManager->getDefaultInput();
  979. return WIN_ERR_OK;
  980. } // end WinSetInputFunc
  981. // GameWindow::winSetDrawFunc =================================================
  982. /** Sets the window's redraw callback functions. */
  983. //=============================================================================
  984. Int GameWindow::winSetDrawFunc( GameWinDrawFunc draw )
  985. {
  986. if( draw )
  987. m_draw = draw;
  988. else
  989. m_draw = TheWindowManager->getDefaultDraw();
  990. return WIN_ERR_OK;
  991. } // end WinSetDrawFunc
  992. // GameWindow::winSetTooltipFunc ==============================================
  993. /** Sets a window's tooltip callback */
  994. //=============================================================================
  995. Int GameWindow::winSetTooltipFunc( GameWinTooltipFunc tooltip )
  996. {
  997. m_tooltip = tooltip;
  998. return WIN_ERR_OK;
  999. } // end WinSetTooltipFunc
  1000. // GameWindow::winSetCallbacks ================================================
  1001. /** Sets the window's input, tooltip, and redraw callback functions. */
  1002. //=============================================================================
  1003. Int GameWindow::winSetCallbacks( GameWinInputFunc input,
  1004. GameWinDrawFunc draw,
  1005. GameWinTooltipFunc tooltip )
  1006. {
  1007. winSetInputFunc( input );
  1008. winSetDrawFunc( draw );
  1009. winSetTooltipFunc( tooltip );
  1010. return WIN_ERR_OK;
  1011. } // end WinSetCallbacks
  1012. // GameWindow::winDrawWindow ==================================================
  1013. /** Draws the default background for the specified window. */
  1014. //=============================================================================
  1015. Int GameWindow::winDrawWindow( void )
  1016. {
  1017. if( BitTest( m_status, WIN_STATUS_HIDDEN ) == FALSE && m_draw )
  1018. m_draw( this, &m_instData );
  1019. return WIN_ERR_OK;
  1020. } // end WinDrawWindow
  1021. // GameWindow::winPointInChild ================================================
  1022. /** Given a window and the mouse coordinates, return the child
  1023. * window which contains the mouse pointer. Child windows are
  1024. * relative to their parents */
  1025. //=============================================================================
  1026. GameWindow *GameWindow::winPointInChild( Int x, Int y, Bool ignoreEnableCheck, Bool playDisabledSound )
  1027. {
  1028. GameWindow *parent;
  1029. GameWindow *child;
  1030. ICoord2D origin;
  1031. for( child = m_child; child; child = child->m_next )
  1032. {
  1033. origin = child->m_region.lo;
  1034. parent = child->winGetParent();
  1035. while( parent )
  1036. {
  1037. origin.x += parent->m_region.lo.x;
  1038. origin.y += parent->m_region.lo.y;
  1039. parent = parent->m_parent;
  1040. } // end while
  1041. if( x >= origin.x && x <= origin.x + child->m_size.x &&
  1042. y >= origin.y && y <= origin.y + child->m_size.y )
  1043. {
  1044. Bool enabled = ignoreEnableCheck || BitTest( child->m_status, WIN_STATUS_ENABLED );
  1045. Bool hidden = BitTest( child->m_status, WIN_STATUS_HIDDEN );
  1046. if( !hidden )
  1047. {
  1048. if( enabled )
  1049. {
  1050. return child->winPointInChild( x, y, ignoreEnableCheck, playDisabledSound );
  1051. }
  1052. else if( playDisabledSound )
  1053. {
  1054. AudioEventRTS disabledClick( "GUIClickDisabled" );
  1055. if( TheAudio )
  1056. {
  1057. TheAudio->addAudioEvent( &disabledClick );
  1058. }
  1059. }
  1060. }
  1061. }
  1062. } // end for child
  1063. // not in any children, must be in parent
  1064. return this;
  1065. } // end WinPointInChild
  1066. // GameWindow::winPointInAnyChild =============================================
  1067. /** Find the child in which the cursor resides; regardless of
  1068. * whether or not the window is actually enabled */
  1069. //=============================================================================
  1070. GameWindow *GameWindow::winPointInAnyChild( Int x, Int y, Bool ignoreHidden, Bool ignoreEnableCheck )
  1071. {
  1072. GameWindow *parent;
  1073. GameWindow *child;
  1074. ICoord2D origin;
  1075. for( child = m_child; child; child = child->m_next )
  1076. {
  1077. origin = child->m_region.lo;
  1078. parent = child->m_parent;
  1079. while( parent )
  1080. {
  1081. origin.x += parent->m_region.lo.x;
  1082. origin.y += parent->m_region.lo.y;
  1083. parent = parent->m_parent;
  1084. } // end while
  1085. if( x >= origin.x && x <= origin.x + child->m_size.x &&
  1086. y >= origin.y && y <= origin.y + child->m_size.y )
  1087. {
  1088. if( !(ignoreHidden == TRUE && BitTest( child->m_status, WIN_STATUS_HIDDEN )) )
  1089. return child->winPointInChild( x, y, ignoreEnableCheck );
  1090. } // end if
  1091. } // end for child
  1092. // not in any children, must be in parent
  1093. return this;
  1094. } // end WinPointInAnyChild
  1095. //
  1096. // In release builds the default input and system functions are optimized
  1097. // to the same address since they take the same input and have the same
  1098. // body. Rather than fill them with bogus code we just want to make
  1099. // sure that different functions are actually created. If you change the
  1100. // body of one but not the other so they are different, please remove
  1101. // the dummy code
  1102. //
  1103. // GameWinDefaultInput ========================================================
  1104. /** The default input callback. Currently does nothing. */
  1105. //=============================================================================
  1106. WindowMsgHandledType GameWinDefaultInput( GameWindow *window, UnsignedInt msg,
  1107. WindowMsgData mData1, WindowMsgData mData2 )
  1108. {
  1109. return MSG_IGNORED;
  1110. } // end GameWinDefaultInput
  1111. ///< Input that blocks all (mouse) input like a wall, instead of passing like it wasn't there
  1112. WindowMsgHandledType GameWinBlockInput( GameWindow *window, UnsignedInt msg,
  1113. WindowMsgData mData1, WindowMsgData mData2 )
  1114. {
  1115. if (msg == GWM_CHAR || msg == GWM_MOUSE_POS)
  1116. return MSG_IGNORED;
  1117. //Added By Sadullah Nader
  1118. //Fix for drag selecting in the control bar
  1119. if (msg == GWM_LEFT_UP )//|| msg == GWM_LEFT_DRAG)
  1120. {
  1121. //stop drag selecting
  1122. TheSelectionTranslator->setLeftMouseButton(FALSE);
  1123. TheSelectionTranslator->setDragSelecting(FALSE);
  1124. TheTacticalView->setMouseLock( FALSE );
  1125. TheInGameUI->setSelecting( FALSE );
  1126. TheInGameUI->endAreaSelectHint(NULL);
  1127. }
  1128. return MSG_HANDLED;
  1129. } // end GameWinBlockInput
  1130. // GameWinDefaultSystem =======================================================
  1131. /** The default system callback. Currently does nothing. */
  1132. //=============================================================================
  1133. WindowMsgHandledType GameWinDefaultSystem( GameWindow *window, UnsignedInt msg,
  1134. WindowMsgData mData1, WindowMsgData mData2 )
  1135. {
  1136. return MSG_IGNORED;
  1137. } // end GameWinDefaultSystem
  1138. // GameWinDefaultTooltip ======================================================
  1139. /** Default tooltip callback */
  1140. //=============================================================================
  1141. void GameWinDefaultTooltip( GameWindow *window,
  1142. WinInstanceData *instData,
  1143. UnsignedInt mouse )
  1144. {
  1145. return;
  1146. } // end GameWinDefaultTooltip
  1147. // GameWinDefaultDraw =========================================================
  1148. /** Default draw, does nothing */
  1149. //=============================================================================
  1150. void GameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )
  1151. {
  1152. return;
  1153. } // end GameWinDefaultDraw
  1154. // GameWindow::winSetEnabledImage =============================================
  1155. /** Set an enabled image into the draw data for the enabled state */
  1156. //=============================================================================
  1157. Int GameWindow::winSetEnabledImage( Int index, const Image *image )
  1158. {
  1159. // sanity
  1160. if( index < 0 || index >= MAX_DRAW_DATA )
  1161. {
  1162. DEBUG_LOG(( "set enabled image, index out of range '%d'\n", index ));
  1163. assert( 0 );
  1164. return WIN_ERR_INVALID_PARAMETER;
  1165. } // end if
  1166. m_instData.m_enabledDrawData[ index ].image = image;
  1167. return WIN_ERR_OK;
  1168. } // end winSetEnabledImage
  1169. // GameWindow::winSetEnabledColor =============================================
  1170. /** set color for enabled state at index */
  1171. //=============================================================================
  1172. Int GameWindow::winSetEnabledColor( Int index, Color color )
  1173. {
  1174. // sanity
  1175. if( index < 0 || index >= MAX_DRAW_DATA )
  1176. {
  1177. DEBUG_LOG(( "set enabled color, index out of range '%d'\n", index ));
  1178. assert( 0 );
  1179. return WIN_ERR_INVALID_PARAMETER;
  1180. } // end if
  1181. m_instData.m_enabledDrawData[ index ].color = color;
  1182. return WIN_ERR_OK;
  1183. } // end winSetEnabledColor
  1184. // GameWindow::winSetEnabledBorderColor =======================================
  1185. /** set border color for state at this index */
  1186. //=============================================================================
  1187. Int GameWindow::winSetEnabledBorderColor( Int index, Color color )
  1188. {
  1189. // sanity
  1190. if( index < 0 || index >= MAX_DRAW_DATA )
  1191. {
  1192. DEBUG_LOG(( "set enabled border color, index out of range '%d'\n", index ));
  1193. assert( 0 );
  1194. return WIN_ERR_INVALID_PARAMETER;
  1195. } // end if
  1196. m_instData.m_enabledDrawData[ index ].borderColor = color;
  1197. return WIN_ERR_OK;
  1198. } // end winSetEnabledBorderColor
  1199. // GameWindow::winSetDisabledImage ============================================
  1200. /** Set an disabled image into the draw data for the disabled state */
  1201. //=============================================================================
  1202. Int GameWindow::winSetDisabledImage( Int index, const Image *image )
  1203. {
  1204. // sanity
  1205. if( index < 0 || index >= MAX_DRAW_DATA )
  1206. {
  1207. DEBUG_LOG(( "set disabled image, index out of range '%d'\n", index ));
  1208. assert( 0 );
  1209. return WIN_ERR_INVALID_PARAMETER;
  1210. } // end if
  1211. m_instData.m_disabledDrawData[ index ].image = image;
  1212. return WIN_ERR_OK;
  1213. } // end winSetDisabledImage
  1214. // GameWindow::winSetDisabledColor ============================================
  1215. /** set color for disabled state at index */
  1216. //=============================================================================
  1217. Int GameWindow::winSetDisabledColor( Int index, Color color )
  1218. {
  1219. // sanity
  1220. if( index < 0 || index >= MAX_DRAW_DATA )
  1221. {
  1222. DEBUG_LOG(( "set disabled color, index out of range '%d'\n", index ));
  1223. assert( 0 );
  1224. return WIN_ERR_INVALID_PARAMETER;
  1225. } // end if
  1226. m_instData.m_disabledDrawData[ index ].color = color;
  1227. return WIN_ERR_OK;
  1228. } // end winSetDisabledColor
  1229. // GameWindow::winSetDisabledBorderColor ======================================
  1230. /** set border color for state at this index */
  1231. //=============================================================================
  1232. Int GameWindow::winSetDisabledBorderColor( Int index, Color color )
  1233. {
  1234. // sanity
  1235. if( index < 0 || index >= MAX_DRAW_DATA )
  1236. {
  1237. DEBUG_LOG(( "set disabled border color, index out of range '%d'\n", index ));
  1238. assert( 0 );
  1239. return WIN_ERR_INVALID_PARAMETER;
  1240. } // end if
  1241. m_instData.m_disabledDrawData[ index ].borderColor = color;
  1242. return WIN_ERR_OK;
  1243. } // end winSetDisabledBorderColor
  1244. // GameWindow::winSetHiliteImage ==============================================
  1245. /** Set an hilite image into the draw data for the hilite state */
  1246. //=============================================================================
  1247. Int GameWindow::winSetHiliteImage( Int index, const Image *image )
  1248. {
  1249. // sanity
  1250. if( index < 0 || index >= MAX_DRAW_DATA )
  1251. {
  1252. DEBUG_LOG(( "set hilite image, index out of range '%d'\n", index ));
  1253. assert( 0 );
  1254. return WIN_ERR_INVALID_PARAMETER;
  1255. } // end if
  1256. m_instData.m_hiliteDrawData[ index ].image = image;
  1257. return WIN_ERR_OK;
  1258. } // end winSetHiliteImage
  1259. // GameWindow::winSetHiliteColor ==============================================
  1260. /** set color for hilite state at index */
  1261. //=============================================================================
  1262. Int GameWindow::winSetHiliteColor( Int index, Color color )
  1263. {
  1264. // sanity
  1265. if( index < 0 || index >= MAX_DRAW_DATA )
  1266. {
  1267. DEBUG_LOG(( "set hilite color, index out of range '%d'\n", index ));
  1268. assert( 0 );
  1269. return WIN_ERR_INVALID_PARAMETER;
  1270. } // end if
  1271. m_instData.m_hiliteDrawData[ index ].color = color;
  1272. return WIN_ERR_OK;
  1273. } // end winSetHiliteColor
  1274. // GameWindow::winSetHiliteBorderColor ========================================
  1275. /** set border color for state at this index */
  1276. //=============================================================================
  1277. Int GameWindow::winSetHiliteBorderColor( Int index, Color color )
  1278. {
  1279. // sanity
  1280. if( index < 0 || index >= MAX_DRAW_DATA )
  1281. {
  1282. DEBUG_LOG(( "set hilite border color, index out of range '%d'\n", index ));
  1283. assert( 0 );
  1284. return WIN_ERR_INVALID_PARAMETER;
  1285. } // end if
  1286. m_instData.m_hiliteDrawData[ index ].borderColor = color;
  1287. return WIN_ERR_OK;
  1288. } // end winSetHiliteBorderColor
  1289. // GameWindow::winGetInputFunc ================================================
  1290. //=============================================================================
  1291. GameWinInputFunc GameWindow::winGetInputFunc( void )
  1292. {
  1293. return m_input;
  1294. } // end winGetInputFunc
  1295. // GameWindow::winGetSystemFunc ===============================================
  1296. //=============================================================================
  1297. GameWinSystemFunc GameWindow::winGetSystemFunc( void )
  1298. {
  1299. return m_system;
  1300. } // end winGetSystemFunc
  1301. // GameWindow::winGetTooltipFunc ==============================================
  1302. //=============================================================================
  1303. GameWinTooltipFunc GameWindow::winGetTooltipFunc( void )
  1304. {
  1305. return m_tooltip;
  1306. } // end winGetTooltipFunc
  1307. // GameWindow::winGetDrawFunc =================================================
  1308. //=============================================================================
  1309. GameWinDrawFunc GameWindow::winGetDrawFunc( void )
  1310. {
  1311. return m_draw;
  1312. } // end winGetDrawFunc
  1313. // GameWindow::winSetEditData =================================================
  1314. //=============================================================================
  1315. void GameWindow::winSetEditData( GameWindowEditData *editData )
  1316. {
  1317. m_editData = editData;
  1318. } // end winSetEditData
  1319. // GameWindow::winGetEditData =================================================
  1320. //=============================================================================
  1321. GameWindowEditData *GameWindow::winGetEditData( void )
  1322. {
  1323. return m_editData;
  1324. } // end winGetEditData