Rise
The Vieneo Province
Loading...
Searching...
No Matches
Controls.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------------------
2// File: UIgui.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//--------------------------------------------------------------------------------------
6#pragma once
7#pragma warning(push)
8#pragma warning(disable:4100)
10#include "ControlArray.h"
11#ifndef UI_GUI_H
12#define UI_GUI_H
13
14#include <usp10.h>
15#include <dimm.h>
16
17#define MAX_TEXT 512
18
19//--------------------------------------------------------------------------------------
20// Defines and macros
21//--------------------------------------------------------------------------------------
22#define EVENT_BUTTON_CLICKED 0x0101
23#define EVENT_COMBOBOX_SELECTION_CHANGED 0x0201
24#define EVENT_RADIOBUTTON_CHANGED 0x0301
25#define EVENT_CHECKBOX_CHANGED 0x0401
26#define EVENT_SLIDER_VALUE_CHANGED 0x0501
27#define EVENT_EDITBOX_STRING 0x0601
28// EVENT_EDITBOX_CHANGE is sent when the listbox content changes
29// due to user input.
30#define EVENT_EDITBOX_CHANGE 0x0602
31#define EVENT_EDITBOX_CANCEL 0x0603
32#define EVENT_LISTBOX_ITEM_DBLCLK 0x0701
33// EVENT_LISTBOX_SELECTION is fired off when the selection changes in
34// a single selection list box.
35#define EVENT_LISTBOX_SELECTION 0x0702
36#define EVENT_LISTBOX_SELECTION_END 0x0703
37
38#define passwordcharC L'·'
39
40//--------------------------------------------------------------------------------------
41// Forward declarations
42//--------------------------------------------------------------------------------------
44class RiseControl;
45class RiseButton;
46class RiseStatic;
47class RiseCheckBox;
48class RiseRadioButton;
49class RiseComboBox;
50class RiseSlider;
51class RiseEditBox;
52class RiseListBox;
53class RiseScrollBar;
54class RiseElement;
55struct UIElementHolder;
56struct UITextureNode;
57struct UIFontNode;
58typedef VOID(CALLBACK*UICallback)(UINT nEvent, int nControlID, RiseControl* pControl,
59 void* pUserContext);
60
61
62//--------------------------------------------------------------------------------------
63// Enums for pre-defined control types
64//--------------------------------------------------------------------------------------
78
88
89#define MAX_CONTROL_STATES 6
90
92{
93 void Init(Rendering::PackedColor defaultColor, Rendering::PackedColor disabledColor = Rendering::ColorARGB(200, 128, 128, 128),
94 Rendering::PackedColor hiddenColor = 0);
95 void Blend(UINT iState, float fElapsedTime, float fRate = 0.7f);
96
97 Rendering::PackedColor States[MAX_CONTROL_STATES]; // Modulate colors for all possible control states
99};
100
101
102//-----------------------------------------------------------------------------
103// Contains all the display tweakables for a sub-control
104//-----------------------------------------------------------------------------
106{
107public:
108 void SetTexture(UINT prmTexture, RECT* prcTexture, Rendering::PackedColor defaultTextureColor = Rendering::ColorARGB(255, 255, 255,
109 255));
110 void SetFont(UINT prmFont, Rendering::PackedColor defaultFontColor = Rendering::ColorARGB(255, 255, 255,
111 255), DWORD prmTextFormat = DT_CENTER |
112 DT_VCENTER);
113
114 void Refresh();
115
116 UINT iTexture; // Index of the texture for this Element
117 UINT iFont; // Index of the font for this Element
118 DWORD dwTextFormat; // The format argument to DrawText
119
120 RECT rcTexture; // Bounding rect of this element on the composite texture
121
124};
125
126
127//-----------------------------------------------------------------------------
128// All controls must be assigned to a dialog, which handles
129// input and rendering for the controls.
130//-----------------------------------------------------------------------------
132{
134
135public:
136 RiseDialog();
137 ~RiseDialog();
138
139 // Need to call this now
140 void Init(RiseDialogResourceManager* pManager, bool bRegisterDialog = true);
141 void Init(RiseDialogResourceManager* pManager, bool bRegisterDialog,
142 LPCWSTR pszControlTextureFilename);
143 void Init(RiseDialogResourceManager* pManager, bool bRegisterDialog,
144 LPCWSTR szControlTextureResourceName, HMODULE hControlTextureResourceModule);
145
146 // Windows message handler
147 bool MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
148
149 // Control creation
150 HRESULT AddStatic(int ID, LPCWSTR strText, int x, int y, int width, int height, bool bIsDefault = false,
151 RiseStatic** ppCreated = NULL, bool bShadow = true);
152 HRESULT AddButton(int ID, LPCWSTR strText, int x, int y, int width, int height, UINT nHotkey = 0,
153 bool bIsDefault = false, RiseButton** ppCreated = NULL);
154 HRESULT AddCheckBox(int ID, LPCWSTR strText, int x, int y, int width, int height, bool bChecked = false,
155 UINT nHotkey = 0, bool bIsDefault = false, RiseCheckBox** ppCreated = NULL);
156 HRESULT AddRadioButton(int ID, UINT nButtonGroup, LPCWSTR strText, int x, int y, int width,
157 int height, bool bChecked = false, UINT nHotkey = 0, bool bIsDefault = false,
158 RiseRadioButton** ppCreated = NULL);
159 HRESULT AddComboBox(int ID, int x, int y, int width, int height, UINT nHotKey = 0, bool bIsDefault =
160 false, RiseComboBox** ppCreated = NULL);
161 HRESULT AddSlider(int ID, int x, int y, int width, int height, int min = 0, int max = 100, int value = 50,
162 bool bIsDefault = false, RiseSlider** ppCreated = NULL);
163 // AddIMEEditBox has been renamed into UIguiIME.cpp as RiseIMEEditBox::CreateIMEEditBox
164 HRESULT AddEditBox(int ID, LPCWSTR strText, int x, int y, int width, int height, bool bIsDefault =
165 false, bool bIsPassword = false, RiseEditBox** ppCreated = NULL);
166 HRESULT AddListBox(int ID, int x, int y, int width, int height, DWORD dwStyle = 0,
167 RiseListBox** ppCreated = NULL);
168 HRESULT AddControl(RiseControl* pControl);
170
171 // Control retrieval
173 {
175 }
177 {
179 }
181 {
183 }
189 {
191 }
193 {
195 }
197 {
199 }
201 {
203 }
204
205 RiseControl* GetControl(int ID);
206 RiseControl* GetControl(int ID, UINT nControlType);
208 void AppendVisibleBounds(std::vector<RECT>& rectangles) const;
209
210 bool GetControlEnabled(int ID);
211 void SetControlEnabled(int ID, bool bEnabled);
212
213 void ClearRadioButtonGroup(UINT nGroup);
214 void ClearComboBox(int ID);
215
216 // Access the default display Elements used when adding new controls
217 HRESULT SetDefaultElement(UINT nControlType, UINT iElement, RiseElement* pElement);
218 RiseElement* GetDefaultElement(UINT nControlType, UINT iElement);
219
220 // Methods called by controls
221 void SendEvent(UINT nEvent, bool bTriggeredByUser, RiseControl* pControl);
222 void RequestFocus(RiseControl* pControl);
223
224 // Render helpers
225 HRESULT DrawRect(RECT* pRect, Rendering::PackedColor color);
226
227
228 HRESULT DrawPolyLine(POINT* apPoints, UINT nNumPoints, Rendering::PackedColor color);
229 HRESULT DrawSprite(RiseElement* pElement, RECT* prcDest, float fDepth=0);
230
231
232 HRESULT CalcTextRect(LPCWSTR strText, RiseElement* pElement, RECT* prcDest, int nCount = -1);
233 HRESULT DrawText(LPCWSTR strText, RiseElement* pElement, RECT* prcDest, bool bShadow = false,
234 int nCount = -1);
235
236
237
238 // Attributes
240 {
241 return m_bVisible;
242 }
243 void SetVisible(bool bVisible)
244 {
245 m_bVisible = bVisible;
246 }
248 {
249 return m_bMinimized;
250 }
251 void SetMinimized(bool bMinimized)
252 {
253 m_bMinimized = bMinimized;
254 }
256 {
257 SetBackgroundColors(colorAllCorners, colorAllCorners, colorAllCorners, colorAllCorners);
258 }
259 void SetBackgroundColors(Rendering::PackedColor colorTopLeft, Rendering::PackedColor colorTopRight, Rendering::PackedColor colorBottomLeft,
260 Rendering::PackedColor colorBottomRight);
261 void EnableCaption(bool bEnable)
262 {
263 m_bCaption = bEnable;
264 }
266 {
267 return m_nCaptionHeight;
268 }
269 void SetCaptionHeight(int nHeight)
270 {
271 m_nCaptionHeight = nHeight;
272 }
273 void SetCaptionText(const WCHAR* pwszText)
274 {
275 wcscpy_s(m_wszCaption, sizeof(m_wszCaption) / sizeof(m_wszCaption[0]), pwszText);
276 }
277 void GetLocation(POINT& Pt) const
278 {
279 Pt.x = m_x; Pt.y = m_y;
280 }
281 void SetLocation(int x, int y)
282 {
283 m_x = x; m_y = y;
284 }
285 void SetSize(int width, int height)
286 {
287 m_width = width; m_height = height;
288 }
290 {
291 return m_width;
292 }
294 {
295 return m_height;
296 }
297
298 void SetScale(float scale)
299 {
300 m_fScale = scale;
301 }
302
303 static void WINAPI SetRefreshTime(float fTime)
304 {
305 s_fTimeRefresh = fTime;
306 }
307
308 static RiseControl* WINAPI GetNextControl(RiseControl* pControl);
309 static RiseControl* WINAPI GetPrevControl(RiseControl* pControl);
310
311 void RemoveControl(int ID);
312 void RemoveAllControls();
313
314 // Sets the callback used to notify the app of control events
315 void SetCallback(UICallback pCallback, void* pUserContext = NULL);
316 void EnableNonUserEvents(bool bEnable)
317 {
318 m_bNonUserEvents = bEnable;
319 }
320 void EnableKeyboardInput(bool bEnable)
321 {
322 m_bKeyboardInput = bEnable;
323 }
324 void EnableMouseInput(bool bEnable)
325 {
326 m_bMouseInput = bEnable;
327 }
329 {
330 return m_bKeyboardInput;
331 }
332
333 // Device state notification
334 void Refresh();
335 HRESULT OnRender(float fElapsedTime);
336
337 // Shared resource access. Indexed fonts and textures are shared among
338 // all the controls.
339 HRESULT SetFont(UINT index, LPCWSTR strFaceName, LONG height, LONG weight);
340 UIFontNode* GetFont(UINT index);
341
342 HRESULT SetTexture(UINT index, LPCWSTR strFilename);
343 HRESULT SetTexture(UINT index, LPCWSTR strResourceName, HMODULE hResourceModule);
344 UITextureNode* GetTexture(UINT index);
345
350
351 static void WINAPI ClearFocus();
352 void FocusDefaultControl();
353
357 float m_fScale = 1.0f;
358
359private:
361
362
363
364 static double s_fTimeRefresh;
366
367 // Initialize default Elements
368 void InitDefaultElements();
369
370 // Windows message handlers
371 void OnMouseMove(POINT pt);
372 void OnMouseUp(POINT pt);
373
374 void SetNextDialog(RiseDialog* pNextDialog);
375
376 // Control events
377 bool OnCycleFocus(bool bForward);
378
379 static RiseControl* s_pControlFocus; // The control which has focus
380 static RiseControl* s_pControlPressed; // The control currently pressed
381
382 RiseControl* m_pControlMouseOver; // The control which is hovered over
383
388 WCHAR m_wszCaption[256];
389
390 int m_x;
391 int m_y;
395
400
404
405 ControlArray <int> m_Textures; // Index into m_TextureCache;
406 ControlArray <int> m_Fonts; // Index into m_FontCache;
407
408 ControlArray <RiseControl*> m_Controls;
409 ControlArray <UIElementHolder*> m_DefaultElements;
410
411 RiseElement m_CapElement; // Element for the caption
412
415};
416
417
418//--------------------------------------------------------------------------------------
419// Structs for shared resources
420//--------------------------------------------------------------------------------------
422{
423 bool bFileSource; // True if this texture is loaded from a file. False if from resource.
425 int nResourceID; // Resource ID. If 0, string-based ID is used and stored in strFilename.
426 WCHAR strFilename[MAX_PATH];
430};
431
433{
434 WCHAR strFace[MAX_PATH];
438};
439
440
441//-----------------------------------------------------------------------------
442// Manages shared resources of dialogs
443//-----------------------------------------------------------------------------
445{
446public:
449
450 bool MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
451
452 // D3D9 specific
455 void OnLostDevice();
456 void OnDestroyDevice();
461
462 // D3D10 specific
463
464
465
466
467
468
470 {
471 return m_FontCache.GetAt(iIndex);
472 };
474 {
475 return m_TextureCache.GetAt(iIndex);
476 };
477
478 int AddFont(LPCWSTR strFaceName, LONG height, LONG weight);
479 int AddTexture(LPCWSTR strFilename);
480 int AddTexture(LPCWSTR strResourceName, HMODULE hResourceModule);
481
482 bool RegisterDialog(RiseDialog* pDialog);
483 void UnregisterDialog(RiseDialog* pDialog);
485
486 // Shared between all dialogs
487
488 // D3D9
490 Rendering::RenderSprite* m_pSprite; // Sprite used for drawing
491
492 // D3D10
495
496 ControlArray <RiseDialog*> m_Dialogs; // Dialogs registered
497
498protected:
499 // D3D9 specific
501 HRESULT CreateFont(UINT index);
502 HRESULT CreateTexture(UINT index);
503
504 // D3D10 specific
505
506
507
508 ControlArray <UITextureNode*> m_TextureCache; // Shared textures
509 ControlArray <UIFontNode*> m_FontCache; // Shared fonts
510};
511
512
513//-----------------------------------------------------------------------------
514// Base class for controls
515//-----------------------------------------------------------------------------
517{
518public:
519 RiseControl(RiseDialog* pDialog = NULL);
520 virtual ~RiseControl();
521
522 virtual HRESULT OnInit()
523 {
524 return S_OK;
525 }
526 virtual void Refresh();
527 virtual void Render(float fElapsedTime)
528 {
529 };
530
531 // Windows message handler
532 virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
533 {
534 return false;
535 }
536
537 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
538 {
539 return false;
540 }
541 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
542 {
543 return false;
544 }
545
546 virtual bool CanHaveFocus()
547 {
548 return false;
549 }
550 virtual void OnFocusIn()
551 {
552 m_bHasFocus = true;
553 }
554 virtual void OnFocusOut()
555 {
556 m_bHasFocus = false;
557 }
558 virtual void OnMouseEnter()
559 {
560 m_bMouseOver = true;
561 }
562 virtual void OnMouseLeave()
563 {
564 m_bMouseOver = false;
565 }
566 virtual void OnHotkey()
567 {
568 }
569
570 virtual BOOL ContainsPoint(POINT pt)
571 {
572 return PtInRect(&m_rcBoundingBox, pt);
573 }
574
575 virtual void SetEnabled(bool bEnabled)
576 {
577 m_bEnabled = bEnabled;
578 }
579 virtual bool GetEnabled()
580 {
581 return m_bEnabled;
582 }
583 virtual void SetVisible(bool bVisible)
584 {
585 m_bVisible = bVisible;
586 }
587 virtual bool GetVisible()
588 {
589 return m_bVisible;
590 }
591
592 UINT GetType() const
593 {
594 return m_Type;
595 }
596
597 int GetID() const
598 {
599 return m_ID;
600 }
601 void SetID(int ID)
602 {
603 m_ID = ID;
604 }
605
606 void SetLocation(int x, int y)
607 {
608 m_x = x; m_y = y; UpdateRects();
609 }
610 void SetSize(int width, int height)
611 {
612 m_width = width;
613 m_height = height;
614 UpdateRects();
615 }
616
617 void SetHotkey(UINT nHotkey)
618 {
619 m_nHotkey = nHotkey;
620 }
622 {
623 return m_nHotkey;
624 }
625
626 void SetUserData(void* pUserData)
627 {
628 m_pUserData = pUserData;
629 }
630 void* GetUserData() const
631 {
632 return m_pUserData;
633 }
634
635 virtual void SetTextColor(Rendering::PackedColor Color);
636 RiseElement* GetElement(UINT iElement)
637 {
638 return m_Elements.GetAt(iElement);
639 }
640 HRESULT SetElement(UINT iElement, RiseElement* pElement);
641
642 bool m_bVisible; // Shown/hidden flag
644 bool m_bMouseOver; // Mouse pointer is above control
645 bool m_bHasFocus; // Control has input focus
646 bool m_bIsDefault; // Is the default control
647 bool m_bIsPassword; // Password type!
648
649 // Size, scale, and positioning members
650 int m_x, m_y;
652
653 // These members are set by the container
654 RiseDialog* m_pDialog; // Parent container
655 UINT m_Index; // Index within the control list
656
657 ControlArray <RiseElement*> m_Elements; // All display elements
658
659protected:
660 virtual void UpdateRects();
661
662 int m_ID; // ID number
663 UI_CONTROL_TYPE m_Type; // Control type, set once in constructor
664 UINT m_nHotkey; // Virtual key code for this control's hotkey
665 void* m_pUserData; // Data associated with this control that is set by user.
666
667 bool m_bEnabled; // Enabled/disabled flag
668
669 RECT m_rcBoundingBox; // Rectangle defining the active region of the control
670};
671
672
673//-----------------------------------------------------------------------------
674// Contains all the display information for a given control type
675//-----------------------------------------------------------------------------
683
684
685//-----------------------------------------------------------------------------
686// Static control
687//-----------------------------------------------------------------------------
689{
690public:
691 RiseStatic(RiseDialog* pDialog = NULL);
692
693 virtual void Render(float fElapsedTime);
694 virtual BOOL ContainsPoint(POINT pt)
695 {
696 return false;
697 }
698
699 HRESULT GetTextCopy(__out_ecount(bufferCount) LPWSTR strDest,
700 UINT bufferCount);
701 LPCWSTR GetText()
702 {
703 return m_strText;
704 }
705 HRESULT SetText(LPCWSTR strText);
706
707
708protected:
709 WCHAR m_strText[MAX_TEXT]; // Window text
710};
711
712
713//-----------------------------------------------------------------------------
714// Button control
715//-----------------------------------------------------------------------------
716class RiseButton : public RiseStatic
717{
718public:
719 RiseButton(RiseDialog* pDialog = NULL);
720
721 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
722 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
723 virtual void OnHotkey()
724 {
727 }
728
729 virtual BOOL ContainsPoint(POINT pt)
730 {
731 return PtInRect(&m_rcBoundingBox, pt);
732 }
733 virtual bool CanHaveFocus()
734 {
735 return (m_bVisible && m_bEnabled);
736 }
737
738 virtual void Render(float fElapsedTime);
739
740protected:
742};
743
744
745//-----------------------------------------------------------------------------
746// CheckBox control
747//-----------------------------------------------------------------------------
749{
750public:
751 RiseCheckBox(RiseDialog* pDialog = NULL);
752
753 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
754 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
755 virtual void OnHotkey()
756 {
759 }
760
761 virtual BOOL ContainsPoint(POINT pt);
762 virtual void UpdateRects();
763
764 virtual void Render(float fElapsedTime);
765
767 {
768 return m_bChecked;
769 }
770 void SetChecked(bool bChecked)
771 {
772 SetCheckedInternal(bChecked, false);
773 }
774
775protected:
776 virtual void SetCheckedInternal(bool bChecked, bool bFromInput);
777
781};
782
783
784//-----------------------------------------------------------------------------
785// RadioButton control
786//-----------------------------------------------------------------------------
788{
789public:
790 RiseRadioButton(RiseDialog* pDialog = NULL);
791
792 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
793 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
794 virtual void OnHotkey()
795 {
797 SetCheckedInternal(true, true, true);
798 }
799
800 void SetChecked(bool bChecked, bool bClearGroup = true)
801 {
802 SetCheckedInternal(bChecked, bClearGroup, false);
803 }
804 void SetButtonGroup(UINT nButtonGroup)
805 {
806 m_nButtonGroup = nButtonGroup;
807 }
809 {
810 return m_nButtonGroup;
811 }
812
813protected:
814 virtual void SetCheckedInternal(bool bChecked, bool bClearGroup, bool bFromInput);
816};
817
818
819//-----------------------------------------------------------------------------
820// Scrollbar control
821//-----------------------------------------------------------------------------
823{
824public:
825 RiseScrollBar(RiseDialog* pDialog = NULL);
826 virtual ~RiseScrollBar();
827
828 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
829 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
830 virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
831
832 virtual void Render(float fElapsedTime);
833 virtual void UpdateRects();
834
835 void SetTrackRange(int nStart, int nEnd);
837 {
838 return m_nPosition;
839 }
840 void SetTrackPos(int nPosition)
841 {
842 m_nPosition = nPosition; Cap(); UpdateThumbRect();
843 }
845 {
846 return m_nPageSize;
847 }
848 void SetPageSize(int nPageSize)
849 {
850 m_nPageSize = nPageSize; Cap(); UpdateThumbRect();
851 }
852
853 void Scroll(int nDelta); // Scroll by nDelta items (plus or minus)
854 void ShowItem(int nIndex); // Ensure that item nIndex is displayed, scroll if necessary
855
856protected:
857 // ARROWSTATE indicates the state of the arrow buttons.
858 // CLEAR No arrow is down.
859 // CLICKED_UP Up arrow is clicked.
860 // CLICKED_DOWN Down arrow is clicked.
861 // HELD_UP Up arrow is held down for sustained period.
862 // HELD_DOWN Down arrow is held down for sustained period.
871
872 void UpdateThumbRect();
873 void Cap(); // Clips position at boundaries. Ensures it stays within legal range.
874
881 int m_nPosition; // Position of the first displayed item
882 int m_nPageSize; // How many items are displayable in one page
883 int m_nStart; // First item
884 int m_nEnd; // The index after the last item
885 POINT m_LastMouse;// Last mouse position
886 ARROWSTATE m_Arrow; // State of the arrows
887 double m_dArrowTS; // Timestamp of last arrow event.
888};
889
890
891//-----------------------------------------------------------------------------
892// ListBox control
893//-----------------------------------------------------------------------------
895{
896 WCHAR strText[256];
897 void* pData;
898
901};
902
904{
905public:
906 RiseListBox(RiseDialog* pDialog = NULL);
907 virtual ~RiseListBox();
908
909 virtual HRESULT OnInit()
910 {
912 }
913 virtual bool CanHaveFocus()
914 {
915 return (m_bVisible && m_bEnabled);
916 }
917 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
918 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
919 virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
920
921 virtual void Render(float fElapsedTime);
922 virtual void UpdateRects();
923
925 {
926 return m_dwStyle;
927 }
928 int GetSize() const
929 {
930 return m_Items.GetSize();
931 }
932 void SetStyle(DWORD dwStyle)
933 {
934 m_dwStyle = dwStyle;
935 }
937 {
938 return m_nSBWidth;
939 }
940 void SetScrollBarWidth(int nWidth)
941 {
942 m_nSBWidth = nWidth; UpdateRects();
943 }
944 void SetBorder(int nBorder, int nMargin)
945 {
946 m_nBorder = nBorder; m_nMargin = nMargin;
947 }
948 HRESULT AddItem(const WCHAR* wszText, void* pData);
949 HRESULT InsertItem(int nIndex, const WCHAR* wszText, void* pData);
950 void RemoveItem(int nIndex);
951 void RemoveItemByData(void* pData);
952 void RemoveAllItems();
953
954 UIListBoxItem* GetItem(int nIndex);
955 int GetSelectedIndex(int nPreviousSelected = -1);
956 UIListBoxItem* GetSelectedItem(int nPreviousSelected = -1)
957 {
958 return GetItem(GetSelectedIndex(nPreviousSelected));
959 }
960 void SelectItem(int nNewIndex);
961
962 enum STYLE
963 {
965 };
966
967protected:
968 RECT m_rcText; // Text rendering bound
969 RECT m_rcSelection; // Selection box bound
974 int m_nTextHeight; // Height of a single line of text
975 DWORD m_dwStyle; // List box style
976 int m_nSelected; // Index of the selected item for single selection list box
977 int m_nSelStart; // Index of the item where selection starts (for handling multi-selection)
978 bool m_bDrag; // Whether the user is dragging the mouse to select
979
980 ControlArray <UIListBoxItem*> m_Items;
981};
982
983
984//-----------------------------------------------------------------------------
985// ComboBox control
986//-----------------------------------------------------------------------------
988{
989 WCHAR strText[256];
990 void* pData;
991
994};
995
996
998{
999public:
1000 RiseComboBox(RiseDialog* pDialog = NULL);
1001 virtual ~RiseComboBox();
1002
1003 virtual void SetTextColor(Rendering::PackedColor Color, Rendering::PackedColor DisabledColor = Rendering::ColorARGB(200, 128, 128, 128));
1004 virtual HRESULT OnInit()
1005 {
1007 }
1008
1009 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
1010 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
1011 virtual void OnHotkey();
1012
1013 virtual bool CanHaveFocus()
1014 {
1015 return (m_bVisible && m_bEnabled);
1016 }
1017 virtual void OnFocusOut();
1018 virtual void Render(float fElapsedTime);
1019
1020 virtual void UpdateRects();
1021
1022 HRESULT AddItem(const WCHAR* strText, void* pData);
1023 void RemoveAllItems();
1024 void RemoveItem(UINT index);
1025 bool ContainsItem(const WCHAR* strText, UINT iStart = 0);
1026 int FindItem(const WCHAR* strText, UINT iStart = 0);
1027 void* GetItemData(const WCHAR* strText);
1028 void* GetItemData(int nIndex);
1029 void SetDropHeight(UINT nHeight, UINT fHeight)
1030 {
1031 m_nDropHeight = nHeight; m_nFontHeight = fHeight; UpdateRects();
1032 }
1034 {
1035 return m_nSBWidth;
1036 }
1037 void SetScrollBarWidth(int nWidth)
1038 {
1039 m_nSBWidth = nWidth; UpdateRects();
1040 }
1041
1043 {
1044 return m_iSelected;
1045 }
1046 void* GetSelectedData();
1048
1050 {
1051 return m_Items.GetSize();
1052 }
1054 {
1055 return m_Items.GetAt(index);
1056 }
1057
1058 HRESULT SetSelectedByIndex(UINT index);
1059 HRESULT SetSelectedByText(const WCHAR* strText);
1060 HRESULT SetSelectedByData(void* pData);
1061
1062protected:
1069
1071
1076
1077
1078 ControlArray <UIComboBoxItem*> m_Items;
1079};
1080
1081
1082//-----------------------------------------------------------------------------
1083// Slider control
1084//-----------------------------------------------------------------------------
1086{
1087public:
1088 RiseSlider(RiseDialog* pDialog = NULL);
1089
1090 virtual BOOL ContainsPoint(POINT pt);
1091 virtual bool CanHaveFocus()
1092 {
1093 return (m_bVisible && m_bEnabled);
1094 }
1095 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
1096 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
1097
1098 virtual void UpdateRects();
1099
1100 virtual void Render(float fElapsedTime);
1101
1102 void SetValue(int nValue)
1103 {
1104 SetValueInternal(nValue, false);
1105 }
1106 int GetValue() const
1107 {
1108 return m_nValue;
1109 };
1110
1111 void GetRange(int& nMin, int& nMax) const
1112 {
1113 nMin = m_nMin; nMax = m_nMax;
1114 }
1115 void SetRange(int nMin, int nMax);
1116
1117protected:
1118 void SetValueInternal(int nValue, bool bFromInput);
1119 int ValueFromPos(int x);
1120
1122
1125
1126 int m_nDragX; // Mouse position at start of drag
1127 int m_nDragOffset; // Drag offset from the center of the button
1129
1132};
1133
1134
1135//-----------------------------------------------------------------------------
1136// CUniBuffer class for the edit control
1137//-----------------------------------------------------------------------------
1139{
1140public:
1141 CUniBuffer(int nInitialSize = 1);
1142 ~CUniBuffer();
1143
1144 static void WINAPI Initialize();
1145 static void WINAPI Uninitialize();
1146
1148 {
1149 return m_nBufferSize;
1150 }
1151 bool SetBufferSize(int nSize);
1153 {
1154 return lstrlenW(m_pwszBuffer);
1155 }
1156 const WCHAR* GetBuffer()
1157 {
1158 return m_pwszBuffer;
1159 }
1160 const WCHAR& operator[](int n) const
1161 {
1162 return m_pwszBuffer[n];
1163 }
1164 WCHAR& operator[](int n);
1166 {
1167 return m_pFontNode;
1168 }
1169 void SetFontNode(UIFontNode* pFontNode)
1170 {
1171 m_pFontNode = pFontNode;
1172 }
1173 void Clear();
1174
1175 bool InsertChar(int nIndex, WCHAR wChar); // Inserts the char at specified index. If nIndex == -1, insert to the end.
1176 bool RemoveChar(int nIndex); // Removes the char at specified index. If nIndex == -1, remove the last char.
1177 bool InsertString(int nIndex, const WCHAR* pStr, int nCount = -1); // Inserts the first nCount characters of the string pStr at specified index. If nCount == -1, the entire string is inserted. If nIndex == -1, insert to the end.
1178 bool SetText(LPCWSTR wszText);
1179
1180 // Uniscribe
1181 HRESULT CPtoX(int nCP, BOOL bTrail, int* pX);
1182 HRESULT XtoCP(int nX, int* pCP, int* pnTrail);
1183 void GetPriorItemPos(int nCP, int* pPrior);
1184 void GetNextItemPos(int nCP, int* pPrior);
1185
1186private:
1187 HRESULT Analyse(); // Uniscribe -- Analyse() analyses the string in the buffer
1188
1189 WCHAR* m_pwszBuffer; // Buffer to hold text
1190 int m_nBufferSize; // Size of the buffer allocated, in characters
1191
1192 // Uniscribe-specific
1193 UIFontNode* m_pFontNode; // Font node for the font that this buffer uses
1194 bool m_bAnalyseRequired; // True if the string has changed since last analysis.
1195 SCRIPT_STRING_ANALYSIS m_Analysis; // Analysis for the current string
1196
1197private:
1198 // Empty implementation of the Uniscribe API
1199 static HRESULT WINAPI Dummy_ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE*, SCRIPT_CONTROL*,
1200 SCRIPT_STATE*)
1201 {
1202 return E_NOTIMPL;
1203 }
1204 static HRESULT WINAPI Dummy_ScriptStringAnalyse(HDC, const void*, int, int, int, DWORD, int, SCRIPT_CONTROL*,
1205 SCRIPT_STATE*, const int*, SCRIPT_TABDEF*, const BYTE*,
1206 SCRIPT_STRING_ANALYSIS*)
1207 {
1208 return E_NOTIMPL;
1209 }
1210 static HRESULT WINAPI Dummy_ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS, int, BOOL, int*)
1211 {
1212 return E_NOTIMPL;
1213 }
1214 static HRESULT WINAPI Dummy_ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS, int, int*, int*)
1215 {
1216 return E_NOTIMPL;
1217 }
1218 static HRESULT WINAPI Dummy_ScriptStringFree(SCRIPT_STRING_ANALYSIS*)
1219 {
1220 return E_NOTIMPL;
1221 }
1222 static const SCRIPT_LOGATTR* WINAPI Dummy_ScriptString_pLogAttr(SCRIPT_STRING_ANALYSIS)
1223 {
1224 return NULL;
1225 }
1226 static const int* WINAPI Dummy_ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS)
1227 {
1228 return NULL;
1229 }
1230
1231 // Function pointers
1232 static HRESULT(WINAPI* _ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE*,
1233 SCRIPT_CONTROL*, SCRIPT_STATE*);
1234 static HRESULT(WINAPI* _ScriptStringAnalyse)(HDC, const void*, int, int, int, DWORD, int,
1235 SCRIPT_CONTROL*, SCRIPT_STATE*, const int*,
1236 SCRIPT_TABDEF*, const BYTE*,
1237 SCRIPT_STRING_ANALYSIS*);
1238 static HRESULT(WINAPI* _ScriptStringCPtoX)(SCRIPT_STRING_ANALYSIS, int, BOOL, int*);
1239 static HRESULT(WINAPI* _ScriptStringXtoCP)(SCRIPT_STRING_ANALYSIS, int, int*, int*);
1240 static HRESULT(WINAPI* _ScriptStringFree)(SCRIPT_STRING_ANALYSIS*);
1241 static const SCRIPT_LOGATTR* (WINAPI*_ScriptString_pLogAttr)(SCRIPT_STRING_ANALYSIS);
1242 static const int* (WINAPI*_ScriptString_pcOutChars)(SCRIPT_STRING_ANALYSIS);
1243
1244 static HINSTANCE s_hDll; // Uniscribe DLL handle
1245
1246};
1247
1248//-----------------------------------------------------------------------------
1249// EditBox control
1250//-----------------------------------------------------------------------------
1252{
1253public:
1254 RiseEditBox(RiseDialog* pDialog = NULL);
1255 virtual ~RiseEditBox();
1256
1257 virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam);
1258 virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam);
1259 virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
1260 virtual void UpdateRects();
1261 virtual bool CanHaveFocus()
1262 {
1263 return (m_bVisible && m_bEnabled);
1264 }
1265 virtual void Render(float fElapsedTime);
1266 virtual void OnFocusIn();
1267
1268 void SetText(LPCWSTR wszText, bool bSelected = false);
1269 LPCWSTR GetText()
1270 {
1271 return m_Buffer.GetBuffer();
1272 }
1274 {
1275 return m_Buffer.GetTextSize();
1276 } // Returns text length in chars excluding NULL.
1277 HRESULT GetTextCopy(__out_ecount(bufferCount) LPWSTR strDest,
1278 UINT bufferCount);
1279 void ClearText();
1281 {
1282 m_TextColor = Color;
1283 } // Text color
1285 {
1286 m_SelTextColor = Color;
1287 } // Selected text color
1289 {
1290 m_SelBkColor = Color;
1291 } // Selected background color
1293 {
1294 m_CaretColor = Color;
1295 } // Caret color
1296 void SetBorderWidth(int nBorder)
1297 {
1298 m_nBorder = nBorder; UpdateRects();
1299 } // Border of the window
1300 void SetSpacing(int nSpacing)
1301 {
1302 m_nSpacing = nSpacing; UpdateRects();
1303 }
1304 void ParseFloatArray(float* pNumbers, int nCount);
1305 void SetTextFloatArray(const float* pNumbers, int nCount);
1306
1307protected:
1308 void PlaceCaret(int nCP);
1309 void DeleteSelectionText();
1310 void ResetCaretBlink();
1311 void CopyToClipboard();
1312 void PasteFromClipboard();
1313
1314 CUniBuffer m_Buffer; // Buffer to hold text
1315 int m_nBorder; // Border of the window
1316 int m_nSpacing; // Spacing between the text and the edge of border
1317 RECT m_rcText; // Bounding rectangle for the text
1318 RECT m_rcRender[9]; // Convenient rectangles for rendering elements
1319 double m_dfBlink; // Caret blink time in milliseconds
1320 double m_dfLastBlink; // Last timestamp of caret blink
1321 bool m_bCaretOn; // Flag to indicate whether caret is currently visible
1322 int m_nCaret; // Caret position, in characters
1323 bool m_bInsertMode; // If true, control is in insert mode. Else, overwrite mode.
1324 int m_nSelStart; // Starting position of the selection. The caret marks the end.
1325 int m_nFirstVisible;// First visible character in the edit control
1328 Rendering::PackedColor m_SelBkColor; // Selected background color
1330
1331 // Mouse-specific
1332 bool m_bMouseDrag; // True to indicate drag in progress
1333
1334 // Static
1335 static bool s_bHideCaret; // If true, we don't render the caret.
1336};
1337
1338
1339
1340
1341#endif // UI_GUI_H
1342
1343#pragma warning(pop)
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void SCRIPT_CONTROL SCRIPT_STATE const int SCRIPT_TABDEF const BYTE SCRIPT_STRING_ANALYSIS BOOL
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
UI_CONTROL_STATE
Definition Controls.h:80
@ UI_STATE_DISABLED
Definition Controls.h:82
@ UI_STATE_NORMAL
Definition Controls.h:81
@ UI_STATE_MOUSEOVER
Definition Controls.h:85
@ UI_STATE_HIDDEN
Definition Controls.h:83
@ UI_STATE_PRESSED
Definition Controls.h:86
@ UI_STATE_FOCUS
Definition Controls.h:84
UI_CONTROL_TYPE
Definition Controls.h:66
@ UI_CONTROL_LISTBOX
Definition Controls.h:75
@ UI_CONTROL_BUTTON
Definition Controls.h:67
@ UI_CONTROL_COMBOBOX
Definition Controls.h:71
@ UI_CONTROL_CHECKBOX
Definition Controls.h:69
@ UI_CONTROL_IMEEDITBOX
Definition Controls.h:74
@ UI_CONTROL_SLIDER
Definition Controls.h:72
@ UI_CONTROL_STATIC
Definition Controls.h:68
@ UI_CONTROL_EDITBOX
Definition Controls.h:73
@ UI_CONTROL_SCROLLBAR
Definition Controls.h:76
@ UI_CONTROL_RADIOBUTTON
Definition Controls.h:70
#define EVENT_BUTTON_CLICKED
Definition Controls.h:22
VOID(CALLBACK *) UICallback(UINT nEvent, int nControlID, RiseControl *pControl, void *pUserContext)
Definition Controls.h:58
#define MAX_TEXT
Definition Controls.h:17
#define MAX_CONTROL_STATES
Definition Controls.h:89
static void WINAPI Initialize()
static SCRIPT_CONTROL SCRIPT_STATE *static const void SCRIPT_CONTROL SCRIPT_STATE const int SCRIPT_TABDEF const BYTE SCRIPT_STRING_ANALYSIS *static int *static int int *static HRESULT(WINAPI *_ScriptStringFree)(SCRIPT_STRING_ANALYSIS *)
static const SCRIPT_LOGATTR *WINAPI Dummy_ScriptString_pLogAttr(SCRIPT_STRING_ANALYSIS)
Definition Controls.h:1222
WCHAR * m_pwszBuffer
Definition Controls.h:1189
bool SetText(LPCWSTR wszText)
bool InsertChar(int nIndex, WCHAR wChar)
static HRESULT(WINAPI *_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
bool RemoveChar(int nIndex)
int GetTextSize()
Definition Controls.h:1152
SCRIPT_STRING_ANALYSIS m_Analysis
Definition Controls.h:1195
const WCHAR * GetBuffer()
Definition Controls.h:1156
static SCRIPT_CONTROL SCRIPT_STATE *static const void int
Definition Controls.h:1234
static const int *WINAPI Dummy_ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS)
Definition Controls.h:1226
UIFontNode * m_pFontNode
Definition Controls.h:1193
static HRESULT WINAPI Dummy_ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS, int, BOOL, int *)
Definition Controls.h:1210
static SCRIPT_CONTROL SCRIPT_STATE *static const void SCRIPT_CONTROL SCRIPT_STATE const int SCRIPT_TABDEF const BYTE SCRIPT_STRING_ANALYSIS *static BOOL
Definition Controls.h:1238
const WCHAR & operator[](int n) const
Definition Controls.h:1160
int m_nBufferSize
Definition Controls.h:1190
void SetFontNode(UIFontNode *pFontNode)
Definition Controls.h:1169
void Clear()
static void WINAPI Uninitialize()
static HINSTANCE s_hDll
Definition Controls.h:1244
bool InsertString(int nIndex, const WCHAR *pStr, int nCount=-1)
void GetNextItemPos(int nCP, int *pPrior)
UIFontNode * GetFontNode()
Definition Controls.h:1165
static SCRIPT_CONTROL SCRIPT_STATE *static const void DWORD
Definition Controls.h:1234
HRESULT CPtoX(int nCP, BOOL bTrail, int *pX)
static HRESULT WINAPI Dummy_ScriptStringFree(SCRIPT_STRING_ANALYSIS *)
Definition Controls.h:1218
static HRESULT WINAPI Dummy_ScriptStringAnalyse(HDC, const void *, int, int, int, DWORD, int, SCRIPT_CONTROL *, SCRIPT_STATE *, const int *, SCRIPT_TABDEF *, const BYTE *, SCRIPT_STRING_ANALYSIS *)
Definition Controls.h:1204
static HRESULT WINAPI Dummy_ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS, int, int *, int *)
Definition Controls.h:1214
bool SetBufferSize(int nSize)
static HRESULT WINAPI Dummy_ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE *, SCRIPT_CONTROL *, SCRIPT_STATE *)
Definition Controls.h:1199
int GetBufferSize()
Definition Controls.h:1147
HRESULT Analyse()
bool m_bAnalyseRequired
Definition Controls.h:1194
HRESULT XtoCP(int nX, int *pCP, int *pnTrail)
static const int *WINAPI * _ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS)
static SCRIPT_CONTROL SCRIPT_STATE *static const void SCRIPT_CONTROL SCRIPT_STATE const int SCRIPT_TABDEF const BYTE SCRIPT_STRING_ANALYSIS *static int *static HRESULT(WINAPI *_ScriptStringXtoCP)(SCRIPT_STRING_ANALYSIS
static const SCRIPT_LOGATTR *WINAPI * _ScriptString_pLogAttr(SCRIPT_STRING_ANALYSIS)
void GetPriorItemPos(int nCP, int *pPrior)
CUniBuffer(int nInitialSize=1)
T & GetAt(int index)
int GetSize() const
virtual void Render(float fElapsedTime)
virtual bool CanHaveFocus()
Definition Controls.h:733
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
bool m_bPressed
Definition Controls.h:741
RiseButton(RiseDialog *pDialog=NULL)
virtual BOOL ContainsPoint(POINT pt)
Definition Controls.h:729
virtual void OnHotkey()
Definition Controls.h:723
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual void SetCheckedInternal(bool bChecked, bool bFromInput)
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
RECT m_rcText
Definition Controls.h:780
RECT m_rcButton
Definition Controls.h:779
virtual void OnHotkey()
Definition Controls.h:755
bool GetChecked()
Definition Controls.h:766
virtual void Render(float fElapsedTime)
virtual void UpdateRects()
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
virtual BOOL ContainsPoint(POINT pt)
RiseCheckBox(RiseDialog *pDialog=NULL)
bool m_bChecked
Definition Controls.h:778
void SetChecked(bool bChecked)
Definition Controls.h:770
int m_nDropHeight
Definition Controls.h:1065
ControlArray< UIComboBoxItem * > m_Items
Definition Controls.h:1078
virtual HRESULT OnInit()
Definition Controls.h:1004
virtual void SetTextColor(Rendering::PackedColor Color, Rendering::PackedColor DisabledColor=Rendering::ColorARGB(200, 128, 128, 128))
RECT m_rcDropdownText
Definition Controls.h:1075
void * GetItemData(const WCHAR *strText)
int FindItem(const WCHAR *strText, UINT iStart=0)
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
int m_nFontHeight
Definition Controls.h:1066
void * GetSelectedData()
UINT GetNumItems()
Definition Controls.h:1049
HRESULT SetSelectedByIndex(UINT index)
RECT m_rcDropdown
Definition Controls.h:1074
int GetScrollBarWidth() const
Definition Controls.h:1033
virtual void UpdateRects()
UIComboBoxItem * GetItem(UINT index)
Definition Controls.h:1053
virtual void Render(float fElapsedTime)
void SetScrollBarWidth(int nWidth)
Definition Controls.h:1037
void RemoveAllItems()
virtual void OnHotkey()
bool ContainsItem(const WCHAR *strText, UINT iStart=0)
UIComboBoxItem * GetSelectedItem()
void RemoveItem(UINT index)
RiseScrollBar m_ScrollBar
Definition Controls.h:1067
RECT m_rcButton
Definition Controls.h:1073
virtual void OnFocusOut()
HRESULT AddItem(const WCHAR *strText, void *pData)
HRESULT SetSelectedByData(void *pData)
virtual bool CanHaveFocus()
Definition Controls.h:1013
HRESULT SetSelectedByText(const WCHAR *strText)
RiseComboBox(RiseDialog *pDialog=NULL)
void SetDropHeight(UINT nHeight, UINT fHeight)
Definition Controls.h:1029
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
int GetSelectedIndex() const
Definition Controls.h:1042
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition Controls.h:537
bool m_bVisible
Definition Controls.h:642
UINT m_Index
Definition Controls.h:655
RiseElement * GetElement(UINT iElement)
Definition Controls.h:636
virtual void OnFocusOut()
Definition Controls.h:554
virtual void OnMouseLeave()
Definition Controls.h:562
void SetLocation(int x, int y)
Definition Controls.h:606
virtual bool GetEnabled()
Definition Controls.h:579
RECT m_rcBoundingBox
Definition Controls.h:669
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
Definition Controls.h:541
bool m_bShadow
Definition Controls.h:643
virtual HRESULT OnInit()
Definition Controls.h:522
void SetHotkey(UINT nHotkey)
Definition Controls.h:617
virtual void Refresh()
bool m_bIsDefault
Definition Controls.h:646
virtual void OnMouseEnter()
Definition Controls.h:558
UI_CONTROL_TYPE m_Type
Definition Controls.h:663
bool m_bHasFocus
Definition Controls.h:645
void SetUserData(void *pUserData)
Definition Controls.h:626
void SetID(int ID)
Definition Controls.h:601
bool m_bEnabled
Definition Controls.h:667
UINT GetType() const
Definition Controls.h:592
virtual void Render(float fElapsedTime)
Definition Controls.h:527
UINT GetHotkey()
Definition Controls.h:621
virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition Controls.h:532
virtual bool GetVisible()
Definition Controls.h:587
virtual bool CanHaveFocus()
Definition Controls.h:546
UINT m_nHotkey
Definition Controls.h:664
HRESULT SetElement(UINT iElement, RiseElement *pElement)
virtual void OnHotkey()
Definition Controls.h:566
bool m_bMouseOver
Definition Controls.h:644
virtual void UpdateRects()
int GetID() const
Definition Controls.h:597
void SetSize(int width, int height)
Definition Controls.h:610
void * GetUserData() const
Definition Controls.h:630
virtual void SetVisible(bool bVisible)
Definition Controls.h:583
RiseControl(RiseDialog *pDialog=NULL)
virtual BOOL ContainsPoint(POINT pt)
Definition Controls.h:570
virtual void OnFocusIn()
Definition Controls.h:550
void * m_pUserData
Definition Controls.h:665
RiseDialog * m_pDialog
Definition Controls.h:654
virtual void SetEnabled(bool bEnabled)
Definition Controls.h:575
ControlArray< RiseElement * > m_Elements
Definition Controls.h:657
bool m_bIsPassword
Definition Controls.h:647
virtual void SetTextColor(Rendering::PackedColor Color)
RiseElement * GetDefaultElement(UINT nControlType, UINT iElement)
float m_fScale
Definition Controls.h:357
static RiseControl * s_pControlFocus
Definition Controls.h:379
void RemoveControl(int ID)
Definition Controls.cpp:226
double m_fTimeLastRefresh
Definition Controls.h:365
void SetNextDialog(RiseDialog *pNextDialog)
HRESULT DrawPolyLine(POINT *apPoints, UINT nNumPoints, Rendering::PackedColor color)
void SendEvent(UINT nEvent, bool bTriggeredByUser, RiseControl *pControl)
Definition Controls.cpp:655
RiseEditBox * GetEditBox(int ID)
Definition Controls.h:196
bool m_bDrag
Definition Controls.h:387
Rendering::PackedColor m_colorTopLeft
Definition Controls.h:396
void Init(RiseDialogResourceManager *pManager, bool bRegisterDialog=true)
Definition Controls.cpp:176
RiseControl * GetControlAtPoint(POINT pt)
static void WINAPI SetRefreshTime(float fTime)
Definition Controls.h:303
HRESULT InitControl(RiseControl *pControl)
RiseDialog * m_pNextDialog
Definition Controls.h:413
bool m_bMouseInput
Definition Controls.h:356
HRESULT SetTexture(UINT index, LPCWSTR strFilename)
Definition Controls.cpp:834
Rendering::PackedColor m_colorBottomRight
Definition Controls.h:399
HRESULT SetDefaultElement(UINT nControlType, UINT iElement, RiseElement *pElement)
HRESULT CalcTextRect(LPCWSTR strText, RiseElement *pElement, RECT *prcDest, int nCount=-1)
Rendering::PackedColor m_colorTopRight
Definition Controls.h:397
bool m_bKeyboardInput
Definition Controls.h:355
HRESULT AddComboBox(int ID, int x, int y, int width, int height, UINT nHotKey=0, bool bIsDefault=false, RiseComboBox **ppCreated=NULL)
UICallback m_pCallbackEvent
Definition Controls.h:402
friend class RiseDialogResourceManager
Definition Controls.h:133
void RemoveAllControls()
Definition Controls.cpp:254
RiseControl * m_pControlMouseOver
Definition Controls.h:382
static double s_fTimeRefresh
Definition Controls.h:364
void SetCaptionText(const WCHAR *pwszText)
Definition Controls.h:273
void OnMouseUp(POINT pt)
bool m_bCaption
Definition Controls.h:385
RiseComboBox * GetComboBox(int ID)
Definition Controls.h:188
void ClearComboBox(int ID)
HRESULT AddListBox(int ID, int x, int y, int width, int height, DWORD dwStyle=0, RiseListBox **ppCreated=NULL)
void EnableKeyboardInput(bool bEnable)
Definition Controls.h:320
UITextureNode * GetTexture(UINT index)
Definition Controls.cpp:878
bool m_bVisible
Definition Controls.h:384
HRESULT AddCheckBox(int ID, LPCWSTR strText, int x, int y, int width, int height, bool bChecked=false, UINT nHotkey=0, bool bIsDefault=false, RiseCheckBox **ppCreated=NULL)
void EnableNonUserEvents(bool bEnable)
Definition Controls.h:316
static RiseControl *WINAPI GetPrevControl(RiseControl *pControl)
ControlArray< RiseControl * > m_Controls
Definition Controls.h:408
void SetSize(int width, int height)
Definition Controls.h:285
void SetMinimized(bool bMinimized)
Definition Controls.h:251
void ClearRadioButtonGroup(UINT nGroup)
bool MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition Controls.cpp:888
void OnMouseMove(POINT pt)
RiseRadioButton * GetRadioButton(int ID)
Definition Controls.h:184
int m_height
Definition Controls.h:393
void AppendVisibleBounds(std::vector< RECT > &rectangles) const
Definition Controls.cpp:510
bool GetVisible()
Definition Controls.h:239
void FocusDefaultControl()
UIFontNode * GetFont(UINT index)
Definition Controls.cpp:732
RiseDialogResourceManager * m_pManager
Definition Controls.h:401
void EnableCaption(bool bEnable)
Definition Controls.h:261
RiseControl * GetControl(int ID)
static RiseControl *WINAPI GetNextControl(RiseControl *pControl)
HRESULT DrawText(LPCWSTR strText, RiseElement *pElement, RECT *prcDest, bool bShadow=false, int nCount=-1)
void GetLocation(POINT &Pt) const
Definition Controls.h:277
void SetVisible(bool bVisible)
Definition Controls.h:243
void Refresh()
Definition Controls.cpp:482
Rendering::PackedColor m_colorBottomLeft
Definition Controls.h:398
HRESULT AddStatic(int ID, LPCWSTR strText, int x, int y, int width, int height, bool bIsDefault=false, RiseStatic **ppCreated=NULL, bool bShadow=true)
void SetCaptionHeight(int nHeight)
Definition Controls.h:269
RiseDialog * m_pPrevDialog
Definition Controls.h:414
static void WINAPI ClearFocus()
bool m_bMinimized
Definition Controls.h:386
int GetWidth()
Definition Controls.h:289
void SetLocation(int x, int y)
Definition Controls.h:281
ControlArray< UIElementHolder * > m_DefaultElements
Definition Controls.h:409
RiseElement m_CapElement
Definition Controls.h:411
void SetBackgroundColors(Rendering::PackedColor colorAllCorners)
Definition Controls.h:255
ControlArray< int > m_Fonts
Definition Controls.h:406
RiseStatic * GetStatic(int ID)
Definition Controls.h:172
int GetCaptionHeight() const
Definition Controls.h:265
int m_nCaptionHeight
Definition Controls.h:394
int m_nDefaultControlID
Definition Controls.h:360
bool OnCycleFocus(bool bForward)
RiseListBox * GetListBox(int ID)
Definition Controls.h:200
bool GetControlEnabled(int ID)
HRESULT OnRender(float fElapsedTime)
Definition Controls.cpp:526
HRESULT AddEditBox(int ID, LPCWSTR strText, int x, int y, int width, int height, bool bIsDefault=false, bool bIsPassword=false, RiseEditBox **ppCreated=NULL)
ControlArray< int > m_Textures
Definition Controls.h:405
void RequestFocus(RiseControl *pControl)
static RiseControl * s_pControlPressed
Definition Controls.h:380
HRESULT AddRadioButton(int ID, UINT nButtonGroup, LPCWSTR strText, int x, int y, int width, int height, bool bChecked=false, UINT nHotkey=0, bool bIsDefault=false, RiseRadioButton **ppCreated=NULL)
void EnableMouseInput(bool bEnable)
Definition Controls.h:324
void SetScale(float scale)
Definition Controls.h:298
RiseCheckBox * GetCheckBox(int ID)
Definition Controls.h:180
void InitDefaultElements()
RiseButton * GetButton(int ID)
Definition Controls.h:176
int m_width
Definition Controls.h:392
void * m_pCallbackEventUserContext
Definition Controls.h:403
HRESULT DrawRect(RECT *pRect, Rendering::PackedColor color)
RiseSlider * GetSlider(int ID)
Definition Controls.h:192
HRESULT AddControl(RiseControl *pControl)
WCHAR m_wszCaption[256]
Definition Controls.h:388
HRESULT SetFont(UINT index, LPCWSTR strFaceName, LONG height, LONG weight)
Definition Controls.cpp:709
void SetCallback(UICallback pCallback, void *pUserContext=NULL)
Definition Controls.cpp:212
HRESULT AddButton(int ID, LPCWSTR strText, int x, int y, int width, int height, UINT nHotkey=0, bool bIsDefault=false, RiseButton **ppCreated=NULL)
bool m_bNonUserEvents
Definition Controls.h:354
RiseDialogResourceManager * GetManager()
Definition Controls.h:346
bool IsKeyboardInputEnabled() const
Definition Controls.h:328
int GetHeight()
Definition Controls.h:293
bool GetMinimized()
Definition Controls.h:247
HRESULT DrawSprite(RiseElement *pElement, RECT *prcDest, float fDepth=0)
void SetControlEnabled(int ID, bool bEnabled)
HRESULT AddSlider(int ID, int x, int y, int width, int height, int min=0, int max=100, int value=50, bool bIsDefault=false, RiseSlider **ppCreated=NULL)
HRESULT CreateTexture(UINT index)
Rendering::RenderDevice * GetRenderer()
Definition Controls.h:457
void EnableKeyboardInputForAllDialogs()
Definition Controls.cpp:473
Rendering::RenderSprite * m_pSprite
Definition Controls.h:490
UITextureNode * GetTextureNode(int iIndex)
Definition Controls.h:473
void UnregisterDialog(RiseDialog *pDialog)
Definition Controls.cpp:444
UIFontNode * GetFontNode(int iIndex)
Definition Controls.h:469
HRESULT OnCreateDevice(Rendering::RenderDevice *pd3dDevice)
Definition Controls.cpp:306
bool RegisterDialog(RiseDialog *pDialog)
Definition Controls.cpp:423
ControlArray< UIFontNode * > m_FontCache
Definition Controls.h:509
int AddTexture(LPCWSTR strFilename)
Definition Controls.cpp:741
Rendering::RenderStateSnapshot * m_pStateBlock
Definition Controls.h:489
int AddFont(LPCWSTR strFaceName, LONG height, LONG weight)
Definition Controls.cpp:671
ControlArray< UITextureNode * > m_TextureCache
Definition Controls.h:508
HRESULT CreateFont(UINT index)
Rendering::RenderDevice * m_renderer
Definition Controls.h:500
bool MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition Controls.cpp:357
ControlArray< RiseDialog * > m_Dialogs
Definition Controls.h:496
Rendering::PackedColor m_SelBkColor
Definition Controls.h:1328
void DeleteSelectionText()
double m_dfLastBlink
Definition Controls.h:1320
void SetSpacing(int nSpacing)
Definition Controls.h:1300
void ClearText()
void PlaceCaret(int nCP)
bool m_bInsertMode
Definition Controls.h:1323
void SetBorderWidth(int nBorder)
Definition Controls.h:1296
void CopyToClipboard()
double m_dfBlink
Definition Controls.h:1319
int m_nSelStart
Definition Controls.h:1324
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
int m_nFirstVisible
Definition Controls.h:1325
void PasteFromClipboard()
RECT m_rcRender[9]
Definition Controls.h:1318
bool m_bCaretOn
Definition Controls.h:1321
void ResetCaretBlink()
virtual void Render(float fElapsedTime)
virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
LPCWSTR GetText()
Definition Controls.h:1269
void SetCaretColor(Rendering::PackedColor Color)
Definition Controls.h:1292
virtual void OnFocusIn()
Rendering::PackedColor m_CaretColor
Definition Controls.h:1329
void SetText(LPCWSTR wszText, bool bSelected=false)
CUniBuffer m_Buffer
Definition Controls.h:1314
void SetSelectedBackColor(Rendering::PackedColor Color)
Definition Controls.h:1288
RiseEditBox(RiseDialog *pDialog=NULL)
void SetSelectedTextColor(Rendering::PackedColor Color)
Definition Controls.h:1284
virtual void SetTextColor(Rendering::PackedColor Color)
Definition Controls.h:1280
Rendering::PackedColor m_TextColor
Definition Controls.h:1326
static bool s_bHideCaret
Definition Controls.h:1335
virtual bool CanHaveFocus()
Definition Controls.h:1261
void SetTextFloatArray(const float *pNumbers, int nCount)
HRESULT GetTextCopy(__out_ecount(bufferCount) LPWSTR strDest, UINT bufferCount)
bool m_bMouseDrag
Definition Controls.h:1332
int GetTextLength()
Definition Controls.h:1273
virtual void UpdateRects()
RECT m_rcText
Definition Controls.h:1317
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
Rendering::PackedColor m_SelTextColor
Definition Controls.h:1327
void ParseFloatArray(float *pNumbers, int nCount)
void SetFont(UINT prmFont, Rendering::PackedColor defaultFontColor=Rendering::ColorARGB(255, 255, 255, 255), DWORD prmTextFormat=DT_CENTER|DT_VCENTER)
UIBlendColor TextureColor
Definition Controls.h:122
RECT rcTexture
Definition Controls.h:120
UINT iTexture
Definition Controls.h:116
UIBlendColor FontColor
Definition Controls.h:123
DWORD dwTextFormat
Definition Controls.h:118
void Refresh()
void SetTexture(UINT prmTexture, RECT *prcTexture, Rendering::PackedColor defaultTextureColor=Rendering::ColorARGB(255, 255, 255, 255))
RECT m_rcText
Definition Controls.h:968
UIListBoxItem * GetItem(int nIndex)
int m_nSBWidth
Definition Controls.h:971
RECT m_rcSelection
Definition Controls.h:969
DWORD GetStyle() const
Definition Controls.h:924
int m_nTextHeight
Definition Controls.h:974
RiseListBox(RiseDialog *pDialog=NULL)
void SetScrollBarWidth(int nWidth)
Definition Controls.h:940
int GetScrollBarWidth() const
Definition Controls.h:936
int m_nSelected
Definition Controls.h:976
int GetSize() const
Definition Controls.h:928
virtual bool CanHaveFocus()
Definition Controls.h:913
DWORD m_dwStyle
Definition Controls.h:975
void RemoveAllItems()
virtual void Render(float fElapsedTime)
void SetBorder(int nBorder, int nMargin)
Definition Controls.h:944
virtual void UpdateRects()
int m_nSelStart
Definition Controls.h:977
void RemoveItem(int nIndex)
UIListBoxItem * GetSelectedItem(int nPreviousSelected=-1)
Definition Controls.h:956
HRESULT AddItem(const WCHAR *wszText, void *pData)
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual HRESULT OnInit()
Definition Controls.h:909
bool m_bDrag
Definition Controls.h:978
void SetStyle(DWORD dwStyle)
Definition Controls.h:932
int m_nBorder
Definition Controls.h:972
void SelectItem(int nNewIndex)
ControlArray< UIListBoxItem * > m_Items
Definition Controls.h:980
void RemoveItemByData(void *pData)
int m_nMargin
Definition Controls.h:973
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
RiseScrollBar m_ScrollBar
Definition Controls.h:970
int GetSelectedIndex(int nPreviousSelected=-1)
HRESULT InsertItem(int nIndex, const WCHAR *wszText, void *pData)
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
UINT m_nButtonGroup
Definition Controls.h:815
void SetChecked(bool bChecked, bool bClearGroup=true)
Definition Controls.h:800
virtual void SetCheckedInternal(bool bChecked, bool bClearGroup, bool bFromInput)
RiseRadioButton(RiseDialog *pDialog=NULL)
UINT GetButtonGroup()
Definition Controls.h:808
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
void SetButtonGroup(UINT nButtonGroup)
Definition Controls.h:804
virtual void OnHotkey()
Definition Controls.h:794
virtual void Render(float fElapsedTime)
int GetTrackPos()
Definition Controls.h:836
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
void Scroll(int nDelta)
void SetPageSize(int nPageSize)
Definition Controls.h:848
RiseScrollBar(RiseDialog *pDialog=NULL)
RECT m_rcUpButton
Definition Controls.h:877
virtual void UpdateRects()
POINT m_LastMouse
Definition Controls.h:885
void SetTrackPos(int nPosition)
Definition Controls.h:840
void ShowItem(int nIndex)
RECT m_rcDownButton
Definition Controls.h:878
void UpdateThumbRect()
ARROWSTATE m_Arrow
Definition Controls.h:886
void SetTrackRange(int nStart, int nEnd)
virtual bool MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
int GetPageSize()
Definition Controls.h:844
double m_dArrowTS
Definition Controls.h:887
bool m_bShowThumb
Definition Controls.h:875
void GetRange(int &nMin, int &nMax) const
Definition Controls.h:1111
virtual bool CanHaveFocus()
Definition Controls.h:1091
int m_nDragOffset
Definition Controls.h:1127
int ValueFromPos(int x)
virtual void Render(float fElapsedTime)
virtual bool HandleKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual bool HandleMouse(UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam)
RECT m_rcButton
Definition Controls.h:1131
int GetValue() const
Definition Controls.h:1106
void SetValue(int nValue)
Definition Controls.h:1102
virtual void UpdateRects()
virtual BOOL ContainsPoint(POINT pt)
bool m_bPressed
Definition Controls.h:1130
int m_nButtonX
Definition Controls.h:1128
RiseSlider(RiseDialog *pDialog=NULL)
void SetValueInternal(int nValue, bool bFromInput)
void SetRange(int nMin, int nMax)
RiseStatic(RiseDialog *pDialog=NULL)
WCHAR m_strText[MAX_TEXT]
Definition Controls.h:709
LPCWSTR GetText()
Definition Controls.h:701
virtual BOOL ContainsPoint(POINT pt)
Definition Controls.h:694
HRESULT SetText(LPCWSTR strText)
virtual void Render(float fElapsedTime)
HRESULT GetTextCopy(__out_ecount(bufferCount) LPWSTR strDest, UINT bufferCount)
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
uint32_t PackedColor
void Blend(UINT iState, float fElapsedTime, float fRate=0.7f)
void Init(Rendering::PackedColor defaultColor, Rendering::PackedColor disabledColor=Rendering::ColorARGB(200, 128, 128, 128), Rendering::PackedColor hiddenColor=0)
RiseMath::Color Current
Definition Controls.h:98
Rendering::PackedColor States[MAX_CONTROL_STATES]
Definition Controls.h:97
WCHAR strText[256]
Definition Controls.h:989
RiseElement Element
Definition Controls.h:681
LONG nWeight
Definition Controls.h:436
Rendering::RenderFont * font
Definition Controls.h:437
WCHAR strFace[MAX_PATH]
Definition Controls.h:434
LONG nHeight
Definition Controls.h:435
void * pData
Definition Controls.h:897
WCHAR strText[256]
Definition Controls.h:896
WCHAR strFilename[MAX_PATH]
Definition Controls.h:426
DWORD dwHeight
Definition Controls.h:428
Rendering::RenderTexture * texture
Definition Controls.h:429
DWORD dwWidth
Definition Controls.h:427
bool bFileSource
Definition Controls.h:423
HMODULE hResourceModule
Definition Controls.h:424