Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1041 lines
41 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef PANEL_H
  8. #define PANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/utlflags.h"
  13. #include "vgui/VGUI.h"
  14. #include "vgui/Dar.h"
  15. #include "vgui_controls/MessageMap.h"
  16. #if defined( VGUI_USEKEYBINDINGMAPS )
  17. #include "vgui_controls/KeyBindingMap.h"
  18. #endif
  19. #include "vgui/IClientPanel.h"
  20. #include "vgui/IScheme.h"
  21. #include "vgui_controls/Controls.h"
  22. #include "vgui_controls/PHandle.h"
  23. #include "vgui_controls/PanelAnimationVar.h"
  24. #include "Color.h"
  25. #include "vstdlib/IKeyValuesSystem.h"
  26. #include "tier1/utlsymbol.h"
  27. #include "vgui_controls/BuildGroup.h"
  28. // undefine windows function macros that overlap
  29. #ifdef PostMessage
  30. #undef PostMessage
  31. #endif
  32. #ifdef SetCursor
  33. #undef SetCursor
  34. #endif
  35. class CUtlBuffer;
  36. namespace vgui
  37. {
  38. #if !defined( _X360 )
  39. #define VGUI_USEDRAGDROP 1
  40. #endif
  41. #if defined( VGUI_USEKEYBINDINGMAPS )
  42. struct PanelKeyBindingMap;
  43. #endif
  44. //-----------------------------------------------------------------------------
  45. // Purpose: Helper functions to construct vgui panels
  46. //
  47. // SETUP_PANEL - will make a panel ready for use right now (i.e setup its colors, borders, fonts, etc)
  48. //
  49. template< class T >
  50. inline T *SETUP_PANEL(T *panel)
  51. {
  52. panel->MakeReadyForUse();
  53. return panel;
  54. }
  55. //
  56. // CREATE_PANEL - creates a panel that is ready to use right now
  57. //
  58. // example of use = to set the FG Color of a panel inside of a constructor (i.e before ApplySchemeSettings() has been run on the child)
  59. //
  60. #define CREATE_PANEL(type, parent, name) (SETUP_PANEL(new type(parent, name)))
  61. //-----------------------------------------------------------------------------
  62. // Purpose: Drag/drop support context info (could defined within Panel...)
  63. //-----------------------------------------------------------------------------
  64. #if defined( VGUI_USEDRAGDROP )
  65. struct DragDrop_t;
  66. class Menu;
  67. #endif
  68. //-----------------------------------------------------------------------------
  69. // Purpose: Macro to handle Colors that can be overridden in .res files
  70. //-----------------------------------------------------------------------------
  71. struct OverridableColorEntry
  72. {
  73. char const *name() { return m_pszScriptName; }
  74. char const *m_pszScriptName;
  75. Color *m_pColor;
  76. Color m_colFromScript;
  77. bool m_bOverridden;
  78. };
  79. #define REGISTER_COLOR_AS_OVERRIDABLE( name, scriptname ) \
  80. AddToOverridableColors( &name, scriptname );
  81. //-----------------------------------------------------------------------------
  82. // Purpose: For hudanimations.txt scripting of vars
  83. //-----------------------------------------------------------------------------
  84. class IPanelAnimationPropertyConverter
  85. {
  86. public:
  87. virtual void GetData( Panel *panel, KeyValues *kv, PanelAnimationMapEntry *entry ) = 0;
  88. virtual void SetData( Panel *panel, KeyValues *kv, PanelAnimationMapEntry *entry ) = 0;
  89. virtual void InitFromDefault( Panel *panel, PanelAnimationMapEntry *entry ) = 0;
  90. };
  91. #if defined( VGUI_USEKEYBINDINGMAPS )
  92. enum KeyBindingContextHandle_t
  93. {
  94. INVALID_KEYBINDINGCONTEXT_HANDLE = 0xffffffff,
  95. };
  96. #endif
  97. class IForceVirtualInheritancePanel
  98. {
  99. // We need Panel to use virtual inheritance so that
  100. // pointers to its members are max size.
  101. // This is due to a limitation in C++ with ahead
  102. // declarations of points to members as used in MessageMap.
  103. };
  104. //=============================================================================
  105. // HPE_BEGIN:
  106. // [tj] bitwise defines for rounded corners
  107. //=============================================================================
  108. #define PANEL_ROUND_CORNER_TOP_LEFT (1 << 0)
  109. #define PANEL_ROUND_CORNER_TOP_RIGHT (1 << 1)
  110. #define PANEL_ROUND_CORNER_BOTTOM_LEFT (1 << 2)
  111. #define PANEL_ROUND_CORNER_BOTTOM_RIGHT (1 << 3)
  112. #define PANEL_ROUND_CORNER_ALL PANEL_ROUND_CORNER_TOP_LEFT | PANEL_ROUND_CORNER_TOP_RIGHT | PANEL_ROUND_CORNER_BOTTOM_LEFT | PANEL_ROUND_CORNER_BOTTOM_RIGHT
  113. //=============================================================================
  114. // HPE_END
  115. //=============================================================================//-----------------------------------------------------------------------------
  116. // Purpose: Base interface to all vgui windows
  117. // All vgui controls that receive message and/or have a physical presence
  118. // on screen are be derived from Panel.
  119. // This is designed as an easy-access to the vgui-functionality; for more
  120. // low-level access to vgui functions use the IPanel/IClientPanel interfaces directly
  121. //-----------------------------------------------------------------------------
  122. class Panel : public IClientPanel, virtual public IForceVirtualInheritancePanel
  123. {
  124. DECLARE_CLASS_SIMPLE_NOBASE( Panel );
  125. public:
  126. // For property mapping
  127. static void InitPropertyConverters( void );
  128. static void AddPropertyConverter( char const *typeName, IPanelAnimationPropertyConverter *converter );
  129. //-----------------------------------------------------------------------------
  130. // CONSTRUCTORS
  131. // these functions deal with the creation of the Panel
  132. // the Panel automatically gets a handle to a vgui-internal panel, the ipanel(), upon construction
  133. // vgui interfaces deal only with ipanel(), not Panel directly
  134. Panel();
  135. Panel(Panel *parent);
  136. Panel(Panel *parent, const char *panelName);
  137. Panel(Panel *parent, const char *panelName, HScheme scheme);
  138. virtual ~Panel();
  139. // returns pointer to Panel's vgui VPanel interface handle
  140. virtual VPANEL GetVPanel() { return _vpanel; }
  141. VPANEL GetVPanel() const { return _vpanel; }
  142. HPanel ToHandle() const;
  143. virtual void Init( int x, int y, int wide, int tall );
  144. //-----------------------------------------------------------------------------
  145. // PANEL METHODS
  146. // these functions all manipulate panels
  147. // they cannot be derived from
  148. void SetName(const char *panelName); // sets the name of the panel - used as an identifier
  149. const char *GetName(); // returns the name of this panel... never NULL
  150. const char *GetClassName(); // returns the class name of the panel (eg. Panel, Label, Button, etc.)
  151. void MakeReadyForUse(); // fully construct this panel so its ready for use right now (i.e fonts loaded, colors set, default label text set, ...)
  152. // panel position & size
  153. // all units are in pixels
  154. void SetPos(int x,int y); // sets position of panel, in local space (ie. relative to parent's position)
  155. void GetPos(int &x,int &y); // gets local position of panel
  156. int GetXPos();
  157. int GetYPos();
  158. void SetSize(int wide,int tall); // sets size of panel
  159. void GetSize(int &wide, int &tall); // gets size of panel
  160. void SetBounds(int x, int y, int wide, int tall); // combination of SetPos/SetSize
  161. void GetBounds(int &x, int &y, int &wide, int &tall); // combination of GetPos/GetSize
  162. int GetWide(); // returns width of panel
  163. void SetWide(int wide); // sets width of panel
  164. int GetTall(); // returns height of panel
  165. void SetTall(int tall); // sets height of panel
  166. void SetMinimumSize(int wide,int tall); // sets the minimum size the panel can go
  167. void GetMinimumSize(int& wide,int& tall); // gets the minimum size
  168. bool IsBuildModeEditable(); // editable in the buildModeDialog?
  169. void SetBuildModeEditable(bool state); // set buildModeDialog editable
  170. bool IsBuildModeDeletable(); // deletable in the buildModeDialog?
  171. void SetBuildModeDeletable(bool state); // set buildModeDialog deletable
  172. bool IsBuildModeActive(); // true if we're currently in edit mode
  173. void SetZPos(int z); // sets Z ordering - lower numbers are always behind higher z's
  174. int GetZPos( void ) const;
  175. void SetAlpha(int alpha); // sets alpha modifier for panel and all child panels [0..255]
  176. int GetAlpha(); // returns the current alpha
  177. // panel visibility
  178. // invisible panels and their children do not drawn, updated, or receive input messages
  179. virtual void SetVisible(bool state);
  180. virtual bool IsVisible();
  181. // painting
  182. virtual VPANEL IsWithinTraverse(int x, int y, bool traversePopups); // recursive; returns a pointer to the panel at those coordinates
  183. MESSAGE_FUNC( Repaint, "Repaint" ); // marks the panel as needing to be repainted
  184. virtual void PostMessage(VPANEL target, KeyValues *message, float delaySeconds = 0.0f);
  185. bool IsWithin(int x, int y); //in screen space
  186. void LocalToScreen(int &x, int &y);
  187. void ScreenToLocal(int &x, int &y);
  188. void ParentLocalToScreen(int &x, int &y);
  189. void MakePopup(bool showTaskbarIcon = true,bool disabled = false); // turns the panel into a popup window (ie. can draw outside of it's parents space)
  190. virtual void OnMove();
  191. // panel hierarchy
  192. virtual Panel *GetParent();
  193. virtual VPANEL GetVParent();
  194. virtual void SetParent(Panel *newParent);
  195. virtual void SetParent(VPANEL newParent);
  196. virtual bool HasParent(VPANEL potentialParent);
  197. int GetChildCount();
  198. Panel *GetChild(int index);
  199. virtual CUtlVector< VPANEL > &GetChildren();
  200. int FindChildIndexByName( const char *childName );
  201. Panel *FindChildByName(const char *childName, bool recurseDown = false);
  202. Panel *FindSiblingByName(const char *siblingName);
  203. void CallParentFunction(KeyValues *message);
  204. template < class T >
  205. T *FindControl( const char *pszName, bool recurseDown = false ) { return dynamic_cast<T *>( FindChildByName( pszName, recurseDown ) ); }
  206. virtual void SetAutoDelete(bool state); // if set to true, panel automatically frees itself when parent is deleted
  207. virtual bool IsAutoDeleteSet();
  208. virtual void DeletePanel(); // simply does a { delete this; }
  209. // messaging
  210. virtual void AddActionSignalTarget(Panel *messageTarget);
  211. virtual void AddActionSignalTarget(VPANEL messageTarget);
  212. virtual void RemoveActionSignalTarget(Panel *oldTarget);
  213. virtual void PostActionSignal(KeyValues *message); // sends a message to the current actionSignalTarget(s)
  214. virtual bool RequestInfoFromChild(const char *childName, KeyValues *outputData);
  215. virtual void PostMessageToChild(const char *childName, KeyValues *messsage);
  216. virtual void PostMessage(Panel *target, KeyValues *message, float delaySeconds = 0.0f);
  217. virtual bool RequestInfo(KeyValues *outputData); // returns true if output is successfully written. You should always chain back to the base class if info request is not handled
  218. virtual bool SetInfo(KeyValues *inputData); // sets a specified value in the control - inverse of the above
  219. virtual void SetSilentMode( bool bSilent ); //change the panel's silent mode; if silent, the panel will not post any action signals
  220. // install a mouse handler
  221. virtual void InstallMouseHandler( Panel *pHandler ); // mouse events will be send to handler panel instead of this panel
  222. // drawing state
  223. virtual void SetEnabled(bool state);
  224. virtual bool IsEnabled();
  225. virtual bool IsPopup(); // has a parent, but is in it's own space
  226. virtual void GetClipRect(int &x0, int &y0, int &x1, int &y1);
  227. virtual void MoveToFront();
  228. // pin positions for auto-layout
  229. enum PinCorner_e
  230. {
  231. PIN_TOPLEFT = 0,
  232. PIN_TOPRIGHT,
  233. PIN_BOTTOMLEFT,
  234. PIN_BOTTOMRIGHT,
  235. // For sibling pinning
  236. PIN_CENTER_TOP,
  237. PIN_CENTER_RIGHT,
  238. PIN_CENTER_BOTTOM,
  239. PIN_CENTER_LEFT,
  240. PIN_LAST
  241. };
  242. // specifies the auto-resize directions for the panel
  243. enum AutoResize_e
  244. {
  245. AUTORESIZE_NO = 0,
  246. AUTORESIZE_RIGHT,
  247. AUTORESIZE_DOWN,
  248. AUTORESIZE_DOWNANDRIGHT,
  249. };
  250. // Sets the pin corner for non-resizing panels
  251. void SetPinCorner( PinCorner_e pinCorner, int nOffsetX, int nOffsetY );
  252. // Sets the pin corner + resize mode for resizing panels
  253. void SetAutoResize( PinCorner_e pinCorner, AutoResize_e resizeDir, int nPinOffsetX, int nPinOffsetY, int nUnpinnedCornerOffsetX, int nUnpinnedCornerOffsetY );
  254. AutoResize_e GetAutoResize();
  255. PinCorner_e GetPinCorner();
  256. // Gets the relative offset of the control from the pinned + non-pinned corner (for resizing)
  257. void GetPinOffset( int &dx, int &dy );
  258. void GetResizeOffset( int &dx, int &dy );
  259. void PinToSibling( const char *pszSibling, PinCorner_e pinOurCorner, PinCorner_e pinSibling );
  260. void UpdateSiblingPin( void );
  261. // colors
  262. virtual void SetBgColor(Color color);
  263. virtual void SetFgColor(Color color);
  264. virtual Color GetBgColor();
  265. virtual Color GetFgColor();
  266. virtual void SetCursor(HCursor cursor);
  267. virtual HCursor GetCursor();
  268. virtual void SetCursorAlwaysVisible( bool visible );
  269. virtual void RequestFocus(int direction = 0);
  270. virtual bool HasFocus();
  271. virtual void InvalidateLayout(bool layoutNow = false, bool reloadScheme = false);
  272. virtual bool RequestFocusPrev(VPANEL panel = NULL);
  273. virtual bool RequestFocusNext(VPANEL panel = NULL);
  274. // tab positioning
  275. virtual void SetTabPosition(int position);
  276. virtual int GetTabPosition();
  277. // border
  278. virtual void SetBorder(IBorder *border);
  279. virtual IBorder *GetBorder();
  280. virtual void SetPaintBorderEnabled(bool state);
  281. virtual void SetPaintBackgroundEnabled(bool state);
  282. virtual void SetPaintEnabled(bool state);
  283. virtual void SetPostChildPaintEnabled(bool state);
  284. virtual void SetPaintBackgroundType(int type); // 0 for normal(opaque), 1 for single texture from Texture1, and 2 for rounded box w/ four corner textures
  285. virtual void GetInset(int &left, int &top, int &right, int &bottom);
  286. virtual void GetPaintSize(int &wide, int &tall);
  287. virtual void SetBuildGroup(BuildGroup *buildGroup);
  288. virtual bool IsBuildGroupEnabled();
  289. virtual bool IsCursorNone();
  290. virtual bool IsCursorOver(); // returns true if the cursor is currently over the panel
  291. virtual void MarkForDeletion(); // object will free it's memory next tick
  292. virtual bool IsLayoutInvalid(); // does this object require a perform layout?
  293. virtual Panel *HasHotkey(wchar_t key); // returns the panel that has this hotkey
  294. virtual bool IsOpaque();
  295. bool IsRightAligned(); // returns true if the settings are aligned to the right of the screen
  296. bool IsBottomAligned(); // returns true if the settings are aligned to the bottom of the screen
  297. // scheme access functions
  298. virtual HScheme GetScheme();
  299. virtual void SetScheme(const char *tag);
  300. virtual void SetScheme(HScheme scheme);
  301. virtual Color GetSchemeColor(const char *keyName,IScheme *pScheme);
  302. virtual Color GetSchemeColor(const char *keyName, Color defaultColor,IScheme *pScheme);
  303. // called when scheme settings need to be applied; called the first time before the panel is painted
  304. virtual void ApplySchemeSettings(IScheme *pScheme);
  305. // interface to build settings
  306. // takes a group of settings and applies them to the control
  307. virtual void ApplySettings(KeyValues *inResourceData);
  308. // records the settings into the resource data
  309. virtual void GetSettings(KeyValues *outResourceData);
  310. // gets a description of the resource for use in the UI
  311. // format: <type><whitespace | punctuation><keyname><whitespace| punctuation><type><whitespace | punctuation><keyname>...
  312. // unknown types as just displayed as strings in the UI (for future UI expansion)
  313. virtual const char *GetDescription();
  314. // returns the name of the module that this instance of panel was compiled into
  315. virtual const char *GetModuleName();
  316. // user configuration settings
  317. // this is used for any control details the user wants saved between sessions
  318. // eg. dialog positions, last directory opened, list column width
  319. virtual void ApplyUserConfigSettings(KeyValues *userConfig);
  320. // returns user config settings for this control
  321. virtual void GetUserConfigSettings(KeyValues *userConfig);
  322. // optimization, return true if this control has any user config settings
  323. virtual bool HasUserConfigSettings();
  324. // message handlers
  325. // override to get access to the message
  326. // override to get access to the message
  327. virtual void OnMessage(const KeyValues *params, VPANEL fromPanel); // called when panel receives message; must chain back
  328. MESSAGE_FUNC_CHARPTR( OnCommand, "Command", command ); // called when a panel receives a command
  329. MESSAGE_FUNC( OnMouseCaptureLost, "MouseCaptureLost" ); // called after the panel loses mouse capture
  330. MESSAGE_FUNC( OnSetFocus, "SetFocus" ); // called after the panel receives the keyboard focus
  331. MESSAGE_FUNC( OnKillFocus, "KillFocus" ); // called after the panel loses the keyboard focus
  332. MESSAGE_FUNC( OnDelete, "Delete" ); // called to delete the panel; Panel::OnDelete() does simply { delete this; }
  333. virtual void OnThink(); // called every frame before painting, but only if panel is visible
  334. virtual void OnChildAdded(VPANEL child); // called when a child has been added to this panel
  335. virtual void OnSizeChanged(int newWide, int newTall); // called after the size of a panel has been changed
  336. // called every frame if ivgui()->AddTickSignal() is called
  337. virtual void OnTick();
  338. // input messages
  339. MESSAGE_FUNC_INT_INT( OnCursorMoved, "OnCursorMoved", x, y );
  340. virtual void OnCursorEntered();
  341. virtual void OnCursorExited();
  342. virtual void OnMousePressed(MouseCode code);
  343. virtual void OnMouseDoublePressed(MouseCode code);
  344. virtual void OnMouseReleased(MouseCode code);
  345. virtual void OnMouseMismatchedRelease( MouseCode code, Panel* pPressedPanel );
  346. virtual void OnMouseWheeled(int delta);
  347. // Trip pressing (e.g., select all text in a TextEntry) requires this to be enabled
  348. virtual void SetTriplePressAllowed( bool state );
  349. virtual bool IsTriplePressAllowed() const;
  350. virtual void OnMouseTriplePressed( MouseCode code );
  351. static char const *KeyCodeToString( KeyCode code );
  352. static wchar_t const *KeyCodeToDisplayString( KeyCode code );
  353. static wchar_t const *KeyCodeModifiersToDisplayString( KeyCode code, int modifiers ); // L"Ctrl+Alt+Shift+Backspace"
  354. static KeyCode StringToKeyCode( char const *str );
  355. #if defined( VGUI_USEKEYBINDINGMAPS )
  356. static KeyBindingContextHandle_t CreateKeyBindingsContext( char const *filename, char const *pathID = 0 );
  357. virtual void SetKeyBindingsContext( KeyBindingContextHandle_t handle );
  358. virtual KeyBindingContextHandle_t GetKeyBindingsContext() const;
  359. virtual bool IsValidKeyBindingsContext() const;
  360. static int GetPanelsWithKeyBindingsCount( KeyBindingContextHandle_t handle );
  361. static Panel *GetPanelWithKeyBindings( KeyBindingContextHandle_t handle, int index );
  362. static void RevertKeyBindings( KeyBindingContextHandle_t handle );
  363. static void ReloadKeyBindings( KeyBindingContextHandle_t handle );
  364. static void SaveKeyBindings( KeyBindingContextHandle_t handle );
  365. static void SaveKeyBindingsToFile( KeyBindingContextHandle_t handle, char const *filename, char const *pathID = 0 );
  366. static void LoadKeyBindings( KeyBindingContextHandle_t handle );
  367. static void LoadKeyBindingsForOnePanel( KeyBindingContextHandle_t handle, Panel *panelOfInterest );
  368. // OnKeyCodeTyped hooks into here for action
  369. virtual bool IsKeyRebound( KeyCode code, int modifiers );
  370. // If a panel implements this and returns true, then the IsKeyRebound check will fail and OnKeyCodeTyped messages will pass through..
  371. // sort of like setting the SetAllowKeyBindingChainToParent flag to false for specific keys
  372. virtual bool IsKeyOverridden( KeyCode code, int modifiers );
  373. virtual void AddKeyBinding( char const *bindingName, int keycode, int modifiers );
  374. KeyBindingMap_t *LookupBinding( char const *bindingName );
  375. KeyBindingMap_t *LookupBindingByKeyCode( KeyCode code, int modifiers );
  376. void LookupBoundKeys( char const *bindingName, CUtlVector< BoundKey_t * >& list );
  377. BoundKey_t *LookupDefaultKey( char const *bindingName );
  378. PanelKeyBindingMap *LookupMapForBinding( char const *bindingName );
  379. // Returns the number of keybindings
  380. int GetKeyMappingCount( );
  381. void RevertKeyBindingsToDefault();
  382. void RemoveAllKeyBindings();
  383. void ReloadKeyBindings();
  384. virtual void EditKeyBindings();
  385. // calls RevertKeyBindingsToDefault() and then LoadKeyBindingsForOnePanel( GetKeyBindingsContext(), this );
  386. void SaveKeyBindingsToBuffer( int level, CUtlBuffer& buf );
  387. bool ParseKeyBindings( KeyValues *kv );
  388. virtual char const *GetKeyBindingsFile() const;
  389. virtual char const *GetKeyBindingsFilePathID() const;
  390. // Set this to false to disallow IsKeyRebound chaining to GetParent() Panels...
  391. void SetAllowKeyBindingChainToParent( bool state );
  392. bool IsKeyBindingChainToParentAllowed() const;
  393. #endif // VGUI_USEKEYBINDINGMAPS
  394. // base implementation forwards Key messages to the Panel's parent
  395. // - override to 'swallow' the input
  396. virtual void OnKeyCodePressed(KeyCode code);
  397. virtual void OnKeyCodeTyped(KeyCode code);
  398. virtual void OnKeyTyped(wchar_t unichar);
  399. virtual void OnKeyCodeReleased(KeyCode code);
  400. virtual void OnKeyFocusTicked(); // every window gets key ticked events
  401. // forwards mouse messages to the panel's parent
  402. MESSAGE_FUNC( OnMouseFocusTicked, "OnMouseFocusTicked" );
  403. // message handlers that don't go through the message pump
  404. virtual void PaintBackground();
  405. virtual void Paint();
  406. virtual void PaintBorder();
  407. virtual void PaintBuildOverlay(); // the extra drawing for when in build mode
  408. virtual void PostChildPaint();
  409. virtual void PerformLayout();
  410. // this enables message mapping for this class - requires matching IMPLEMENT_PANELDESC() in the .cpp file
  411. DECLARE_PANELMAP();
  412. virtual VPANEL GetCurrentKeyFocus();
  413. // returns a pointer to the tooltip object associated with the panel
  414. // creates a new one if none yet exists
  415. BaseTooltip *GetTooltip();
  416. void SetTooltip( BaseTooltip *pToolTip, const char *pszText );
  417. /// Returns the effective tooltip text to use, whether stored
  418. /// locally in this panel, or in the tooltip object. Returns
  419. /// an empty string if no tooltip text
  420. const char *GetEffectiveTooltipText() const;
  421. // proportional mode settings
  422. virtual bool IsProportional() { return _flags.IsFlagSet( IS_PROPORTIONAL ); }
  423. virtual void SetProportional(bool state);
  424. // input interest
  425. virtual void SetMouseInputEnabled( bool state );
  426. virtual void SetKeyBoardInputEnabled( bool state );
  427. virtual bool IsMouseInputEnabled();
  428. virtual bool IsKeyBoardInputEnabled();
  429. virtual void DrawTexturedBox( int x, int y, int wide, int tall, Color color, float normalizedAlpha );
  430. virtual void DrawBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha, bool hollow = false );
  431. virtual void DrawBoxFade(int x, int y, int wide, int tall, Color color, float normalizedAlpha, unsigned int alpha0, unsigned int alpha1, bool bHorizontal, bool hollow = false );
  432. virtual void DrawHollowBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha );
  433. //=============================================================================
  434. // HPE_BEGIN:
  435. //=============================================================================
  436. // [menglish] Draws a hollow box similar to the already existing draw hollow box function, but takes the indents as params
  437. virtual void DrawHollowBox( int x, int y, int wide, int tall, Color color, float normalizedAlpha, int cornerWide, int cornerTall );
  438. // [tj] Simple getters and setters to decide which corners to draw rounded
  439. unsigned char GetRoundedCorners() { return m_roundedCorners; }
  440. void SetRoundedCorners (unsigned char cornerFlags) { m_roundedCorners = cornerFlags; }
  441. bool ShouldDrawTopLeftCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_TOP_LEFT ) != 0; }
  442. bool ShouldDrawTopRightCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_TOP_RIGHT ) != 0; }
  443. bool ShouldDrawBottomLeftCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_LEFT ) != 0; }
  444. bool ShouldDrawBottomRightCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_RIGHT ) != 0; }
  445. //=============================================================================
  446. // HPE_END
  447. //=============================================================================
  448. // Drag Drop Public interface
  449. virtual void SetDragEnabled( bool enabled );
  450. virtual bool IsDragEnabled() const;
  451. virtual void SetShowDragHelper( bool enabled );
  452. // Called if drag drop is started but not dropped on top of droppable panel...
  453. virtual void OnDragFailed( CUtlVector< KeyValues * >& msglist );
  454. // Use this to prevent chaining up from a parent which can mess with mouse functionality if you don't want to chain up from a child panel to the best
  455. // draggable parent.
  456. virtual void SetBlockDragChaining( bool block );
  457. virtual bool IsBlockingDragChaining() const;
  458. virtual int GetDragStartTolerance() const;
  459. virtual void SetDragSTartTolerance( int nTolerance );
  460. // If hover context time is non-zero, then after the drop cursor is hovering over the panel for that amount of time
  461. // the Show hover context menu function will be invoked
  462. virtual void SetDropEnabled( bool enabled, float m_flHoverContextTime = 0.0f );
  463. virtual bool IsDropEnabled() const;
  464. // Called if m_flHoverContextTime was non-zero, allows droppee to preview the drop data and show an appropriate menu
  465. // Return false if not using context menu
  466. virtual bool GetDropContextMenu( Menu *menu, CUtlVector< KeyValues * >& msglist );
  467. virtual void OnDropContextHoverShow( CUtlVector< KeyValues * >& msglist );
  468. virtual void OnDropContextHoverHide( CUtlVector< KeyValues * >& msglist );
  469. #if defined( VGUI_USEDRAGDROP )
  470. virtual DragDrop_t *GetDragDropInfo();
  471. #endif
  472. // For handling multiple selections...
  473. virtual void OnGetAdditionalDragPanels( CUtlVector< Panel * >& dragabbles );
  474. virtual void OnCreateDragData( KeyValues *msg );
  475. // Called to see if a drop enabled panel can accept the specified data blob
  476. virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
  477. // Mouse is on draggable panel and has started moving, but is not over a droppable panel yet
  478. virtual void OnDraggablePanelPaint();
  479. // Mouse is now over a droppable panel
  480. virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels );
  481. virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
  482. // called on droptarget when draggable panel entered/exited droptarget
  483. virtual void OnPanelEnteredDroppablePanel( CUtlVector< KeyValues * >& msglist );
  484. virtual void OnPanelExitedDroppablePanel ( CUtlVector< KeyValues * >& msglist );
  485. // Chains up to any parent marked DropEnabled
  486. virtual Panel *GetDropTarget( CUtlVector< KeyValues * >& msglist );
  487. // Chains up to first parent marked DragEnabled
  488. virtual Panel *GetDragPanel();
  489. virtual bool IsBeingDragged();
  490. virtual HCursor GetDropCursor( CUtlVector< KeyValues * >& msglist );
  491. Color GetDropFrameColor();
  492. Color GetDragFrameColor();
  493. // Can override to require custom behavior to start the drag state
  494. virtual bool CanStartDragging( int startx, int starty, int mx, int my );
  495. // Draws a filled rect of specified bounds, but omits the bounds of the skip panel from those bounds
  496. virtual void FillRectSkippingPanel( const Color &clr, int x, int y, int w, int h, Panel *skipPanel );
  497. virtual int GetPaintBackgroundType();
  498. virtual void GetCornerTextureSize( int& w, int& h );
  499. bool IsChildOfModalSubTree();
  500. bool IsChildOfSurfaceModalPanel();
  501. bool ShouldHandleInputMessage();
  502. virtual void SetSkipChildDuringPainting( Panel *child );
  503. // If this is set, then the drag drop won't occur until the mouse leaves the drag panels current rectangle
  504. void SetStartDragWhenMouseExitsPanel( bool state );
  505. bool IsStartDragWhenMouseExitsPanel() const;
  506. void DisableMouseInputForThisPanel( bool bDisable );
  507. bool IsMouseInputDisabledForThisPanel() const;
  508. bool GetForceStereoRenderToFrameBuffer() const { return m_bForceStereoRenderToFrameBuffer; }
  509. void SetForceStereoRenderToFrameBuffer( bool bForce ) { m_bForceStereoRenderToFrameBuffer = bForce; }
  510. void PostMessageToAllSiblings( KeyValues *msg, float delaySeconds = 0.0f );
  511. template< class S >
  512. void PostMessageToAllSiblingsOfType( KeyValues *msg, float delaySeconds = 0.0f );
  513. void SetConsoleStylePanel( bool bConsoleStyle );
  514. bool IsConsoleStylePanel() const;
  515. void SetParentNeedsCursorMoveEvents( bool bNeedsEvents ) { m_bParentNeedsCursorMoveEvents = bNeedsEvents; }
  516. bool ParentNeedsCursorMoveEvents() const { return m_bParentNeedsCursorMoveEvents; }
  517. // For 360: support directional navigation between UI controls via dpad
  518. enum NAV_DIRECTION { ND_UP, ND_DOWN, ND_LEFT, ND_RIGHT, ND_BACK, ND_NONE };
  519. virtual Panel* NavigateUp();
  520. virtual Panel* NavigateDown();
  521. virtual Panel* NavigateLeft();
  522. virtual Panel* NavigateRight();
  523. virtual Panel* NavigateActivate();
  524. virtual Panel* NavigateBack();
  525. virtual void NavigateTo();
  526. virtual void NavigateFrom();
  527. virtual void NavigateToChild( Panel *pNavigateTo ); //mouse support
  528. // if set, Panel gets PerformLayout called after the camera and the renderer's m_matrixWorldToScreen has been setup, so panels can be correctly attached to entities in the world
  529. inline void SetWorldPositionCurrentFrame( bool bWorldPositionCurrentFrame ) { m_bWorldPositionCurrentFrame = bWorldPositionCurrentFrame; }
  530. inline bool GetWorldPositionCurrentFrame() { return m_bWorldPositionCurrentFrame; }
  531. Panel* SetNavUp( Panel* navUp );
  532. Panel* SetNavDown( Panel* navDown );
  533. Panel* SetNavLeft( Panel* navLeft );
  534. Panel* SetNavRight( Panel* navRight );
  535. Panel* SetNavToRelay( Panel* navToRelay );
  536. Panel* SetNavActivate( Panel* navActivate );
  537. Panel* SetNavBack( Panel* navBack );
  538. NAV_DIRECTION GetLastNavDirection();
  539. MESSAGE_FUNC_CHARPTR( OnNavigateTo, "OnNavigateTo", panelName );
  540. MESSAGE_FUNC_CHARPTR( OnNavigateFrom, "OnNavigateFrom", panelName );
  541. // Drag Drop protected/internal interface
  542. protected:
  543. virtual void OnStartDragging();
  544. virtual void OnContinueDragging();
  545. virtual void OnFinishDragging( bool mousereleased, MouseCode code, bool aborted = false );
  546. virtual void DragDropStartDragging();
  547. virtual void GetDragData( CUtlVector< KeyValues * >& list );
  548. virtual void CreateDragData();
  549. virtual void PaintTraverse(bool Repaint, bool allowForce = true);
  550. protected:
  551. virtual void OnChildSettingsApplied( KeyValues *pInResourceData, Panel *pChild );
  552. MESSAGE_FUNC_ENUM_ENUM( OnRequestFocus, "OnRequestFocus", VPANEL, subFocus, VPANEL, defaultPanel);
  553. MESSAGE_FUNC_INT_INT( OnScreenSizeChanged, "OnScreenSizeChanged", oldwide, oldtall );
  554. virtual void *QueryInterface(EInterfaceID id);
  555. void AddToOverridableColors( Color *pColor, char const *scriptname )
  556. {
  557. int iIdx = m_OverridableColorEntries.AddToTail();
  558. m_OverridableColorEntries[iIdx].m_pszScriptName = scriptname;
  559. m_OverridableColorEntries[iIdx].m_pColor = pColor;
  560. m_OverridableColorEntries[iIdx].m_bOverridden = false;
  561. }
  562. void ApplyOverridableColors( void );
  563. void SetOverridableColor( Color *pColor, const Color &newColor );
  564. public:
  565. void SetNavUp( const char* controlName );
  566. void SetNavDown( const char* controlName );
  567. void SetNavLeft( const char* controlName );
  568. void SetNavRight( const char* controlName );
  569. void SetNavToRelay( const char* controlName );
  570. void SetNavActivate( const char* controlName );
  571. void SetNavBack( const char* controlName );
  572. /*
  573. Will recursively look for the next visible panel in the navigation chain, parameters are for internal use.
  574. It will stop looking if first == nextpanel (to prevent infinite looping).
  575. */
  576. Panel* GetNavUp( Panel *first = NULL );
  577. Panel* GetNavDown( Panel *first = NULL );
  578. Panel* GetNavLeft( Panel *first = NULL );
  579. Panel* GetNavRight( Panel *first = NULL );
  580. Panel* GetNavToRelay( Panel *first = NULL );
  581. Panel* GetNavActivate( Panel *first = NULL );
  582. Panel* GetNavBack( Panel *first = NULL );
  583. const char* GetNavUpName( void ) const { return m_sNavUpName.String(); }
  584. const char* GetNavDownName( void ) const { return m_sNavDownName.String(); }
  585. const char* GetNavLeftName( void ) const { return m_sNavLeftName.String(); }
  586. const char* GetNavRightName( void ) const { return m_sNavRightName.String(); }
  587. const char* GetNavToRelayName( void ) const { return m_sNavToRelayName.String(); }
  588. const char* GetNavActivateName( void ) const { return m_sNavActivateName.String(); }
  589. const char* GetNavBackName( void ) const { return m_sNavBackName.String(); }
  590. enum BuildModeFlags_t
  591. {
  592. BUILDMODE_EDITABLE = 1 << 0,
  593. BUILDMODE_DELETABLE = 1 << 1,
  594. BUILDMODE_SAVE_XPOS_RIGHTALIGNED = 1 << 2,
  595. BUILDMODE_SAVE_XPOS_CENTERALIGNED = 1 << 3,
  596. BUILDMODE_SAVE_YPOS_BOTTOMALIGNED = 1 << 4,
  597. BUILDMODE_SAVE_YPOS_CENTERALIGNED = 1 << 5,
  598. BUILDMODE_SAVE_WIDE_FULL = 1 << 6,
  599. BUILDMODE_SAVE_TALL_FULL = 1 << 7,
  600. BUILDMODE_SAVE_PROPORTIONAL_TO_PARENT = 1 << 8,
  601. BUILDMODE_SAVE_WIDE_PROPORTIONAL = 1 << 9,
  602. BUILDMODE_SAVE_TALL_PROPORTIONAL = 1 << 10,
  603. BUILDMODE_SAVE_XPOS_PROPORTIONAL_SELF = 1 << 11,
  604. BUILDMODE_SAVE_YPOS_PROPORTIONAL_SELF = 1 << 12,
  605. BUILDMODE_SAVE_WIDE_PROPORTIONAL_TALL = 1 << 13,
  606. BUILDMODE_SAVE_TALL_PROPORTIONAL_WIDE = 1 << 14,
  607. BUILDMODE_SAVE_XPOS_PROPORTIONAL_PARENT = 1 << 15,
  608. BUILDMODE_SAVE_YPOS_PROPORTIONAL_PARENT = 1 << 16,
  609. BUILDMODE_SAVE_WIDE_PROPORTIONAL_SELF = 1 << 17,
  610. BUILDMODE_SAVE_TALL_PROPORTIONAL_SELF = 1 << 18,
  611. };
  612. protected:
  613. //this will return m_NavDown and will not look for the next visible panel
  614. Panel* GetNavUpPanel();
  615. Panel* GetNavDownPanel();
  616. Panel* GetNavLeftPanel();
  617. Panel* GetNavRightPanel();
  618. Panel* GetNavToRelayPanel();
  619. Panel* GetNavActivatePanel();
  620. Panel* GetNavBackPanel();
  621. bool m_PassUnhandledInput;
  622. NAV_DIRECTION m_LastNavDirection;
  623. private:
  624. enum PanelFlags_t
  625. {
  626. MARKED_FOR_DELETION = 0x0001,
  627. NEEDS_REPAINT = 0x0002,
  628. PAINT_BORDER_ENABLED = 0x0004,
  629. PAINT_BACKGROUND_ENABLED = 0x0008,
  630. PAINT_ENABLED = 0x0010,
  631. POST_CHILD_PAINT_ENABLED = 0x0020,
  632. AUTODELETE_ENABLED = 0x0040,
  633. NEEDS_LAYOUT = 0x0080,
  634. NEEDS_SCHEME_UPDATE = 0x0100,
  635. NEEDS_DEFAULT_SETTINGS_APPLIED = 0x0200,
  636. #if defined( VGUI_USEKEYBINDINGMAPS )
  637. ALLOW_CHAIN_KEYBINDING_TO_PARENT = 0x0400,
  638. #endif
  639. IN_PERFORM_LAYOUT = 0x0800,
  640. IS_PROPORTIONAL = 0x1000,
  641. TRIPLE_PRESS_ALLOWED = 0x2000,
  642. DRAG_REQUIRES_PANEL_EXIT = 0x4000,
  643. IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY = 0x8000,
  644. ALL_FLAGS = 0xFFFF,
  645. };
  646. // used to get the Panel * for users with only IClientPanel
  647. virtual Panel *GetPanel() { return this; }
  648. // private methods
  649. void Think();
  650. void PerformApplySchemeSettings();
  651. void InternalPerformLayout();
  652. void InternalSetCursor();
  653. MESSAGE_FUNC_INT_INT( InternalCursorMoved, "CursorMoved", xpos, ypos );
  654. MESSAGE_FUNC( InternalCursorEntered, "CursorEntered" );
  655. MESSAGE_FUNC( InternalCursorExited, "CursorExited" );
  656. MESSAGE_FUNC_INT( InternalMousePressed, "MousePressed", code );
  657. MESSAGE_FUNC_INT( InternalMouseDoublePressed, "MouseDoublePressed", code );
  658. // Triple presses are synthesized
  659. MESSAGE_FUNC_INT( InternalMouseTriplePressed, "MouseTriplePressed", code );
  660. MESSAGE_FUNC_INT( InternalMouseReleased, "MouseReleased", code );
  661. MESSAGE_FUNC_INT( InternalMouseWheeled, "MouseWheeled", delta );
  662. MESSAGE_FUNC_INT( InternalKeyCodePressed, "KeyCodePressed", code );
  663. MESSAGE_FUNC_INT( InternalKeyCodeTyped, "KeyCodeTyped", code );
  664. MESSAGE_FUNC_INT( InternalKeyTyped, "KeyTyped", unichar );
  665. MESSAGE_FUNC_INT( InternalKeyCodeReleased, "KeyCodeReleased", code );
  666. MESSAGE_FUNC( InternalKeyFocusTicked, "KeyFocusTicked" );
  667. MESSAGE_FUNC( InternalMouseFocusTicked, "MouseFocusTicked" );
  668. MESSAGE_FUNC( InternalInvalidateLayout, "Invalidate" );
  669. MESSAGE_FUNC( InternalMove, "Move" );
  670. virtual void InternalFocusChanged(bool lost); // called when the focus gets changed
  671. void PreparePanelMap( PanelMap_t *panelMap );
  672. bool InternalRequestInfo( PanelAnimationMap *map, KeyValues *outputData );
  673. bool InternalSetInfo( PanelAnimationMap *map, KeyValues *inputData );
  674. PanelAnimationMapEntry *FindPanelAnimationEntry( char const *scriptname, PanelAnimationMap *map );
  675. // Recursively invoke settings for PanelAnimationVars
  676. void InternalApplySettings( PanelAnimationMap *map, KeyValues *inResourceData);
  677. void InternalInitDefaultValues( PanelAnimationMap *map );
  678. // Purpose: Loads panel details related to autoresize from the resource info
  679. void ApplyAutoResizeSettings(KeyValues *inResourceData);
  680. void FindDropTargetPanel_R( CUtlVector< VPANEL >& panelList, int x, int y, VPANEL check );
  681. Panel *FindDropTargetPanel();
  682. int GetProportionalScaledValue( int rootTall, int normalizedValue );
  683. #if defined( VGUI_USEDRAGDROP )
  684. DragDrop_t *m_pDragDrop;
  685. Color m_clrDragFrame;
  686. Color m_clrDropFrame;
  687. #endif
  688. BaseTooltip *m_pTooltips;
  689. bool m_bToolTipOverridden;
  690. PHandle m_SkipChild;
  691. long m_lLastDoublePressTime;
  692. HFont m_infoFont;
  693. #if defined( VGUI_USEKEYBINDINGMAPS )
  694. KeyBindingContextHandle_t m_hKeyBindingsContext;
  695. #endif
  696. // data
  697. VPANEL _vpanel; // handle to a vgui panel
  698. char *_panelName; // string name of the panel - only unique within the current context
  699. IBorder *_border;
  700. CUtlFlags< unsigned short > _flags; // see PanelFlags_t
  701. Dar<HPanel> _actionSignalTargetDar; // the panel to direct notify messages to ("Command", "TextChanged", etc.)
  702. CUtlVector<OverridableColorEntry> m_OverridableColorEntries;
  703. Color _fgColor; // foreground color
  704. Color _bgColor; // background color
  705. HBuildGroup _buildGroup;
  706. short m_nPinDeltaX; // Relative position of the pinned corner to the edge
  707. short m_nPinDeltaY;
  708. short m_nResizeDeltaX; // Relative position of the non-pinned corner to the edge
  709. short m_nResizeDeltaY;
  710. HCursor _cursor;
  711. unsigned int _buildModeFlags; // flags that control how the build mode dialog handles this panel
  712. byte _pinCorner : 4; // the corner of the dialog this panel is pinned to
  713. byte _autoResizeDirection : 4; // the directions in which the panel will auto-resize to
  714. unsigned char _tabPosition; // the panel's place in the tab ordering
  715. HScheme m_iScheme; // handle to the scheme to use
  716. bool m_bIsDMXSerialized : 1; // Is this a DMX panel?
  717. bool m_bUseSchemeColors : 1; // Should we use colors from the scheme?
  718. bool m_bIsSilent : 1; // should this panel PostActionSignals?
  719. bool m_bIsConsoleStylePanel : 1;
  720. bool m_bParentNeedsCursorMoveEvents : 1;
  721. // Sibling pinning
  722. char *_pinToSibling; // string name of the sibling panel we're pinned to
  723. byte _pinToSiblingCorner; // the corner of the sibling panel we're pinned to
  724. byte _pinCornerToSibling; // the corner of our panel that we're pinning to our sibling
  725. PHandle m_pinSibling;
  726. CUtlString m_sNavUpName;
  727. PHandle m_NavUp;
  728. CUtlString m_sNavDownName;
  729. PHandle m_NavDown;
  730. CUtlString m_sNavLeftName;
  731. PHandle m_NavLeft;
  732. CUtlString m_sNavRightName;
  733. PHandle m_NavRight;
  734. CUtlString m_sNavToRelayName;
  735. PHandle m_NavToRelay;
  736. CUtlString m_sNavActivateName;
  737. PHandle m_NavActivate;
  738. CUtlString m_sNavBackName;
  739. PHandle m_NavBack;
  740. private:
  741. char *_tooltipText; // Tool tip text for panels that share tooltip panels with other panels
  742. PHandle m_hMouseEventHandler;
  743. bool m_bWorldPositionCurrentFrame; // if set, Panel gets PerformLayout called after the camera and the renderer's m_matrixWorldToScreen has been setup, so panels can be correctly attached to entities in the world
  744. bool m_bForceStereoRenderToFrameBuffer;
  745. static Panel* m_sMousePressedPanels[ ( MOUSE_MIDDLE - MOUSE_LEFT ) + 1 ];
  746. CUtlDict< VPanelHandle > m_dictChidlren;
  747. CPanelAnimationVar( float, m_flAlpha, "alpha", "255" );
  748. // 1 == Textured (TextureId1 only)
  749. // 2 == Rounded Corner Box
  750. CPanelAnimationVar( int, m_nPaintBackgroundType, "PaintBackgroundType", "0" );
  751. CPanelAnimationVarAliasType( int, m_nBgTextureId1, "Texture1", "vgui/hud/800corner1", "textureid" );
  752. CPanelAnimationVarAliasType( int, m_nBgTextureId2, "Texture2", "vgui/hud/800corner2", "textureid" );
  753. CPanelAnimationVarAliasType( int, m_nBgTextureId3, "Texture3", "vgui/hud/800corner3", "textureid" );
  754. CPanelAnimationVarAliasType( int, m_nBgTextureId4, "Texture4", "vgui/hud/800corner4", "textureid" );
  755. //=============================================================================
  756. // HPE_BEGIN:
  757. // [tj] A bitset of flags to determine which corners should be rounded
  758. //=============================================================================
  759. unsigned char m_roundedCorners;
  760. //=============================================================================
  761. // HPE_END
  762. //=============================================================================
  763. friend class BuildGroup;
  764. friend class BuildModeDialog;
  765. friend class PHandle;
  766. // obselete, remove soon
  767. void OnOldMessage(KeyValues *params, VPANEL ifromPanel);
  768. };
  769. inline void Panel::DisableMouseInputForThisPanel( bool bDisable )
  770. {
  771. _flags.SetFlag( IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY, bDisable );
  772. }
  773. inline bool Panel::IsMouseInputDisabledForThisPanel() const
  774. {
  775. return _flags.IsFlagSet( IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY );
  776. }
  777. #if 0
  778. // This function cannot be defined here because it requires on a full definition of
  779. // KeyValues (to call KeyValues::MakeCopy()) whereas the rest of this header file
  780. // assumes a forward declared definition of KeyValues.
  781. template< class S >
  782. inline void Panel::PostMessageToAllSiblingsOfType( KeyValues *msg, float delaySeconds /*= 0.0f*/ )
  783. {
  784. Panel *parent = GetParent();
  785. if ( parent )
  786. {
  787. int nChildCount = parent->GetChildCount();
  788. for ( int i = 0; i < nChildCount; ++i )
  789. {
  790. Panel *sibling = parent->GetChild( i );
  791. if ( sibling == this )
  792. continue;
  793. if ( dynamic_cast< S * >( sibling ) )
  794. {
  795. PostMessage( sibling->GetVPanel(), msg->MakeCopy(), delaySeconds );
  796. }
  797. }
  798. }
  799. msg->deleteThis();
  800. }
  801. #endif
  802. class Button;
  803. struct SortedPanel_t
  804. {
  805. SortedPanel_t( Panel *panel );
  806. Panel *pPanel;
  807. Button *pButton;
  808. };
  809. class CSortedPanelYLess
  810. {
  811. public:
  812. bool Less( const SortedPanel_t &src1, const SortedPanel_t &src2, void *pCtx )
  813. {
  814. int nX1, nY1, nX2, nY2;
  815. src1.pPanel->GetPos( nX1, nY1 );
  816. src2.pPanel->GetPos( nX2, nY2 );
  817. if ( nY1 == nY2 )
  818. {
  819. return ( nX1 < nX2 );
  820. }
  821. if ( nY1 < nY2 )
  822. {
  823. return true;
  824. }
  825. return false;
  826. }
  827. };
  828. void VguiPanelGetSortedChildPanelList( Panel *pParentPanel, void *pSortedPanels );
  829. void VguiPanelGetSortedChildButtonList( Panel *pParentPanel, void *pSortedPanels, char *pchFilter = NULL, int nFilterType = 0 );
  830. int VguiPanelNavigateSortedChildButtonList( void *pSortedPanels, int nDir );
  831. int ComputeWide(Panel* pPanel, unsigned int& nBuildFlags, KeyValues *inResourceData, int nParentWide, int nParentTall, bool bComputingForTall);
  832. int ComputeTall(Panel* pPanel, unsigned int& nBuildFlags, KeyValues *inResourceData, int nParentWide, int nParentTall, bool bComputingForWide);
  833. enum EOperator
  834. {
  835. OP_ADD,
  836. OP_SUB,
  837. OP_SET,
  838. };
  839. int ComputePos( Panel* pPanel, const char *pszInput, int &nPos, const int& nSize, const int& nParentSize, const bool& bX, EOperator eOp );
  840. } // namespace vgui
  841. #endif // PANEL_H