comboboxctrl.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/comboboxctrl.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/10/02 12:30p $*
  29. * *
  30. * $Revision:: 25 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "comboboxctrl.h"
  36. #include "assetmgr.h"
  37. #include "refcount.h"
  38. #include "font3d.h"
  39. #include "mousemgr.h"
  40. #include "ww3d.h"
  41. #include "dialogmgr.h"
  42. #include "dialogbase.h"
  43. #include "stylemgr.h"
  44. ////////////////////////////////////////////////////////////////
  45. //
  46. // ComboBoxCtrlClass
  47. //
  48. ////////////////////////////////////////////////////////////////
  49. ComboBoxCtrlClass::ComboBoxCtrlClass (void) :
  50. WasButtonPressedOnMe (false),
  51. IsDropDownDisplayed (false),
  52. TextRect (0, 0, 0, 0),
  53. ButtonRect (0, 0, 0, 0),
  54. FullRect (0, 0, 0, 0),
  55. DropDownSize (0, 0),
  56. IsInitialized (false),
  57. LastDropDownDisplayChange (0),
  58. CurrSel(-1)
  59. {
  60. //
  61. // Set the font for the text renderers
  62. //
  63. StyleMgrClass::Assign_Font (&TextRenderer, StyleMgrClass::FONT_LISTS);
  64. StyleMgrClass::Configure_Renderer (&ControlRenderer);
  65. //
  66. // Configure the hilight renderer
  67. //
  68. StyleMgrClass::Configure_Renderer (&HilightRenderer);
  69. //
  70. // Let the drop down know who its parent is
  71. //
  72. DropDownCtrl.Set_Combo_Box (this);
  73. DropDownCtrl.Set_Is_Embedded (true);
  74. EditControl.Set_Is_Embedded (true);
  75. return ;
  76. }
  77. ////////////////////////////////////////////////////////////////
  78. //
  79. // ~ComboBoxCtrlClass
  80. //
  81. ////////////////////////////////////////////////////////////////
  82. ComboBoxCtrlClass::~ComboBoxCtrlClass (void)
  83. {
  84. return ;
  85. }
  86. void ComboBoxCtrlClass::Set_Style(DWORD style)
  87. {
  88. DialogControlClass::Set_Style(style);
  89. if ((style & CBS_OEMCONVERT) != 0) {
  90. EditControl.Set_Style(ES_OEMCONVERT);
  91. } else {
  92. EditControl.Set_Style(0);
  93. }
  94. }
  95. ////////////////////////////////////////////////////////////////
  96. //
  97. // Create_Text_Renderers
  98. //
  99. ////////////////////////////////////////////////////////////////
  100. void
  101. ComboBoxCtrlClass::Create_Text_Renderers (void)
  102. {
  103. if ((Style & 0x0F) == CBS_DROPDOWN) {
  104. return;
  105. }
  106. HilightRenderer.Reset ();
  107. HilightRenderer.Set_Coordinate_Range (Render2DClass::Get_Screen_Resolution ());
  108. StyleMgrClass::Configure_Hilighter (&HilightRenderer);
  109. //
  110. // Lookup the string to display
  111. //
  112. WideStringClass display_string(255, true);
  113. DropDownCtrl.Get_String (DropDownCtrl.Get_Curr_Sel(), display_string);
  114. //
  115. // Setup this renderer
  116. //
  117. Render2DSentenceClass &renderer = TextRenderer;
  118. renderer.Reset ();
  119. //
  120. // Draw the text
  121. //
  122. StyleMgrClass::Render_Text (display_string, &renderer, TextRect, true, true,
  123. StyleMgrClass::LEFT_JUSTIFY, IsEnabled);
  124. //
  125. // Do the hilight
  126. //
  127. if (HasFocus && IsEnabled) {
  128. StyleMgrClass::Render_Hilight (&HilightRenderer, TextRect);
  129. }
  130. return ;
  131. }
  132. ////////////////////////////////////////////////////////////////
  133. //
  134. // Create_Control_Renderers
  135. //
  136. ////////////////////////////////////////////////////////////////
  137. void
  138. ComboBoxCtrlClass::Create_Control_Renderers (void)
  139. {
  140. Render2DClass &renderer = ControlRenderer;
  141. //
  142. // Configure this renderer
  143. //
  144. renderer.Reset ();
  145. renderer.Enable_Texturing (false);
  146. renderer.Set_Coordinate_Range (Render2DClass::Get_Screen_Resolution());
  147. //
  148. // Determine which color to draw the outline in
  149. //
  150. int color = StyleMgrClass::Get_Line_Color ();
  151. int bkcolor = StyleMgrClass::Get_Bk_Color ();
  152. if (IsEnabled == false) {
  153. color = StyleMgrClass::Get_Disabled_Line_Color ();
  154. bkcolor = StyleMgrClass::Get_Disabled_Bk_Color ();
  155. }
  156. //
  157. // Draw the control outline
  158. //
  159. RectClass rect = ClientRect;
  160. renderer.Add_Outline (rect, 1.0F, color);
  161. //
  162. // Now draw the background
  163. //
  164. rect.Right -= 1;
  165. rect.Bottom -= 1;
  166. renderer.Add_Quad (rect, bkcolor);
  167. //
  168. // Draw the button
  169. //
  170. rect = ButtonRect;
  171. renderer.Add_Line (Vector2 (rect.Left, rect.Bottom), Vector2 (rect.Left, rect.Top-1), 1, color);
  172. float width = int(ButtonRect.Width () / 4);
  173. float height = int(ButtonRect.Height () / 4);
  174. float center_x = int(ButtonRect.Left + (ButtonRect.Width () / 2));
  175. float center_y = int(ButtonRect.Top + (ButtonRect.Height () / 2));
  176. renderer.Add_Line (Vector2 (center_x - width, center_y - height), Vector2 (center_x + width, center_y - height), 1, color);
  177. renderer.Add_Line (Vector2 (center_x + width, center_y - height), Vector2 (center_x, center_y + height), 1, color);
  178. renderer.Add_Line (Vector2 (center_x, center_y + height), Vector2 (center_x - width, center_y - height), 1, color);
  179. return ;
  180. }
  181. ////////////////////////////////////////////////////////////////
  182. //
  183. // On_Set_Cursor
  184. //
  185. ////////////////////////////////////////////////////////////////
  186. void
  187. ComboBoxCtrlClass::On_Set_Cursor (const Vector2 &mouse_pos)
  188. {
  189. //
  190. // Change the mouse cursor if necessary
  191. //
  192. if (ClientRect.Contains (mouse_pos)) {
  193. MouseMgrClass::Set_Cursor (MouseMgrClass::CURSOR_ACTION);
  194. }
  195. return ;
  196. }
  197. ////////////////////////////////////////////////////////////////
  198. //
  199. // Set_Window_Pos
  200. //
  201. ////////////////////////////////////////////////////////////////
  202. void
  203. ComboBoxCtrlClass::Set_Window_Pos (const Vector2 &pos)
  204. {
  205. float width = FullRect.Width ();
  206. float height = FullRect.Height ();
  207. //
  208. // Recalculate the window's bounding rectangle
  209. //
  210. FullRect.Left = (int)pos.X;
  211. FullRect.Top = (int)pos.Y;
  212. FullRect.Right = (int)(FullRect.Left + width);
  213. FullRect.Bottom = (int)(FullRect.Top + height);
  214. //
  215. // Let the control recalculate anything it needs
  216. //
  217. DialogControlClass::Set_Window_Pos (pos);
  218. return ;
  219. }
  220. ////////////////////////////////////////////////////////////////
  221. //
  222. // Update_Client_Rect
  223. //
  224. ////////////////////////////////////////////////////////////////
  225. void
  226. ComboBoxCtrlClass::Update_Client_Rect (void)
  227. {
  228. if (IsInitialized == false) {
  229. FullRect = Rect;
  230. IsInitialized = true;
  231. }
  232. //
  233. // Determine what one character spacing would be
  234. //
  235. Vector2 char_size = TextRenderer.Get_Text_Extents (L"W");
  236. float border_width = char_size.X + 2;
  237. float border_height = 2;
  238. float button_height = int(char_size.Y * 2.0F);
  239. float button_width = button_height;
  240. //
  241. // Shrink the client area
  242. //
  243. ClientRect = Rect;
  244. ClientRect.Bottom = ClientRect.Top + button_height;
  245. //
  246. // Remember how much space we have for the drop down control
  247. //
  248. DropDownSize.X = int(ClientRect.Width ());
  249. DropDownSize.Y = int(FullRect.Bottom - ClientRect.Bottom);
  250. //
  251. // Calculate the bounding rectangle for the drop-down control
  252. //
  253. RectClass drop_down_rect;
  254. drop_down_rect.Left = ClientRect.Left;
  255. drop_down_rect.Top = ClientRect.Bottom;
  256. drop_down_rect.Right = drop_down_rect.Left + DropDownSize.X;
  257. drop_down_rect.Bottom = drop_down_rect.Top + DropDownSize.Y;
  258. //
  259. // Should the drop-down, go down or up?
  260. //
  261. RectClass screen_rect = Render2DClass::Get_Screen_Resolution ();
  262. if (drop_down_rect.Bottom > screen_rect.Bottom) {
  263. drop_down_rect.Bottom = ClientRect.Top;
  264. drop_down_rect.Top = drop_down_rect.Bottom - DropDownSize.Y;
  265. }
  266. //
  267. // Configure the drop-down control
  268. //
  269. DropDownCtrl.Set_Full_Rect (drop_down_rect);
  270. DropDownCtrl.Set_Window_Rect (drop_down_rect);
  271. //
  272. // Make the window rect and the client rect the same
  273. //
  274. Rect = ClientRect;
  275. //
  276. // Calculate where the button is located
  277. //
  278. ButtonRect = ClientRect;
  279. ButtonRect.Left = ClientRect.Right - button_width;
  280. ButtonRect.Bottom = ClientRect.Top + button_height;
  281. //
  282. // Calculate the area the text can render into
  283. //
  284. TextRect = ClientRect;
  285. TextRect.Top += border_height;
  286. TextRect.Left += border_width;
  287. TextRect.Right = ButtonRect.Left - border_width;
  288. TextRect.Bottom = ButtonRect.Bottom - border_height;
  289. RectClass editRect = ClientRect;
  290. editRect.Right = ButtonRect.Left;
  291. editRect.Bottom = ButtonRect.Bottom;
  292. EditControl.Set_Window_Rect(editRect);
  293. // If this is a dropdown then make the controls rect only cover the button.
  294. // The edit control will handle the rest of the control orginal area.
  295. if ((Style & 0x0F) == CBS_DROPDOWN) {
  296. ClientRect = ButtonRect;
  297. Rect = ButtonRect;
  298. }
  299. Set_Dirty ();
  300. return ;
  301. }
  302. ////////////////////////////////////////////////////////////////
  303. //
  304. // Render
  305. //
  306. ////////////////////////////////////////////////////////////////
  307. void
  308. ComboBoxCtrlClass::Render (void)
  309. {
  310. //
  311. // Recreate the renderers (if necessary)
  312. //
  313. if (IsDirty) {
  314. Create_Control_Renderers ();
  315. Create_Text_Renderers ();
  316. }
  317. //
  318. // Render the background and text for the current state
  319. //
  320. ControlRenderer.Render ();
  321. TextRenderer.Render ();
  322. HilightRenderer.Render ();
  323. //
  324. // Check to see if the mouse button is still down
  325. //
  326. WasButtonPressedOnMe &= DialogMgrClass::Is_Button_Down (VK_LBUTTON);
  327. DialogControlClass::Render ();
  328. return ;
  329. }
  330. ////////////////////////////////////////////////////////////////
  331. //
  332. // On_LButton_Down
  333. //
  334. ////////////////////////////////////////////////////////////////
  335. void
  336. ComboBoxCtrlClass::On_LButton_Down (const Vector2 &mouse_pos)
  337. {
  338. if (HasFocus) {
  339. WasButtonPressedOnMe = true;
  340. }
  341. // Display_Drop_Down (true);
  342. Display_Drop_Down(!IsDropDownDisplayed);
  343. return ;
  344. }
  345. ////////////////////////////////////////////////////////////////
  346. //
  347. // On_LButton_Up
  348. //
  349. ////////////////////////////////////////////////////////////////
  350. void
  351. ComboBoxCtrlClass::On_LButton_Up (const Vector2 &mouse_pos)
  352. {
  353. //
  354. // Reset our flags
  355. //
  356. WasButtonPressedOnMe = false;
  357. return ;
  358. }
  359. ////////////////////////////////////////////////////////////////
  360. //
  361. // On_Mouse_Move
  362. //
  363. ////////////////////////////////////////////////////////////////
  364. void
  365. ComboBoxCtrlClass::On_Mouse_Move (const Vector2 &mouse_pos)
  366. {
  367. return ;
  368. }
  369. ////////////////////////////////////////////////////////////////
  370. //
  371. // On_Set_Focus
  372. //
  373. ////////////////////////////////////////////////////////////////
  374. void
  375. ComboBoxCtrlClass::On_Set_Focus (void)
  376. {
  377. Set_Dirty ();
  378. //
  379. // Set the focus to the edit control if we are in that mode
  380. //
  381. /*if ((Style & 0x0F) == CBS_DROPDOWN) {
  382. DialogMgrClass::Set_Focus(&EditControl);
  383. }*/
  384. DialogControlClass::On_Set_Focus ();
  385. return ;
  386. }
  387. ////////////////////////////////////////////////////////////////
  388. //
  389. // On_Kill_Focus
  390. //
  391. ////////////////////////////////////////////////////////////////
  392. void
  393. ComboBoxCtrlClass::On_Kill_Focus (DialogControlClass *focus)
  394. {
  395. Set_Dirty ();
  396. DialogControlClass::On_Kill_Focus (focus);
  397. return ;
  398. }
  399. ////////////////////////////////////////////////////////////////
  400. //
  401. // On_Key_Down
  402. //
  403. ////////////////////////////////////////////////////////////////
  404. bool
  405. ComboBoxCtrlClass::On_Key_Down (uint32 key_id, uint32 key_data)
  406. {
  407. bool handled = false;
  408. bool is_dirty = true;
  409. switch (key_id)
  410. {
  411. case VK_HOME:
  412. Set_Sel (0, true);
  413. break;
  414. case VK_END:
  415. Set_Sel (DropDownCtrl.Get_Count () - 1, true);
  416. break;
  417. case VK_UP:
  418. case VK_LEFT:
  419. Set_Sel (max<int>(0, (DropDownCtrl.Get_Curr_Sel () - 1)), true);
  420. break;
  421. case VK_DOWN:
  422. case VK_RIGHT:
  423. Set_Sel (DropDownCtrl.Get_Curr_Sel () + 1, true);
  424. break;
  425. default:
  426. is_dirty = false;
  427. handled = false;
  428. break;
  429. }
  430. if (is_dirty) {
  431. Set_Dirty ();
  432. }
  433. return handled;
  434. }
  435. ////////////////////////////////////////////////////////////////
  436. //
  437. // On_Create
  438. //
  439. ////////////////////////////////////////////////////////////////
  440. void
  441. ComboBoxCtrlClass::On_Create (void)
  442. {
  443. if ((Style & 0x0F) == CBS_DROPDOWN) {
  444. Parent->Add_Control(&EditControl);
  445. Set_Wants_Focus(false);
  446. EditControl.Set_Advise_Sink(this);
  447. }
  448. return ;
  449. }
  450. ////////////////////////////////////////////////////////////////
  451. //
  452. // On_Destroy
  453. //
  454. ////////////////////////////////////////////////////////////////
  455. void
  456. ComboBoxCtrlClass::On_Destroy (void)
  457. {
  458. Parent->Remove_Control(&DropDownCtrl);
  459. Parent->Remove_Control(&EditControl);
  460. return ;
  461. }
  462. ////////////////////////////////////////////////////////////////
  463. //
  464. // On_Drop_Down_End
  465. //
  466. ////////////////////////////////////////////////////////////////
  467. void
  468. ComboBoxCtrlClass::On_Drop_Down_End (int curr_sel)
  469. {
  470. Set_Sel(curr_sel, true);
  471. // Hide the drop down
  472. Display_Drop_Down (false);
  473. //
  474. // If we aren't embedding an edit control, then we
  475. // need to focus after the drop down exits
  476. //
  477. if ((Style & 0x0F) != CBS_DROPDOWN) {
  478. Set_Focus ();
  479. } else {
  480. EditControl.Set_Focus ();
  481. }
  482. return ;
  483. }
  484. ////////////////////////////////////////////////////////////////
  485. //
  486. // Display_Drop_Down
  487. //
  488. ////////////////////////////////////////////////////////////////
  489. void
  490. ComboBoxCtrlClass::Display_Drop_Down (bool onoff)
  491. {
  492. int curr_time = DialogMgrClass::Get_Time ();
  493. if (onoff) {
  494. //
  495. // Show the drop down control
  496. //
  497. if (IsDropDownDisplayed == false && (curr_time - LastDropDownDisplayChange) > 0.1F) {
  498. Parent->Add_Control (&DropDownCtrl);
  499. DropDownCtrl.Set_Focus ();
  500. IsDropDownDisplayed = true;
  501. LastDropDownDisplayChange = curr_time;
  502. if ((Style & 0x0F) == CBS_DROPDOWN) {
  503. WideStringClass text(255, true);
  504. text = EditControl.Get_Text();
  505. int index = DropDownCtrl.Find_Closest_String(text);
  506. Set_Sel(index, true);
  507. }
  508. }
  509. } else {
  510. //
  511. // Hide the drop down
  512. //
  513. if (IsDropDownDisplayed) {
  514. Parent->Remove_Control (&DropDownCtrl);
  515. IsDropDownDisplayed = false;
  516. LastDropDownDisplayChange = curr_time;
  517. }
  518. }
  519. return ;
  520. }
  521. ////////////////////////////////////////////////////////////////
  522. //
  523. // On_Mouse_Wheel
  524. //
  525. ////////////////////////////////////////////////////////////////
  526. void
  527. ComboBoxCtrlClass::On_Mouse_Wheel (int direction)
  528. {
  529. if (direction < 0) {
  530. Set_Sel (max<int>(0, (DropDownCtrl.Get_Curr_Sel () - 1)), true);
  531. } else {
  532. Set_Sel (DropDownCtrl.Get_Curr_Sel () + 1, true);
  533. }
  534. Set_Dirty ();
  535. return ;
  536. }
  537. ////////////////////////////////////////////////////////////////
  538. //
  539. // Select_String
  540. //
  541. ////////////////////////////////////////////////////////////////
  542. int
  543. ComboBoxCtrlClass::Select_String (const WCHAR* string)
  544. {
  545. int index = Find_String (string);
  546. if (index >= 0) {
  547. Set_Curr_Sel (index);
  548. }
  549. return index;
  550. }
  551. void ComboBoxCtrlClass::Delete_String(int index)
  552. {
  553. if (index >= 0 && index < DropDownCtrl.Get_Count()) {
  554. DropDownCtrl.Delete_String(index);
  555. CurrSel = -2;
  556. int newSel = DropDownCtrl.Get_Curr_Sel();
  557. Set_Sel(newSel, false);
  558. }
  559. }
  560. ////////////////////////////////////////////////////////////////
  561. //
  562. // Set_Curr_Sel
  563. //
  564. ////////////////////////////////////////////////////////////////
  565. void
  566. ComboBoxCtrlClass::Set_Curr_Sel (int index)
  567. {
  568. Set_Sel(index, false);
  569. }
  570. void
  571. ComboBoxCtrlClass::Set_Sel (int index, bool notify)
  572. {
  573. if (CurrSel != index) {
  574. DropDownCtrl.Set_Curr_Sel(index);
  575. int newSel = DropDownCtrl.Get_Curr_Sel();
  576. if (CurrSel != newSel) {
  577. Set_Dirty();
  578. // If this is a dropdown then automatically fill in the edit part with
  579. // the new selection string.
  580. if ((Style & 0x0F) == CBS_DROPDOWN) {
  581. if (newSel >= 0) {
  582. WideStringClass editString(255, true);
  583. DropDownCtrl.Get_String(newSel, editString);
  584. EditControl.Set_Text(editString);
  585. } else {
  586. EditControl.Set_Text(L"");
  587. }
  588. }
  589. int oldSel = CurrSel;
  590. CurrSel = newSel;
  591. if (notify) {
  592. ADVISE_NOTIFY(On_ComboBoxCtrl_Sel_Change(this, Get_ID(), oldSel, newSel));
  593. }
  594. }
  595. }
  596. }
  597. ////////////////////////////////////////////////////////////////
  598. //
  599. // Get_Text
  600. //
  601. ////////////////////////////////////////////////////////////////
  602. const WCHAR*
  603. ComboBoxCtrlClass::Get_Text(void) const
  604. {
  605. if ((Style & 0x0F) == CBS_DROPDOWN) {
  606. return EditControl.Get_Text();
  607. }
  608. return DropDownCtrl.Get_String(Get_Curr_Sel());
  609. }
  610. ////////////////////////////////////////////////////////////////
  611. //
  612. // Set_Text
  613. //
  614. ////////////////////////////////////////////////////////////////
  615. void
  616. ComboBoxCtrlClass::Set_Text (const WCHAR *title)
  617. {
  618. if ((Style & 0x0F) == CBS_DROPDOWN) {
  619. EditControl.Set_Text (title);
  620. }
  621. DialogControlClass::Set_Text (title);
  622. return ;
  623. }
  624. ////////////////////////////////////////////////////////////////
  625. //
  626. // On_EditCtrl_Key_Down
  627. //
  628. ////////////////////////////////////////////////////////////////
  629. void
  630. ComboBoxCtrlClass::On_EditCtrl_Change(EditCtrlClass* edit, int)
  631. {
  632. if (edit == &EditControl) {
  633. ADVISE_NOTIFY(On_ComboBoxCtrl_Edit_Change(this, Get_ID()));
  634. }
  635. }
  636. ////////////////////////////////////////////////////////////////
  637. //
  638. // On_EditCtrl_Key_Down
  639. //
  640. ////////////////////////////////////////////////////////////////
  641. bool
  642. ComboBoxCtrlClass::On_EditCtrl_Key_Down (EditCtrlClass *edit, uint32 key_id, uint32 key_data)
  643. {
  644. if (edit != &EditControl) {
  645. return false;
  646. }
  647. bool handled = true;
  648. switch (key_id)
  649. {
  650. case VK_UP:
  651. Set_Sel (max<int>(0, (DropDownCtrl.Get_Curr_Sel () - 1)), true);
  652. break;
  653. case VK_DOWN:
  654. Set_Sel (DropDownCtrl.Get_Curr_Sel () + 1, true);
  655. break;
  656. default:
  657. handled = false;
  658. break;
  659. }
  660. return handled;
  661. }