| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Combat *
- * *
- * $Archive:: /Commando/Code/wwui/dialogcontrol.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 10/26/01 12:07p $*
- * *
- * $Revision:: 13 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "dialogcontrol.h"
- #include "dialogbase.h"
- #include "mousemgr.h"
- #include "dialogmgr.h"
- #include "render2d.h"
- #include "stylemgr.h"
- ////////////////////////////////////////////////////////////////
- //
- // DialogControlClass
- //
- ////////////////////////////////////////////////////////////////
- DialogControlClass::DialogControlClass (void) :
- Rect (0, 0, 0, 0),
- ClientRect (0, 0, 0, 0),
- Style (0),
- ID (0),
- Parent (NULL),
- HasFocus (false),
- IsDirty (true),
- WantsFocus (true),
- AdviseSink (NULL),
- IsEnabled (true),
- IsVisible (true),
- IsEmbedded (false),
- TextColor (0, 0, 0),
- IsTextColorOverridden (false)
- {
-
- INT32_TO_VRGB (StyleMgrClass::Get_Text_Color (), TextColor);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // ~DialogControlClass
- //
- ////////////////////////////////////////////////////////////////
- DialogControlClass::~DialogControlClass (void)
- {
- //
- // Remove the input focus if this control has it
- //
- if (DialogMgrClass::Get_Focus () == this) {
- DialogMgrClass::Set_Focus (NULL);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Set_Focus
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::Set_Focus (void)
- {
- DialogMgrClass::Set_Focus (this);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Set_Cursor
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::On_Set_Cursor (const Vector2 & /*mouse_pos*/)
- {
- MouseMgrClass::Set_Cursor (MouseMgrClass::CURSOR_ARROW);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Set_Capture
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::Set_Capture (void)
- {
- DialogMgrClass::Set_Capture (this);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Release_Capture
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::Release_Capture (void)
- {
- DialogMgrClass::Release_Capture ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Set_Window_Pos
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::Set_Window_Pos (const Vector2 &pos)
- {
- float width = Rect.Width ();
- float height = Rect.Height ();
- //
- // Recalculate the window's bounding rectangle
- //
- Rect.Left = (int)pos.X;
- Rect.Top = (int)pos.Y;
- Rect.Right = (int)(Rect.Left + width);
- Rect.Bottom = (int)(Rect.Top + height);
- //
- // Let the control recalculate anything it needs
- //
- Update_Client_Rect ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Center_Mouse
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::Center_Mouse (void)
- {
- //
- // Put the mouse cursor in the middle of this control
- //
- /*Vector3 mouse_pos = DialogMgrClass::Get_Mouse_Pos ();
- mouse_pos.X = Rect.Left + int(Rect.Width () / 2);
- mouse_pos.Y = Rect.Top + int(Rect.Height () / 2);
- DialogMgrClass::Set_Mouse_Pos (mouse_pos);*/
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Enable
- //
- ////////////////////////////////////////////////////////////////
- void
- DialogControlClass::Enable (bool onoff)
- {
- if (onoff != IsEnabled) {
- IsEnabled = onoff;
- Set_Dirty ();
- //
- // Remove the focus (if necessary)
- //
- if (IsEnabled == false && DialogMgrClass::Get_Focus () == this) {
- DialogMgrClass::Set_Focus (NULL);
- }
- }
- return ;
- }
|