diff options
Diffstat (limited to 'mp/src/public/vgui_controls')
81 files changed, 11800 insertions, 11800 deletions
diff --git a/mp/src/public/vgui_controls/AnalogBar.h b/mp/src/public/vgui_controls/AnalogBar.h index a5f68fbb..d6d696e0 100644 --- a/mp/src/public/vgui_controls/AnalogBar.h +++ b/mp/src/public/vgui_controls/AnalogBar.h @@ -1,109 +1,109 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef ANALOGBAR_H
-#define ANALOGBAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Status bar that visually displays discrete analogValue in the form
-// of a segmented strip
-//-----------------------------------------------------------------------------
-class AnalogBar : public Panel
-{
- DECLARE_CLASS_SIMPLE( AnalogBar, Panel );
-
-public:
- AnalogBar(Panel *parent, const char *panelName);
- ~AnalogBar();
-
- // 'analogValue' is in the range [0.0f, 1.0f]
- MESSAGE_FUNC_FLOAT( SetAnalogValue, "SetAnalogValue", analogValue );
- float GetAnalogValue();
- virtual void SetSegmentInfo( int gap, int width );
-
- // utility function for calculating a time remaining string
- static bool ConstructTimeRemainingString(OUT_Z_BYTECAP(outputBufferSizeInBytes) wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentAnalogValue, float lastAnalogValueUpdateTime, bool addRemainingSuffix);
-
- void SetBarInset( int pixels );
- int GetBarInset( void );
-
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void GetSettings(KeyValues *outResourceData);
- virtual const char *GetDescription();
-
- // returns the number of segment blocks drawn
- int GetDrawnSegmentCount();
- int GetTotalSegmentCount();
-
- enum AnalogValueDir_e
- {
- PROGRESS_EAST,
- PROGRESS_WEST,
- PROGRESS_NORTH,
- PROGRESS_SOUTH
- };
-
- int GetAnalogValueDirection() const { return m_iAnalogValueDirection; }
- void SetAnalogValueDirection( int val ) { m_iAnalogValueDirection = val; }
-
- void SetHomeValue( float val ) { m_fHomeValue = val; }
-
- const Color& GetHomeColor( void ) { return m_HomeColor; }
- void SetHomeColor( const Color &color ) { m_HomeColor = color; }
-
-protected:
- virtual void Paint();
- void PaintSegment( int &x, int &y, int tall, int wide, Color color, bool bHome );
- virtual void PaintBackground();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
- /* CUSTOM MESSAGE HANDLING
- "SetAnalogValue"
- input: "analogValue" - float value of the analogValue to set
- */
-
-protected:
- int m_iAnalogValueDirection;
- float _analogValue;
-
-private:
- int _segmentCount;
- int _segmentGap;
- int _segmentWide;
- int m_iBarInset;
- char *m_pszDialogVar;
-
- float m_fHomeValue;
- Color m_HomeColor;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Non-segmented analogValue bar
-//-----------------------------------------------------------------------------
-class ContinuousAnalogBar : public AnalogBar
-{
- DECLARE_CLASS_SIMPLE( ContinuousAnalogBar, AnalogBar );
-
-public:
- ContinuousAnalogBar(Panel *parent, const char *panelName);
-
- virtual void Paint();
-};
-
-} // namespace vgui
-
-#endif // ANALOGBAR_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef ANALOGBAR_H +#define ANALOGBAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Status bar that visually displays discrete analogValue in the form +// of a segmented strip +//----------------------------------------------------------------------------- +class AnalogBar : public Panel +{ + DECLARE_CLASS_SIMPLE( AnalogBar, Panel ); + +public: + AnalogBar(Panel *parent, const char *panelName); + ~AnalogBar(); + + // 'analogValue' is in the range [0.0f, 1.0f] + MESSAGE_FUNC_FLOAT( SetAnalogValue, "SetAnalogValue", analogValue ); + float GetAnalogValue(); + virtual void SetSegmentInfo( int gap, int width ); + + // utility function for calculating a time remaining string + static bool ConstructTimeRemainingString(OUT_Z_BYTECAP(outputBufferSizeInBytes) wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentAnalogValue, float lastAnalogValueUpdateTime, bool addRemainingSuffix); + + void SetBarInset( int pixels ); + int GetBarInset( void ); + + virtual void ApplySettings(KeyValues *inResourceData); + virtual void GetSettings(KeyValues *outResourceData); + virtual const char *GetDescription(); + + // returns the number of segment blocks drawn + int GetDrawnSegmentCount(); + int GetTotalSegmentCount(); + + enum AnalogValueDir_e + { + PROGRESS_EAST, + PROGRESS_WEST, + PROGRESS_NORTH, + PROGRESS_SOUTH + }; + + int GetAnalogValueDirection() const { return m_iAnalogValueDirection; } + void SetAnalogValueDirection( int val ) { m_iAnalogValueDirection = val; } + + void SetHomeValue( float val ) { m_fHomeValue = val; } + + const Color& GetHomeColor( void ) { return m_HomeColor; } + void SetHomeColor( const Color &color ) { m_HomeColor = color; } + +protected: + virtual void Paint(); + void PaintSegment( int &x, int &y, int tall, int wide, Color color, bool bHome ); + virtual void PaintBackground(); + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables ); + /* CUSTOM MESSAGE HANDLING + "SetAnalogValue" + input: "analogValue" - float value of the analogValue to set + */ + +protected: + int m_iAnalogValueDirection; + float _analogValue; + +private: + int _segmentCount; + int _segmentGap; + int _segmentWide; + int m_iBarInset; + char *m_pszDialogVar; + + float m_fHomeValue; + Color m_HomeColor; +}; + +//----------------------------------------------------------------------------- +// Purpose: Non-segmented analogValue bar +//----------------------------------------------------------------------------- +class ContinuousAnalogBar : public AnalogBar +{ + DECLARE_CLASS_SIMPLE( ContinuousAnalogBar, AnalogBar ); + +public: + ContinuousAnalogBar(Panel *parent, const char *panelName); + + virtual void Paint(); +}; + +} // namespace vgui + +#endif // ANALOGBAR_H diff --git a/mp/src/public/vgui_controls/AnimatingImagePanel.h b/mp/src/public/vgui_controls/AnimatingImagePanel.h index 838d2eb5..a65a5dc3 100644 --- a/mp/src/public/vgui_controls/AnimatingImagePanel.h +++ b/mp/src/public/vgui_controls/AnimatingImagePanel.h @@ -1,66 +1,66 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef ANIMATINGIMAGEPANEL_H
-#define ANIMATINGIMAGEPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utlvector.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Animating image
-//-----------------------------------------------------------------------------
-class AnimatingImagePanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( AnimatingImagePanel, Panel );
-
-public:
- AnimatingImagePanel(Panel *parent, const char *name);
-
- // Add an image to the end of the list of animations
- // image - pointer to the image to add to the end of the list
- virtual void AddImage(IImage *image);
-
- // Load a set of animations by name.
- // baseName - The name of the animations without their frame number or file extension, (e.g. c1.tga becomes just c.)
- // framecount: number of frames in the animation
- virtual void LoadAnimation(const char *baseName, int frameCount);
-
- virtual void StartAnimation();
- virtual void StopAnimation();
- virtual void ResetAnimation(int frame = 0);
-
-protected:
- virtual void OnTick();
- virtual void PerformLayout();
- virtual void PaintBackground();
-
- virtual void GetSettings(KeyValues *outResourceData);
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual const char *GetDescription();
-
-private:
- int m_iCurrentImage;
- int m_iNextFrameTime;
- int m_iFrameTimeMillis;
- CUtlVector<IImage *> m_Frames;
- char *m_pImageName;
- bool m_bAnimating;
- bool m_bFiltered;
- bool m_bScaleImage;
-};
-
-}; // namespace vgui
-
-#endif // ANIMATINGIMAGEPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef ANIMATINGIMAGEPANEL_H +#define ANIMATINGIMAGEPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utlvector.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Animating image +//----------------------------------------------------------------------------- +class AnimatingImagePanel : public Panel +{ + DECLARE_CLASS_SIMPLE( AnimatingImagePanel, Panel ); + +public: + AnimatingImagePanel(Panel *parent, const char *name); + + // Add an image to the end of the list of animations + // image - pointer to the image to add to the end of the list + virtual void AddImage(IImage *image); + + // Load a set of animations by name. + // baseName - The name of the animations without their frame number or file extension, (e.g. c1.tga becomes just c.) + // framecount: number of frames in the animation + virtual void LoadAnimation(const char *baseName, int frameCount); + + virtual void StartAnimation(); + virtual void StopAnimation(); + virtual void ResetAnimation(int frame = 0); + +protected: + virtual void OnTick(); + virtual void PerformLayout(); + virtual void PaintBackground(); + + virtual void GetSettings(KeyValues *outResourceData); + virtual void ApplySettings(KeyValues *inResourceData); + virtual const char *GetDescription(); + +private: + int m_iCurrentImage; + int m_iNextFrameTime; + int m_iFrameTimeMillis; + CUtlVector<IImage *> m_Frames; + char *m_pImageName; + bool m_bAnimating; + bool m_bFiltered; + bool m_bScaleImage; +}; + +}; // namespace vgui + +#endif // ANIMATINGIMAGEPANEL_H diff --git a/mp/src/public/vgui_controls/AnimationController.h b/mp/src/public/vgui_controls/AnimationController.h index 101debf4..e418f329 100644 --- a/mp/src/public/vgui_controls/AnimationController.h +++ b/mp/src/public/vgui_controls/AnimationController.h @@ -1,270 +1,270 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef ANIMATIONCONTROLLER_H
-#define ANIMATIONCONTROLLER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/PHandle.h>
-
-#include "tier1/utlsymbol.h"
-#include "tier1/utlvector.h"
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Handles controlling panel animation
-// It is never visible, but needs to be a panel so that can receive messages
-//-----------------------------------------------------------------------------
-class AnimationController : public Panel
-{
- DECLARE_CLASS_SIMPLE( AnimationController, Panel );
-
-public:
- AnimationController(Panel *parent);
- ~AnimationController();
-
- // sets which script file to use
- bool SetScriptFile( VPANEL sizingPanel, const char *fileName, bool wipeAll = false );
-
- // reloads the currently set script file
- void ReloadScriptFile();
-
- // runs a frame of animation (time is passed in so slow motion, etc. works)
- void UpdateAnimations( float curtime );
-
- int GetNumActiveAnimations( void ) { return m_ActiveAnimations.Count(); }
-
- // plays all animations to completion instantly
- void RunAllAnimationsToCompletion();
-
- // stops all animations
- void CancelAllAnimations();
-
- // starts an animation sequence script
- bool StartAnimationSequence(const char *sequenceName);
- bool StartAnimationSequence(Panel *pWithinParent, const char *sequenceName);
-
- // gets the length of an animation sequence, in seconds
- float GetAnimationSequenceLength(const char *sequenceName);
-
- // sets that the script file should be reloaded each time a script is ran
- // used for development
- void SetAutoReloadScript(bool state);
-
- enum Interpolators_e
- {
- INTERPOLATOR_LINEAR,
- INTERPOLATOR_ACCEL,
- INTERPOLATOR_DEACCEL,
- INTERPOLATOR_PULSE,
- INTERPOLATOR_FLICKER,
- INTERPOLATOR_SIMPLESPLINE, // ease in / out
- INTERPOLATOR_BOUNCE, // gravitational bounce
- };
-
- // runs the specific animation command (doesn't use script file at all)
- void RunAnimationCommand(vgui::Panel *panel, const char *variable, float targetValue, float startDelaySeconds, float durationSeconds, Interpolators_e interpolator, float animParameter = 0 );
- void RunAnimationCommand(vgui::Panel *panel, const char *variable, Color targetValue, float startDelaySeconds, float durationSeconds, Interpolators_e interpolator, float animParameter = 0 );
-
-private:
- bool UpdateScreenSize();
-
- bool LoadScriptFile(const char *fileName);
- bool ParseScriptFile(char *pMem, int length);
-
- void UpdatePostedMessages(bool bRunToCompletion);
- void UpdateActiveAnimations(bool bRunToCompletion);
-
- bool m_bAutoReloadScript;
- float m_flCurrentTime;
-
- enum AnimCommandType_e
- {
- CMD_ANIMATE,
- CMD_RUNEVENT,
- CMD_STOPEVENT,
- CMD_STOPANIMATION,
- CMD_STOPPANELANIMATIONS,
- CMD_SETFONT,
- CMD_SETTEXTURE,
- CMD_SETSTRING,
- };
-
- enum RelativeAlignment
- {
- a_northwest = 0,
- a_north,
- a_northeast,
- a_west,
- a_center,
- a_east,
- a_southwest,
- a_south,
- a_southeast,
- };
-
- struct RelativeAlignmentLookup
- {
- RelativeAlignment align;
- char const *name;
- };
-
- // a single animatable value
- // some var types use 1, 2, 3 or all 4 of the values
- struct Value_t
- {
- float a, b, c, d;
- };
-
- struct AnimAlign_t
- {
- // For Position, Xpos, YPos
- bool relativePosition;
- UtlSymId_t alignPanel;
- RelativeAlignment alignment;
- };
-
- // info for the animate command
- struct AnimCmdAnimate_t
- {
- UtlSymId_t panel;
- UtlSymId_t variable;
- Value_t target;
- int interpolationFunction;
- float interpolationParameter;
- float startTime;
- float duration;
-
- AnimAlign_t align;
-
- };
-
- // info for the run event command
- struct AnimCmdEvent_t
- {
- UtlSymId_t event;
- UtlSymId_t variable;
- UtlSymId_t variable2;
- float timeDelay;
- };
-
- // holds a single command from an animation sequence
- struct AnimCommand_t
- {
- AnimCommandType_e commandType;
- union
- {
- AnimCmdAnimate_t animate;
- AnimCmdEvent_t runEvent;
- } cmdData;
- };
-
- // holds a full sequence
- struct AnimSequence_t
- {
- UtlSymId_t name;
- float duration;
- CUtlVector<AnimCommand_t> cmdList;
- };
-
- // holds the list of sequences
- CUtlVector<AnimSequence_t> m_Sequences;
-
- // list of active animations
- struct ActiveAnimation_t
- {
- PHandle panel;
- UtlSymId_t seqName; // the sequence this belongs to
- UtlSymId_t variable;
- bool started;
- Value_t startValue;
- Value_t endValue;
- int interpolator;
- float interpolatorParam;
- float startTime;
- float endTime;
-
- AnimAlign_t align;
- };
- CUtlVector<ActiveAnimation_t> m_ActiveAnimations;
-
- // posted messages
- struct PostedMessage_t
- {
- AnimCommandType_e commandType;
- UtlSymId_t seqName;
- UtlSymId_t event;
- UtlSymId_t variable;
- UtlSymId_t variable2;
- float startTime;
- PHandle parent;
- };
- CUtlVector<PostedMessage_t> m_PostedMessages;
-
- struct RanEvent_t
- {
- UtlSymId_t event;
- Panel *pParent;
-
- bool operator==( const RanEvent_t &other ) const
- {
- return ( event == other.event && pParent == other.pParent );
- }
- };
-
- // variable names
- UtlSymId_t m_sPosition, m_sSize, m_sFgColor, m_sBgColor;
- UtlSymId_t m_sXPos, m_sYPos, m_sWide, m_sTall;
-
- // file name
- CUtlVector<UtlSymId_t> m_ScriptFileNames;
-
- // runs a single line of the script
- void ExecAnimationCommand(UtlSymId_t seqName, AnimCommand_t &animCommand, Panel *pWithinParent);
- // removes all commands belonging to a script
- void RemoveQueuedAnimationCommands(UtlSymId_t seqName, vgui::Panel *panel = NULL);
- // removes an existing instance of a command
- void RemoveQueuedAnimationByType(vgui::Panel *panel, UtlSymId_t variable, UtlSymId_t sequenceToIgnore);
-
- // handlers
- void StartCmd_Animate(UtlSymId_t seqName, AnimCmdAnimate_t &cmd, Panel *pWithinParent);
- void StartCmd_Animate(Panel *panel, UtlSymId_t seqName, AnimCmdAnimate_t &cmd);
- void RunCmd_RunEvent(PostedMessage_t &msg);
- void RunCmd_StopEvent(PostedMessage_t &msg);
- void RunCmd_StopPanelAnimations(PostedMessage_t &msg);
- void RunCmd_StopAnimation(PostedMessage_t &msg);
- void RunCmd_SetFont(PostedMessage_t &msg);
- void RunCmd_SetTexture(PostedMessage_t &msg);
- void RunCmd_SetString(PostedMessage_t &msg);
-
- // value access
- Value_t GetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var);
- void SetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var, Value_t &value);
-
- // interpolation
- Value_t GetInterpolatedValue(int interpolator, float interpolatorParam, float currentTime, float startTime, float endTime, Value_t &startValue, Value_t &endValue);
-
- void SetupPosition( AnimCmdAnimate_t& cmd, float *output, char const *psz, int screendimension );
- static RelativeAlignment LookupAlignment( char const *token );
- static RelativeAlignmentLookup g_AlignmentLookup[];
-
- int GetRelativeOffset( AnimAlign_t& cmd, bool xcoord );
-
- VPANEL m_hSizePanel;
- int m_nScreenBounds[ 4 ];
-};
-
-// singleton accessor for use only by other vgui_controls
-extern AnimationController *GetAnimationController();
-
-} // namespace vgui
-
-#endif // ANIMATIONCONTROLLER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef ANIMATIONCONTROLLER_H +#define ANIMATIONCONTROLLER_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> +#include <vgui_controls/PHandle.h> + +#include "tier1/utlsymbol.h" +#include "tier1/utlvector.h" + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Handles controlling panel animation +// It is never visible, but needs to be a panel so that can receive messages +//----------------------------------------------------------------------------- +class AnimationController : public Panel +{ + DECLARE_CLASS_SIMPLE( AnimationController, Panel ); + +public: + AnimationController(Panel *parent); + ~AnimationController(); + + // sets which script file to use + bool SetScriptFile( VPANEL sizingPanel, const char *fileName, bool wipeAll = false ); + + // reloads the currently set script file + void ReloadScriptFile(); + + // runs a frame of animation (time is passed in so slow motion, etc. works) + void UpdateAnimations( float curtime ); + + int GetNumActiveAnimations( void ) { return m_ActiveAnimations.Count(); } + + // plays all animations to completion instantly + void RunAllAnimationsToCompletion(); + + // stops all animations + void CancelAllAnimations(); + + // starts an animation sequence script + bool StartAnimationSequence(const char *sequenceName); + bool StartAnimationSequence(Panel *pWithinParent, const char *sequenceName); + + // gets the length of an animation sequence, in seconds + float GetAnimationSequenceLength(const char *sequenceName); + + // sets that the script file should be reloaded each time a script is ran + // used for development + void SetAutoReloadScript(bool state); + + enum Interpolators_e + { + INTERPOLATOR_LINEAR, + INTERPOLATOR_ACCEL, + INTERPOLATOR_DEACCEL, + INTERPOLATOR_PULSE, + INTERPOLATOR_FLICKER, + INTERPOLATOR_SIMPLESPLINE, // ease in / out + INTERPOLATOR_BOUNCE, // gravitational bounce + }; + + // runs the specific animation command (doesn't use script file at all) + void RunAnimationCommand(vgui::Panel *panel, const char *variable, float targetValue, float startDelaySeconds, float durationSeconds, Interpolators_e interpolator, float animParameter = 0 ); + void RunAnimationCommand(vgui::Panel *panel, const char *variable, Color targetValue, float startDelaySeconds, float durationSeconds, Interpolators_e interpolator, float animParameter = 0 ); + +private: + bool UpdateScreenSize(); + + bool LoadScriptFile(const char *fileName); + bool ParseScriptFile(char *pMem, int length); + + void UpdatePostedMessages(bool bRunToCompletion); + void UpdateActiveAnimations(bool bRunToCompletion); + + bool m_bAutoReloadScript; + float m_flCurrentTime; + + enum AnimCommandType_e + { + CMD_ANIMATE, + CMD_RUNEVENT, + CMD_STOPEVENT, + CMD_STOPANIMATION, + CMD_STOPPANELANIMATIONS, + CMD_SETFONT, + CMD_SETTEXTURE, + CMD_SETSTRING, + }; + + enum RelativeAlignment + { + a_northwest = 0, + a_north, + a_northeast, + a_west, + a_center, + a_east, + a_southwest, + a_south, + a_southeast, + }; + + struct RelativeAlignmentLookup + { + RelativeAlignment align; + char const *name; + }; + + // a single animatable value + // some var types use 1, 2, 3 or all 4 of the values + struct Value_t + { + float a, b, c, d; + }; + + struct AnimAlign_t + { + // For Position, Xpos, YPos + bool relativePosition; + UtlSymId_t alignPanel; + RelativeAlignment alignment; + }; + + // info for the animate command + struct AnimCmdAnimate_t + { + UtlSymId_t panel; + UtlSymId_t variable; + Value_t target; + int interpolationFunction; + float interpolationParameter; + float startTime; + float duration; + + AnimAlign_t align; + + }; + + // info for the run event command + struct AnimCmdEvent_t + { + UtlSymId_t event; + UtlSymId_t variable; + UtlSymId_t variable2; + float timeDelay; + }; + + // holds a single command from an animation sequence + struct AnimCommand_t + { + AnimCommandType_e commandType; + union + { + AnimCmdAnimate_t animate; + AnimCmdEvent_t runEvent; + } cmdData; + }; + + // holds a full sequence + struct AnimSequence_t + { + UtlSymId_t name; + float duration; + CUtlVector<AnimCommand_t> cmdList; + }; + + // holds the list of sequences + CUtlVector<AnimSequence_t> m_Sequences; + + // list of active animations + struct ActiveAnimation_t + { + PHandle panel; + UtlSymId_t seqName; // the sequence this belongs to + UtlSymId_t variable; + bool started; + Value_t startValue; + Value_t endValue; + int interpolator; + float interpolatorParam; + float startTime; + float endTime; + + AnimAlign_t align; + }; + CUtlVector<ActiveAnimation_t> m_ActiveAnimations; + + // posted messages + struct PostedMessage_t + { + AnimCommandType_e commandType; + UtlSymId_t seqName; + UtlSymId_t event; + UtlSymId_t variable; + UtlSymId_t variable2; + float startTime; + PHandle parent; + }; + CUtlVector<PostedMessage_t> m_PostedMessages; + + struct RanEvent_t + { + UtlSymId_t event; + Panel *pParent; + + bool operator==( const RanEvent_t &other ) const + { + return ( event == other.event && pParent == other.pParent ); + } + }; + + // variable names + UtlSymId_t m_sPosition, m_sSize, m_sFgColor, m_sBgColor; + UtlSymId_t m_sXPos, m_sYPos, m_sWide, m_sTall; + + // file name + CUtlVector<UtlSymId_t> m_ScriptFileNames; + + // runs a single line of the script + void ExecAnimationCommand(UtlSymId_t seqName, AnimCommand_t &animCommand, Panel *pWithinParent); + // removes all commands belonging to a script + void RemoveQueuedAnimationCommands(UtlSymId_t seqName, vgui::Panel *panel = NULL); + // removes an existing instance of a command + void RemoveQueuedAnimationByType(vgui::Panel *panel, UtlSymId_t variable, UtlSymId_t sequenceToIgnore); + + // handlers + void StartCmd_Animate(UtlSymId_t seqName, AnimCmdAnimate_t &cmd, Panel *pWithinParent); + void StartCmd_Animate(Panel *panel, UtlSymId_t seqName, AnimCmdAnimate_t &cmd); + void RunCmd_RunEvent(PostedMessage_t &msg); + void RunCmd_StopEvent(PostedMessage_t &msg); + void RunCmd_StopPanelAnimations(PostedMessage_t &msg); + void RunCmd_StopAnimation(PostedMessage_t &msg); + void RunCmd_SetFont(PostedMessage_t &msg); + void RunCmd_SetTexture(PostedMessage_t &msg); + void RunCmd_SetString(PostedMessage_t &msg); + + // value access + Value_t GetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var); + void SetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var, Value_t &value); + + // interpolation + Value_t GetInterpolatedValue(int interpolator, float interpolatorParam, float currentTime, float startTime, float endTime, Value_t &startValue, Value_t &endValue); + + void SetupPosition( AnimCmdAnimate_t& cmd, float *output, char const *psz, int screendimension ); + static RelativeAlignment LookupAlignment( char const *token ); + static RelativeAlignmentLookup g_AlignmentLookup[]; + + int GetRelativeOffset( AnimAlign_t& cmd, bool xcoord ); + + VPANEL m_hSizePanel; + int m_nScreenBounds[ 4 ]; +}; + +// singleton accessor for use only by other vgui_controls +extern AnimationController *GetAnimationController(); + +} // namespace vgui + +#endif // ANIMATIONCONTROLLER_H diff --git a/mp/src/public/vgui_controls/BitmapImagePanel.h b/mp/src/public/vgui_controls/BitmapImagePanel.h index 95c1286d..639ffb67 100644 --- a/mp/src/public/vgui_controls/BitmapImagePanel.h +++ b/mp/src/public/vgui_controls/BitmapImagePanel.h @@ -1,57 +1,57 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef BITMAPIMAGEPANEL_H
-#define BITMAPIMAGEPANEL_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Label.h>
-
-namespace vgui {
-
-class CBitmapImagePanel : public vgui::Panel
-{
-public:
- CBitmapImagePanel( vgui::Panel *parent, char const *panelName, char const *filename = NULL );
- ~CBitmapImagePanel();
-
- virtual void PaintBackground();
-
- virtual void setTexture( char const *filename, bool hardwareFiltered = true );
-
- void setImageColor( Color color ) { m_bgColor = color; }
-
- // Set how the image aligns itself within the panel
- virtual void SetContentAlignment(Label::Alignment alignment);
-
-protected:
- virtual void GetSettings(KeyValues *outResourceData);
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual const char *GetDescription();
- virtual void ApplySchemeSettings( IScheme *pScheme );
- virtual void PaintBorder();
-
-private:
- typedef vgui::Panel BaseClass;
-
- virtual void ComputeImagePosition(int &x, int &y, int &w, int &h);
- Label::Alignment m_contentAlignment;
-
- bool m_preserveAspectRatio;
- bool m_hardwareFiltered;
-
- IImage *m_pImage;
- Color m_bgColor;
- char *m_pszImageName;
- char *m_pszColorName;
-};
-
-};
-
-#endif // BITMAPIMAGEPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef BITMAPIMAGEPANEL_H +#define BITMAPIMAGEPANEL_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Label.h> + +namespace vgui { + +class CBitmapImagePanel : public vgui::Panel +{ +public: + CBitmapImagePanel( vgui::Panel *parent, char const *panelName, char const *filename = NULL ); + ~CBitmapImagePanel(); + + virtual void PaintBackground(); + + virtual void setTexture( char const *filename, bool hardwareFiltered = true ); + + void setImageColor( Color color ) { m_bgColor = color; } + + // Set how the image aligns itself within the panel + virtual void SetContentAlignment(Label::Alignment alignment); + +protected: + virtual void GetSettings(KeyValues *outResourceData); + virtual void ApplySettings(KeyValues *inResourceData); + virtual const char *GetDescription(); + virtual void ApplySchemeSettings( IScheme *pScheme ); + virtual void PaintBorder(); + +private: + typedef vgui::Panel BaseClass; + + virtual void ComputeImagePosition(int &x, int &y, int &w, int &h); + Label::Alignment m_contentAlignment; + + bool m_preserveAspectRatio; + bool m_hardwareFiltered; + + IImage *m_pImage; + Color m_bgColor; + char *m_pszImageName; + char *m_pszColorName; +}; + +}; + +#endif // BITMAPIMAGEPANEL_H diff --git a/mp/src/public/vgui_controls/BuildGroup.h b/mp/src/public/vgui_controls/BuildGroup.h index 635907bb..e95bca60 100644 --- a/mp/src/public/vgui_controls/BuildGroup.h +++ b/mp/src/public/vgui_controls/BuildGroup.h @@ -1,184 +1,184 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef VGUI_BUILDGROUP_H
-#define VGUI_BUILDGROUP_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier1/utlvector.h"
-#include "tier1/utlsymbol.h"
-#include <vgui/VGUI.h>
-#include <vgui/Dar.h>
-#include <vgui/Cursor.h>
-#include <vgui/IScheme.h>
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/PHandle.h>
-#include "tier1/utlhandletable.h"
-
-class KeyValues;
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: a BuildGroup is a list of panels contained in a window (the contextPanel)
-// Members of this group are viewable and editable in Build Mode, via the BuildModeDialog wizard
-//-----------------------------------------------------------------------------
-class BuildGroup
-{
- DECLARE_HANDLES( BuildGroup, 20 );
-
-public:
- BuildGroup(Panel *parentPanel, Panel *contextPanel);
- ~BuildGroup();
-
- // Toggle build mode on/off
- virtual void SetEnabled(bool state);
-
- // Check if buildgroup is enabled
- virtual bool IsEnabled();
-
- // Return the currently selected panel
- virtual Panel *GetCurrentPanel();
-
- // Load the control settings from file
- virtual void LoadControlSettings(const char *controlResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL);
-
- // Reload the control settings from file
- void ReloadControlSettings();
-
- // changes which control settings are currently loaded
- void ChangeControlSettingsFile(const char *controlResourceName);
-
- // Save control settings from file, using the same resource
- // name as what LoadControlSettings() was called with
- virtual bool SaveControlSettings();
-
- // Serialize settings from a resource data container
- virtual void ApplySettings(KeyValues *resourceData);
-
- // Serialize settings to a resource data container
- virtual void GetSettings(KeyValues *resourceData);
-
- // Remove all objects in the current control group
- virtual void RemoveSettings();
-
- // Get a new unique fieldname for a new control
- void GetNewFieldName(char *newFieldName, int newFieldNameSize, Panel *newPanel);
-
- // Check if a control name is already taken
- Panel *FieldNameTaken(const char *fieldName);
-
- // Add a new control (via the BuildModeDialog)
- Panel *NewControl( KeyValues *controlKeys, int x=0, int y=0);
- Panel *NewControl( const char *name, int x=0, int y=0);
-
- // Set the panel from which the build group gets all it's object creation information
- virtual void SetContextPanel(Panel *contextPanel);
-
- //Get the panel that build group is pointed at.
- virtual Panel *GetContextPanel();
-
- // Get the list of panels in the buildgroup
- CUtlVector<PHandle> *GetPanelList();
-
- // Get the resource file name used
- virtual const char *GetResourceName(void) { return m_pResourceName; }
-
- virtual void PanelAdded(Panel* panel);
-
- virtual bool MousePressed(MouseCode code,Panel* panel);
- virtual bool MouseReleased(MouseCode code,Panel* panel);
-
- // Get the list of panels that are currently selected
- virtual CUtlVector<PHandle> *GetControlGroup();
-
- // Toggle ruler display on/off
- virtual void ToggleRulerDisplay();
-
- // Toggle visibility of ruler number labels
- virtual void SetRulerLabelsVisible(bool state);
-
- // Check if ruler display is activated
- virtual bool HasRulersOn();
-
- // Draw Rulers on screen
- virtual void DrawRulers();
-
- // registers that a control settings file may be loaded
- // use when the dialog may have multiple states and the editor will need to be able to switch between them
- void RegisterControlSettingsFile(const char *controlResourceName, const char *pathID = NULL);
-
- // iterator for registered files
- int GetRegisteredControlSettingsFileCount();
- const char *GetRegisteredControlSettingsFileByIndex(int index);
-
- // dialog variables
- KeyValues *GetDialogVariables();
-
- // conditional keys for selectively reading keyvalues
- void ProcessConditionalKeys( KeyValues *pDat, KeyValues *pConditions );
-
-protected:
- virtual bool CursorMoved(int x, int y, Panel *panel);
- virtual bool MouseDoublePressed(MouseCode code, Panel *panel);
- virtual bool KeyCodeTyped(KeyCode code, Panel *panel);
- virtual bool KeyCodeReleased(KeyCode code, Panel *panel );
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual bool KeyTyped( wchar_t unichar, Panel *panel );
-
- virtual HCursor GetCursor(Panel *panel);
-
-private:
- void ApplySnap(Panel* panel);
- Panel *CreateBuildDialog();
- void ActivateBuildDialog();
- void DeleteAllControlsCreatedByControlSettingsFile();
-
- bool _enabled;
- int _snapX;
- int _snapY;
- HCursor _cursor_sizenwse;
- HCursor _cursor_sizenesw;
- HCursor _cursor_sizewe;
- HCursor _cursor_sizens;
- HCursor _cursor_sizeall;
- bool _dragging;
- MouseCode _dragMouseCode;
- int _dragStartPanelPos[2];
- int _dragStartCursorPos[2];
- int _dragStartPanelSize[ 2 ];
- Panel * _currentPanel;
- CUtlVector<PHandle> _panelDar;
- char *m_pResourceName;
- char *m_pResourcePathID;
- PHandle m_hBuildDialog;
- Panel *m_pBuildContext; // the panel from which the build dialog gets all the information it needs
- Panel *m_pParentPanel; // panel to create new controls in
- CUtlVector<PHandle> _controlGroup; // grouped panels
- CUtlVector<int> _groupDeltaX; // x offsets of panels in group from the selected panel
- CUtlVector<int> _groupDeltaY; // y offsets of panels in group from the selected panel
- Label *_rulerNumber[4]; // 4 numbers to label rulers with
- bool _showRulers; // toggles ruler display
- CUtlVector<CUtlSymbol> m_RegisteredControlSettingsFiles;
-
- friend class Panel;
-};
-
-
-//-----------------------------------------------------------------------------
-// Handle to a build group
-//-----------------------------------------------------------------------------
-typedef CUtlHandle<BuildGroup> HBuildGroup;
-
-
-} // namespace vgui
-
-#endif // VGUI_BUILDGROUP_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef VGUI_BUILDGROUP_H +#define VGUI_BUILDGROUP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlvector.h" +#include "tier1/utlsymbol.h" +#include <vgui/VGUI.h> +#include <vgui/Dar.h> +#include <vgui/Cursor.h> +#include <vgui/IScheme.h> +#include <vgui_controls/Controls.h> +#include <vgui_controls/PHandle.h> +#include "tier1/utlhandletable.h" + +class KeyValues; + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: a BuildGroup is a list of panels contained in a window (the contextPanel) +// Members of this group are viewable and editable in Build Mode, via the BuildModeDialog wizard +//----------------------------------------------------------------------------- +class BuildGroup +{ + DECLARE_HANDLES( BuildGroup, 20 ); + +public: + BuildGroup(Panel *parentPanel, Panel *contextPanel); + ~BuildGroup(); + + // Toggle build mode on/off + virtual void SetEnabled(bool state); + + // Check if buildgroup is enabled + virtual bool IsEnabled(); + + // Return the currently selected panel + virtual Panel *GetCurrentPanel(); + + // Load the control settings from file + virtual void LoadControlSettings(const char *controlResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL); + + // Reload the control settings from file + void ReloadControlSettings(); + + // changes which control settings are currently loaded + void ChangeControlSettingsFile(const char *controlResourceName); + + // Save control settings from file, using the same resource + // name as what LoadControlSettings() was called with + virtual bool SaveControlSettings(); + + // Serialize settings from a resource data container + virtual void ApplySettings(KeyValues *resourceData); + + // Serialize settings to a resource data container + virtual void GetSettings(KeyValues *resourceData); + + // Remove all objects in the current control group + virtual void RemoveSettings(); + + // Get a new unique fieldname for a new control + void GetNewFieldName(char *newFieldName, int newFieldNameSize, Panel *newPanel); + + // Check if a control name is already taken + Panel *FieldNameTaken(const char *fieldName); + + // Add a new control (via the BuildModeDialog) + Panel *NewControl( KeyValues *controlKeys, int x=0, int y=0); + Panel *NewControl( const char *name, int x=0, int y=0); + + // Set the panel from which the build group gets all it's object creation information + virtual void SetContextPanel(Panel *contextPanel); + + //Get the panel that build group is pointed at. + virtual Panel *GetContextPanel(); + + // Get the list of panels in the buildgroup + CUtlVector<PHandle> *GetPanelList(); + + // Get the resource file name used + virtual const char *GetResourceName(void) { return m_pResourceName; } + + virtual void PanelAdded(Panel* panel); + + virtual bool MousePressed(MouseCode code,Panel* panel); + virtual bool MouseReleased(MouseCode code,Panel* panel); + + // Get the list of panels that are currently selected + virtual CUtlVector<PHandle> *GetControlGroup(); + + // Toggle ruler display on/off + virtual void ToggleRulerDisplay(); + + // Toggle visibility of ruler number labels + virtual void SetRulerLabelsVisible(bool state); + + // Check if ruler display is activated + virtual bool HasRulersOn(); + + // Draw Rulers on screen + virtual void DrawRulers(); + + // registers that a control settings file may be loaded + // use when the dialog may have multiple states and the editor will need to be able to switch between them + void RegisterControlSettingsFile(const char *controlResourceName, const char *pathID = NULL); + + // iterator for registered files + int GetRegisteredControlSettingsFileCount(); + const char *GetRegisteredControlSettingsFileByIndex(int index); + + // dialog variables + KeyValues *GetDialogVariables(); + + // conditional keys for selectively reading keyvalues + void ProcessConditionalKeys( KeyValues *pDat, KeyValues *pConditions ); + +protected: + virtual bool CursorMoved(int x, int y, Panel *panel); + virtual bool MouseDoublePressed(MouseCode code, Panel *panel); + virtual bool KeyCodeTyped(KeyCode code, Panel *panel); + virtual bool KeyCodeReleased(KeyCode code, Panel *panel ); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual bool KeyTyped( wchar_t unichar, Panel *panel ); + + virtual HCursor GetCursor(Panel *panel); + +private: + void ApplySnap(Panel* panel); + Panel *CreateBuildDialog(); + void ActivateBuildDialog(); + void DeleteAllControlsCreatedByControlSettingsFile(); + + bool _enabled; + int _snapX; + int _snapY; + HCursor _cursor_sizenwse; + HCursor _cursor_sizenesw; + HCursor _cursor_sizewe; + HCursor _cursor_sizens; + HCursor _cursor_sizeall; + bool _dragging; + MouseCode _dragMouseCode; + int _dragStartPanelPos[2]; + int _dragStartCursorPos[2]; + int _dragStartPanelSize[ 2 ]; + Panel * _currentPanel; + CUtlVector<PHandle> _panelDar; + char *m_pResourceName; + char *m_pResourcePathID; + PHandle m_hBuildDialog; + Panel *m_pBuildContext; // the panel from which the build dialog gets all the information it needs + Panel *m_pParentPanel; // panel to create new controls in + CUtlVector<PHandle> _controlGroup; // grouped panels + CUtlVector<int> _groupDeltaX; // x offsets of panels in group from the selected panel + CUtlVector<int> _groupDeltaY; // y offsets of panels in group from the selected panel + Label *_rulerNumber[4]; // 4 numbers to label rulers with + bool _showRulers; // toggles ruler display + CUtlVector<CUtlSymbol> m_RegisteredControlSettingsFiles; + + friend class Panel; +}; + + +//----------------------------------------------------------------------------- +// Handle to a build group +//----------------------------------------------------------------------------- +typedef CUtlHandle<BuildGroup> HBuildGroup; + + +} // namespace vgui + +#endif // VGUI_BUILDGROUP_H diff --git a/mp/src/public/vgui_controls/BuildModeDialog.h b/mp/src/public/vgui_controls/BuildModeDialog.h index af96c597..25c61853 100644 --- a/mp/src/public/vgui_controls/BuildModeDialog.h +++ b/mp/src/public/vgui_controls/BuildModeDialog.h @@ -1,136 +1,136 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef BUILDMODEDIALOG_H
-#define BUILDMODEDIALOG_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Frame.h>
-
-struct PanelItem_t;
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Dialog for use in build mode editing
-//-----------------------------------------------------------------------------
-class BuildModeDialog : public Frame
-{
- DECLARE_CLASS_SIMPLE( BuildModeDialog, Frame );
-
-public:
- BuildModeDialog( BuildGroup *buildGroup );
- ~BuildModeDialog();
-
- // Set the current control to edit
- MESSAGE_FUNC_PTR( SetActiveControl, "SetActiveControl", panelPtr );
-
- // Update the current control with the current resource settings.
- MESSAGE_FUNC_PTR( UpdateControlData, "UpdateControlData", panel );
-
- // Store the current settings of all panels in the build group.
- virtual KeyValues *StoreSettings();
-
- // Store the current settings of the current panel
- MESSAGE_FUNC( StoreUndoSettings, "StoreUndo" );
-
- /* CUSTOM MESSAGE HANDLING
- "SetActiveControl"
- input: "PanelPtr" - panel to set active control to edit to
- */
-
- MESSAGE_FUNC( OnShowNewControlMenu, "ShowNewControlMenu" );
-
-protected:
- virtual void PerformLayout();
- virtual void OnClose();
- virtual void OnCommand( const char *command );
- virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
- virtual bool IsBuildGroupEnabled();
-
-private:
- void CreateControls();
-
- void OnKeyCodeTyped(KeyCode code);
- MESSAGE_FUNC( ApplyDataToControls, "ApplyDataToControls" );
- MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
- MESSAGE_FUNC( OnDeletePanel, "DeletePanel" );
- void ExitBuildMode();
- Panel *OnNewControl(const char *name, int x = 0, int y = 0);
- MESSAGE_FUNC( DoUndo, "Undo" );
- MESSAGE_FUNC( DoCopy, "Copy" );
- MESSAGE_FUNC( DoPaste, "Paste" );
- MESSAGE_FUNC( EnableSaveButton, "EnableSaveButton" );
- void RevertToSaved();
- void ShowHelp();
- MESSAGE_FUNC( ShutdownBuildMode, "Close" );
- MESSAGE_FUNC( OnPanelMoved, "PanelMoved" );
- MESSAGE_FUNC( OnTextKillFocus, "TextKillFocus" );
- MESSAGE_FUNC( OnReloadLocalization, "ReloadLocalization" );
- MESSAGE_FUNC_CHARPTR( OnCreateNewControl, "CreateNewControl", text );
-
- MESSAGE_FUNC_CHARPTR( OnSetClipboardText, "SetClipboardText", text );
-
- MESSAGE_FUNC_INT( OnChangeChild, "OnChangeChild", direction );
-
- Panel *m_pCurrentPanel;
- BuildGroup *m_pBuildGroup;
- Label *m_pStatusLabel;
- ComboBox *m_pFileSelectionCombo;
- Divider *m_pDivider;
-
- class PanelList;
- PanelList *m_pPanelList;
-
- Button *m_pSaveButton;
- Button *m_pApplyButton;
- Button *m_pExitButton;
- Button *m_pDeleteButton;
- Button *m_pReloadLocalization;
- MenuButton *m_pVarsButton;
-
- bool _autoUpdate;
-
- ComboBox *m_pAddNewControlCombo; // combo box for adding new controls
- KeyValues *_undoSettings; // settings for the Undo command
- KeyValues *_copySettings; // settings for the Copy/Paste command
- char _copyClassName[255];
- int m_nClick[ 2 ];
-
- void RemoveAllControls( void );
- void UpdateEditControl(PanelItem_t &panelItem, const char *datstring);
-
- enum {
- TYPE_STRING,
- TYPE_INTEGER,
- TYPE_COLOR,
- TYPE_ALIGNMENT,
- TYPE_AUTORESIZE,
- TYPE_CORNER,
- TYPE_LOCALIZEDSTRING,
- };
-
- vgui::DHANDLE< Menu > m_hContextMenu;
-
- ComboBox *m_pEditableParents;
- ComboBox *m_pEditableChildren;
-
- Button *m_pNextChild;
- Button *m_pPrevChild;
-
- friend class PanelList;
-};
-
-} // namespace vgui
-
-
-#endif // BUILDMODEDIALOG_H
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef BUILDMODEDIALOG_H +#define BUILDMODEDIALOG_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Frame.h> + +struct PanelItem_t; + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Dialog for use in build mode editing +//----------------------------------------------------------------------------- +class BuildModeDialog : public Frame +{ + DECLARE_CLASS_SIMPLE( BuildModeDialog, Frame ); + +public: + BuildModeDialog( BuildGroup *buildGroup ); + ~BuildModeDialog(); + + // Set the current control to edit + MESSAGE_FUNC_PTR( SetActiveControl, "SetActiveControl", panelPtr ); + + // Update the current control with the current resource settings. + MESSAGE_FUNC_PTR( UpdateControlData, "UpdateControlData", panel ); + + // Store the current settings of all panels in the build group. + virtual KeyValues *StoreSettings(); + + // Store the current settings of the current panel + MESSAGE_FUNC( StoreUndoSettings, "StoreUndo" ); + + /* CUSTOM MESSAGE HANDLING + "SetActiveControl" + input: "PanelPtr" - panel to set active control to edit to + */ + + MESSAGE_FUNC( OnShowNewControlMenu, "ShowNewControlMenu" ); + +protected: + virtual void PerformLayout(); + virtual void OnClose(); + virtual void OnCommand( const char *command ); + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + virtual bool IsBuildGroupEnabled(); + +private: + void CreateControls(); + + void OnKeyCodeTyped(KeyCode code); + MESSAGE_FUNC( ApplyDataToControls, "ApplyDataToControls" ); + MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel ); + MESSAGE_FUNC( OnDeletePanel, "DeletePanel" ); + void ExitBuildMode(); + Panel *OnNewControl(const char *name, int x = 0, int y = 0); + MESSAGE_FUNC( DoUndo, "Undo" ); + MESSAGE_FUNC( DoCopy, "Copy" ); + MESSAGE_FUNC( DoPaste, "Paste" ); + MESSAGE_FUNC( EnableSaveButton, "EnableSaveButton" ); + void RevertToSaved(); + void ShowHelp(); + MESSAGE_FUNC( ShutdownBuildMode, "Close" ); + MESSAGE_FUNC( OnPanelMoved, "PanelMoved" ); + MESSAGE_FUNC( OnTextKillFocus, "TextKillFocus" ); + MESSAGE_FUNC( OnReloadLocalization, "ReloadLocalization" ); + MESSAGE_FUNC_CHARPTR( OnCreateNewControl, "CreateNewControl", text ); + + MESSAGE_FUNC_CHARPTR( OnSetClipboardText, "SetClipboardText", text ); + + MESSAGE_FUNC_INT( OnChangeChild, "OnChangeChild", direction ); + + Panel *m_pCurrentPanel; + BuildGroup *m_pBuildGroup; + Label *m_pStatusLabel; + ComboBox *m_pFileSelectionCombo; + Divider *m_pDivider; + + class PanelList; + PanelList *m_pPanelList; + + Button *m_pSaveButton; + Button *m_pApplyButton; + Button *m_pExitButton; + Button *m_pDeleteButton; + Button *m_pReloadLocalization; + MenuButton *m_pVarsButton; + + bool _autoUpdate; + + ComboBox *m_pAddNewControlCombo; // combo box for adding new controls + KeyValues *_undoSettings; // settings for the Undo command + KeyValues *_copySettings; // settings for the Copy/Paste command + char _copyClassName[255]; + int m_nClick[ 2 ]; + + void RemoveAllControls( void ); + void UpdateEditControl(PanelItem_t &panelItem, const char *datstring); + + enum { + TYPE_STRING, + TYPE_INTEGER, + TYPE_COLOR, + TYPE_ALIGNMENT, + TYPE_AUTORESIZE, + TYPE_CORNER, + TYPE_LOCALIZEDSTRING, + }; + + vgui::DHANDLE< Menu > m_hContextMenu; + + ComboBox *m_pEditableParents; + ComboBox *m_pEditableChildren; + + Button *m_pNextChild; + Button *m_pPrevChild; + + friend class PanelList; +}; + +} // namespace vgui + + +#endif // BUILDMODEDIALOG_H + diff --git a/mp/src/public/vgui_controls/Button.h b/mp/src/public/vgui_controls/Button.h index 6b5a7d53..50b68dae 100644 --- a/mp/src/public/vgui_controls/Button.h +++ b/mp/src/public/vgui_controls/Button.h @@ -1,238 +1,238 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef BUTTON_H
-#define BUTTON_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui/Dar.h>
-#include <Color.h>
-#include <vgui_controls/Label.h>
-#include "vgui/MouseCode.h"
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-class Button : public Label
-{
- DECLARE_CLASS_SIMPLE( Button, Label );
-
-public:
- // You can optionally pass in the panel to send the click message to and the name of the command to send to that panel.
- Button(Panel *parent, const char *panelName, const char *text, Panel *pActionSignalTarget=NULL, const char *pCmd=NULL);
- Button(Panel *parent, const char *panelName, const wchar_t *text, Panel *pActionSignalTarget=NULL, const char *pCmd=NULL);
- ~Button();
-private:
- void Init();
-public:
- // Set armed state.
- virtual void SetArmed(bool state);
- // Check armed state
- virtual bool IsArmed( void );
-
- // Check depressed state
- virtual bool IsDepressed();
- // Set button force depressed state.
- virtual void ForceDepressed(bool state);
- // Set button depressed state with respect to the force depressed state.
- virtual void RecalculateDepressedState( void );
-
- // Set button selected state.
- virtual void SetSelected(bool state);
- // Check selected state
- virtual bool IsSelected( void );
-
- virtual void SetBlink(bool state);
- virtual bool IsBlinking( void );
-
- //Set whether or not the button captures all mouse input when depressed.
- virtual void SetUseCaptureMouse( bool state );
- // Check if mouse capture is enabled.
- virtual bool IsUseCaptureMouseEnabled( void );
-
- // Activate a button click.
- MESSAGE_FUNC( DoClick, "PressButton" );
- MESSAGE_FUNC( OnHotkey, "Hotkey" )
- {
- DoClick();
- }
-
- // Set button to be mouse clickable or not.
- virtual void SetMouseClickEnabled( MouseCode code, bool state );
- // Check if button is mouse clickable
- virtual bool IsMouseClickEnabled( MouseCode code );
- // sets the how this button activates
- enum ActivationType_t
- {
- ACTIVATE_ONPRESSEDANDRELEASED, // normal button behaviour
- ACTIVATE_ONPRESSED, // menu buttons, toggle buttons
- ACTIVATE_ONRELEASED, // menu items
- };
- virtual void SetButtonActivationType(ActivationType_t activationType);
-
- // Message targets that the button has been pressed
- virtual void FireActionSignal( void );
- // Perform graphical layout of button
- virtual void PerformLayout();
-
- virtual bool RequestInfo(KeyValues *data);
-
- virtual bool CanBeDefaultButton(void);
-
- // Set this button to be the button that is accessed by default when the user hits ENTER or SPACE
- MESSAGE_FUNC_INT( SetAsDefaultButton, "SetAsDefaultButton", state );
- // Set this button to be the button that is currently accessed by default when the user hits ENTER or SPACE
- MESSAGE_FUNC_INT( SetAsCurrentDefaultButton, "SetAsCurrentDefaultButton", state );
-
- // Respond when key focus is received
- virtual void OnSetFocus();
- // Respond when focus is killed
- virtual void OnKillFocus();
-
- // Set button border attribute enabled, controls display of button.
- virtual void SetButtonBorderEnabled( bool state );
-
- // Set default button colors.
- virtual void SetDefaultColor(Color fgColor, Color bgColor);
- // Set armed button colors
- virtual void SetArmedColor(Color fgColor, Color bgColor);
- // Set selected button colors
- virtual void SetSelectedColor(Color fgColor, Color bgColor);
- // Set depressed button colors
- virtual void SetDepressedColor(Color fgColor, Color bgColor);
- // Set blink button color
- virtual void SetBlinkColor(Color fgColor);
-
- // Get button foreground color
- virtual Color GetButtonFgColor();
- // Get button background color
- virtual Color GetButtonBgColor();
-
- Color GetButtonDefaultFgColor() { return _defaultFgColor; }
- Color GetButtonDefaultBgColor() { return _defaultBgColor; }
-
- Color GetButtonArmedFgColor() { return _armedFgColor; }
- Color GetButtonArmedBgColor() { return _armedBgColor; }
-
- Color GetButtonSelectedFgColor() { return _selectedFgColor; }
- Color GetButtonSelectedBgColor() { return _selectedBgColor; }
-
- Color GetButtonDepressedFgColor() { return _depressedFgColor; }
- Color GetButtonDepressedBgColor() { return _depressedBgColor; }
-
- // Set default button border attributes.
- virtual void SetDefaultBorder(IBorder *border);
- // Set depressed button border attributes.
- virtual void SetDepressedBorder(IBorder *border);
- // Set key focused button border attributes.
- virtual void SetKeyFocusBorder(IBorder *border);
-
- // Set the command to send when the button is pressed
- // Set the panel to send the command to with AddActionSignalTarget()
- virtual void SetCommand( const char *command );
- // Set the message to send when the button is pressed
- virtual void SetCommand( KeyValues *message );
-
- // sound handling
- void SetArmedSound(const char *sound);
- void SetDepressedSound(const char *sound);
- void SetReleasedSound(const char *sound);
-
- /* CUSTOM MESSAGE HANDLING
- "PressButton" - makes the button act as if it had just been pressed by the user (just like DoClick())
- input: none
- */
-
- virtual void OnCursorEntered();
- virtual void OnCursorExited();
- virtual void SizeToContents();
-
- virtual KeyValues *GetCommand();
-
- bool IsDrawingFocusBox();
- void DrawFocusBox( bool bEnable );
-
- bool ShouldPaint(){ return _paint; }
- void SetShouldPaint( bool paint ){ _paint = paint; }
-
- virtual void ApplySettings( KeyValues *inResourceData );
- virtual void NavigateTo();
- virtual void NavigateFrom();
-
-protected:
- virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1);
-
- // Paint button on screen
- virtual void Paint(void);
- // Get button border attributes.
- virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
-
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_INT( OnSetState, "SetState", state );
-
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseDoublePressed(MouseCode code);
- virtual void OnMouseReleased(MouseCode code);
- virtual void OnKeyCodePressed(KeyCode code);
- virtual void OnKeyCodeReleased(KeyCode code);
-
- // Get control settings for editing
- virtual void GetSettings( KeyValues *outResourceData );
- virtual const char *GetDescription( void );
-
- KeyValues *GetActionMessage();
- void PlayButtonReleasedSound();
-
-protected:
- enum ButtonFlags_t
- {
- ARMED = 0x0001,
- DEPRESSED = 0x0002,
- FORCE_DEPRESSED = 0x0004,
- BUTTON_BORDER_ENABLED = 0x0008,
- USE_CAPTURE_MOUSE = 0x0010,
- BUTTON_KEY_DOWN = 0x0020,
- DEFAULT_BUTTON = 0x0040,
- SELECTED = 0x0080,
- DRAW_FOCUS_BOX = 0x0100,
- BLINK = 0x0200,
- ALL_FLAGS = 0xFFFF,
- };
-
- CUtlFlags< unsigned short > _buttonFlags; // see ButtonFlags_t
- int _mouseClickMask;
- KeyValues *_actionMessage;
- ActivationType_t _activationType;
-
- IBorder *_defaultBorder;
- IBorder *_depressedBorder;
- IBorder *_keyFocusBorder;
-
- Color _defaultFgColor, _defaultBgColor;
- Color _armedFgColor, _armedBgColor;
- Color _selectedFgColor, _selectedBgColor;
- Color _depressedFgColor, _depressedBgColor;
- Color _keyboardFocusColor;
- Color _blinkFgColor;
-
- bool _paint;
-
- unsigned short m_sArmedSoundName, m_sDepressedSoundName, m_sReleasedSoundName;
- bool m_bSelectionStateSaved;
- bool m_bStaySelectedOnClick;
-};
-
-} // namespace vgui
-
-#endif // BUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef BUTTON_H +#define BUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui/Dar.h> +#include <Color.h> +#include <vgui_controls/Label.h> +#include "vgui/MouseCode.h" + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class Button : public Label +{ + DECLARE_CLASS_SIMPLE( Button, Label ); + +public: + // You can optionally pass in the panel to send the click message to and the name of the command to send to that panel. + Button(Panel *parent, const char *panelName, const char *text, Panel *pActionSignalTarget=NULL, const char *pCmd=NULL); + Button(Panel *parent, const char *panelName, const wchar_t *text, Panel *pActionSignalTarget=NULL, const char *pCmd=NULL); + ~Button(); +private: + void Init(); +public: + // Set armed state. + virtual void SetArmed(bool state); + // Check armed state + virtual bool IsArmed( void ); + + // Check depressed state + virtual bool IsDepressed(); + // Set button force depressed state. + virtual void ForceDepressed(bool state); + // Set button depressed state with respect to the force depressed state. + virtual void RecalculateDepressedState( void ); + + // Set button selected state. + virtual void SetSelected(bool state); + // Check selected state + virtual bool IsSelected( void ); + + virtual void SetBlink(bool state); + virtual bool IsBlinking( void ); + + //Set whether or not the button captures all mouse input when depressed. + virtual void SetUseCaptureMouse( bool state ); + // Check if mouse capture is enabled. + virtual bool IsUseCaptureMouseEnabled( void ); + + // Activate a button click. + MESSAGE_FUNC( DoClick, "PressButton" ); + MESSAGE_FUNC( OnHotkey, "Hotkey" ) + { + DoClick(); + } + + // Set button to be mouse clickable or not. + virtual void SetMouseClickEnabled( MouseCode code, bool state ); + // Check if button is mouse clickable + virtual bool IsMouseClickEnabled( MouseCode code ); + // sets the how this button activates + enum ActivationType_t + { + ACTIVATE_ONPRESSEDANDRELEASED, // normal button behaviour + ACTIVATE_ONPRESSED, // menu buttons, toggle buttons + ACTIVATE_ONRELEASED, // menu items + }; + virtual void SetButtonActivationType(ActivationType_t activationType); + + // Message targets that the button has been pressed + virtual void FireActionSignal( void ); + // Perform graphical layout of button + virtual void PerformLayout(); + + virtual bool RequestInfo(KeyValues *data); + + virtual bool CanBeDefaultButton(void); + + // Set this button to be the button that is accessed by default when the user hits ENTER or SPACE + MESSAGE_FUNC_INT( SetAsDefaultButton, "SetAsDefaultButton", state ); + // Set this button to be the button that is currently accessed by default when the user hits ENTER or SPACE + MESSAGE_FUNC_INT( SetAsCurrentDefaultButton, "SetAsCurrentDefaultButton", state ); + + // Respond when key focus is received + virtual void OnSetFocus(); + // Respond when focus is killed + virtual void OnKillFocus(); + + // Set button border attribute enabled, controls display of button. + virtual void SetButtonBorderEnabled( bool state ); + + // Set default button colors. + virtual void SetDefaultColor(Color fgColor, Color bgColor); + // Set armed button colors + virtual void SetArmedColor(Color fgColor, Color bgColor); + // Set selected button colors + virtual void SetSelectedColor(Color fgColor, Color bgColor); + // Set depressed button colors + virtual void SetDepressedColor(Color fgColor, Color bgColor); + // Set blink button color + virtual void SetBlinkColor(Color fgColor); + + // Get button foreground color + virtual Color GetButtonFgColor(); + // Get button background color + virtual Color GetButtonBgColor(); + + Color GetButtonDefaultFgColor() { return _defaultFgColor; } + Color GetButtonDefaultBgColor() { return _defaultBgColor; } + + Color GetButtonArmedFgColor() { return _armedFgColor; } + Color GetButtonArmedBgColor() { return _armedBgColor; } + + Color GetButtonSelectedFgColor() { return _selectedFgColor; } + Color GetButtonSelectedBgColor() { return _selectedBgColor; } + + Color GetButtonDepressedFgColor() { return _depressedFgColor; } + Color GetButtonDepressedBgColor() { return _depressedBgColor; } + + // Set default button border attributes. + virtual void SetDefaultBorder(IBorder *border); + // Set depressed button border attributes. + virtual void SetDepressedBorder(IBorder *border); + // Set key focused button border attributes. + virtual void SetKeyFocusBorder(IBorder *border); + + // Set the command to send when the button is pressed + // Set the panel to send the command to with AddActionSignalTarget() + virtual void SetCommand( const char *command ); + // Set the message to send when the button is pressed + virtual void SetCommand( KeyValues *message ); + + // sound handling + void SetArmedSound(const char *sound); + void SetDepressedSound(const char *sound); + void SetReleasedSound(const char *sound); + + /* CUSTOM MESSAGE HANDLING + "PressButton" - makes the button act as if it had just been pressed by the user (just like DoClick()) + input: none + */ + + virtual void OnCursorEntered(); + virtual void OnCursorExited(); + virtual void SizeToContents(); + + virtual KeyValues *GetCommand(); + + bool IsDrawingFocusBox(); + void DrawFocusBox( bool bEnable ); + + bool ShouldPaint(){ return _paint; } + void SetShouldPaint( bool paint ){ _paint = paint; } + + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void NavigateTo(); + virtual void NavigateFrom(); + +protected: + virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1); + + // Paint button on screen + virtual void Paint(void); + // Get button border attributes. + virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_INT( OnSetState, "SetState", state ); + + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); + virtual void OnKeyCodePressed(KeyCode code); + virtual void OnKeyCodeReleased(KeyCode code); + + // Get control settings for editing + virtual void GetSettings( KeyValues *outResourceData ); + virtual const char *GetDescription( void ); + + KeyValues *GetActionMessage(); + void PlayButtonReleasedSound(); + +protected: + enum ButtonFlags_t + { + ARMED = 0x0001, + DEPRESSED = 0x0002, + FORCE_DEPRESSED = 0x0004, + BUTTON_BORDER_ENABLED = 0x0008, + USE_CAPTURE_MOUSE = 0x0010, + BUTTON_KEY_DOWN = 0x0020, + DEFAULT_BUTTON = 0x0040, + SELECTED = 0x0080, + DRAW_FOCUS_BOX = 0x0100, + BLINK = 0x0200, + ALL_FLAGS = 0xFFFF, + }; + + CUtlFlags< unsigned short > _buttonFlags; // see ButtonFlags_t + int _mouseClickMask; + KeyValues *_actionMessage; + ActivationType_t _activationType; + + IBorder *_defaultBorder; + IBorder *_depressedBorder; + IBorder *_keyFocusBorder; + + Color _defaultFgColor, _defaultBgColor; + Color _armedFgColor, _armedBgColor; + Color _selectedFgColor, _selectedBgColor; + Color _depressedFgColor, _depressedBgColor; + Color _keyboardFocusColor; + Color _blinkFgColor; + + bool _paint; + + unsigned short m_sArmedSoundName, m_sDepressedSoundName, m_sReleasedSoundName; + bool m_bSelectionStateSaved; + bool m_bStaySelectedOnClick; +}; + +} // namespace vgui + +#endif // BUTTON_H diff --git a/mp/src/public/vgui_controls/CheckButton.h b/mp/src/public/vgui_controls/CheckButton.h index b84fdee2..a7e25ac9 100644 --- a/mp/src/public/vgui_controls/CheckButton.h +++ b/mp/src/public/vgui_controls/CheckButton.h @@ -1,106 +1,106 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef CHECKBUTTON_H
-#define CHECKBUTTON_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/ToggleButton.h>
-#include <vgui_controls/TextImage.h>
-
-namespace vgui
-{
-
-class TextImage;
-
-//-----------------------------------------------------------------------------
-// Purpose: Check box image
-//-----------------------------------------------------------------------------
-class CheckImage : public TextImage
-{
-public:
- CheckImage(CheckButton *CheckButton) : TextImage( "g" )
- {
- _CheckButton = CheckButton;
-
- SetSize(20, 13);
- }
-
- virtual void Paint();
-
- virtual void SetColor(Color color)
- {
- _borderColor1 = color;
- _borderColor2 = color;
- _checkColor = color;
- }
-
- Color _borderColor1;
- Color _borderColor2;
- Color _checkColor;
-
- Color _bgColor;
-
-private:
- CheckButton *_CheckButton;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Tick-box button
-//-----------------------------------------------------------------------------
-class CheckButton : public ToggleButton
-{
- DECLARE_CLASS_SIMPLE( CheckButton, ToggleButton );
-
-public:
- CheckButton(Panel *parent, const char *panelName, const char *text);
- ~CheckButton();
-
- // Check the button
- virtual void SetSelected(bool state );
-
- // sets whether or not the state of the check can be changed
- // if this is set to false, then no input in the code or by the user can change it's state
- virtual void SetCheckButtonCheckable(bool state);
- virtual bool IsCheckButtonCheckable() const { return m_bCheckButtonCheckable; }
-
- Color GetDisabledFgColor() { return _disabledFgColor; }
- Color GetDisabledBgColor() { return _disabledBgColor; }
-
- CheckImage *GetCheckImage() { return _checkBoxImage; }
-
- virtual void SetHighlightColor(Color fgColor);
-
-protected:
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
- virtual Color GetButtonFgColor();
-
- virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
-
- /* MESSAGES SENT
- "CheckButtonChecked" - sent when the check button state is changed
- "state" - button state: 1 is checked, 0 is unchecked
- */
-
-
-private:
- enum { CHECK_INSET = 6 };
- bool m_bCheckButtonCheckable;
- CheckImage *_checkBoxImage;
- Color _disabledFgColor;
- Color _disabledBgColor;
- Color _highlightFgColor;
-};
-
-} // namespace vgui
-
-#endif // CHECKBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef CHECKBUTTON_H +#define CHECKBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/ToggleButton.h> +#include <vgui_controls/TextImage.h> + +namespace vgui +{ + +class TextImage; + +//----------------------------------------------------------------------------- +// Purpose: Check box image +//----------------------------------------------------------------------------- +class CheckImage : public TextImage +{ +public: + CheckImage(CheckButton *CheckButton) : TextImage( "g" ) + { + _CheckButton = CheckButton; + + SetSize(20, 13); + } + + virtual void Paint(); + + virtual void SetColor(Color color) + { + _borderColor1 = color; + _borderColor2 = color; + _checkColor = color; + } + + Color _borderColor1; + Color _borderColor2; + Color _checkColor; + + Color _bgColor; + +private: + CheckButton *_CheckButton; +}; + +//----------------------------------------------------------------------------- +// Purpose: Tick-box button +//----------------------------------------------------------------------------- +class CheckButton : public ToggleButton +{ + DECLARE_CLASS_SIMPLE( CheckButton, ToggleButton ); + +public: + CheckButton(Panel *parent, const char *panelName, const char *text); + ~CheckButton(); + + // Check the button + virtual void SetSelected(bool state ); + + // sets whether or not the state of the check can be changed + // if this is set to false, then no input in the code or by the user can change it's state + virtual void SetCheckButtonCheckable(bool state); + virtual bool IsCheckButtonCheckable() const { return m_bCheckButtonCheckable; } + + Color GetDisabledFgColor() { return _disabledFgColor; } + Color GetDisabledBgColor() { return _disabledBgColor; } + + CheckImage *GetCheckImage() { return _checkBoxImage; } + + virtual void SetHighlightColor(Color fgColor); + +protected: + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel ); + virtual Color GetButtonFgColor(); + + virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + + /* MESSAGES SENT + "CheckButtonChecked" - sent when the check button state is changed + "state" - button state: 1 is checked, 0 is unchecked + */ + + +private: + enum { CHECK_INSET = 6 }; + bool m_bCheckButtonCheckable; + CheckImage *_checkBoxImage; + Color _disabledFgColor; + Color _disabledBgColor; + Color _highlightFgColor; +}; + +} // namespace vgui + +#endif // CHECKBUTTON_H diff --git a/mp/src/public/vgui_controls/CheckButtonList.h b/mp/src/public/vgui_controls/CheckButtonList.h index f550a4e7..6bb95d94 100644 --- a/mp/src/public/vgui_controls/CheckButtonList.h +++ b/mp/src/public/vgui_controls/CheckButtonList.h @@ -1,74 +1,74 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef CHECKBUTTONLIST_H
-#define CHECKBUTTONLIST_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/EditablePanel.h>
-#include "utlvector.h"
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Contains a list of check boxes, displaying scrollbars if necessary
-//-----------------------------------------------------------------------------
-class CheckButtonList : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( CheckButtonList, EditablePanel );
-
-public:
- CheckButtonList(Panel *parent, const char *name);
- ~CheckButtonList();
-
- // adds a check button to the list
- int AddItem(const char *itemText, bool startsSelected, KeyValues *userData);
-
- // clears the list
- void RemoveAll();
-
- // number of items in list that are checked
- int GetCheckedItemCount();
-
- // item iteration
- bool IsItemIDValid(int itemID);
- int GetHighestItemID();
- int GetItemCount();
-
- // item info
- KeyValues *GetItemData(int itemID);
- bool IsItemChecked(int itemID);
- void SetItemCheckable(int itemID, bool state);
-
- /* MESSAGES SENT
- "CheckButtonChecked" - sent when one of the check buttons state has changed
-
- */
-
-protected:
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnMouseWheeled(int delta);
-
-private:
- MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", pParams );
- MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" );
-
- struct CheckItem_t
- {
- vgui::CheckButton *checkButton;
- KeyValues *userData;
- };
- CUtlVector<CheckItem_t> m_CheckItems;
- vgui::ScrollBar *m_pScrollBar;
-};
-
-}
-
-#endif // CHECKBUTTONLIST_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef CHECKBUTTONLIST_H +#define CHECKBUTTONLIST_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/EditablePanel.h> +#include "utlvector.h" + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Contains a list of check boxes, displaying scrollbars if necessary +//----------------------------------------------------------------------------- +class CheckButtonList : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( CheckButtonList, EditablePanel ); + +public: + CheckButtonList(Panel *parent, const char *name); + ~CheckButtonList(); + + // adds a check button to the list + int AddItem(const char *itemText, bool startsSelected, KeyValues *userData); + + // clears the list + void RemoveAll(); + + // number of items in list that are checked + int GetCheckedItemCount(); + + // item iteration + bool IsItemIDValid(int itemID); + int GetHighestItemID(); + int GetItemCount(); + + // item info + KeyValues *GetItemData(int itemID); + bool IsItemChecked(int itemID); + void SetItemCheckable(int itemID, bool state); + + /* MESSAGES SENT + "CheckButtonChecked" - sent when one of the check buttons state has changed + + */ + +protected: + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnMouseWheeled(int delta); + +private: + MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", pParams ); + MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" ); + + struct CheckItem_t + { + vgui::CheckButton *checkButton; + KeyValues *userData; + }; + CUtlVector<CheckItem_t> m_CheckItems; + vgui::ScrollBar *m_pScrollBar; +}; + +} + +#endif // CHECKBUTTONLIST_H diff --git a/mp/src/public/vgui_controls/CircularProgressBar.h b/mp/src/public/vgui_controls/CircularProgressBar.h index 6d1d0676..2a31f504 100644 --- a/mp/src/public/vgui_controls/CircularProgressBar.h +++ b/mp/src/public/vgui_controls/CircularProgressBar.h @@ -1,74 +1,74 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef CIRCULARPROGRESSBAR_H
-#define CIRCULARPROGRESSBAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/ProgressBar.h>
-
-enum progress_textures_t
-{
- PROGRESS_TEXTURE_FG,
- PROGRESS_TEXTURE_BG,
-
- NUM_PROGRESS_TEXTURES,
-};
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Progress Bar in the shape of a pie graph
-//-----------------------------------------------------------------------------
-class CircularProgressBar : public ProgressBar
-{
- DECLARE_CLASS_SIMPLE( CircularProgressBar, ProgressBar );
-
-public:
- CircularProgressBar(Panel *parent, const char *panelName);
- ~CircularProgressBar();
-
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
- void SetFgImage(const char *imageName) { SetImage( imageName, PROGRESS_TEXTURE_FG ); }
- void SetBgImage(const char *imageName) { SetImage( imageName, PROGRESS_TEXTURE_BG ); }
-
- enum CircularProgressDir_e
- {
- PROGRESS_CW,
- PROGRESS_CCW
- };
- int GetProgressDirection() const { return m_iProgressDirection; }
- void SetProgressDirection( int val ) { m_iProgressDirection = val; }
- void SetStartSegment( int val ) { m_iStartSegment = val; }
-
-protected:
- virtual void Paint();
- virtual void PaintBackground();
-
- void DrawCircleSegment( Color c, float flEndDegrees, bool clockwise /* = true */ );
- void SetImage(const char *imageName, progress_textures_t iPos);
-
-private:
- int m_iProgressDirection;
- int m_iStartSegment;
-
- int m_nTextureId[NUM_PROGRESS_TEXTURES];
- char *m_pszImageName[NUM_PROGRESS_TEXTURES];
- int m_lenImageName[NUM_PROGRESS_TEXTURES];
-};
-
-} // namespace vgui
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef CIRCULARPROGRESSBAR_H +#define CIRCULARPROGRESSBAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> +#include <vgui_controls/ProgressBar.h> + +enum progress_textures_t +{ + PROGRESS_TEXTURE_FG, + PROGRESS_TEXTURE_BG, + + NUM_PROGRESS_TEXTURES, +}; + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Progress Bar in the shape of a pie graph +//----------------------------------------------------------------------------- +class CircularProgressBar : public ProgressBar +{ + DECLARE_CLASS_SIMPLE( CircularProgressBar, ProgressBar ); + +public: + CircularProgressBar(Panel *parent, const char *panelName); + ~CircularProgressBar(); + + virtual void ApplySettings(KeyValues *inResourceData); + virtual void ApplySchemeSettings(IScheme *pScheme); + + void SetFgImage(const char *imageName) { SetImage( imageName, PROGRESS_TEXTURE_FG ); } + void SetBgImage(const char *imageName) { SetImage( imageName, PROGRESS_TEXTURE_BG ); } + + enum CircularProgressDir_e + { + PROGRESS_CW, + PROGRESS_CCW + }; + int GetProgressDirection() const { return m_iProgressDirection; } + void SetProgressDirection( int val ) { m_iProgressDirection = val; } + void SetStartSegment( int val ) { m_iStartSegment = val; } + +protected: + virtual void Paint(); + virtual void PaintBackground(); + + void DrawCircleSegment( Color c, float flEndDegrees, bool clockwise /* = true */ ); + void SetImage(const char *imageName, progress_textures_t iPos); + +private: + int m_iProgressDirection; + int m_iStartSegment; + + int m_nTextureId[NUM_PROGRESS_TEXTURES]; + char *m_pszImageName[NUM_PROGRESS_TEXTURES]; + int m_lenImageName[NUM_PROGRESS_TEXTURES]; +}; + +} // namespace vgui + #endif // CIRCULARPROGRESSBAR_H
\ No newline at end of file diff --git a/mp/src/public/vgui_controls/ComboBox.h b/mp/src/public/vgui_controls/ComboBox.h index 4beb9714..c5c3eba0 100644 --- a/mp/src/public/vgui_controls/ComboBox.h +++ b/mp/src/public/vgui_controls/ComboBox.h @@ -1,186 +1,186 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef COMBOBOX_H
-#define COMBOBOX_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/TextEntry.h>
-#include <vgui_controls/Menu.h>
-#include <vgui_controls/Button.h>
-
-namespace vgui
-{
-//-----------------------------------------------------------------------------
-// Purpose: Scroll bar button
-//-----------------------------------------------------------------------------
-class ComboBoxButton : public vgui::Button
-{
-public:
- ComboBoxButton(ComboBox *parent, const char *panelName, const char *text);
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
- virtual void OnCursorExited();
-
- virtual Color GetButtonBgColor()
- {
- if (IsEnabled())
- return Button::GetButtonBgColor();
-
- return m_DisabledBgColor;
- }
-
-private:
- Color m_DisabledBgColor;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Text entry with drop down options list
-//-----------------------------------------------------------------------------
-class ComboBox : public TextEntry
-{
- DECLARE_CLASS_SIMPLE( ComboBox, TextEntry );
-
-public:
- ComboBox(Panel *parent, const char *panelName, int numLines, bool allowEdit);
- ~ComboBox();
-
- // functions designed to be overriden
- virtual void OnShowMenu(Menu *menu) {}
- virtual void OnHideMenu(Menu *menu) {}
-
- // Set the number of items in the drop down menu.
- virtual void SetNumberOfEditLines( int numLines );
-
- // Add an item to the drop down
- virtual int AddItem(const char *itemText, const KeyValues *userData);
- virtual int AddItem(const wchar_t *itemText, const KeyValues *userData);
-
- virtual int GetItemCount();
- int GetItemIDFromRow( int row );
-
- // update the item
- virtual bool UpdateItem(int itemID, const char *itemText,const KeyValues *userData);
- virtual bool UpdateItem(int itemID, const wchar_t *itemText, const KeyValues *userData);
- virtual bool IsItemIDValid(int itemID);
-
- // set the enabled state of an item
- virtual void SetItemEnabled(const char *itemText, bool state);
- virtual void SetItemEnabled(int itemID, bool state);
-
- // Removes a single item
- void DeleteItem( int itemID );
-
- // Remove all items from the drop down menu
- void RemoveAll();
- // deprecated, use above
- void DeleteAllItems() { RemoveAll(); }
-
- // Sorts the items in the list - FIXME does nothing
- virtual void SortItems();
-
- // Set the visiblity of the drop down menu button.
- virtual void SetDropdownButtonVisible(bool state);
-
- // Return true if the combobox current has the dropdown menu open
- virtual bool IsDropdownVisible();
-
- // Activate the item in the menu list,as if that
- // menu item had been selected by the user
- MESSAGE_FUNC_INT( ActivateItem, "ActivateItem", itemID );
- void ActivateItemByRow(int row);
-
- void SilentActivateItem(int itemID); // Sets the menu to the appropriate row without sending a TextChanged message
- void SilentActivateItemByRow(int row); // Sets the menu to the appropriate row without sending a TextChanged message
-
- int GetActiveItem();
- KeyValues *GetActiveItemUserData();
- KeyValues *GetItemUserData(int itemID);
- void GetItemText( int itemID, OUT_Z_BYTECAP(bufLenInBytes) wchar_t *text, int bufLenInBytes );
- void GetItemText( int itemID, OUT_Z_BYTECAP(bufLenInBytes) char *text, int bufLenInBytes );
-
- // sets a custom menu to use for the dropdown
- virtual void SetMenu( Menu *menu );
- virtual Menu *GetMenu() { return m_pDropDown; }
-
- // Layout the format of the combo box for drawing on screen
- virtual void PerformLayout();
-
- /* action signals
- "TextChanged" - signals that the text has changed in the combo box
-
- */
-
- virtual void ShowMenu();
- virtual void HideMenu();
- virtual void OnKillFocus();
- MESSAGE_FUNC( OnMenuClose, "MenuClose" );
- virtual void DoClick();
- virtual void OnSizeChanged(int wide, int tall);
-
- virtual void SetOpenDirection(Menu::MenuDirection_e direction);
-
- virtual void SetFont( HFont font );
-
- virtual void SetUseFallbackFont( bool bState, HFont hFallback );
-
- ComboBoxButton *GetComboButton( void ) { return m_pButton; }
-
-protected:
- // overrides
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseDoublePressed(MouseCode code);
- MESSAGE_FUNC( OnMenuItemSelected, "MenuItemSelected" );
- virtual void OnCommand( const char *command );
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void ApplySettings( KeyValues *pInResourceData );
- virtual void OnCursorEntered();
- virtual void OnCursorExited();
-
- // custom message handlers
- MESSAGE_FUNC_WCHARPTR( OnSetText, "SetText", text );
- virtual void OnSetFocus(); // called after the panel receives the keyboard focus
-#ifdef _X360
- virtual void OnKeyCodePressed(KeyCode code);
-#endif
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void OnKeyTyped(wchar_t unichar);
-
- void SelectMenuItem(int itemToSelect);
- void MoveAlongMenuItemList(int direction);
- void MoveToFirstMenuItem();
- void MoveToLastMenuItem();
-private:
- void DoMenuLayout();
-
- Menu *m_pDropDown;
- ComboBoxButton *m_pButton;
- bool m_bPreventTextChangeMessage;
-
-//=============================================================================
-// HPE_BEGIN:
-// [pfreese] This member variable is never initialized and not used correctly
-//=============================================================================
-
-// bool m_bAllowEdit;
-
-//=============================================================================
-// HPE_END
-//=============================================================================
- bool m_bHighlight;
- Menu::MenuDirection_e m_iDirection;
- int m_iOpenOffsetY;
-
- char m_szBorderOverride[64];
-};
-
-} // namespace vgui
-
-#endif // COMBOBOX_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef COMBOBOX_H +#define COMBOBOX_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/TextEntry.h> +#include <vgui_controls/Menu.h> +#include <vgui_controls/Button.h> + +namespace vgui +{ +//----------------------------------------------------------------------------- +// Purpose: Scroll bar button +//----------------------------------------------------------------------------- +class ComboBoxButton : public vgui::Button +{ +public: + ComboBoxButton(ComboBox *parent, const char *panelName, const char *text); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + virtual void OnCursorExited(); + + virtual Color GetButtonBgColor() + { + if (IsEnabled()) + return Button::GetButtonBgColor(); + + return m_DisabledBgColor; + } + +private: + Color m_DisabledBgColor; +}; + +//----------------------------------------------------------------------------- +// Purpose: Text entry with drop down options list +//----------------------------------------------------------------------------- +class ComboBox : public TextEntry +{ + DECLARE_CLASS_SIMPLE( ComboBox, TextEntry ); + +public: + ComboBox(Panel *parent, const char *panelName, int numLines, bool allowEdit); + ~ComboBox(); + + // functions designed to be overriden + virtual void OnShowMenu(Menu *menu) {} + virtual void OnHideMenu(Menu *menu) {} + + // Set the number of items in the drop down menu. + virtual void SetNumberOfEditLines( int numLines ); + + // Add an item to the drop down + virtual int AddItem(const char *itemText, const KeyValues *userData); + virtual int AddItem(const wchar_t *itemText, const KeyValues *userData); + + virtual int GetItemCount(); + int GetItemIDFromRow( int row ); + + // update the item + virtual bool UpdateItem(int itemID, const char *itemText,const KeyValues *userData); + virtual bool UpdateItem(int itemID, const wchar_t *itemText, const KeyValues *userData); + virtual bool IsItemIDValid(int itemID); + + // set the enabled state of an item + virtual void SetItemEnabled(const char *itemText, bool state); + virtual void SetItemEnabled(int itemID, bool state); + + // Removes a single item + void DeleteItem( int itemID ); + + // Remove all items from the drop down menu + void RemoveAll(); + // deprecated, use above + void DeleteAllItems() { RemoveAll(); } + + // Sorts the items in the list - FIXME does nothing + virtual void SortItems(); + + // Set the visiblity of the drop down menu button. + virtual void SetDropdownButtonVisible(bool state); + + // Return true if the combobox current has the dropdown menu open + virtual bool IsDropdownVisible(); + + // Activate the item in the menu list,as if that + // menu item had been selected by the user + MESSAGE_FUNC_INT( ActivateItem, "ActivateItem", itemID ); + void ActivateItemByRow(int row); + + void SilentActivateItem(int itemID); // Sets the menu to the appropriate row without sending a TextChanged message + void SilentActivateItemByRow(int row); // Sets the menu to the appropriate row without sending a TextChanged message + + int GetActiveItem(); + KeyValues *GetActiveItemUserData(); + KeyValues *GetItemUserData(int itemID); + void GetItemText( int itemID, OUT_Z_BYTECAP(bufLenInBytes) wchar_t *text, int bufLenInBytes ); + void GetItemText( int itemID, OUT_Z_BYTECAP(bufLenInBytes) char *text, int bufLenInBytes ); + + // sets a custom menu to use for the dropdown + virtual void SetMenu( Menu *menu ); + virtual Menu *GetMenu() { return m_pDropDown; } + + // Layout the format of the combo box for drawing on screen + virtual void PerformLayout(); + + /* action signals + "TextChanged" - signals that the text has changed in the combo box + + */ + + virtual void ShowMenu(); + virtual void HideMenu(); + virtual void OnKillFocus(); + MESSAGE_FUNC( OnMenuClose, "MenuClose" ); + virtual void DoClick(); + virtual void OnSizeChanged(int wide, int tall); + + virtual void SetOpenDirection(Menu::MenuDirection_e direction); + + virtual void SetFont( HFont font ); + + virtual void SetUseFallbackFont( bool bState, HFont hFallback ); + + ComboBoxButton *GetComboButton( void ) { return m_pButton; } + +protected: + // overrides + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + MESSAGE_FUNC( OnMenuItemSelected, "MenuItemSelected" ); + virtual void OnCommand( const char *command ); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void ApplySettings( KeyValues *pInResourceData ); + virtual void OnCursorEntered(); + virtual void OnCursorExited(); + + // custom message handlers + MESSAGE_FUNC_WCHARPTR( OnSetText, "SetText", text ); + virtual void OnSetFocus(); // called after the panel receives the keyboard focus +#ifdef _X360 + virtual void OnKeyCodePressed(KeyCode code); +#endif + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnKeyTyped(wchar_t unichar); + + void SelectMenuItem(int itemToSelect); + void MoveAlongMenuItemList(int direction); + void MoveToFirstMenuItem(); + void MoveToLastMenuItem(); +private: + void DoMenuLayout(); + + Menu *m_pDropDown; + ComboBoxButton *m_pButton; + bool m_bPreventTextChangeMessage; + +//============================================================================= +// HPE_BEGIN: +// [pfreese] This member variable is never initialized and not used correctly +//============================================================================= + +// bool m_bAllowEdit; + +//============================================================================= +// HPE_END +//============================================================================= + bool m_bHighlight; + Menu::MenuDirection_e m_iDirection; + int m_iOpenOffsetY; + + char m_szBorderOverride[64]; +}; + +} // namespace vgui + +#endif // COMBOBOX_H diff --git a/mp/src/public/vgui_controls/ControllerMap.h b/mp/src/public/vgui_controls/ControllerMap.h index 62fda7e0..7ccbdc60 100644 --- a/mp/src/public/vgui_controls/ControllerMap.h +++ b/mp/src/public/vgui_controls/ControllerMap.h @@ -1,48 +1,48 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef CONTROLLERMAP_H
-#define CONTROLLERMAP_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "Panel.h"
-#include "utlmap.h"
-#include "utlsymbol.h"
-
-class CControllerMap : public vgui::Panel
-{
- DECLARE_CLASS_SIMPLE( CControllerMap, vgui::Panel )
-
- virtual void OnKeyCodeTyped( vgui::KeyCode code );
-
-public:
- CControllerMap( vgui::Panel *parent, const char *name );
-
- virtual void ApplySettings( KeyValues *inResourceData );
-
- int NumButtons( void )
- {
- return m_buttonMap.Count();
- }
-
- const char *GetBindingText( int idx );
- const char *GetBindingIcon( int idx );
-
-private:
-
- struct button_t
- {
- CUtlSymbol cmd;
- CUtlSymbol text;
- CUtlSymbol icon;
- };
- CUtlMap< int, button_t > m_buttonMap;
-};
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef CONTROLLERMAP_H +#define CONTROLLERMAP_H +#ifdef _WIN32 +#pragma once +#endif + +#include "Panel.h" +#include "utlmap.h" +#include "utlsymbol.h" + +class CControllerMap : public vgui::Panel +{ + DECLARE_CLASS_SIMPLE( CControllerMap, vgui::Panel ) + + virtual void OnKeyCodeTyped( vgui::KeyCode code ); + +public: + CControllerMap( vgui::Panel *parent, const char *name ); + + virtual void ApplySettings( KeyValues *inResourceData ); + + int NumButtons( void ) + { + return m_buttonMap.Count(); + } + + const char *GetBindingText( int idx ); + const char *GetBindingIcon( int idx ); + +private: + + struct button_t + { + CUtlSymbol cmd; + CUtlSymbol text; + CUtlSymbol icon; + }; + CUtlMap< int, button_t > m_buttonMap; +}; + #endif // CONTROLLERMAP_H
\ No newline at end of file diff --git a/mp/src/public/vgui_controls/Controls.h b/mp/src/public/vgui_controls/Controls.h index 7a77abaa..0afb8ded 100644 --- a/mp/src/public/vgui_controls/Controls.h +++ b/mp/src/public/vgui_controls/Controls.h @@ -1,161 +1,161 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef CONTROLS_H
-#define CONTROLS_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui/IPanel.h>
-#include <vstdlib/IKeyValuesSystem.h>
-
-#include "tier1/interface.h"
-#include "vgui/MouseCode.h"
-#include "vgui/KeyCode.h"
-#include "tier3/tier3.h"
-
-
-namespace vgui
-{
-
-// handles the initialization of the vgui interfaces
-// interfaces (listed below) are first attempted to be loaded from primaryProvider, then secondaryProvider
-// moduleName should be the name of the module that this instance of the vgui_controls has been compiled into
-bool VGui_InitInterfacesList( const char *moduleName, CreateInterfaceFn *factoryList, int numFactories );
-
-// returns the name of the module as specified above
-const char *GetControlsModuleName();
-
-class IPanel;
-class IInput;
-class ISchemeManager;
-class ISurface;
-class ISystem;
-class IVGui;
-
-//-----------------------------------------------------------------------------
-// Backward compat interfaces, use the interfaces grabbed in tier3
-// set of accessor functions to vgui interfaces
-// the appropriate header file for each is listed above the item
-//-----------------------------------------------------------------------------
-
-// #include <vgui/IInput.h>
-inline vgui::IInput *input()
-{
- return g_pVGuiInput;
-}
-
-// #include <vgui/IScheme.h>
-inline vgui::ISchemeManager *scheme()
-{
- return g_pVGuiSchemeManager;
-}
-
-// #include <vgui/ISurface.h>
-inline vgui::ISurface *surface()
-{
- return g_pVGuiSurface;
-}
-
-// #include <vgui/ISystem.h>
-inline vgui::ISystem *system()
-{
- return g_pVGuiSystem;
-}
-
-// #include <vgui/IVGui.h>
-inline vgui::IVGui *ivgui()
-{
- return g_pVGui;
-}
-
-// #include <vgui/IPanel.h>
-inline vgui::IPanel *ipanel()
-{
- return g_pVGuiPanel;
-}
-
-// predeclare all the vgui control class names
-class AnalogBar;
-class AnimatingImagePanel;
-class AnimationController;
-class BuildModeDialog;
-class Button;
-class CheckButton;
-class CheckButtonList;
-class CircularProgressBar;
-template< class T >class CvarToggleCheckButton;
-class ComboBox;
-class DirectorySelectDialog;
-class Divider;
-class EditablePanel;
-class FileOpenDialog;
-class Frame;
-class GraphPanel;
-class HTML;
-class ImagePanel;
-class Label;
-class ListPanel;
-class ListViewPanel;
-class Menu;
-class MenuBar;
-class MenuButton;
-class MenuItem;
-class MessageBox;
-class Panel;
-class PanelListPanel;
-class ProgressBar;
-class ProgressBox;
-class PropertyDialog;
-class PropertyPage;
-class PropertySheet;
-class QueryBox;
-class RadioButton;
-class RichText;
-class ScalableImagePanel;
-class ScrollBar;
-class ScrollBarSlider;
-class SectionedListPanel;
-class Slider;
-class Splitter;
-class TextEntry;
-class ToggleButton;
-class BaseTooltip;
-class TextTooltip;
-class TreeView;
-class CTreeViewListControl;
-class URLLabel;
-class WizardPanel;
-class WizardSubPanel;
-
-// vgui controls helper classes
-class BuildGroup;
-class FocusNavGroup;
-class IBorder;
-class IImage;
-class Image;
-class ImageList;
-class TextImage;
-
-} // namespace vgui
-
-// hotkeys disabled until we work out exactly how we want to do them
-#define VGUI_HOTKEYS_ENABLED
-//#define VGUI_DRAW_HOTKEYS_ENABLED
-
-#define USING_BUILD_FACTORY( className ) \
- extern className *g_##className##LinkerHack; \
- className *g_##className##PullInModule = g_##className##LinkerHack;
-
-#define USING_BUILD_FACTORY_ALIAS( className, factoryName ) \
- extern className *g_##factoryName##LinkerHack; \
- className *g_##factoryName##PullInModule = g_##factoryName##LinkerHack;
-
-#endif // CONTROLS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef CONTROLS_H +#define CONTROLS_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui/IPanel.h> +#include <vstdlib/IKeyValuesSystem.h> + +#include "tier1/interface.h" +#include "vgui/MouseCode.h" +#include "vgui/KeyCode.h" +#include "tier3/tier3.h" + + +namespace vgui +{ + +// handles the initialization of the vgui interfaces +// interfaces (listed below) are first attempted to be loaded from primaryProvider, then secondaryProvider +// moduleName should be the name of the module that this instance of the vgui_controls has been compiled into +bool VGui_InitInterfacesList( const char *moduleName, CreateInterfaceFn *factoryList, int numFactories ); + +// returns the name of the module as specified above +const char *GetControlsModuleName(); + +class IPanel; +class IInput; +class ISchemeManager; +class ISurface; +class ISystem; +class IVGui; + +//----------------------------------------------------------------------------- +// Backward compat interfaces, use the interfaces grabbed in tier3 +// set of accessor functions to vgui interfaces +// the appropriate header file for each is listed above the item +//----------------------------------------------------------------------------- + +// #include <vgui/IInput.h> +inline vgui::IInput *input() +{ + return g_pVGuiInput; +} + +// #include <vgui/IScheme.h> +inline vgui::ISchemeManager *scheme() +{ + return g_pVGuiSchemeManager; +} + +// #include <vgui/ISurface.h> +inline vgui::ISurface *surface() +{ + return g_pVGuiSurface; +} + +// #include <vgui/ISystem.h> +inline vgui::ISystem *system() +{ + return g_pVGuiSystem; +} + +// #include <vgui/IVGui.h> +inline vgui::IVGui *ivgui() +{ + return g_pVGui; +} + +// #include <vgui/IPanel.h> +inline vgui::IPanel *ipanel() +{ + return g_pVGuiPanel; +} + +// predeclare all the vgui control class names +class AnalogBar; +class AnimatingImagePanel; +class AnimationController; +class BuildModeDialog; +class Button; +class CheckButton; +class CheckButtonList; +class CircularProgressBar; +template< class T >class CvarToggleCheckButton; +class ComboBox; +class DirectorySelectDialog; +class Divider; +class EditablePanel; +class FileOpenDialog; +class Frame; +class GraphPanel; +class HTML; +class ImagePanel; +class Label; +class ListPanel; +class ListViewPanel; +class Menu; +class MenuBar; +class MenuButton; +class MenuItem; +class MessageBox; +class Panel; +class PanelListPanel; +class ProgressBar; +class ProgressBox; +class PropertyDialog; +class PropertyPage; +class PropertySheet; +class QueryBox; +class RadioButton; +class RichText; +class ScalableImagePanel; +class ScrollBar; +class ScrollBarSlider; +class SectionedListPanel; +class Slider; +class Splitter; +class TextEntry; +class ToggleButton; +class BaseTooltip; +class TextTooltip; +class TreeView; +class CTreeViewListControl; +class URLLabel; +class WizardPanel; +class WizardSubPanel; + +// vgui controls helper classes +class BuildGroup; +class FocusNavGroup; +class IBorder; +class IImage; +class Image; +class ImageList; +class TextImage; + +} // namespace vgui + +// hotkeys disabled until we work out exactly how we want to do them +#define VGUI_HOTKEYS_ENABLED +//#define VGUI_DRAW_HOTKEYS_ENABLED + +#define USING_BUILD_FACTORY( className ) \ + extern className *g_##className##LinkerHack; \ + className *g_##className##PullInModule = g_##className##LinkerHack; + +#define USING_BUILD_FACTORY_ALIAS( className, factoryName ) \ + extern className *g_##factoryName##LinkerHack; \ + className *g_##factoryName##PullInModule = g_##factoryName##LinkerHack; + +#endif // CONTROLS_H diff --git a/mp/src/public/vgui_controls/DialogManager.h b/mp/src/public/vgui_controls/DialogManager.h index 5eee0dc7..5c376162 100644 --- a/mp/src/public/vgui_controls/DialogManager.h +++ b/mp/src/public/vgui_controls/DialogManager.h @@ -1,196 +1,196 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef DIALOGMANAGER_H
-#define DIALOGMANAGER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utllinkedlist.h>
-#include <KeyValues.h>
-#include <vgui_controls/PHandle.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: utility class, maps a set of ID's to dialogs
-// used to manage sets of similar dialogs (object property dialogs, etc.)
-//-----------------------------------------------------------------------------
-template <class TDialog, class I = int>
-class DialogManager
-{
-public:
- // new dialog factory function
- typedef TDialog *(*CreateNewDialogFunc_t)(I dialogID);
-
- // constructor
- DialogManager(CreateNewDialogFunc_t createDialogFunc);
-
- // finds the dialog by the specified ID
- TDialog *FindDialog(I dialogID, bool bCreate);
-
- // opens the dialog; creating it if specified
- TDialog *ActivateDialog(I dialogID, bool bCreate);
-
- // closes all the dialogs
- void CloseAll();
-
- // closes and deletes all the dialogs
- void CloseAndDeleteAll();
-
- // returns number of active dialogs
- int Count();
-
- // sets parent to use
- void SetParent( vgui::VPANEL parent );
-
-private:
- // checks if an index in the dialog list is valid; if it has been deleted, removes the entry
- bool ValidateIndex(int index);
-
- struct DialogItem_t
- {
- I id;
- DHANDLE<TDialog> dlg;
- };
-
- CUtlLinkedList<DialogItem_t, int> m_Dialogs;
- CreateNewDialogFunc_t m_CreateFunc;
- vgui::VPANEL m_pVGUIParentPanel;
-};
-
-
-// constructor
-template <class TDialog, class I>
-inline DialogManager<TDialog, I>::DialogManager(CreateNewDialogFunc_t createDialogFunc)
-{
- m_CreateFunc = createDialogFunc;
- m_pVGUIParentPanel = NULL;
-}
-
-// finds the dialog; creating it if necessary
-template <class TDialog, class I>
-inline TDialog *DialogManager<TDialog, I>::FindDialog(I dialogID, bool bCreate)
-{
- for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++)
- {
- if (ValidateIndex(i) && m_Dialogs[i].id == dialogID)
- {
- return m_Dialogs[i].dlg;
- }
- }
-
- if (bCreate)
- {
- int newIndex = m_Dialogs.AddToTail();
- if (m_CreateFunc)
- {
- m_Dialogs[newIndex].dlg = m_CreateFunc(dialogID);
- }
- else
- {
- m_Dialogs[newIndex].dlg = new TDialog(NULL, dialogID);
- }
- Assert(m_pVGUIParentPanel);
- m_Dialogs[newIndex].dlg->SetParent( m_pVGUIParentPanel );
-
- m_Dialogs[newIndex].id = dialogID;
- return m_Dialogs[newIndex].dlg;
- }
-
- // dlg not found, not created
- return NULL;
-}
-
-// opens the dialog; creating it if necessary
-template <class TDialog, class I>
-inline TDialog *DialogManager<TDialog, I>::ActivateDialog(I dialogID, bool bCreate)
-{
- TDialog *dlg = FindDialog(dialogID, bCreate);
- if (dlg)
- {
- dlg->Activate();
- }
- return dlg;
-}
-
-// count
-template <class TDialog, class I>
-inline int DialogManager<TDialog, I>::Count()
-{
- // validate all the indexes first
- for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++)
- {
- if (ValidateIndex(i))
- {
- }
- }
-
- // return the (remaining) count
- return m_Dialogs.Count();
-}
-
-// closes all the dialogs
-template <class TDialog, class I>
-inline void DialogManager<TDialog, I>::CloseAll()
-{
- for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++)
- {
- if (ValidateIndex(i))
- {
- m_Dialogs[i].dlg->PostMessage(m_Dialogs[i].dlg, new KeyValues("Close"));
- }
- }
-}
-
-// closes and deletes all the dialogs
-template <class TDialog, class I>
-inline void DialogManager<TDialog, I>::CloseAndDeleteAll()
-{
- CloseAll();
- for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++)
- {
- if (ValidateIndex(i))
- {
- m_Dialogs[i].dlg->MarkForDeletion();
- }
- }
- m_Dialogs.RemoveAll();
-}
-
-// checks if a dialog is valid; if it has been deleted, removes the entry
-template <class TDialog, class I>
-inline bool DialogManager<TDialog, I>::ValidateIndex(int index)
-{
- if (m_Dialogs.IsValidIndex(index))
- {
- if (m_Dialogs[index].dlg.Get())
- {
- return true;
- }
- else
- {
- // entry has been deleted; removed
- m_Dialogs.Remove(index);
- }
- }
- return false;
-}
-
-template <class TDialog, class I>
-inline void DialogManager<TDialog, I>::SetParent( vgui::VPANEL parent )
-{
- m_pVGUIParentPanel = parent;
-}
-
-
-} // namespace vgui
-
-#endif // DIALOGMANAGER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DIALOGMANAGER_H +#define DIALOGMANAGER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utllinkedlist.h> +#include <KeyValues.h> +#include <vgui_controls/PHandle.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: utility class, maps a set of ID's to dialogs +// used to manage sets of similar dialogs (object property dialogs, etc.) +//----------------------------------------------------------------------------- +template <class TDialog, class I = int> +class DialogManager +{ +public: + // new dialog factory function + typedef TDialog *(*CreateNewDialogFunc_t)(I dialogID); + + // constructor + DialogManager(CreateNewDialogFunc_t createDialogFunc); + + // finds the dialog by the specified ID + TDialog *FindDialog(I dialogID, bool bCreate); + + // opens the dialog; creating it if specified + TDialog *ActivateDialog(I dialogID, bool bCreate); + + // closes all the dialogs + void CloseAll(); + + // closes and deletes all the dialogs + void CloseAndDeleteAll(); + + // returns number of active dialogs + int Count(); + + // sets parent to use + void SetParent( vgui::VPANEL parent ); + +private: + // checks if an index in the dialog list is valid; if it has been deleted, removes the entry + bool ValidateIndex(int index); + + struct DialogItem_t + { + I id; + DHANDLE<TDialog> dlg; + }; + + CUtlLinkedList<DialogItem_t, int> m_Dialogs; + CreateNewDialogFunc_t m_CreateFunc; + vgui::VPANEL m_pVGUIParentPanel; +}; + + +// constructor +template <class TDialog, class I> +inline DialogManager<TDialog, I>::DialogManager(CreateNewDialogFunc_t createDialogFunc) +{ + m_CreateFunc = createDialogFunc; + m_pVGUIParentPanel = NULL; +} + +// finds the dialog; creating it if necessary +template <class TDialog, class I> +inline TDialog *DialogManager<TDialog, I>::FindDialog(I dialogID, bool bCreate) +{ + for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++) + { + if (ValidateIndex(i) && m_Dialogs[i].id == dialogID) + { + return m_Dialogs[i].dlg; + } + } + + if (bCreate) + { + int newIndex = m_Dialogs.AddToTail(); + if (m_CreateFunc) + { + m_Dialogs[newIndex].dlg = m_CreateFunc(dialogID); + } + else + { + m_Dialogs[newIndex].dlg = new TDialog(NULL, dialogID); + } + Assert(m_pVGUIParentPanel); + m_Dialogs[newIndex].dlg->SetParent( m_pVGUIParentPanel ); + + m_Dialogs[newIndex].id = dialogID; + return m_Dialogs[newIndex].dlg; + } + + // dlg not found, not created + return NULL; +} + +// opens the dialog; creating it if necessary +template <class TDialog, class I> +inline TDialog *DialogManager<TDialog, I>::ActivateDialog(I dialogID, bool bCreate) +{ + TDialog *dlg = FindDialog(dialogID, bCreate); + if (dlg) + { + dlg->Activate(); + } + return dlg; +} + +// count +template <class TDialog, class I> +inline int DialogManager<TDialog, I>::Count() +{ + // validate all the indexes first + for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++) + { + if (ValidateIndex(i)) + { + } + } + + // return the (remaining) count + return m_Dialogs.Count(); +} + +// closes all the dialogs +template <class TDialog, class I> +inline void DialogManager<TDialog, I>::CloseAll() +{ + for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++) + { + if (ValidateIndex(i)) + { + m_Dialogs[i].dlg->PostMessage(m_Dialogs[i].dlg, new KeyValues("Close")); + } + } +} + +// closes and deletes all the dialogs +template <class TDialog, class I> +inline void DialogManager<TDialog, I>::CloseAndDeleteAll() +{ + CloseAll(); + for (int i = 0; i < m_Dialogs.MaxElementIndex(); i++) + { + if (ValidateIndex(i)) + { + m_Dialogs[i].dlg->MarkForDeletion(); + } + } + m_Dialogs.RemoveAll(); +} + +// checks if a dialog is valid; if it has been deleted, removes the entry +template <class TDialog, class I> +inline bool DialogManager<TDialog, I>::ValidateIndex(int index) +{ + if (m_Dialogs.IsValidIndex(index)) + { + if (m_Dialogs[index].dlg.Get()) + { + return true; + } + else + { + // entry has been deleted; removed + m_Dialogs.Remove(index); + } + } + return false; +} + +template <class TDialog, class I> +inline void DialogManager<TDialog, I>::SetParent( vgui::VPANEL parent ) +{ + m_pVGUIParentPanel = parent; +} + + +} // namespace vgui + +#endif // DIALOGMANAGER_H diff --git a/mp/src/public/vgui_controls/DirectorySelectDialog.h b/mp/src/public/vgui_controls/DirectorySelectDialog.h index f970d271..f024d326 100644 --- a/mp/src/public/vgui_controls/DirectorySelectDialog.h +++ b/mp/src/public/vgui_controls/DirectorySelectDialog.h @@ -1,96 +1,96 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef DIRECTORYSELECTDIALOG_H
-#define DIRECTORYSELECTDIALOG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/TreeView.h>
-#include <vgui_controls/Frame.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Used to handle dynamically populating the tree view
-//-----------------------------------------------------------------------------
-class DirectoryTreeView : public TreeView
-{
-public:
- DirectoryTreeView(DirectorySelectDialog *parent, const char *name);
- virtual void GenerateChildrenOfNode(int itemIndex);
-
-private:
- DirectorySelectDialog *m_pParent;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Utility dialog, used to let user select a directory (like during install)
-//-----------------------------------------------------------------------------
-class DirectorySelectDialog : public Frame
-{
- DECLARE_CLASS_SIMPLE( DirectorySelectDialog, Frame );
-
-public:
- DirectorySelectDialog(vgui::Panel *parent, const char *title);
-
- // sets where it should start searching
- void SetStartDirectory(const char *path);
-
- // sets what name should show up by default in the create directory dialog
- void SetDefaultCreateDirectoryName(const char *defaultCreateDirName);
-
- // opens the dialog
- void DoModal();
-
- /* action signals
-
- "DirectorySelected"
- "dir" - the directory that was selected
-
- */
-
- // Expand the tree nodes to match a supplied path, optionally selecting the final directory
- void ExpandTreeToPath( const char *lpszPath, bool bSelectFinalDirectory = true );
-
-protected:
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnClose();
-
- // command buttons
- virtual void OnCommand(const char *command);
-
-private:
- MESSAGE_FUNC( OnTextChanged, "TextChanged" );
- MESSAGE_FUNC( OnTreeViewItemSelected, "TreeViewItemSelected" );
- MESSAGE_FUNC_CHARPTR( OnCreateDirectory, "CreateDirectory", dir );
- void BuildDirTree();
- void BuildDriveChoices();
- void ExpandTreeNode(const char *path, int parentNodeIndex);
- void GenerateChildrenOfDirectoryNode(int nodeIndex);
- void GenerateFullPathForNode(int nodeIndex, char *path, int pathBufferSize);
- bool DoesDirectoryHaveSubdirectories(const char *path, const char *dir);
-
- char m_szCurrentDir[512];
- char m_szDefaultCreateDirName[64];
- char m_szCurrentDrive[16];
- vgui::TreeView *m_pDirTree;
- vgui::ComboBox *m_pDriveCombo;
- vgui::Button *m_pCancelButton;
- vgui::Button *m_pSelectButton;
- vgui::Button *m_pCreateButton;
-
- friend class DirectoryTreeView;
-};
-
-} // namespace vgui
-
-
-#endif // DIRECTORYSELECTDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef DIRECTORYSELECTDIALOG_H +#define DIRECTORYSELECTDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Controls.h> +#include <vgui_controls/TreeView.h> +#include <vgui_controls/Frame.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Used to handle dynamically populating the tree view +//----------------------------------------------------------------------------- +class DirectoryTreeView : public TreeView +{ +public: + DirectoryTreeView(DirectorySelectDialog *parent, const char *name); + virtual void GenerateChildrenOfNode(int itemIndex); + +private: + DirectorySelectDialog *m_pParent; +}; + +//----------------------------------------------------------------------------- +// Purpose: Utility dialog, used to let user select a directory (like during install) +//----------------------------------------------------------------------------- +class DirectorySelectDialog : public Frame +{ + DECLARE_CLASS_SIMPLE( DirectorySelectDialog, Frame ); + +public: + DirectorySelectDialog(vgui::Panel *parent, const char *title); + + // sets where it should start searching + void SetStartDirectory(const char *path); + + // sets what name should show up by default in the create directory dialog + void SetDefaultCreateDirectoryName(const char *defaultCreateDirName); + + // opens the dialog + void DoModal(); + + /* action signals + + "DirectorySelected" + "dir" - the directory that was selected + + */ + + // Expand the tree nodes to match a supplied path, optionally selecting the final directory + void ExpandTreeToPath( const char *lpszPath, bool bSelectFinalDirectory = true ); + +protected: + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnClose(); + + // command buttons + virtual void OnCommand(const char *command); + +private: + MESSAGE_FUNC( OnTextChanged, "TextChanged" ); + MESSAGE_FUNC( OnTreeViewItemSelected, "TreeViewItemSelected" ); + MESSAGE_FUNC_CHARPTR( OnCreateDirectory, "CreateDirectory", dir ); + void BuildDirTree(); + void BuildDriveChoices(); + void ExpandTreeNode(const char *path, int parentNodeIndex); + void GenerateChildrenOfDirectoryNode(int nodeIndex); + void GenerateFullPathForNode(int nodeIndex, char *path, int pathBufferSize); + bool DoesDirectoryHaveSubdirectories(const char *path, const char *dir); + + char m_szCurrentDir[512]; + char m_szDefaultCreateDirName[64]; + char m_szCurrentDrive[16]; + vgui::TreeView *m_pDirTree; + vgui::ComboBox *m_pDriveCombo; + vgui::Button *m_pCancelButton; + vgui::Button *m_pSelectButton; + vgui::Button *m_pCreateButton; + + friend class DirectoryTreeView; +}; + +} // namespace vgui + + +#endif // DIRECTORYSELECTDIALOG_H diff --git a/mp/src/public/vgui_controls/Divider.h b/mp/src/public/vgui_controls/Divider.h index 2b5bca13..1c6e7b09 100644 --- a/mp/src/public/vgui_controls/Divider.h +++ b/mp/src/public/vgui_controls/Divider.h @@ -1,38 +1,38 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef DIVIDER_H
-#define DIVIDER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Thin line used to divide sections in dialogs
-//-----------------------------------------------------------------------------
-class Divider : public Panel
-{
- DECLARE_CLASS_SIMPLE( Divider, Panel );
-
-public:
- Divider(Panel *parent, const char *name);
- ~Divider();
-
- virtual void ApplySchemeSettings(IScheme *pScheme);
-};
-
-
-} // namespace vgui
-
-
-#endif // DIVIDER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef DIVIDER_H +#define DIVIDER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Thin line used to divide sections in dialogs +//----------------------------------------------------------------------------- +class Divider : public Panel +{ + DECLARE_CLASS_SIMPLE( Divider, Panel ); + +public: + Divider(Panel *parent, const char *name); + ~Divider(); + + virtual void ApplySchemeSettings(IScheme *pScheme); +}; + + +} // namespace vgui + + +#endif // DIVIDER_H diff --git a/mp/src/public/vgui_controls/EditablePanel.h b/mp/src/public/vgui_controls/EditablePanel.h index 3530d7a2..11b8e768 100644 --- a/mp/src/public/vgui_controls/EditablePanel.h +++ b/mp/src/public/vgui_controls/EditablePanel.h @@ -1,163 +1,163 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef EDITABLEPANEL_H
-#define EDITABLEPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/FocusNavGroup.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Panel that supports editing via the build dialog
-//-----------------------------------------------------------------------------
-class EditablePanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( EditablePanel, Panel );
-
-public:
- EditablePanel(Panel *parent, const char *panelName);
- EditablePanel(Panel *parent, const char *panelName, HScheme hScheme);
-
- virtual ~EditablePanel();
-
- // Load the control settings - should be done after all the children are added
- // If you pass in pPreloadedKeyValues, it won't actually load the file. That way, you can cache
- // the keyvalues outside of here if you want to prevent file accesses in the middle of the game.
- virtual void LoadControlSettings(const char *dialogResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL);
- virtual void ApplySettings(KeyValues *inResourceData);
-
- // sets the name of this dialog so it can be saved in the user config area
- // use dialogID to differentiate multiple instances of the same dialog
- virtual void LoadUserConfig(const char *configName, int dialogID = 0);
- virtual void SaveUserConfig();
-
- // combines both of the above, LoadControlSettings & LoadUserConfig
- virtual void LoadControlSettingsAndUserConfig(const char *dialogResourceName, int dialogID = 0);
-
- // Override to change how build mode is activated
- virtual void ActivateBuildMode();
-
- // Return the buildgroup that this panel is part of.
- virtual BuildGroup *GetBuildGroup();
-
- // Virtual factory for control creation
- // controlName is a string which is the same as the class name
- virtual Panel *CreateControlByName(const char *controlName);
-
- // Shortcut function to set data in child controls
- virtual void SetControlString(const char *controlName, const char *string);
- // Shortcut function to set data in child controls
- virtual void SetControlString(const char *controlName, const wchar_t *string);
- // Shortcut function to set data in child controls
- virtual void SetControlInt(const char *controlName, int state);
- // Shortcut function to get data in child controls
- virtual int GetControlInt(const char *controlName, int defaultState);
- // Shortcut function to get data in child controls
- // Returns a maximum of 511 characters in the string
- virtual const char *GetControlString(const char *controlName, const char *defaultString = "");
- // as above, but copies the result into the specified buffer instead of a static buffer
- virtual void GetControlString(const char *controlName, char *buf, int bufSize, const char *defaultString = "");
- // sets the enabled state of a control
- virtual void SetControlEnabled(const char *controlName, bool enabled);
- virtual void SetControlVisible(const char *controlName, bool visible);
-
- // localization variables (used in constructing UI strings)
- // after the variable is set, causes all the necessary sub-panels to update
- virtual void SetDialogVariable(const char *varName, const char *value);
- virtual void SetDialogVariable(const char *varName, const wchar_t *value);
- virtual void SetDialogVariable(const char *varName, int value);
- virtual void SetDialogVariable(const char *varName, float value);
-
- // Focus handling
- // Delegate focus to a sub panel
- virtual void RequestFocus(int direction = 0);
- virtual bool RequestFocusNext(VPANEL panel);
- virtual bool RequestFocusPrev(VPANEL panel);
- // Pass the focus down onto the last used panel
- virtual void OnSetFocus();
- // Update focus info for navigation
- virtual void OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel);
- // Get the panel that currently has keyfocus
- virtual VPANEL GetCurrentKeyFocus();
- // Get the panel with the specified hotkey
- virtual Panel *HasHotkey(wchar_t key);
-
- virtual void OnKeyCodePressed( KeyCode code );
-
- // Handle information requests
- virtual bool RequestInfo(KeyValues *data);
- /* INFO HANDLING
- "BuildDialog"
- input:
- "BuildGroupPtr" - pointer to the panel/dialog to edit
- returns:
- "PanelPtr" - pointer to a new BuildModeDialog()
-
- "ControlFactory"
- input:
- "ControlName" - class name of the control to create
- returns:
- "PanelPtr" - pointer to the newly created panel, or NULL if no such class exists
- */
- // registers a file in the list of control settings, so the vgui dialog can choose between them to edit
- virtual void RegisterControlSettingsFile(const char *dialogResourceName, const char *pathID = NULL);
-
- // localization variables - only use this if you need to iterate the variables, use the SetLoc*() to set them
- KeyValues *GetDialogVariables();
-
-protected:
- virtual void PaintBackground();
-
- // nav group access
- virtual FocusNavGroup &GetFocusNavGroup();
-
- // called when default button has been set
- MESSAGE_FUNC_HANDLE( OnDefaultButtonSet, "DefaultButtonSet", button );
- // called when the current default button has been set
- MESSAGE_FUNC_HANDLE( OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button );
- MESSAGE_FUNC( OnFindDefaultButton, "FindDefaultButton" );
-
- // overrides
- virtual void OnChildAdded(VPANEL child);
- virtual void OnSizeChanged(int wide, int tall);
- virtual void OnClose();
-
- // user configuration settings
- // this is used for any control details the user wants saved between sessions
- // eg. dialog positions, last directory opened, list column width
- virtual void ApplyUserConfigSettings(KeyValues *userConfig);
-
- // returns user config settings for this control
- virtual void GetUserConfigSettings(KeyValues *userConfig);
-
- // optimization for text rendering, returns true if text should be rendered immediately after Paint()
- // disabled for now
- // virtual bool ShouldFlushText();
-
-private:
- void ForceSubPanelsToUpdateWithNewDialogVariables();
-
- BuildGroup *_buildGroup;
- FocusNavGroup m_NavGroup;
- KeyValues *m_pDialogVariables;
-
- // the wide and tall to which all controls are locked - used for autolayout deltas
- char *m_pszConfigName;
- int m_iConfigID;
- bool m_bShouldSkipAutoResize;
-};
-
-} // namespace vgui
-
-#endif // EDITABLEPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef EDITABLEPANEL_H +#define EDITABLEPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> +#include <vgui_controls/FocusNavGroup.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Panel that supports editing via the build dialog +//----------------------------------------------------------------------------- +class EditablePanel : public Panel +{ + DECLARE_CLASS_SIMPLE( EditablePanel, Panel ); + +public: + EditablePanel(Panel *parent, const char *panelName); + EditablePanel(Panel *parent, const char *panelName, HScheme hScheme); + + virtual ~EditablePanel(); + + // Load the control settings - should be done after all the children are added + // If you pass in pPreloadedKeyValues, it won't actually load the file. That way, you can cache + // the keyvalues outside of here if you want to prevent file accesses in the middle of the game. + virtual void LoadControlSettings(const char *dialogResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL); + virtual void ApplySettings(KeyValues *inResourceData); + + // sets the name of this dialog so it can be saved in the user config area + // use dialogID to differentiate multiple instances of the same dialog + virtual void LoadUserConfig(const char *configName, int dialogID = 0); + virtual void SaveUserConfig(); + + // combines both of the above, LoadControlSettings & LoadUserConfig + virtual void LoadControlSettingsAndUserConfig(const char *dialogResourceName, int dialogID = 0); + + // Override to change how build mode is activated + virtual void ActivateBuildMode(); + + // Return the buildgroup that this panel is part of. + virtual BuildGroup *GetBuildGroup(); + + // Virtual factory for control creation + // controlName is a string which is the same as the class name + virtual Panel *CreateControlByName(const char *controlName); + + // Shortcut function to set data in child controls + virtual void SetControlString(const char *controlName, const char *string); + // Shortcut function to set data in child controls + virtual void SetControlString(const char *controlName, const wchar_t *string); + // Shortcut function to set data in child controls + virtual void SetControlInt(const char *controlName, int state); + // Shortcut function to get data in child controls + virtual int GetControlInt(const char *controlName, int defaultState); + // Shortcut function to get data in child controls + // Returns a maximum of 511 characters in the string + virtual const char *GetControlString(const char *controlName, const char *defaultString = ""); + // as above, but copies the result into the specified buffer instead of a static buffer + virtual void GetControlString(const char *controlName, char *buf, int bufSize, const char *defaultString = ""); + // sets the enabled state of a control + virtual void SetControlEnabled(const char *controlName, bool enabled); + virtual void SetControlVisible(const char *controlName, bool visible); + + // localization variables (used in constructing UI strings) + // after the variable is set, causes all the necessary sub-panels to update + virtual void SetDialogVariable(const char *varName, const char *value); + virtual void SetDialogVariable(const char *varName, const wchar_t *value); + virtual void SetDialogVariable(const char *varName, int value); + virtual void SetDialogVariable(const char *varName, float value); + + // Focus handling + // Delegate focus to a sub panel + virtual void RequestFocus(int direction = 0); + virtual bool RequestFocusNext(VPANEL panel); + virtual bool RequestFocusPrev(VPANEL panel); + // Pass the focus down onto the last used panel + virtual void OnSetFocus(); + // Update focus info for navigation + virtual void OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel); + // Get the panel that currently has keyfocus + virtual VPANEL GetCurrentKeyFocus(); + // Get the panel with the specified hotkey + virtual Panel *HasHotkey(wchar_t key); + + virtual void OnKeyCodePressed( KeyCode code ); + + // Handle information requests + virtual bool RequestInfo(KeyValues *data); + /* INFO HANDLING + "BuildDialog" + input: + "BuildGroupPtr" - pointer to the panel/dialog to edit + returns: + "PanelPtr" - pointer to a new BuildModeDialog() + + "ControlFactory" + input: + "ControlName" - class name of the control to create + returns: + "PanelPtr" - pointer to the newly created panel, or NULL if no such class exists + */ + // registers a file in the list of control settings, so the vgui dialog can choose between them to edit + virtual void RegisterControlSettingsFile(const char *dialogResourceName, const char *pathID = NULL); + + // localization variables - only use this if you need to iterate the variables, use the SetLoc*() to set them + KeyValues *GetDialogVariables(); + +protected: + virtual void PaintBackground(); + + // nav group access + virtual FocusNavGroup &GetFocusNavGroup(); + + // called when default button has been set + MESSAGE_FUNC_HANDLE( OnDefaultButtonSet, "DefaultButtonSet", button ); + // called when the current default button has been set + MESSAGE_FUNC_HANDLE( OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button ); + MESSAGE_FUNC( OnFindDefaultButton, "FindDefaultButton" ); + + // overrides + virtual void OnChildAdded(VPANEL child); + virtual void OnSizeChanged(int wide, int tall); + virtual void OnClose(); + + // user configuration settings + // this is used for any control details the user wants saved between sessions + // eg. dialog positions, last directory opened, list column width + virtual void ApplyUserConfigSettings(KeyValues *userConfig); + + // returns user config settings for this control + virtual void GetUserConfigSettings(KeyValues *userConfig); + + // optimization for text rendering, returns true if text should be rendered immediately after Paint() + // disabled for now + // virtual bool ShouldFlushText(); + +private: + void ForceSubPanelsToUpdateWithNewDialogVariables(); + + BuildGroup *_buildGroup; + FocusNavGroup m_NavGroup; + KeyValues *m_pDialogVariables; + + // the wide and tall to which all controls are locked - used for autolayout deltas + char *m_pszConfigName; + int m_iConfigID; + bool m_bShouldSkipAutoResize; +}; + +} // namespace vgui + +#endif // EDITABLEPANEL_H diff --git a/mp/src/public/vgui_controls/ExpandButton.h b/mp/src/public/vgui_controls/ExpandButton.h index 6c89a4ff..2dbf8493 100644 --- a/mp/src/public/vgui_controls/ExpandButton.h +++ b/mp/src/public/vgui_controls/ExpandButton.h @@ -1,61 +1,61 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: A button with no borders that shows a left-pointing or down-pointing triangle
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef EXPANDBUTTON_H
-#define EXPANDBUTTON_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/ToggleButton.h>
-
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: A button with no borders that shows a left-pointing or down-pointing arrow
-//-----------------------------------------------------------------------------
-class ExpandButton : public ToggleButton
-{
- DECLARE_CLASS_SIMPLE( ExpandButton, ToggleButton );
-
-public:
- ExpandButton( Panel *parent, const char *panelName );
- ~ExpandButton();
-
- // Expand the button (selected == expanded)
- virtual void SetSelected( bool bExpand );
-
- // sets whether or not the state of the check can be changed
- // if this is set to false, then no input in the code or by the user can change it's state
- void SetExpandable(bool state);
-
- virtual void Paint();
-
-protected:
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_PTR( OnExpanded, "Expanded", panel );
-
- virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
-
- /* MESSAGES SENT
- "Expanded" - sent when the expand button state is changed
- "state" - button state: 1 is expanded, 0 is unexpanded
- */
-
-private:
- bool m_bExpandable;
- HFont m_hFont;
- Color m_Color;
-};
-
-} // namespace vgui
-
-#endif // EXPANDBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A button with no borders that shows a left-pointing or down-pointing triangle +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef EXPANDBUTTON_H +#define EXPANDBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/ToggleButton.h> + + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: A button with no borders that shows a left-pointing or down-pointing arrow +//----------------------------------------------------------------------------- +class ExpandButton : public ToggleButton +{ + DECLARE_CLASS_SIMPLE( ExpandButton, ToggleButton ); + +public: + ExpandButton( Panel *parent, const char *panelName ); + ~ExpandButton(); + + // Expand the button (selected == expanded) + virtual void SetSelected( bool bExpand ); + + // sets whether or not the state of the check can be changed + // if this is set to false, then no input in the code or by the user can change it's state + void SetExpandable(bool state); + + virtual void Paint(); + +protected: + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_PTR( OnExpanded, "Expanded", panel ); + + virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + + /* MESSAGES SENT + "Expanded" - sent when the expand button state is changed + "state" - button state: 1 is expanded, 0 is unexpanded + */ + +private: + bool m_bExpandable; + HFont m_hFont; + Color m_Color; +}; + +} // namespace vgui + +#endif // EXPANDBUTTON_H diff --git a/mp/src/public/vgui_controls/FileOpenDialog.h b/mp/src/public/vgui_controls/FileOpenDialog.h index 1e96177d..bcaccf0f 100644 --- a/mp/src/public/vgui_controls/FileOpenDialog.h +++ b/mp/src/public/vgui_controls/FileOpenDialog.h @@ -1,160 +1,160 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Declaration of FileOpenDialog class, a generic open/save as file dialog
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef FILEOPENDIALOG_H
-#define FILEOPENDIALOG_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/Frame.h"
-
-namespace vgui
-{
-
-class FileCompletionEdit; // local
-class InputDialog;
-
-//-----------------------------------------------------------------------------
-// Purpose: generic open/save as file dialog
-//-----------------------------------------------------------------------------
-enum FileOpenDialogType_t
-{
- FOD_SAVE = 0,
- FOD_OPEN,
- FOD_SELECT_DIRECTORY,
-};
-
-
-class FileOpenDialog : public vgui::Frame
-{
- DECLARE_CLASS_SIMPLE( FileOpenDialog, Frame );
-
-public:
- // NOTE: Backward compat constructor
- FileOpenDialog( Panel *parent, const char *title, bool bOpenFile, KeyValues *pContextKeyValues = 0 );
-
- // The context keyvalues are added to all messages sent by this dialog if they are specified
- FileOpenDialog( Panel *parent, const char *title, FileOpenDialogType_t type, KeyValues *pContextKeyValues = 0 );
- ~FileOpenDialog();
-
- // Set the directory the file search starts in
- void SetStartDirectory(const char *dir);
-
- // Sets the start directory context (and resets the start directory in the process)
- // NOTE: If you specify a startdir context, then if you've already opened
- // a file with that same start dir context before, it will start in the
- // same directory it ended up in.
- void SetStartDirectoryContext( const char *pContext, const char *pDefaultDir );
-
- // Add filters for the drop down combo box
- // The filter info, if specified, gets sent back to the app in the FileSelected message
- void AddFilter( const char *filter, const char *filterName, bool bActive, const char *pFilterInfo = NULL );
-
- // Activate the dialog
- // NOTE: The argument is there for backward compat
- void DoModal( bool bUnused = false );
-
- // Get the directory this is currently in
- void GetCurrentDirectory( char *buf, int bufSize );
-
- // Get the last selected file name
- void GetSelectedFileName( char *buf, int bufSize );
-
- /*
- messages sent:
- "FileSelected"
- "fullpath" // specifies the fullpath of the file
- "filterinfo" // Returns the filter info associated with the active filter
- "FileSelectionCancelled"
- */
-
-protected:
- virtual void OnCommand( const char *command );
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnClose();
- virtual void OnKeyCodeTyped(KeyCode code);
-
- // handles the open button being pressed
- // checks on what has changed and acts accordingly
- MESSAGE_FUNC( OnOpen, "OnOpen" );
- MESSAGE_FUNC( OnSelectFolder, "SelectFolder" );
- MESSAGE_FUNC( OnFolderUp, "OnFolderUp" );
- MESSAGE_FUNC( OnNewFolder, "OnNewFolder" );
- MESSAGE_FUNC( OnOpenInExplorer, "OpenInExplorer" );
-
- MESSAGE_FUNC( PopulateFileList, "PopulateFileList" );
- MESSAGE_FUNC( PopulateDriveList, "PopulateDriveList" );
- MESSAGE_FUNC( PopulateFileNameCompletion, "PopulateFileNameCompletion" );
-
- // moves the directory structure up
- virtual void MoveUpFolder();
-
- // validates that the current path is valid
- virtual void ValidatePath();
-
- // handles an item in the list being selected
- MESSAGE_FUNC( OnItemSelected, "ItemSelected" );
- MESSAGE_FUNC( OnListItemSelected, "ListItemSelected" )
- {
- OnItemSelected();
- }
-
- // changes directories in response to selecting drives from the combo box
- MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
-
- MESSAGE_FUNC( OnInputCanceled, "InputCanceled" );
- MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", data );
-
-private:
- // Necessary because we have 2 constructors
- void Init( const char *title, KeyValues *pContextKeyValues );
-
- // Does the specified extension match something in the filter list?
- bool ExtensionMatchesFilter( const char *pExt );
-
- // Choose the first non *.* filter in the filter list
- void ChooseExtension( char *pExt, int nBufLen );
-
- // Saves the file to the start dir context
- void SaveFileToStartDirContext( const char *pFullPath );
-
- // Posts a file selected message
- void PostFileSelectedMessage( const char *pFileName );
-
- // Creates a new folder
- void NewFolder( char const *folderName );
-
- vgui::ComboBox *m_pFullPathEdit;
- vgui::ListPanel *m_pFileList;
-
- FileCompletionEdit *m_pFileNameEdit;
-
- vgui::ComboBox *m_pFileTypeCombo;
- vgui::Button *m_pOpenButton;
- vgui::Button *m_pCancelButton;
- vgui::Button *m_pFolderUpButton;
- vgui::Button *m_pNewFolderButton;
- vgui::Button *m_pOpenInExplorerButton;
- vgui::ImagePanel *m_pFolderIcon;
- vgui::Label *m_pFileTypeLabel;
-
- KeyValues *m_pContextKeyValues;
-
- char m_szLastPath[1024];
- unsigned short m_nStartDirContext;
- FileOpenDialogType_t m_DialogType;
- bool m_bFileSelected : 1;
-
- VPANEL m_SaveModal;
- vgui::DHANDLE< vgui::InputDialog > m_hInputDialog;
-};
-
-} // namespace vgui
-
-#endif // FILEOPENDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Declaration of FileOpenDialog class, a generic open/save as file dialog +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef FILEOPENDIALOG_H +#define FILEOPENDIALOG_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Frame.h" + +namespace vgui +{ + +class FileCompletionEdit; // local +class InputDialog; + +//----------------------------------------------------------------------------- +// Purpose: generic open/save as file dialog +//----------------------------------------------------------------------------- +enum FileOpenDialogType_t +{ + FOD_SAVE = 0, + FOD_OPEN, + FOD_SELECT_DIRECTORY, +}; + + +class FileOpenDialog : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( FileOpenDialog, Frame ); + +public: + // NOTE: Backward compat constructor + FileOpenDialog( Panel *parent, const char *title, bool bOpenFile, KeyValues *pContextKeyValues = 0 ); + + // The context keyvalues are added to all messages sent by this dialog if they are specified + FileOpenDialog( Panel *parent, const char *title, FileOpenDialogType_t type, KeyValues *pContextKeyValues = 0 ); + ~FileOpenDialog(); + + // Set the directory the file search starts in + void SetStartDirectory(const char *dir); + + // Sets the start directory context (and resets the start directory in the process) + // NOTE: If you specify a startdir context, then if you've already opened + // a file with that same start dir context before, it will start in the + // same directory it ended up in. + void SetStartDirectoryContext( const char *pContext, const char *pDefaultDir ); + + // Add filters for the drop down combo box + // The filter info, if specified, gets sent back to the app in the FileSelected message + void AddFilter( const char *filter, const char *filterName, bool bActive, const char *pFilterInfo = NULL ); + + // Activate the dialog + // NOTE: The argument is there for backward compat + void DoModal( bool bUnused = false ); + + // Get the directory this is currently in + void GetCurrentDirectory( char *buf, int bufSize ); + + // Get the last selected file name + void GetSelectedFileName( char *buf, int bufSize ); + + /* + messages sent: + "FileSelected" + "fullpath" // specifies the fullpath of the file + "filterinfo" // Returns the filter info associated with the active filter + "FileSelectionCancelled" + */ + +protected: + virtual void OnCommand( const char *command ); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnClose(); + virtual void OnKeyCodeTyped(KeyCode code); + + // handles the open button being pressed + // checks on what has changed and acts accordingly + MESSAGE_FUNC( OnOpen, "OnOpen" ); + MESSAGE_FUNC( OnSelectFolder, "SelectFolder" ); + MESSAGE_FUNC( OnFolderUp, "OnFolderUp" ); + MESSAGE_FUNC( OnNewFolder, "OnNewFolder" ); + MESSAGE_FUNC( OnOpenInExplorer, "OpenInExplorer" ); + + MESSAGE_FUNC( PopulateFileList, "PopulateFileList" ); + MESSAGE_FUNC( PopulateDriveList, "PopulateDriveList" ); + MESSAGE_FUNC( PopulateFileNameCompletion, "PopulateFileNameCompletion" ); + + // moves the directory structure up + virtual void MoveUpFolder(); + + // validates that the current path is valid + virtual void ValidatePath(); + + // handles an item in the list being selected + MESSAGE_FUNC( OnItemSelected, "ItemSelected" ); + MESSAGE_FUNC( OnListItemSelected, "ListItemSelected" ) + { + OnItemSelected(); + } + + // changes directories in response to selecting drives from the combo box + MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv ); + + MESSAGE_FUNC( OnInputCanceled, "InputCanceled" ); + MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", data ); + +private: + // Necessary because we have 2 constructors + void Init( const char *title, KeyValues *pContextKeyValues ); + + // Does the specified extension match something in the filter list? + bool ExtensionMatchesFilter( const char *pExt ); + + // Choose the first non *.* filter in the filter list + void ChooseExtension( char *pExt, int nBufLen ); + + // Saves the file to the start dir context + void SaveFileToStartDirContext( const char *pFullPath ); + + // Posts a file selected message + void PostFileSelectedMessage( const char *pFileName ); + + // Creates a new folder + void NewFolder( char const *folderName ); + + vgui::ComboBox *m_pFullPathEdit; + vgui::ListPanel *m_pFileList; + + FileCompletionEdit *m_pFileNameEdit; + + vgui::ComboBox *m_pFileTypeCombo; + vgui::Button *m_pOpenButton; + vgui::Button *m_pCancelButton; + vgui::Button *m_pFolderUpButton; + vgui::Button *m_pNewFolderButton; + vgui::Button *m_pOpenInExplorerButton; + vgui::ImagePanel *m_pFolderIcon; + vgui::Label *m_pFileTypeLabel; + + KeyValues *m_pContextKeyValues; + + char m_szLastPath[1024]; + unsigned short m_nStartDirContext; + FileOpenDialogType_t m_DialogType; + bool m_bFileSelected : 1; + + VPANEL m_SaveModal; + vgui::DHANDLE< vgui::InputDialog > m_hInputDialog; +}; + +} // namespace vgui + +#endif // FILEOPENDIALOG_H diff --git a/mp/src/public/vgui_controls/FileOpenStateMachine.h b/mp/src/public/vgui_controls/FileOpenStateMachine.h index bfbea715..4fb327cb 100644 --- a/mp/src/public/vgui_controls/FileOpenStateMachine.h +++ b/mp/src/public/vgui_controls/FileOpenStateMachine.h @@ -1,172 +1,172 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// This is a helper class designed to help with the chains of modal dialogs
-// encountered when trying to open or save a particular file
-//
-//=============================================================================
-
-#ifndef FILEOPENSTATEMACHINE_H
-#define FILEOPENSTATEMACHINE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/Panel.h"
-#include "tier1/utlstring.h"
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Interface for things using the file open state machine
-//-----------------------------------------------------------------------------
-abstract_class IFileOpenStateMachineClient
-{
-public:
- // Called by to allow clients to set up the save dialog
- virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues ) = 0;
-
- // Called by to allow clients to actually read the file in
- virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues ) = 0;
-
- // Called by to allow clients to actually write the file out
- virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues ) = 0;
-};
-
-
-//-----------------------------------------------------------------------------
-// This is a helper class designed to help with chains of modal dialogs
-//-----------------------------------------------------------------------------
-enum FileOpenStateMachineFlags_t
-{
- FOSM_SHOW_PERFORCE_DIALOGS = 0x1,
- FOSM_SHOW_SAVE_QUERY = 0x2,
-};
-
-class FileOpenStateMachine : public Panel
-{
- DECLARE_CLASS_SIMPLE( FileOpenStateMachine, Panel );
-
-public:
- enum CompletionState_t
- {
- IN_PROGRESS = 0, // Still not finished, not successful or error
- SUCCESSFUL, // Operation finished successfully
- FILE_SAVE_CANCELLED, // The user chose 'cancel' in the dialog asking if he wanted to save
- FILE_SAVE_NAME_NOT_SPECIFIED, // User hit cancel in the SaveAs dialog
- FILE_NOT_OVERWRITTEN, // Operation aborted; existed file and user chose to not write over it
- FILE_NOT_CHECKED_OUT, // Operation aborted; file wasn't checked out so couldn't be written over
- ERROR_WRITING_FILE, // Error occurred writing the file out
- ERROR_MAKING_FILE_WRITEABLE, // Error occurred when making the file writeable
- FILE_NOT_MADE_WRITEABLE, // User chose to not make the file be writeable
- FILE_OPEN_NAME_NOT_SPECIFIED, // User hit cancel in the Open dialog
- ERROR_READING_FILE, // Error occurred reading the file in
- };
-
- FileOpenStateMachine( vgui::Panel *pParent, IFileOpenStateMachineClient *pClient );
- virtual ~FileOpenStateMachine();
-
- // Opens a file, saves an existing one if necessary
- void OpenFile( const char *pOpenFileType, KeyValues *pContextKeyValues, const char *pSaveFileName = NULL, const char *pSaveFileType = NULL, int nFlags = 0 );
-
- // Version of OpenFile that skips browsing for a particular file to open
- void OpenFile( const char *pOpenFileName, const char *pOpenFileType, KeyValues *pContextKeyValues, const char *pSaveFileName = NULL, const char *pSaveFileType = NULL, int nFlags = 0 );
-
- // Used to save a specified file, and deal with all the lovely dialogs
- // Pass in NULL to get a dialog to choose a filename to save
- void SaveFile( KeyValues *pContextKeyValues, const char *pFileName, const char *pFileType, int nFlags = FOSM_SHOW_PERFORCE_DIALOGS );
-
- // Returns the state machine completion state
- CompletionState_t GetCompletionState();
-
- /* MESSAGES SENT
- "FileStateMachineFinished" - Called when we exit the state machine for any reason
- "completionState" - See the CompletionState_t enum above
- "wroteFile" - Indicates whether a file was written or not
- "fullPath" - Indicates the full path of the file read for OpenFile or written for SaveFile
- "fileType" - Indicates the file type of the file read for OpenFile or written for SaveFile
- Use GetFirstTrueSubKey() to get the context passed into the OpenFile/SaveFile methods
- */
-
-private:
- enum FOSMState_t
- {
- STATE_NONE = -1,
- STATE_SHOWING_SAVE_DIRTY_FILE_DIALOG = 0,
- STATE_SHOWING_SAVE_DIALOG,
- STATE_SHOWING_OVERWRITE_DIALOG,
- STATE_SHOWING_CHECK_OUT_DIALOG,
- STATE_SHOWING_MAKE_FILE_WRITEABLE_DIALOG,
- STATE_WRITING_FILE,
- STATE_SHOWING_PERFORCE_ADD_DIALOG,
- STATE_SHOWING_OPEN_DIALOG,
- STATE_READING_FILE,
- };
-
- MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", pKeyValues );
- MESSAGE_FUNC( OnFileSelectionCancelled, "FileSelectionCancelled" );
- MESSAGE_FUNC_PARAMS( OnPerforceQueryCompleted, "PerforceQueryCompleted", pKeyValues );
- MESSAGE_FUNC( OnMakeFileWriteable, "MakeFileWriteable" );
- MESSAGE_FUNC( OnCancelMakeFileWriteable, "CancelMakeFileWriteable" );
-
- // These messages are related to the dialog in OverwriteFileDialog
- MESSAGE_FUNC( OnOverwriteFile, "OverwriteFile" );
- MESSAGE_FUNC( OnCancelOverwriteFile, "CancelOverwriteFile" );
-
- // These messages come from the savedocumentquery dialog
- MESSAGE_FUNC( OnSaveFile, "OnSaveFile" );
- MESSAGE_FUNC( OnMarkNotDirty, "OnMarkNotDirty" );
- MESSAGE_FUNC( OnCancelSaveDocument, "OnCancelSaveDocument" );
-
- // Cleans up keyvalues
- void CleanUpContextKeyValues();
-
- // Utility to set the completion state
- void SetCompletionState( CompletionState_t state );
-
- // Show the save document query dialog
- void ShowSaveQuery( );
-
- // Shows the overwrite existing file dialog
- void OverwriteFileDialog( );
-
- // Shows the open file for edit dialog
- void CheckOutDialog( );
-
- // Shows the make file writeable dialog
- void MakeFileWriteableDialog( );
-
- // Writes the file out
- void WriteFile();
-
- // Shows the open file dialog
- void OpenFileDialog( );
-
- // Reads the file in
- void ReadFile();
-
- IFileOpenStateMachineClient *m_pClient;
- KeyValues *m_pContextKeyValues;
- FOSMState_t m_CurrentState;
- CompletionState_t m_CompletionState;
- CUtlString m_FileName;
- CUtlString m_SaveFileType;
- CUtlString m_OpenFileType;
- CUtlString m_OpenFileName;
- bool m_bShowPerforceDialogs : 1;
- bool m_bShowSaveQuery : 1;
- bool m_bIsOpeningFile : 1;
- bool m_bWroteFile : 1;
-};
-
-} // end namespace vgui
-
-
-
-#endif // FILEOPENSTATEMACHINE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// This is a helper class designed to help with the chains of modal dialogs +// encountered when trying to open or save a particular file +// +//============================================================================= + +#ifndef FILEOPENSTATEMACHINE_H +#define FILEOPENSTATEMACHINE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Panel.h" +#include "tier1/utlstring.h" + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- + + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Interface for things using the file open state machine +//----------------------------------------------------------------------------- +abstract_class IFileOpenStateMachineClient +{ +public: + // Called by to allow clients to set up the save dialog + virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues ) = 0; + + // Called by to allow clients to actually read the file in + virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues ) = 0; + + // Called by to allow clients to actually write the file out + virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues ) = 0; +}; + + +//----------------------------------------------------------------------------- +// This is a helper class designed to help with chains of modal dialogs +//----------------------------------------------------------------------------- +enum FileOpenStateMachineFlags_t +{ + FOSM_SHOW_PERFORCE_DIALOGS = 0x1, + FOSM_SHOW_SAVE_QUERY = 0x2, +}; + +class FileOpenStateMachine : public Panel +{ + DECLARE_CLASS_SIMPLE( FileOpenStateMachine, Panel ); + +public: + enum CompletionState_t + { + IN_PROGRESS = 0, // Still not finished, not successful or error + SUCCESSFUL, // Operation finished successfully + FILE_SAVE_CANCELLED, // The user chose 'cancel' in the dialog asking if he wanted to save + FILE_SAVE_NAME_NOT_SPECIFIED, // User hit cancel in the SaveAs dialog + FILE_NOT_OVERWRITTEN, // Operation aborted; existed file and user chose to not write over it + FILE_NOT_CHECKED_OUT, // Operation aborted; file wasn't checked out so couldn't be written over + ERROR_WRITING_FILE, // Error occurred writing the file out + ERROR_MAKING_FILE_WRITEABLE, // Error occurred when making the file writeable + FILE_NOT_MADE_WRITEABLE, // User chose to not make the file be writeable + FILE_OPEN_NAME_NOT_SPECIFIED, // User hit cancel in the Open dialog + ERROR_READING_FILE, // Error occurred reading the file in + }; + + FileOpenStateMachine( vgui::Panel *pParent, IFileOpenStateMachineClient *pClient ); + virtual ~FileOpenStateMachine(); + + // Opens a file, saves an existing one if necessary + void OpenFile( const char *pOpenFileType, KeyValues *pContextKeyValues, const char *pSaveFileName = NULL, const char *pSaveFileType = NULL, int nFlags = 0 ); + + // Version of OpenFile that skips browsing for a particular file to open + void OpenFile( const char *pOpenFileName, const char *pOpenFileType, KeyValues *pContextKeyValues, const char *pSaveFileName = NULL, const char *pSaveFileType = NULL, int nFlags = 0 ); + + // Used to save a specified file, and deal with all the lovely dialogs + // Pass in NULL to get a dialog to choose a filename to save + void SaveFile( KeyValues *pContextKeyValues, const char *pFileName, const char *pFileType, int nFlags = FOSM_SHOW_PERFORCE_DIALOGS ); + + // Returns the state machine completion state + CompletionState_t GetCompletionState(); + + /* MESSAGES SENT + "FileStateMachineFinished" - Called when we exit the state machine for any reason + "completionState" - See the CompletionState_t enum above + "wroteFile" - Indicates whether a file was written or not + "fullPath" - Indicates the full path of the file read for OpenFile or written for SaveFile + "fileType" - Indicates the file type of the file read for OpenFile or written for SaveFile + Use GetFirstTrueSubKey() to get the context passed into the OpenFile/SaveFile methods + */ + +private: + enum FOSMState_t + { + STATE_NONE = -1, + STATE_SHOWING_SAVE_DIRTY_FILE_DIALOG = 0, + STATE_SHOWING_SAVE_DIALOG, + STATE_SHOWING_OVERWRITE_DIALOG, + STATE_SHOWING_CHECK_OUT_DIALOG, + STATE_SHOWING_MAKE_FILE_WRITEABLE_DIALOG, + STATE_WRITING_FILE, + STATE_SHOWING_PERFORCE_ADD_DIALOG, + STATE_SHOWING_OPEN_DIALOG, + STATE_READING_FILE, + }; + + MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", pKeyValues ); + MESSAGE_FUNC( OnFileSelectionCancelled, "FileSelectionCancelled" ); + MESSAGE_FUNC_PARAMS( OnPerforceQueryCompleted, "PerforceQueryCompleted", pKeyValues ); + MESSAGE_FUNC( OnMakeFileWriteable, "MakeFileWriteable" ); + MESSAGE_FUNC( OnCancelMakeFileWriteable, "CancelMakeFileWriteable" ); + + // These messages are related to the dialog in OverwriteFileDialog + MESSAGE_FUNC( OnOverwriteFile, "OverwriteFile" ); + MESSAGE_FUNC( OnCancelOverwriteFile, "CancelOverwriteFile" ); + + // These messages come from the savedocumentquery dialog + MESSAGE_FUNC( OnSaveFile, "OnSaveFile" ); + MESSAGE_FUNC( OnMarkNotDirty, "OnMarkNotDirty" ); + MESSAGE_FUNC( OnCancelSaveDocument, "OnCancelSaveDocument" ); + + // Cleans up keyvalues + void CleanUpContextKeyValues(); + + // Utility to set the completion state + void SetCompletionState( CompletionState_t state ); + + // Show the save document query dialog + void ShowSaveQuery( ); + + // Shows the overwrite existing file dialog + void OverwriteFileDialog( ); + + // Shows the open file for edit dialog + void CheckOutDialog( ); + + // Shows the make file writeable dialog + void MakeFileWriteableDialog( ); + + // Writes the file out + void WriteFile(); + + // Shows the open file dialog + void OpenFileDialog( ); + + // Reads the file in + void ReadFile(); + + IFileOpenStateMachineClient *m_pClient; + KeyValues *m_pContextKeyValues; + FOSMState_t m_CurrentState; + CompletionState_t m_CompletionState; + CUtlString m_FileName; + CUtlString m_SaveFileType; + CUtlString m_OpenFileType; + CUtlString m_OpenFileName; + bool m_bShowPerforceDialogs : 1; + bool m_bShowSaveQuery : 1; + bool m_bIsOpeningFile : 1; + bool m_bWroteFile : 1; +}; + +} // end namespace vgui + + + +#endif // FILEOPENSTATEMACHINE_H diff --git a/mp/src/public/vgui_controls/FocusNavGroup.h b/mp/src/public/vgui_controls/FocusNavGroup.h index e0b2b5a7..2d743512 100644 --- a/mp/src/public/vgui_controls/FocusNavGroup.h +++ b/mp/src/public/vgui_controls/FocusNavGroup.h @@ -1,61 +1,61 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef FOCUSNAVGROUP_H
-#define FOCUSNAVGROUP_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/PHandle.h>
-
-namespace vgui
-{
-
-class Panel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Handles navigation through a set of panels, with tab order & hotkeys
-//-----------------------------------------------------------------------------
-class FocusNavGroup
-{
-public:
- FocusNavGroup(Panel *panel);
- ~FocusNavGroup();
- virtual Panel *GetDefaultPanel(); // returns a pointer to the panel with the default focus
-
- virtual void SetDefaultButton(Panel *panel); // sets which panel should receive input when ENTER is hit
- virtual VPANEL GetDefaultButton(); // panel which receives default input when ENTER is hit, if current focused item cannot accept ENTER
- virtual VPANEL GetCurrentDefaultButton(); // panel which receives input when ENTER is hit
- virtual Panel *FindPanelByHotkey(wchar_t key); // finds the panel which is activated by the specified key
- virtual bool RequestFocusPrev(VPANEL panel = NULL); // if panel is NULL, then the tab increment is based last known panel that had key focus
- virtual bool RequestFocusNext(VPANEL panel = NULL);
-
- virtual Panel *GetCurrentFocus();
- virtual VPANEL SetCurrentFocus(VPANEL panel, VPANEL defaultPanel); // returns the Default panel
-
- // sets the panel that owns this FocusNavGroup to be the root in the focus traversal heirarchy
- // focus change via KEY_TAB will only travel to children of this main panel
- virtual void SetFocusTopLevel(bool state);
-
- virtual void SetCurrentDefaultButton(VPANEL panel, bool sendCurrentDefaultButtonMessage = true);
-private:
- bool CanButtonBeDefault(VPANEL panel);
-
- VPanelHandle _defaultButton;
- VPanelHandle _currentDefaultButton;
- VPanelHandle _currentFocus;
-
- Panel *_mainPanel;
- bool _topLevelFocus;
-};
-
-} // namespace vgui
-
-#endif // FOCUSNAVGROUP_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef FOCUSNAVGROUP_H +#define FOCUSNAVGROUP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/PHandle.h> + +namespace vgui +{ + +class Panel; + +//----------------------------------------------------------------------------- +// Purpose: Handles navigation through a set of panels, with tab order & hotkeys +//----------------------------------------------------------------------------- +class FocusNavGroup +{ +public: + FocusNavGroup(Panel *panel); + ~FocusNavGroup(); + virtual Panel *GetDefaultPanel(); // returns a pointer to the panel with the default focus + + virtual void SetDefaultButton(Panel *panel); // sets which panel should receive input when ENTER is hit + virtual VPANEL GetDefaultButton(); // panel which receives default input when ENTER is hit, if current focused item cannot accept ENTER + virtual VPANEL GetCurrentDefaultButton(); // panel which receives input when ENTER is hit + virtual Panel *FindPanelByHotkey(wchar_t key); // finds the panel which is activated by the specified key + virtual bool RequestFocusPrev(VPANEL panel = NULL); // if panel is NULL, then the tab increment is based last known panel that had key focus + virtual bool RequestFocusNext(VPANEL panel = NULL); + + virtual Panel *GetCurrentFocus(); + virtual VPANEL SetCurrentFocus(VPANEL panel, VPANEL defaultPanel); // returns the Default panel + + // sets the panel that owns this FocusNavGroup to be the root in the focus traversal heirarchy + // focus change via KEY_TAB will only travel to children of this main panel + virtual void SetFocusTopLevel(bool state); + + virtual void SetCurrentDefaultButton(VPANEL panel, bool sendCurrentDefaultButtonMessage = true); +private: + bool CanButtonBeDefault(VPANEL panel); + + VPanelHandle _defaultButton; + VPanelHandle _currentDefaultButton; + VPanelHandle _currentFocus; + + Panel *_mainPanel; + bool _topLevelFocus; +}; + +} // namespace vgui + +#endif // FOCUSNAVGROUP_H diff --git a/mp/src/public/vgui_controls/Frame.h b/mp/src/public/vgui_controls/Frame.h index d5ce4a99..0485a374 100644 --- a/mp/src/public/vgui_controls/Frame.h +++ b/mp/src/public/vgui_controls/Frame.h @@ -1,260 +1,260 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef VGUI_FRAME_H
-#define VGUI_FRAME_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui/Dar.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/EditablePanel.h>
-#include <vgui_controls/FocusNavGroup.h>
-
-namespace vgui
-{
-
-class FrameButton;
-class FrameSystemButton;
-
-//-----------------------------------------------------------------------------
-// Purpose: Windowed frame
-//-----------------------------------------------------------------------------
-class Frame : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( Frame, EditablePanel );
-
-public:
- Frame(Panel *parent, const char *panelName, bool showTaskbarIcon = true, bool bPopup = true );
- virtual ~Frame();
-
- // Set the text in the title bar. Set surfaceTitle=true if you want this to be the taskbar text as well.
- virtual void SetTitle(const char *title, bool surfaceTitle);
- virtual void SetTitle(const wchar_t *title, bool surfaceTitle);
-
- // Bring the frame to the front and requests focus, ensures it's not minimized
- virtual void Activate();
-
- // activates the dialog; if dialog is not currently visible it starts it minimized and flashing in the taskbar
- virtual void ActivateMinimized();
-
- // closes the dialog
- MESSAGE_FUNC( Close, "Close" );
- MESSAGE_FUNC( CloseModal, "CloseModal" );
-
- // sets the dialog to delete self on close
- virtual void SetDeleteSelfOnClose( bool state );
-
- // Move the dialog to the center of the screen
- virtual void MoveToCenterOfScreen();
-
- // Set the movability of the panel
- virtual void SetMoveable(bool state);
- // Check the movability of the panel
- virtual bool IsMoveable();
-
- // Set the resizability of the panel
- virtual void SetSizeable(bool state);
- // Check the resizability of the panel
- virtual bool IsSizeable();
- // Toggle visibility of the system menu button
- virtual void SetMenuButtonVisible(bool state);
- void SetMenuButtonResponsive(bool state);
-
- // Toggle visibility of the minimize button
- virtual void SetMinimizeButtonVisible(bool state);
- // Toggle visibility of the maximize button
- virtual void SetMaximizeButtonVisible(bool state);
- // Toggles visibility of the minimize-to-systray icon (defaults to false)
- virtual void SetMinimizeToSysTrayButtonVisible(bool state);
-
- // Toggle visibility of the close button
- virtual void SetCloseButtonVisible(bool state);
-
- // returns true if the dialog is currently minimized
- virtual bool IsMinimized();
- // Flash the window system tray button until the frame gets focus
- virtual void FlashWindow();
- // Stops any window flashing
- virtual void FlashWindowStop();
- // command handling
- virtual void OnCommand(const char *command);
-
- // Get the system menu
- virtual Menu *GetSysMenu();
- // Set the system menu
- virtual void SetSysMenu(Menu *menu);
-
- // Set the system menu images
- void SetImages( const char *pEnabledImage, const char *pDisabledImage = NULL );
-
- // set whether the title bar should be rendered
- virtual void SetTitleBarVisible( bool state );
-
- // When moving via caption, don't let any part of window go outside parent's bounds
- virtual void SetClipToParent( bool state );
- virtual bool GetClipToParent() const;
-
- // Set to true to make the caption height small
- virtual void SetSmallCaption( bool state );
- virtual bool IsSmallCaption() const;
-
- virtual int GetDraggerSize();
- virtual int GetCornerSize();
- virtual int GetBottomRightSize();
- virtual int GetCaptionHeight();
-
- /* CUSTOM MESSAGE HANDLING
- "SetTitle"
- input: "text" - string to set the title to be
- */
-
- // Load the control settings
- virtual void LoadControlSettings( const char *dialogResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL );
-
- void SetChainKeysToParent( bool state );
- bool CanChainKeysToParent() const;
-
- // Shows the dialog in a modal fashion
- virtual void DoModal();
-
- void PlaceUnderCursor( );
-
- // Disables the fade-in/out-effect even if configured in the scheme settings
- void DisableFadeEffect( void );
-
- // Temporarily enables or disables the fade effect rather than zeroing the fade times as done in DisableFadeEffect
- void SetFadeEffectDisableOverride( bool disabled );
-
-protected:
- // Respond to mouse presses
- virtual void OnMousePressed(MouseCode code);
- // Respond to Key typing
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void OnKeyTyped(wchar_t unichar);
- // Respond to Key releases
- virtual void OnKeyCodeReleased(KeyCode code);
- // Respond to Key focus ticks
- virtual void OnKeyFocusTicked();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- // Recalculate the position of all items
- virtual void PerformLayout();
- // Respond when a close message is recieved. Can be called directly to close a frame.
- virtual void OnClose();
- // Respond to a window finishing its closure. i.e. when a fading window has fully finished its fadeout.
- virtual void OnFinishedClose();
- // Minimize the window on the taskbar.
- MESSAGE_FUNC( OnMinimize, "Minimize" );
- // Called when minimize-to-systray button is pressed (does nothing by default)
- virtual void OnMinimizeToSysTray();
- // the frame close button was pressed
- MESSAGE_FUNC( OnCloseFrameButtonPressed, "CloseFrameButtonPressed" );
- // Add the child to the focus nav group
- virtual void OnChildAdded(VPANEL child);
- // settings
- virtual void ApplySettings(KeyValues *inResourceData);
- // records the settings into the resource data
- virtual void GetSettings(KeyValues *outResourceData);
- virtual const char *GetDescription( void );
-
- // gets the default position and size on the screen to appear the first time (defaults to centered)
- virtual bool GetDefaultScreenPosition(int &x, int &y, int &wide, int &tall);
-
- // painting
- virtual void PaintBackground();
-
- // per-frame thinking, used for transition effects
- virtual void OnThink();
-
- // screen size
- virtual void OnScreenSizeChanged(int iOldWide, int iOldTall);
-
- // Get the size of the panel inside the frame edges.
- virtual void GetClientArea(int &x, int &y, int &wide, int &tall);
-
- // user configuration settings
- // this is used for any control details the user wants saved between sessions
- // eg. dialog positions, last directory opened, list column width
- virtual void ApplyUserConfigSettings(KeyValues *userConfig);
-
- // returns user config settings for this control
- virtual void GetUserConfigSettings(KeyValues *userConfig);
-
- // optimization, return true if this control has any user config settings
- virtual bool HasUserConfigSettings();
-
-private:
- MESSAGE_FUNC_CHARPTR( InternalSetTitle, "SetTitle", text );
- MESSAGE_FUNC( InternalFlashWindow, "FlashWindow" );
- MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
-
- void SetupResizeCursors();
- void LayoutProportional( FrameButton *bt);
- void FinishClose();
- void OnFrameFocusChanged(bool bHasFocus);
-
- Color _titleBarBgColor;
- Color _titleBarDisabledBgColor;
- Color _titleBarFgColor;
- Color _titleBarDisabledFgColor;
- Color m_InFocusBgColor;
- Color m_OutOfFocusBgColor;
- TextImage *_title;
-
-#if !defined( _X360 )
- Panel *_topGrip;
- Panel *_bottomGrip;
- Panel *_leftGrip;
- Panel *_rightGrip;
- Panel *_topLeftGrip;
- Panel *_topRightGrip;
- Panel *_bottomLeftGrip;
- Panel *_bottomRightGrip;
- Panel *_captionGrip;
- FrameButton *_minimizeButton;
- FrameButton *_maximizeButton;
- FrameButton *_minimizeToSysTrayButton;
- FrameButton *_closeButton;
- FrameSystemButton *_menuButton;
- Menu *_sysMenu;
-#endif
-
- float m_flTransitionEffectTime;
- float m_flFocusTransitionEffectTime;
- int m_iClientInsetX;
- int m_iClientInsetY;
- int m_iTitleTextInsetX;
- int m_nGripperWidth;
- VPANEL m_hPreviousModal;
- HFont m_hCustomTitleFont;
-
- bool _sizeable : 1;
- bool _moveable : 1;
- bool m_bHasFocus : 1;
- bool _flashWindow : 1;
- bool _nextFlashState : 1;
- bool _drawTitleBar : 1;
- bool m_bPreviouslyVisible : 1;
- bool m_bFadingOut : 1;
- bool m_bDeleteSelfOnClose : 1;
- bool m_bDisableFadeEffect : 1;
- bool m_bClipToParent : 1;
- bool m_bSmallCaption : 1;
- bool m_bChainKeysToParent : 1;
- bool m_bPrimed : 1;
- bool m_iClientInsetXOverridden : 1;
-
- CPanelAnimationVarAliasType( int, m_iTitleTextInsetXOverride, "titletextinsetX", "0", "proportional_int" );
- CPanelAnimationVar( int, m_iTitleTextInsetYOverride, "titletextinsetY", "0" );
-};
-
-} // namespace vgui
-
-#endif // VGUI_FRAME_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef VGUI_FRAME_H +#define VGUI_FRAME_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui/Dar.h> +#include <vgui_controls/Panel.h> +#include <vgui_controls/EditablePanel.h> +#include <vgui_controls/FocusNavGroup.h> + +namespace vgui +{ + +class FrameButton; +class FrameSystemButton; + +//----------------------------------------------------------------------------- +// Purpose: Windowed frame +//----------------------------------------------------------------------------- +class Frame : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( Frame, EditablePanel ); + +public: + Frame(Panel *parent, const char *panelName, bool showTaskbarIcon = true, bool bPopup = true ); + virtual ~Frame(); + + // Set the text in the title bar. Set surfaceTitle=true if you want this to be the taskbar text as well. + virtual void SetTitle(const char *title, bool surfaceTitle); + virtual void SetTitle(const wchar_t *title, bool surfaceTitle); + + // Bring the frame to the front and requests focus, ensures it's not minimized + virtual void Activate(); + + // activates the dialog; if dialog is not currently visible it starts it minimized and flashing in the taskbar + virtual void ActivateMinimized(); + + // closes the dialog + MESSAGE_FUNC( Close, "Close" ); + MESSAGE_FUNC( CloseModal, "CloseModal" ); + + // sets the dialog to delete self on close + virtual void SetDeleteSelfOnClose( bool state ); + + // Move the dialog to the center of the screen + virtual void MoveToCenterOfScreen(); + + // Set the movability of the panel + virtual void SetMoveable(bool state); + // Check the movability of the panel + virtual bool IsMoveable(); + + // Set the resizability of the panel + virtual void SetSizeable(bool state); + // Check the resizability of the panel + virtual bool IsSizeable(); + // Toggle visibility of the system menu button + virtual void SetMenuButtonVisible(bool state); + void SetMenuButtonResponsive(bool state); + + // Toggle visibility of the minimize button + virtual void SetMinimizeButtonVisible(bool state); + // Toggle visibility of the maximize button + virtual void SetMaximizeButtonVisible(bool state); + // Toggles visibility of the minimize-to-systray icon (defaults to false) + virtual void SetMinimizeToSysTrayButtonVisible(bool state); + + // Toggle visibility of the close button + virtual void SetCloseButtonVisible(bool state); + + // returns true if the dialog is currently minimized + virtual bool IsMinimized(); + // Flash the window system tray button until the frame gets focus + virtual void FlashWindow(); + // Stops any window flashing + virtual void FlashWindowStop(); + // command handling + virtual void OnCommand(const char *command); + + // Get the system menu + virtual Menu *GetSysMenu(); + // Set the system menu + virtual void SetSysMenu(Menu *menu); + + // Set the system menu images + void SetImages( const char *pEnabledImage, const char *pDisabledImage = NULL ); + + // set whether the title bar should be rendered + virtual void SetTitleBarVisible( bool state ); + + // When moving via caption, don't let any part of window go outside parent's bounds + virtual void SetClipToParent( bool state ); + virtual bool GetClipToParent() const; + + // Set to true to make the caption height small + virtual void SetSmallCaption( bool state ); + virtual bool IsSmallCaption() const; + + virtual int GetDraggerSize(); + virtual int GetCornerSize(); + virtual int GetBottomRightSize(); + virtual int GetCaptionHeight(); + + /* CUSTOM MESSAGE HANDLING + "SetTitle" + input: "text" - string to set the title to be + */ + + // Load the control settings + virtual void LoadControlSettings( const char *dialogResourceName, const char *pathID = NULL, KeyValues *pPreloadedKeyValues = NULL, KeyValues *pConditions = NULL ); + + void SetChainKeysToParent( bool state ); + bool CanChainKeysToParent() const; + + // Shows the dialog in a modal fashion + virtual void DoModal(); + + void PlaceUnderCursor( ); + + // Disables the fade-in/out-effect even if configured in the scheme settings + void DisableFadeEffect( void ); + + // Temporarily enables or disables the fade effect rather than zeroing the fade times as done in DisableFadeEffect + void SetFadeEffectDisableOverride( bool disabled ); + +protected: + // Respond to mouse presses + virtual void OnMousePressed(MouseCode code); + // Respond to Key typing + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnKeyTyped(wchar_t unichar); + // Respond to Key releases + virtual void OnKeyCodeReleased(KeyCode code); + // Respond to Key focus ticks + virtual void OnKeyFocusTicked(); + virtual void ApplySchemeSettings(IScheme *pScheme); + // Recalculate the position of all items + virtual void PerformLayout(); + // Respond when a close message is recieved. Can be called directly to close a frame. + virtual void OnClose(); + // Respond to a window finishing its closure. i.e. when a fading window has fully finished its fadeout. + virtual void OnFinishedClose(); + // Minimize the window on the taskbar. + MESSAGE_FUNC( OnMinimize, "Minimize" ); + // Called when minimize-to-systray button is pressed (does nothing by default) + virtual void OnMinimizeToSysTray(); + // the frame close button was pressed + MESSAGE_FUNC( OnCloseFrameButtonPressed, "CloseFrameButtonPressed" ); + // Add the child to the focus nav group + virtual void OnChildAdded(VPANEL child); + // settings + virtual void ApplySettings(KeyValues *inResourceData); + // records the settings into the resource data + virtual void GetSettings(KeyValues *outResourceData); + virtual const char *GetDescription( void ); + + // gets the default position and size on the screen to appear the first time (defaults to centered) + virtual bool GetDefaultScreenPosition(int &x, int &y, int &wide, int &tall); + + // painting + virtual void PaintBackground(); + + // per-frame thinking, used for transition effects + virtual void OnThink(); + + // screen size + virtual void OnScreenSizeChanged(int iOldWide, int iOldTall); + + // Get the size of the panel inside the frame edges. + virtual void GetClientArea(int &x, int &y, int &wide, int &tall); + + // user configuration settings + // this is used for any control details the user wants saved between sessions + // eg. dialog positions, last directory opened, list column width + virtual void ApplyUserConfigSettings(KeyValues *userConfig); + + // returns user config settings for this control + virtual void GetUserConfigSettings(KeyValues *userConfig); + + // optimization, return true if this control has any user config settings + virtual bool HasUserConfigSettings(); + +private: + MESSAGE_FUNC_CHARPTR( InternalSetTitle, "SetTitle", text ); + MESSAGE_FUNC( InternalFlashWindow, "FlashWindow" ); + MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables ); + + void SetupResizeCursors(); + void LayoutProportional( FrameButton *bt); + void FinishClose(); + void OnFrameFocusChanged(bool bHasFocus); + + Color _titleBarBgColor; + Color _titleBarDisabledBgColor; + Color _titleBarFgColor; + Color _titleBarDisabledFgColor; + Color m_InFocusBgColor; + Color m_OutOfFocusBgColor; + TextImage *_title; + +#if !defined( _X360 ) + Panel *_topGrip; + Panel *_bottomGrip; + Panel *_leftGrip; + Panel *_rightGrip; + Panel *_topLeftGrip; + Panel *_topRightGrip; + Panel *_bottomLeftGrip; + Panel *_bottomRightGrip; + Panel *_captionGrip; + FrameButton *_minimizeButton; + FrameButton *_maximizeButton; + FrameButton *_minimizeToSysTrayButton; + FrameButton *_closeButton; + FrameSystemButton *_menuButton; + Menu *_sysMenu; +#endif + + float m_flTransitionEffectTime; + float m_flFocusTransitionEffectTime; + int m_iClientInsetX; + int m_iClientInsetY; + int m_iTitleTextInsetX; + int m_nGripperWidth; + VPANEL m_hPreviousModal; + HFont m_hCustomTitleFont; + + bool _sizeable : 1; + bool _moveable : 1; + bool m_bHasFocus : 1; + bool _flashWindow : 1; + bool _nextFlashState : 1; + bool _drawTitleBar : 1; + bool m_bPreviouslyVisible : 1; + bool m_bFadingOut : 1; + bool m_bDeleteSelfOnClose : 1; + bool m_bDisableFadeEffect : 1; + bool m_bClipToParent : 1; + bool m_bSmallCaption : 1; + bool m_bChainKeysToParent : 1; + bool m_bPrimed : 1; + bool m_iClientInsetXOverridden : 1; + + CPanelAnimationVarAliasType( int, m_iTitleTextInsetXOverride, "titletextinsetX", "0", "proportional_int" ); + CPanelAnimationVar( int, m_iTitleTextInsetYOverride, "titletextinsetY", "0" ); +}; + +} // namespace vgui + +#endif // VGUI_FRAME_H diff --git a/mp/src/public/vgui_controls/GraphPanel.h b/mp/src/public/vgui_controls/GraphPanel.h index fbb1dc3e..e2c2bfe4 100644 --- a/mp/src/public/vgui_controls/GraphPanel.h +++ b/mp/src/public/vgui_controls/GraphPanel.h @@ -1,81 +1,81 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef GRAPHPANEL_H
-#define GRAPHPANEL_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-#include "utllinkedlist.h"
-#include "utlvector.h"
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Holds and displays a chart
-//-----------------------------------------------------------------------------
-class GraphPanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( GraphPanel, Panel );
-
-public:
- GraphPanel(Panel *parent, const char *name);
-
- // domain settings (x-axis settings)
- // sets the window of samples to display
- void SetDisplayDomainSize(float size);
- // sets the range of samples the graph should keep
- // should be set to the max you would set the display domain size
- void SetMaxDomainSize(float size);
- // sets the minimum domain that will be displayed; used to collapse samples
- void SetMinDomainSize(float size);
-
- // range settings (y-axis settings)
- void SetUseFixedRange(float lowRange, float highRange);
- void SetUseDynamicRange(float *rangeList, int numRanges);
- void GetDisplayedRange(float &lowRange, float &highRange);
-
- // adds an item to the end of the list
- // sampleEnd is assumed to be the trailing edge of the sample
- // assumes that the samples are fairly evenly spaced (not much more work to do to fix this though)
- void AddItem(float sampleEnd, float sampleValue);
-
-protected:
- virtual void Paint();
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
-private:
- int GetVisibleItemCount();
-
- struct Sample_t
- {
- float sampleEnd;
- float value;
- };
- CUtlLinkedList<Sample_t, int> m_Samples;
-
- // the window to show
- float m_flDomainSize;
- float m_flMaxDomainSize, m_flMinDomainSize;
- bool m_bMaxDomainSizeSet;
-
- // range
- float m_flLowRange, m_flHighRange;
- bool m_bUseDynamicRange;
- CUtlVector<float> m_RangeList;
-
- // rendering
- int m_iGraphBarWidth;
- int m_iGraphBarGapWidth;
-};
-
-} // namespace vgui
-
-#endif // GRAPHPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef GRAPHPANEL_H +#define GRAPHPANEL_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> +#include "utllinkedlist.h" +#include "utlvector.h" + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Holds and displays a chart +//----------------------------------------------------------------------------- +class GraphPanel : public Panel +{ + DECLARE_CLASS_SIMPLE( GraphPanel, Panel ); + +public: + GraphPanel(Panel *parent, const char *name); + + // domain settings (x-axis settings) + // sets the window of samples to display + void SetDisplayDomainSize(float size); + // sets the range of samples the graph should keep + // should be set to the max you would set the display domain size + void SetMaxDomainSize(float size); + // sets the minimum domain that will be displayed; used to collapse samples + void SetMinDomainSize(float size); + + // range settings (y-axis settings) + void SetUseFixedRange(float lowRange, float highRange); + void SetUseDynamicRange(float *rangeList, int numRanges); + void GetDisplayedRange(float &lowRange, float &highRange); + + // adds an item to the end of the list + // sampleEnd is assumed to be the trailing edge of the sample + // assumes that the samples are fairly evenly spaced (not much more work to do to fix this though) + void AddItem(float sampleEnd, float sampleValue); + +protected: + virtual void Paint(); + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + +private: + int GetVisibleItemCount(); + + struct Sample_t + { + float sampleEnd; + float value; + }; + CUtlLinkedList<Sample_t, int> m_Samples; + + // the window to show + float m_flDomainSize; + float m_flMaxDomainSize, m_flMinDomainSize; + bool m_bMaxDomainSizeSet; + + // range + float m_flLowRange, m_flHighRange; + bool m_bUseDynamicRange; + CUtlVector<float> m_RangeList; + + // rendering + int m_iGraphBarWidth; + int m_iGraphBarGapWidth; +}; + +} // namespace vgui + +#endif // GRAPHPANEL_H diff --git a/mp/src/public/vgui_controls/HTML.h b/mp/src/public/vgui_controls/HTML.h index 3eed7694..5306c533 100644 --- a/mp/src/public/vgui_controls/HTML.h +++ b/mp/src/public/vgui_controls/HTML.h @@ -1,348 +1,348 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Creates a HTML control
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef HTML_H
-#define HTML_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui/IImage.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/PHandle.h>
-#include <vgui_controls/FileOpenDialog.h>
-#include <vgui_controls/TextEntry.h>
-#include <html/ihtmlchrome.h>
-#include <tier1/utlmap.h>
-
-class HTMLComboBoxHost;
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Control to display HTML content
-// This control utilises a hidden IE window to render a HTML page for you.
-// It can load any valid URL (i.e local files or web pages), you cannot dynamically change the
-// content however (internally to the control that is).
-//-----------------------------------------------------------------------------
-class HTML: public Panel, public IHTMLResponses
-{
- DECLARE_CLASS_SIMPLE( HTML, Panel );
- // TODO::STYLE
- //DECLARE_STYLE_BASE( "HTML" );
-public:
-
- HTML(Panel *parent,const char *name, bool allowJavaScript = false, bool bPopupWindow = false);
- ~HTML();
-
- // IHTML pass through functions
- virtual void OpenURL( const char *URL, const char *pchPostData, bool bForce = false );
- virtual bool StopLoading();
- virtual bool Refresh();
- virtual void OnMove();
- virtual void RunJavascript( const char *pchScript );
- virtual void GoBack();
- virtual void GoForward();
- virtual bool BCanGoBack();
- virtual bool BCanGoFoward();
-
- // event functions you can override and specialize behavior of
- virtual bool OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect );
- virtual void OnFinishRequest(const char *url, const char *pageTitle, const CUtlMap < CUtlString, CUtlString > &headers ) {}
- virtual void OnSetHTMLTitle( const char *pchTitle ) {}
- virtual void OnLinkAtPosition( const char *pchURL ) {}
- virtual void OnURLChanged( const char *url, const char *pchPostData, bool bIsRedirect ) {}
-
- virtual bool OnOpenNewTab( const char *pchURL, bool bForeground ) { return false; }
-
- // configuration
- virtual void SetScrollbarsEnabled(bool state);
- virtual void SetContextMenuEnabled(bool state);
- virtual void SetViewSourceEnabled( bool state );
- virtual void NewWindowsOnly( bool state );
-
- bool IsScrolledToBottom();
- bool IsScrollbarVisible();
-
- // url handlers, lets you have web page links fire vgui events
- // use to have custom web page links, eg. "steam://open/subscriptionpage"
- // message contains "CustomURL", "url"
- virtual void AddCustomURLHandler(const char *customProtocolName, vgui::Panel *target);
-
- // overridden to paint our special web browser texture
- virtual void Paint();
-
- // pass messages to the texture component to tell it about resizes
- virtual void OnSizeChanged(int wide,int tall);
-
- // pass mouse clicks through
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseReleased(MouseCode code);
- virtual void OnCursorMoved(int x,int y);
- virtual void OnMouseDoublePressed(MouseCode code);
- virtual void OnKeyTyped(wchar_t unichar);
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void OnKeyCodeReleased(KeyCode code);
- virtual void PerformLayout();
- virtual void OnMouseWheeled(int delta);
- virtual void PostChildPaint();
-
- /* message posting:
-
- "HTMLSliderMoved" - indicates the scrollbar has moved
-
- "OnURLChanged" - indicates a new URL is being loaded
- "url"
- "postdata"
-
- "OnFinishRequest" - indicates all url loaded has completed
-
- "HTMLBackRequested" - mouse4 has been pressed on the dialog
- "HTMLForwardRequested" - mouse5 has been pressed on the dialog
-
- "SecurityStatus" - indicates the SSL status of the page (disabled,good,bad)
- "url"
- "secure" - true if an ssl page
- "certerror" - true if there is a cert error loading the page
- "isevcert" - true if this is an EV style cert
- "certname" - name of the entity this cert is issued to
- */
-
- MESSAGE_FUNC_INT( OnSetCursorVGUI, "SetCursor", cursor );
-
- virtual void OnCommand( const char *pchCommand );
-
- void AddHeader( const char *pchHeader, const char *pchValue );
- void OnKillFocus();
- void OnSetFocus();
-
- void Find( const char *pchSubStr );
- void StopFind();
- void FindNext();
- void FindPrevious();
- void ShowFindDialog();
- void HideFindDialog();
- bool FindDialogVisible();
- int HorizontalScrollMax() { return m_scrollHorizontal.m_nMax; }
- int VerticalScrollMax() { return m_scrollVertical.m_nMax; }
-
- void GetLinkAtPosition( int x, int y );
-
- void HidePopup();
-
-#ifdef DBGFLAG_VALIDATE
- virtual void Validate( CValidator &validator, const char *pchName )
- {
- ValidateObj( m_CustomURLHandlers );
- BaseClass::Validate( validator, pchName );
- }
-#endif // DBGFLAG_VALIDATE
-
- void PaintComboBox();
- int BrowserGetIndex() { return m_iBrowser; }
-protected:
- virtual void ApplySchemeSettings( IScheme *pScheme );
-
- friend class HTMLComboBoxHost;
- vgui::Menu *m_pContextMenu;
-
-private:
- // IHTMLResponses callbacks from the browser engine
- virtual void BrowserSetIndex( int idx ) { m_iBrowser = idx; BrowserResize(); SendPendingHTMLMessages(); }
- virtual void BrowserReady( const CMsgBrowserReady *pCmd );
- virtual void BrowserNeedsPaint( const CMsgNeedsPaint *pCmd );
- virtual void BrowserStartRequest( const CMsgStartRequest *pCmd );
- virtual void BrowserURLChanged( const CMsgURLChanged *pCmd );
- virtual void BrowserFinishedRequest( const CMsgFinishedRequest *pCmd );
- virtual void BrowserShowPopup( const CMsgShowPopup *pCmd );
- virtual void BrowserHidePopup( const CMsgHidePopup *pCmd );
- virtual void BrowserOpenNewTab( const CMsgOpenNewTab *pCmd );
- virtual void BrowserPopupHTMLWindow( const CMsgPopupHTMLWindow *pCmd );
- virtual void BrowserSetHTMLTitle( const CMsgSetHTMLTitle *pCmd );
- virtual void BrowserLoadingResource( const CMsgLoadingResource *pCmd );
- virtual void BrowserStatusText( const CMsgStatusText *pCmd );
- virtual void BrowserSetCursor( const CMsgSetCursor *pCmd );
- virtual void BrowserFileLoadDialog( const CMsgFileLoadDialog *pCmd );
- virtual void BrowserShowToolTip( const CMsgShowToolTip *pCmd );
- virtual void BrowserUpdateToolTip( const CMsgUpdateToolTip *pCmd );
- virtual void BrowserHideToolTip( const CMsgHideToolTip *pCmd );
- virtual void BrowserSearchResults( const CMsgSearchResults *pCmd );
- virtual void BrowserClose( const CMsgClose *pCmd );
- virtual void BrowserHorizontalScrollBarSizeResponse( const CMsgHorizontalScrollBarSizeResponse *pCmd );
- virtual void BrowserVerticalScrollBarSizeResponse( const CMsgVerticalScrollBarSizeResponse *pCmd );
- virtual void BrowserGetZoomResponse( const CMsgGetZoomResponse *pCmd );
- virtual void BrowserLinkAtPositionResponse( const CMsgLinkAtPositionResponse *pCmd );
- virtual void BrowserZoomToElementAtPositionResponse( const CMsgZoomToElementAtPositionResponse *pCmd );
- virtual void BrowserJSAlert( const CMsgJSAlert *pCmd );
- virtual void BrowserJSConfirm( const CMsgJSConfirm *pCmd );
- virtual void BrowserCanGoBackandForward( const CMsgCanGoBackAndForward *pCmd );
- virtual void BrowserOpenSteamURL( const CMsgOpenSteamURL *pCmd );
- virtual void BrowserSizePopup( const CMsgSizePopup *pCmd );
- void SendPendingHTMLMessages();
- /*virtual void BrowserResourceResponse( const CMsgResourceResponse *pCmd );*/
- virtual void BrowserScalePageToValueResponse( const CMsgScalePageToValueResponse *pCmd ){}
- virtual void BrowserRequestFullScreen( const CMsgRequestFullScreen *pCmd ) {}
- virtual void BrowserExitFullScreen( const CMsgExitFullScreen *pCmd ) {}
- virtual void BrowserGetCookiesForURLResponse( const CMsgGetCookiesForURLResponse *pCmd ){}
- virtual void BrowserNodeGotFocus( const CMsgNodeHasFocus *pCmd ){}
- virtual void BrowserSavePageToJPEGResponse( const CMsgSavePageToJPEGResponse *pCmd ) {}
- virtual void BrowserFocusedNodeValueResponse( const CMsgFocusedNodeTextResponse *pCmd ) {}
-
- virtual void _DeserializeAndDispatch( HTMLCommandBuffer_t *pCmd );
-
- void PostURL(const char *URL, const char *pchPostData, bool force);
- virtual void BrowserResize();
- virtual void CalcScrollBars(int w,int h);
- void UpdateSizeAndScrollBars();
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" );
- MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
- MESSAGE_FUNC( OnFileSelectionCancelled, "FileSelectionCancelled" );
- MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
- MESSAGE_FUNC_PTR( OnEditNewLine, "TextNewLine", panel );
- MESSAGE_FUNC_INT( DismissJSDialog, "DismissJSDialog", result );
-
- void UpdateCachedHTMLValues();
-
- vgui::Panel *m_pInteriorPanel;
- vgui::ScrollBar *_hbar,*_vbar;
- vgui::DHANDLE<vgui::FileOpenDialog> m_hFileOpenDialog;
- class CHTMLFindBar : public vgui::EditablePanel
- {
- DECLARE_CLASS_SIMPLE( CHTMLFindBar, EditablePanel );
- public:
- CHTMLFindBar( HTML *parent );
- void SetText( const char *pchText ) { m_pFindBar->SetText( pchText ); }
- void GetText( char *pText, int ccText ) { m_pFindBar->GetText( pText, ccText ); }
- void OnCommand( const char *pchCmd );
- void ShowCountLabel() { m_pFindCountLabel->SetVisible( true ); }
- void HideCountLabel() { m_pFindCountLabel->SetVisible( false ); }
- void SetHidden( bool bState ) { m_bHidden = bState; }
- bool BIsHidden() { return m_bHidden; }
-
- private:
- vgui::TextEntry *m_pFindBar;
- vgui::HTML *m_pParent;
- vgui::Label *m_pFindCountLabel;
- bool m_bHidden;
- };
-
- CHTMLFindBar *m_pFindBar;
- HTMLComboBoxHost *m_pComboBoxHost;
-
- int m_iMouseX,m_iMouseY; // where the mouse is on the control
-
- int m_iScrollBorderX,m_iScrollBorderY;
- int m_iWideLastHTMLSize, m_iTalLastHTMLSize;
- int m_iCopyLinkMenuItemID;
-
- bool m_bScrollBarEnabled;
- bool m_bContextMenuEnabled;
- int m_iScrollbarSize;
- bool m_bNewWindowsOnly;
- int m_nViewSourceAllowedIndex;
- CUtlString m_sDragURL;
- int m_iDragStartX, m_iDragStartY;
-
- struct CustomURLHandler_t
- {
- PHandle hPanel;
- char url[32];
- };
- CUtlVector<CustomURLHandler_t> m_CustomURLHandlers;
-
- int m_iBrowser; // our browser handle
- int m_iHTMLTextureID; // vgui texture id
- // Track the texture width and height requested so we can tell
- // when the size has changed and reallocate the texture.
- int m_allocedTextureWidth;
- int m_allocedTextureHeight;
- int m_iComboBoxTextureID; // vgui texture id of the combo box
- bool m_bNeedsFullTextureUpload;
- int m_allocedComboBoxWidth;
- int m_allocedComboBoxHeight;
- CUtlString m_sCurrentURL; // the url of our current page
- // find in page state
- bool m_bInFind;
- CUtlString m_sLastSearchString;
-
- bool m_bCanGoBack; // cache of forward and back state
- bool m_bCanGoForward;
-
- struct LinkAtPos_t
- {
- LinkAtPos_t() { m_nX = m_nY = 0; }
- uint32 m_nX;
- uint32 m_nY;
- CUtlString m_sURL;
- };
- LinkAtPos_t m_LinkAtPos; // cache for link at pos requests, because the request is async
- bool m_bRequestingDragURL; // true if we need a response for a drag url loc
- bool m_bRequestingCopyLink; // true if we wanted to copy the link under the cursor
-
- struct ScrollData_t
- {
- ScrollData_t()
- {
- m_bVisible = false;
- m_nX = m_nY = m_nWide = m_nTall = m_nMax = m_nScroll = 0;
- }
-
- bool operator==( ScrollData_t const &src ) const
- {
- return m_bVisible == src.m_bVisible &&
- m_nX == src.m_nX &&
- m_nY == src.m_nY &&
- m_nWide == src.m_nWide &&
- m_nTall == src.m_nTall &&
- m_nMax == src.m_nMax &&
- m_nScroll == src.m_nScroll;
- }
-
- bool operator!=( ScrollData_t const &src ) const
- {
- return !operator==(src);
- }
-
-
- bool m_bVisible; // is the scroll bar visible
- int m_nX; /// where cef put the scroll bar
- int m_nY;
- int m_nWide;
- int m_nTall; // how many pixels of scroll in the current scroll knob
- int m_nMax; // most amount of pixels we can scroll
- int m_nScroll; // currently scrolled amount of pixels
- float m_flZoom; // zoom level this scroll bar is for
- };
-
- ScrollData_t m_scrollHorizontal; // details of horizontal scroll bar
- ScrollData_t m_scrollVertical; // details of vertical scroll bar
- float m_flZoom; // current page zoom level
-
- CUtlString m_sPendingURLLoad; // cache of url to load if we get a PostURL before the cef object is mage
- CUtlString m_sPendingPostData; // cache of the post data for above
-
- struct CustomCursorCache_t
- {
- CustomCursorCache_t() {}
- CustomCursorCache_t( const void *pchData ) { m_pchData = pchData; }
- float m_CacheTime; // the time we cached the cursor
- CursorCode m_Cursor; // the vgui handle to it
- const void *m_pchData; // the pointer to the cursor char data so we can detect the same cursor being used
- bool operator==(const CustomCursorCache_t& rhs) const
- {
- return m_pchData == rhs.m_pchData ;
- }
- };
- CUtlVector<CustomCursorCache_t> m_vecHCursor;
- CUtlVector<HTMLCommandBuffer_t *> m_vecPendingMessages;
-};
-
-} // namespace vgui
-
-#endif // HTML_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Creates a HTML control +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef HTML_H +#define HTML_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui/IImage.h> +#include <vgui_controls/Panel.h> +#include <vgui_controls/PHandle.h> +#include <vgui_controls/FileOpenDialog.h> +#include <vgui_controls/TextEntry.h> +#include <html/ihtmlchrome.h> +#include <tier1/utlmap.h> + +class HTMLComboBoxHost; +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Control to display HTML content +// This control utilises a hidden IE window to render a HTML page for you. +// It can load any valid URL (i.e local files or web pages), you cannot dynamically change the +// content however (internally to the control that is). +//----------------------------------------------------------------------------- +class HTML: public Panel, public IHTMLResponses +{ + DECLARE_CLASS_SIMPLE( HTML, Panel ); + // TODO::STYLE + //DECLARE_STYLE_BASE( "HTML" ); +public: + + HTML(Panel *parent,const char *name, bool allowJavaScript = false, bool bPopupWindow = false); + ~HTML(); + + // IHTML pass through functions + virtual void OpenURL( const char *URL, const char *pchPostData, bool bForce = false ); + virtual bool StopLoading(); + virtual bool Refresh(); + virtual void OnMove(); + virtual void RunJavascript( const char *pchScript ); + virtual void GoBack(); + virtual void GoForward(); + virtual bool BCanGoBack(); + virtual bool BCanGoFoward(); + + // event functions you can override and specialize behavior of + virtual bool OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect ); + virtual void OnFinishRequest(const char *url, const char *pageTitle, const CUtlMap < CUtlString, CUtlString > &headers ) {} + virtual void OnSetHTMLTitle( const char *pchTitle ) {} + virtual void OnLinkAtPosition( const char *pchURL ) {} + virtual void OnURLChanged( const char *url, const char *pchPostData, bool bIsRedirect ) {} + + virtual bool OnOpenNewTab( const char *pchURL, bool bForeground ) { return false; } + + // configuration + virtual void SetScrollbarsEnabled(bool state); + virtual void SetContextMenuEnabled(bool state); + virtual void SetViewSourceEnabled( bool state ); + virtual void NewWindowsOnly( bool state ); + + bool IsScrolledToBottom(); + bool IsScrollbarVisible(); + + // url handlers, lets you have web page links fire vgui events + // use to have custom web page links, eg. "steam://open/subscriptionpage" + // message contains "CustomURL", "url" + virtual void AddCustomURLHandler(const char *customProtocolName, vgui::Panel *target); + + // overridden to paint our special web browser texture + virtual void Paint(); + + // pass messages to the texture component to tell it about resizes + virtual void OnSizeChanged(int wide,int tall); + + // pass mouse clicks through + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); + virtual void OnCursorMoved(int x,int y); + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnKeyTyped(wchar_t unichar); + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnKeyCodeReleased(KeyCode code); + virtual void PerformLayout(); + virtual void OnMouseWheeled(int delta); + virtual void PostChildPaint(); + + /* message posting: + + "HTMLSliderMoved" - indicates the scrollbar has moved + + "OnURLChanged" - indicates a new URL is being loaded + "url" + "postdata" + + "OnFinishRequest" - indicates all url loaded has completed + + "HTMLBackRequested" - mouse4 has been pressed on the dialog + "HTMLForwardRequested" - mouse5 has been pressed on the dialog + + "SecurityStatus" - indicates the SSL status of the page (disabled,good,bad) + "url" + "secure" - true if an ssl page + "certerror" - true if there is a cert error loading the page + "isevcert" - true if this is an EV style cert + "certname" - name of the entity this cert is issued to + */ + + MESSAGE_FUNC_INT( OnSetCursorVGUI, "SetCursor", cursor ); + + virtual void OnCommand( const char *pchCommand ); + + void AddHeader( const char *pchHeader, const char *pchValue ); + void OnKillFocus(); + void OnSetFocus(); + + void Find( const char *pchSubStr ); + void StopFind(); + void FindNext(); + void FindPrevious(); + void ShowFindDialog(); + void HideFindDialog(); + bool FindDialogVisible(); + int HorizontalScrollMax() { return m_scrollHorizontal.m_nMax; } + int VerticalScrollMax() { return m_scrollVertical.m_nMax; } + + void GetLinkAtPosition( int x, int y ); + + void HidePopup(); + +#ifdef DBGFLAG_VALIDATE + virtual void Validate( CValidator &validator, const char *pchName ) + { + ValidateObj( m_CustomURLHandlers ); + BaseClass::Validate( validator, pchName ); + } +#endif // DBGFLAG_VALIDATE + + void PaintComboBox(); + int BrowserGetIndex() { return m_iBrowser; } +protected: + virtual void ApplySchemeSettings( IScheme *pScheme ); + + friend class HTMLComboBoxHost; + vgui::Menu *m_pContextMenu; + +private: + // IHTMLResponses callbacks from the browser engine + virtual void BrowserSetIndex( int idx ) { m_iBrowser = idx; BrowserResize(); SendPendingHTMLMessages(); } + virtual void BrowserReady( const CMsgBrowserReady *pCmd ); + virtual void BrowserNeedsPaint( const CMsgNeedsPaint *pCmd ); + virtual void BrowserStartRequest( const CMsgStartRequest *pCmd ); + virtual void BrowserURLChanged( const CMsgURLChanged *pCmd ); + virtual void BrowserFinishedRequest( const CMsgFinishedRequest *pCmd ); + virtual void BrowserShowPopup( const CMsgShowPopup *pCmd ); + virtual void BrowserHidePopup( const CMsgHidePopup *pCmd ); + virtual void BrowserOpenNewTab( const CMsgOpenNewTab *pCmd ); + virtual void BrowserPopupHTMLWindow( const CMsgPopupHTMLWindow *pCmd ); + virtual void BrowserSetHTMLTitle( const CMsgSetHTMLTitle *pCmd ); + virtual void BrowserLoadingResource( const CMsgLoadingResource *pCmd ); + virtual void BrowserStatusText( const CMsgStatusText *pCmd ); + virtual void BrowserSetCursor( const CMsgSetCursor *pCmd ); + virtual void BrowserFileLoadDialog( const CMsgFileLoadDialog *pCmd ); + virtual void BrowserShowToolTip( const CMsgShowToolTip *pCmd ); + virtual void BrowserUpdateToolTip( const CMsgUpdateToolTip *pCmd ); + virtual void BrowserHideToolTip( const CMsgHideToolTip *pCmd ); + virtual void BrowserSearchResults( const CMsgSearchResults *pCmd ); + virtual void BrowserClose( const CMsgClose *pCmd ); + virtual void BrowserHorizontalScrollBarSizeResponse( const CMsgHorizontalScrollBarSizeResponse *pCmd ); + virtual void BrowserVerticalScrollBarSizeResponse( const CMsgVerticalScrollBarSizeResponse *pCmd ); + virtual void BrowserGetZoomResponse( const CMsgGetZoomResponse *pCmd ); + virtual void BrowserLinkAtPositionResponse( const CMsgLinkAtPositionResponse *pCmd ); + virtual void BrowserZoomToElementAtPositionResponse( const CMsgZoomToElementAtPositionResponse *pCmd ); + virtual void BrowserJSAlert( const CMsgJSAlert *pCmd ); + virtual void BrowserJSConfirm( const CMsgJSConfirm *pCmd ); + virtual void BrowserCanGoBackandForward( const CMsgCanGoBackAndForward *pCmd ); + virtual void BrowserOpenSteamURL( const CMsgOpenSteamURL *pCmd ); + virtual void BrowserSizePopup( const CMsgSizePopup *pCmd ); + void SendPendingHTMLMessages(); + /*virtual void BrowserResourceResponse( const CMsgResourceResponse *pCmd );*/ + virtual void BrowserScalePageToValueResponse( const CMsgScalePageToValueResponse *pCmd ){} + virtual void BrowserRequestFullScreen( const CMsgRequestFullScreen *pCmd ) {} + virtual void BrowserExitFullScreen( const CMsgExitFullScreen *pCmd ) {} + virtual void BrowserGetCookiesForURLResponse( const CMsgGetCookiesForURLResponse *pCmd ){} + virtual void BrowserNodeGotFocus( const CMsgNodeHasFocus *pCmd ){} + virtual void BrowserSavePageToJPEGResponse( const CMsgSavePageToJPEGResponse *pCmd ) {} + virtual void BrowserFocusedNodeValueResponse( const CMsgFocusedNodeTextResponse *pCmd ) {} + + virtual void _DeserializeAndDispatch( HTMLCommandBuffer_t *pCmd ); + + void PostURL(const char *URL, const char *pchPostData, bool force); + virtual void BrowserResize(); + virtual void CalcScrollBars(int w,int h); + void UpdateSizeAndScrollBars(); + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); + MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath ); + MESSAGE_FUNC( OnFileSelectionCancelled, "FileSelectionCancelled" ); + MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel ); + MESSAGE_FUNC_PTR( OnEditNewLine, "TextNewLine", panel ); + MESSAGE_FUNC_INT( DismissJSDialog, "DismissJSDialog", result ); + + void UpdateCachedHTMLValues(); + + vgui::Panel *m_pInteriorPanel; + vgui::ScrollBar *_hbar,*_vbar; + vgui::DHANDLE<vgui::FileOpenDialog> m_hFileOpenDialog; + class CHTMLFindBar : public vgui::EditablePanel + { + DECLARE_CLASS_SIMPLE( CHTMLFindBar, EditablePanel ); + public: + CHTMLFindBar( HTML *parent ); + void SetText( const char *pchText ) { m_pFindBar->SetText( pchText ); } + void GetText( char *pText, int ccText ) { m_pFindBar->GetText( pText, ccText ); } + void OnCommand( const char *pchCmd ); + void ShowCountLabel() { m_pFindCountLabel->SetVisible( true ); } + void HideCountLabel() { m_pFindCountLabel->SetVisible( false ); } + void SetHidden( bool bState ) { m_bHidden = bState; } + bool BIsHidden() { return m_bHidden; } + + private: + vgui::TextEntry *m_pFindBar; + vgui::HTML *m_pParent; + vgui::Label *m_pFindCountLabel; + bool m_bHidden; + }; + + CHTMLFindBar *m_pFindBar; + HTMLComboBoxHost *m_pComboBoxHost; + + int m_iMouseX,m_iMouseY; // where the mouse is on the control + + int m_iScrollBorderX,m_iScrollBorderY; + int m_iWideLastHTMLSize, m_iTalLastHTMLSize; + int m_iCopyLinkMenuItemID; + + bool m_bScrollBarEnabled; + bool m_bContextMenuEnabled; + int m_iScrollbarSize; + bool m_bNewWindowsOnly; + int m_nViewSourceAllowedIndex; + CUtlString m_sDragURL; + int m_iDragStartX, m_iDragStartY; + + struct CustomURLHandler_t + { + PHandle hPanel; + char url[32]; + }; + CUtlVector<CustomURLHandler_t> m_CustomURLHandlers; + + int m_iBrowser; // our browser handle + int m_iHTMLTextureID; // vgui texture id + // Track the texture width and height requested so we can tell + // when the size has changed and reallocate the texture. + int m_allocedTextureWidth; + int m_allocedTextureHeight; + int m_iComboBoxTextureID; // vgui texture id of the combo box + bool m_bNeedsFullTextureUpload; + int m_allocedComboBoxWidth; + int m_allocedComboBoxHeight; + CUtlString m_sCurrentURL; // the url of our current page + // find in page state + bool m_bInFind; + CUtlString m_sLastSearchString; + + bool m_bCanGoBack; // cache of forward and back state + bool m_bCanGoForward; + + struct LinkAtPos_t + { + LinkAtPos_t() { m_nX = m_nY = 0; } + uint32 m_nX; + uint32 m_nY; + CUtlString m_sURL; + }; + LinkAtPos_t m_LinkAtPos; // cache for link at pos requests, because the request is async + bool m_bRequestingDragURL; // true if we need a response for a drag url loc + bool m_bRequestingCopyLink; // true if we wanted to copy the link under the cursor + + struct ScrollData_t + { + ScrollData_t() + { + m_bVisible = false; + m_nX = m_nY = m_nWide = m_nTall = m_nMax = m_nScroll = 0; + } + + bool operator==( ScrollData_t const &src ) const + { + return m_bVisible == src.m_bVisible && + m_nX == src.m_nX && + m_nY == src.m_nY && + m_nWide == src.m_nWide && + m_nTall == src.m_nTall && + m_nMax == src.m_nMax && + m_nScroll == src.m_nScroll; + } + + bool operator!=( ScrollData_t const &src ) const + { + return !operator==(src); + } + + + bool m_bVisible; // is the scroll bar visible + int m_nX; /// where cef put the scroll bar + int m_nY; + int m_nWide; + int m_nTall; // how many pixels of scroll in the current scroll knob + int m_nMax; // most amount of pixels we can scroll + int m_nScroll; // currently scrolled amount of pixels + float m_flZoom; // zoom level this scroll bar is for + }; + + ScrollData_t m_scrollHorizontal; // details of horizontal scroll bar + ScrollData_t m_scrollVertical; // details of vertical scroll bar + float m_flZoom; // current page zoom level + + CUtlString m_sPendingURLLoad; // cache of url to load if we get a PostURL before the cef object is mage + CUtlString m_sPendingPostData; // cache of the post data for above + + struct CustomCursorCache_t + { + CustomCursorCache_t() {} + CustomCursorCache_t( const void *pchData ) { m_pchData = pchData; } + float m_CacheTime; // the time we cached the cursor + CursorCode m_Cursor; // the vgui handle to it + const void *m_pchData; // the pointer to the cursor char data so we can detect the same cursor being used + bool operator==(const CustomCursorCache_t& rhs) const + { + return m_pchData == rhs.m_pchData ; + } + }; + CUtlVector<CustomCursorCache_t> m_vecHCursor; + CUtlVector<HTMLCommandBuffer_t *> m_vecPendingMessages; +}; + +} // namespace vgui + +#endif // HTML_H diff --git a/mp/src/public/vgui_controls/Image.h b/mp/src/public/vgui_controls/Image.h index c0d5196d..9ed128e7 100644 --- a/mp/src/public/vgui_controls/Image.h +++ b/mp/src/public/vgui_controls/Image.h @@ -1,80 +1,80 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef IMAGE_H
-#define IMAGE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <Color.h>
-#include <vgui/IImage.h>
-
-namespace vgui
-{
-
-class Panel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Basic image control
-//-----------------------------------------------------------------------------
-class Image : public IImage
-{
-public:
- Image();
- virtual ~Image();
-
- // Set the position of the image
- virtual void SetPos( int x, int y );
- // Get the position of the image
- virtual void GetPos( int &x, int &y );
- // Get the size of the image
- virtual void GetSize( int &wide, int &tall );
- virtual void GetContentSize( int &wide, int &tall );
- // Set the draw color
- virtual void SetColor( Color color );
- // set the background color
- virtual void SetBkColor( Color color ) { DrawSetColor( color ); }
- // Get the draw color
- virtual Color GetColor();
- virtual bool Evict();
- virtual int GetNumFrames();
- virtual void SetFrame( int nFrame );
- virtual HTexture GetID();
- virtual void SetRotation( int iRotation ) { return; };
-
-protected:
- virtual void SetSize(int wide, int tall);
- virtual void DrawSetColor(Color color);
- virtual void DrawSetColor(int r, int g, int b, int a);
- virtual void DrawFilledRect(int x0, int y0, int x1, int y1);
- virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1);
- virtual void DrawLine(int x0,int y0,int x1,int y1);
- virtual void DrawPolyLine(int *px, int *py, int numPoints);
- virtual void DrawSetTextFont(HFont font);
- virtual void DrawSetTextColor(Color color);
- virtual void DrawSetTextColor(int r, int g, int b, int a);
- virtual void DrawSetTextPos(int x,int y);
- virtual void DrawPrintText(const wchar_t *str, int strlen);
- virtual void DrawPrintText(int x, int y, const wchar_t *str, int strlen);
- virtual void DrawPrintChar(wchar_t ch);
- virtual void DrawPrintChar(int x, int y, wchar_t ch);
- virtual void DrawSetTexture(int id);
- virtual void DrawTexturedRect(int x0, int y0, int x1, int y1);
- virtual void Paint() = 0;
-
-private:
- int _pos[2];
- int _size[2];
- Color _color;
-};
-
-} // namespace vgui
-
-#endif // IMAGE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef IMAGE_H +#define IMAGE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <Color.h> +#include <vgui/IImage.h> + +namespace vgui +{ + +class Panel; + +//----------------------------------------------------------------------------- +// Purpose: Basic image control +//----------------------------------------------------------------------------- +class Image : public IImage +{ +public: + Image(); + virtual ~Image(); + + // Set the position of the image + virtual void SetPos( int x, int y ); + // Get the position of the image + virtual void GetPos( int &x, int &y ); + // Get the size of the image + virtual void GetSize( int &wide, int &tall ); + virtual void GetContentSize( int &wide, int &tall ); + // Set the draw color + virtual void SetColor( Color color ); + // set the background color + virtual void SetBkColor( Color color ) { DrawSetColor( color ); } + // Get the draw color + virtual Color GetColor(); + virtual bool Evict(); + virtual int GetNumFrames(); + virtual void SetFrame( int nFrame ); + virtual HTexture GetID(); + virtual void SetRotation( int iRotation ) { return; }; + +protected: + virtual void SetSize(int wide, int tall); + virtual void DrawSetColor(Color color); + virtual void DrawSetColor(int r, int g, int b, int a); + virtual void DrawFilledRect(int x0, int y0, int x1, int y1); + virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1); + virtual void DrawLine(int x0,int y0,int x1,int y1); + virtual void DrawPolyLine(int *px, int *py, int numPoints); + virtual void DrawSetTextFont(HFont font); + virtual void DrawSetTextColor(Color color); + virtual void DrawSetTextColor(int r, int g, int b, int a); + virtual void DrawSetTextPos(int x,int y); + virtual void DrawPrintText(const wchar_t *str, int strlen); + virtual void DrawPrintText(int x, int y, const wchar_t *str, int strlen); + virtual void DrawPrintChar(wchar_t ch); + virtual void DrawPrintChar(int x, int y, wchar_t ch); + virtual void DrawSetTexture(int id); + virtual void DrawTexturedRect(int x0, int y0, int x1, int y1); + virtual void Paint() = 0; + +private: + int _pos[2]; + int _size[2]; + Color _color; +}; + +} // namespace vgui + +#endif // IMAGE_H diff --git a/mp/src/public/vgui_controls/ImageList.h b/mp/src/public/vgui_controls/ImageList.h index 6e8e2223..db9ec638 100644 --- a/mp/src/public/vgui_controls/ImageList.h +++ b/mp/src/public/vgui_controls/ImageList.h @@ -1,56 +1,56 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef IMAGELIST_H
-#define IMAGELIST_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utlvector.h>
-#include <vgui/VGUI.h>
-#include <vgui/IImage.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: holds a collection of images
-// used by controls so that images can be refered to by indices
-//-----------------------------------------------------------------------------
-class ImageList
-{
-public:
- ImageList(bool deleteImagesWhenDone);
- ~ImageList();
-
- // adds a new image to the list, returning the index it was placed at
- int AddImage(vgui::IImage *image);
-
- // returns the number of images
- int GetImageCount();
-
- // returns true if an index is valid
- bool IsValidIndex(int imageIndex);
-
- // sets an image at a specified index, growing and adding NULL images if necessary
- void SetImageAtIndex(int index, vgui::IImage *image);
-
- // gets an image, imageIndex is of range [0, GetImageCount)
- // image index 0 is always the blank image
- vgui::IImage *GetImage(int imageIndex);
-
-private:
- CUtlVector<vgui::IImage *> m_Images;
- bool m_bDeleteImagesWhenDone;
-};
-
-
-} // namespace vgui
-
-#endif // IMAGELIST_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef IMAGELIST_H +#define IMAGELIST_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utlvector.h> +#include <vgui/VGUI.h> +#include <vgui/IImage.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: holds a collection of images +// used by controls so that images can be refered to by indices +//----------------------------------------------------------------------------- +class ImageList +{ +public: + ImageList(bool deleteImagesWhenDone); + ~ImageList(); + + // adds a new image to the list, returning the index it was placed at + int AddImage(vgui::IImage *image); + + // returns the number of images + int GetImageCount(); + + // returns true if an index is valid + bool IsValidIndex(int imageIndex); + + // sets an image at a specified index, growing and adding NULL images if necessary + void SetImageAtIndex(int index, vgui::IImage *image); + + // gets an image, imageIndex is of range [0, GetImageCount) + // image index 0 is always the blank image + vgui::IImage *GetImage(int imageIndex); + +private: + CUtlVector<vgui::IImage *> m_Images; + bool m_bDeleteImagesWhenDone; +}; + + +} // namespace vgui + +#endif // IMAGELIST_H diff --git a/mp/src/public/vgui_controls/ImagePanel.h b/mp/src/public/vgui_controls/ImagePanel.h index 9540d5bc..730cf38c 100644 --- a/mp/src/public/vgui_controls/ImagePanel.h +++ b/mp/src/public/vgui_controls/ImagePanel.h @@ -1,91 +1,91 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef IMAGEPANEL_H
-#define IMAGEPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-class IImage;
-
-//-----------------------------------------------------------------------------
-// Purpose: Panel that holds a single image
-//-----------------------------------------------------------------------------
-class ImagePanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( ImagePanel, Panel );
-public:
- ImagePanel(Panel *parent, const char *name);
- ~ImagePanel();
-
- virtual void SetImage(IImage *image);
- virtual void SetImage(const char *imageName);
- virtual IImage *GetImage();
- char *GetImageName();
-
- void SetShouldCenterImage( bool state ) { m_bCenterImage = state; }
- bool GetShouldCenterImage() const { return m_bCenterImage; }
-
- // sets whether or not the image should scale to fit the size of the ImagePanel (defaults to false)
- void SetShouldScaleImage( bool state );
- bool GetShouldScaleImage();
- void SetScaleAmount( float scale );
- float GetScaleAmount( void );
-
- void SetTileImage( bool bTile ) { m_bTileImage = bTile; }
-
- // set the color to fill with, if no image is specified
- void SetFillColor( Color col );
- Color GetFillColor();
-
- virtual Color GetDrawColor( void );
- virtual void SetDrawColor( Color drawColor );
-
- virtual void ApplySettings(KeyValues *inResourceData);
-
- // unhooks and evicts image if possible, caller must re-establish
- bool EvictImage();
-
- int GetNumFrames();
- void SetFrame( int nFrame );
-
- void SetRotation( int iRotation ) { m_iRotation = iRotation; }
-
-protected:
- virtual void PaintBackground();
- virtual void GetSettings(KeyValues *outResourceData);
- virtual const char *GetDescription();
- virtual void OnSizeChanged(int newWide, int newTall);
- virtual void ApplySchemeSettings( IScheme *pScheme );
-
-private:
- IImage *m_pImage;
- char *m_pszImageName;
- char *m_pszFillColorName;
- char *m_pszDrawColorName;
- bool m_bCenterImage;
- bool m_bScaleImage;
- bool m_bTileImage;
- bool m_bTileHorizontally;
- bool m_bTileVertically;
- float m_fScaleAmount;
- Color m_FillColor;
- Color m_DrawColor;
- int m_iRotation;
-};
-
-} // namespace vgui
-
-#endif // IMAGEPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef IMAGEPANEL_H +#define IMAGEPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +class IImage; + +//----------------------------------------------------------------------------- +// Purpose: Panel that holds a single image +//----------------------------------------------------------------------------- +class ImagePanel : public Panel +{ + DECLARE_CLASS_SIMPLE( ImagePanel, Panel ); +public: + ImagePanel(Panel *parent, const char *name); + ~ImagePanel(); + + virtual void SetImage(IImage *image); + virtual void SetImage(const char *imageName); + virtual IImage *GetImage(); + char *GetImageName(); + + void SetShouldCenterImage( bool state ) { m_bCenterImage = state; } + bool GetShouldCenterImage() const { return m_bCenterImage; } + + // sets whether or not the image should scale to fit the size of the ImagePanel (defaults to false) + void SetShouldScaleImage( bool state ); + bool GetShouldScaleImage(); + void SetScaleAmount( float scale ); + float GetScaleAmount( void ); + + void SetTileImage( bool bTile ) { m_bTileImage = bTile; } + + // set the color to fill with, if no image is specified + void SetFillColor( Color col ); + Color GetFillColor(); + + virtual Color GetDrawColor( void ); + virtual void SetDrawColor( Color drawColor ); + + virtual void ApplySettings(KeyValues *inResourceData); + + // unhooks and evicts image if possible, caller must re-establish + bool EvictImage(); + + int GetNumFrames(); + void SetFrame( int nFrame ); + + void SetRotation( int iRotation ) { m_iRotation = iRotation; } + +protected: + virtual void PaintBackground(); + virtual void GetSettings(KeyValues *outResourceData); + virtual const char *GetDescription(); + virtual void OnSizeChanged(int newWide, int newTall); + virtual void ApplySchemeSettings( IScheme *pScheme ); + +private: + IImage *m_pImage; + char *m_pszImageName; + char *m_pszFillColorName; + char *m_pszDrawColorName; + bool m_bCenterImage; + bool m_bScaleImage; + bool m_bTileImage; + bool m_bTileHorizontally; + bool m_bTileVertically; + float m_fScaleAmount; + Color m_FillColor; + Color m_DrawColor; + int m_iRotation; +}; + +} // namespace vgui + +#endif // IMAGEPANEL_H diff --git a/mp/src/public/vgui_controls/InputDialog.h b/mp/src/public/vgui_controls/InputDialog.h index 7ef8d08f..00b8d6f5 100644 --- a/mp/src/public/vgui_controls/InputDialog.h +++ b/mp/src/public/vgui_controls/InputDialog.h @@ -1,106 +1,106 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef INPUTDIALOG_H
-#define INPUTDIALOG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Controls.h>
-#include <vgui_controls/Frame.h>
-
-namespace vgui
-{
-
-class Label;
-class Button;
-class TextEntry;
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Utility dialog base class - just has context kv and ok/cancel buttons
-//-----------------------------------------------------------------------------
-class BaseInputDialog : public Frame
-{
- DECLARE_CLASS_SIMPLE( BaseInputDialog, Frame );
-
-public:
- BaseInputDialog( vgui::Panel *parent, const char *title );
- ~BaseInputDialog();
-
- void DoModal( KeyValues *pContextKeyValues = NULL );
-
-protected:
- virtual void PerformLayout();
- virtual void PerformLayout( int x, int y, int w, int h ) {}
-
- // command buttons
- virtual void OnCommand( const char *command );
-
- void CleanUpContextKeyValues();
- KeyValues *m_pContextKeyValues;
-
-private:
- vgui::Button *m_pCancelButton;
- vgui::Button *m_pOKButton;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Utility dialog, used to ask yes/no questions of the user
-//-----------------------------------------------------------------------------
-class InputMessageBox : public BaseInputDialog
-{
- DECLARE_CLASS_SIMPLE( InputMessageBox, BaseInputDialog );
-
-public:
- InputMessageBox( vgui::Panel *parent, const char *title, char const *prompt );
- ~InputMessageBox();
-
-protected:
- virtual void PerformLayout( int x, int y, int w, int h );
-
-private:
- vgui::Label *m_pPrompt;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Utility dialog, used to let user type in some text
-//-----------------------------------------------------------------------------
-class InputDialog : public BaseInputDialog
-{
- DECLARE_CLASS_SIMPLE( InputDialog, BaseInputDialog );
-
-public:
- InputDialog( vgui::Panel *parent, const char *title, char const *prompt, char const *defaultValue = "" );
- ~InputDialog();
-
- void SetMultiline( bool state );
-
- /* action signals
-
- "InputCompleted"
- "text" - the text entered
-
- "InputCanceled"
- */
- void AllowNumericInputOnly( bool bOnlyNumeric );
-
-protected:
- virtual void PerformLayout( int x, int y, int w, int h );
-
- // command buttons
- virtual void OnCommand(const char *command);
-
-private:
- vgui::Label *m_pPrompt;
- vgui::TextEntry *m_pInput;
-};
-
-} // namespace vgui
-
-
-#endif // INPUTDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef INPUTDIALOG_H +#define INPUTDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Controls.h> +#include <vgui_controls/Frame.h> + +namespace vgui +{ + +class Label; +class Button; +class TextEntry; + + +//----------------------------------------------------------------------------- +// Purpose: Utility dialog base class - just has context kv and ok/cancel buttons +//----------------------------------------------------------------------------- +class BaseInputDialog : public Frame +{ + DECLARE_CLASS_SIMPLE( BaseInputDialog, Frame ); + +public: + BaseInputDialog( vgui::Panel *parent, const char *title ); + ~BaseInputDialog(); + + void DoModal( KeyValues *pContextKeyValues = NULL ); + +protected: + virtual void PerformLayout(); + virtual void PerformLayout( int x, int y, int w, int h ) {} + + // command buttons + virtual void OnCommand( const char *command ); + + void CleanUpContextKeyValues(); + KeyValues *m_pContextKeyValues; + +private: + vgui::Button *m_pCancelButton; + vgui::Button *m_pOKButton; +}; + +//----------------------------------------------------------------------------- +// Purpose: Utility dialog, used to ask yes/no questions of the user +//----------------------------------------------------------------------------- +class InputMessageBox : public BaseInputDialog +{ + DECLARE_CLASS_SIMPLE( InputMessageBox, BaseInputDialog ); + +public: + InputMessageBox( vgui::Panel *parent, const char *title, char const *prompt ); + ~InputMessageBox(); + +protected: + virtual void PerformLayout( int x, int y, int w, int h ); + +private: + vgui::Label *m_pPrompt; +}; + +//----------------------------------------------------------------------------- +// Purpose: Utility dialog, used to let user type in some text +//----------------------------------------------------------------------------- +class InputDialog : public BaseInputDialog +{ + DECLARE_CLASS_SIMPLE( InputDialog, BaseInputDialog ); + +public: + InputDialog( vgui::Panel *parent, const char *title, char const *prompt, char const *defaultValue = "" ); + ~InputDialog(); + + void SetMultiline( bool state ); + + /* action signals + + "InputCompleted" + "text" - the text entered + + "InputCanceled" + */ + void AllowNumericInputOnly( bool bOnlyNumeric ); + +protected: + virtual void PerformLayout( int x, int y, int w, int h ); + + // command buttons + virtual void OnCommand(const char *command); + +private: + vgui::Label *m_pPrompt; + vgui::TextEntry *m_pInput; +}; + +} // namespace vgui + + +#endif // INPUTDIALOG_H diff --git a/mp/src/public/vgui_controls/KeyBindingHelpDialog.h b/mp/src/public/vgui_controls/KeyBindingHelpDialog.h index 284cfc08..3e4d0ede 100644 --- a/mp/src/public/vgui_controls/KeyBindingHelpDialog.h +++ b/mp/src/public/vgui_controls/KeyBindingHelpDialog.h @@ -1,63 +1,63 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef KEYBINDINGHELPDIALOG_H
-#define KEYBINDINGHELPDIALOG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/Frame.h"
-#include "vgui/KeyCode.h"
-
-namespace vgui
-{
-
-class ListPanel;
-class CKeyBoardEditorDialog;
-
-//-----------------------------------------------------------------------------
-// Purpose: Dialog for use in editing keybindings
-//-----------------------------------------------------------------------------
-class CKeyBindingHelpDialog : public Frame
-{
- DECLARE_CLASS_SIMPLE( CKeyBindingHelpDialog, Frame );
-
-public:
- CKeyBindingHelpDialog( Panel *parent, Panel *panelToView, KeyBindingContextHandle_t handle, KeyCode code, int modifiers );
- ~CKeyBindingHelpDialog();
-
- virtual void OnCommand( char const *cmd );
- virtual void OnKeyCodeTyped(vgui::KeyCode code);
-
- // The key originally bound to help was pressed
- void HelpKeyPressed();
-private:
-
- virtual void OnTick();
-
- bool IsHelpKeyStillBeingHeld();
-
- void PopulateList();
- void GetMappingList( Panel *panel, CUtlVector< PanelKeyBindingMap * >& maps );
-
- void AnsiText( char const *token, char *out, size_t buflen );
-
- vgui::PHandle m_hPanel;
- KeyBindingContextHandle_t m_Handle;
- KeyCode m_KeyCode;
- int m_Modifiers;
-
- ListPanel *m_pList;
- double m_flShowTime;
- bool m_bPermanent;
-
- DHANDLE< CKeyBoardEditorDialog > m_hKeyBindingsEditor;
-};
-
-}
-
-#endif // KEYBINDINGHELPDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef KEYBINDINGHELPDIALOG_H +#define KEYBINDINGHELPDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Frame.h" +#include "vgui/KeyCode.h" + +namespace vgui +{ + +class ListPanel; +class CKeyBoardEditorDialog; + +//----------------------------------------------------------------------------- +// Purpose: Dialog for use in editing keybindings +//----------------------------------------------------------------------------- +class CKeyBindingHelpDialog : public Frame +{ + DECLARE_CLASS_SIMPLE( CKeyBindingHelpDialog, Frame ); + +public: + CKeyBindingHelpDialog( Panel *parent, Panel *panelToView, KeyBindingContextHandle_t handle, KeyCode code, int modifiers ); + ~CKeyBindingHelpDialog(); + + virtual void OnCommand( char const *cmd ); + virtual void OnKeyCodeTyped(vgui::KeyCode code); + + // The key originally bound to help was pressed + void HelpKeyPressed(); +private: + + virtual void OnTick(); + + bool IsHelpKeyStillBeingHeld(); + + void PopulateList(); + void GetMappingList( Panel *panel, CUtlVector< PanelKeyBindingMap * >& maps ); + + void AnsiText( char const *token, char *out, size_t buflen ); + + vgui::PHandle m_hPanel; + KeyBindingContextHandle_t m_Handle; + KeyCode m_KeyCode; + int m_Modifiers; + + ListPanel *m_pList; + double m_flShowTime; + bool m_bPermanent; + + DHANDLE< CKeyBoardEditorDialog > m_hKeyBindingsEditor; +}; + +} + +#endif // KEYBINDINGHELPDIALOG_H diff --git a/mp/src/public/vgui_controls/KeyBindingMap.h b/mp/src/public/vgui_controls/KeyBindingMap.h index 6e779b0f..16641c76 100644 --- a/mp/src/public/vgui_controls/KeyBindingMap.h +++ b/mp/src/public/vgui_controls/KeyBindingMap.h @@ -1,225 +1,225 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef KEYBINDINGMAP_H
-#define KEYBINDINGMAP_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier1/utlvector.h"
-
-// more flexible than default pointers to members code required for casting member function pointers
-//#pragma pointers_to_members( full_generality, virtual_inheritance )
-
-namespace vgui
-{
-
-class Panel;
-
-enum
-{
- MODIFIER_SHIFT = ( 1 << 0 ),
- MODIFIER_CONTROL = ( 1 << 1 ),
- MODIFIER_ALT = ( 1 << 2 ),
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: An actual keybinding, where bindingname references a bindingmap mentioned below
-//-----------------------------------------------------------------------------
-struct BoundKey_t
-{
- BoundKey_t();
- BoundKey_t( const BoundKey_t& src );
- ~BoundKey_t();
- BoundKey_t& operator =( const BoundKey_t& src );
-
- bool isbuiltin; // whether this was by the #DECLARE macros or via code/parsing a config file
- char const *bindingname; // what it's bound to
- int keycode; // vgui keycode
- int modifiers; // which modifiers
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Single item in a message map
-// Contains the information to map a string message name with parameters
-// to a function call
-//-----------------------------------------------------------------------------
-struct KeyBindingMap_t
-{
- KeyBindingMap_t();
- KeyBindingMap_t( const KeyBindingMap_t& src );
- ~KeyBindingMap_t();
-
- char const *bindingname; // for the script file
- ALIGN16 MessageFunc_t func;
- char const *helpstring; // e.g., #KeybindingPasteHelp
- char const *docstring; // e.g., #KeybindingPasteHelp
- bool passive; // dispatch command, but still chain
-};
-
-#define DECLARE_KEYBINDINGMAP( className ) \
- static void KB_AddToMap \
- ( \
- char const *bindingname, \
- vgui::KeyCode defaultcode, \
- int default_modifiers, \
- vgui::MessageFunc_t function, \
- char const *helpstring, \
- char const *docstring, \
- bool passive \
- ) \
- { \
- vgui::PanelKeyBindingMap *map = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \
- \
- vgui::KeyBindingMap_t entry; \
- entry.bindingname = bindingname; \
- \
- entry.func = function; \
- \
- entry.helpstring = helpstring; \
- entry.docstring = docstring; \
- \
- entry.passive = passive; \
- \
- map->entries.AddToTail( entry ); \
- \
- vgui::BoundKey_t kb; \
- kb.isbuiltin = true; \
- kb.bindingname = bindingname; \
- kb.keycode = defaultcode; \
- kb.modifiers = default_modifiers; \
- map->defaultkeys.AddToTail( kb ); \
- map->boundkeys.AddToTail( kb ); \
- } \
- \
- static void KB_ChainToMap( void ) \
- { \
- static bool chained = false; \
- if ( chained ) \
- return; \
- chained = true; \
- vgui::PanelKeyBindingMap *map = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \
- map->pfnClassName = &GetPanelClassName; \
- if ( map && GetPanelBaseClassName() && GetPanelBaseClassName()[0] ) \
- { \
- map->baseMap = vgui::FindOrAddPanelKeyBindingMap( GetPanelBaseClassName() ); \
- } \
- } \
- \
- static void KB_AddBoundKey \
- ( \
- char const *bindingname, \
- int keycode, \
- int modifiers \
- ) \
- { \
- vgui::PanelKeyBindingMap *map = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \
- vgui::BoundKey_t kb; \
- kb.isbuiltin = true; \
- kb.bindingname = bindingname; \
- kb.keycode = keycode; \
- kb.modifiers = modifiers; \
- map->defaultkeys.AddToTail( kb ); \
- map->boundkeys.AddToTail( kb ); \
- } \
- \
- class className##_RegisterKBMap; \
- friend class className##_RegisterKBMap; \
- class className##_RegisterKBMap \
- { \
- public: \
- className##_RegisterKBMap() \
- { \
- className::KB_ChainToMap(); \
- } \
- }; \
- className##_RegisterKBMap m_RegisterClassKB; \
- \
- virtual vgui::PanelKeyBindingMap *GetKBMap() \
- { \
- static vgui::PanelKeyBindingMap *s_pMap = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \
- return s_pMap; \
- }
-
-#define _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, passive ) \
- class PanelKBMapFunc_##name; \
- friend class PanelKBMapFunc_##name; \
- class PanelKBMapFunc_##name \
- { \
- public: \
- static void InitVar() \
- { \
- static bool bAdded = false; \
- if ( !bAdded ) \
- { \
- bAdded = true; \
- KB_AddToMap( #name, keycode, modifiers, (vgui::MessageFunc_t)&ThisClass::function, help, doc, passive ); \
- } \
- } \
- PanelKBMapFunc_##name() \
- { \
- PanelKBMapFunc_##name::InitVar(); \
- } \
- }; \
- PanelKBMapFunc_##name m_##name##_register;
-
-#define _KBBindKeyCommon( name, keycode, modifiers, _classname ) \
- class PanelKBBindFunc_##_classname; \
- friend class PanelKBBindFunc_##_classname; \
- class PanelKBBindFunc_##_classname \
- { \
- public: \
- static void InitVar() \
- { \
- static bool bAdded = false; \
- if ( !bAdded ) \
- { \
- bAdded = true; \
- KB_AddBoundKey( #name, keycode, modifiers ); \
- } \
- } \
- PanelKBBindFunc_##_classname() \
- { \
- PanelKBBindFunc_##_classname::InitVar(); \
- } \
- }; \
- PanelKBBindFunc_##_classname m_##_classname##_bindkey_register;
-
-#define KEYBINDING_FUNC( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, false ); virtual void function()
-#define KEYBINDING_FUNC_NODECLARE( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, false );
-#define KEYBINDING_FUNC_PASSIVE( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, true ); virtual void function()
-#define KEYBINDING_FUNC_PASSIVE_NODECLARE( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, true );
-
-// For definding additional (non-default) keybindings
-#define KEYBINDING_ADDBINDING( name, keycode, modifiers ) _KBBindKeyCommon( name, keycode, modifiers, name );
-#define KEYBINDING_ADDBINDING_MULTIPLE( name, keycode, modifiers, _classname ) _KBBindKeyCommon( name, keycode, modifiers, _classname );
-
-// mapping, one per class
-struct PanelKeyBindingMap
-{
- PanelKeyBindingMap()
- {
- baseMap = NULL;
- pfnClassName = NULL;
- processed = false;
- }
-
- CUtlVector< KeyBindingMap_t > entries;
- bool processed;
- PanelKeyBindingMap *baseMap;
- CUtlVector< BoundKey_t > defaultkeys;
- CUtlVector< BoundKey_t > boundkeys;
- char const *(*pfnClassName)( void );
-};
-
-PanelKeyBindingMap *FindPanelKeyBindingMap( char const *className );
-PanelKeyBindingMap *FindOrAddPanelKeyBindingMap( char const *className );
-
-} // namespace vgui
-
-
-#endif // KEYBINDINGMAP_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef KEYBINDINGMAP_H +#define KEYBINDINGMAP_H +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlvector.h" + +// more flexible than default pointers to members code required for casting member function pointers +//#pragma pointers_to_members( full_generality, virtual_inheritance ) + +namespace vgui +{ + +class Panel; + +enum +{ + MODIFIER_SHIFT = ( 1 << 0 ), + MODIFIER_CONTROL = ( 1 << 1 ), + MODIFIER_ALT = ( 1 << 2 ), +}; + +//----------------------------------------------------------------------------- +// Purpose: An actual keybinding, where bindingname references a bindingmap mentioned below +//----------------------------------------------------------------------------- +struct BoundKey_t +{ + BoundKey_t(); + BoundKey_t( const BoundKey_t& src ); + ~BoundKey_t(); + BoundKey_t& operator =( const BoundKey_t& src ); + + bool isbuiltin; // whether this was by the #DECLARE macros or via code/parsing a config file + char const *bindingname; // what it's bound to + int keycode; // vgui keycode + int modifiers; // which modifiers +}; + +//----------------------------------------------------------------------------- +// Purpose: Single item in a message map +// Contains the information to map a string message name with parameters +// to a function call +//----------------------------------------------------------------------------- +struct KeyBindingMap_t +{ + KeyBindingMap_t(); + KeyBindingMap_t( const KeyBindingMap_t& src ); + ~KeyBindingMap_t(); + + char const *bindingname; // for the script file + ALIGN16 MessageFunc_t func; + char const *helpstring; // e.g., #KeybindingPasteHelp + char const *docstring; // e.g., #KeybindingPasteHelp + bool passive; // dispatch command, but still chain +}; + +#define DECLARE_KEYBINDINGMAP( className ) \ + static void KB_AddToMap \ + ( \ + char const *bindingname, \ + vgui::KeyCode defaultcode, \ + int default_modifiers, \ + vgui::MessageFunc_t function, \ + char const *helpstring, \ + char const *docstring, \ + bool passive \ + ) \ + { \ + vgui::PanelKeyBindingMap *map = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \ + \ + vgui::KeyBindingMap_t entry; \ + entry.bindingname = bindingname; \ + \ + entry.func = function; \ + \ + entry.helpstring = helpstring; \ + entry.docstring = docstring; \ + \ + entry.passive = passive; \ + \ + map->entries.AddToTail( entry ); \ + \ + vgui::BoundKey_t kb; \ + kb.isbuiltin = true; \ + kb.bindingname = bindingname; \ + kb.keycode = defaultcode; \ + kb.modifiers = default_modifiers; \ + map->defaultkeys.AddToTail( kb ); \ + map->boundkeys.AddToTail( kb ); \ + } \ + \ + static void KB_ChainToMap( void ) \ + { \ + static bool chained = false; \ + if ( chained ) \ + return; \ + chained = true; \ + vgui::PanelKeyBindingMap *map = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \ + map->pfnClassName = &GetPanelClassName; \ + if ( map && GetPanelBaseClassName() && GetPanelBaseClassName()[0] ) \ + { \ + map->baseMap = vgui::FindOrAddPanelKeyBindingMap( GetPanelBaseClassName() ); \ + } \ + } \ + \ + static void KB_AddBoundKey \ + ( \ + char const *bindingname, \ + int keycode, \ + int modifiers \ + ) \ + { \ + vgui::PanelKeyBindingMap *map = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \ + vgui::BoundKey_t kb; \ + kb.isbuiltin = true; \ + kb.bindingname = bindingname; \ + kb.keycode = keycode; \ + kb.modifiers = modifiers; \ + map->defaultkeys.AddToTail( kb ); \ + map->boundkeys.AddToTail( kb ); \ + } \ + \ + class className##_RegisterKBMap; \ + friend class className##_RegisterKBMap; \ + class className##_RegisterKBMap \ + { \ + public: \ + className##_RegisterKBMap() \ + { \ + className::KB_ChainToMap(); \ + } \ + }; \ + className##_RegisterKBMap m_RegisterClassKB; \ + \ + virtual vgui::PanelKeyBindingMap *GetKBMap() \ + { \ + static vgui::PanelKeyBindingMap *s_pMap = vgui::FindOrAddPanelKeyBindingMap( GetPanelClassName() ); \ + return s_pMap; \ + } + +#define _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, passive ) \ + class PanelKBMapFunc_##name; \ + friend class PanelKBMapFunc_##name; \ + class PanelKBMapFunc_##name \ + { \ + public: \ + static void InitVar() \ + { \ + static bool bAdded = false; \ + if ( !bAdded ) \ + { \ + bAdded = true; \ + KB_AddToMap( #name, keycode, modifiers, (vgui::MessageFunc_t)&ThisClass::function, help, doc, passive ); \ + } \ + } \ + PanelKBMapFunc_##name() \ + { \ + PanelKBMapFunc_##name::InitVar(); \ + } \ + }; \ + PanelKBMapFunc_##name m_##name##_register; + +#define _KBBindKeyCommon( name, keycode, modifiers, _classname ) \ + class PanelKBBindFunc_##_classname; \ + friend class PanelKBBindFunc_##_classname; \ + class PanelKBBindFunc_##_classname \ + { \ + public: \ + static void InitVar() \ + { \ + static bool bAdded = false; \ + if ( !bAdded ) \ + { \ + bAdded = true; \ + KB_AddBoundKey( #name, keycode, modifiers ); \ + } \ + } \ + PanelKBBindFunc_##_classname() \ + { \ + PanelKBBindFunc_##_classname::InitVar(); \ + } \ + }; \ + PanelKBBindFunc_##_classname m_##_classname##_bindkey_register; + +#define KEYBINDING_FUNC( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, false ); virtual void function() +#define KEYBINDING_FUNC_NODECLARE( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, false ); +#define KEYBINDING_FUNC_PASSIVE( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, true ); virtual void function() +#define KEYBINDING_FUNC_PASSIVE_NODECLARE( name, keycode, modifiers, function, help, doc ) _KBMapFuncCommonFunc( name, keycode, modifiers, function, help, doc, true ); + +// For definding additional (non-default) keybindings +#define KEYBINDING_ADDBINDING( name, keycode, modifiers ) _KBBindKeyCommon( name, keycode, modifiers, name ); +#define KEYBINDING_ADDBINDING_MULTIPLE( name, keycode, modifiers, _classname ) _KBBindKeyCommon( name, keycode, modifiers, _classname ); + +// mapping, one per class +struct PanelKeyBindingMap +{ + PanelKeyBindingMap() + { + baseMap = NULL; + pfnClassName = NULL; + processed = false; + } + + CUtlVector< KeyBindingMap_t > entries; + bool processed; + PanelKeyBindingMap *baseMap; + CUtlVector< BoundKey_t > defaultkeys; + CUtlVector< BoundKey_t > boundkeys; + char const *(*pfnClassName)( void ); +}; + +PanelKeyBindingMap *FindPanelKeyBindingMap( char const *className ); +PanelKeyBindingMap *FindOrAddPanelKeyBindingMap( char const *className ); + +} // namespace vgui + + +#endif // KEYBINDINGMAP_H diff --git a/mp/src/public/vgui_controls/KeyBoardEditorDialog.h b/mp/src/public/vgui_controls/KeyBoardEditorDialog.h index c1761b87..209c86f7 100644 --- a/mp/src/public/vgui_controls/KeyBoardEditorDialog.h +++ b/mp/src/public/vgui_controls/KeyBoardEditorDialog.h @@ -1,138 +1,138 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef KEYBOARDEDITORDIALOG_H
-#define KEYBOARDEDITORDIALOG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/Frame.h"
-#include "vgui_controls/PropertySheet.h"
-#include "vgui_controls/PropertyPage.h"
-
-class VControlsListPanel;
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Dialog for use in editing keybindings
-//-----------------------------------------------------------------------------
-class CKeyBoardEditorPage : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( CKeyBoardEditorPage, EditablePanel );
-
-public:
- CKeyBoardEditorPage( Panel *parent, Panel *panelToEdit, KeyBindingContextHandle_t handle );
- ~CKeyBoardEditorPage();
-
- void SetKeybindingsSaveFile( char const *filename, char const *pathID = 0 );
-
- virtual void OnKeyCodeTyped(vgui::KeyCode code);
-
- virtual void ApplySchemeSettings( IScheme *scheme );
-
- void OnSaveChanges();
- void OnRevert();
- void OnUseDefaults();
-
-protected:
-
- virtual void OnPageHide();
-
- virtual void OnCommand( char const *cmd );
-
- void PopulateList();
-
- void GetMappingList( Panel *panel, CUtlVector< PanelKeyBindingMap * >& maps );
- int GetMappingCount( Panel *panel );
-
- void BindKey( vgui::KeyCode code );
-
- // Trap row selection message
- MESSAGE_FUNC( ItemSelected, "ItemSelected" );
- MESSAGE_FUNC_INT( OnClearBinding, "ClearBinding", item );
-
- void SaveMappings();
- void UpdateCurrentMappings();
- void RestoreMappings();
- void ApplyMappings();
-
-protected:
- void AnsiText( char const *token, char *out, size_t buflen );
-
- Panel *m_pPanel;
- KeyBindingContextHandle_t m_Handle;
-
- VControlsListPanel *m_pList;
-
- struct SaveMapping_t
- {
- SaveMapping_t();
- SaveMapping_t( const SaveMapping_t& src );
-
- PanelKeyBindingMap *map;
- CUtlVector< BoundKey_t > current;
- CUtlVector< BoundKey_t > original;
- };
-
- CUtlVector< SaveMapping_t * > m_Save;
-};
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Dialog for use in editing keybindings
-//-----------------------------------------------------------------------------
-class CKeyBoardEditorSheet : public PropertySheet
-{
- DECLARE_CLASS_SIMPLE( CKeyBoardEditorSheet, PropertySheet );
-
-public:
- CKeyBoardEditorSheet( Panel *parent, Panel *panelToEdit, KeyBindingContextHandle_t handle );
-
- void SetKeybindingsSaveFile( char const *filename, char const *pathID = 0 );
-
- void OnSaveChanges();
- void OnRevert();
- void OnUseDefaults();
-
-protected:
-
- vgui::PHandle m_hPanel;
- KeyBindingContextHandle_t m_Handle;
- bool m_bSaveToExternalFile;
- CUtlSymbol m_SaveFileName;
- CUtlSymbol m_SaveFilePathID;
- Color m_clrAlteredItem;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Dialog for use in editing keybindings
-//-----------------------------------------------------------------------------
-class CKeyBoardEditorDialog : public Frame
-{
- DECLARE_CLASS_SIMPLE( CKeyBoardEditorDialog, Frame );
-
-public:
- CKeyBoardEditorDialog( Panel *parent, Panel *panelToEdit, KeyBindingContextHandle_t handle );
-
- void SetKeybindingsSaveFile( char const *filename, char const *pathID = 0 );
-
- virtual void OnCommand( char const *cmd );
-
-private:
- CKeyBoardEditorSheet *m_pKBEditor;
-
- Button *m_pSave;
- Button *m_pCancel;
- Button *m_pRevert;
- Button *m_pUseDefaults;
-};
-
-}
-
-#endif // KEYBOARDEDITORDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef KEYBOARDEDITORDIALOG_H +#define KEYBOARDEDITORDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Frame.h" +#include "vgui_controls/PropertySheet.h" +#include "vgui_controls/PropertyPage.h" + +class VControlsListPanel; + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Dialog for use in editing keybindings +//----------------------------------------------------------------------------- +class CKeyBoardEditorPage : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( CKeyBoardEditorPage, EditablePanel ); + +public: + CKeyBoardEditorPage( Panel *parent, Panel *panelToEdit, KeyBindingContextHandle_t handle ); + ~CKeyBoardEditorPage(); + + void SetKeybindingsSaveFile( char const *filename, char const *pathID = 0 ); + + virtual void OnKeyCodeTyped(vgui::KeyCode code); + + virtual void ApplySchemeSettings( IScheme *scheme ); + + void OnSaveChanges(); + void OnRevert(); + void OnUseDefaults(); + +protected: + + virtual void OnPageHide(); + + virtual void OnCommand( char const *cmd ); + + void PopulateList(); + + void GetMappingList( Panel *panel, CUtlVector< PanelKeyBindingMap * >& maps ); + int GetMappingCount( Panel *panel ); + + void BindKey( vgui::KeyCode code ); + + // Trap row selection message + MESSAGE_FUNC( ItemSelected, "ItemSelected" ); + MESSAGE_FUNC_INT( OnClearBinding, "ClearBinding", item ); + + void SaveMappings(); + void UpdateCurrentMappings(); + void RestoreMappings(); + void ApplyMappings(); + +protected: + void AnsiText( char const *token, char *out, size_t buflen ); + + Panel *m_pPanel; + KeyBindingContextHandle_t m_Handle; + + VControlsListPanel *m_pList; + + struct SaveMapping_t + { + SaveMapping_t(); + SaveMapping_t( const SaveMapping_t& src ); + + PanelKeyBindingMap *map; + CUtlVector< BoundKey_t > current; + CUtlVector< BoundKey_t > original; + }; + + CUtlVector< SaveMapping_t * > m_Save; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Dialog for use in editing keybindings +//----------------------------------------------------------------------------- +class CKeyBoardEditorSheet : public PropertySheet +{ + DECLARE_CLASS_SIMPLE( CKeyBoardEditorSheet, PropertySheet ); + +public: + CKeyBoardEditorSheet( Panel *parent, Panel *panelToEdit, KeyBindingContextHandle_t handle ); + + void SetKeybindingsSaveFile( char const *filename, char const *pathID = 0 ); + + void OnSaveChanges(); + void OnRevert(); + void OnUseDefaults(); + +protected: + + vgui::PHandle m_hPanel; + KeyBindingContextHandle_t m_Handle; + bool m_bSaveToExternalFile; + CUtlSymbol m_SaveFileName; + CUtlSymbol m_SaveFilePathID; + Color m_clrAlteredItem; +}; + +//----------------------------------------------------------------------------- +// Purpose: Dialog for use in editing keybindings +//----------------------------------------------------------------------------- +class CKeyBoardEditorDialog : public Frame +{ + DECLARE_CLASS_SIMPLE( CKeyBoardEditorDialog, Frame ); + +public: + CKeyBoardEditorDialog( Panel *parent, Panel *panelToEdit, KeyBindingContextHandle_t handle ); + + void SetKeybindingsSaveFile( char const *filename, char const *pathID = 0 ); + + virtual void OnCommand( char const *cmd ); + +private: + CKeyBoardEditorSheet *m_pKBEditor; + + Button *m_pSave; + Button *m_pCancel; + Button *m_pRevert; + Button *m_pUseDefaults; +}; + +} + +#endif // KEYBOARDEDITORDIALOG_H diff --git a/mp/src/public/vgui_controls/KeyRepeat.h b/mp/src/public/vgui_controls/KeyRepeat.h index 08789186..83d30a33 100644 --- a/mp/src/public/vgui_controls/KeyRepeat.h +++ b/mp/src/public/vgui_controls/KeyRepeat.h @@ -1,79 +1,79 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef KEYREPEAT_H
-#define KEYREPEAT_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-enum KEYREPEAT_ALIASES
-{
- KR_ALIAS_UP,
- KR_ALIAS_DOWN,
- KR_ALIAS_LEFT,
- KR_ALIAS_RIGHT,
-
- FM_NUM_KEYREPEAT_ALIASES,
-};
-
-class CKeyRepeatHandler
-{
-public:
- CKeyRepeatHandler()
- {
- Reset();
- for ( int i = 0; i < FM_NUM_KEYREPEAT_ALIASES; i++ )
- {
- m_flRepeatTimes[i] = 0.16;
- }
- }
-
- void Reset( void ) { memset( m_bAliasDown, 0, sizeof(bool) * FM_NUM_KEYREPEAT_ALIASES ); m_bHaveKeyDown = false; }
- void KeyDown( vgui::KeyCode code );
- void KeyUp( vgui::KeyCode code );
- vgui::KeyCode KeyRepeated( void );
- void SetKeyRepeatTime( vgui::KeyCode code, float flRepeat );
-
-private:
- int GetIndexForCode( vgui::KeyCode code )
- {
- switch ( code )
- {
- case KEY_XBUTTON_DOWN:
- case KEY_XSTICK1_DOWN:
- return KR_ALIAS_DOWN; break;
- case KEY_XBUTTON_UP:
- case KEY_XSTICK1_UP:
- return KR_ALIAS_UP; break;
- case KEY_XBUTTON_LEFT:
- case KEY_XSTICK1_LEFT:
- return KR_ALIAS_LEFT; break;
- case KEY_XBUTTON_RIGHT:
- case KEY_XSTICK1_RIGHT:
- return KR_ALIAS_RIGHT; break;
- default:
- break;
- }
- return -1;
- }
-
-private:
- bool m_bAliasDown[FM_NUM_KEYREPEAT_ALIASES];
- float m_flRepeatTimes[FM_NUM_KEYREPEAT_ALIASES];
- float m_flNextKeyRepeat;
- bool m_bHaveKeyDown;
-};
-
-
-} // namespace vgui
-
-#endif // KEYREPEAT_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef KEYREPEAT_H +#define KEYREPEAT_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +enum KEYREPEAT_ALIASES +{ + KR_ALIAS_UP, + KR_ALIAS_DOWN, + KR_ALIAS_LEFT, + KR_ALIAS_RIGHT, + + FM_NUM_KEYREPEAT_ALIASES, +}; + +class CKeyRepeatHandler +{ +public: + CKeyRepeatHandler() + { + Reset(); + for ( int i = 0; i < FM_NUM_KEYREPEAT_ALIASES; i++ ) + { + m_flRepeatTimes[i] = 0.16; + } + } + + void Reset( void ) { memset( m_bAliasDown, 0, sizeof(bool) * FM_NUM_KEYREPEAT_ALIASES ); m_bHaveKeyDown = false; } + void KeyDown( vgui::KeyCode code ); + void KeyUp( vgui::KeyCode code ); + vgui::KeyCode KeyRepeated( void ); + void SetKeyRepeatTime( vgui::KeyCode code, float flRepeat ); + +private: + int GetIndexForCode( vgui::KeyCode code ) + { + switch ( code ) + { + case KEY_XBUTTON_DOWN: + case KEY_XSTICK1_DOWN: + return KR_ALIAS_DOWN; break; + case KEY_XBUTTON_UP: + case KEY_XSTICK1_UP: + return KR_ALIAS_UP; break; + case KEY_XBUTTON_LEFT: + case KEY_XSTICK1_LEFT: + return KR_ALIAS_LEFT; break; + case KEY_XBUTTON_RIGHT: + case KEY_XSTICK1_RIGHT: + return KR_ALIAS_RIGHT; break; + default: + break; + } + return -1; + } + +private: + bool m_bAliasDown[FM_NUM_KEYREPEAT_ALIASES]; + float m_flRepeatTimes[FM_NUM_KEYREPEAT_ALIASES]; + float m_flNextKeyRepeat; + bool m_bHaveKeyDown; +}; + + +} // namespace vgui + +#endif // KEYREPEAT_H diff --git a/mp/src/public/vgui_controls/Label.h b/mp/src/public/vgui_controls/Label.h index aefc37b3..53422f76 100644 --- a/mp/src/public/vgui_controls/Label.h +++ b/mp/src/public/vgui_controls/Label.h @@ -1,225 +1,225 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef LABEL_H
-#define LABEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "utlvector.h"
-#include "vgui/VGUI.h"
-#include "vgui_controls/Panel.h"
-#include "vgui_controls/PHandle.h"
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Contains and displays a set of images
-// By default starts with one TextImage
-//-----------------------------------------------------------------------------
-class Label : public Panel
-{
- DECLARE_CLASS_SIMPLE( Label, Panel );
-
-public:
- // Constructors
- Label(Panel *parent, const char *panelName, const char *text);
- Label(Panel *parent, const char *panelName, const wchar_t *wszText);
- ~Label();
-
-public:
- // Take the string and looks it up in the localization file to convert it to unicode
- virtual void SetText(const char *tokenName);
-
- // Set unicode text directly
- virtual void SetText(const wchar_t *unicodeString, bool bClearUnlocalizedSymbol = false );
-
- // Get the current text
- virtual void GetText(OUT_Z_BYTECAP(bufferLen) char *textOut, int bufferLen);
- virtual void GetText(OUT_Z_BYTECAP(bufLenInBytes) wchar_t *textOut, int bufLenInBytes);
-
- // Content alignment
- // Get the size of the content within the label
- virtual void GetContentSize(int &wide, int &tall);
-
- // Set how the content aligns itself within the label
- // alignment code, used to determine how the images are layed out within the Label
- enum Alignment
- {
- a_northwest = 0,
- a_north,
- a_northeast,
- a_west,
- a_center,
- a_east,
- a_southwest,
- a_south,
- a_southeast,
- };
-
- virtual void SetContentAlignment(Alignment alignment);
- virtual void SetEnabled(bool state);
- // Additional offset at the Start of the text (from whichever sides it is aligned)
- virtual void SetTextInset(int xInset, int yInset);
- virtual void GetTextInset(int *xInset, int *yInset );
-
- // Text colors
- virtual void SetFgColor(Color color);
- virtual Color GetFgColor();
-
- // colors to use when the label is disabled
- virtual void SetDisabledFgColor1(Color color);
- virtual void SetDisabledFgColor2(Color color);
- virtual Color GetDisabledFgColor1();
- virtual Color GetDisabledFgColor2();
-
- // Set whether the text is displayed bright or dull
- enum EColorState
- {
- CS_NORMAL,
- CS_DULL,
- CS_BRIGHT,
- };
- virtual void SetTextColorState(EColorState state);
-
- // Font
- virtual void SetFont(HFont font);
- virtual HFont GetFont();
-
- // Hotkey
- virtual Panel *HasHotkey(wchar_t key);
- virtual void SetHotkey(wchar_t key);
- virtual wchar_t GetHotKey();
-
- // Labels can be associated with controls, and alter behaviour based on the associates behaviour
- // If the associate is disabled, so are we
- // If the associate has focus, we may alter how we draw
- // If we get a hotkey press or focus message, we forward the focus to the associate
- virtual void SetAssociatedControl(Panel *control);
-
- // Multiple image handling
- // Images are drawn from left to right across the label, ordered by index
- // By default there is a TextImage in position 0 (see GetTextImage()/SetTextImageIndex())
- virtual int AddImage(IImage *image, int preOffset); // Return the index the image was placed in
- virtual void SetImageAtIndex(int index, IImage *image, int preOffset);
- virtual void SetImagePreOffset(int index, int preOffset); // Set the offset in pixels before the image
- virtual IImage *GetImageAtIndex(int index);
- virtual int GetImageCount();
- virtual void ClearImages();
- virtual void ResetToSimpleTextImage();
- // fixes the layout bounds of the image within the label
- virtual void SetImageBounds(int index, int x, int width);
-
- // Teturns a pointer to the default text image
- virtual TextImage *GetTextImage();
-
- // Moves where the default text image is within the image array (it starts in position 0)
- // Setting it to -1 removes it from the image list
- // Returns the index the default text image was previously in
- virtual int SetTextImageIndex(int newIndex);
-
- // Message handling
- // outputData - keyName is the name of the attribute requested.
- // for Labels "text" is an option that returns the default text image text
- // returns true on success in finding the requested value. false on failure.
- virtual bool RequestInfo(KeyValues *outputData);
- /* INFO HANDLING
- "GetText"
- returns:
- "text" - text contained in the label
- */
-
- /* CUSTOM MESSAGE HANDLING
- "SetText"
- input: "text" - label text is set to be this string
- */
-
- virtual void SizeToContents();
-
- // the +8 is padding to the content size
- // the code which uses it should really set that itself;
- // however a lot of existing code relies on this
- enum Padding
- {
- Content = 8,
- };
-
- void SetWrap( bool bWrap );
- void SetCenterWrap( bool bWrap );
-
- void SetAllCaps( bool bAllCaps );
-
-protected:
- virtual void PerformLayout();
- virtual wchar_t CalculateHotkey(const char *text);
- virtual wchar_t CalculateHotkey(const wchar_t *text);
- virtual void ComputeAlignment(int &tx0, int &ty0, int &tx1, int &ty1);
- virtual void Paint();
- MESSAGE_FUNC_PARAMS( OnSetText, "SetText", params );
- virtual void DrawDashedLine(int x0, int y0, int x1, int y1, int dashLen, int gapLen);
- virtual void OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel);
- MESSAGE_FUNC( OnHotkeyPressed, "Hotkey" );
- virtual void OnMousePressed(MouseCode code);
- virtual void OnSizeChanged(int wide, int tall);
-
- // makes sure that the maxIndex will be a valid index
- virtual void EnsureImageCapacity(int maxIndex);
-
- // editing
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void GetSettings( KeyValues *outResourceData );
- virtual void ApplySettings( KeyValues *inResourceData );
- virtual const char *GetDescription( void );
-
- MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
-
- void HandleAutoSizing( void );
-
-private:
- void Init();
-
- Alignment _contentAlignment;
- TextImage *_textImage; // this is the textImage, if the full text will not
- // fit we put as much as we can and add an elipsis (...)
- struct TImageInfo
- {
- IImage *image;
- short offset;
- short xpos;
- short width;
- };
- CUtlVector<TImageInfo> _imageDar;
-
- int _textInset[2];
- Color _disabledFgColor1;
- Color _disabledFgColor2;
- Color _associateColor;
- int _textImageIndex; // index in the image array that the default _textimage resides
- EColorState _textColorState;
-
- PHandle _associate;
- char *_associateName;
-
- char *_fontOverrideName;
-
- wchar_t _hotkey; // the hotkey contained in the text
-
- bool m_bWrap;
- bool m_bCenterWrap;
- bool m_bAllCaps;
- bool m_bAutoWideToContents;
- bool m_bAutoWideDirty;
- bool m_bUseProportionalInsets;
-
-};
-
-} // namespace vgui
-
-#endif // LABEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef LABEL_H +#define LABEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "utlvector.h" +#include "vgui/VGUI.h" +#include "vgui_controls/Panel.h" +#include "vgui_controls/PHandle.h" + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Contains and displays a set of images +// By default starts with one TextImage +//----------------------------------------------------------------------------- +class Label : public Panel +{ + DECLARE_CLASS_SIMPLE( Label, Panel ); + +public: + // Constructors + Label(Panel *parent, const char *panelName, const char *text); + Label(Panel *parent, const char *panelName, const wchar_t *wszText); + ~Label(); + +public: + // Take the string and looks it up in the localization file to convert it to unicode + virtual void SetText(const char *tokenName); + + // Set unicode text directly + virtual void SetText(const wchar_t *unicodeString, bool bClearUnlocalizedSymbol = false ); + + // Get the current text + virtual void GetText(OUT_Z_BYTECAP(bufferLen) char *textOut, int bufferLen); + virtual void GetText(OUT_Z_BYTECAP(bufLenInBytes) wchar_t *textOut, int bufLenInBytes); + + // Content alignment + // Get the size of the content within the label + virtual void GetContentSize(int &wide, int &tall); + + // Set how the content aligns itself within the label + // alignment code, used to determine how the images are layed out within the Label + enum Alignment + { + a_northwest = 0, + a_north, + a_northeast, + a_west, + a_center, + a_east, + a_southwest, + a_south, + a_southeast, + }; + + virtual void SetContentAlignment(Alignment alignment); + virtual void SetEnabled(bool state); + // Additional offset at the Start of the text (from whichever sides it is aligned) + virtual void SetTextInset(int xInset, int yInset); + virtual void GetTextInset(int *xInset, int *yInset ); + + // Text colors + virtual void SetFgColor(Color color); + virtual Color GetFgColor(); + + // colors to use when the label is disabled + virtual void SetDisabledFgColor1(Color color); + virtual void SetDisabledFgColor2(Color color); + virtual Color GetDisabledFgColor1(); + virtual Color GetDisabledFgColor2(); + + // Set whether the text is displayed bright or dull + enum EColorState + { + CS_NORMAL, + CS_DULL, + CS_BRIGHT, + }; + virtual void SetTextColorState(EColorState state); + + // Font + virtual void SetFont(HFont font); + virtual HFont GetFont(); + + // Hotkey + virtual Panel *HasHotkey(wchar_t key); + virtual void SetHotkey(wchar_t key); + virtual wchar_t GetHotKey(); + + // Labels can be associated with controls, and alter behaviour based on the associates behaviour + // If the associate is disabled, so are we + // If the associate has focus, we may alter how we draw + // If we get a hotkey press or focus message, we forward the focus to the associate + virtual void SetAssociatedControl(Panel *control); + + // Multiple image handling + // Images are drawn from left to right across the label, ordered by index + // By default there is a TextImage in position 0 (see GetTextImage()/SetTextImageIndex()) + virtual int AddImage(IImage *image, int preOffset); // Return the index the image was placed in + virtual void SetImageAtIndex(int index, IImage *image, int preOffset); + virtual void SetImagePreOffset(int index, int preOffset); // Set the offset in pixels before the image + virtual IImage *GetImageAtIndex(int index); + virtual int GetImageCount(); + virtual void ClearImages(); + virtual void ResetToSimpleTextImage(); + // fixes the layout bounds of the image within the label + virtual void SetImageBounds(int index, int x, int width); + + // Teturns a pointer to the default text image + virtual TextImage *GetTextImage(); + + // Moves where the default text image is within the image array (it starts in position 0) + // Setting it to -1 removes it from the image list + // Returns the index the default text image was previously in + virtual int SetTextImageIndex(int newIndex); + + // Message handling + // outputData - keyName is the name of the attribute requested. + // for Labels "text" is an option that returns the default text image text + // returns true on success in finding the requested value. false on failure. + virtual bool RequestInfo(KeyValues *outputData); + /* INFO HANDLING + "GetText" + returns: + "text" - text contained in the label + */ + + /* CUSTOM MESSAGE HANDLING + "SetText" + input: "text" - label text is set to be this string + */ + + virtual void SizeToContents(); + + // the +8 is padding to the content size + // the code which uses it should really set that itself; + // however a lot of existing code relies on this + enum Padding + { + Content = 8, + }; + + void SetWrap( bool bWrap ); + void SetCenterWrap( bool bWrap ); + + void SetAllCaps( bool bAllCaps ); + +protected: + virtual void PerformLayout(); + virtual wchar_t CalculateHotkey(const char *text); + virtual wchar_t CalculateHotkey(const wchar_t *text); + virtual void ComputeAlignment(int &tx0, int &ty0, int &tx1, int &ty1); + virtual void Paint(); + MESSAGE_FUNC_PARAMS( OnSetText, "SetText", params ); + virtual void DrawDashedLine(int x0, int y0, int x1, int y1, int dashLen, int gapLen); + virtual void OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel); + MESSAGE_FUNC( OnHotkeyPressed, "Hotkey" ); + virtual void OnMousePressed(MouseCode code); + virtual void OnSizeChanged(int wide, int tall); + + // makes sure that the maxIndex will be a valid index + virtual void EnsureImageCapacity(int maxIndex); + + // editing + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void GetSettings( KeyValues *outResourceData ); + virtual void ApplySettings( KeyValues *inResourceData ); + virtual const char *GetDescription( void ); + + MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables ); + + void HandleAutoSizing( void ); + +private: + void Init(); + + Alignment _contentAlignment; + TextImage *_textImage; // this is the textImage, if the full text will not + // fit we put as much as we can and add an elipsis (...) + struct TImageInfo + { + IImage *image; + short offset; + short xpos; + short width; + }; + CUtlVector<TImageInfo> _imageDar; + + int _textInset[2]; + Color _disabledFgColor1; + Color _disabledFgColor2; + Color _associateColor; + int _textImageIndex; // index in the image array that the default _textimage resides + EColorState _textColorState; + + PHandle _associate; + char *_associateName; + + char *_fontOverrideName; + + wchar_t _hotkey; // the hotkey contained in the text + + bool m_bWrap; + bool m_bCenterWrap; + bool m_bAllCaps; + bool m_bAutoWideToContents; + bool m_bAutoWideDirty; + bool m_bUseProportionalInsets; + +}; + +} // namespace vgui + +#endif // LABEL_H diff --git a/mp/src/public/vgui_controls/ListPanel.h b/mp/src/public/vgui_controls/ListPanel.h index ce19f28b..9248856e 100644 --- a/mp/src/public/vgui_controls/ListPanel.h +++ b/mp/src/public/vgui_controls/ListPanel.h @@ -1,371 +1,371 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef LISTPANEL_H
-#define LISTPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utllinkedlist.h>
-#include <utlvector.h>
-#include <utlrbtree.h>
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-class KeyValues;
-
-namespace vgui
-{
-
-class ScrollBar;
-class TextImage;
-class ImagePanel;
-class Label;
-class Button;
-class IDraggerEvent;
-class FastSortListPanelItem;
-
-//-----------------------------------------------------------------------------
-// Purpose: Generic class for ListPanel items
-//-----------------------------------------------------------------------------
-class ListPanelItem
-{
-public:
- ListPanelItem() :
- kv( 0 ),
- userData( 0 ),
- m_pDragData( 0 ),
- m_bImage( false ),
- m_nImageIndex( -1 ),
- m_nImageIndexSelected( -1 ),
- m_pIcon( 0 )
- {
- }
-
- KeyValues *kv;
- unsigned int userData;
- KeyValues *m_pDragData;
- bool m_bImage;
- int m_nImageIndex;
- int m_nImageIndexSelected;
- IImage *m_pIcon;
-};
-
-typedef int __cdecl SortFunc(
- ListPanel *pPanel,
- const ListPanelItem &item1,
- const ListPanelItem &item2 );
-
-//-----------------------------------------------------------------------------
-// Purpose: A spread-sheet type data view, similar to MFC's
-//-----------------------------------------------------------------------------
-class ListPanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( ListPanel, Panel );
-
-public:
- ListPanel(Panel *parent, const char *panelName);
- ~ListPanel();
-
- // COLUMN HANDLING
- // all indices are 0 based, limit of 255 columns
- // columns are resizable by default
- enum ColumnFlags_e
- {
- COLUMN_FIXEDSIZE = 0x01, // set to have the column be a fixed size
- COLUMN_RESIZEWITHWINDOW = 0x02, // set to have the column grow with the parent dialog growing
- COLUMN_IMAGE = 0x04, // set if the column data is not text, but instead the index of the image to display
- COLUMN_HIDDEN = 0x08, // column is hidden by default
- COLUMN_UNHIDABLE = 0x10, // column is unhidable
- };
-
- // adds a column header
- virtual void AddColumnHeader(int index, const char *columnName, const char *columnText, int startingWidth, int minWidth, int maxWidth, int columnFlags = 0);
- virtual void AddColumnHeader(int index, const char *columnName, const char *columnText, int width, int columnFlags = 0);
-
- virtual void RemoveColumn(int column); // removes a column
- virtual int FindColumn(const char *columnName);
- virtual void SetColumnHeaderHeight( int height );
- virtual void SetColumnHeaderText(int column, const char *text);
- virtual void SetColumnHeaderText(int column, wchar_t *text);
- virtual void SetColumnHeaderImage(int column, int imageListIndex);
- virtual void SetColumnHeaderTooltip(int column, const char *tooltipText);
- virtual void SetColumnTextAlignment( int column, int align );
-
- // Get information about the column headers.
- virtual int GetNumColumnHeaders() const;
- virtual bool GetColumnHeaderText( int index, char *pOut, int maxLen );
-
- virtual void SetSortFunc(int column, SortFunc *func);
- virtual void SetSortColumn(int column);
- virtual void SortList( void );
- virtual void SetColumnSortable(int column, bool sortable);
- virtual void SetColumnVisible(int column, bool visible);
- int GetSortColumn() const;
-
- // sets whether the user can add/remove columns (defaults to off)
- virtual void SetAllowUserModificationOfColumns(bool allowed);
-
- // DATA HANDLING
- // data->GetName() is used to uniquely identify an item
- // data sub items are matched against column header name to be used in the table
- virtual int AddItem(const KeyValues *data, unsigned int userData, bool bScrollToItem, bool bSortOnAdd); // Takes a copy of the data for use in the table. Returns the index the item is at.
- void SetItemDragData( int itemID, const KeyValues *data ); // Makes a copy of the keyvalues to store in the table. Used when dragging from the table. Only used if the caller enables drag support
- virtual int GetItemCount( void ); // returns the number of VISIBLE items
- virtual int GetItem(const char *itemName); // gets the row index of an item by name (data->GetName())
- virtual KeyValues *GetItem(int itemID); // returns pointer to data the row holds
- virtual int GetItemCurrentRow(int itemID); // returns -1 if invalid index or item not visible
- virtual int GetItemIDFromRow(int currentRow); // returns -1 if invalid row
- virtual unsigned int GetItemUserData(int itemID);
- virtual ListPanelItem *GetItemData(int itemID);
- virtual void SetUserData( int itemID, unsigned int userData );
- virtual int GetItemIDFromUserData( unsigned int userData );
- virtual void ApplyItemChanges(int itemID); // applies any changes to the data, performed by modifying the return of GetItem() above
- virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items)
- virtual void RereadAllItems(); // updates the view with the new data
-
- virtual void RemoveAll(); // clears and deletes all the memory used by the data items
- virtual void DeleteAllItems(); // obselete, use RemoveAll();
-
- virtual void GetCellText(int itemID, int column, OUT_Z_BYTECAP(bufferSizeInBytes) wchar_t *buffer, int bufferSizeInBytes); // returns the data held by a specific cell
- virtual IImage *GetCellImage(int itemID, int column); //, ImagePanel *&buffer); // returns the image held by a specific cell
-
- // Use these until they return InvalidItemID to iterate all the items.
- virtual int FirstItem() const;
- virtual int NextItem( int iItem ) const;
-
- virtual int InvalidItemID() const;
- virtual bool IsValidItemID(int itemID);
-
- // sets whether the dataitem is visible or not
- // it is removed from the row list when it becomes invisible, but stays in the indexes
- // this is much faster than a normal remove
- virtual void SetItemVisible(int itemID, bool state);
- virtual void SetItemDisabled(int itemID, bool state );
- bool IsItemVisible( int itemID );
-
- virtual void SetFont(HFont font);
-
- // image handling
- virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone);
-
- // SELECTION
-
- // returns the count of selected items
- virtual int GetSelectedItemsCount();
-
- // returns the selected item by selection index, valid in range [0, GetNumSelectedRows)
- virtual int GetSelectedItem(int selectionIndex);
-
- // sets no item as selected
- virtual void ClearSelectedItems();
-
- virtual bool IsItemSelected( int itemID );
-
- // adds a item to the select list
- virtual void AddSelectedItem( int itemID );
-
- // sets this single item as the only selected item
- virtual void SetSingleSelectedItem( int itemID );
-
- // returns the selected column, -1 for particular column selected
- virtual int GetSelectedColumn();
-
- // whether or not to select specific cells (off by default)
- virtual void SetSelectIndividualCells(bool state);
-
- // whether or not multiple cells/rows can be selected
- void SetMultiselectEnabled( bool bState );
- bool IsMultiselectEnabled() const;
-
- // sets a single cell - all other previous rows are cleared
- virtual void SetSelectedCell(int row, int column);
-
- virtual bool GetCellAtPos(int x, int y, int &row, int &column); // returns true if any found, row and column are filled out. x, y are in screen space
- virtual bool GetCellBounds( int row, int column, int& x, int& y, int& wide, int& tall );
-
- // sets the text which is displayed when the list is empty
- virtual void SetEmptyListText(const char *text);
- virtual void SetEmptyListText(const wchar_t *text);
-
- // relayout the scroll bar in response to changing the items in the list panel
- // do this if you RemoveAll()
- void ResetScrollBar();
-
- // Attaches drag data to a particular item
- virtual void OnCreateDragData( KeyValues *msg );
-
- void SetIgnoreDoubleClick( bool state );
-
- // set up a field for editing
- virtual void EnterEditMode(int itemID, int column, vgui::Panel *editPanel);
-
- // leaves editing mode
- virtual void LeaveEditMode();
-
- // returns true if we are currently in inline editing mode
- virtual bool IsInEditMode();
-
- MESSAGE_FUNC_INT( ResizeColumnToContents, "ResizeColumnToContents", column );
-
-#ifdef _X360
- virtual void NavigateTo();
-#endif
- /// Version number for file format of user config. This defaults to 1,
- /// and if you rearrange columns you can increment it to cause any old
- /// user configs (which will be screwed up) to be discarded.
- int m_nUserConfigFileVersion;
-
-protected:
- // PAINTING
- virtual Panel *GetCellRenderer(int row, int column);
-
- // overrides
- virtual void OnMouseWheeled(int delta);
- virtual void OnSizeChanged(int wide, int tall);
- virtual void PerformLayout();
- virtual void Paint();
- virtual void PaintBackground();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnMousePressed( MouseCode code );
- virtual void OnMouseDoublePressed( MouseCode code );
-#ifdef _X360
- virtual void OnKeyCodePressed(KeyCode code);
-#else
- virtual void OnKeyCodePressed( KeyCode code );
-#endif
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" );
- MESSAGE_FUNC_INT_INT( OnColumnResized, "ColumnResized", column, delta );
- MESSAGE_FUNC_INT( OnSetSortColumn, "SetSortColumn", column );
- MESSAGE_FUNC( OpenColumnChoiceMenu, "OpenColumnChoiceMenu" );
- MESSAGE_FUNC_INT( OnToggleColumnVisible, "ToggleColumnVisible", col );
- virtual float GetRowsPerPage();
- virtual int GetStartItem();
-
- // user configuration
- virtual void ApplyUserConfigSettings(KeyValues *userConfig);
- virtual void GetUserConfigSettings(KeyValues *userConfig);
- virtual bool HasUserConfigSettings();
-
- /* MESSAGES SENT
- "ItemSelected" - query which items are selected
- "ItemDeselected" - query which items are selected
- */
-
-public:
- virtual void SetSortColumnEx( int iPrimarySortColumn, int iSecondarySortColumn, bool bSortAscending );
- void GetSortColumnEx( int &iPrimarySortColumn, int &iSecondarySortColumn, bool &bSortAscending ) const;
-
-private:
- // Cleans up allocations associated with a particular item
- void CleanupItem( FastSortListPanelItem *data );
-
- // adds the item into the column indexes
- void IndexItem(int itemID);
-
- // Purpose:
- void UpdateSelection( vgui::MouseCode code, int x, int y, int row, int column );
-
- // Handles multiselect
- void HandleMultiSelection( int itemID, int row, int column );
-
- // Handles addselect
- void HandleAddSelection( int itemID, int row, int column );
-
- // pre-sorted columns
- struct IndexItem_t
- {
- ListPanelItem *dataItem;
- int duplicateIndex;
- };
- typedef CUtlRBTree<IndexItem_t, int> IndexRBTree_t;
-
- struct column_t
- {
- Button *m_pHeader;
- int m_iMinWidth;
- int m_iMaxWidth;
- bool m_bResizesWithWindow;
- Panel *m_pResizer;
- SortFunc *m_pSortFunc;
- bool m_bTypeIsText;
- bool m_bHidden;
- bool m_bUnhidable;
- IndexRBTree_t m_SortedTree;
- int m_nContentAlignment;
- };
-
- // list of the column headers
- CUtlLinkedList<column_t, unsigned char> m_ColumnsData;
-
- // persistent list of all columns ever created, indexes into m_ColumnsData - used for matching up DATAITEM m_SortedTreeIndexes
- CUtlVector<unsigned char> m_ColumnsHistory;
-
- // current list of columns, indexes into m_ColumnsData
- CUtlVector<unsigned char> m_CurrentColumns;
-
- int m_iColumnDraggerMoved; // which column dragger was moved->which header to resize
- int m_lastBarWidth;
-
- CUtlLinkedList<FastSortListPanelItem*, int> m_DataItems;
- CUtlVector<int> m_VisibleItems;
-
- // set to true if the table needs to be sorted before it's drawn next
- int m_iSortColumn;
- int m_iSortColumnSecondary;
-
- void ResortColumnRBTree(int col);
- static bool RBTreeLessFunc(vgui::ListPanel::IndexItem_t &item1, vgui::ListPanel::IndexItem_t &item2);
-
- TextImage *m_pTextImage; // used in rendering
- ImagePanel *m_pImagePanel; // used in rendering
- Label *m_pLabel; // used in rendering
- ScrollBar *m_hbar;
- ScrollBar *m_vbar;
-
- int m_iSelectedColumn;
-
- bool m_bNeedsSort : 1;
- bool m_bSortAscending : 1;
- bool m_bSortAscendingSecondary : 1;
- bool m_bCanSelectIndividualCells : 1;
- bool m_bShiftHeldDown : 1;
- bool m_bMultiselectEnabled : 1;
- bool m_bAllowUserAddDeleteColumns : 1;
- bool m_bDeleteImageListWhenDone : 1;
- bool m_bIgnoreDoubleClick : 1;
-
- int m_iHeaderHeight;
- int m_iRowHeight;
-
- // selection data
- CUtlVector<int> m_SelectedItems; // array of selected rows
- int m_LastItemSelected; // remember the last row selected for future shift clicks
-
- int m_iTableStartX;
- int m_iTableStartY;
-
- Color m_LabelFgColor;
- Color m_DisabledColor;
- Color m_SelectionFgColor;
- Color m_DisabledSelectionFgColor;
-
- ImageList *m_pImageList;
- TextImage *m_pEmptyListText;
-
- PHandle m_hEditModePanel;
- int m_iEditModeItemID;
- int m_iEditModeColumn;
-
- void ResetColumnHeaderCommands();
-};
-
-}
-
-#endif // LISTPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef LISTPANEL_H +#define LISTPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utllinkedlist.h> +#include <utlvector.h> +#include <utlrbtree.h> +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +class KeyValues; + +namespace vgui +{ + +class ScrollBar; +class TextImage; +class ImagePanel; +class Label; +class Button; +class IDraggerEvent; +class FastSortListPanelItem; + +//----------------------------------------------------------------------------- +// Purpose: Generic class for ListPanel items +//----------------------------------------------------------------------------- +class ListPanelItem +{ +public: + ListPanelItem() : + kv( 0 ), + userData( 0 ), + m_pDragData( 0 ), + m_bImage( false ), + m_nImageIndex( -1 ), + m_nImageIndexSelected( -1 ), + m_pIcon( 0 ) + { + } + + KeyValues *kv; + unsigned int userData; + KeyValues *m_pDragData; + bool m_bImage; + int m_nImageIndex; + int m_nImageIndexSelected; + IImage *m_pIcon; +}; + +typedef int __cdecl SortFunc( + ListPanel *pPanel, + const ListPanelItem &item1, + const ListPanelItem &item2 ); + +//----------------------------------------------------------------------------- +// Purpose: A spread-sheet type data view, similar to MFC's +//----------------------------------------------------------------------------- +class ListPanel : public Panel +{ + DECLARE_CLASS_SIMPLE( ListPanel, Panel ); + +public: + ListPanel(Panel *parent, const char *panelName); + ~ListPanel(); + + // COLUMN HANDLING + // all indices are 0 based, limit of 255 columns + // columns are resizable by default + enum ColumnFlags_e + { + COLUMN_FIXEDSIZE = 0x01, // set to have the column be a fixed size + COLUMN_RESIZEWITHWINDOW = 0x02, // set to have the column grow with the parent dialog growing + COLUMN_IMAGE = 0x04, // set if the column data is not text, but instead the index of the image to display + COLUMN_HIDDEN = 0x08, // column is hidden by default + COLUMN_UNHIDABLE = 0x10, // column is unhidable + }; + + // adds a column header + virtual void AddColumnHeader(int index, const char *columnName, const char *columnText, int startingWidth, int minWidth, int maxWidth, int columnFlags = 0); + virtual void AddColumnHeader(int index, const char *columnName, const char *columnText, int width, int columnFlags = 0); + + virtual void RemoveColumn(int column); // removes a column + virtual int FindColumn(const char *columnName); + virtual void SetColumnHeaderHeight( int height ); + virtual void SetColumnHeaderText(int column, const char *text); + virtual void SetColumnHeaderText(int column, wchar_t *text); + virtual void SetColumnHeaderImage(int column, int imageListIndex); + virtual void SetColumnHeaderTooltip(int column, const char *tooltipText); + virtual void SetColumnTextAlignment( int column, int align ); + + // Get information about the column headers. + virtual int GetNumColumnHeaders() const; + virtual bool GetColumnHeaderText( int index, char *pOut, int maxLen ); + + virtual void SetSortFunc(int column, SortFunc *func); + virtual void SetSortColumn(int column); + virtual void SortList( void ); + virtual void SetColumnSortable(int column, bool sortable); + virtual void SetColumnVisible(int column, bool visible); + int GetSortColumn() const; + + // sets whether the user can add/remove columns (defaults to off) + virtual void SetAllowUserModificationOfColumns(bool allowed); + + // DATA HANDLING + // data->GetName() is used to uniquely identify an item + // data sub items are matched against column header name to be used in the table + virtual int AddItem(const KeyValues *data, unsigned int userData, bool bScrollToItem, bool bSortOnAdd); // Takes a copy of the data for use in the table. Returns the index the item is at. + void SetItemDragData( int itemID, const KeyValues *data ); // Makes a copy of the keyvalues to store in the table. Used when dragging from the table. Only used if the caller enables drag support + virtual int GetItemCount( void ); // returns the number of VISIBLE items + virtual int GetItem(const char *itemName); // gets the row index of an item by name (data->GetName()) + virtual KeyValues *GetItem(int itemID); // returns pointer to data the row holds + virtual int GetItemCurrentRow(int itemID); // returns -1 if invalid index or item not visible + virtual int GetItemIDFromRow(int currentRow); // returns -1 if invalid row + virtual unsigned int GetItemUserData(int itemID); + virtual ListPanelItem *GetItemData(int itemID); + virtual void SetUserData( int itemID, unsigned int userData ); + virtual int GetItemIDFromUserData( unsigned int userData ); + virtual void ApplyItemChanges(int itemID); // applies any changes to the data, performed by modifying the return of GetItem() above + virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items) + virtual void RereadAllItems(); // updates the view with the new data + + virtual void RemoveAll(); // clears and deletes all the memory used by the data items + virtual void DeleteAllItems(); // obselete, use RemoveAll(); + + virtual void GetCellText(int itemID, int column, OUT_Z_BYTECAP(bufferSizeInBytes) wchar_t *buffer, int bufferSizeInBytes); // returns the data held by a specific cell + virtual IImage *GetCellImage(int itemID, int column); //, ImagePanel *&buffer); // returns the image held by a specific cell + + // Use these until they return InvalidItemID to iterate all the items. + virtual int FirstItem() const; + virtual int NextItem( int iItem ) const; + + virtual int InvalidItemID() const; + virtual bool IsValidItemID(int itemID); + + // sets whether the dataitem is visible or not + // it is removed from the row list when it becomes invisible, but stays in the indexes + // this is much faster than a normal remove + virtual void SetItemVisible(int itemID, bool state); + virtual void SetItemDisabled(int itemID, bool state ); + bool IsItemVisible( int itemID ); + + virtual void SetFont(HFont font); + + // image handling + virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone); + + // SELECTION + + // returns the count of selected items + virtual int GetSelectedItemsCount(); + + // returns the selected item by selection index, valid in range [0, GetNumSelectedRows) + virtual int GetSelectedItem(int selectionIndex); + + // sets no item as selected + virtual void ClearSelectedItems(); + + virtual bool IsItemSelected( int itemID ); + + // adds a item to the select list + virtual void AddSelectedItem( int itemID ); + + // sets this single item as the only selected item + virtual void SetSingleSelectedItem( int itemID ); + + // returns the selected column, -1 for particular column selected + virtual int GetSelectedColumn(); + + // whether or not to select specific cells (off by default) + virtual void SetSelectIndividualCells(bool state); + + // whether or not multiple cells/rows can be selected + void SetMultiselectEnabled( bool bState ); + bool IsMultiselectEnabled() const; + + // sets a single cell - all other previous rows are cleared + virtual void SetSelectedCell(int row, int column); + + virtual bool GetCellAtPos(int x, int y, int &row, int &column); // returns true if any found, row and column are filled out. x, y are in screen space + virtual bool GetCellBounds( int row, int column, int& x, int& y, int& wide, int& tall ); + + // sets the text which is displayed when the list is empty + virtual void SetEmptyListText(const char *text); + virtual void SetEmptyListText(const wchar_t *text); + + // relayout the scroll bar in response to changing the items in the list panel + // do this if you RemoveAll() + void ResetScrollBar(); + + // Attaches drag data to a particular item + virtual void OnCreateDragData( KeyValues *msg ); + + void SetIgnoreDoubleClick( bool state ); + + // set up a field for editing + virtual void EnterEditMode(int itemID, int column, vgui::Panel *editPanel); + + // leaves editing mode + virtual void LeaveEditMode(); + + // returns true if we are currently in inline editing mode + virtual bool IsInEditMode(); + + MESSAGE_FUNC_INT( ResizeColumnToContents, "ResizeColumnToContents", column ); + +#ifdef _X360 + virtual void NavigateTo(); +#endif + /// Version number for file format of user config. This defaults to 1, + /// and if you rearrange columns you can increment it to cause any old + /// user configs (which will be screwed up) to be discarded. + int m_nUserConfigFileVersion; + +protected: + // PAINTING + virtual Panel *GetCellRenderer(int row, int column); + + // overrides + virtual void OnMouseWheeled(int delta); + virtual void OnSizeChanged(int wide, int tall); + virtual void PerformLayout(); + virtual void Paint(); + virtual void PaintBackground(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnMousePressed( MouseCode code ); + virtual void OnMouseDoublePressed( MouseCode code ); +#ifdef _X360 + virtual void OnKeyCodePressed(KeyCode code); +#else + virtual void OnKeyCodePressed( KeyCode code ); +#endif + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); + MESSAGE_FUNC_INT_INT( OnColumnResized, "ColumnResized", column, delta ); + MESSAGE_FUNC_INT( OnSetSortColumn, "SetSortColumn", column ); + MESSAGE_FUNC( OpenColumnChoiceMenu, "OpenColumnChoiceMenu" ); + MESSAGE_FUNC_INT( OnToggleColumnVisible, "ToggleColumnVisible", col ); + virtual float GetRowsPerPage(); + virtual int GetStartItem(); + + // user configuration + virtual void ApplyUserConfigSettings(KeyValues *userConfig); + virtual void GetUserConfigSettings(KeyValues *userConfig); + virtual bool HasUserConfigSettings(); + + /* MESSAGES SENT + "ItemSelected" - query which items are selected + "ItemDeselected" - query which items are selected + */ + +public: + virtual void SetSortColumnEx( int iPrimarySortColumn, int iSecondarySortColumn, bool bSortAscending ); + void GetSortColumnEx( int &iPrimarySortColumn, int &iSecondarySortColumn, bool &bSortAscending ) const; + +private: + // Cleans up allocations associated with a particular item + void CleanupItem( FastSortListPanelItem *data ); + + // adds the item into the column indexes + void IndexItem(int itemID); + + // Purpose: + void UpdateSelection( vgui::MouseCode code, int x, int y, int row, int column ); + + // Handles multiselect + void HandleMultiSelection( int itemID, int row, int column ); + + // Handles addselect + void HandleAddSelection( int itemID, int row, int column ); + + // pre-sorted columns + struct IndexItem_t + { + ListPanelItem *dataItem; + int duplicateIndex; + }; + typedef CUtlRBTree<IndexItem_t, int> IndexRBTree_t; + + struct column_t + { + Button *m_pHeader; + int m_iMinWidth; + int m_iMaxWidth; + bool m_bResizesWithWindow; + Panel *m_pResizer; + SortFunc *m_pSortFunc; + bool m_bTypeIsText; + bool m_bHidden; + bool m_bUnhidable; + IndexRBTree_t m_SortedTree; + int m_nContentAlignment; + }; + + // list of the column headers + CUtlLinkedList<column_t, unsigned char> m_ColumnsData; + + // persistent list of all columns ever created, indexes into m_ColumnsData - used for matching up DATAITEM m_SortedTreeIndexes + CUtlVector<unsigned char> m_ColumnsHistory; + + // current list of columns, indexes into m_ColumnsData + CUtlVector<unsigned char> m_CurrentColumns; + + int m_iColumnDraggerMoved; // which column dragger was moved->which header to resize + int m_lastBarWidth; + + CUtlLinkedList<FastSortListPanelItem*, int> m_DataItems; + CUtlVector<int> m_VisibleItems; + + // set to true if the table needs to be sorted before it's drawn next + int m_iSortColumn; + int m_iSortColumnSecondary; + + void ResortColumnRBTree(int col); + static bool RBTreeLessFunc(vgui::ListPanel::IndexItem_t &item1, vgui::ListPanel::IndexItem_t &item2); + + TextImage *m_pTextImage; // used in rendering + ImagePanel *m_pImagePanel; // used in rendering + Label *m_pLabel; // used in rendering + ScrollBar *m_hbar; + ScrollBar *m_vbar; + + int m_iSelectedColumn; + + bool m_bNeedsSort : 1; + bool m_bSortAscending : 1; + bool m_bSortAscendingSecondary : 1; + bool m_bCanSelectIndividualCells : 1; + bool m_bShiftHeldDown : 1; + bool m_bMultiselectEnabled : 1; + bool m_bAllowUserAddDeleteColumns : 1; + bool m_bDeleteImageListWhenDone : 1; + bool m_bIgnoreDoubleClick : 1; + + int m_iHeaderHeight; + int m_iRowHeight; + + // selection data + CUtlVector<int> m_SelectedItems; // array of selected rows + int m_LastItemSelected; // remember the last row selected for future shift clicks + + int m_iTableStartX; + int m_iTableStartY; + + Color m_LabelFgColor; + Color m_DisabledColor; + Color m_SelectionFgColor; + Color m_DisabledSelectionFgColor; + + ImageList *m_pImageList; + TextImage *m_pEmptyListText; + + PHandle m_hEditModePanel; + int m_iEditModeItemID; + int m_iEditModeColumn; + + void ResetColumnHeaderCommands(); +}; + +} + +#endif // LISTPANEL_H diff --git a/mp/src/public/vgui_controls/ListViewPanel.h b/mp/src/public/vgui_controls/ListViewPanel.h index e0fe4f41..39f1bec7 100644 --- a/mp/src/public/vgui_controls/ListViewPanel.h +++ b/mp/src/public/vgui_controls/ListViewPanel.h @@ -1,121 +1,121 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef LISTVIEWPANEL_H
-#define LISTVIEWPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utllinkedlist.h>
-#include <utlvector.h>
-
-namespace vgui
-{
-
-class ListViewPanel;
-typedef bool (*ListViewSortFunc_t)(KeyValues *kv1, KeyValues *kv2);
-
-class ListViewItem;
-
-//-----------------------------------------------------------------------------
-// Purpose: List Ctrl Panel with each item having an icon and text after it
-//-----------------------------------------------------------------------------
-class ListViewPanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( ListViewPanel, Panel );
-
-public:
- ListViewPanel(Panel *parent, const char *panelName);
- ~ListViewPanel();
-
- virtual int AddItem(const KeyValues *data, bool bScrollToItem, bool bSortOnAdd);
- virtual int GetItemCount();
- virtual KeyValues *GetItem(int itemID);
- virtual void ApplyItemChanges(int itemID);
- virtual void RemoveItem(int itemID);
- virtual void DeleteAllItems();
- virtual int GetItemIDFromPos(int iPos); // valid from [0, GetItemCount)
-
- virtual int InvalidItemID();
- virtual bool IsValidItemID(int itemID);
-
- virtual void ScrollToItem(int itemID);
-
- virtual void SetSortFunc(ListViewSortFunc_t func);
- virtual void SortList();
-
- // image handling
- virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone);
-
- virtual void SetFont(HFont font);
-
- // returns the count of selected items
- virtual int GetSelectedItemsCount();
-
- // returns the selected item by selection index, valid in range [0, GetNumSelectedRows)
- virtual int GetSelectedItem(int selectionIndex);
-
- // sets no item as selected
- virtual void ClearSelectedItems();
-
- // adds a item to the select list
- virtual void AddSelectedItem(int itemID);
-
- // sets this single item as the only selected item
- virtual void SetSingleSelectedItem(int itemID);
-
-protected:
- // overrides
- virtual void OnMouseWheeled(int delta);
- virtual void OnSizeChanged(int wide, int tall);
- virtual void PerformLayout();
- virtual void Paint();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnMousePressed( MouseCode code);
- virtual void OnMouseDoublePressed( MouseCode code);
- virtual void OnKeyCodeTyped( KeyCode code);
- virtual void OnKeyTyped(wchar_t unichar);
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" );
- virtual int GetItemsPerColumn();
-
-private:
- ScrollBar *m_hbar;
-
- friend class ListViewItem;
- void OnItemMousePressed(ListViewItem* pItem, MouseCode code);
- void OnItemMouseDoublePressed(ListViewItem* pItem, MouseCode code);
- int GetItemsMaxWidth();
- int GetItemIndex(int itemID);
- void OnShiftSelect(int itemID);
- void FinishKeyPress(int itemID);
-
- CUtlLinkedList<ListViewItem*, int> m_DataItems;
- CUtlVector<int> m_SortedItems;
- ListViewSortFunc_t m_pSortFunc;
-
- int m_iRowHeight;
- HFont m_hFont;
-
- Color m_LabelFgColor;
- Color m_SelectionFgColor;
-
- // selection data
- CUtlVector<int> m_SelectedItems;
- int m_LastSelectedItemID;
- int m_ShiftStartItemID;
-
- bool m_bNeedsSort;
- bool m_bDeleteImageListWhenDone;
- ImageList *m_pImageList;
-};
-
-
-}
-
-#endif // LISTVIEWPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef LISTVIEWPANEL_H +#define LISTVIEWPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utllinkedlist.h> +#include <utlvector.h> + +namespace vgui +{ + +class ListViewPanel; +typedef bool (*ListViewSortFunc_t)(KeyValues *kv1, KeyValues *kv2); + +class ListViewItem; + +//----------------------------------------------------------------------------- +// Purpose: List Ctrl Panel with each item having an icon and text after it +//----------------------------------------------------------------------------- +class ListViewPanel : public Panel +{ + DECLARE_CLASS_SIMPLE( ListViewPanel, Panel ); + +public: + ListViewPanel(Panel *parent, const char *panelName); + ~ListViewPanel(); + + virtual int AddItem(const KeyValues *data, bool bScrollToItem, bool bSortOnAdd); + virtual int GetItemCount(); + virtual KeyValues *GetItem(int itemID); + virtual void ApplyItemChanges(int itemID); + virtual void RemoveItem(int itemID); + virtual void DeleteAllItems(); + virtual int GetItemIDFromPos(int iPos); // valid from [0, GetItemCount) + + virtual int InvalidItemID(); + virtual bool IsValidItemID(int itemID); + + virtual void ScrollToItem(int itemID); + + virtual void SetSortFunc(ListViewSortFunc_t func); + virtual void SortList(); + + // image handling + virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone); + + virtual void SetFont(HFont font); + + // returns the count of selected items + virtual int GetSelectedItemsCount(); + + // returns the selected item by selection index, valid in range [0, GetNumSelectedRows) + virtual int GetSelectedItem(int selectionIndex); + + // sets no item as selected + virtual void ClearSelectedItems(); + + // adds a item to the select list + virtual void AddSelectedItem(int itemID); + + // sets this single item as the only selected item + virtual void SetSingleSelectedItem(int itemID); + +protected: + // overrides + virtual void OnMouseWheeled(int delta); + virtual void OnSizeChanged(int wide, int tall); + virtual void PerformLayout(); + virtual void Paint(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnMousePressed( MouseCode code); + virtual void OnMouseDoublePressed( MouseCode code); + virtual void OnKeyCodeTyped( KeyCode code); + virtual void OnKeyTyped(wchar_t unichar); + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); + virtual int GetItemsPerColumn(); + +private: + ScrollBar *m_hbar; + + friend class ListViewItem; + void OnItemMousePressed(ListViewItem* pItem, MouseCode code); + void OnItemMouseDoublePressed(ListViewItem* pItem, MouseCode code); + int GetItemsMaxWidth(); + int GetItemIndex(int itemID); + void OnShiftSelect(int itemID); + void FinishKeyPress(int itemID); + + CUtlLinkedList<ListViewItem*, int> m_DataItems; + CUtlVector<int> m_SortedItems; + ListViewSortFunc_t m_pSortFunc; + + int m_iRowHeight; + HFont m_hFont; + + Color m_LabelFgColor; + Color m_SelectionFgColor; + + // selection data + CUtlVector<int> m_SelectedItems; + int m_LastSelectedItemID; + int m_ShiftStartItemID; + + bool m_bNeedsSort; + bool m_bDeleteImageListWhenDone; + ImageList *m_pImageList; +}; + + +} + +#endif // LISTVIEWPANEL_H diff --git a/mp/src/public/vgui_controls/Menu.h b/mp/src/public/vgui_controls/Menu.h index dffeb3f6..2b374373 100644 --- a/mp/src/public/vgui_controls/Menu.h +++ b/mp/src/public/vgui_controls/Menu.h @@ -1,356 +1,356 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef MENU_H
-#define MENU_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/Label.h>
-#include <utllinkedlist.h>
-#include <utlvector.h>
-
-namespace vgui
-{
-
-class MenuItem;
-class ScrollBar;
-class MenuSeparator;
-
-//-----------------------------------------------------------------------------
-// Purpose: A menu is a list of items that can be selected with one click, navigated
-// with arrow keys and/or hot keys, and have a lit behavior when mouse over.
-// It is NOT the button which opens the menu, but only the menu itself.
-//
-// Behaviour spec:
-// Menu navigation can be done in 2 modes, via keyboard keys and via mouse.
-// Clicking on menu button opens menu.
-// Only one item in a menu is highlighted at a time.
-// Only one submenu in a menu is open at a time.
-// Disabled menuitems get highlighted via mouse and keys but will not activate.
-//
-// Mouse:
-// Moving mouse into a menuitem highlights it.
-// If the menuitem has a cascading menu, the menu opens when the mouse enters
-// the menuitem. The cascading menuitem stays highlighted while its menu is open.
-// No submenu items are highlighted by default.
-// Moving the mouse into another menuitem closes any previously open submenus in the list.
-// Clicking once in the menu item activates the menu item and closes all menus.
-// Moving the mouse off a menuitem unhighlights it.
-// The scroll bar arrows can be used to move up/down the menu one item at a time.
-// The clicking and dragging on the scroll bar nob also scrolls the menu items.
-// If a highlighed menuitem scrolls off, and the user then begins navigating via keys,
-// the menu will snap the scroll bar so the highlighted item is visible.
-// If user has been navigating via keys, moving the mouse over a menu item
-// highlights it.
-// Mousewheel:
-// You must have the mouse inside the menu/scroll bar to use the wheel.
-// The mouse wheel moves the highlighted menuitem up or down the list.
-// If the list has no scroll bar the wheel will cycle from the bottom of the list
-// to the top of the list and vice versa.
-// If the list has a scrollbar the mouse wheel will stop at the top or bottom
-// of the list.
-// If the mouse is over the scroll bar no items are highlighted.
-// Keyboard:
-// When a menu is opened, no items are highlighted.
-// If a menuitem has a cascading menu it does not open when the item is highlighted.
-// The down arrow selects the next item in the list.
-// (first item if none are highlighted and there is a scrollbar).
-// The up arrow selects the previous item in the list
-// (first item if none are highlighted and there is a scrollbar, last item if none are
-// highlighted and there is no scrollbar).
-// Selecting a new menuitem closes any previously open submenus in the list.
-// The enter key activates the selected item and closes all menus.
-// If the selected item has a cascading menu, activating it opens its submenu.
-// These may also be activated by pressing the right arrow.
-// Pressing the left arrow closes the submenu.
-// When the submenu is opened the cascading menuitem stays highlighted.
-// No items in the submenu are highlighted when it is opened.
-//
-// Note: Cascading menuitems in menus with a scrollbar is not supported.
-// Its a clunky UI and if we want this we should design a better solution,
-// perhaps along the lines of how explorer's bookmarks does it.
-// It currently functions, but there are some arm/disarm bugs.
-//
-//
-//-----------------------------------------------------------------------------
-class Menu : public Panel
-{
- DECLARE_CLASS_SIMPLE( Menu, Panel );
- friend class MenuItem;
-public:
- enum MenuDirection_e
- {
- LEFT,
- RIGHT,
- UP,
- DOWN,
- CURSOR, // make the menu appear under the mouse cursor
- ALIGN_WITH_PARENT, // make the menu appear under the parent
- };
-
- Menu(Panel *parent, const char *panelName);
- ~Menu();
-
- static void PlaceContextMenu( Panel *parent, Menu *menu );
- static void OnInternalMousePressed( Panel *other, MouseCode code );
-
- virtual void PositionRelativeToPanel( Panel *reference, MenuDirection_e direction, int nAdditionalYOffset = 0, bool showMenu = false );
-
- // the menu. For combo boxes, it's the edit/field, etc. etc.
-
- // Add a simple text item to the menu
- virtual int AddMenuItem( const char *itemName, const char *itemText, const char *command, Panel *target, const KeyValues *userData = NULL );
- virtual int AddMenuItem( const char *itemName, const wchar_t *wszItemText, const char *command, Panel *target, const KeyValues *userData = NULL );
-
- virtual int AddMenuItem( const char *itemName, const char *itemText, KeyValues *message, Panel *target , const KeyValues *userData = NULL);
- virtual int AddMenuItem( const char *itemName, const wchar_t *wszItemText, KeyValues *message, Panel *target , const KeyValues *userData = NULL);
-
- virtual int AddMenuItem( const char *itemText, const char *command, Panel *target , const KeyValues *userData = NULL);
- virtual int AddMenuItem( const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL );
- virtual int AddMenuItem( const char *itemText, Panel *target, const KeyValues *userData = NULL );
-
- // Add a checkable item to the menu
- virtual int AddCheckableMenuItem( const char *itemName, const char *itemText, const char *command, Panel *target, const KeyValues *userData = NULL );
- virtual int AddCheckableMenuItem( const char *itemName, const wchar_t *wszItemText, const char *command, Panel *target, const KeyValues *userData = NULL );
-
- virtual int AddCheckableMenuItem( const char *itemName, const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL );
- virtual int AddCheckableMenuItem( const char *itemName, const wchar_t *wszItemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL );
-
- virtual int AddCheckableMenuItem( const char *itemText, const char *command, Panel *target , const KeyValues *userData = NULL);
- virtual int AddCheckableMenuItem( const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL );
- virtual int AddCheckableMenuItem( const char *itemText, Panel *target, const KeyValues *userData = NULL );
-
- // Add a cascading menu item to the menu
- virtual int AddCascadingMenuItem( const char *itemName, const char *itemText, const char *command, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
- virtual int AddCascadingMenuItem( const char *itemName, const wchar_t *wszItemText, const char *command, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
-
- virtual int AddCascadingMenuItem( const char *itemName, const char *itemText, KeyValues *message, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
- virtual int AddCascadingMenuItem( const char *itemName, const wchar_t *wszItemText, KeyValues *message, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
-
- virtual int AddCascadingMenuItem( const char *itemText, const char *command, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
- virtual int AddCascadingMenuItem( const char *itemText, KeyValues *message, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
- virtual int AddCascadingMenuItem( const char *itemText, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL );
-
- // Add a custom panel to the menu
- virtual int AddMenuItem( MenuItem *panel );
-
- virtual void AddSeparator();
- virtual void AddSeparatorAfterItem( int itemID );
-
- // Sets the values of a menu item at the specified index
- virtual void UpdateMenuItem(int itemID, const char *itemText,KeyValues *message, const KeyValues *userData = NULL);
- virtual void UpdateMenuItem(int itemID, const wchar_t *wszItemText,KeyValues *message, const KeyValues *userData = NULL);
-
- virtual void MoveMenuItem( int itemID, int moveBeforeThisItemID );
-
- virtual bool IsValidMenuID(int itemID);
- virtual int GetInvalidMenuID();
-
- KeyValues *GetItemUserData(int itemID);
- void GetItemText(int itemID, wchar_t *text, int bufLenInBytes);
- void GetItemText(int itemID, char *text, int bufLenInBytes);
-
- virtual void SetItemEnabled(const char *itemName, bool state);
- virtual void SetItemEnabled(int itemID, bool state);
- virtual void SetItemVisible(const char *itemName, bool visible);
- virtual void SetItemVisible(int itemID, bool visible);
-
- // Remove a single item
- void DeleteItem( int itemID );
-
- // Clear the menu, deleting all the menu items within
- void DeleteAllItems();
-
- // Override the auto-width setting with a single fixed width
- virtual void SetFixedWidth( int width );
-
- // Sets the content alignment of all items in the menu
- void SetContentAlignment( Label::Alignment alignment );
-
- // sets the height of each menu item
- virtual void SetMenuItemHeight(int itemHeight);
- virtual int GetMenuItemHeight() const;
-
- // Set the max number of items visible (scrollbar appears with more)
- virtual void SetNumberOfVisibleItems( int numItems );
-
- // Add the menu to the menu manager (see Menu::SetVisible())?
- void EnableUseMenuManager( bool bUseMenuManager );
-
- // Set up the menu items layout
- virtual void PerformLayout( void );
-
- virtual void SetBorder(class IBorder *border);
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
- // Set type ahead behaviour
- enum MenuTypeAheadMode
- {
- COMPAT_MODE = 0,
- HOT_KEY_MODE,
- TYPE_AHEAD_MODE,
- };
- virtual void SetTypeAheadMode(MenuTypeAheadMode mode);
- virtual int GetTypeAheadMode();
-
- // Hotkey handling
- virtual void OnKeyTyped(wchar_t unichar);
- // Menu nagivation etc.
- virtual void OnKeyCodeTyped( KeyCode code );
-
- // Visibility
- virtual void SetVisible(bool state);
-
- // Activates item in the menu list, as if that menu item had been selected by the user
- virtual void ActivateItem(int itemID);
- virtual void SilentActivateItem(int itemID); // activate item, but don't fire the action signal
- virtual void ActivateItemByRow(int row);
- virtual int GetActiveItem(); // returns the itemID (not the row) of the active item
-
- // Return the number of items currently in the menu list
- virtual int GetItemCount();
-
- // return the menuID of the n'th item in the menu list, valid from [0, GetItemCount)
- virtual int GetMenuID(int index);
-
- // Return the number of items currently visible in the menu list
- int GetCurrentlyVisibleItemsCount();
-
- MenuItem *GetMenuItem(int itemID);
- void CloseOtherMenus(MenuItem *item);
- virtual void OnKillFocus();
-
- int GetMenuMode();
- enum MenuMode
- {
- MOUSE = 0,
- KEYBOARD,
- };
-
- void SetCurrentlyHighlightedItem(int itemID);
- int GetCurrentlyHighlightedItem();
- void ClearCurrentlyHighlightedItem();
-
- // Set the checked state of a checkable menuItem
- void SetMenuItemChecked(int itemID, bool state);
- bool IsChecked(int index); // check if item is checked.
-
-
- void SetMinimumWidth(int width);
- int GetMinimumWidth();
-
- // baseclass overrides to chain colors through to cascade menus
- virtual void SetFgColor( Color newColor );
- virtual void SetBgColor( Color newColor );
-
- virtual void SetFont( HFont font );
-
- // Pass in NULL hotkey to remove hotkey
- void SetCurrentKeyBinding( int itemID, char const *hotkey );
-
- void ForceCalculateWidth();
-
- void SetUseFallbackFont( bool bState, HFont hFallback );
-
-protected:
- // helper functions
- int AddMenuItemCharCommand(MenuItem *item, const char *command, Panel *target, const KeyValues *userData);
- int AddMenuItemKeyValuesCommand(MenuItem *item, KeyValues *message, Panel *target, const KeyValues *userData);
-
- // vgui result reporting
- virtual void OnCommand( const char *command );
- MESSAGE_FUNC_PTR( OnMenuItemSelected, "MenuItemSelected", panel );
- virtual void AddScrollBar();
- virtual void RemoveScrollBar();
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" );
- virtual void Paint();
- virtual void LayoutMenuBorder();
- virtual void MakeItemsVisibleInScrollRange( int maxVisibleItems, int nNumPixelsAvailable );
- virtual void OnMouseWheeled(int delta);
- // Alternate OnKeyTyped behaviors
- virtual void OnHotKey(wchar_t unichar);
- virtual void OnTypeAhead(wchar_t unichar);
-
- int CountVisibleItems();
- void ComputeWorkspaceSize( int& workWide, int& workTall );
- int ComputeFullMenuHeightWithInsets();
-
- void CalculateWidth();
-
- void LayoutScrollBar();
- void PositionCascadingMenu();
- void SizeMenuItems();
- void OnCursorMoved(int x, int y);
- void OnKeyCodePressed(KeyCode code);
- void OnMenuClose();
- MESSAGE_FUNC( OnKeyModeSet, "KeyModeSet" );
-
- void SetCurrentlySelectedItem(MenuItem *item);
- void SetCurrentlySelectedItem(int itemID);
- MESSAGE_FUNC_INT( OnCursorEnteredMenuItem, "CursorEnteredMenuItem", VPanel);
- MESSAGE_FUNC_INT( OnCursorExitedMenuItem, "CursorExitedMenuItem", VPanel);
-
- void MoveAlongMenuItemList(int direction, int loopCount);
-
- enum
- {
- DEFAULT_MENU_ITEM_HEIGHT = 22, // height of items in the menu
- MENU_UP = -1, // used for moving up/down list of menu items in the menu
- MENU_DOWN = 1
- };
-
-#ifdef DBGFLAG_VALIDATE
- virtual void Validate( CValidator &validator, char *pchName );
-#endif // DBGFLAG_VALIDATE
-
-private:
- MenuItem *GetParentMenuItem();
-
- int m_iMenuItemHeight;
- int m_iFixedWidth;
- int m_iMinimumWidth; // a minimum width the menu has to be if it is not fixed width
- int m_iNumVisibleLines; // number of items in menu before scroll bar adds on
- ScrollBar *m_pScroller;
-
- CUtlLinkedList<MenuItem*, int> m_MenuItems;
-
- CUtlVector<int> m_VisibleSortedItems;
- CUtlVector<int> m_SortedItems; // used for visual
- CUtlVector<int> m_Separators; // menu item ids after which separators should be shown
- CUtlVector<MenuSeparator *> m_SeparatorPanels;
-
- bool _sizedForScrollBar: 1 ; // whether menu has been sized for a scrollbar
- bool m_bUseFallbackFont : 1;
- bool _recalculateWidth : 1;
- bool m_bUseMenuManager : 1;
-
- int _menuWide;
- int m_iCurrentlySelectedItemID;
- int m_iInputMode;
- int m_iCheckImageWidth; // the size of the check box spot on a checkable menu.
- int m_iProportionalScrollBarSize;
- Label::Alignment m_Alignment;
- Color _borderDark;
- int m_iActivatedItem;
- HFont m_hItemFont;
- HFont m_hFallbackItemFont;
-
- // for managing type ahead
- #define TYPEAHEAD_BUFSIZE 256
- MenuTypeAheadMode m_eTypeAheadMode;
- wchar_t m_szTypeAheadBuf[TYPEAHEAD_BUFSIZE];
- int m_iNumTypeAheadChars;
- double m_fLastTypeAheadTime;
-};
-
-} // namespace vgui
-
-#endif // MENU_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef MENU_H +#define MENU_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> +#include <vgui_controls/Label.h> +#include <utllinkedlist.h> +#include <utlvector.h> + +namespace vgui +{ + +class MenuItem; +class ScrollBar; +class MenuSeparator; + +//----------------------------------------------------------------------------- +// Purpose: A menu is a list of items that can be selected with one click, navigated +// with arrow keys and/or hot keys, and have a lit behavior when mouse over. +// It is NOT the button which opens the menu, but only the menu itself. +// +// Behaviour spec: +// Menu navigation can be done in 2 modes, via keyboard keys and via mouse. +// Clicking on menu button opens menu. +// Only one item in a menu is highlighted at a time. +// Only one submenu in a menu is open at a time. +// Disabled menuitems get highlighted via mouse and keys but will not activate. +// +// Mouse: +// Moving mouse into a menuitem highlights it. +// If the menuitem has a cascading menu, the menu opens when the mouse enters +// the menuitem. The cascading menuitem stays highlighted while its menu is open. +// No submenu items are highlighted by default. +// Moving the mouse into another menuitem closes any previously open submenus in the list. +// Clicking once in the menu item activates the menu item and closes all menus. +// Moving the mouse off a menuitem unhighlights it. +// The scroll bar arrows can be used to move up/down the menu one item at a time. +// The clicking and dragging on the scroll bar nob also scrolls the menu items. +// If a highlighed menuitem scrolls off, and the user then begins navigating via keys, +// the menu will snap the scroll bar so the highlighted item is visible. +// If user has been navigating via keys, moving the mouse over a menu item +// highlights it. +// Mousewheel: +// You must have the mouse inside the menu/scroll bar to use the wheel. +// The mouse wheel moves the highlighted menuitem up or down the list. +// If the list has no scroll bar the wheel will cycle from the bottom of the list +// to the top of the list and vice versa. +// If the list has a scrollbar the mouse wheel will stop at the top or bottom +// of the list. +// If the mouse is over the scroll bar no items are highlighted. +// Keyboard: +// When a menu is opened, no items are highlighted. +// If a menuitem has a cascading menu it does not open when the item is highlighted. +// The down arrow selects the next item in the list. +// (first item if none are highlighted and there is a scrollbar). +// The up arrow selects the previous item in the list +// (first item if none are highlighted and there is a scrollbar, last item if none are +// highlighted and there is no scrollbar). +// Selecting a new menuitem closes any previously open submenus in the list. +// The enter key activates the selected item and closes all menus. +// If the selected item has a cascading menu, activating it opens its submenu. +// These may also be activated by pressing the right arrow. +// Pressing the left arrow closes the submenu. +// When the submenu is opened the cascading menuitem stays highlighted. +// No items in the submenu are highlighted when it is opened. +// +// Note: Cascading menuitems in menus with a scrollbar is not supported. +// Its a clunky UI and if we want this we should design a better solution, +// perhaps along the lines of how explorer's bookmarks does it. +// It currently functions, but there are some arm/disarm bugs. +// +// +//----------------------------------------------------------------------------- +class Menu : public Panel +{ + DECLARE_CLASS_SIMPLE( Menu, Panel ); + friend class MenuItem; +public: + enum MenuDirection_e + { + LEFT, + RIGHT, + UP, + DOWN, + CURSOR, // make the menu appear under the mouse cursor + ALIGN_WITH_PARENT, // make the menu appear under the parent + }; + + Menu(Panel *parent, const char *panelName); + ~Menu(); + + static void PlaceContextMenu( Panel *parent, Menu *menu ); + static void OnInternalMousePressed( Panel *other, MouseCode code ); + + virtual void PositionRelativeToPanel( Panel *reference, MenuDirection_e direction, int nAdditionalYOffset = 0, bool showMenu = false ); + + // the menu. For combo boxes, it's the edit/field, etc. etc. + + // Add a simple text item to the menu + virtual int AddMenuItem( const char *itemName, const char *itemText, const char *command, Panel *target, const KeyValues *userData = NULL ); + virtual int AddMenuItem( const char *itemName, const wchar_t *wszItemText, const char *command, Panel *target, const KeyValues *userData = NULL ); + + virtual int AddMenuItem( const char *itemName, const char *itemText, KeyValues *message, Panel *target , const KeyValues *userData = NULL); + virtual int AddMenuItem( const char *itemName, const wchar_t *wszItemText, KeyValues *message, Panel *target , const KeyValues *userData = NULL); + + virtual int AddMenuItem( const char *itemText, const char *command, Panel *target , const KeyValues *userData = NULL); + virtual int AddMenuItem( const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL ); + virtual int AddMenuItem( const char *itemText, Panel *target, const KeyValues *userData = NULL ); + + // Add a checkable item to the menu + virtual int AddCheckableMenuItem( const char *itemName, const char *itemText, const char *command, Panel *target, const KeyValues *userData = NULL ); + virtual int AddCheckableMenuItem( const char *itemName, const wchar_t *wszItemText, const char *command, Panel *target, const KeyValues *userData = NULL ); + + virtual int AddCheckableMenuItem( const char *itemName, const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL ); + virtual int AddCheckableMenuItem( const char *itemName, const wchar_t *wszItemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL ); + + virtual int AddCheckableMenuItem( const char *itemText, const char *command, Panel *target , const KeyValues *userData = NULL); + virtual int AddCheckableMenuItem( const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL ); + virtual int AddCheckableMenuItem( const char *itemText, Panel *target, const KeyValues *userData = NULL ); + + // Add a cascading menu item to the menu + virtual int AddCascadingMenuItem( const char *itemName, const char *itemText, const char *command, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + virtual int AddCascadingMenuItem( const char *itemName, const wchar_t *wszItemText, const char *command, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + + virtual int AddCascadingMenuItem( const char *itemName, const char *itemText, KeyValues *message, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + virtual int AddCascadingMenuItem( const char *itemName, const wchar_t *wszItemText, KeyValues *message, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + + virtual int AddCascadingMenuItem( const char *itemText, const char *command, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + virtual int AddCascadingMenuItem( const char *itemText, KeyValues *message, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + virtual int AddCascadingMenuItem( const char *itemText, Panel *target, Menu *cascadeMenu, const KeyValues *userData = NULL ); + + // Add a custom panel to the menu + virtual int AddMenuItem( MenuItem *panel ); + + virtual void AddSeparator(); + virtual void AddSeparatorAfterItem( int itemID ); + + // Sets the values of a menu item at the specified index + virtual void UpdateMenuItem(int itemID, const char *itemText,KeyValues *message, const KeyValues *userData = NULL); + virtual void UpdateMenuItem(int itemID, const wchar_t *wszItemText,KeyValues *message, const KeyValues *userData = NULL); + + virtual void MoveMenuItem( int itemID, int moveBeforeThisItemID ); + + virtual bool IsValidMenuID(int itemID); + virtual int GetInvalidMenuID(); + + KeyValues *GetItemUserData(int itemID); + void GetItemText(int itemID, wchar_t *text, int bufLenInBytes); + void GetItemText(int itemID, char *text, int bufLenInBytes); + + virtual void SetItemEnabled(const char *itemName, bool state); + virtual void SetItemEnabled(int itemID, bool state); + virtual void SetItemVisible(const char *itemName, bool visible); + virtual void SetItemVisible(int itemID, bool visible); + + // Remove a single item + void DeleteItem( int itemID ); + + // Clear the menu, deleting all the menu items within + void DeleteAllItems(); + + // Override the auto-width setting with a single fixed width + virtual void SetFixedWidth( int width ); + + // Sets the content alignment of all items in the menu + void SetContentAlignment( Label::Alignment alignment ); + + // sets the height of each menu item + virtual void SetMenuItemHeight(int itemHeight); + virtual int GetMenuItemHeight() const; + + // Set the max number of items visible (scrollbar appears with more) + virtual void SetNumberOfVisibleItems( int numItems ); + + // Add the menu to the menu manager (see Menu::SetVisible())? + void EnableUseMenuManager( bool bUseMenuManager ); + + // Set up the menu items layout + virtual void PerformLayout( void ); + + virtual void SetBorder(class IBorder *border); + virtual void ApplySchemeSettings(IScheme *pScheme); + + // Set type ahead behaviour + enum MenuTypeAheadMode + { + COMPAT_MODE = 0, + HOT_KEY_MODE, + TYPE_AHEAD_MODE, + }; + virtual void SetTypeAheadMode(MenuTypeAheadMode mode); + virtual int GetTypeAheadMode(); + + // Hotkey handling + virtual void OnKeyTyped(wchar_t unichar); + // Menu nagivation etc. + virtual void OnKeyCodeTyped( KeyCode code ); + + // Visibility + virtual void SetVisible(bool state); + + // Activates item in the menu list, as if that menu item had been selected by the user + virtual void ActivateItem(int itemID); + virtual void SilentActivateItem(int itemID); // activate item, but don't fire the action signal + virtual void ActivateItemByRow(int row); + virtual int GetActiveItem(); // returns the itemID (not the row) of the active item + + // Return the number of items currently in the menu list + virtual int GetItemCount(); + + // return the menuID of the n'th item in the menu list, valid from [0, GetItemCount) + virtual int GetMenuID(int index); + + // Return the number of items currently visible in the menu list + int GetCurrentlyVisibleItemsCount(); + + MenuItem *GetMenuItem(int itemID); + void CloseOtherMenus(MenuItem *item); + virtual void OnKillFocus(); + + int GetMenuMode(); + enum MenuMode + { + MOUSE = 0, + KEYBOARD, + }; + + void SetCurrentlyHighlightedItem(int itemID); + int GetCurrentlyHighlightedItem(); + void ClearCurrentlyHighlightedItem(); + + // Set the checked state of a checkable menuItem + void SetMenuItemChecked(int itemID, bool state); + bool IsChecked(int index); // check if item is checked. + + + void SetMinimumWidth(int width); + int GetMinimumWidth(); + + // baseclass overrides to chain colors through to cascade menus + virtual void SetFgColor( Color newColor ); + virtual void SetBgColor( Color newColor ); + + virtual void SetFont( HFont font ); + + // Pass in NULL hotkey to remove hotkey + void SetCurrentKeyBinding( int itemID, char const *hotkey ); + + void ForceCalculateWidth(); + + void SetUseFallbackFont( bool bState, HFont hFallback ); + +protected: + // helper functions + int AddMenuItemCharCommand(MenuItem *item, const char *command, Panel *target, const KeyValues *userData); + int AddMenuItemKeyValuesCommand(MenuItem *item, KeyValues *message, Panel *target, const KeyValues *userData); + + // vgui result reporting + virtual void OnCommand( const char *command ); + MESSAGE_FUNC_PTR( OnMenuItemSelected, "MenuItemSelected", panel ); + virtual void AddScrollBar(); + virtual void RemoveScrollBar(); + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); + virtual void Paint(); + virtual void LayoutMenuBorder(); + virtual void MakeItemsVisibleInScrollRange( int maxVisibleItems, int nNumPixelsAvailable ); + virtual void OnMouseWheeled(int delta); + // Alternate OnKeyTyped behaviors + virtual void OnHotKey(wchar_t unichar); + virtual void OnTypeAhead(wchar_t unichar); + + int CountVisibleItems(); + void ComputeWorkspaceSize( int& workWide, int& workTall ); + int ComputeFullMenuHeightWithInsets(); + + void CalculateWidth(); + + void LayoutScrollBar(); + void PositionCascadingMenu(); + void SizeMenuItems(); + void OnCursorMoved(int x, int y); + void OnKeyCodePressed(KeyCode code); + void OnMenuClose(); + MESSAGE_FUNC( OnKeyModeSet, "KeyModeSet" ); + + void SetCurrentlySelectedItem(MenuItem *item); + void SetCurrentlySelectedItem(int itemID); + MESSAGE_FUNC_INT( OnCursorEnteredMenuItem, "CursorEnteredMenuItem", VPanel); + MESSAGE_FUNC_INT( OnCursorExitedMenuItem, "CursorExitedMenuItem", VPanel); + + void MoveAlongMenuItemList(int direction, int loopCount); + + enum + { + DEFAULT_MENU_ITEM_HEIGHT = 22, // height of items in the menu + MENU_UP = -1, // used for moving up/down list of menu items in the menu + MENU_DOWN = 1 + }; + +#ifdef DBGFLAG_VALIDATE + virtual void Validate( CValidator &validator, char *pchName ); +#endif // DBGFLAG_VALIDATE + +private: + MenuItem *GetParentMenuItem(); + + int m_iMenuItemHeight; + int m_iFixedWidth; + int m_iMinimumWidth; // a minimum width the menu has to be if it is not fixed width + int m_iNumVisibleLines; // number of items in menu before scroll bar adds on + ScrollBar *m_pScroller; + + CUtlLinkedList<MenuItem*, int> m_MenuItems; + + CUtlVector<int> m_VisibleSortedItems; + CUtlVector<int> m_SortedItems; // used for visual + CUtlVector<int> m_Separators; // menu item ids after which separators should be shown + CUtlVector<MenuSeparator *> m_SeparatorPanels; + + bool _sizedForScrollBar: 1 ; // whether menu has been sized for a scrollbar + bool m_bUseFallbackFont : 1; + bool _recalculateWidth : 1; + bool m_bUseMenuManager : 1; + + int _menuWide; + int m_iCurrentlySelectedItemID; + int m_iInputMode; + int m_iCheckImageWidth; // the size of the check box spot on a checkable menu. + int m_iProportionalScrollBarSize; + Label::Alignment m_Alignment; + Color _borderDark; + int m_iActivatedItem; + HFont m_hItemFont; + HFont m_hFallbackItemFont; + + // for managing type ahead + #define TYPEAHEAD_BUFSIZE 256 + MenuTypeAheadMode m_eTypeAheadMode; + wchar_t m_szTypeAheadBuf[TYPEAHEAD_BUFSIZE]; + int m_iNumTypeAheadChars; + double m_fLastTypeAheadTime; +}; + +} // namespace vgui + +#endif // MENU_H diff --git a/mp/src/public/vgui_controls/MenuBar.h b/mp/src/public/vgui_controls/MenuBar.h index 4971ccf8..01ccc06a 100644 --- a/mp/src/public/vgui_controls/MenuBar.h +++ b/mp/src/public/vgui_controls/MenuBar.h @@ -1,54 +1,54 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MENUBAR_H
-#define MENUBAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-#include <utlvector.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-class MenuBar : public Panel
-{
- DECLARE_CLASS_SIMPLE( MenuBar, Panel );
-
-public:
- MenuBar(Panel *parent, const char *panelName);
- ~MenuBar();
-
- virtual void AddButton(MenuButton *button); // add button to end of menu list
- virtual void AddMenu( const char *pButtonName, Menu *pMenu );
-
- virtual void GetContentSize( int& w, int&h );
-
-protected:
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void OnKeyTyped(wchar_t unichar);
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void PerformLayout();
- virtual void Paint();
- MESSAGE_FUNC( OnMenuClose, "MenuClose" );
- MESSAGE_FUNC_INT( OnCursorEnteredMenuButton, "CursorEnteredMenuButton", VPanel);
-
-private:
- CUtlVector<MenuButton *> m_pMenuButtons;
- int m_nRightEdge;
-};
-
-} // namespace vgui
-
-#endif // MENUBAR_H
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MENUBAR_H +#define MENUBAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> +#include <utlvector.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class MenuBar : public Panel +{ + DECLARE_CLASS_SIMPLE( MenuBar, Panel ); + +public: + MenuBar(Panel *parent, const char *panelName); + ~MenuBar(); + + virtual void AddButton(MenuButton *button); // add button to end of menu list + virtual void AddMenu( const char *pButtonName, Menu *pMenu ); + + virtual void GetContentSize( int& w, int&h ); + +protected: + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnKeyTyped(wchar_t unichar); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void PerformLayout(); + virtual void Paint(); + MESSAGE_FUNC( OnMenuClose, "MenuClose" ); + MESSAGE_FUNC_INT( OnCursorEnteredMenuButton, "CursorEnteredMenuButton", VPanel); + +private: + CUtlVector<MenuButton *> m_pMenuButtons; + int m_nRightEdge; +}; + +} // namespace vgui + +#endif // MENUBAR_H + diff --git a/mp/src/public/vgui_controls/MenuButton.h b/mp/src/public/vgui_controls/MenuButton.h index ed5d56e9..a90fb236 100644 --- a/mp/src/public/vgui_controls/MenuButton.h +++ b/mp/src/public/vgui_controls/MenuButton.h @@ -1,82 +1,82 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MENUBUTTON_H
-#define MENUBUTTON_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Button.h>
-#include "vgui_controls/Menu.h"
-
-namespace vgui
-{
-
-class Menu;
-class TextImage;
-
-//-----------------------------------------------------------------------------
-// Purpose: Button that displays a menu when pressed
-//-----------------------------------------------------------------------------
-class MenuButton : public Button
-{
- DECLARE_CLASS_SIMPLE( MenuButton, Button );
-
-public:
- MenuButton(Panel *parent, const char *panelName, const char *text);
- ~MenuButton();
-
- // functions designed to be overriden
- virtual void OnShowMenu(Menu *menu) {}
- virtual void OnHideMenu(Menu *menu) {}
- virtual int OnCheckMenuItemCount() { return 0; }
-
- virtual void SetMenu(Menu *menu);
- virtual void HideMenu(void);
- virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1);
- MESSAGE_FUNC( OnMenuClose, "MenuClose" );
- MESSAGE_FUNC_PARAMS( OnKillFocus, "KillFocus", kv ); // called after the panel loses the keyboard focus
- virtual void DoClick();
- virtual void SetOpenOffsetY(int yOffset);
-
- virtual bool CanBeDefaultButton(void);
-
- // sets the direction in which the menu opens from the button, defaults to down
- virtual void SetOpenDirection(Menu::MenuDirection_e direction);
-
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void OnCursorEntered();
-
- virtual void Paint();
- virtual void PerformLayout();
- virtual void ApplySchemeSettings( IScheme *pScheme );
- virtual void OnCursorMoved( int x, int y );
-
- // This style is like the IE "back" button where the left side acts like a regular button, the the right side has a little
- // combo box dropdown indicator and presents and submenu
- void SetDropMenuButtonStyle( bool state );
- bool IsDropMenuButtonStyle() const;
-
- Menu *GetMenu();
-
-private:
-
- Menu *m_pMenu;
- Menu::MenuDirection_e m_iDirection;
-
- int _openOffsetY; // vertical offset of menu from the menu button
-
- bool m_bDropMenuButtonStyle : 1;
- TextImage *m_pDropMenuImage;
- int m_nImageIndex;
-};
-
-}; // namespace vgui
-
-#endif // MENUBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MENUBUTTON_H +#define MENUBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Button.h> +#include "vgui_controls/Menu.h" + +namespace vgui +{ + +class Menu; +class TextImage; + +//----------------------------------------------------------------------------- +// Purpose: Button that displays a menu when pressed +//----------------------------------------------------------------------------- +class MenuButton : public Button +{ + DECLARE_CLASS_SIMPLE( MenuButton, Button ); + +public: + MenuButton(Panel *parent, const char *panelName, const char *text); + ~MenuButton(); + + // functions designed to be overriden + virtual void OnShowMenu(Menu *menu) {} + virtual void OnHideMenu(Menu *menu) {} + virtual int OnCheckMenuItemCount() { return 0; } + + virtual void SetMenu(Menu *menu); + virtual void HideMenu(void); + virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1); + MESSAGE_FUNC( OnMenuClose, "MenuClose" ); + MESSAGE_FUNC_PARAMS( OnKillFocus, "KillFocus", kv ); // called after the panel loses the keyboard focus + virtual void DoClick(); + virtual void SetOpenOffsetY(int yOffset); + + virtual bool CanBeDefaultButton(void); + + // sets the direction in which the menu opens from the button, defaults to down + virtual void SetOpenDirection(Menu::MenuDirection_e direction); + + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnCursorEntered(); + + virtual void Paint(); + virtual void PerformLayout(); + virtual void ApplySchemeSettings( IScheme *pScheme ); + virtual void OnCursorMoved( int x, int y ); + + // This style is like the IE "back" button where the left side acts like a regular button, the the right side has a little + // combo box dropdown indicator and presents and submenu + void SetDropMenuButtonStyle( bool state ); + bool IsDropMenuButtonStyle() const; + + Menu *GetMenu(); + +private: + + Menu *m_pMenu; + Menu::MenuDirection_e m_iDirection; + + int _openOffsetY; // vertical offset of menu from the menu button + + bool m_bDropMenuButtonStyle : 1; + TextImage *m_pDropMenuImage; + int m_nImageIndex; +}; + +}; // namespace vgui + +#endif // MENUBUTTON_H diff --git a/mp/src/public/vgui_controls/MenuItem.h b/mp/src/public/vgui_controls/MenuItem.h index e396c284..6baa512e 100644 --- a/mp/src/public/vgui_controls/MenuItem.h +++ b/mp/src/public/vgui_controls/MenuItem.h @@ -1,136 +1,136 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MENUITEM_H
-#define MENUITEM_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/Menu.h>
-
-namespace vgui
-{
-
-class IBorder;
-class TextImage;
-class Menu;
-class Image;
-
-//-----------------------------------------------------------------------------
-// Purpose: The items in a menu
-// MenuItems MUST have the Menu class as parents.
-//-----------------------------------------------------------------------------
-class MenuItem : public Button
-{
- DECLARE_CLASS_SIMPLE( MenuItem, Button );
-
-public:
- MenuItem(Menu *parent, const char *panelName, const char *text, Menu *cascadeMenu = NULL, bool checkable = false);
- MenuItem(Menu *parent, const char *panelName, const wchar_t *wszText, Menu *cascadeMenu = NULL, bool checkable = false);
- ~MenuItem();
-
- virtual void Paint();
-
- // Activate the menu item as if it had been selected by the user
- virtual void FireActionSignal();
-
- virtual bool CanBeDefaultButton(void);
-
- // Handle mouse cursor entering a MenuItem.
- void OnCursorEntered();
- // Handle mouse cursor exiting a MenuItem.
- void OnCursorExited();
-
- // Close the cascading menu if we have one.
- void CloseCascadeMenu();
-
- // Pass kill focus events up to parent on loss of focus
- MESSAGE_FUNC( OnKillFocus, "MenuClose" );
-
- // Return true if this item triggers a cascading menu
- bool HasMenu();
-
- // Set the size of the text portion of the label.
- void SetTextImageSize(int wide, int tall);
-
- //Return the size of the text portion of the label.
- void GetTextImageSize(int &wide, int &tall);
-
- // Return the size of the arrow portion of the label.
- void GetArrowImageSize(int &wide, int &tall);
-
- // Return the size of the check portion of the label.
- void GetCheckImageSize(int &wide, int &tall);
-
- // Return the menu that this menuItem contains
- Menu *GetMenu();
-
- virtual void PerformLayout();
-
- // Respond to cursor movement
- void OnCursorMoved(int x, int y);
-
- // Highlight item
- MESSAGE_FUNC( ArmItem, "ArmItem" );
- // Unhighlight item.
- MESSAGE_FUNC( DisarmItem, "DisarmItem" );
-
- // is the item highlighted?
- bool IsItemArmed();
-
- // Open cascading menu if there is one.
- void OpenCascadeMenu();
-
- bool IsCheckable();
- bool IsChecked();
-
- // Set a checkable menuItem checked or unchecked.
- void SetChecked(bool state);
-
- KeyValues *GetUserData();
- void SetUserData(const KeyValues *kv);
-
- int GetActiveItem() { if ( m_pCascadeMenu ) { return m_pCascadeMenu->GetActiveItem(); } else { return 0; }}
-
- Menu *GetParentMenu();
-
- void SetCurrentKeyBinding( char const *keyName );
-
- virtual void GetContentSize( int& cw, int &ch );
-
-protected:
- void OnKeyCodeReleased(KeyCode code);
- void OnMenuClose();
- MESSAGE_FUNC( OnKeyModeSet, "KeyModeSet" );
-
- // vgui overrides
- virtual void Init( void );
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
-
-private:
- enum { CHECK_INSET = 6 };
- Menu *m_pCascadeMenu; // menu triggered to open upon selecting this menu item
- bool m_bCheckable; // can this menu item have a little check to the left of it when you select it?
- bool m_bChecked; // whether item is checked or not.
- TextImage *m_pCascadeArrow; // little arrow that appears to the right of menuitems that open a menu
- Image *m_pCheck; // the check that appears to the left of checked menu items
- TextImage *m_pBlankCheck; // a blank image same size as the check for when items are not checked.
-
- TextImage *m_pCurrentKeyBinding; // An optional indicator for the key currently bound to this menu item
-
- KeyValues *m_pUserData;
-
-};
-
-} // namespace vgui
-
-#endif // MENUITEM_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MENUITEM_H +#define MENUITEM_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Button.h> +#include <vgui_controls/Menu.h> + +namespace vgui +{ + +class IBorder; +class TextImage; +class Menu; +class Image; + +//----------------------------------------------------------------------------- +// Purpose: The items in a menu +// MenuItems MUST have the Menu class as parents. +//----------------------------------------------------------------------------- +class MenuItem : public Button +{ + DECLARE_CLASS_SIMPLE( MenuItem, Button ); + +public: + MenuItem(Menu *parent, const char *panelName, const char *text, Menu *cascadeMenu = NULL, bool checkable = false); + MenuItem(Menu *parent, const char *panelName, const wchar_t *wszText, Menu *cascadeMenu = NULL, bool checkable = false); + ~MenuItem(); + + virtual void Paint(); + + // Activate the menu item as if it had been selected by the user + virtual void FireActionSignal(); + + virtual bool CanBeDefaultButton(void); + + // Handle mouse cursor entering a MenuItem. + void OnCursorEntered(); + // Handle mouse cursor exiting a MenuItem. + void OnCursorExited(); + + // Close the cascading menu if we have one. + void CloseCascadeMenu(); + + // Pass kill focus events up to parent on loss of focus + MESSAGE_FUNC( OnKillFocus, "MenuClose" ); + + // Return true if this item triggers a cascading menu + bool HasMenu(); + + // Set the size of the text portion of the label. + void SetTextImageSize(int wide, int tall); + + //Return the size of the text portion of the label. + void GetTextImageSize(int &wide, int &tall); + + // Return the size of the arrow portion of the label. + void GetArrowImageSize(int &wide, int &tall); + + // Return the size of the check portion of the label. + void GetCheckImageSize(int &wide, int &tall); + + // Return the menu that this menuItem contains + Menu *GetMenu(); + + virtual void PerformLayout(); + + // Respond to cursor movement + void OnCursorMoved(int x, int y); + + // Highlight item + MESSAGE_FUNC( ArmItem, "ArmItem" ); + // Unhighlight item. + MESSAGE_FUNC( DisarmItem, "DisarmItem" ); + + // is the item highlighted? + bool IsItemArmed(); + + // Open cascading menu if there is one. + void OpenCascadeMenu(); + + bool IsCheckable(); + bool IsChecked(); + + // Set a checkable menuItem checked or unchecked. + void SetChecked(bool state); + + KeyValues *GetUserData(); + void SetUserData(const KeyValues *kv); + + int GetActiveItem() { if ( m_pCascadeMenu ) { return m_pCascadeMenu->GetActiveItem(); } else { return 0; }} + + Menu *GetParentMenu(); + + void SetCurrentKeyBinding( char const *keyName ); + + virtual void GetContentSize( int& cw, int &ch ); + +protected: + void OnKeyCodeReleased(KeyCode code); + void OnMenuClose(); + MESSAGE_FUNC( OnKeyModeSet, "KeyModeSet" ); + + // vgui overrides + virtual void Init( void ); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + +private: + enum { CHECK_INSET = 6 }; + Menu *m_pCascadeMenu; // menu triggered to open upon selecting this menu item + bool m_bCheckable; // can this menu item have a little check to the left of it when you select it? + bool m_bChecked; // whether item is checked or not. + TextImage *m_pCascadeArrow; // little arrow that appears to the right of menuitems that open a menu + Image *m_pCheck; // the check that appears to the left of checked menu items + TextImage *m_pBlankCheck; // a blank image same size as the check for when items are not checked. + + TextImage *m_pCurrentKeyBinding; // An optional indicator for the key currently bound to this menu item + + KeyValues *m_pUserData; + +}; + +} // namespace vgui + +#endif // MENUITEM_H diff --git a/mp/src/public/vgui_controls/MessageBox.h b/mp/src/public/vgui_controls/MessageBox.h index bfd82079..47918223 100644 --- a/mp/src/public/vgui_controls/MessageBox.h +++ b/mp/src/public/vgui_controls/MessageBox.h @@ -1,98 +1,98 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MESSAGEBOX_H
-#define MESSAGEBOX_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Frame.h>
-
-// prevent windows macros from messing with the class
-#ifdef MessageBox
-#undef MessageBox
-#endif
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Popup discardable message box
-//-----------------------------------------------------------------------------
-class MessageBox : public Frame
-{
- DECLARE_CLASS_SIMPLE( MessageBox, Frame );
-
-public:
- // title - Text to be displayed in the title bar of the window
- // text - Text message in the message box
- // startMinimized - wether message box starts minimized. Starts invisible by default
- // parent - parent panel of the message box, by default it has no parent. This will keep the box visible until the OK button is pressed.
- MessageBox(const char *title, const char *text, Panel *parent = NULL);
- MessageBox(const wchar_t *wszTitle, const wchar_t *wszText, Panel *parent = NULL);
- ~MessageBox();
-
- // Put the message box into a modal state
- virtual void DoModal(Frame *pFrameOver = NULL);
-
- // make the message box appear and in a modeless state
- virtual void ShowWindow(Frame *pFrameOver = NULL);
-
- // Set a string command to be sent when the OK button is pressed
- // Use AddActionSignalTarget() to mark yourself as a recipient of the command
- virtual void SetCommand(const char *command);
- virtual void SetCommand(KeyValues *command);
-
- // Set the visibility of the OK button.
- virtual void SetOKButtonVisible(bool state);
-
- // Set the text on the OK button
- virtual void SetOKButtonText(const char *buttonText);
- virtual void SetOKButtonText(const wchar_t *wszButtonText);
-
- // Cancel button (off by default)
- void SetCancelButtonVisible(bool state);
- void SetCancelButtonText(const char *buttonText);
- void SetCancelButtonText(const wchar_t *wszButtonText);
- void SetCancelCommand( KeyValues *command );
-
- // Toggles visibility of the close box.
- virtual void DisableCloseButton(bool state);
-
- virtual void OnCommand( const char *pCommand );
-
- // Shows the message box over the cursor
- void ShowMessageBoxOverCursor( bool bEnable );
-
-protected:
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
-protected:
- Button *m_pOkButton;
- Button *m_pCancelButton;
- Label *m_pMessageLabel;
-
-private:
- MESSAGE_FUNC( OnShutdownRequest, "ShutdownRequest" );
-
- void Init();
-
- KeyValues *m_OkCommand;
- KeyValues *m_CancelCommand;
- vgui::Frame *m_pFrameOver;
- bool m_bNoAutoClose : 1;
- bool m_bShowMessageBoxOverCursor : 1;
-};
-
-} // namespace vgui
-
-
-#endif // MESSAGEBOX_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MESSAGEBOX_H +#define MESSAGEBOX_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Frame.h> + +// prevent windows macros from messing with the class +#ifdef MessageBox +#undef MessageBox +#endif + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Popup discardable message box +//----------------------------------------------------------------------------- +class MessageBox : public Frame +{ + DECLARE_CLASS_SIMPLE( MessageBox, Frame ); + +public: + // title - Text to be displayed in the title bar of the window + // text - Text message in the message box + // startMinimized - wether message box starts minimized. Starts invisible by default + // parent - parent panel of the message box, by default it has no parent. This will keep the box visible until the OK button is pressed. + MessageBox(const char *title, const char *text, Panel *parent = NULL); + MessageBox(const wchar_t *wszTitle, const wchar_t *wszText, Panel *parent = NULL); + ~MessageBox(); + + // Put the message box into a modal state + virtual void DoModal(Frame *pFrameOver = NULL); + + // make the message box appear and in a modeless state + virtual void ShowWindow(Frame *pFrameOver = NULL); + + // Set a string command to be sent when the OK button is pressed + // Use AddActionSignalTarget() to mark yourself as a recipient of the command + virtual void SetCommand(const char *command); + virtual void SetCommand(KeyValues *command); + + // Set the visibility of the OK button. + virtual void SetOKButtonVisible(bool state); + + // Set the text on the OK button + virtual void SetOKButtonText(const char *buttonText); + virtual void SetOKButtonText(const wchar_t *wszButtonText); + + // Cancel button (off by default) + void SetCancelButtonVisible(bool state); + void SetCancelButtonText(const char *buttonText); + void SetCancelButtonText(const wchar_t *wszButtonText); + void SetCancelCommand( KeyValues *command ); + + // Toggles visibility of the close box. + virtual void DisableCloseButton(bool state); + + virtual void OnCommand( const char *pCommand ); + + // Shows the message box over the cursor + void ShowMessageBoxOverCursor( bool bEnable ); + +protected: + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + +protected: + Button *m_pOkButton; + Button *m_pCancelButton; + Label *m_pMessageLabel; + +private: + MESSAGE_FUNC( OnShutdownRequest, "ShutdownRequest" ); + + void Init(); + + KeyValues *m_OkCommand; + KeyValues *m_CancelCommand; + vgui::Frame *m_pFrameOver; + bool m_bNoAutoClose : 1; + bool m_bShowMessageBoxOverCursor : 1; +}; + +} // namespace vgui + + +#endif // MESSAGEBOX_H diff --git a/mp/src/public/vgui_controls/MessageDialog.h b/mp/src/public/vgui_controls/MessageDialog.h index 38e2b534..191bb2b6 100644 --- a/mp/src/public/vgui_controls/MessageDialog.h +++ b/mp/src/public/vgui_controls/MessageDialog.h @@ -1,154 +1,154 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Contains the CMessageDialog declaration
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MESSAGEDIALOG_H
-#define MESSAGEDIALOG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-// styles
-#define MD_WARNING 0x0001
-#define MD_ERROR 0x0002
-
-// button configurations
-#define MD_OK 0x0004 // 1 button - OK
-#define MD_CANCEL 0x0008 // 1 button - CANCEL
-#define MD_OKCANCEL 0x0010 // 2 buttons - OK and CANCEL
-#define MD_YESNO 0x0020 // 2 buttons - YES and NO
-
-// behavior
-#define MD_SIMPLEFRAME 0x0100 // legacy corners
-#define MD_COMMANDAFTERCLOSE 0x0200 // send command at dialog termination (i.e. after fade)
-#define MD_RESTRICTPAINT 0x0400 // only paint this dialog (hide any other ui elements)
-#define MD_COMMANDONFORCECLOSE 0x0800 // send command when the dialog is closed assuming A input
-
-// dialog type
-enum EDialogType
-{
- MD_SAVE_BEFORE_QUIT,
- MD_QUIT_CONFIRMATION,
- MD_QUIT_CONFIRMATION_TF,
- MD_KICK_CONFIRMATION,
- MD_CLIENT_KICKED,
- MD_LOST_HOST,
- MD_LOST_SERVER,
- MD_SEARCHING_FOR_GAMES,
- MD_CREATING_GAME,
- MD_MODIFYING_SESSION,
- MD_SESSION_SEARCH_FAILED,
- MD_SESSION_CREATE_FAILED,
- MD_SESSION_CONNECTING,
- MD_SESSION_CONNECT_NOTAVAILABLE,
- MD_SESSION_CONNECT_SESSIONFULL,
- MD_SESSION_CONNECT_FAILED,
- MD_EXIT_SESSION_CONFIRMATION,
- MD_STORAGE_DEVICES_NEEDED,
- MD_STORAGE_DEVICES_CHANGED,
- MD_STORAGE_DEVICES_TOO_FULL,
- MD_NOT_ONLINE_ENABLED,
- MD_NOT_ONLINE_SIGNEDIN,
- MD_DEFAULT_CONTROLS_CONFIRM,
- MD_AUTOSAVE_EXPLANATION,
- MD_COMMENTARY_EXPLANATION,
- MD_COMMENTARY_EXPLANATION_MULTI,
- MD_COMMENTARY_CHAPTER_UNLOCK_EXPLANATION,
- MD_SAVE_BEFORE_LANGUAGE_CHANGE,
- MD_SAVE_BEFORE_NEW_GAME,
- MD_SAVE_BEFORE_LOAD,
- MD_DELETE_SAVE_CONFIRM,
- MD_SAVE_OVERWRITE,
- MD_SAVING_WARNING,
- MD_SAVE_COMPLETE,
- MD_STANDARD_SAMPLE,
- MD_WARNING_SAMPLE,
- MD_ERROR_SAMPLE,
- MD_PROMPT_SIGNIN,
- MD_PROMPT_SIGNIN_REQUIRED,
- MD_PROMPT_STORAGE_DEVICE,
- MD_PROMPT_STORAGE_DEVICE_REQUIRED,
- MD_DISCONNECT_CONFIRMATION,
- MD_DISCONNECT_CONFIRMATION_HOST,
- MD_LOAD_FAILED_WARNING,
- MD_OPTION_CHANGE_FROM_X360_DASHBOARD,
- MD_STORAGE_DEVICES_CORRUPT,
- MD_CHECKING_STORAGE_DEVICE
-};
-
-#include "vgui_controls/Frame.h"
-#include "vgui_controls/Label.h"
-#include "vgui_controls/AnimatingImagePanel.h"
-#include "vgui_controls/ImagePanel.h"
-
-//-----------------------------------------------------------------------------
-// Purpose: Simple modal dialog box for Xbox 360 warnings and messages
-//-----------------------------------------------------------------------------
-class CMessageDialog : public vgui::Frame
-{
- DECLARE_CLASS_SIMPLE( CMessageDialog, vgui::Frame );
-
-public:
- CMessageDialog( vgui::Panel *parent, const uint nType, const char *pTitle, const char *pMsg, const char *pCmdA, const char *pCmdB, vgui::Panel *pParent, bool bShowActivity );
- ~CMessageDialog();
-
- enum
- {
- BTN_INVALID = -1,
- BTN_B,
- BTN_A,
- MAX_BUTTONS,
- };
-
- struct ButtonLabel_s
- {
- vgui::Label *pIcon;
- vgui::Label *pText;
- int nWide;
- bool bCreated;
- };
-
- virtual void OnKeyCodePressed( vgui::KeyCode code );
- virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
- virtual void ApplySettings( KeyValues *inResourceData );
- virtual void PaintBackground();
- uint GetType( void );
- void SetControlSettingsKeys( KeyValues *pKeys );
-
-private:
- void CreateButtonLabel( ButtonLabel_s *pButton, const char *pIcon, const char *pText );
- void DoCommand( int button );
-
- vgui::Panel *m_pCreator;
-
- vgui::Label *m_pTitle;
- vgui::Label *m_pMsg;
- vgui::ImagePanel *m_pBackground;
-
- vgui::AnimatingImagePanel *m_pAnimatingPanel;
-
- vgui::HFont m_hButtonFont;
- vgui::HFont m_hTextFont;
- uint m_nType;
- Color m_ButtonTextColor;
- int m_ButtonPressed;
- KeyValues *m_pControlSettings;
-
- int m_FooterTall;
- int m_ButtonMargin;
- Color m_clrNotSimpleBG;
- Color m_clrNotSimpleBGBlack;
- int m_ButtonIconLabelSpace;
-
- int m_ActivityIndent;
-
- bool m_bShowActivity; // should we show an animating image panel?
-
- ButtonLabel_s m_Buttons[MAX_BUTTONS];
- char *m_pCommands[MAX_BUTTONS];
-};
-
-#endif // MESSAGEDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Contains the CMessageDialog declaration +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MESSAGEDIALOG_H +#define MESSAGEDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +// styles +#define MD_WARNING 0x0001 +#define MD_ERROR 0x0002 + +// button configurations +#define MD_OK 0x0004 // 1 button - OK +#define MD_CANCEL 0x0008 // 1 button - CANCEL +#define MD_OKCANCEL 0x0010 // 2 buttons - OK and CANCEL +#define MD_YESNO 0x0020 // 2 buttons - YES and NO + +// behavior +#define MD_SIMPLEFRAME 0x0100 // legacy corners +#define MD_COMMANDAFTERCLOSE 0x0200 // send command at dialog termination (i.e. after fade) +#define MD_RESTRICTPAINT 0x0400 // only paint this dialog (hide any other ui elements) +#define MD_COMMANDONFORCECLOSE 0x0800 // send command when the dialog is closed assuming A input + +// dialog type +enum EDialogType +{ + MD_SAVE_BEFORE_QUIT, + MD_QUIT_CONFIRMATION, + MD_QUIT_CONFIRMATION_TF, + MD_KICK_CONFIRMATION, + MD_CLIENT_KICKED, + MD_LOST_HOST, + MD_LOST_SERVER, + MD_SEARCHING_FOR_GAMES, + MD_CREATING_GAME, + MD_MODIFYING_SESSION, + MD_SESSION_SEARCH_FAILED, + MD_SESSION_CREATE_FAILED, + MD_SESSION_CONNECTING, + MD_SESSION_CONNECT_NOTAVAILABLE, + MD_SESSION_CONNECT_SESSIONFULL, + MD_SESSION_CONNECT_FAILED, + MD_EXIT_SESSION_CONFIRMATION, + MD_STORAGE_DEVICES_NEEDED, + MD_STORAGE_DEVICES_CHANGED, + MD_STORAGE_DEVICES_TOO_FULL, + MD_NOT_ONLINE_ENABLED, + MD_NOT_ONLINE_SIGNEDIN, + MD_DEFAULT_CONTROLS_CONFIRM, + MD_AUTOSAVE_EXPLANATION, + MD_COMMENTARY_EXPLANATION, + MD_COMMENTARY_EXPLANATION_MULTI, + MD_COMMENTARY_CHAPTER_UNLOCK_EXPLANATION, + MD_SAVE_BEFORE_LANGUAGE_CHANGE, + MD_SAVE_BEFORE_NEW_GAME, + MD_SAVE_BEFORE_LOAD, + MD_DELETE_SAVE_CONFIRM, + MD_SAVE_OVERWRITE, + MD_SAVING_WARNING, + MD_SAVE_COMPLETE, + MD_STANDARD_SAMPLE, + MD_WARNING_SAMPLE, + MD_ERROR_SAMPLE, + MD_PROMPT_SIGNIN, + MD_PROMPT_SIGNIN_REQUIRED, + MD_PROMPT_STORAGE_DEVICE, + MD_PROMPT_STORAGE_DEVICE_REQUIRED, + MD_DISCONNECT_CONFIRMATION, + MD_DISCONNECT_CONFIRMATION_HOST, + MD_LOAD_FAILED_WARNING, + MD_OPTION_CHANGE_FROM_X360_DASHBOARD, + MD_STORAGE_DEVICES_CORRUPT, + MD_CHECKING_STORAGE_DEVICE +}; + +#include "vgui_controls/Frame.h" +#include "vgui_controls/Label.h" +#include "vgui_controls/AnimatingImagePanel.h" +#include "vgui_controls/ImagePanel.h" + +//----------------------------------------------------------------------------- +// Purpose: Simple modal dialog box for Xbox 360 warnings and messages +//----------------------------------------------------------------------------- +class CMessageDialog : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CMessageDialog, vgui::Frame ); + +public: + CMessageDialog( vgui::Panel *parent, const uint nType, const char *pTitle, const char *pMsg, const char *pCmdA, const char *pCmdB, vgui::Panel *pParent, bool bShowActivity ); + ~CMessageDialog(); + + enum + { + BTN_INVALID = -1, + BTN_B, + BTN_A, + MAX_BUTTONS, + }; + + struct ButtonLabel_s + { + vgui::Label *pIcon; + vgui::Label *pText; + int nWide; + bool bCreated; + }; + + virtual void OnKeyCodePressed( vgui::KeyCode code ); + virtual void ApplySchemeSettings( vgui::IScheme *pScheme ); + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void PaintBackground(); + uint GetType( void ); + void SetControlSettingsKeys( KeyValues *pKeys ); + +private: + void CreateButtonLabel( ButtonLabel_s *pButton, const char *pIcon, const char *pText ); + void DoCommand( int button ); + + vgui::Panel *m_pCreator; + + vgui::Label *m_pTitle; + vgui::Label *m_pMsg; + vgui::ImagePanel *m_pBackground; + + vgui::AnimatingImagePanel *m_pAnimatingPanel; + + vgui::HFont m_hButtonFont; + vgui::HFont m_hTextFont; + uint m_nType; + Color m_ButtonTextColor; + int m_ButtonPressed; + KeyValues *m_pControlSettings; + + int m_FooterTall; + int m_ButtonMargin; + Color m_clrNotSimpleBG; + Color m_clrNotSimpleBGBlack; + int m_ButtonIconLabelSpace; + + int m_ActivityIndent; + + bool m_bShowActivity; // should we show an animating image panel? + + ButtonLabel_s m_Buttons[MAX_BUTTONS]; + char *m_pCommands[MAX_BUTTONS]; +}; + +#endif // MESSAGEDIALOG_H diff --git a/mp/src/public/vgui_controls/MessageMap.h b/mp/src/public/vgui_controls/MessageMap.h index a5c82c1c..226c0adc 100644 --- a/mp/src/public/vgui_controls/MessageMap.h +++ b/mp/src/public/vgui_controls/MessageMap.h @@ -1,381 +1,381 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef MESSAGEMAP_H
-#define MESSAGEMAP_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier1/utlvector.h"
-
-// more flexible than default pointers to members code required for casting member function pointers
-//#pragma pointers_to_members( full_generality, virtual_inheritance )
-
-namespace vgui
-{
-
-////////////// MESSAGEMAP DEFINITIONS //////////////
-
-
-//-----------------------------------------------------------------------------
-// Purpose: parameter data type enumeration
-// used internal but the shortcut macros require this to be exposed
-//-----------------------------------------------------------------------------
-enum DataType_t
-{
- DATATYPE_VOID,
- DATATYPE_CONSTCHARPTR,
- DATATYPE_INT,
- DATATYPE_FLOAT,
- DATATYPE_PTR,
- DATATYPE_BOOL,
- DATATYPE_KEYVALUES,
- DATATYPE_CONSTWCHARPTR,
- DATATYPE_UINT64,
- DATATYPE_HANDLE, // It's an int, really
-};
-
-#ifdef WIN32
-class __virtual_inheritance Panel;
-#else
-class Panel;
-#endif
-typedef unsigned int VPANEL;
-
-typedef void (Panel::*MessageFunc_t)(void);
-
-//-----------------------------------------------------------------------------
-// Purpose: Single item in a message map
-// Contains the information to map a string message name with parameters
-// to a function call
-//-----------------------------------------------------------------------------
-#pragma warning(disable:4121)
-struct MessageMapItem_t
-{
- const char *name;
- // VC6 aligns this to 16-bytes. Since some of the code has been compiled with VC6,
- // we need to enforce the alignment on later compilers to remain compatible.
- ALIGN16 MessageFunc_t func;
-
- int numParams;
-
- DataType_t firstParamType;
- const char *firstParamName;
-
- DataType_t secondParamType;
- const char *secondParamName;
-
- int nameSymbol;
- int firstParamSymbol;
- int secondParamSymbol;
-};
-
-#define DECLARE_PANELMESSAGEMAP( className ) \
- static void AddToMap( char const *scriptname, vgui::MessageFunc_t function, int paramCount, int p1type, const char *p1name, int p2type, const char *p2name ) \
- { \
- vgui::PanelMessageMap *map = vgui::FindOrAddPanelMessageMap( GetPanelClassName() ); \
- \
- vgui::MessageMapItem_t entry; \
- entry.name = scriptname; \
- entry.func = function; \
- entry.numParams = paramCount; \
- entry.firstParamType = (vgui::DataType_t)p1type; \
- entry.firstParamName = p1name; \
- entry.secondParamType = (vgui::DataType_t)p2type; \
- entry.secondParamName = p2name; \
- entry.nameSymbol = 0; \
- entry.firstParamSymbol = 0; \
- entry.secondParamSymbol = 0; \
- \
- map->entries.AddToTail( entry ); \
- } \
- \
- static void ChainToMap( void ) \
- { \
- static bool chained = false; \
- if ( chained ) \
- return; \
- chained = true; \
- vgui::PanelMessageMap *map = vgui::FindOrAddPanelMessageMap( GetPanelClassName() ); \
- map->pfnClassName = &GetPanelClassName; \
- if ( map && GetPanelBaseClassName() && GetPanelBaseClassName()[0] ) \
- { \
- map->baseMap = vgui::FindOrAddPanelMessageMap( GetPanelBaseClassName() ); \
- } \
- } \
- \
- class className##_RegisterMap; \
- friend class className##_RegisterMap; \
- class className##_RegisterMap \
- { \
- public: \
- className##_RegisterMap() \
- { \
- className::ChainToMap(); \
- } \
- }; \
- className##_RegisterMap m_RegisterClass; \
- \
- virtual vgui::PanelMessageMap *GetMessageMap() \
- { \
- static vgui::PanelMessageMap *s_pMap = vgui::FindOrAddPanelMessageMap( GetPanelClassName() ); \
- return s_pMap; \
- }
-
-#if !defined( _XBOX )
-#define VGUI_USEKEYBINDINGMAPS 1
-#endif
-
-#if defined( VGUI_USEKEYBINDINGMAPS )
-
-#define DECLARE_CLASS_SIMPLE( className, baseClassName ) \
- typedef baseClassName BaseClass; \
- typedef className ThisClass; \
-public: \
- DECLARE_PANELMESSAGEMAP( className ); \
- DECLARE_PANELANIMATION( className ); \
- DECLARE_KEYBINDINGMAP( className ); \
- static char const *GetPanelClassName() { return #className; } \
- static char const *GetPanelBaseClassName() { return #baseClassName; }
-
-#define DECLARE_CLASS_SIMPLE_NOBASE( className ) \
- typedef className ThisClass; \
-public: \
- DECLARE_PANELMESSAGEMAP( className ); \
- DECLARE_PANELANIMATION( className ); \
- DECLARE_KEYBINDINGMAP( className ); \
- static char const *GetPanelClassName() { return #className; } \
- static char const *GetPanelBaseClassName() { return NULL; }
-
-#else // no keybinding maps
-
-#define DECLARE_CLASS_SIMPLE( className, baseClassName ) \
- typedef baseClassName BaseClass; \
- typedef className ThisClass; \
-public: \
- DECLARE_PANELMESSAGEMAP( className ); \
- DECLARE_PANELANIMATION( className ); \
- static char const *GetPanelClassName() { return #className; } \
- static char const *GetPanelBaseClassName() { return #baseClassName; }
-
-#define DECLARE_CLASS_SIMPLE_NOBASE( className ) \
- typedef className ThisClass; \
-public: \
- DECLARE_PANELMESSAGEMAP( className ); \
- DECLARE_PANELANIMATION( className ); \
- static char const *GetPanelClassName() { return #className; } \
- static char const *GetPanelBaseClassName() { return NULL; }
-
-#endif // !VGUI_USEKEYBINDINGMAPS
-
-#define _MessageFuncCommon( name, scriptname, paramCount, p1type, p1name, p2type, p2name ) \
- class PanelMessageFunc_##name; \
- friend class PanelMessageFunc_##name; \
- class PanelMessageFunc_##name \
- { \
- public: \
- static void InitVar() \
- { \
- static bool bAdded = false; \
- if ( !bAdded ) \
- { \
- bAdded = true; \
- AddToMap( scriptname, (vgui::MessageFunc_t)&ThisClass::name, paramCount, p1type, p1name, p2type, p2name ); \
- } \
- } \
- PanelMessageFunc_##name() \
- { \
- PanelMessageFunc_##name::InitVar(); \
- } \
- }; \
- PanelMessageFunc_##name m_##name##_register; \
-
-// Use this macro to define a message mapped function
-// must end with a semicolon ';', or with a function
-// no parameter
-#define MESSAGE_FUNC( name, scriptname ) _MessageFuncCommon( name, scriptname, 0, 0, 0, 0, 0 ); virtual void name( void )
-
-// one parameter
-#define MESSAGE_FUNC_INT( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_INT, #p1, 0, 0 ); virtual void name( int p1 )
-#define MESSAGE_FUNC_UINT64( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_UINT64, #p1, 0, 0 ); virtual void name( uint64 p1 )
-#define MESSAGE_FUNC_PTR( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_PTR, #p1, 0, 0 ); virtual void name( vgui::Panel *p1 )
-#define MESSAGE_FUNC_HANDLE( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_HANDLE, #p1, 0, 0 ); virtual void name( vgui::VPANEL p1 )
-#define MESSAGE_FUNC_ENUM( name, scriptname, t1, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_INT, #p1, 0, 0 ); virtual void name( t1 p1 )
-#define MESSAGE_FUNC_FLOAT( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_FLOAT, #p1, 0, 0 ); virtual void name( float p1 )
-#define MESSAGE_FUNC_CHARPTR( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_CONSTCHARPTR, #p1, 0, 0 ); virtual void name( const char *p1 )
-#define MESSAGE_FUNC_WCHARPTR( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_CONSTWCHARPTR, #p1, 0, 0 ); virtual void name( const wchar_t *p1 )
-
-// two parameters
-#define MESSAGE_FUNC_INT_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( int p1, int p2 )
-#define MESSAGE_FUNC_PTR_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( vgui::Panel *p1, int p2 )
-#define MESSAGE_FUNC_HANDLE_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( vgui::VPANEL p1, int p2 )
-#define MESSAGE_FUNC_ENUM_ENUM( name, scriptname, t1, p1, t2, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( t1 p1, t2 p2 )
-#define MESSAGE_FUNC_INT_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( int p1, const char *p2 )
-#define MESSAGE_FUNC_PTR_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( vgui::Panel *p1, const char *p2 )
-#define MESSAGE_FUNC_HANDLE_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( vgui::VPANEL p1, const char *p2 )
-#define MESSAGE_FUNC_PTR_WCHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_CONSTWCHARPTR, #p2 ); virtual void name( vgui::Panel *p1, const wchar_t *p2 )
-#define MESSAGE_FUNC_HANDLE_WCHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_CONSTWCHARPTR, #p2 ); virtual void name( vgui::VPANEL p1, const wchar_t *p2 )
-#define MESSAGE_FUNC_CHARPTR_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_CONSTCHARPTR, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( const char *p1, const char *p2 )
-
-// unlimited parameters (passed in the whole KeyValues)
-#define MESSAGE_FUNC_PARAMS( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_KEYVALUES, NULL, 0, 0 ); virtual void name( KeyValues *p1 )
-
-// no-virtual function version
-#define MESSAGE_FUNC_NV( name, scriptname ) _MessageFuncCommon( name, scriptname, 0, 0, 0, 0, 0 ); void name( void )
-#define MESSAGE_FUNC_NV_INT( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_INT, #p1, 0, 0 ); void name( int p1 )
-#define MESSAGE_FUNC_NV_INT_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_INT, #p2 ); void name( int p1, int p2 )
-
-
-// mapping, one per class
-struct PanelMessageMap
-{
- PanelMessageMap()
- {
- baseMap = NULL;
- pfnClassName = NULL;
- processed = false;
- }
-
- CUtlVector< MessageMapItem_t > entries;
- bool processed;
- PanelMessageMap *baseMap;
- char const *(*pfnClassName)( void );
-};
-
-PanelMessageMap *FindPanelMessageMap( char const *className );
-PanelMessageMap *FindOrAddPanelMessageMap( char const *className );
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// OBSELETE MAPPING FUNCTIONS, USE ABOVE
-//
-///////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-// no parameters
-#define MAP_MESSAGE( type, name, func ) { name, (vgui::MessageFunc_t)(&type::func), 0 }
-
-// implicit single parameter (params is the data store)
-#define MAP_MESSAGE_PARAMS( type, name, func ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_KEYVALUES, NULL }
-
-// single parameter
-#define MAP_MESSAGE_PTR( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_PTR, param1 }
-#define MAP_MESSAGE_INT( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_INT, param1 }
-#define MAP_MESSAGE_BOOL( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_BOOL, param1 }
-#define MAP_MESSAGE_FLOAT( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_FLOAT, param1 }
-#define MAP_MESSAGE_PTR( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_PTR, param1 }
-#define MAP_MESSAGE_CONSTCHARPTR( type, name, func, param1) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_CONSTCHARPTR, param1 }
-#define MAP_MESSAGE_CONSTWCHARPTR( type, name, func, param1) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_CONSTWCHARPTR, param1 }
-
-// two parameters
-#define MAP_MESSAGE_INT_INT( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_INT, param1, vgui::DATATYPE_INT, param2 }
-#define MAP_MESSAGE_PTR_INT( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_PTR, param1, vgui::DATATYPE_INT, param2 }
-#define MAP_MESSAGE_INT_CONSTCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_INT, param1, vgui::DATATYPE_CONSTCHARPTR, param2 }
-#define MAP_MESSAGE_PTR_CONSTCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_PTR, param1, vgui::DATATYPE_CONSTCHARPTR, param2 }
-#define MAP_MESSAGE_PTR_CONSTWCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_PTR, param1, vgui::DATATYPE_CONSTWCHARPTR, param2 }
-#define MAP_MESSAGE_CONSTCHARPTR_CONSTCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_CONSTCHARPTR, param1, vgui::DATATYPE_CONSTCHARPTR, param2 }
-
-// if more parameters are needed, just use MAP_MESSAGE_PARAMS() and pass the keyvalue set into the function
-
-//-----------------------------------------------------------------------------
-// Purpose: stores the list of objects in the hierarchy
-// used to iterate through an object's message maps
-//-----------------------------------------------------------------------------
-struct PanelMap_t
-{
- MessageMapItem_t *dataDesc;
- int dataNumFields;
- const char *dataClassName;
- PanelMap_t *baseMap;
- int processed;
-};
-
-// for use in class declarations
-// declares the static variables and functions needed for the data description iteration
-#define DECLARE_PANELMAP() \
- static vgui::PanelMap_t m_PanelMap; \
- static vgui::MessageMapItem_t m_MessageMap[]; \
- virtual vgui::PanelMap_t *GetPanelMap( void );
-
-// could embed typeid() into here as well?
-#define IMPLEMENT_PANELMAP( derivedClass, baseClass ) \
- vgui::PanelMap_t derivedClass::m_PanelMap = { derivedClass::m_MessageMap, ARRAYSIZE(derivedClass::m_MessageMap), #derivedClass, &baseClass::m_PanelMap }; \
- vgui::PanelMap_t *derivedClass::GetPanelMap( void ) { return &m_PanelMap; }
-
-typedef vgui::Panel *( *PANELCREATEFUNC )( void );
-
-//-----------------------------------------------------------------------------
-// Purpose: Used by DECLARE_BUILD_FACTORY macro to create a linked list of
-// instancing functions
-//-----------------------------------------------------------------------------
-class CBuildFactoryHelper
-{
-public:
- // Static list of helpers
- static CBuildFactoryHelper *m_sHelpers;
-
-public:
- // Construction
- CBuildFactoryHelper( char const *className, PANELCREATEFUNC func );
-
- // Accessors
- CBuildFactoryHelper *GetNext( void );
-
- char const *GetClassName() const;
-
- vgui::Panel *CreatePanel();
-
- static vgui::Panel *InstancePanel( char const *className );
- static void GetFactoryNames( CUtlVector< char const * >& list );
-private:
-
- static bool HasFactory( char const *className );
-
- // Next factory in list
- CBuildFactoryHelper *m_pNext;
-
- int m_Type;
- PANELCREATEFUNC m_CreateFunc;
- char const *m_pClassName;
-};
-
-// This is the macro which implements creation of each type of panel
-// It creates a function which instances an object of the specified type
-// It them hooks that function up to the helper list so that the CHud objects can create
-// the elements by name, with no header file dependency, etc.
-#define DECLARE_BUILD_FACTORY( className ) \
- static vgui::Panel *Create_##className( void ) \
- { \
- return new className( NULL, NULL ); \
- }; \
- static vgui::CBuildFactoryHelper g_##className##_Helper( #className, Create_##className );\
- className *g_##className##LinkerHack = NULL;
-
-#define DECLARE_BUILD_FACTORY_DEFAULT_TEXT( className, defaultText ) \
- static vgui::Panel *Create_##className( void ) \
- { \
- return new className( NULL, NULL, #defaultText ); \
- }; \
- static vgui::CBuildFactoryHelper g_##className##_Helper( #className, Create_##className );\
- className *g_##className##LinkerHack = NULL;
-
-// This one allows passing in a special function with calls new panel( xxx ) with arbitrary default parameters
-#define DECLARE_BUILD_FACTORY_CUSTOM( className, createFunc ) \
- static vgui::CBuildFactoryHelper g_##className##_Helper( #className, createFunc );\
- className *g_##className##LinkerHack = NULL;
-
-#define DECLARE_BUILD_FACTORY_CUSTOM_ALIAS( className, factoryName, createFunc ) \
- static vgui::CBuildFactoryHelper g_##factoryName##_Helper( #factoryName, createFunc );\
- className *g_##factoryName##LinkerHack = NULL;
-
-} // namespace vgui
-
-
-#endif // MESSAGEMAP_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef MESSAGEMAP_H +#define MESSAGEMAP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlvector.h" + +// more flexible than default pointers to members code required for casting member function pointers +//#pragma pointers_to_members( full_generality, virtual_inheritance ) + +namespace vgui +{ + +////////////// MESSAGEMAP DEFINITIONS ////////////// + + +//----------------------------------------------------------------------------- +// Purpose: parameter data type enumeration +// used internal but the shortcut macros require this to be exposed +//----------------------------------------------------------------------------- +enum DataType_t +{ + DATATYPE_VOID, + DATATYPE_CONSTCHARPTR, + DATATYPE_INT, + DATATYPE_FLOAT, + DATATYPE_PTR, + DATATYPE_BOOL, + DATATYPE_KEYVALUES, + DATATYPE_CONSTWCHARPTR, + DATATYPE_UINT64, + DATATYPE_HANDLE, // It's an int, really +}; + +#ifdef WIN32 +class __virtual_inheritance Panel; +#else +class Panel; +#endif +typedef unsigned int VPANEL; + +typedef void (Panel::*MessageFunc_t)(void); + +//----------------------------------------------------------------------------- +// Purpose: Single item in a message map +// Contains the information to map a string message name with parameters +// to a function call +//----------------------------------------------------------------------------- +#pragma warning(disable:4121) +struct MessageMapItem_t +{ + const char *name; + // VC6 aligns this to 16-bytes. Since some of the code has been compiled with VC6, + // we need to enforce the alignment on later compilers to remain compatible. + ALIGN16 MessageFunc_t func; + + int numParams; + + DataType_t firstParamType; + const char *firstParamName; + + DataType_t secondParamType; + const char *secondParamName; + + int nameSymbol; + int firstParamSymbol; + int secondParamSymbol; +}; + +#define DECLARE_PANELMESSAGEMAP( className ) \ + static void AddToMap( char const *scriptname, vgui::MessageFunc_t function, int paramCount, int p1type, const char *p1name, int p2type, const char *p2name ) \ + { \ + vgui::PanelMessageMap *map = vgui::FindOrAddPanelMessageMap( GetPanelClassName() ); \ + \ + vgui::MessageMapItem_t entry; \ + entry.name = scriptname; \ + entry.func = function; \ + entry.numParams = paramCount; \ + entry.firstParamType = (vgui::DataType_t)p1type; \ + entry.firstParamName = p1name; \ + entry.secondParamType = (vgui::DataType_t)p2type; \ + entry.secondParamName = p2name; \ + entry.nameSymbol = 0; \ + entry.firstParamSymbol = 0; \ + entry.secondParamSymbol = 0; \ + \ + map->entries.AddToTail( entry ); \ + } \ + \ + static void ChainToMap( void ) \ + { \ + static bool chained = false; \ + if ( chained ) \ + return; \ + chained = true; \ + vgui::PanelMessageMap *map = vgui::FindOrAddPanelMessageMap( GetPanelClassName() ); \ + map->pfnClassName = &GetPanelClassName; \ + if ( map && GetPanelBaseClassName() && GetPanelBaseClassName()[0] ) \ + { \ + map->baseMap = vgui::FindOrAddPanelMessageMap( GetPanelBaseClassName() ); \ + } \ + } \ + \ + class className##_RegisterMap; \ + friend class className##_RegisterMap; \ + class className##_RegisterMap \ + { \ + public: \ + className##_RegisterMap() \ + { \ + className::ChainToMap(); \ + } \ + }; \ + className##_RegisterMap m_RegisterClass; \ + \ + virtual vgui::PanelMessageMap *GetMessageMap() \ + { \ + static vgui::PanelMessageMap *s_pMap = vgui::FindOrAddPanelMessageMap( GetPanelClassName() ); \ + return s_pMap; \ + } + +#if !defined( _XBOX ) +#define VGUI_USEKEYBINDINGMAPS 1 +#endif + +#if defined( VGUI_USEKEYBINDINGMAPS ) + +#define DECLARE_CLASS_SIMPLE( className, baseClassName ) \ + typedef baseClassName BaseClass; \ + typedef className ThisClass; \ +public: \ + DECLARE_PANELMESSAGEMAP( className ); \ + DECLARE_PANELANIMATION( className ); \ + DECLARE_KEYBINDINGMAP( className ); \ + static char const *GetPanelClassName() { return #className; } \ + static char const *GetPanelBaseClassName() { return #baseClassName; } + +#define DECLARE_CLASS_SIMPLE_NOBASE( className ) \ + typedef className ThisClass; \ +public: \ + DECLARE_PANELMESSAGEMAP( className ); \ + DECLARE_PANELANIMATION( className ); \ + DECLARE_KEYBINDINGMAP( className ); \ + static char const *GetPanelClassName() { return #className; } \ + static char const *GetPanelBaseClassName() { return NULL; } + +#else // no keybinding maps + +#define DECLARE_CLASS_SIMPLE( className, baseClassName ) \ + typedef baseClassName BaseClass; \ + typedef className ThisClass; \ +public: \ + DECLARE_PANELMESSAGEMAP( className ); \ + DECLARE_PANELANIMATION( className ); \ + static char const *GetPanelClassName() { return #className; } \ + static char const *GetPanelBaseClassName() { return #baseClassName; } + +#define DECLARE_CLASS_SIMPLE_NOBASE( className ) \ + typedef className ThisClass; \ +public: \ + DECLARE_PANELMESSAGEMAP( className ); \ + DECLARE_PANELANIMATION( className ); \ + static char const *GetPanelClassName() { return #className; } \ + static char const *GetPanelBaseClassName() { return NULL; } + +#endif // !VGUI_USEKEYBINDINGMAPS + +#define _MessageFuncCommon( name, scriptname, paramCount, p1type, p1name, p2type, p2name ) \ + class PanelMessageFunc_##name; \ + friend class PanelMessageFunc_##name; \ + class PanelMessageFunc_##name \ + { \ + public: \ + static void InitVar() \ + { \ + static bool bAdded = false; \ + if ( !bAdded ) \ + { \ + bAdded = true; \ + AddToMap( scriptname, (vgui::MessageFunc_t)&ThisClass::name, paramCount, p1type, p1name, p2type, p2name ); \ + } \ + } \ + PanelMessageFunc_##name() \ + { \ + PanelMessageFunc_##name::InitVar(); \ + } \ + }; \ + PanelMessageFunc_##name m_##name##_register; \ + +// Use this macro to define a message mapped function +// must end with a semicolon ';', or with a function +// no parameter +#define MESSAGE_FUNC( name, scriptname ) _MessageFuncCommon( name, scriptname, 0, 0, 0, 0, 0 ); virtual void name( void ) + +// one parameter +#define MESSAGE_FUNC_INT( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_INT, #p1, 0, 0 ); virtual void name( int p1 ) +#define MESSAGE_FUNC_UINT64( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_UINT64, #p1, 0, 0 ); virtual void name( uint64 p1 ) +#define MESSAGE_FUNC_PTR( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_PTR, #p1, 0, 0 ); virtual void name( vgui::Panel *p1 ) +#define MESSAGE_FUNC_HANDLE( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_HANDLE, #p1, 0, 0 ); virtual void name( vgui::VPANEL p1 ) +#define MESSAGE_FUNC_ENUM( name, scriptname, t1, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_INT, #p1, 0, 0 ); virtual void name( t1 p1 ) +#define MESSAGE_FUNC_FLOAT( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_FLOAT, #p1, 0, 0 ); virtual void name( float p1 ) +#define MESSAGE_FUNC_CHARPTR( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_CONSTCHARPTR, #p1, 0, 0 ); virtual void name( const char *p1 ) +#define MESSAGE_FUNC_WCHARPTR( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_CONSTWCHARPTR, #p1, 0, 0 ); virtual void name( const wchar_t *p1 ) + +// two parameters +#define MESSAGE_FUNC_INT_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( int p1, int p2 ) +#define MESSAGE_FUNC_PTR_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( vgui::Panel *p1, int p2 ) +#define MESSAGE_FUNC_HANDLE_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( vgui::VPANEL p1, int p2 ) +#define MESSAGE_FUNC_ENUM_ENUM( name, scriptname, t1, p1, t2, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_INT, #p2 ); virtual void name( t1 p1, t2 p2 ) +#define MESSAGE_FUNC_INT_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( int p1, const char *p2 ) +#define MESSAGE_FUNC_PTR_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( vgui::Panel *p1, const char *p2 ) +#define MESSAGE_FUNC_HANDLE_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( vgui::VPANEL p1, const char *p2 ) +#define MESSAGE_FUNC_PTR_WCHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_CONSTWCHARPTR, #p2 ); virtual void name( vgui::Panel *p1, const wchar_t *p2 ) +#define MESSAGE_FUNC_HANDLE_WCHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_CONSTWCHARPTR, #p2 ); virtual void name( vgui::VPANEL p1, const wchar_t *p2 ) +#define MESSAGE_FUNC_CHARPTR_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_CONSTCHARPTR, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( const char *p1, const char *p2 ) + +// unlimited parameters (passed in the whole KeyValues) +#define MESSAGE_FUNC_PARAMS( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_KEYVALUES, NULL, 0, 0 ); virtual void name( KeyValues *p1 ) + +// no-virtual function version +#define MESSAGE_FUNC_NV( name, scriptname ) _MessageFuncCommon( name, scriptname, 0, 0, 0, 0, 0 ); void name( void ) +#define MESSAGE_FUNC_NV_INT( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_INT, #p1, 0, 0 ); void name( int p1 ) +#define MESSAGE_FUNC_NV_INT_INT( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_INT, #p1, vgui::DATATYPE_INT, #p2 ); void name( int p1, int p2 ) + + +// mapping, one per class +struct PanelMessageMap +{ + PanelMessageMap() + { + baseMap = NULL; + pfnClassName = NULL; + processed = false; + } + + CUtlVector< MessageMapItem_t > entries; + bool processed; + PanelMessageMap *baseMap; + char const *(*pfnClassName)( void ); +}; + +PanelMessageMap *FindPanelMessageMap( char const *className ); +PanelMessageMap *FindOrAddPanelMessageMap( char const *className ); + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// OBSELETE MAPPING FUNCTIONS, USE ABOVE +// +/////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// no parameters +#define MAP_MESSAGE( type, name, func ) { name, (vgui::MessageFunc_t)(&type::func), 0 } + +// implicit single parameter (params is the data store) +#define MAP_MESSAGE_PARAMS( type, name, func ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_KEYVALUES, NULL } + +// single parameter +#define MAP_MESSAGE_PTR( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_PTR, param1 } +#define MAP_MESSAGE_INT( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_INT, param1 } +#define MAP_MESSAGE_BOOL( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_BOOL, param1 } +#define MAP_MESSAGE_FLOAT( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_FLOAT, param1 } +#define MAP_MESSAGE_PTR( type, name, func, param1 ) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_PTR, param1 } +#define MAP_MESSAGE_CONSTCHARPTR( type, name, func, param1) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_CONSTCHARPTR, param1 } +#define MAP_MESSAGE_CONSTWCHARPTR( type, name, func, param1) { name, (vgui::MessageFunc_t)(&type::func), 1, vgui::DATATYPE_CONSTWCHARPTR, param1 } + +// two parameters +#define MAP_MESSAGE_INT_INT( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_INT, param1, vgui::DATATYPE_INT, param2 } +#define MAP_MESSAGE_PTR_INT( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_PTR, param1, vgui::DATATYPE_INT, param2 } +#define MAP_MESSAGE_INT_CONSTCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_INT, param1, vgui::DATATYPE_CONSTCHARPTR, param2 } +#define MAP_MESSAGE_PTR_CONSTCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_PTR, param1, vgui::DATATYPE_CONSTCHARPTR, param2 } +#define MAP_MESSAGE_PTR_CONSTWCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_PTR, param1, vgui::DATATYPE_CONSTWCHARPTR, param2 } +#define MAP_MESSAGE_CONSTCHARPTR_CONSTCHARPTR( type, name, func, param1, param2 ) { name, (vgui::MessageFunc_t)&type::func, 2, vgui::DATATYPE_CONSTCHARPTR, param1, vgui::DATATYPE_CONSTCHARPTR, param2 } + +// if more parameters are needed, just use MAP_MESSAGE_PARAMS() and pass the keyvalue set into the function + +//----------------------------------------------------------------------------- +// Purpose: stores the list of objects in the hierarchy +// used to iterate through an object's message maps +//----------------------------------------------------------------------------- +struct PanelMap_t +{ + MessageMapItem_t *dataDesc; + int dataNumFields; + const char *dataClassName; + PanelMap_t *baseMap; + int processed; +}; + +// for use in class declarations +// declares the static variables and functions needed for the data description iteration +#define DECLARE_PANELMAP() \ + static vgui::PanelMap_t m_PanelMap; \ + static vgui::MessageMapItem_t m_MessageMap[]; \ + virtual vgui::PanelMap_t *GetPanelMap( void ); + +// could embed typeid() into here as well? +#define IMPLEMENT_PANELMAP( derivedClass, baseClass ) \ + vgui::PanelMap_t derivedClass::m_PanelMap = { derivedClass::m_MessageMap, ARRAYSIZE(derivedClass::m_MessageMap), #derivedClass, &baseClass::m_PanelMap }; \ + vgui::PanelMap_t *derivedClass::GetPanelMap( void ) { return &m_PanelMap; } + +typedef vgui::Panel *( *PANELCREATEFUNC )( void ); + +//----------------------------------------------------------------------------- +// Purpose: Used by DECLARE_BUILD_FACTORY macro to create a linked list of +// instancing functions +//----------------------------------------------------------------------------- +class CBuildFactoryHelper +{ +public: + // Static list of helpers + static CBuildFactoryHelper *m_sHelpers; + +public: + // Construction + CBuildFactoryHelper( char const *className, PANELCREATEFUNC func ); + + // Accessors + CBuildFactoryHelper *GetNext( void ); + + char const *GetClassName() const; + + vgui::Panel *CreatePanel(); + + static vgui::Panel *InstancePanel( char const *className ); + static void GetFactoryNames( CUtlVector< char const * >& list ); +private: + + static bool HasFactory( char const *className ); + + // Next factory in list + CBuildFactoryHelper *m_pNext; + + int m_Type; + PANELCREATEFUNC m_CreateFunc; + char const *m_pClassName; +}; + +// This is the macro which implements creation of each type of panel +// It creates a function which instances an object of the specified type +// It them hooks that function up to the helper list so that the CHud objects can create +// the elements by name, with no header file dependency, etc. +#define DECLARE_BUILD_FACTORY( className ) \ + static vgui::Panel *Create_##className( void ) \ + { \ + return new className( NULL, NULL ); \ + }; \ + static vgui::CBuildFactoryHelper g_##className##_Helper( #className, Create_##className );\ + className *g_##className##LinkerHack = NULL; + +#define DECLARE_BUILD_FACTORY_DEFAULT_TEXT( className, defaultText ) \ + static vgui::Panel *Create_##className( void ) \ + { \ + return new className( NULL, NULL, #defaultText ); \ + }; \ + static vgui::CBuildFactoryHelper g_##className##_Helper( #className, Create_##className );\ + className *g_##className##LinkerHack = NULL; + +// This one allows passing in a special function with calls new panel( xxx ) with arbitrary default parameters +#define DECLARE_BUILD_FACTORY_CUSTOM( className, createFunc ) \ + static vgui::CBuildFactoryHelper g_##className##_Helper( #className, createFunc );\ + className *g_##className##LinkerHack = NULL; + +#define DECLARE_BUILD_FACTORY_CUSTOM_ALIAS( className, factoryName, createFunc ) \ + static vgui::CBuildFactoryHelper g_##factoryName##_Helper( #factoryName, createFunc );\ + className *g_##factoryName##LinkerHack = NULL; + +} // namespace vgui + + +#endif // MESSAGEMAP_H diff --git a/mp/src/public/vgui_controls/PHandle.h b/mp/src/public/vgui_controls/PHandle.h index 8a129061..959ee4a9 100644 --- a/mp/src/public/vgui_controls/PHandle.h +++ b/mp/src/public/vgui_controls/PHandle.h @@ -1,86 +1,86 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PHANDLE_H
-#define PHANDLE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-
-namespace vgui
-{
-
-class Panel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Safe pointer class for handling Panel or derived panel classes
-//-----------------------------------------------------------------------------
-class PHandle
-{
-public:
- PHandle() : m_iPanelID(INVALID_PANEL) {} //m_iSerialNumber(0), m_pListEntry(0) {}
-
- Panel *Get();
- Panel *Set( Panel *pPanel );
- Panel *Set( HPanel hPanel );
-
- operator Panel *() { return Get(); }
- Panel * operator ->() { return Get(); }
- Panel * operator = (Panel *pPanel) { return Set(pPanel); }
-
- bool operator == (Panel *pPanel) { return (Get() == pPanel); }
- operator bool () { return Get() != 0; }
-
-private:
- HPanel m_iPanelID;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Safe pointer class to just convert between VPANEL's and PHandle
-//-----------------------------------------------------------------------------
-class VPanelHandle
-{
-public:
- VPanelHandle() : m_iPanelID(INVALID_PANEL) {}
-
- VPANEL Get();
- VPANEL Set( VPANEL pPanel );
-
- operator VPANEL () { return Get(); }
- VPANEL operator = (VPANEL pPanel) { return Set(pPanel); }
-
- bool operator == (VPANEL pPanel) { return (Get() == pPanel); }
- operator bool () { return Get() != 0; }
-
-private:
- HPanel m_iPanelID;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: DHANDLE is a templated version of PHandle
-//-----------------------------------------------------------------------------
-template< class PanelType >
-class DHANDLE : public PHandle
-{
-public:
- PanelType *Get() { return (PanelType *)PHandle::Get(); }
- PanelType *Set( PanelType *pPanel ) { return (PanelType *)PHandle::Set(pPanel); }
- PanelType *Set( HPanel hPanel ) { return (PanelType *)PHandle::Set(hPanel); }
-
- operator PanelType *() { return (PanelType *)PHandle::Get(); }
- PanelType * operator ->() { return (PanelType *)PHandle::Get(); }
- PanelType * operator = (PanelType *pPanel) { return (PanelType *)PHandle::Set(pPanel); }
- bool operator == (Panel *pPanel) { return (PHandle::Get() == pPanel); }
- operator bool () { return PHandle::Get() != NULL; }
-};
-
-};
-
-#endif // PHANDLE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PHANDLE_H +#define PHANDLE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> + +namespace vgui +{ + +class Panel; + +//----------------------------------------------------------------------------- +// Purpose: Safe pointer class for handling Panel or derived panel classes +//----------------------------------------------------------------------------- +class PHandle +{ +public: + PHandle() : m_iPanelID(INVALID_PANEL) {} //m_iSerialNumber(0), m_pListEntry(0) {} + + Panel *Get(); + Panel *Set( Panel *pPanel ); + Panel *Set( HPanel hPanel ); + + operator Panel *() { return Get(); } + Panel * operator ->() { return Get(); } + Panel * operator = (Panel *pPanel) { return Set(pPanel); } + + bool operator == (Panel *pPanel) { return (Get() == pPanel); } + operator bool () { return Get() != 0; } + +private: + HPanel m_iPanelID; +}; + +//----------------------------------------------------------------------------- +// Purpose: Safe pointer class to just convert between VPANEL's and PHandle +//----------------------------------------------------------------------------- +class VPanelHandle +{ +public: + VPanelHandle() : m_iPanelID(INVALID_PANEL) {} + + VPANEL Get(); + VPANEL Set( VPANEL pPanel ); + + operator VPANEL () { return Get(); } + VPANEL operator = (VPANEL pPanel) { return Set(pPanel); } + + bool operator == (VPANEL pPanel) { return (Get() == pPanel); } + operator bool () { return Get() != 0; } + +private: + HPanel m_iPanelID; +}; + +//----------------------------------------------------------------------------- +// Purpose: DHANDLE is a templated version of PHandle +//----------------------------------------------------------------------------- +template< class PanelType > +class DHANDLE : public PHandle +{ +public: + PanelType *Get() { return (PanelType *)PHandle::Get(); } + PanelType *Set( PanelType *pPanel ) { return (PanelType *)PHandle::Set(pPanel); } + PanelType *Set( HPanel hPanel ) { return (PanelType *)PHandle::Set(hPanel); } + + operator PanelType *() { return (PanelType *)PHandle::Get(); } + PanelType * operator ->() { return (PanelType *)PHandle::Get(); } + PanelType * operator = (PanelType *pPanel) { return (PanelType *)PHandle::Set(pPanel); } + bool operator == (Panel *pPanel) { return (PHandle::Get() == pPanel); } + operator bool () { return PHandle::Get() != NULL; } +}; + +}; + +#endif // PHANDLE_H diff --git a/mp/src/public/vgui_controls/Panel.h b/mp/src/public/vgui_controls/Panel.h index afbfd177..0523cb31 100644 --- a/mp/src/public/vgui_controls/Panel.h +++ b/mp/src/public/vgui_controls/Panel.h @@ -1,1008 +1,1008 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef PANEL_H
-#define PANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier1/utlflags.h"
-#include "vgui/VGUI.h"
-#include "vgui/Dar.h"
-#include "vgui_controls/MessageMap.h"
-#if defined( VGUI_USEKEYBINDINGMAPS )
-#include "vgui_controls/KeyBindingMap.h"
-#endif
-#include "vgui/IClientPanel.h"
-#include "vgui/IScheme.h"
-#include "vgui_controls/Controls.h"
-#include "vgui_controls/PHandle.h"
-#include "vgui_controls/PanelAnimationVar.h"
-#include "Color.h"
-#include "vstdlib/IKeyValuesSystem.h"
-#include "tier1/utlsymbol.h"
-#include "vgui_controls/BuildGroup.h"
-
-// undefine windows function macros that overlap
-#ifdef PostMessage
-#undef PostMessage
-#endif
-
-#ifdef SetCursor
-#undef SetCursor
-#endif
-
-class CUtlBuffer;
-
-namespace vgui
-{
-
-#if !defined( _X360 )
-#define VGUI_USEDRAGDROP 1
-#endif
-
-#if defined( VGUI_USEKEYBINDINGMAPS )
-struct PanelKeyBindingMap;
-#endif
-//-----------------------------------------------------------------------------
-// Purpose: Helper functions to construct vgui panels
-//
-// SETUP_PANEL - will make a panel ready for use right now (i.e setup its colors, borders, fonts, etc)
-//
-template< class T >
-inline T *SETUP_PANEL(T *panel)
-{
- panel->MakeReadyForUse();
- return panel;
-}
-
-//
-// CREATE_PANEL - creates a panel that is ready to use right now
-//
-// 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)
-//
-#define CREATE_PANEL(type, parent, name) (SETUP_PANEL(new type(parent, name)))
-
-//-----------------------------------------------------------------------------
-// Purpose: Drag/drop support context info (could defined within Panel...)
-//-----------------------------------------------------------------------------
-#if defined( VGUI_USEDRAGDROP )
-struct DragDrop_t;
-class Menu;
-#endif
-
-//-----------------------------------------------------------------------------
-// Purpose: Macro to handle Colors that can be overridden in .res files
-//-----------------------------------------------------------------------------
-struct OverridableColorEntry
-{
- char const *name() { return m_pszScriptName; }
-
- char const *m_pszScriptName;
- Color *m_pColor;
- Color m_colFromScript;
- bool m_bOverridden;
-};
-
-#define REGISTER_COLOR_AS_OVERRIDABLE( name, scriptname ) \
- AddToOverridableColors( &name, scriptname );
-
-
-
-//-----------------------------------------------------------------------------
-// Purpose: For hudanimations.txt scripting of vars
-//-----------------------------------------------------------------------------
-class IPanelAnimationPropertyConverter
-{
-public:
- virtual void GetData( Panel *panel, KeyValues *kv, PanelAnimationMapEntry *entry ) = 0;
- virtual void SetData( Panel *panel, KeyValues *kv, PanelAnimationMapEntry *entry ) = 0;
- virtual void InitFromDefault( Panel *panel, PanelAnimationMapEntry *entry ) = 0;
-};
-
-#if defined( VGUI_USEKEYBINDINGMAPS )
-enum KeyBindingContextHandle_t
-{
- INVALID_KEYBINDINGCONTEXT_HANDLE = 0xffffffff,
-};
-#endif
-
-class IForceVirtualInheritancePanel
-{
- // We need Panel to use virtual inheritance so that
- // pointers to its members are max size.
- // This is due to a limitation in C++ with ahead
- // declarations of points to members as used in MessageMap.
-};
-
-//=============================================================================
-// HPE_BEGIN:
-// [tj] bitwise defines for rounded corners
-//=============================================================================
-#define PANEL_ROUND_CORNER_TOP_LEFT (1 << 0)
-#define PANEL_ROUND_CORNER_TOP_RIGHT (1 << 1)
-#define PANEL_ROUND_CORNER_BOTTOM_LEFT (1 << 2)
-#define PANEL_ROUND_CORNER_BOTTOM_RIGHT (1 << 3)
-#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
-//=============================================================================
-// HPE_END
-//=============================================================================//-----------------------------------------------------------------------------
-// Purpose: Base interface to all vgui windows
-// All vgui controls that receive message and/or have a physical presence
-// on screen are be derived from Panel.
-// This is designed as an easy-access to the vgui-functionality; for more
-// low-level access to vgui functions use the IPanel/IClientPanel interfaces directly
-//-----------------------------------------------------------------------------
-class Panel : public IClientPanel, virtual IForceVirtualInheritancePanel
-{
- DECLARE_CLASS_SIMPLE_NOBASE( Panel );
-
-public:
- // For property mapping
- static void InitPropertyConverters( void );
- static void AddPropertyConverter( char const *typeName, IPanelAnimationPropertyConverter *converter );
-
- //-----------------------------------------------------------------------------
- // CONSTRUCTORS
- // these functions deal with the creation of the Panel
- // the Panel automatically gets a handle to a vgui-internal panel, the ipanel(), upon construction
- // vgui interfaces deal only with ipanel(), not Panel directly
- Panel();
- Panel(Panel *parent);
- Panel(Panel *parent, const char *panelName);
- Panel(Panel *parent, const char *panelName, HScheme scheme);
-
- virtual ~Panel();
-
- // returns pointer to Panel's vgui VPanel interface handle
- virtual VPANEL GetVPanel() { return _vpanel; }
- HPanel ToHandle() const;
-
- virtual void Init( int x, int y, int wide, int tall );
-
- //-----------------------------------------------------------------------------
- // PANEL METHODS
- // these functions all manipulate panels
- // they cannot be derived from
- void SetName(const char *panelName); // sets the name of the panel - used as an identifier
- const char *GetName(); // returns the name of this panel... never NULL
- const char *GetClassName(); // returns the class name of the panel (eg. Panel, Label, Button, etc.)
-
- void MakeReadyForUse(); // fully construct this panel so its ready for use right now (i.e fonts loaded, colors set, default label text set, ...)
-
- // panel position & size
- // all units are in pixels
- void SetPos(int x,int y); // sets position of panel, in local space (ie. relative to parent's position)
- void GetPos(int &x,int &y); // gets local position of panel
- void SetSize(int wide,int tall); // sets size of panel
- void GetSize(int &wide, int &tall); // gets size of panel
- void SetBounds(int x, int y, int wide, int tall); // combination of SetPos/SetSize
- void GetBounds(int &x, int &y, int &wide, int &tall); // combination of GetPos/GetSize
- int GetWide(); // returns width of panel
- void SetWide(int wide); // sets width of panel
- int GetTall(); // returns height of panel
- void SetTall(int tall); // sets height of panel
- void SetMinimumSize(int wide,int tall); // sets the minimum size the panel can go
- void GetMinimumSize(int& wide,int& tall); // gets the minimum size
- bool IsBuildModeEditable(); // editable in the buildModeDialog?
- void SetBuildModeEditable(bool state); // set buildModeDialog editable
- bool IsBuildModeDeletable(); // deletable in the buildModeDialog?
- void SetBuildModeDeletable(bool state); // set buildModeDialog deletable
- bool IsBuildModeActive(); // true if we're currently in edit mode
- void SetZPos(int z); // sets Z ordering - lower numbers are always behind higher z's
- int GetZPos( void );
- void SetAlpha(int alpha); // sets alpha modifier for panel and all child panels [0..255]
- int GetAlpha(); // returns the current alpha
-
- // panel visibility
- // invisible panels and their children do not drawn, updated, or receive input messages
- virtual void SetVisible(bool state);
- virtual bool IsVisible();
-
- // painting
- virtual VPANEL IsWithinTraverse(int x, int y, bool traversePopups); // recursive; returns a pointer to the panel at those coordinates
- MESSAGE_FUNC( Repaint, "Repaint" ); // marks the panel as needing to be repainted
- virtual void PostMessage(VPANEL target, KeyValues *message, float delaySeconds = 0.0f);
-
- bool IsWithin(int x, int y); //in screen space
- void LocalToScreen(int &x, int &y);
- void ScreenToLocal(int &x, int &y);
- void ParentLocalToScreen(int &x, int &y);
- void MakePopup(bool showTaskbarIcon = true,bool disabled = false); // turns the panel into a popup window (ie. can draw outside of it's parents space)
- virtual void OnMove();
-
- // panel hierarchy
- virtual Panel *GetParent();
- virtual VPANEL GetVParent();
- virtual void SetParent(Panel *newParent);
- virtual void SetParent(VPANEL newParent);
- virtual bool HasParent(VPANEL potentialParent);
-
- int GetChildCount();
- Panel *GetChild(int index);
- virtual CUtlVector< VPANEL > &GetChildren();
- int FindChildIndexByName( const char *childName );
- Panel *FindChildByName(const char *childName, bool recurseDown = false);
- Panel *FindSiblingByName(const char *siblingName);
- void CallParentFunction(KeyValues *message);
-
- template <class T>
- T *FindControl( const char *pszName, bool recurseDown = false ) { return dynamic_cast<T *>( FindChildByName( pszName, recurseDown ) ); }
-
- virtual void SetAutoDelete(bool state); // if set to true, panel automatically frees itself when parent is deleted
- virtual bool IsAutoDeleteSet();
- virtual void DeletePanel(); // simply does a { delete this; }
-
- // messaging
- virtual void AddActionSignalTarget(Panel *messageTarget);
- virtual void AddActionSignalTarget(VPANEL messageTarget);
- virtual void RemoveActionSignalTarget(Panel *oldTarget);
- virtual void PostActionSignal(KeyValues *message); // sends a message to the current actionSignalTarget(s)
- virtual bool RequestInfoFromChild(const char *childName, KeyValues *outputData);
- virtual void PostMessageToChild(const char *childName, KeyValues *messsage);
- virtual void PostMessage(Panel *target, KeyValues *message, float delaySeconds = 0.0f);
- 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
- virtual bool SetInfo(KeyValues *inputData); // sets a specified value in the control - inverse of the above
- virtual void SetSilentMode( bool bSilent ); //change the panel's silent mode; if silent, the panel will not post any action signals
-
- // install a mouse handler
- virtual void InstallMouseHandler( Panel *pHandler ); // mouse events will be send to handler panel instead of this panel
-
- // drawing state
- virtual void SetEnabled(bool state);
- virtual bool IsEnabled();
- virtual bool IsPopup(); // has a parent, but is in it's own space
- virtual void GetClipRect(int &x0, int &y0, int &x1, int &y1);
- virtual void MoveToFront();
-
- // pin positions for auto-layout
- enum PinCorner_e
- {
- PIN_TOPLEFT = 0,
- PIN_TOPRIGHT,
- PIN_BOTTOMLEFT,
- PIN_BOTTOMRIGHT,
-
- // For sibling pinning
- PIN_CENTER_TOP,
- PIN_CENTER_RIGHT,
- PIN_CENTER_BOTTOM,
- PIN_CENTER_LEFT,
- };
-
- // specifies the auto-resize directions for the panel
- enum AutoResize_e
- {
- AUTORESIZE_NO = 0,
- AUTORESIZE_RIGHT,
- AUTORESIZE_DOWN,
- AUTORESIZE_DOWNANDRIGHT,
- };
-
- // Sets the pin corner for non-resizing panels
- void SetPinCorner( PinCorner_e pinCorner, int nOffsetX, int nOffsetY );
-
- // Sets the pin corner + resize mode for resizing panels
- void SetAutoResize( PinCorner_e pinCorner, AutoResize_e resizeDir, int nPinOffsetX, int nPinOffsetY, int nUnpinnedCornerOffsetX, int nUnpinnedCornerOffsetY );
-
- AutoResize_e GetAutoResize();
- PinCorner_e GetPinCorner();
-
- // Gets the relative offset of the control from the pinned + non-pinned corner (for resizing)
- void GetPinOffset( int &dx, int &dy );
- void GetResizeOffset( int &dx, int &dy );
-
- void PinToSibling( const char *pszSibling, PinCorner_e pinOurCorner, PinCorner_e pinSibling );
- void UpdateSiblingPin( void );
-
- // colors
- virtual void SetBgColor(Color color);
- virtual void SetFgColor(Color color);
- virtual Color GetBgColor();
- virtual Color GetFgColor();
-
- virtual void SetCursor(HCursor cursor);
- virtual HCursor GetCursor();
- virtual void SetCursorAlwaysVisible( bool visible );
- virtual void RequestFocus(int direction = 0);
- virtual bool HasFocus();
- virtual void InvalidateLayout(bool layoutNow = false, bool reloadScheme = false);
- virtual bool RequestFocusPrev(VPANEL panel = NULL);
- virtual bool RequestFocusNext(VPANEL panel = NULL);
- // tab positioning
- virtual void SetTabPosition(int position);
- virtual int GetTabPosition();
- // border
- virtual void SetBorder(IBorder *border);
- virtual IBorder *GetBorder();
- virtual void SetPaintBorderEnabled(bool state);
- virtual void SetPaintBackgroundEnabled(bool state);
- virtual void SetPaintEnabled(bool state);
- virtual void SetPostChildPaintEnabled(bool state);
- virtual void SetPaintBackgroundType(int type); // 0 for normal(opaque), 1 for single texture from Texture1, and 2 for rounded box w/ four corner textures
- virtual void GetInset(int &left, int &top, int &right, int &bottom);
- virtual void GetPaintSize(int &wide, int &tall);
- virtual void SetBuildGroup(BuildGroup *buildGroup);
- virtual bool IsBuildGroupEnabled();
- virtual bool IsCursorNone();
- virtual bool IsCursorOver(); // returns true if the cursor is currently over the panel
- virtual void MarkForDeletion(); // object will free it's memory next tick
- virtual bool IsLayoutInvalid(); // does this object require a perform layout?
- virtual Panel *HasHotkey(wchar_t key); // returns the panel that has this hotkey
- virtual bool IsOpaque();
- bool IsRightAligned(); // returns true if the settings are aligned to the right of the screen
- bool IsBottomAligned(); // returns true if the settings are aligned to the bottom of the screen
-
- // scheme access functions
- virtual HScheme GetScheme();
- virtual void SetScheme(const char *tag);
- virtual void SetScheme(HScheme scheme);
- virtual Color GetSchemeColor(const char *keyName,IScheme *pScheme);
- virtual Color GetSchemeColor(const char *keyName, Color defaultColor,IScheme *pScheme);
-
- // called when scheme settings need to be applied; called the first time before the panel is painted
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
- // interface to build settings
- // takes a group of settings and applies them to the control
- virtual void ApplySettings(KeyValues *inResourceData);
-
- // records the settings into the resource data
- virtual void GetSettings(KeyValues *outResourceData);
-
- // gets a description of the resource for use in the UI
- // format: <type><whitespace | punctuation><keyname><whitespace| punctuation><type><whitespace | punctuation><keyname>...
- // unknown types as just displayed as strings in the UI (for future UI expansion)
- virtual const char *GetDescription();
-
- // returns the name of the module that this instance of panel was compiled into
- virtual const char *GetModuleName();
-
- // user configuration settings
- // this is used for any control details the user wants saved between sessions
- // eg. dialog positions, last directory opened, list column width
- virtual void ApplyUserConfigSettings(KeyValues *userConfig);
-
- // returns user config settings for this control
- virtual void GetUserConfigSettings(KeyValues *userConfig);
-
- // optimization, return true if this control has any user config settings
- virtual bool HasUserConfigSettings();
-
- // message handlers
- // override to get access to the message
- // override to get access to the message
- virtual void OnMessage(const KeyValues *params, VPANEL fromPanel); // called when panel receives message; must chain back
- MESSAGE_FUNC_CHARPTR( OnCommand, "Command", command ); // called when a panel receives a command
- MESSAGE_FUNC( OnMouseCaptureLost, "MouseCaptureLost" ); // called after the panel loses mouse capture
- MESSAGE_FUNC( OnSetFocus, "SetFocus" ); // called after the panel receives the keyboard focus
- MESSAGE_FUNC( OnKillFocus, "KillFocus" ); // called after the panel loses the keyboard focus
- MESSAGE_FUNC( OnDelete, "Delete" ); // called to delete the panel; Panel::OnDelete() does simply { delete this; }
- virtual void OnThink(); // called every frame before painting, but only if panel is visible
- virtual void OnChildAdded(VPANEL child); // called when a child has been added to this panel
- virtual void OnSizeChanged(int newWide, int newTall); // called after the size of a panel has been changed
-
- // called every frame if ivgui()->AddTickSignal() is called
- virtual void OnTick();
-
- // input messages
- MESSAGE_FUNC_INT_INT( OnCursorMoved, "OnCursorMoved", x, y );
- virtual void OnCursorEntered();
- virtual void OnCursorExited();
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseDoublePressed(MouseCode code);
- virtual void OnMouseReleased(MouseCode code);
- virtual void OnMouseWheeled(int delta);
-
- // Trip pressing (e.g., select all text in a TextEntry) requires this to be enabled
- virtual void SetTriplePressAllowed( bool state );
- virtual bool IsTriplePressAllowed() const;
- virtual void OnMouseTriplePressed( MouseCode code );
-
- static char const *KeyCodeToString( KeyCode code );
- static wchar_t const *KeyCodeToDisplayString( KeyCode code );
- static wchar_t const *KeyCodeModifiersToDisplayString( KeyCode code, int modifiers ); // L"Ctrl+Alt+Shift+Backspace"
-
- static KeyCode StringToKeyCode( char const *str );
-#if defined( VGUI_USEKEYBINDINGMAPS )
- static KeyBindingContextHandle_t CreateKeyBindingsContext( char const *filename, char const *pathID = 0 );
- virtual void SetKeyBindingsContext( KeyBindingContextHandle_t handle );
- virtual KeyBindingContextHandle_t GetKeyBindingsContext() const;
- virtual bool IsValidKeyBindingsContext() const;
-
- static int GetPanelsWithKeyBindingsCount( KeyBindingContextHandle_t handle );
- static Panel *GetPanelWithKeyBindings( KeyBindingContextHandle_t handle, int index );
-
- static void RevertKeyBindings( KeyBindingContextHandle_t handle );
-
- static void ReloadKeyBindings( KeyBindingContextHandle_t handle );
- static void SaveKeyBindings( KeyBindingContextHandle_t handle );
- static void SaveKeyBindingsToFile( KeyBindingContextHandle_t handle, char const *filename, char const *pathID = 0 );
- static void LoadKeyBindings( KeyBindingContextHandle_t handle );
- static void LoadKeyBindingsForOnePanel( KeyBindingContextHandle_t handle, Panel *panelOfInterest );
-
- // OnKeyCodeTyped hooks into here for action
- virtual bool IsKeyRebound( KeyCode code, int modifiers );
- // If a panel implements this and returns true, then the IsKeyRebound check will fail and OnKeyCodeTyped messages will pass through..
- // sort of like setting the SetAllowKeyBindingChainToParent flag to false for specific keys
- virtual bool IsKeyOverridden( KeyCode code, int modifiers );
-
- virtual void AddKeyBinding( char const *bindingName, int keycode, int modifiers );
-
- KeyBindingMap_t *LookupBinding( char const *bindingName );
- KeyBindingMap_t *LookupBindingByKeyCode( KeyCode code, int modifiers );
- void LookupBoundKeys( char const *bindingName, CUtlVector< BoundKey_t * >& list );
- BoundKey_t *LookupDefaultKey( char const *bindingName );
- PanelKeyBindingMap *LookupMapForBinding( char const *bindingName );
-
- // Returns the number of keybindings
- int GetKeyMappingCount( );
-
- void RevertKeyBindingsToDefault();
- void RemoveAllKeyBindings();
- void ReloadKeyBindings();
- virtual void EditKeyBindings();
-
- // calls RevertKeyBindingsToDefault() and then LoadKeyBindingsForOnePanel( GetKeyBindingsContext(), this );
- void SaveKeyBindingsToBuffer( int level, CUtlBuffer& buf );
- bool ParseKeyBindings( KeyValues *kv );
-
- virtual char const *GetKeyBindingsFile() const;
- virtual char const *GetKeyBindingsFilePathID() const;
-
- // Set this to false to disallow IsKeyRebound chaining to GetParent() Panels...
- void SetAllowKeyBindingChainToParent( bool state );
- bool IsKeyBindingChainToParentAllowed() const;
-#endif // VGUI_USEKEYBINDINGMAPS
-
- // base implementation forwards Key messages to the Panel's parent
- // - override to 'swallow' the input
- virtual void OnKeyCodePressed(KeyCode code);
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void OnKeyTyped(wchar_t unichar);
- virtual void OnKeyCodeReleased(KeyCode code);
- virtual void OnKeyFocusTicked(); // every window gets key ticked events
-
- // forwards mouse messages to the panel's parent
- MESSAGE_FUNC( OnMouseFocusTicked, "OnMouseFocusTicked" );
-
- // message handlers that don't go through the message pump
- virtual void PaintBackground();
- virtual void Paint();
- virtual void PaintBorder();
- virtual void PaintBuildOverlay(); // the extra drawing for when in build mode
- virtual void PostChildPaint();
- virtual void PerformLayout();
-
- // this enables message mapping for this class - requires matching IMPLEMENT_PANELDESC() in the .cpp file
- DECLARE_PANELMAP();
-
- virtual VPANEL GetCurrentKeyFocus();
-
- // returns a pointer to the tooltip object associated with the panel
- // creates a new one if none yet exists
- BaseTooltip *GetTooltip();
- void SetTooltip( BaseTooltip *pToolTip, const char *pszText );
-
- /// Returns the effective tooltip text to use, whether stored
- /// locally in this panel, or in the tooltip object. Returns
- /// an empty string if no tooltip text
- const char *GetEffectiveTooltipText() const;
-
- // proportional mode settings
- virtual bool IsProportional() { return _flags.IsFlagSet( IS_PROPORTIONAL ); }
- virtual void SetProportional(bool state);
-
- // input interest
- virtual void SetMouseInputEnabled( bool state );
- virtual void SetKeyBoardInputEnabled( bool state );
- virtual bool IsMouseInputEnabled();
- virtual bool IsKeyBoardInputEnabled();
-
- virtual void DrawTexturedBox( int x, int y, int wide, int tall, Color color, float normalizedAlpha );
- virtual void DrawBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha, bool hollow = false );
- 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 );
- virtual void DrawHollowBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha );
- //=============================================================================
- // HPE_BEGIN:
- //=============================================================================
-
- // [menglish] Draws a hollow box similar to the already existing draw hollow box function, but takes the indents as params
- virtual void DrawHollowBox( int x, int y, int wide, int tall, Color color, float normalizedAlpha, int cornerWide, int cornerTall );
-
- // [tj] Simple getters and setters to decide which corners to draw rounded
- unsigned char GetRoundedCorners() { return m_roundedCorners; }
- void SetRoundedCorners (unsigned char cornerFlags) { m_roundedCorners = cornerFlags; }
- bool ShouldDrawTopLeftCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_TOP_LEFT; }
- bool ShouldDrawTopRightCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_TOP_RIGHT; }
- bool ShouldDrawBottomLeftCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_LEFT; }
- bool ShouldDrawBottomRightCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_RIGHT; }
-
- //=============================================================================
- // HPE_END
- //=============================================================================
-
-// Drag Drop Public interface
-
- virtual void SetDragEnabled( bool enabled );
- virtual bool IsDragEnabled() const;
-
- virtual void SetShowDragHelper( bool enabled );
-
- // Called if drag drop is started but not dropped on top of droppable panel...
- virtual void OnDragFailed( CUtlVector< KeyValues * >& msglist );
-
- // 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
- // draggable parent.
- virtual void SetBlockDragChaining( bool block );
- virtual bool IsBlockingDragChaining() const;
-
- virtual int GetDragStartTolerance() const;
- virtual void SetDragSTartTolerance( int nTolerance );
-
- // If hover context time is non-zero, then after the drop cursor is hovering over the panel for that amount of time
- // the Show hover context menu function will be invoked
- virtual void SetDropEnabled( bool enabled, float m_flHoverContextTime = 0.0f );
- virtual bool IsDropEnabled() const;
-
- // Called if m_flHoverContextTime was non-zero, allows droppee to preview the drop data and show an appropriate menu
- // Return false if not using context menu
- virtual bool GetDropContextMenu( Menu *menu, CUtlVector< KeyValues * >& msglist );
- virtual void OnDropContextHoverShow( CUtlVector< KeyValues * >& msglist );
- virtual void OnDropContextHoverHide( CUtlVector< KeyValues * >& msglist );
-
-#if defined( VGUI_USEDRAGDROP )
- virtual DragDrop_t *GetDragDropInfo();
-#endif
- // For handling multiple selections...
- virtual void OnGetAdditionalDragPanels( CUtlVector< Panel * >& dragabbles );
-
- virtual void OnCreateDragData( KeyValues *msg );
- // Called to see if a drop enabled panel can accept the specified data blob
- virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
-
- // Mouse is on draggable panel and has started moving, but is not over a droppable panel yet
- virtual void OnDraggablePanelPaint();
- // Mouse is now over a droppable panel
- virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels );
-
- virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
-
- // called on droptarget when draggable panel entered/exited droptarget
- virtual void OnPanelEnteredDroppablePanel( CUtlVector< KeyValues * >& msglist );
- virtual void OnPanelExitedDroppablePanel ( CUtlVector< KeyValues * >& msglist );
-
- // Chains up to any parent marked DropEnabled
- virtual Panel *GetDropTarget( CUtlVector< KeyValues * >& msglist );
- // Chains up to first parent marked DragEnabled
- virtual Panel *GetDragPanel();
- virtual bool IsBeingDragged();
- virtual HCursor GetDropCursor( CUtlVector< KeyValues * >& msglist );
-
- Color GetDropFrameColor();
- Color GetDragFrameColor();
-
- // Can override to require custom behavior to start the drag state
- virtual bool CanStartDragging( int startx, int starty, int mx, int my );
-
- // Draws a filled rect of specified bounds, but omits the bounds of the skip panel from those bounds
- virtual void FillRectSkippingPanel( const Color &clr, int x, int y, int w, int h, Panel *skipPanel );
-
- virtual int GetPaintBackgroundType();
- virtual void GetCornerTextureSize( int& w, int& h );
-
- bool IsChildOfModalSubTree();
- bool IsChildOfSurfaceModalPanel();
-
- bool ShouldHandleInputMessage();
-
- virtual void SetSkipChildDuringPainting( Panel *child );
-
- // If this is set, then the drag drop won't occur until the mouse leaves the drag panels current rectangle
- void SetStartDragWhenMouseExitsPanel( bool state );
- bool IsStartDragWhenMouseExitsPanel() const;
-
- void DisableMouseInputForThisPanel( bool bDisable );
- bool IsMouseInputDisabledForThisPanel() const;
-
- bool GetForceStereoRenderToFrameBuffer() const { return m_bForceStereoRenderToFrameBuffer; }
- void SetForceStereoRenderToFrameBuffer( bool bForce ) { m_bForceStereoRenderToFrameBuffer = bForce; }
-
- void PostMessageToAllSiblings( KeyValues *msg, float delaySeconds = 0.0f );
- template< class S >
- void PostMessageToAllSiblingsOfType( KeyValues *msg, float delaySeconds = 0.0f );
-
- void SetConsoleStylePanel( bool bConsoleStyle );
- bool IsConsoleStylePanel() const;
-
- void SetParentNeedsCursorMoveEvents( bool bNeedsEvents ) { m_bParentNeedsCursorMoveEvents = bNeedsEvents; }
- bool ParentNeedsCursorMoveEvents() const { return m_bParentNeedsCursorMoveEvents; }
-
- // For 360: support directional navigation between UI controls via dpad
- enum NAV_DIRECTION { ND_UP, ND_DOWN, ND_LEFT, ND_RIGHT, ND_BACK, ND_NONE };
- virtual Panel* NavigateUp();
- virtual Panel* NavigateDown();
- virtual Panel* NavigateLeft();
- virtual Panel* NavigateRight();
- virtual Panel* NavigateActivate();
- virtual Panel* NavigateBack();
- virtual void NavigateTo();
- virtual void NavigateFrom();
- virtual void NavigateToChild( Panel *pNavigateTo ); //mouse support
- // 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
- inline void SetWorldPositionCurrentFrame( bool bWorldPositionCurrentFrame ) { m_bWorldPositionCurrentFrame = bWorldPositionCurrentFrame; }
- inline bool GetWorldPositionCurrentFrame() { return m_bWorldPositionCurrentFrame; }
-
- Panel* SetNavUp( Panel* navUp );
- Panel* SetNavDown( Panel* navDown );
- Panel* SetNavLeft( Panel* navLeft );
- Panel* SetNavRight( Panel* navRight );
- Panel* SetNavToRelay( Panel* navToRelay );
- Panel* SetNavActivate( Panel* navActivate );
- Panel* SetNavBack( Panel* navBack );
- NAV_DIRECTION GetLastNavDirection();
- MESSAGE_FUNC_CHARPTR( OnNavigateTo, "OnNavigateTo", panelName );
- MESSAGE_FUNC_CHARPTR( OnNavigateFrom, "OnNavigateFrom", panelName );
-
-// Drag Drop protected/internal interface
-protected:
-
- virtual void OnStartDragging();
- virtual void OnContinueDragging();
- virtual void OnFinishDragging( bool mousereleased, MouseCode code, bool aborted = false );
-
- virtual void DragDropStartDragging();
-
- virtual void GetDragData( CUtlVector< KeyValues * >& list );
- virtual void CreateDragData();
-
- virtual void PaintTraverse(bool Repaint, bool allowForce = true);
-
-protected:
- MESSAGE_FUNC_ENUM_ENUM( OnRequestFocus, "OnRequestFocus", VPANEL, subFocus, VPANEL, defaultPanel);
- MESSAGE_FUNC_INT_INT( OnScreenSizeChanged, "OnScreenSizeChanged", oldwide, oldtall );
- virtual void *QueryInterface(EInterfaceID id);
-
- void AddToOverridableColors( Color *pColor, char const *scriptname )
- {
- int iIdx = m_OverridableColorEntries.AddToTail();
- m_OverridableColorEntries[iIdx].m_pszScriptName = scriptname;
- m_OverridableColorEntries[iIdx].m_pColor = pColor;
- m_OverridableColorEntries[iIdx].m_bOverridden = false;
- }
-
- void ApplyOverridableColors( void );
- void SetOverridableColor( Color *pColor, const Color &newColor );
-
-public:
- void SetNavUp( const char* controlName );
- void SetNavDown( const char* controlName );
- void SetNavLeft( const char* controlName );
- void SetNavRight( const char* controlName );
- void SetNavToRelay( const char* controlName );
- void SetNavActivate( const char* controlName );
- void SetNavBack( const char* controlName );
-
- /*
- Will recursively look for the next visible panel in the navigation chain, parameters are for internal use.
- It will stop looking if first == nextpanel (to prevent infinite looping).
- */
- Panel* GetNavUp( Panel *first = NULL );
- Panel* GetNavDown( Panel *first = NULL );
- Panel* GetNavLeft( Panel *first = NULL );
- Panel* GetNavRight( Panel *first = NULL );
- Panel* GetNavToRelay( Panel *first = NULL );
- Panel* GetNavActivate( Panel *first = NULL );
- Panel* GetNavBack( Panel *first = NULL );
-
- const char* GetNavUpName( void ) const { return m_sNavUpName.String(); }
- const char* GetNavDownName( void ) const { return m_sNavDownName.String(); }
- const char* GetNavLeftName( void ) const { return m_sNavLeftName.String(); }
- const char* GetNavRightName( void ) const { return m_sNavRightName.String(); }
- const char* GetNavToRelayName( void ) const { return m_sNavToRelayName.String(); }
- const char* GetNavActivateName( void ) const { return m_sNavActivateName.String(); }
- const char* GetNavBackName( void ) const { return m_sNavBackName.String(); }
-
-protected:
- //this will return m_NavDown and will not look for the next visible panel
- Panel* GetNavUpPanel();
- Panel* GetNavDownPanel();
- Panel* GetNavLeftPanel();
- Panel* GetNavRightPanel();
- Panel* GetNavToRelayPanel();
- Panel* GetNavActivatePanel();
- Panel* GetNavBackPanel();
-
- bool m_PassUnhandledInput;
- NAV_DIRECTION m_LastNavDirection;
-
-private:
- enum BuildModeFlags_t
- {
- BUILDMODE_EDITABLE = 0x01,
- BUILDMODE_DELETABLE = 0x02,
- BUILDMODE_SAVE_XPOS_RIGHTALIGNED = 0x04,
- BUILDMODE_SAVE_XPOS_CENTERALIGNED = 0x08,
- BUILDMODE_SAVE_YPOS_BOTTOMALIGNED = 0x10,
- BUILDMODE_SAVE_YPOS_CENTERALIGNED = 0x20,
- BUILDMODE_SAVE_WIDE_FULL = 0x40,
- BUILDMODE_SAVE_TALL_FULL = 0x80,
- BUILDMODE_SAVE_PROPORTIONAL_TO_PARENT = 0x100,
- };
-
- enum PanelFlags_t
- {
- MARKED_FOR_DELETION = 0x0001,
- NEEDS_REPAINT = 0x0002,
- PAINT_BORDER_ENABLED = 0x0004,
- PAINT_BACKGROUND_ENABLED = 0x0008,
- PAINT_ENABLED = 0x0010,
- POST_CHILD_PAINT_ENABLED = 0x0020,
- AUTODELETE_ENABLED = 0x0040,
- NEEDS_LAYOUT = 0x0080,
- NEEDS_SCHEME_UPDATE = 0x0100,
- NEEDS_DEFAULT_SETTINGS_APPLIED = 0x0200,
-#if defined( VGUI_USEKEYBINDINGMAPS )
- ALLOW_CHAIN_KEYBINDING_TO_PARENT = 0x0400,
-#endif
- IN_PERFORM_LAYOUT = 0x0800,
- IS_PROPORTIONAL = 0x1000,
- TRIPLE_PRESS_ALLOWED = 0x2000,
- DRAG_REQUIRES_PANEL_EXIT = 0x4000,
- IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY = 0x8000,
- ALL_FLAGS = 0xFFFF,
- };
-
- // used to get the Panel * for users with only IClientPanel
- virtual Panel *GetPanel() { return this; }
-
- // private methods
- void Think();
- void PerformApplySchemeSettings();
-
- void InternalPerformLayout();
- void InternalSetCursor();
-
- MESSAGE_FUNC_INT_INT( InternalCursorMoved, "CursorMoved", xpos, ypos );
- MESSAGE_FUNC( InternalCursorEntered, "CursorEntered" );
- MESSAGE_FUNC( InternalCursorExited, "CursorExited" );
-
- MESSAGE_FUNC_INT( InternalMousePressed, "MousePressed", code );
- MESSAGE_FUNC_INT( InternalMouseDoublePressed, "MouseDoublePressed", code );
- // Triple presses are synthesized
- MESSAGE_FUNC_INT( InternalMouseTriplePressed, "MouseTriplePressed", code );
- MESSAGE_FUNC_INT( InternalMouseReleased, "MouseReleased", code );
- MESSAGE_FUNC_INT( InternalMouseWheeled, "MouseWheeled", delta );
- MESSAGE_FUNC_INT( InternalKeyCodePressed, "KeyCodePressed", code );
- MESSAGE_FUNC_INT( InternalKeyCodeTyped, "KeyCodeTyped", code );
- MESSAGE_FUNC_INT( InternalKeyTyped, "KeyTyped", unichar );
- MESSAGE_FUNC_INT( InternalKeyCodeReleased, "KeyCodeReleased", code );
-
- MESSAGE_FUNC( InternalKeyFocusTicked, "KeyFocusTicked" );
- MESSAGE_FUNC( InternalMouseFocusTicked, "MouseFocusTicked" );
-
- MESSAGE_FUNC( InternalInvalidateLayout, "Invalidate" );
-
- MESSAGE_FUNC( InternalMove, "Move" );
- virtual void InternalFocusChanged(bool lost); // called when the focus gets changed
-
- void PreparePanelMap( PanelMap_t *panelMap );
-
- bool InternalRequestInfo( PanelAnimationMap *map, KeyValues *outputData );
- bool InternalSetInfo( PanelAnimationMap *map, KeyValues *inputData );
-
- PanelAnimationMapEntry *FindPanelAnimationEntry( char const *scriptname, PanelAnimationMap *map );
-
- // Recursively invoke settings for PanelAnimationVars
- void InternalApplySettings( PanelAnimationMap *map, KeyValues *inResourceData);
- void InternalInitDefaultValues( PanelAnimationMap *map );
-
- // Purpose: Loads panel details related to autoresize from the resource info
- void ApplyAutoResizeSettings(KeyValues *inResourceData);
-
- void FindDropTargetPanel_R( CUtlVector< VPANEL >& panelList, int x, int y, VPANEL check );
- Panel *FindDropTargetPanel();
-
- int GetProportionalScaledValue( int rootTall, int normalizedValue );
-
-#if defined( VGUI_USEDRAGDROP )
- DragDrop_t *m_pDragDrop;
- Color m_clrDragFrame;
- Color m_clrDropFrame;
-#endif
-
- BaseTooltip *m_pTooltips;
- bool m_bToolTipOverridden;
-
- PHandle m_SkipChild;
- long m_lLastDoublePressTime;
- HFont m_infoFont;
-
-#if defined( VGUI_USEKEYBINDINGMAPS )
- KeyBindingContextHandle_t m_hKeyBindingsContext;
-#endif
-
- // data
- VPANEL _vpanel; // handle to a vgui panel
- char *_panelName; // string name of the panel - only unique within the current context
- IBorder *_border;
-
- CUtlFlags< unsigned short > _flags; // see PanelFlags_t
- Dar<HPanel> _actionSignalTargetDar; // the panel to direct notify messages to ("Command", "TextChanged", etc.)
-
- CUtlVector<OverridableColorEntry> m_OverridableColorEntries;
-
- Color _fgColor; // foreground color
- Color _bgColor; // background color
-
- HBuildGroup _buildGroup;
-
- short m_nPinDeltaX; // Relative position of the pinned corner to the edge
- short m_nPinDeltaY;
- short m_nResizeDeltaX; // Relative position of the non-pinned corner to the edge
- short m_nResizeDeltaY;
-
- HCursor _cursor;
- unsigned short _buildModeFlags; // flags that control how the build mode dialog handles this panel
-
- byte _pinCorner : 4; // the corner of the dialog this panel is pinned to
- byte _autoResizeDirection : 4; // the directions in which the panel will auto-resize to
-
- unsigned char _tabPosition; // the panel's place in the tab ordering
- HScheme m_iScheme; // handle to the scheme to use
-
- bool m_bIsDMXSerialized : 1; // Is this a DMX panel?
- bool m_bUseSchemeColors : 1; // Should we use colors from the scheme?
- bool m_bIsSilent : 1; // should this panel PostActionSignals?
- bool m_bIsConsoleStylePanel : 1;
- bool m_bParentNeedsCursorMoveEvents : 1;
-
- // Sibling pinning
- char *_pinToSibling; // string name of the sibling panel we're pinned to
- byte _pinToSiblingCorner; // the corner of the sibling panel we're pinned to
- byte _pinCornerToSibling; // the corner of our panel that we're pinning to our sibling
- PHandle m_pinSibling;
-
- CUtlString m_sNavUpName;
- PHandle m_NavUp;
-
- CUtlString m_sNavDownName;
- PHandle m_NavDown;
-
- CUtlString m_sNavLeftName;
- PHandle m_NavLeft;
-
- CUtlString m_sNavRightName;
- PHandle m_NavRight;
-
- CUtlString m_sNavToRelayName;
- PHandle m_NavToRelay;
-
- CUtlString m_sNavActivateName;
- PHandle m_NavActivate;
-
- CUtlString m_sNavBackName;
- PHandle m_NavBack;
-
-private:
-
- char *_tooltipText; // Tool tip text for panels that share tooltip panels with other panels
-
- PHandle m_hMouseEventHandler;
-
- 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
-
- bool m_bForceStereoRenderToFrameBuffer;
-
- CPanelAnimationVar( float, m_flAlpha, "alpha", "255" );
-
- // 1 == Textured (TextureId1 only)
- // 2 == Rounded Corner Box
- CPanelAnimationVar( int, m_nPaintBackgroundType, "PaintBackgroundType", "0" );
- CPanelAnimationVarAliasType( int, m_nBgTextureId1, "Texture1", "vgui/hud/800corner1", "textureid" );
- CPanelAnimationVarAliasType( int, m_nBgTextureId2, "Texture2", "vgui/hud/800corner2", "textureid" );
- CPanelAnimationVarAliasType( int, m_nBgTextureId3, "Texture3", "vgui/hud/800corner3", "textureid" );
- CPanelAnimationVarAliasType( int, m_nBgTextureId4, "Texture4", "vgui/hud/800corner4", "textureid" );
-
- //=============================================================================
- // HPE_BEGIN:
- // [tj] A bitset of flags to determine which corners should be rounded
- //=============================================================================
- unsigned char m_roundedCorners;
- //=============================================================================
- // HPE_END
- //=============================================================================
- friend class BuildGroup;
- friend class BuildModeDialog;
- friend class PHandle;
-
- // obselete, remove soon
- void OnOldMessage(KeyValues *params, VPANEL ifromPanel);
-};
-
-inline void Panel::DisableMouseInputForThisPanel( bool bDisable )
-{
- _flags.SetFlag( IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY, bDisable );
-}
-
-inline bool Panel::IsMouseInputDisabledForThisPanel() const
-{
- return _flags.IsFlagSet( IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY );
-}
-
-#if 0
-// This function cannot be defined here because it requires on a full definition of
-// KeyValues (to call KeyValues::MakeCopy()) whereas the rest of this header file
-// assumes a forward declared definition of KeyValues.
-template< class S >
-inline void Panel::PostMessageToAllSiblingsOfType( KeyValues *msg, float delaySeconds /*= 0.0f*/ )
-{
- Panel *parent = GetParent();
- if ( parent )
- {
- int nChildCount = parent->GetChildCount();
- for ( int i = 0; i < nChildCount; ++i )
- {
- Panel *sibling = parent->GetChild( i );
- if ( sibling == this )
- continue;
- if ( dynamic_cast< S * >( sibling ) )
- {
- PostMessage( sibling->GetVPanel(), msg->MakeCopy(), delaySeconds );
- }
- }
- }
-
- msg->deleteThis();
-}
-#endif
-
-class Button;
-
-struct SortedPanel_t
-{
- SortedPanel_t( Panel *panel );
-
- Panel *pPanel;
- Button *pButton;
-};
-
-class CSortedPanelYLess
-{
-public:
- bool Less( const SortedPanel_t &src1, const SortedPanel_t &src2, void *pCtx )
- {
- int nX1, nY1, nX2, nY2;
- src1.pPanel->GetPos( nX1, nY1 );
- src2.pPanel->GetPos( nX2, nY2 );
-
- if ( nY1 == nY2 )
- {
- return ( nX1 < nX2 );
- }
-
- if ( nY1 < nY2 )
- {
- return true;
- }
-
- return false;
- }
-};
-
-
-void VguiPanelGetSortedChildPanelList( Panel *pParentPanel, void *pSortedPanels );
-void VguiPanelGetSortedChildButtonList( Panel *pParentPanel, void *pSortedPanels, char *pchFilter = NULL, int nFilterType = 0 );
-int VguiPanelNavigateSortedChildButtonList( void *pSortedPanels, int nDir );
-
-
-} // namespace vgui
-
-
-#endif // PANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef PANEL_H +#define PANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlflags.h" +#include "vgui/VGUI.h" +#include "vgui/Dar.h" +#include "vgui_controls/MessageMap.h" +#if defined( VGUI_USEKEYBINDINGMAPS ) +#include "vgui_controls/KeyBindingMap.h" +#endif +#include "vgui/IClientPanel.h" +#include "vgui/IScheme.h" +#include "vgui_controls/Controls.h" +#include "vgui_controls/PHandle.h" +#include "vgui_controls/PanelAnimationVar.h" +#include "Color.h" +#include "vstdlib/IKeyValuesSystem.h" +#include "tier1/utlsymbol.h" +#include "vgui_controls/BuildGroup.h" + +// undefine windows function macros that overlap +#ifdef PostMessage +#undef PostMessage +#endif + +#ifdef SetCursor +#undef SetCursor +#endif + +class CUtlBuffer; + +namespace vgui +{ + +#if !defined( _X360 ) +#define VGUI_USEDRAGDROP 1 +#endif + +#if defined( VGUI_USEKEYBINDINGMAPS ) +struct PanelKeyBindingMap; +#endif +//----------------------------------------------------------------------------- +// Purpose: Helper functions to construct vgui panels +// +// SETUP_PANEL - will make a panel ready for use right now (i.e setup its colors, borders, fonts, etc) +// +template< class T > +inline T *SETUP_PANEL(T *panel) +{ + panel->MakeReadyForUse(); + return panel; +} + +// +// CREATE_PANEL - creates a panel that is ready to use right now +// +// 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) +// +#define CREATE_PANEL(type, parent, name) (SETUP_PANEL(new type(parent, name))) + +//----------------------------------------------------------------------------- +// Purpose: Drag/drop support context info (could defined within Panel...) +//----------------------------------------------------------------------------- +#if defined( VGUI_USEDRAGDROP ) +struct DragDrop_t; +class Menu; +#endif + +//----------------------------------------------------------------------------- +// Purpose: Macro to handle Colors that can be overridden in .res files +//----------------------------------------------------------------------------- +struct OverridableColorEntry +{ + char const *name() { return m_pszScriptName; } + + char const *m_pszScriptName; + Color *m_pColor; + Color m_colFromScript; + bool m_bOverridden; +}; + +#define REGISTER_COLOR_AS_OVERRIDABLE( name, scriptname ) \ + AddToOverridableColors( &name, scriptname ); + + + +//----------------------------------------------------------------------------- +// Purpose: For hudanimations.txt scripting of vars +//----------------------------------------------------------------------------- +class IPanelAnimationPropertyConverter +{ +public: + virtual void GetData( Panel *panel, KeyValues *kv, PanelAnimationMapEntry *entry ) = 0; + virtual void SetData( Panel *panel, KeyValues *kv, PanelAnimationMapEntry *entry ) = 0; + virtual void InitFromDefault( Panel *panel, PanelAnimationMapEntry *entry ) = 0; +}; + +#if defined( VGUI_USEKEYBINDINGMAPS ) +enum KeyBindingContextHandle_t +{ + INVALID_KEYBINDINGCONTEXT_HANDLE = 0xffffffff, +}; +#endif + +class IForceVirtualInheritancePanel +{ + // We need Panel to use virtual inheritance so that + // pointers to its members are max size. + // This is due to a limitation in C++ with ahead + // declarations of points to members as used in MessageMap. +}; + +//============================================================================= +// HPE_BEGIN: +// [tj] bitwise defines for rounded corners +//============================================================================= +#define PANEL_ROUND_CORNER_TOP_LEFT (1 << 0) +#define PANEL_ROUND_CORNER_TOP_RIGHT (1 << 1) +#define PANEL_ROUND_CORNER_BOTTOM_LEFT (1 << 2) +#define PANEL_ROUND_CORNER_BOTTOM_RIGHT (1 << 3) +#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 +//============================================================================= +// HPE_END +//=============================================================================//----------------------------------------------------------------------------- +// Purpose: Base interface to all vgui windows +// All vgui controls that receive message and/or have a physical presence +// on screen are be derived from Panel. +// This is designed as an easy-access to the vgui-functionality; for more +// low-level access to vgui functions use the IPanel/IClientPanel interfaces directly +//----------------------------------------------------------------------------- +class Panel : public IClientPanel, virtual IForceVirtualInheritancePanel +{ + DECLARE_CLASS_SIMPLE_NOBASE( Panel ); + +public: + // For property mapping + static void InitPropertyConverters( void ); + static void AddPropertyConverter( char const *typeName, IPanelAnimationPropertyConverter *converter ); + + //----------------------------------------------------------------------------- + // CONSTRUCTORS + // these functions deal with the creation of the Panel + // the Panel automatically gets a handle to a vgui-internal panel, the ipanel(), upon construction + // vgui interfaces deal only with ipanel(), not Panel directly + Panel(); + Panel(Panel *parent); + Panel(Panel *parent, const char *panelName); + Panel(Panel *parent, const char *panelName, HScheme scheme); + + virtual ~Panel(); + + // returns pointer to Panel's vgui VPanel interface handle + virtual VPANEL GetVPanel() { return _vpanel; } + HPanel ToHandle() const; + + virtual void Init( int x, int y, int wide, int tall ); + + //----------------------------------------------------------------------------- + // PANEL METHODS + // these functions all manipulate panels + // they cannot be derived from + void SetName(const char *panelName); // sets the name of the panel - used as an identifier + const char *GetName(); // returns the name of this panel... never NULL + const char *GetClassName(); // returns the class name of the panel (eg. Panel, Label, Button, etc.) + + void MakeReadyForUse(); // fully construct this panel so its ready for use right now (i.e fonts loaded, colors set, default label text set, ...) + + // panel position & size + // all units are in pixels + void SetPos(int x,int y); // sets position of panel, in local space (ie. relative to parent's position) + void GetPos(int &x,int &y); // gets local position of panel + void SetSize(int wide,int tall); // sets size of panel + void GetSize(int &wide, int &tall); // gets size of panel + void SetBounds(int x, int y, int wide, int tall); // combination of SetPos/SetSize + void GetBounds(int &x, int &y, int &wide, int &tall); // combination of GetPos/GetSize + int GetWide(); // returns width of panel + void SetWide(int wide); // sets width of panel + int GetTall(); // returns height of panel + void SetTall(int tall); // sets height of panel + void SetMinimumSize(int wide,int tall); // sets the minimum size the panel can go + void GetMinimumSize(int& wide,int& tall); // gets the minimum size + bool IsBuildModeEditable(); // editable in the buildModeDialog? + void SetBuildModeEditable(bool state); // set buildModeDialog editable + bool IsBuildModeDeletable(); // deletable in the buildModeDialog? + void SetBuildModeDeletable(bool state); // set buildModeDialog deletable + bool IsBuildModeActive(); // true if we're currently in edit mode + void SetZPos(int z); // sets Z ordering - lower numbers are always behind higher z's + int GetZPos( void ); + void SetAlpha(int alpha); // sets alpha modifier for panel and all child panels [0..255] + int GetAlpha(); // returns the current alpha + + // panel visibility + // invisible panels and their children do not drawn, updated, or receive input messages + virtual void SetVisible(bool state); + virtual bool IsVisible(); + + // painting + virtual VPANEL IsWithinTraverse(int x, int y, bool traversePopups); // recursive; returns a pointer to the panel at those coordinates + MESSAGE_FUNC( Repaint, "Repaint" ); // marks the panel as needing to be repainted + virtual void PostMessage(VPANEL target, KeyValues *message, float delaySeconds = 0.0f); + + bool IsWithin(int x, int y); //in screen space + void LocalToScreen(int &x, int &y); + void ScreenToLocal(int &x, int &y); + void ParentLocalToScreen(int &x, int &y); + void MakePopup(bool showTaskbarIcon = true,bool disabled = false); // turns the panel into a popup window (ie. can draw outside of it's parents space) + virtual void OnMove(); + + // panel hierarchy + virtual Panel *GetParent(); + virtual VPANEL GetVParent(); + virtual void SetParent(Panel *newParent); + virtual void SetParent(VPANEL newParent); + virtual bool HasParent(VPANEL potentialParent); + + int GetChildCount(); + Panel *GetChild(int index); + virtual CUtlVector< VPANEL > &GetChildren(); + int FindChildIndexByName( const char *childName ); + Panel *FindChildByName(const char *childName, bool recurseDown = false); + Panel *FindSiblingByName(const char *siblingName); + void CallParentFunction(KeyValues *message); + + template <class T> + T *FindControl( const char *pszName, bool recurseDown = false ) { return dynamic_cast<T *>( FindChildByName( pszName, recurseDown ) ); } + + virtual void SetAutoDelete(bool state); // if set to true, panel automatically frees itself when parent is deleted + virtual bool IsAutoDeleteSet(); + virtual void DeletePanel(); // simply does a { delete this; } + + // messaging + virtual void AddActionSignalTarget(Panel *messageTarget); + virtual void AddActionSignalTarget(VPANEL messageTarget); + virtual void RemoveActionSignalTarget(Panel *oldTarget); + virtual void PostActionSignal(KeyValues *message); // sends a message to the current actionSignalTarget(s) + virtual bool RequestInfoFromChild(const char *childName, KeyValues *outputData); + virtual void PostMessageToChild(const char *childName, KeyValues *messsage); + virtual void PostMessage(Panel *target, KeyValues *message, float delaySeconds = 0.0f); + 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 + virtual bool SetInfo(KeyValues *inputData); // sets a specified value in the control - inverse of the above + virtual void SetSilentMode( bool bSilent ); //change the panel's silent mode; if silent, the panel will not post any action signals + + // install a mouse handler + virtual void InstallMouseHandler( Panel *pHandler ); // mouse events will be send to handler panel instead of this panel + + // drawing state + virtual void SetEnabled(bool state); + virtual bool IsEnabled(); + virtual bool IsPopup(); // has a parent, but is in it's own space + virtual void GetClipRect(int &x0, int &y0, int &x1, int &y1); + virtual void MoveToFront(); + + // pin positions for auto-layout + enum PinCorner_e + { + PIN_TOPLEFT = 0, + PIN_TOPRIGHT, + PIN_BOTTOMLEFT, + PIN_BOTTOMRIGHT, + + // For sibling pinning + PIN_CENTER_TOP, + PIN_CENTER_RIGHT, + PIN_CENTER_BOTTOM, + PIN_CENTER_LEFT, + }; + + // specifies the auto-resize directions for the panel + enum AutoResize_e + { + AUTORESIZE_NO = 0, + AUTORESIZE_RIGHT, + AUTORESIZE_DOWN, + AUTORESIZE_DOWNANDRIGHT, + }; + + // Sets the pin corner for non-resizing panels + void SetPinCorner( PinCorner_e pinCorner, int nOffsetX, int nOffsetY ); + + // Sets the pin corner + resize mode for resizing panels + void SetAutoResize( PinCorner_e pinCorner, AutoResize_e resizeDir, int nPinOffsetX, int nPinOffsetY, int nUnpinnedCornerOffsetX, int nUnpinnedCornerOffsetY ); + + AutoResize_e GetAutoResize(); + PinCorner_e GetPinCorner(); + + // Gets the relative offset of the control from the pinned + non-pinned corner (for resizing) + void GetPinOffset( int &dx, int &dy ); + void GetResizeOffset( int &dx, int &dy ); + + void PinToSibling( const char *pszSibling, PinCorner_e pinOurCorner, PinCorner_e pinSibling ); + void UpdateSiblingPin( void ); + + // colors + virtual void SetBgColor(Color color); + virtual void SetFgColor(Color color); + virtual Color GetBgColor(); + virtual Color GetFgColor(); + + virtual void SetCursor(HCursor cursor); + virtual HCursor GetCursor(); + virtual void SetCursorAlwaysVisible( bool visible ); + virtual void RequestFocus(int direction = 0); + virtual bool HasFocus(); + virtual void InvalidateLayout(bool layoutNow = false, bool reloadScheme = false); + virtual bool RequestFocusPrev(VPANEL panel = NULL); + virtual bool RequestFocusNext(VPANEL panel = NULL); + // tab positioning + virtual void SetTabPosition(int position); + virtual int GetTabPosition(); + // border + virtual void SetBorder(IBorder *border); + virtual IBorder *GetBorder(); + virtual void SetPaintBorderEnabled(bool state); + virtual void SetPaintBackgroundEnabled(bool state); + virtual void SetPaintEnabled(bool state); + virtual void SetPostChildPaintEnabled(bool state); + virtual void SetPaintBackgroundType(int type); // 0 for normal(opaque), 1 for single texture from Texture1, and 2 for rounded box w/ four corner textures + virtual void GetInset(int &left, int &top, int &right, int &bottom); + virtual void GetPaintSize(int &wide, int &tall); + virtual void SetBuildGroup(BuildGroup *buildGroup); + virtual bool IsBuildGroupEnabled(); + virtual bool IsCursorNone(); + virtual bool IsCursorOver(); // returns true if the cursor is currently over the panel + virtual void MarkForDeletion(); // object will free it's memory next tick + virtual bool IsLayoutInvalid(); // does this object require a perform layout? + virtual Panel *HasHotkey(wchar_t key); // returns the panel that has this hotkey + virtual bool IsOpaque(); + bool IsRightAligned(); // returns true if the settings are aligned to the right of the screen + bool IsBottomAligned(); // returns true if the settings are aligned to the bottom of the screen + + // scheme access functions + virtual HScheme GetScheme(); + virtual void SetScheme(const char *tag); + virtual void SetScheme(HScheme scheme); + virtual Color GetSchemeColor(const char *keyName,IScheme *pScheme); + virtual Color GetSchemeColor(const char *keyName, Color defaultColor,IScheme *pScheme); + + // called when scheme settings need to be applied; called the first time before the panel is painted + virtual void ApplySchemeSettings(IScheme *pScheme); + + // interface to build settings + // takes a group of settings and applies them to the control + virtual void ApplySettings(KeyValues *inResourceData); + + // records the settings into the resource data + virtual void GetSettings(KeyValues *outResourceData); + + // gets a description of the resource for use in the UI + // format: <type><whitespace | punctuation><keyname><whitespace| punctuation><type><whitespace | punctuation><keyname>... + // unknown types as just displayed as strings in the UI (for future UI expansion) + virtual const char *GetDescription(); + + // returns the name of the module that this instance of panel was compiled into + virtual const char *GetModuleName(); + + // user configuration settings + // this is used for any control details the user wants saved between sessions + // eg. dialog positions, last directory opened, list column width + virtual void ApplyUserConfigSettings(KeyValues *userConfig); + + // returns user config settings for this control + virtual void GetUserConfigSettings(KeyValues *userConfig); + + // optimization, return true if this control has any user config settings + virtual bool HasUserConfigSettings(); + + // message handlers + // override to get access to the message + // override to get access to the message + virtual void OnMessage(const KeyValues *params, VPANEL fromPanel); // called when panel receives message; must chain back + MESSAGE_FUNC_CHARPTR( OnCommand, "Command", command ); // called when a panel receives a command + MESSAGE_FUNC( OnMouseCaptureLost, "MouseCaptureLost" ); // called after the panel loses mouse capture + MESSAGE_FUNC( OnSetFocus, "SetFocus" ); // called after the panel receives the keyboard focus + MESSAGE_FUNC( OnKillFocus, "KillFocus" ); // called after the panel loses the keyboard focus + MESSAGE_FUNC( OnDelete, "Delete" ); // called to delete the panel; Panel::OnDelete() does simply { delete this; } + virtual void OnThink(); // called every frame before painting, but only if panel is visible + virtual void OnChildAdded(VPANEL child); // called when a child has been added to this panel + virtual void OnSizeChanged(int newWide, int newTall); // called after the size of a panel has been changed + + // called every frame if ivgui()->AddTickSignal() is called + virtual void OnTick(); + + // input messages + MESSAGE_FUNC_INT_INT( OnCursorMoved, "OnCursorMoved", x, y ); + virtual void OnCursorEntered(); + virtual void OnCursorExited(); + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); + virtual void OnMouseWheeled(int delta); + + // Trip pressing (e.g., select all text in a TextEntry) requires this to be enabled + virtual void SetTriplePressAllowed( bool state ); + virtual bool IsTriplePressAllowed() const; + virtual void OnMouseTriplePressed( MouseCode code ); + + static char const *KeyCodeToString( KeyCode code ); + static wchar_t const *KeyCodeToDisplayString( KeyCode code ); + static wchar_t const *KeyCodeModifiersToDisplayString( KeyCode code, int modifiers ); // L"Ctrl+Alt+Shift+Backspace" + + static KeyCode StringToKeyCode( char const *str ); +#if defined( VGUI_USEKEYBINDINGMAPS ) + static KeyBindingContextHandle_t CreateKeyBindingsContext( char const *filename, char const *pathID = 0 ); + virtual void SetKeyBindingsContext( KeyBindingContextHandle_t handle ); + virtual KeyBindingContextHandle_t GetKeyBindingsContext() const; + virtual bool IsValidKeyBindingsContext() const; + + static int GetPanelsWithKeyBindingsCount( KeyBindingContextHandle_t handle ); + static Panel *GetPanelWithKeyBindings( KeyBindingContextHandle_t handle, int index ); + + static void RevertKeyBindings( KeyBindingContextHandle_t handle ); + + static void ReloadKeyBindings( KeyBindingContextHandle_t handle ); + static void SaveKeyBindings( KeyBindingContextHandle_t handle ); + static void SaveKeyBindingsToFile( KeyBindingContextHandle_t handle, char const *filename, char const *pathID = 0 ); + static void LoadKeyBindings( KeyBindingContextHandle_t handle ); + static void LoadKeyBindingsForOnePanel( KeyBindingContextHandle_t handle, Panel *panelOfInterest ); + + // OnKeyCodeTyped hooks into here for action + virtual bool IsKeyRebound( KeyCode code, int modifiers ); + // If a panel implements this and returns true, then the IsKeyRebound check will fail and OnKeyCodeTyped messages will pass through.. + // sort of like setting the SetAllowKeyBindingChainToParent flag to false for specific keys + virtual bool IsKeyOverridden( KeyCode code, int modifiers ); + + virtual void AddKeyBinding( char const *bindingName, int keycode, int modifiers ); + + KeyBindingMap_t *LookupBinding( char const *bindingName ); + KeyBindingMap_t *LookupBindingByKeyCode( KeyCode code, int modifiers ); + void LookupBoundKeys( char const *bindingName, CUtlVector< BoundKey_t * >& list ); + BoundKey_t *LookupDefaultKey( char const *bindingName ); + PanelKeyBindingMap *LookupMapForBinding( char const *bindingName ); + + // Returns the number of keybindings + int GetKeyMappingCount( ); + + void RevertKeyBindingsToDefault(); + void RemoveAllKeyBindings(); + void ReloadKeyBindings(); + virtual void EditKeyBindings(); + + // calls RevertKeyBindingsToDefault() and then LoadKeyBindingsForOnePanel( GetKeyBindingsContext(), this ); + void SaveKeyBindingsToBuffer( int level, CUtlBuffer& buf ); + bool ParseKeyBindings( KeyValues *kv ); + + virtual char const *GetKeyBindingsFile() const; + virtual char const *GetKeyBindingsFilePathID() const; + + // Set this to false to disallow IsKeyRebound chaining to GetParent() Panels... + void SetAllowKeyBindingChainToParent( bool state ); + bool IsKeyBindingChainToParentAllowed() const; +#endif // VGUI_USEKEYBINDINGMAPS + + // base implementation forwards Key messages to the Panel's parent + // - override to 'swallow' the input + virtual void OnKeyCodePressed(KeyCode code); + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnKeyTyped(wchar_t unichar); + virtual void OnKeyCodeReleased(KeyCode code); + virtual void OnKeyFocusTicked(); // every window gets key ticked events + + // forwards mouse messages to the panel's parent + MESSAGE_FUNC( OnMouseFocusTicked, "OnMouseFocusTicked" ); + + // message handlers that don't go through the message pump + virtual void PaintBackground(); + virtual void Paint(); + virtual void PaintBorder(); + virtual void PaintBuildOverlay(); // the extra drawing for when in build mode + virtual void PostChildPaint(); + virtual void PerformLayout(); + + // this enables message mapping for this class - requires matching IMPLEMENT_PANELDESC() in the .cpp file + DECLARE_PANELMAP(); + + virtual VPANEL GetCurrentKeyFocus(); + + // returns a pointer to the tooltip object associated with the panel + // creates a new one if none yet exists + BaseTooltip *GetTooltip(); + void SetTooltip( BaseTooltip *pToolTip, const char *pszText ); + + /// Returns the effective tooltip text to use, whether stored + /// locally in this panel, or in the tooltip object. Returns + /// an empty string if no tooltip text + const char *GetEffectiveTooltipText() const; + + // proportional mode settings + virtual bool IsProportional() { return _flags.IsFlagSet( IS_PROPORTIONAL ); } + virtual void SetProportional(bool state); + + // input interest + virtual void SetMouseInputEnabled( bool state ); + virtual void SetKeyBoardInputEnabled( bool state ); + virtual bool IsMouseInputEnabled(); + virtual bool IsKeyBoardInputEnabled(); + + virtual void DrawTexturedBox( int x, int y, int wide, int tall, Color color, float normalizedAlpha ); + virtual void DrawBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha, bool hollow = false ); + 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 ); + virtual void DrawHollowBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha ); + //============================================================================= + // HPE_BEGIN: + //============================================================================= + + // [menglish] Draws a hollow box similar to the already existing draw hollow box function, but takes the indents as params + virtual void DrawHollowBox( int x, int y, int wide, int tall, Color color, float normalizedAlpha, int cornerWide, int cornerTall ); + + // [tj] Simple getters and setters to decide which corners to draw rounded + unsigned char GetRoundedCorners() { return m_roundedCorners; } + void SetRoundedCorners (unsigned char cornerFlags) { m_roundedCorners = cornerFlags; } + bool ShouldDrawTopLeftCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_TOP_LEFT ) != 0; } + bool ShouldDrawTopRightCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_TOP_RIGHT ) != 0; } + bool ShouldDrawBottomLeftCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_LEFT ) != 0; } + bool ShouldDrawBottomRightCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_RIGHT ) != 0; } + + //============================================================================= + // HPE_END + //============================================================================= + +// Drag Drop Public interface + + virtual void SetDragEnabled( bool enabled ); + virtual bool IsDragEnabled() const; + + virtual void SetShowDragHelper( bool enabled ); + + // Called if drag drop is started but not dropped on top of droppable panel... + virtual void OnDragFailed( CUtlVector< KeyValues * >& msglist ); + + // 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 + // draggable parent. + virtual void SetBlockDragChaining( bool block ); + virtual bool IsBlockingDragChaining() const; + + virtual int GetDragStartTolerance() const; + virtual void SetDragSTartTolerance( int nTolerance ); + + // If hover context time is non-zero, then after the drop cursor is hovering over the panel for that amount of time + // the Show hover context menu function will be invoked + virtual void SetDropEnabled( bool enabled, float m_flHoverContextTime = 0.0f ); + virtual bool IsDropEnabled() const; + + // Called if m_flHoverContextTime was non-zero, allows droppee to preview the drop data and show an appropriate menu + // Return false if not using context menu + virtual bool GetDropContextMenu( Menu *menu, CUtlVector< KeyValues * >& msglist ); + virtual void OnDropContextHoverShow( CUtlVector< KeyValues * >& msglist ); + virtual void OnDropContextHoverHide( CUtlVector< KeyValues * >& msglist ); + +#if defined( VGUI_USEDRAGDROP ) + virtual DragDrop_t *GetDragDropInfo(); +#endif + // For handling multiple selections... + virtual void OnGetAdditionalDragPanels( CUtlVector< Panel * >& dragabbles ); + + virtual void OnCreateDragData( KeyValues *msg ); + // Called to see if a drop enabled panel can accept the specified data blob + virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist ); + + // Mouse is on draggable panel and has started moving, but is not over a droppable panel yet + virtual void OnDraggablePanelPaint(); + // Mouse is now over a droppable panel + virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels ); + + virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist ); + + // called on droptarget when draggable panel entered/exited droptarget + virtual void OnPanelEnteredDroppablePanel( CUtlVector< KeyValues * >& msglist ); + virtual void OnPanelExitedDroppablePanel ( CUtlVector< KeyValues * >& msglist ); + + // Chains up to any parent marked DropEnabled + virtual Panel *GetDropTarget( CUtlVector< KeyValues * >& msglist ); + // Chains up to first parent marked DragEnabled + virtual Panel *GetDragPanel(); + virtual bool IsBeingDragged(); + virtual HCursor GetDropCursor( CUtlVector< KeyValues * >& msglist ); + + Color GetDropFrameColor(); + Color GetDragFrameColor(); + + // Can override to require custom behavior to start the drag state + virtual bool CanStartDragging( int startx, int starty, int mx, int my ); + + // Draws a filled rect of specified bounds, but omits the bounds of the skip panel from those bounds + virtual void FillRectSkippingPanel( const Color &clr, int x, int y, int w, int h, Panel *skipPanel ); + + virtual int GetPaintBackgroundType(); + virtual void GetCornerTextureSize( int& w, int& h ); + + bool IsChildOfModalSubTree(); + bool IsChildOfSurfaceModalPanel(); + + bool ShouldHandleInputMessage(); + + virtual void SetSkipChildDuringPainting( Panel *child ); + + // If this is set, then the drag drop won't occur until the mouse leaves the drag panels current rectangle + void SetStartDragWhenMouseExitsPanel( bool state ); + bool IsStartDragWhenMouseExitsPanel() const; + + void DisableMouseInputForThisPanel( bool bDisable ); + bool IsMouseInputDisabledForThisPanel() const; + + bool GetForceStereoRenderToFrameBuffer() const { return m_bForceStereoRenderToFrameBuffer; } + void SetForceStereoRenderToFrameBuffer( bool bForce ) { m_bForceStereoRenderToFrameBuffer = bForce; } + + void PostMessageToAllSiblings( KeyValues *msg, float delaySeconds = 0.0f ); + template< class S > + void PostMessageToAllSiblingsOfType( KeyValues *msg, float delaySeconds = 0.0f ); + + void SetConsoleStylePanel( bool bConsoleStyle ); + bool IsConsoleStylePanel() const; + + void SetParentNeedsCursorMoveEvents( bool bNeedsEvents ) { m_bParentNeedsCursorMoveEvents = bNeedsEvents; } + bool ParentNeedsCursorMoveEvents() const { return m_bParentNeedsCursorMoveEvents; } + + // For 360: support directional navigation between UI controls via dpad + enum NAV_DIRECTION { ND_UP, ND_DOWN, ND_LEFT, ND_RIGHT, ND_BACK, ND_NONE }; + virtual Panel* NavigateUp(); + virtual Panel* NavigateDown(); + virtual Panel* NavigateLeft(); + virtual Panel* NavigateRight(); + virtual Panel* NavigateActivate(); + virtual Panel* NavigateBack(); + virtual void NavigateTo(); + virtual void NavigateFrom(); + virtual void NavigateToChild( Panel *pNavigateTo ); //mouse support + // 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 + inline void SetWorldPositionCurrentFrame( bool bWorldPositionCurrentFrame ) { m_bWorldPositionCurrentFrame = bWorldPositionCurrentFrame; } + inline bool GetWorldPositionCurrentFrame() { return m_bWorldPositionCurrentFrame; } + + Panel* SetNavUp( Panel* navUp ); + Panel* SetNavDown( Panel* navDown ); + Panel* SetNavLeft( Panel* navLeft ); + Panel* SetNavRight( Panel* navRight ); + Panel* SetNavToRelay( Panel* navToRelay ); + Panel* SetNavActivate( Panel* navActivate ); + Panel* SetNavBack( Panel* navBack ); + NAV_DIRECTION GetLastNavDirection(); + MESSAGE_FUNC_CHARPTR( OnNavigateTo, "OnNavigateTo", panelName ); + MESSAGE_FUNC_CHARPTR( OnNavigateFrom, "OnNavigateFrom", panelName ); + +// Drag Drop protected/internal interface +protected: + + virtual void OnStartDragging(); + virtual void OnContinueDragging(); + virtual void OnFinishDragging( bool mousereleased, MouseCode code, bool aborted = false ); + + virtual void DragDropStartDragging(); + + virtual void GetDragData( CUtlVector< KeyValues * >& list ); + virtual void CreateDragData(); + + virtual void PaintTraverse(bool Repaint, bool allowForce = true); + +protected: + MESSAGE_FUNC_ENUM_ENUM( OnRequestFocus, "OnRequestFocus", VPANEL, subFocus, VPANEL, defaultPanel); + MESSAGE_FUNC_INT_INT( OnScreenSizeChanged, "OnScreenSizeChanged", oldwide, oldtall ); + virtual void *QueryInterface(EInterfaceID id); + + void AddToOverridableColors( Color *pColor, char const *scriptname ) + { + int iIdx = m_OverridableColorEntries.AddToTail(); + m_OverridableColorEntries[iIdx].m_pszScriptName = scriptname; + m_OverridableColorEntries[iIdx].m_pColor = pColor; + m_OverridableColorEntries[iIdx].m_bOverridden = false; + } + + void ApplyOverridableColors( void ); + void SetOverridableColor( Color *pColor, const Color &newColor ); + +public: + void SetNavUp( const char* controlName ); + void SetNavDown( const char* controlName ); + void SetNavLeft( const char* controlName ); + void SetNavRight( const char* controlName ); + void SetNavToRelay( const char* controlName ); + void SetNavActivate( const char* controlName ); + void SetNavBack( const char* controlName ); + + /* + Will recursively look for the next visible panel in the navigation chain, parameters are for internal use. + It will stop looking if first == nextpanel (to prevent infinite looping). + */ + Panel* GetNavUp( Panel *first = NULL ); + Panel* GetNavDown( Panel *first = NULL ); + Panel* GetNavLeft( Panel *first = NULL ); + Panel* GetNavRight( Panel *first = NULL ); + Panel* GetNavToRelay( Panel *first = NULL ); + Panel* GetNavActivate( Panel *first = NULL ); + Panel* GetNavBack( Panel *first = NULL ); + + const char* GetNavUpName( void ) const { return m_sNavUpName.String(); } + const char* GetNavDownName( void ) const { return m_sNavDownName.String(); } + const char* GetNavLeftName( void ) const { return m_sNavLeftName.String(); } + const char* GetNavRightName( void ) const { return m_sNavRightName.String(); } + const char* GetNavToRelayName( void ) const { return m_sNavToRelayName.String(); } + const char* GetNavActivateName( void ) const { return m_sNavActivateName.String(); } + const char* GetNavBackName( void ) const { return m_sNavBackName.String(); } + +protected: + //this will return m_NavDown and will not look for the next visible panel + Panel* GetNavUpPanel(); + Panel* GetNavDownPanel(); + Panel* GetNavLeftPanel(); + Panel* GetNavRightPanel(); + Panel* GetNavToRelayPanel(); + Panel* GetNavActivatePanel(); + Panel* GetNavBackPanel(); + + bool m_PassUnhandledInput; + NAV_DIRECTION m_LastNavDirection; + +private: + enum BuildModeFlags_t + { + BUILDMODE_EDITABLE = 0x01, + BUILDMODE_DELETABLE = 0x02, + BUILDMODE_SAVE_XPOS_RIGHTALIGNED = 0x04, + BUILDMODE_SAVE_XPOS_CENTERALIGNED = 0x08, + BUILDMODE_SAVE_YPOS_BOTTOMALIGNED = 0x10, + BUILDMODE_SAVE_YPOS_CENTERALIGNED = 0x20, + BUILDMODE_SAVE_WIDE_FULL = 0x40, + BUILDMODE_SAVE_TALL_FULL = 0x80, + BUILDMODE_SAVE_PROPORTIONAL_TO_PARENT = 0x100, + }; + + enum PanelFlags_t + { + MARKED_FOR_DELETION = 0x0001, + NEEDS_REPAINT = 0x0002, + PAINT_BORDER_ENABLED = 0x0004, + PAINT_BACKGROUND_ENABLED = 0x0008, + PAINT_ENABLED = 0x0010, + POST_CHILD_PAINT_ENABLED = 0x0020, + AUTODELETE_ENABLED = 0x0040, + NEEDS_LAYOUT = 0x0080, + NEEDS_SCHEME_UPDATE = 0x0100, + NEEDS_DEFAULT_SETTINGS_APPLIED = 0x0200, +#if defined( VGUI_USEKEYBINDINGMAPS ) + ALLOW_CHAIN_KEYBINDING_TO_PARENT = 0x0400, +#endif + IN_PERFORM_LAYOUT = 0x0800, + IS_PROPORTIONAL = 0x1000, + TRIPLE_PRESS_ALLOWED = 0x2000, + DRAG_REQUIRES_PANEL_EXIT = 0x4000, + IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY = 0x8000, + ALL_FLAGS = 0xFFFF, + }; + + // used to get the Panel * for users with only IClientPanel + virtual Panel *GetPanel() { return this; } + + // private methods + void Think(); + void PerformApplySchemeSettings(); + + void InternalPerformLayout(); + void InternalSetCursor(); + + MESSAGE_FUNC_INT_INT( InternalCursorMoved, "CursorMoved", xpos, ypos ); + MESSAGE_FUNC( InternalCursorEntered, "CursorEntered" ); + MESSAGE_FUNC( InternalCursorExited, "CursorExited" ); + + MESSAGE_FUNC_INT( InternalMousePressed, "MousePressed", code ); + MESSAGE_FUNC_INT( InternalMouseDoublePressed, "MouseDoublePressed", code ); + // Triple presses are synthesized + MESSAGE_FUNC_INT( InternalMouseTriplePressed, "MouseTriplePressed", code ); + MESSAGE_FUNC_INT( InternalMouseReleased, "MouseReleased", code ); + MESSAGE_FUNC_INT( InternalMouseWheeled, "MouseWheeled", delta ); + MESSAGE_FUNC_INT( InternalKeyCodePressed, "KeyCodePressed", code ); + MESSAGE_FUNC_INT( InternalKeyCodeTyped, "KeyCodeTyped", code ); + MESSAGE_FUNC_INT( InternalKeyTyped, "KeyTyped", unichar ); + MESSAGE_FUNC_INT( InternalKeyCodeReleased, "KeyCodeReleased", code ); + + MESSAGE_FUNC( InternalKeyFocusTicked, "KeyFocusTicked" ); + MESSAGE_FUNC( InternalMouseFocusTicked, "MouseFocusTicked" ); + + MESSAGE_FUNC( InternalInvalidateLayout, "Invalidate" ); + + MESSAGE_FUNC( InternalMove, "Move" ); + virtual void InternalFocusChanged(bool lost); // called when the focus gets changed + + void PreparePanelMap( PanelMap_t *panelMap ); + + bool InternalRequestInfo( PanelAnimationMap *map, KeyValues *outputData ); + bool InternalSetInfo( PanelAnimationMap *map, KeyValues *inputData ); + + PanelAnimationMapEntry *FindPanelAnimationEntry( char const *scriptname, PanelAnimationMap *map ); + + // Recursively invoke settings for PanelAnimationVars + void InternalApplySettings( PanelAnimationMap *map, KeyValues *inResourceData); + void InternalInitDefaultValues( PanelAnimationMap *map ); + + // Purpose: Loads panel details related to autoresize from the resource info + void ApplyAutoResizeSettings(KeyValues *inResourceData); + + void FindDropTargetPanel_R( CUtlVector< VPANEL >& panelList, int x, int y, VPANEL check ); + Panel *FindDropTargetPanel(); + + int GetProportionalScaledValue( int rootTall, int normalizedValue ); + +#if defined( VGUI_USEDRAGDROP ) + DragDrop_t *m_pDragDrop; + Color m_clrDragFrame; + Color m_clrDropFrame; +#endif + + BaseTooltip *m_pTooltips; + bool m_bToolTipOverridden; + + PHandle m_SkipChild; + long m_lLastDoublePressTime; + HFont m_infoFont; + +#if defined( VGUI_USEKEYBINDINGMAPS ) + KeyBindingContextHandle_t m_hKeyBindingsContext; +#endif + + // data + VPANEL _vpanel; // handle to a vgui panel + char *_panelName; // string name of the panel - only unique within the current context + IBorder *_border; + + CUtlFlags< unsigned short > _flags; // see PanelFlags_t + Dar<HPanel> _actionSignalTargetDar; // the panel to direct notify messages to ("Command", "TextChanged", etc.) + + CUtlVector<OverridableColorEntry> m_OverridableColorEntries; + + Color _fgColor; // foreground color + Color _bgColor; // background color + + HBuildGroup _buildGroup; + + short m_nPinDeltaX; // Relative position of the pinned corner to the edge + short m_nPinDeltaY; + short m_nResizeDeltaX; // Relative position of the non-pinned corner to the edge + short m_nResizeDeltaY; + + HCursor _cursor; + unsigned short _buildModeFlags; // flags that control how the build mode dialog handles this panel + + byte _pinCorner : 4; // the corner of the dialog this panel is pinned to + byte _autoResizeDirection : 4; // the directions in which the panel will auto-resize to + + unsigned char _tabPosition; // the panel's place in the tab ordering + HScheme m_iScheme; // handle to the scheme to use + + bool m_bIsDMXSerialized : 1; // Is this a DMX panel? + bool m_bUseSchemeColors : 1; // Should we use colors from the scheme? + bool m_bIsSilent : 1; // should this panel PostActionSignals? + bool m_bIsConsoleStylePanel : 1; + bool m_bParentNeedsCursorMoveEvents : 1; + + // Sibling pinning + char *_pinToSibling; // string name of the sibling panel we're pinned to + byte _pinToSiblingCorner; // the corner of the sibling panel we're pinned to + byte _pinCornerToSibling; // the corner of our panel that we're pinning to our sibling + PHandle m_pinSibling; + + CUtlString m_sNavUpName; + PHandle m_NavUp; + + CUtlString m_sNavDownName; + PHandle m_NavDown; + + CUtlString m_sNavLeftName; + PHandle m_NavLeft; + + CUtlString m_sNavRightName; + PHandle m_NavRight; + + CUtlString m_sNavToRelayName; + PHandle m_NavToRelay; + + CUtlString m_sNavActivateName; + PHandle m_NavActivate; + + CUtlString m_sNavBackName; + PHandle m_NavBack; + +private: + + char *_tooltipText; // Tool tip text for panels that share tooltip panels with other panels + + PHandle m_hMouseEventHandler; + + 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 + + bool m_bForceStereoRenderToFrameBuffer; + + CPanelAnimationVar( float, m_flAlpha, "alpha", "255" ); + + // 1 == Textured (TextureId1 only) + // 2 == Rounded Corner Box + CPanelAnimationVar( int, m_nPaintBackgroundType, "PaintBackgroundType", "0" ); + CPanelAnimationVarAliasType( int, m_nBgTextureId1, "Texture1", "vgui/hud/800corner1", "textureid" ); + CPanelAnimationVarAliasType( int, m_nBgTextureId2, "Texture2", "vgui/hud/800corner2", "textureid" ); + CPanelAnimationVarAliasType( int, m_nBgTextureId3, "Texture3", "vgui/hud/800corner3", "textureid" ); + CPanelAnimationVarAliasType( int, m_nBgTextureId4, "Texture4", "vgui/hud/800corner4", "textureid" ); + + //============================================================================= + // HPE_BEGIN: + // [tj] A bitset of flags to determine which corners should be rounded + //============================================================================= + unsigned char m_roundedCorners; + //============================================================================= + // HPE_END + //============================================================================= + friend class BuildGroup; + friend class BuildModeDialog; + friend class PHandle; + + // obselete, remove soon + void OnOldMessage(KeyValues *params, VPANEL ifromPanel); +}; + +inline void Panel::DisableMouseInputForThisPanel( bool bDisable ) +{ + _flags.SetFlag( IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY, bDisable ); +} + +inline bool Panel::IsMouseInputDisabledForThisPanel() const +{ + return _flags.IsFlagSet( IS_MOUSE_DISABLED_FOR_THIS_PANEL_ONLY ); +} + +#if 0 +// This function cannot be defined here because it requires on a full definition of +// KeyValues (to call KeyValues::MakeCopy()) whereas the rest of this header file +// assumes a forward declared definition of KeyValues. +template< class S > +inline void Panel::PostMessageToAllSiblingsOfType( KeyValues *msg, float delaySeconds /*= 0.0f*/ ) +{ + Panel *parent = GetParent(); + if ( parent ) + { + int nChildCount = parent->GetChildCount(); + for ( int i = 0; i < nChildCount; ++i ) + { + Panel *sibling = parent->GetChild( i ); + if ( sibling == this ) + continue; + if ( dynamic_cast< S * >( sibling ) ) + { + PostMessage( sibling->GetVPanel(), msg->MakeCopy(), delaySeconds ); + } + } + } + + msg->deleteThis(); +} +#endif + +class Button; + +struct SortedPanel_t +{ + SortedPanel_t( Panel *panel ); + + Panel *pPanel; + Button *pButton; +}; + +class CSortedPanelYLess +{ +public: + bool Less( const SortedPanel_t &src1, const SortedPanel_t &src2, void *pCtx ) + { + int nX1, nY1, nX2, nY2; + src1.pPanel->GetPos( nX1, nY1 ); + src2.pPanel->GetPos( nX2, nY2 ); + + if ( nY1 == nY2 ) + { + return ( nX1 < nX2 ); + } + + if ( nY1 < nY2 ) + { + return true; + } + + return false; + } +}; + + +void VguiPanelGetSortedChildPanelList( Panel *pParentPanel, void *pSortedPanels ); +void VguiPanelGetSortedChildButtonList( Panel *pParentPanel, void *pSortedPanels, char *pchFilter = NULL, int nFilterType = 0 ); +int VguiPanelNavigateSortedChildButtonList( void *pSortedPanels, int nDir ); + + +} // namespace vgui + + +#endif // PANEL_H diff --git a/mp/src/public/vgui_controls/PanelAnimationVar.h b/mp/src/public/vgui_controls/PanelAnimationVar.h index 8b274f70..24c41c8c 100644 --- a/mp/src/public/vgui_controls/PanelAnimationVar.h +++ b/mp/src/public/vgui_controls/PanelAnimationVar.h @@ -1,161 +1,161 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef PANELANIMATIONVAR_H
-#define PANELANIMATIONVAR_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier1/utlvector.h"
-#include <vgui_controls/Panel.h>
-
-#define DECLARE_PANELANIMATION( className ) \
- static void AddToAnimationMap( char const *scriptname, char const *type, char const *var, \
- char const *defaultvalue, bool array, PANELLOOKUPFUNC func ) \
- { \
- PanelAnimationMap *map = FindOrAddPanelAnimationMap( GetPanelClassName() ); \
- \
- PanelAnimationMapEntry entry; \
- entry.m_pszScriptName = scriptname; \
- entry.m_pszVariable = var; \
- entry.m_pszType = type; \
- entry.m_pszDefaultValue = defaultvalue; \
- entry.m_pfnLookup = func; \
- entry.m_bArray = array; \
- \
- map->entries.AddToTail( entry ); \
- } \
- \
- static void ChainToAnimationMap( void ) \
- { \
- static bool chained = false; \
- if ( chained ) \
- return; \
- chained = true; \
- PanelAnimationMap *map = FindOrAddPanelAnimationMap( GetPanelClassName() ); \
- map->pfnClassName = GetPanelClassName; \
- if ( map && GetPanelBaseClassName() && GetPanelBaseClassName()[0] ) \
- { \
- map->baseMap = FindOrAddPanelAnimationMap( GetPanelBaseClassName() ); \
- } \
- } \
- \
- class className##_Register; \
- friend class className##_Register; \
- class className##_Register \
- { \
- public: \
- className##_Register() \
- { \
- className::ChainToAnimationMap(); \
- } \
- }; \
- className##_Register m_RegisterAnimationClass; \
- \
- virtual PanelAnimationMap *GetAnimMap() \
- { \
- return FindOrAddPanelAnimationMap( GetPanelClassName() ); \
- }
-
-typedef void *( *PANELLOOKUPFUNC )( vgui::Panel *panel );
-
-// Use this macro to define a variable which hudanimations.txt and hudlayout.res scripts can access
-#define CPanelAnimationVarAliasType( type, name, scriptname, defaultvalue, typealias ) \
- class PanelAnimationVar_##name; \
- friend class PanelAnimationVar_##name; \
- static void *GetVar_##name( vgui::Panel *panel ) \
- { \
- return &(( ThisClass *)panel)->name; \
- } \
- class PanelAnimationVar_##name \
- { \
- public: \
- static void InitVar() \
- { \
- static bool bAdded = false; \
- if ( !bAdded ) \
- { \
- bAdded = true; \
- AddToAnimationMap( scriptname, typealias, #name, defaultvalue, false, ThisClass::GetVar_##name ); \
- } \
- } \
- PanelAnimationVar_##name() \
- { \
- PanelAnimationVar_##name::InitVar(); \
- } \
- }; \
- PanelAnimationVar_##name m_##name##_register; \
- type name;
-
-#define CPanelAnimationVar( type, name, scriptname, defaultvalue ) \
- CPanelAnimationVarAliasType( type, name, scriptname, defaultvalue, #type )
-
-// Use this macro to define a variable which hudanimations.txt and hudlayout.res scripts can access
-#define CPanelAnimationStringVarAliasType( count, name, scriptname, defaultvalue, typealias ) \
- class PanelAnimationVar_##name; \
- friend class PanelAnimationVar_##name; \
- static void *GetVar_##name( vgui::Panel *panel ) \
- { \
- return &(( ThisClass *)panel)->name; \
- } \
- class PanelAnimationVar_##name \
- { \
- public: \
- static void InitVar() \
- { \
- static bool bAdded = false; \
- if ( !bAdded ) \
- { \
- bAdded = true; \
- AddToAnimationMap( scriptname, typealias, #name, defaultvalue, true, ThisClass::GetVar_##name ); \
- } \
- } \
- PanelAnimationVar_##name() \
- { \
- PanelAnimationVar_##name::InitVar(); \
- } \
- }; \
- PanelAnimationVar_##name m_##name##_register; \
- char name[ count ];
-
-#define CPanelAnimationStringVar( count, name, scriptname, defaultvalue ) \
- CPanelAnimationStringVarAliasType( count, name, scriptname, defaultvalue, "string" )
-
-struct PanelAnimationMapEntry
-{
- char const *name() { return m_pszScriptName; }
- char const *type() { return m_pszType; }
- char const *defaultvalue() { return m_pszDefaultValue; }
- bool isarray() { return m_bArray; }
-
- char const *m_pszScriptName;
- char const *m_pszVariable;
- char const *m_pszType;
- char const *m_pszDefaultValue;
- bool m_bArray;
-
- PANELLOOKUPFUNC m_pfnLookup;
-};
-
-struct PanelAnimationMap
-{
- PanelAnimationMap()
- {
- baseMap = NULL;
- pfnClassName = NULL;
- }
-
- CUtlVector< PanelAnimationMapEntry > entries;
- PanelAnimationMap *baseMap;
- char const *(*pfnClassName)( void );
-};
-
-PanelAnimationMap *FindPanelAnimationMap( char const *className );
-PanelAnimationMap *FindOrAddPanelAnimationMap( char const *className );
-void PanelAnimationDumpVars( char const *className );
-
-#endif // PANELANIMATIONVAR_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef PANELANIMATIONVAR_H +#define PANELANIMATIONVAR_H +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlvector.h" +#include <vgui_controls/Panel.h> + +#define DECLARE_PANELANIMATION( className ) \ + static void AddToAnimationMap( char const *scriptname, char const *type, char const *var, \ + char const *defaultvalue, bool array, PANELLOOKUPFUNC func ) \ + { \ + PanelAnimationMap *map = FindOrAddPanelAnimationMap( GetPanelClassName() ); \ + \ + PanelAnimationMapEntry entry; \ + entry.m_pszScriptName = scriptname; \ + entry.m_pszVariable = var; \ + entry.m_pszType = type; \ + entry.m_pszDefaultValue = defaultvalue; \ + entry.m_pfnLookup = func; \ + entry.m_bArray = array; \ + \ + map->entries.AddToTail( entry ); \ + } \ + \ + static void ChainToAnimationMap( void ) \ + { \ + static bool chained = false; \ + if ( chained ) \ + return; \ + chained = true; \ + PanelAnimationMap *map = FindOrAddPanelAnimationMap( GetPanelClassName() ); \ + map->pfnClassName = GetPanelClassName; \ + if ( map && GetPanelBaseClassName() && GetPanelBaseClassName()[0] ) \ + { \ + map->baseMap = FindOrAddPanelAnimationMap( GetPanelBaseClassName() ); \ + } \ + } \ + \ + class className##_Register; \ + friend class className##_Register; \ + class className##_Register \ + { \ + public: \ + className##_Register() \ + { \ + className::ChainToAnimationMap(); \ + } \ + }; \ + className##_Register m_RegisterAnimationClass; \ + \ + virtual PanelAnimationMap *GetAnimMap() \ + { \ + return FindOrAddPanelAnimationMap( GetPanelClassName() ); \ + } + +typedef void *( *PANELLOOKUPFUNC )( vgui::Panel *panel ); + +// Use this macro to define a variable which hudanimations.txt and hudlayout.res scripts can access +#define CPanelAnimationVarAliasType( type, name, scriptname, defaultvalue, typealias ) \ + class PanelAnimationVar_##name; \ + friend class PanelAnimationVar_##name; \ + static void *GetVar_##name( vgui::Panel *panel ) \ + { \ + return &(( ThisClass *)panel)->name; \ + } \ + class PanelAnimationVar_##name \ + { \ + public: \ + static void InitVar() \ + { \ + static bool bAdded = false; \ + if ( !bAdded ) \ + { \ + bAdded = true; \ + AddToAnimationMap( scriptname, typealias, #name, defaultvalue, false, ThisClass::GetVar_##name ); \ + } \ + } \ + PanelAnimationVar_##name() \ + { \ + PanelAnimationVar_##name::InitVar(); \ + } \ + }; \ + PanelAnimationVar_##name m_##name##_register; \ + type name; + +#define CPanelAnimationVar( type, name, scriptname, defaultvalue ) \ + CPanelAnimationVarAliasType( type, name, scriptname, defaultvalue, #type ) + +// Use this macro to define a variable which hudanimations.txt and hudlayout.res scripts can access +#define CPanelAnimationStringVarAliasType( count, name, scriptname, defaultvalue, typealias ) \ + class PanelAnimationVar_##name; \ + friend class PanelAnimationVar_##name; \ + static void *GetVar_##name( vgui::Panel *panel ) \ + { \ + return &(( ThisClass *)panel)->name; \ + } \ + class PanelAnimationVar_##name \ + { \ + public: \ + static void InitVar() \ + { \ + static bool bAdded = false; \ + if ( !bAdded ) \ + { \ + bAdded = true; \ + AddToAnimationMap( scriptname, typealias, #name, defaultvalue, true, ThisClass::GetVar_##name ); \ + } \ + } \ + PanelAnimationVar_##name() \ + { \ + PanelAnimationVar_##name::InitVar(); \ + } \ + }; \ + PanelAnimationVar_##name m_##name##_register; \ + char name[ count ]; + +#define CPanelAnimationStringVar( count, name, scriptname, defaultvalue ) \ + CPanelAnimationStringVarAliasType( count, name, scriptname, defaultvalue, "string" ) + +struct PanelAnimationMapEntry +{ + char const *name() { return m_pszScriptName; } + char const *type() { return m_pszType; } + char const *defaultvalue() { return m_pszDefaultValue; } + bool isarray() { return m_bArray; } + + char const *m_pszScriptName; + char const *m_pszVariable; + char const *m_pszType; + char const *m_pszDefaultValue; + bool m_bArray; + + PANELLOOKUPFUNC m_pfnLookup; +}; + +struct PanelAnimationMap +{ + PanelAnimationMap() + { + baseMap = NULL; + pfnClassName = NULL; + } + + CUtlVector< PanelAnimationMapEntry > entries; + PanelAnimationMap *baseMap; + char const *(*pfnClassName)( void ); +}; + +PanelAnimationMap *FindPanelAnimationMap( char const *className ); +PanelAnimationMap *FindOrAddPanelAnimationMap( char const *className ); +void PanelAnimationDumpVars( char const *className ); + +#endif // PANELANIMATIONVAR_H diff --git a/mp/src/public/vgui_controls/PanelListPanel.h b/mp/src/public/vgui_controls/PanelListPanel.h index 392feb3d..98292079 100644 --- a/mp/src/public/vgui_controls/PanelListPanel.h +++ b/mp/src/public/vgui_controls/PanelListPanel.h @@ -1,124 +1,124 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PANELLISTPANEL_H
-#define PANELLISTPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utllinkedlist.h>
-#include <utlvector.h>
-#include <vgui/VGUI.h>
-#include <vgui_controls/EditablePanel.h>
-
-class KeyValues;
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: A list of variable height child panels
-// each list item consists of a label-panel pair. Height of the item is
-// determined from the lable.
-//-----------------------------------------------------------------------------
-class PanelListPanel : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( PanelListPanel, Panel );
-
-public:
- PanelListPanel( vgui::Panel *parent, char const *panelName );
- ~PanelListPanel();
-
- // DATA & ROW HANDLING
- // The list now owns the panel
- virtual int AddItem( Panel *labelPanel, Panel *panel );
- int GetItemCount() const;
- int GetItemIDFromRow( int nRow ) const;
-
- // Iteration. Use these until they return InvalidItemID to iterate all the items.
- int FirstItem() const;
- int NextItem( int nItemID ) const;
- int InvalidItemID() const;
-
- virtual Panel *GetItemLabel(int itemID);
- virtual Panel *GetItemPanel(int itemID);
-
- ScrollBar* GetScrollbar() { return m_vbar; }
-
- virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items)
- virtual void DeleteAllItems(); // clears and deletes all the memory used by the data items
- void RemoveAll();
-
- // painting
- virtual vgui::Panel *GetCellRenderer( int row );
-
- // layout
- void SetFirstColumnWidth( int width );
- int GetFirstColumnWidth();
- void SetNumColumns( int iNumColumns );
- int GetNumColumns( void );
- void MoveScrollBarToTop();
-
- // selection
- void SetSelectedPanel( Panel *panel );
- Panel *GetSelectedPanel();
- /*
- On a panel being selected, a message gets sent to it
- "PanelSelected" int "state"
- where state is 1 on selection, 0 on deselection
- */
-
- void SetVerticalBufferPixels( int buffer );
-
- void ScrollToItem( int itemNumber );
-
- CUtlVector< int > *GetSortedVector( void )
- {
- return &m_SortedItems;
- }
-
-protected:
- // overrides
- virtual void OnSizeChanged(int wide, int tall);
- MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
- virtual void OnMouseWheeled(int delta);
-
-private:
- int ComputeVPixelsNeeded();
-
- enum { DEFAULT_HEIGHT = 24, PANELBUFFER = 5 };
-
- typedef struct dataitem_s
- {
- // Always store a panel pointer
- Panel *panel;
- Panel *labelPanel;
- } DATAITEM;
-
- // list of the column headers
-
- CUtlLinkedList<DATAITEM, int> m_DataItems;
- CUtlVector<int> m_SortedItems;
-
- ScrollBar *m_vbar;
- Panel *m_pPanelEmbedded;
-
- PHandle m_hSelectedItem;
- int m_iFirstColumnWidth;
- int m_iNumColumns;
- int m_iDefaultHeight;
- int m_iPanelBuffer;
-
- CPanelAnimationVar( bool, m_bAutoHideScrollbar, "autohide_scrollbar", "0" );
-};
-
-}
-#endif // PANELLISTPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PANELLISTPANEL_H +#define PANELLISTPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utllinkedlist.h> +#include <utlvector.h> +#include <vgui/VGUI.h> +#include <vgui_controls/EditablePanel.h> + +class KeyValues; + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: A list of variable height child panels +// each list item consists of a label-panel pair. Height of the item is +// determined from the lable. +//----------------------------------------------------------------------------- +class PanelListPanel : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( PanelListPanel, Panel ); + +public: + PanelListPanel( vgui::Panel *parent, char const *panelName ); + ~PanelListPanel(); + + // DATA & ROW HANDLING + // The list now owns the panel + virtual int AddItem( Panel *labelPanel, Panel *panel ); + int GetItemCount() const; + int GetItemIDFromRow( int nRow ) const; + + // Iteration. Use these until they return InvalidItemID to iterate all the items. + int FirstItem() const; + int NextItem( int nItemID ) const; + int InvalidItemID() const; + + virtual Panel *GetItemLabel(int itemID); + virtual Panel *GetItemPanel(int itemID); + + ScrollBar* GetScrollbar() { return m_vbar; } + + virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items) + virtual void DeleteAllItems(); // clears and deletes all the memory used by the data items + void RemoveAll(); + + // painting + virtual vgui::Panel *GetCellRenderer( int row ); + + // layout + void SetFirstColumnWidth( int width ); + int GetFirstColumnWidth(); + void SetNumColumns( int iNumColumns ); + int GetNumColumns( void ); + void MoveScrollBarToTop(); + + // selection + void SetSelectedPanel( Panel *panel ); + Panel *GetSelectedPanel(); + /* + On a panel being selected, a message gets sent to it + "PanelSelected" int "state" + where state is 1 on selection, 0 on deselection + */ + + void SetVerticalBufferPixels( int buffer ); + + void ScrollToItem( int itemNumber ); + + CUtlVector< int > *GetSortedVector( void ) + { + return &m_SortedItems; + } + +protected: + // overrides + virtual void OnSizeChanged(int wide, int tall); + MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position ); + virtual void PerformLayout(); + virtual void ApplySchemeSettings(vgui::IScheme *pScheme); + virtual void OnMouseWheeled(int delta); + +private: + int ComputeVPixelsNeeded(); + + enum { DEFAULT_HEIGHT = 24, PANELBUFFER = 5 }; + + typedef struct dataitem_s + { + // Always store a panel pointer + Panel *panel; + Panel *labelPanel; + } DATAITEM; + + // list of the column headers + + CUtlLinkedList<DATAITEM, int> m_DataItems; + CUtlVector<int> m_SortedItems; + + ScrollBar *m_vbar; + Panel *m_pPanelEmbedded; + + PHandle m_hSelectedItem; + int m_iFirstColumnWidth; + int m_iNumColumns; + int m_iDefaultHeight; + int m_iPanelBuffer; + + CPanelAnimationVar( bool, m_bAutoHideScrollbar, "autohide_scrollbar", "0" ); +}; + +} +#endif // PANELLISTPANEL_H diff --git a/mp/src/public/vgui_controls/PerforceFileExplorer.h b/mp/src/public/vgui_controls/PerforceFileExplorer.h index 4e44d7da..4d3dd876 100644 --- a/mp/src/public/vgui_controls/PerforceFileExplorer.h +++ b/mp/src/public/vgui_controls/PerforceFileExplorer.h @@ -1,67 +1,67 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Allows you to browse a directory structure, showing perforce files
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef PERFORCEFILEEXPLORER_H
-#define PERFORCEFILEEXPLORER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include "tier1/utlstring.h"
-#include "vgui_controls/Frame.h"
-
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-class PerforceFileList;
-class ComboBox;
-class Button;
-
-
-//-----------------------------------------------------------------------------
-// Contains a list of files, determines their perforce status
-//-----------------------------------------------------------------------------
-class PerforceFileExplorer : public vgui::Frame
-{
- DECLARE_CLASS_SIMPLE( PerforceFileExplorer, Frame );
-
-public:
- // The context keyvalues are added to all messages sent by this dialog if they are specified
- PerforceFileExplorer( Panel *parent, const char *pPanelName );
- ~PerforceFileExplorer();
-
- // Inherited from Frame
- virtual void ApplySchemeSettings( IScheme *pScheme );
- virtual void PerformLayout();
-
-protected:
- MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
- MESSAGE_FUNC( OnItemDoubleClicked, "ItemDoubleClicked" );
- MESSAGE_FUNC( OnFolderUp, "FolderUp" );
-
- void PopulateFileList();
- void PopulateDriveList();
-
- // Returns the current directory
- void SetCurrentDirectory( const char *pCurrentDirectory );
-
- Button *m_pFolderUpButton;
- ComboBox *m_pFullPathCombo;
- PerforceFileList *m_pFileList;
- CUtlString m_CurrentDirectory;
-};
-
-
-} // namespace vgui
-
-#endif // PERFORCEFILEEXPLORER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Allows you to browse a directory structure, showing perforce files +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef PERFORCEFILEEXPLORER_H +#define PERFORCEFILEEXPLORER_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "tier1/utlstring.h" +#include "vgui_controls/Frame.h" + + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class PerforceFileList; +class ComboBox; +class Button; + + +//----------------------------------------------------------------------------- +// Contains a list of files, determines their perforce status +//----------------------------------------------------------------------------- +class PerforceFileExplorer : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( PerforceFileExplorer, Frame ); + +public: + // The context keyvalues are added to all messages sent by this dialog if they are specified + PerforceFileExplorer( Panel *parent, const char *pPanelName ); + ~PerforceFileExplorer(); + + // Inherited from Frame + virtual void ApplySchemeSettings( IScheme *pScheme ); + virtual void PerformLayout(); + +protected: + MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv ); + MESSAGE_FUNC( OnItemDoubleClicked, "ItemDoubleClicked" ); + MESSAGE_FUNC( OnFolderUp, "FolderUp" ); + + void PopulateFileList(); + void PopulateDriveList(); + + // Returns the current directory + void SetCurrentDirectory( const char *pCurrentDirectory ); + + Button *m_pFolderUpButton; + ComboBox *m_pFullPathCombo; + PerforceFileList *m_pFileList; + CUtlString m_CurrentDirectory; +}; + + +} // namespace vgui + +#endif // PERFORCEFILEEXPLORER_H diff --git a/mp/src/public/vgui_controls/PerforceFileList.h b/mp/src/public/vgui_controls/PerforceFileList.h index 65f3807a..148b005c 100644 --- a/mp/src/public/vgui_controls/PerforceFileList.h +++ b/mp/src/public/vgui_controls/PerforceFileList.h @@ -1,114 +1,114 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Contains a list of files, determines their perforce status
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef PERFORCEFILELIST_H
-#define PERFORCEFILELIST_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier1/utlstring.h"
-#include "tier1/UtlStringMap.h"
-#include "vgui_controls/ListPanel.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-struct P4File_t;
-
-namespace vgui
-{
- class ListPanel;
-}
-
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Contains a list of files, determines their perforce status
-//-----------------------------------------------------------------------------
-class PerforceFileList : public vgui::ListPanel
-{
- DECLARE_CLASS_SIMPLE( PerforceFileList, ListPanel );
-
-public:
- // The context keyvalues are added to all messages sent by this dialog if they are specified
- PerforceFileList( Panel *parent, const char *pPanelName );
- ~PerforceFileList();
-
- // Add a file to the file list. Note that this file may exist on disk or not
- // and it may exist in perforce or not. It's specified as a full path on disk though.
- // In the case where a file doesn't exist on disk, but it does exist in perforce
- // specify where that file would appear on disk.
- // This function returns the itemID of the added file
- // If you already know the file exists or is a directory (or not), specify that in the call.
- // -1 means autodetect whether the file exists or is a directory
- int AddFile( const char *pFullPath, int nFileExists = -1, int nIsDirectory = -1 );
-
- // Is a file already in the list?
- bool IsFileInList( const char *pFullPath );
-
- // Find the item ID associated with a particular file
- int FindFile( const char *pFullPath );
-
- // Remove all files from the list
- void RemoveAllFiles();
-
- // Refresh perforce information
- void Refresh();
-
- // Refresh perforce information manually
- void RefreshPerforceState( int nItemID, bool bFileExists, P4File_t *pFileInfo );
-
- // Is a particular list item a directory?
- bool IsDirectoryItem( int nItemID );
-
- // Returns the file associated with a particular item ID
- const char *GetFile( int nItemID );
-
- // Toggle showing deleted files or not
- void ShowDeletedFiles( bool bShowDeletedFiles );
-
- // Inherited from vgui::EditablePanel
- virtual void ApplySchemeSettings( IScheme *pScheme );
- virtual void OnMouseDoublePressed( MouseCode code );
-
- /*
- messages sent:
- "ItemDoubleClicked" // Called when an item is double-clicked
- */
-
-protected:
- struct DirectoryInfo_t
- {
- CUtlString m_ClientSpec;
- CUtlVector< int > m_ItemIDs;
- };
-
- // Add a file to the file list.
- int AddFileToFileList( const char *pFullPath, bool bExistsOnDisk );
-
- // Add a directory to the file list.
- int AddDirectoryToFileList( const char *pFullPath, bool bExistsOnDisk );
-
- // Add a directory to the directory list, returns client spec
- void AddItemToDirectoryList( const char *pFullPath, int nItemID, bool bIsDirectory );
-
- // Used to look up directories -> client specs
- CUtlStringMap< DirectoryInfo_t > m_Directories;
-
- // Show deleted files?
- bool m_bShowDeletedFiles;
-};
-
-
-} // namespace vgui
-
-#endif // PERFORCEFILELIST_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Contains a list of files, determines their perforce status +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef PERFORCEFILELIST_H +#define PERFORCEFILELIST_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlstring.h" +#include "tier1/UtlStringMap.h" +#include "vgui_controls/ListPanel.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +struct P4File_t; + +namespace vgui +{ + class ListPanel; +} + + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Contains a list of files, determines their perforce status +//----------------------------------------------------------------------------- +class PerforceFileList : public vgui::ListPanel +{ + DECLARE_CLASS_SIMPLE( PerforceFileList, ListPanel ); + +public: + // The context keyvalues are added to all messages sent by this dialog if they are specified + PerforceFileList( Panel *parent, const char *pPanelName ); + ~PerforceFileList(); + + // Add a file to the file list. Note that this file may exist on disk or not + // and it may exist in perforce or not. It's specified as a full path on disk though. + // In the case where a file doesn't exist on disk, but it does exist in perforce + // specify where that file would appear on disk. + // This function returns the itemID of the added file + // If you already know the file exists or is a directory (or not), specify that in the call. + // -1 means autodetect whether the file exists or is a directory + int AddFile( const char *pFullPath, int nFileExists = -1, int nIsDirectory = -1 ); + + // Is a file already in the list? + bool IsFileInList( const char *pFullPath ); + + // Find the item ID associated with a particular file + int FindFile( const char *pFullPath ); + + // Remove all files from the list + void RemoveAllFiles(); + + // Refresh perforce information + void Refresh(); + + // Refresh perforce information manually + void RefreshPerforceState( int nItemID, bool bFileExists, P4File_t *pFileInfo ); + + // Is a particular list item a directory? + bool IsDirectoryItem( int nItemID ); + + // Returns the file associated with a particular item ID + const char *GetFile( int nItemID ); + + // Toggle showing deleted files or not + void ShowDeletedFiles( bool bShowDeletedFiles ); + + // Inherited from vgui::EditablePanel + virtual void ApplySchemeSettings( IScheme *pScheme ); + virtual void OnMouseDoublePressed( MouseCode code ); + + /* + messages sent: + "ItemDoubleClicked" // Called when an item is double-clicked + */ + +protected: + struct DirectoryInfo_t + { + CUtlString m_ClientSpec; + CUtlVector< int > m_ItemIDs; + }; + + // Add a file to the file list. + int AddFileToFileList( const char *pFullPath, bool bExistsOnDisk ); + + // Add a directory to the file list. + int AddDirectoryToFileList( const char *pFullPath, bool bExistsOnDisk ); + + // Add a directory to the directory list, returns client spec + void AddItemToDirectoryList( const char *pFullPath, int nItemID, bool bIsDirectory ); + + // Used to look up directories -> client specs + CUtlStringMap< DirectoryInfo_t > m_Directories; + + // Show deleted files? + bool m_bShowDeletedFiles; +}; + + +} // namespace vgui + +#endif // PERFORCEFILELIST_H diff --git a/mp/src/public/vgui_controls/ProgressBar.h b/mp/src/public/vgui_controls/ProgressBar.h index 4d5a968b..a91269b1 100644 --- a/mp/src/public/vgui_controls/ProgressBar.h +++ b/mp/src/public/vgui_controls/ProgressBar.h @@ -1,103 +1,103 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PROGRESSBAR_H
-#define PROGRESSBAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Status bar that visually displays discrete progress in the form
-// of a segmented strip
-//-----------------------------------------------------------------------------
-class ProgressBar : public Panel
-{
- DECLARE_CLASS_SIMPLE( ProgressBar, Panel );
-
-public:
- ProgressBar(Panel *parent, const char *panelName);
- ~ProgressBar();
-
- // 'progress' is in the range [0.0f, 1.0f]
- MESSAGE_FUNC_FLOAT( SetProgress, "SetProgress", progress );
- float GetProgress();
- virtual void SetSegmentInfo( int gap, int width );
-
- // utility function for calculating a time remaining string
- static bool ConstructTimeRemainingString(OUT_Z_BYTECAP(outputBufferSizeInBytes) wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentProgress, float lastProgressUpdateTime, bool addRemainingSuffix);
-
- void SetBarInset( int pixels );
- int GetBarInset( void );
- void SetMargin( int pixels );
- int GetMargin();
-
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void GetSettings(KeyValues *outResourceData);
- virtual const char *GetDescription();
-
- // returns the number of segment blocks drawn
- int GetDrawnSegmentCount();
-
- enum ProgressDir_e
- {
- PROGRESS_EAST,
- PROGRESS_WEST,
- PROGRESS_NORTH,
- PROGRESS_SOUTH
- };
-
- int GetProgressDirection() const { return m_iProgressDirection; }
- void SetProgressDirection( int val ) { m_iProgressDirection = val; }
-
-protected:
- virtual void Paint();
- void PaintSegment( int &x, int &y, int tall, int wide );
- virtual void PaintBackground();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
- /* CUSTOM MESSAGE HANDLING
- "SetProgress"
- input: "progress" - float value of the progress to set
- */
-
-protected:
- int m_iProgressDirection;
- float _progress;
-
-private:
- int _segmentCount;
- int _segmentGap;
- int _segmentWide;
- int m_iBarInset;
- int m_iBarMargin;
- char *m_pszDialogVar;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Non-segmented progress bar
-//-----------------------------------------------------------------------------
-class ContinuousProgressBar : public ProgressBar
-{
- DECLARE_CLASS_SIMPLE( ContinuousProgressBar, ProgressBar );
-
-public:
- ContinuousProgressBar(Panel *parent, const char *panelName);
-
- virtual void Paint();
-};
-
-} // namespace vgui
-
-#endif // PROGRESSBAR_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PROGRESSBAR_H +#define PROGRESSBAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Status bar that visually displays discrete progress in the form +// of a segmented strip +//----------------------------------------------------------------------------- +class ProgressBar : public Panel +{ + DECLARE_CLASS_SIMPLE( ProgressBar, Panel ); + +public: + ProgressBar(Panel *parent, const char *panelName); + ~ProgressBar(); + + // 'progress' is in the range [0.0f, 1.0f] + MESSAGE_FUNC_FLOAT( SetProgress, "SetProgress", progress ); + float GetProgress(); + virtual void SetSegmentInfo( int gap, int width ); + + // utility function for calculating a time remaining string + static bool ConstructTimeRemainingString(OUT_Z_BYTECAP(outputBufferSizeInBytes) wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentProgress, float lastProgressUpdateTime, bool addRemainingSuffix); + + void SetBarInset( int pixels ); + int GetBarInset( void ); + void SetMargin( int pixels ); + int GetMargin(); + + virtual void ApplySettings(KeyValues *inResourceData); + virtual void GetSettings(KeyValues *outResourceData); + virtual const char *GetDescription(); + + // returns the number of segment blocks drawn + int GetDrawnSegmentCount(); + + enum ProgressDir_e + { + PROGRESS_EAST, + PROGRESS_WEST, + PROGRESS_NORTH, + PROGRESS_SOUTH + }; + + int GetProgressDirection() const { return m_iProgressDirection; } + void SetProgressDirection( int val ) { m_iProgressDirection = val; } + +protected: + virtual void Paint(); + void PaintSegment( int &x, int &y, int tall, int wide ); + virtual void PaintBackground(); + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables ); + /* CUSTOM MESSAGE HANDLING + "SetProgress" + input: "progress" - float value of the progress to set + */ + +protected: + int m_iProgressDirection; + float _progress; + +private: + int _segmentCount; + int _segmentGap; + int _segmentWide; + int m_iBarInset; + int m_iBarMargin; + char *m_pszDialogVar; +}; + +//----------------------------------------------------------------------------- +// Purpose: Non-segmented progress bar +//----------------------------------------------------------------------------- +class ContinuousProgressBar : public ProgressBar +{ + DECLARE_CLASS_SIMPLE( ContinuousProgressBar, ProgressBar ); + +public: + ContinuousProgressBar(Panel *parent, const char *panelName); + + virtual void Paint(); +}; + +} // namespace vgui + +#endif // PROGRESSBAR_H diff --git a/mp/src/public/vgui_controls/ProgressBox.h b/mp/src/public/vgui_controls/ProgressBox.h index 0fb206b4..d5c321a4 100644 --- a/mp/src/public/vgui_controls/ProgressBox.h +++ b/mp/src/public/vgui_controls/ProgressBox.h @@ -1,99 +1,99 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PROGRESSBOX_H
-#define PROGRESSBOX_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Frame.h>
-
-// prevent windows macros from messing with the class
-#ifdef ProgressBox
-#undef ProgressBox
-#endif
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Popup discardable message box
-//-----------------------------------------------------------------------------
-class ProgressBox : public Frame
-{
- DECLARE_CLASS_SIMPLE( ProgressBox, Frame );
-
-public:
- // title - Text to be displayed in the title bar of the window
- // text - Text message in the message box
- // parent - parent panel of the message box, by default it has no parent.
- ProgressBox(const char *title, const char *text, const char *pszUnknownTimeString, Panel *parent = NULL);
- ProgressBox(const wchar_t *wszTitle, const wchar_t *wszText, const wchar_t *wszUnknownTimeString, Panel *parent = NULL);
- ~ProgressBox();
-
- // Put the message box into a modal state
- virtual void DoModal(Frame *pFrameOver = NULL);
-
- // make the message box appear and in a modeless state
- virtual void ShowWindow(Frame *pFrameOver = NULL);
-
- // updates progress bar, range [0, 1]
- virtual void SetProgress(float progress);
-
- // sets the info text
- virtual void SetText(const char *text);
-
- // toggles visibility of the close box.
- virtual void SetCancelButtonVisible(bool state);
-
- // toggles the enabled state of the cancel button (for if it needs to be disabled part way through a process)
- virtual void SetCancelButtonEnabled(bool state);
-
- /* custom messages:
-
- "ProgressBoxCancelled"
- sent if the user pressed the cancel button (must be enabled & visible for this to happen)
-
- */
-
-protected:
- virtual void PerformLayout();
- virtual void OnClose();
- virtual void OnCloseFrameButtonPressed();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnThink();
- virtual void OnCommand(const char *command);
- virtual void OnTick();
-
- // called when the update has been cancelled
- virtual void OnCancel();
-
-private:
- MESSAGE_FUNC( OnShutdownRequest, "ShutdownRequest" );
- void Init();
- void UpdateTitle();
-
- Label *m_pMessageLabel;
- ProgressBar *m_pProgressBar;
- Button *m_pCancelButton;
-
- wchar_t m_wszTitleString[128];
- wchar_t m_wcsInfoString[128];
- wchar_t m_wszUnknownTimeString[128];
-
- float m_flFirstProgressUpdate;
- float m_flLastProgressUpdate;
- float m_flCurrentProgress;
-};
-
-} // namespace vgui
-
-
-#endif // PROGRESSBOX_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PROGRESSBOX_H +#define PROGRESSBOX_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Frame.h> + +// prevent windows macros from messing with the class +#ifdef ProgressBox +#undef ProgressBox +#endif + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Popup discardable message box +//----------------------------------------------------------------------------- +class ProgressBox : public Frame +{ + DECLARE_CLASS_SIMPLE( ProgressBox, Frame ); + +public: + // title - Text to be displayed in the title bar of the window + // text - Text message in the message box + // parent - parent panel of the message box, by default it has no parent. + ProgressBox(const char *title, const char *text, const char *pszUnknownTimeString, Panel *parent = NULL); + ProgressBox(const wchar_t *wszTitle, const wchar_t *wszText, const wchar_t *wszUnknownTimeString, Panel *parent = NULL); + ~ProgressBox(); + + // Put the message box into a modal state + virtual void DoModal(Frame *pFrameOver = NULL); + + // make the message box appear and in a modeless state + virtual void ShowWindow(Frame *pFrameOver = NULL); + + // updates progress bar, range [0, 1] + virtual void SetProgress(float progress); + + // sets the info text + virtual void SetText(const char *text); + + // toggles visibility of the close box. + virtual void SetCancelButtonVisible(bool state); + + // toggles the enabled state of the cancel button (for if it needs to be disabled part way through a process) + virtual void SetCancelButtonEnabled(bool state); + + /* custom messages: + + "ProgressBoxCancelled" + sent if the user pressed the cancel button (must be enabled & visible for this to happen) + + */ + +protected: + virtual void PerformLayout(); + virtual void OnClose(); + virtual void OnCloseFrameButtonPressed(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnThink(); + virtual void OnCommand(const char *command); + virtual void OnTick(); + + // called when the update has been cancelled + virtual void OnCancel(); + +private: + MESSAGE_FUNC( OnShutdownRequest, "ShutdownRequest" ); + void Init(); + void UpdateTitle(); + + Label *m_pMessageLabel; + ProgressBar *m_pProgressBar; + Button *m_pCancelButton; + + wchar_t m_wszTitleString[128]; + wchar_t m_wcsInfoString[128]; + wchar_t m_wszUnknownTimeString[128]; + + float m_flFirstProgressUpdate; + float m_flLastProgressUpdate; + float m_flCurrentProgress; +}; + +} // namespace vgui + + +#endif // PROGRESSBOX_H diff --git a/mp/src/public/vgui_controls/PropertyDialog.h b/mp/src/public/vgui_controls/PropertyDialog.h index 5711a33b..32747f0a 100644 --- a/mp/src/public/vgui_controls/PropertyDialog.h +++ b/mp/src/public/vgui_controls/PropertyDialog.h @@ -1,84 +1,84 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PROPERTYDIALOG_H
-#define PROPERTYDIALOG_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Frame.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Simple frame that holds a property sheet
-//-----------------------------------------------------------------------------
-class PropertyDialog : public Frame
-{
- DECLARE_CLASS_SIMPLE( PropertyDialog, Frame );
-
-public:
- PropertyDialog(Panel *parent, const char *panelName);
- ~PropertyDialog();
-
- // returns a pointer to the PropertySheet this dialog encapsulates
- virtual PropertySheet *GetPropertySheet();
-
- // wrapper for PropertySheet interface
- virtual void AddPage(Panel *page, const char *title);
- virtual Panel *GetActivePage();
- virtual void ResetAllData();
- virtual void ApplyChanges();
-
- // sets the text on the OK/Cancel buttons, overriding the default
- void SetOKButtonText(const char *text);
- void SetCancelButtonText(const char *text);
- void SetApplyButtonText(const char *text);
-
- // changes the visibility of the buttons
- void SetOKButtonVisible(bool state);
- void SetCancelButtonVisible(bool state);
- void SetApplyButtonVisible(bool state);
-
- /* MESSAGES SENT
- "ResetData" - sent when page is loaded. Data should be reloaded from document into controls.
- "ApplyChanges" - sent when the OK / Apply button is pressed. Changed data should be written into document.
- */
-
-protected:
- // Called when the OK button is pressed. Simply closes the dialog.
- virtual bool OnOK(bool applyOnly);
-
- // called when the Cancel button is pressed
- virtual void OnCancel();
-
- // vgui overrides
- virtual void PerformLayout();
- virtual void OnCommand(const char *command);
- virtual void ActivateBuildMode();
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual void RequestFocus(int direction = 0);
-
- MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" );
- void EnableApplyButton(bool bEnable);
-
-private:
- PropertySheet *_propertySheet;
- Button *_okButton;
- Button *_cancelButton;
- Button *_applyButton;
-
- CPanelAnimationVar( int, m_iSheetInsetBottom, "sheetinset_bottom", "32" );
-};
-
-}; // vgui
-
-#endif // PROPERTYDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PROPERTYDIALOG_H +#define PROPERTYDIALOG_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Frame.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Simple frame that holds a property sheet +//----------------------------------------------------------------------------- +class PropertyDialog : public Frame +{ + DECLARE_CLASS_SIMPLE( PropertyDialog, Frame ); + +public: + PropertyDialog(Panel *parent, const char *panelName); + ~PropertyDialog(); + + // returns a pointer to the PropertySheet this dialog encapsulates + virtual PropertySheet *GetPropertySheet(); + + // wrapper for PropertySheet interface + virtual void AddPage(Panel *page, const char *title); + virtual Panel *GetActivePage(); + virtual void ResetAllData(); + virtual void ApplyChanges(); + + // sets the text on the OK/Cancel buttons, overriding the default + void SetOKButtonText(const char *text); + void SetCancelButtonText(const char *text); + void SetApplyButtonText(const char *text); + + // changes the visibility of the buttons + void SetOKButtonVisible(bool state); + void SetCancelButtonVisible(bool state); + void SetApplyButtonVisible(bool state); + + /* MESSAGES SENT + "ResetData" - sent when page is loaded. Data should be reloaded from document into controls. + "ApplyChanges" - sent when the OK / Apply button is pressed. Changed data should be written into document. + */ + +protected: + // Called when the OK button is pressed. Simply closes the dialog. + virtual bool OnOK(bool applyOnly); + + // called when the Cancel button is pressed + virtual void OnCancel(); + + // vgui overrides + virtual void PerformLayout(); + virtual void OnCommand(const char *command); + virtual void ActivateBuildMode(); + virtual void OnKeyCodeTyped(KeyCode code); + virtual void RequestFocus(int direction = 0); + + MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" ); + void EnableApplyButton(bool bEnable); + +private: + PropertySheet *_propertySheet; + Button *_okButton; + Button *_cancelButton; + Button *_applyButton; + + CPanelAnimationVar( int, m_iSheetInsetBottom, "sheetinset_bottom", "32" ); +}; + +}; // vgui + +#endif // PROPERTYDIALOG_H diff --git a/mp/src/public/vgui_controls/PropertyPage.h b/mp/src/public/vgui_controls/PropertyPage.h index 74b37e7c..8120ed06 100644 --- a/mp/src/public/vgui_controls/PropertyPage.h +++ b/mp/src/public/vgui_controls/PropertyPage.h @@ -1,58 +1,58 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PROPERTYPAGE_H
-#define PROPERTYPAGE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/EditablePanel.h>
-#include <vgui_controls/PHandle.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Property page, as held by a set of property sheets
-//-----------------------------------------------------------------------------
-class PropertyPage : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( PropertyPage, EditablePanel );
-
-public:
- PropertyPage(Panel *parent, const char *panelName);
- ~PropertyPage();
-
- // Called when page is loaded. Data should be reloaded from document into controls.
- MESSAGE_FUNC( OnResetData, "ResetData" );
-
- // Called when the OK / Apply button is pressed. Changed data should be written into document.
- MESSAGE_FUNC( OnApplyChanges, "ApplyChanges" );
-
- // called when the page is shown/hidden
- MESSAGE_FUNC( OnPageShow, "PageShow" );
- MESSAGE_FUNC( OnPageHide, "PageHide" );
-
- virtual void OnKeyCodeTyped(KeyCode code);
- virtual bool HasUserConfigSettings() { return true; }
-
- virtual void SetVisible(bool state);
-
-protected:
- // called to be notified of the tab button used to Activate this page
- // if overridden this must be chained back to
- MESSAGE_FUNC_PTR( OnPageTabActivated, "PageTabActivated", panel );
-
-private:
- PHandle _pageTab;
-};
-
-} // namespace vgui
-
-#endif // PROPERTYPAGE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PROPERTYPAGE_H +#define PROPERTYPAGE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/EditablePanel.h> +#include <vgui_controls/PHandle.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Property page, as held by a set of property sheets +//----------------------------------------------------------------------------- +class PropertyPage : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( PropertyPage, EditablePanel ); + +public: + PropertyPage(Panel *parent, const char *panelName); + ~PropertyPage(); + + // Called when page is loaded. Data should be reloaded from document into controls. + MESSAGE_FUNC( OnResetData, "ResetData" ); + + // Called when the OK / Apply button is pressed. Changed data should be written into document. + MESSAGE_FUNC( OnApplyChanges, "ApplyChanges" ); + + // called when the page is shown/hidden + MESSAGE_FUNC( OnPageShow, "PageShow" ); + MESSAGE_FUNC( OnPageHide, "PageHide" ); + + virtual void OnKeyCodeTyped(KeyCode code); + virtual bool HasUserConfigSettings() { return true; } + + virtual void SetVisible(bool state); + +protected: + // called to be notified of the tab button used to Activate this page + // if overridden this must be chained back to + MESSAGE_FUNC_PTR( OnPageTabActivated, "PageTabActivated", panel ); + +private: + PHandle _pageTab; +}; + +} // namespace vgui + +#endif // PROPERTYPAGE_H diff --git a/mp/src/public/vgui_controls/PropertySheet.h b/mp/src/public/vgui_controls/PropertySheet.h index ccdd76f2..d6fdf88d 100644 --- a/mp/src/public/vgui_controls/PropertySheet.h +++ b/mp/src/public/vgui_controls/PropertySheet.h @@ -1,209 +1,209 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PROPERTYSHEET_H
-#define PROPERTYSHEET_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui/VGUI.h"
-#include "vgui_controls/EditablePanel.h"
-#include "vgui_controls/PHandle.h"
-#include "utlvector.h"
-
-namespace vgui
-{
-
-class PageTab;
-class ImagePanel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Tabbed property sheet. Holds and displays a set of Panel's
-//-----------------------------------------------------------------------------
-class PropertySheet : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( PropertySheet, EditablePanel );
-
-public:
- PropertySheet(Panel *parent, const char *panelName, bool draggableTabs = false );
- PropertySheet(Panel *parent, const char *panelName,ComboBox *combo);
- ~PropertySheet();
-
- virtual bool IsDraggableTab() const;
- void SetDraggableTabs( bool state );
-
- // Adds a page to the sheet. The first page added becomes the active sheet.
- virtual void AddPage(Panel *page, const char *title, char const *imageName = NULL, bool showContextMenu = false );
-
- // sets the current page
- virtual void SetActivePage(Panel *page);
-
- // sets the width, in pixels, of the page tab buttons.
- virtual void SetTabWidth(int pixels);
-
- // Gets a pointer to the currently active page.
- virtual Panel *GetActivePage();
-
- // Removes (but doesn't delete) all pages
- virtual void RemoveAllPages();
-
- // Removes all the pages and marks all the pages for deletion.
- virtual void DeleteAllPages();
-
- // reloads the data in all the property page
- virtual void ResetAllData();
-
- // writes out any changed data to the doc
- virtual void ApplyChanges();
-
- // focus handling - passed on to current active page
- virtual void RequestFocus(int direction = 0);
- virtual bool RequestFocusPrev(VPANEL panel = NULL);
- virtual bool RequestFocusNext(VPANEL panel = NULL);
-
- // returns the ith panel
- virtual Panel *GetPage(int i);
-
- // deletes this panel from the sheet
- virtual void DeletePage(Panel *panel);
- // removes this panel from the sheet, sets its parent to NULL, but does not delete it
- virtual void RemovePage(Panel *panel);
-
- // returns the current activated tab
- virtual Panel *GetActiveTab();
-
- // returns the title text of the tab
- virtual void GetActiveTabTitle( char *textOut, int bufferLen );
-
- // returns the title of tab "i"
- virtual bool GetTabTitle( int i, char *textOut, int bufferLen );
-
- // sets the title of tab "i"
- virtual bool SetTabTitle( int i, char *pchTitle );
-
- // returns the index of the active page
- virtual int GetActivePageNum();
-
- // returns the number of pages in the sheet
- virtual int GetNumPages();
-
- // disable the page with title "title"
- virtual void DisablePage(const char *title);
-
- // enable the page with title "title"
- virtual void EnablePage(const char *title);
-
- virtual void SetSmallTabs( bool state );
- virtual bool IsSmallTabs() const;
-
- /* MESSAGES SENT TO PAGES
- "PageShow" - sent when a page is shown
- "PageHide" - sent when a page is hidden
- "ResetData" - sent when the data should be reloaded from doc
- "ApplyChanges" - sent when data should be written to doc
- */
-
- virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
- virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
- // Mouse is now over a droppable panel
- virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels );
-
- void ShowContextButtons( bool state );
- bool ShouldShowContextButtons() const;
-
- int FindPage( Panel *page ) const;
-
- bool PageHasContextMenu( Panel *page ) const;
-
- void SetKBNavigationEnabled( bool state );
- bool IsKBNavigationEnabled() const;
-
- virtual bool HasUserConfigSettings() { return true; }
-
-protected:
- virtual void PaintBorder();
- virtual void PerformLayout();
- virtual Panel *HasHotkey(wchar_t key);
- virtual void ChangeActiveTab(int index);
- virtual void OnKeyCodePressed(KeyCode code);
- virtual void OnCommand(const char *command);
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void ApplySettings(KeyValues *inResourceData);
-
- // internal message handlers
- MESSAGE_FUNC_PTR( OnTabPressed, "TabPressed", panel );
- MESSAGE_FUNC_PTR_WCHARPTR( OnTextChanged, "TextChanged", panel, text );
- MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params );
- MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" );
- // called when default button has been set
- MESSAGE_FUNC_HANDLE( OnDefaultButtonSet, "DefaultButtonSet", button );
- // called when the current default button has been set
- MESSAGE_FUNC_HANDLE( OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button);
- MESSAGE_FUNC( OnFindDefaultButton, "FindDefaultButton" );
-
-private:
-
- // enable/disable the page with title "title"
- virtual void SetPageEnabled(const char *title,bool state);
-
- struct Page_t
- {
- Page_t() :
- page( 0 ),
- contextMenu( false )
- {
- }
-
- Panel *page;
- bool contextMenu;
- };
-
- CUtlVector<Page_t> m_Pages;
- CUtlVector<PageTab *> m_PageTabs;
- Panel *_activePage;
- PageTab *_activeTab;
- int _tabWidth;
- int _activeTabIndex;
- ComboBox *_combo;
- bool _showTabs;
- bool _tabFocus;
-
- PHandle m_hPreviouslyActivePage;
- float m_flPageTransitionEffectTime;
- bool m_bSmallTabs;
- HFont m_tabFont;
- bool m_bDraggableTabs;
- bool m_bContextButton;
- bool m_bKBNavigationEnabled;
-
- CPanelAnimationVarAliasType( int, m_iTabXIndent, "tabxindent", "0", "proportional_int" );
- CPanelAnimationVarAliasType( int, m_iTabXDelta, "tabxdelta", "0", "proportional_int" );
- CPanelAnimationVarAliasType( bool, m_bTabFitText, "tabxfittotext", "1", "bool" );
-
- //=============================================================================
- // HPE_BEGIN:
- // [tj] These variables have been split into the initially specified size
- // and the currently set size. This is so we can always recalculate the
- // new value for resolution changes.
- //=============================================================================
- CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeight, "tabheight", "28", "int" );
- CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeightSmall, "tabheight_small", "14", "int" );
-
- int m_iTabHeight;
- int m_iTabHeightSmall;
- //=============================================================================
- // HPE_END
- //=============================================================================
-
- KeyValues *m_pTabKV;
-};
-
-}; // namespace vgui
-
-#endif // PROPERTYSHEET_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PROPERTYSHEET_H +#define PROPERTYSHEET_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui/VGUI.h" +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/PHandle.h" +#include "utlvector.h" + +namespace vgui +{ + +class PageTab; +class ImagePanel; + +//----------------------------------------------------------------------------- +// Purpose: Tabbed property sheet. Holds and displays a set of Panel's +//----------------------------------------------------------------------------- +class PropertySheet : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( PropertySheet, EditablePanel ); + +public: + PropertySheet(Panel *parent, const char *panelName, bool draggableTabs = false ); + PropertySheet(Panel *parent, const char *panelName,ComboBox *combo); + ~PropertySheet(); + + virtual bool IsDraggableTab() const; + void SetDraggableTabs( bool state ); + + // Adds a page to the sheet. The first page added becomes the active sheet. + virtual void AddPage(Panel *page, const char *title, char const *imageName = NULL, bool showContextMenu = false ); + + // sets the current page + virtual void SetActivePage(Panel *page); + + // sets the width, in pixels, of the page tab buttons. + virtual void SetTabWidth(int pixels); + + // Gets a pointer to the currently active page. + virtual Panel *GetActivePage(); + + // Removes (but doesn't delete) all pages + virtual void RemoveAllPages(); + + // Removes all the pages and marks all the pages for deletion. + virtual void DeleteAllPages(); + + // reloads the data in all the property page + virtual void ResetAllData(); + + // writes out any changed data to the doc + virtual void ApplyChanges(); + + // focus handling - passed on to current active page + virtual void RequestFocus(int direction = 0); + virtual bool RequestFocusPrev(VPANEL panel = NULL); + virtual bool RequestFocusNext(VPANEL panel = NULL); + + // returns the ith panel + virtual Panel *GetPage(int i); + + // deletes this panel from the sheet + virtual void DeletePage(Panel *panel); + // removes this panel from the sheet, sets its parent to NULL, but does not delete it + virtual void RemovePage(Panel *panel); + + // returns the current activated tab + virtual Panel *GetActiveTab(); + + // returns the title text of the tab + virtual void GetActiveTabTitle( char *textOut, int bufferLen ); + + // returns the title of tab "i" + virtual bool GetTabTitle( int i, char *textOut, int bufferLen ); + + // sets the title of tab "i" + virtual bool SetTabTitle( int i, char *pchTitle ); + + // returns the index of the active page + virtual int GetActivePageNum(); + + // returns the number of pages in the sheet + virtual int GetNumPages(); + + // disable the page with title "title" + virtual void DisablePage(const char *title); + + // enable the page with title "title" + virtual void EnablePage(const char *title); + + virtual void SetSmallTabs( bool state ); + virtual bool IsSmallTabs() const; + + /* MESSAGES SENT TO PAGES + "PageShow" - sent when a page is shown + "PageHide" - sent when a page is hidden + "ResetData" - sent when the data should be reloaded from doc + "ApplyChanges" - sent when data should be written to doc + */ + + virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist ); + virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist ); + // Mouse is now over a droppable panel + virtual void OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels ); + + void ShowContextButtons( bool state ); + bool ShouldShowContextButtons() const; + + int FindPage( Panel *page ) const; + + bool PageHasContextMenu( Panel *page ) const; + + void SetKBNavigationEnabled( bool state ); + bool IsKBNavigationEnabled() const; + + virtual bool HasUserConfigSettings() { return true; } + +protected: + virtual void PaintBorder(); + virtual void PerformLayout(); + virtual Panel *HasHotkey(wchar_t key); + virtual void ChangeActiveTab(int index); + virtual void OnKeyCodePressed(KeyCode code); + virtual void OnCommand(const char *command); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void ApplySettings(KeyValues *inResourceData); + + // internal message handlers + MESSAGE_FUNC_PTR( OnTabPressed, "TabPressed", panel ); + MESSAGE_FUNC_PTR_WCHARPTR( OnTextChanged, "TextChanged", panel, text ); + MESSAGE_FUNC_PARAMS( OnOpenContextMenu, "OpenContextMenu", params ); + MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" ); + // called when default button has been set + MESSAGE_FUNC_HANDLE( OnDefaultButtonSet, "DefaultButtonSet", button ); + // called when the current default button has been set + MESSAGE_FUNC_HANDLE( OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button); + MESSAGE_FUNC( OnFindDefaultButton, "FindDefaultButton" ); + +private: + + // enable/disable the page with title "title" + virtual void SetPageEnabled(const char *title,bool state); + + struct Page_t + { + Page_t() : + page( 0 ), + contextMenu( false ) + { + } + + Panel *page; + bool contextMenu; + }; + + CUtlVector<Page_t> m_Pages; + CUtlVector<PageTab *> m_PageTabs; + Panel *_activePage; + PageTab *_activeTab; + int _tabWidth; + int _activeTabIndex; + ComboBox *_combo; + bool _showTabs; + bool _tabFocus; + + PHandle m_hPreviouslyActivePage; + float m_flPageTransitionEffectTime; + bool m_bSmallTabs; + HFont m_tabFont; + bool m_bDraggableTabs; + bool m_bContextButton; + bool m_bKBNavigationEnabled; + + CPanelAnimationVarAliasType( int, m_iTabXIndent, "tabxindent", "0", "proportional_int" ); + CPanelAnimationVarAliasType( int, m_iTabXDelta, "tabxdelta", "0", "proportional_int" ); + CPanelAnimationVarAliasType( bool, m_bTabFitText, "tabxfittotext", "1", "bool" ); + + //============================================================================= + // HPE_BEGIN: + // [tj] These variables have been split into the initially specified size + // and the currently set size. This is so we can always recalculate the + // new value for resolution changes. + //============================================================================= + CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeight, "tabheight", "28", "int" ); + CPanelAnimationVarAliasType( int, m_iSpecifiedTabHeightSmall, "tabheight_small", "14", "int" ); + + int m_iTabHeight; + int m_iTabHeightSmall; + //============================================================================= + // HPE_END + //============================================================================= + + KeyValues *m_pTabKV; +}; + +}; // namespace vgui + +#endif // PROPERTYSHEET_H diff --git a/mp/src/public/vgui_controls/QueryBox.h b/mp/src/public/vgui_controls/QueryBox.h index d3df48d5..40e6e46f 100644 --- a/mp/src/public/vgui_controls/QueryBox.h +++ b/mp/src/public/vgui_controls/QueryBox.h @@ -1,62 +1,62 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Creates a Message box with a question in it and yes/no buttons
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef QUERYBOX_H
-#define QUERYBOX_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <KeyValues.h>
-#include <vgui_controls/MessageBox.h>
-#include <vgui_controls/Button.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Creates A Message box with a question in it and yes/no buttons
-//-----------------------------------------------------------------------------
-class QueryBox : public MessageBox
-{
- DECLARE_CLASS_SIMPLE( QueryBox, MessageBox );
-
-public:
- QueryBox(const char *title, const char *queryText,vgui::Panel *parent = NULL );
- QueryBox(const wchar_t *wszTitle, const wchar_t *wszQueryText,vgui::Panel *parent = NULL);
- ~QueryBox();
-
- // Layout the window for drawing
- virtual void PerformLayout();
-
- // Set the keyvalues to send when ok button is hit
- void SetOKCommand(KeyValues *keyValues);
-
- // Set the keyvalues to send when the cancel button is hit
- void SetCancelCommand(KeyValues *keyValues);
-
- // Set the text on the Cancel button
- void SetCancelButtonText(const char *buttonText);
- void SetCancelButtonText(const wchar_t *wszButtonText);
-
- // Set a value of the ok command
- void SetOKCommandValue(const char *keyName, int value);
-
-protected:
- virtual void OnKeyCodeTyped( KeyCode code );
- virtual void OnKeyCodePressed( KeyCode code );
- virtual void OnCommand(const char *command);
- Button *m_pCancelButton;
-
-private:
- KeyValues *m_pCancelCommand;
- KeyValues *m_pOkCommand;
-};
-
-}
-#endif // QUERYBOX_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Creates a Message box with a question in it and yes/no buttons +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef QUERYBOX_H +#define QUERYBOX_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <KeyValues.h> +#include <vgui_controls/MessageBox.h> +#include <vgui_controls/Button.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Creates A Message box with a question in it and yes/no buttons +//----------------------------------------------------------------------------- +class QueryBox : public MessageBox +{ + DECLARE_CLASS_SIMPLE( QueryBox, MessageBox ); + +public: + QueryBox(const char *title, const char *queryText,vgui::Panel *parent = NULL ); + QueryBox(const wchar_t *wszTitle, const wchar_t *wszQueryText,vgui::Panel *parent = NULL); + ~QueryBox(); + + // Layout the window for drawing + virtual void PerformLayout(); + + // Set the keyvalues to send when ok button is hit + void SetOKCommand(KeyValues *keyValues); + + // Set the keyvalues to send when the cancel button is hit + void SetCancelCommand(KeyValues *keyValues); + + // Set the text on the Cancel button + void SetCancelButtonText(const char *buttonText); + void SetCancelButtonText(const wchar_t *wszButtonText); + + // Set a value of the ok command + void SetOKCommandValue(const char *keyName, int value); + +protected: + virtual void OnKeyCodeTyped( KeyCode code ); + virtual void OnKeyCodePressed( KeyCode code ); + virtual void OnCommand(const char *command); + Button *m_pCancelButton; + +private: + KeyValues *m_pCancelCommand; + KeyValues *m_pOkCommand; +}; + +} +#endif // QUERYBOX_H diff --git a/mp/src/public/vgui_controls/RadioButton.h b/mp/src/public/vgui_controls/RadioButton.h index b48c64b5..c21abbad 100644 --- a/mp/src/public/vgui_controls/RadioButton.h +++ b/mp/src/public/vgui_controls/RadioButton.h @@ -1,112 +1,112 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef RADIOBUTTON_H
-#define RADIOBUTTON_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/ToggleButton.h>
-#include <vgui_controls/TextImage.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Radio buton image
-//-----------------------------------------------------------------------------
-class RadioImage : public TextImage
-{
-public:
- RadioImage(RadioButton *radioButton) : TextImage( "n" )
- {
- _radioButton = radioButton;
-
- SetSize(20, 13);
- }
-
- virtual void Paint();
-
- virtual void SetColor(Color color)
- {
- _borderColor1 = color;
- _borderColor2 = color;
- _checkColor = color;
- }
-
- Color _borderColor1;
- Color _borderColor2;
- Color _checkColor;
-
- Color _bgColor;
-
-private:
- RadioButton *_radioButton;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Radio buttons are automatically selected into groups by who their
-// parent is. At most one radio button is active at any time.
-//-----------------------------------------------------------------------------
-class RadioButton : public ToggleButton
-{
- DECLARE_CLASS_SIMPLE( RadioButton, ToggleButton );
-
-public:
- RadioButton(Panel *parent, const char *panelName, const char *text);
- ~RadioButton();
-
- // Set the radio button checked. When a radio button is checked, a
- // message is sent to all other radio buttons in the same group so
- // they will become unchecked.
- virtual void SetSelected(bool state);
-
- // Get the tab position of the radio button with the set of radio buttons
- // A group of RadioButtons must have the same TabPosition, with [1, n] subtabpositions
- virtual int GetSubTabPosition();
- virtual void SetSubTabPosition(int position);
-
- // Return the RadioButton's real tab position (its Panel one changes)
- virtual int GetRadioTabPosition();
-
- // Set the selection state of the radio button, but don't fire
- // any action signals or messages to other radio buttons
- virtual void SilentSetSelected(bool state);
-
-protected:
- virtual void DoClick();
-
- virtual void Paint();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_INT( OnRadioButtonChecked, "RadioButtonChecked", tabposition);
- virtual void OnKeyCodeTyped(KeyCode code);
-
- virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus);
-
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void GetSettings(KeyValues *outResourceData);
- virtual const char *GetDescription();
- virtual void PerformLayout();
-
- RadioButton *FindBestRadioButton(int direction);
-
-private:
- RadioImage *_radioBoxImage;
- int _oldTabPosition;
- Color _selectedFgColor;
-
- int _subTabPosition; // tab position with the radio button list
-
- void InternalSetSelected(bool state, bool bFireEvents);
-};
-
-}; // namespace vgui
-
-#endif // RADIOBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef RADIOBUTTON_H +#define RADIOBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/ToggleButton.h> +#include <vgui_controls/TextImage.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Radio buton image +//----------------------------------------------------------------------------- +class RadioImage : public TextImage +{ +public: + RadioImage(RadioButton *radioButton) : TextImage( "n" ) + { + _radioButton = radioButton; + + SetSize(20, 13); + } + + virtual void Paint(); + + virtual void SetColor(Color color) + { + _borderColor1 = color; + _borderColor2 = color; + _checkColor = color; + } + + Color _borderColor1; + Color _borderColor2; + Color _checkColor; + + Color _bgColor; + +private: + RadioButton *_radioButton; +}; + +//----------------------------------------------------------------------------- +// Purpose: Radio buttons are automatically selected into groups by who their +// parent is. At most one radio button is active at any time. +//----------------------------------------------------------------------------- +class RadioButton : public ToggleButton +{ + DECLARE_CLASS_SIMPLE( RadioButton, ToggleButton ); + +public: + RadioButton(Panel *parent, const char *panelName, const char *text); + ~RadioButton(); + + // Set the radio button checked. When a radio button is checked, a + // message is sent to all other radio buttons in the same group so + // they will become unchecked. + virtual void SetSelected(bool state); + + // Get the tab position of the radio button with the set of radio buttons + // A group of RadioButtons must have the same TabPosition, with [1, n] subtabpositions + virtual int GetSubTabPosition(); + virtual void SetSubTabPosition(int position); + + // Return the RadioButton's real tab position (its Panel one changes) + virtual int GetRadioTabPosition(); + + // Set the selection state of the radio button, but don't fire + // any action signals or messages to other radio buttons + virtual void SilentSetSelected(bool state); + +protected: + virtual void DoClick(); + + virtual void Paint(); + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_INT( OnRadioButtonChecked, "RadioButtonChecked", tabposition); + virtual void OnKeyCodeTyped(KeyCode code); + + virtual IBorder *GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + + virtual void ApplySettings(KeyValues *inResourceData); + virtual void GetSettings(KeyValues *outResourceData); + virtual const char *GetDescription(); + virtual void PerformLayout(); + + RadioButton *FindBestRadioButton(int direction); + +private: + RadioImage *_radioBoxImage; + int _oldTabPosition; + Color _selectedFgColor; + + int _subTabPosition; // tab position with the radio button list + + void InternalSetSelected(bool state, bool bFireEvents); +}; + +}; // namespace vgui + +#endif // RADIOBUTTON_H diff --git a/mp/src/public/vgui_controls/RichText.h b/mp/src/public/vgui_controls/RichText.h index ea54285a..704ef08b 100644 --- a/mp/src/public/vgui_controls/RichText.h +++ b/mp/src/public/vgui_controls/RichText.h @@ -1,297 +1,297 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef RICHTEXT_H
-#define RICHTEXT_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Panel.h>
-#include <utlvector.h>
-
-namespace vgui
-{
-
-class ClickPanel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Non-editable display of a rich text control
-//-----------------------------------------------------------------------------
-class RichText : public Panel
-{
- DECLARE_CLASS_SIMPLE( RichText, Panel );
-
-public:
- RichText(Panel *parent, const char *panelName);
- ~RichText();
-
- // text manipulation
- virtual void SetText(const char *text);
- virtual void SetText(const wchar_t *text);
- void GetText(int offset, OUT_Z_BYTECAP(bufLenInBytes) wchar_t *buf, int bufLenInBytes);
- void GetText(int offset, OUT_Z_BYTECAP(bufLenInBytes) char *pch, int bufLenInBytes);
-
- // configuration
- void SetFont(HFont font);
-
- // inserts characters at the end of the stream
- void InsertChar(wchar_t ch);
- void InsertString(const char *text);
- void InsertString(const wchar_t *wszText);
-
- // selection
- void SelectNone();
- void SelectAllText();
- void SelectNoText();
- MESSAGE_FUNC( CutSelected, "DoCutSelected" );
- MESSAGE_FUNC( CopySelected, "DoCopySelected" );
-
- // sets the RichText control interactive or not (meaning you can select/copy text in the window)
- void SetPanelInteractive( bool bInteractive ){ m_bInteractive = bInteractive; }
-
- // sets the RichText scrollbar invisible if it's not going to be used
- void SetUnusedScrollbarInvisible( bool bInvis ){ m_bUnusedScrollbarInvis = bInvis; }
-
- // cursor movement
- void GotoTextStart(); // go to start of text buffer
- void GotoTextEnd(); // go to end of text buffer
-
- // configuration
- // sets visibility of scrollbar
- void SetVerticalScrollbar(bool state);
- // sets limit of number of characters insertable into field; set to -1 to remove maximum
- // only works with if rich-edit is NOT enabled
- void SetMaximumCharCount(int maxChars);
-
- // rich edit commands
- void InsertColorChange(Color col);
- // IndentChange doesn't take effect until the next newline character
- void InsertIndentChange(int pixelsIndent);
- // clickable text
- // notification that text was clicked is through "TextClicked" message
- void InsertClickableTextStart( const char *pchClickAction = NULL );
- void InsertClickableTextEnd();
- // inserts a string that needs to be scanned for urls/mailto commands to be made clickable
- void InsertPossibleURLString(const char *text, Color URLTextColor, Color normalTextColor);
-
- void InsertFade( float flSustain, float flLength );
-
- void ResetAllFades( bool bHold, bool bOnlyExpired = false, float flNewSustain = -1.0f );
-
- // sets the height of the window so all text is visible.
- // used by tooltips
- void SetToFullHeight();
- int GetNumLines();
-
- /* CUSTOM MESSAGE HANDLING
- "SetText"
- input: "text" - text is set to be this string
- */
-
- /* MESSAGE SENDING (to action signal targets)
- "TextChanged" - sent when the text is edited by the user
-
-
- "TextClicked" - sent when clickable text has been clicked on
- "text" - the text that was clicked on
- */
-
- virtual bool RequestInfo(KeyValues *outputData);
- /* INFO HANDLING
- "GetText"
- returns:
- "text" - text contained in the text box
- */
- virtual void SetFgColor( Color color );
- virtual void SetDrawOffsets( int ofsx, int ofsy );
- bool IsScrollbarVisible();
-
- // sets how URL's are handled
- // if set, a "URLClicked" "url" "<data>" message will be sent to that panel
- void SetURLClickedHandler( Panel *pPanelToHandleClickMsg );
-
- void SetUnderlineFont( HFont font );
-
- bool IsAllTextAlphaZero() const;
- bool HasText() const;
-
- void SetDrawTextOnly();
-
-protected:
- virtual void OnThink();
- virtual void PerformLayout(); // layout the text in the window
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void Paint();
-
- virtual void ApplySettings( KeyValues *inResourceData );
- virtual void GetSettings( KeyValues *outResourceData );
- virtual const char *GetDescription( void );
- MESSAGE_FUNC_WCHARPTR( OnSetText, "SetText", text );
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); // respond to scroll bar events
- virtual void OnKillFocus();
- virtual void OnMouseWheeled(int delta); // respond to mouse wheel events
- virtual void OnKeyCodeTyped(KeyCode code); //respond to keyboard events
-
- MESSAGE_FUNC_INT( OnClickPanel, "ClickPanel", index);
-
- virtual void OnCursorMoved(int x, int y); // respond to moving the cursor with mouse button down
- virtual void OnMousePressed(MouseCode code); // respond to mouse down events
- virtual void OnMouseDoublePressed(MouseCode code);
- virtual void OnMouseReleased(MouseCode code); // respond to mouse up events
-
- virtual void OnMouseFocusTicked(); // do while window has mouse focus
- virtual void OnCursorEntered(); // handle cursor entering window
- virtual void OnCursorExited(); // handle cursor exiting window
-
- virtual void OnMouseCaptureLost();
- virtual void OnSizeChanged(int newWide, int newTall);
- virtual void OnSetFocus();
-
- // clickable url handling
- int ParseTextStringForUrls(const char *text, int startPos, char *pchURLText, int cchURLText, char *pchURL, int cchURL, bool &clickable);
- virtual void OnTextClicked(const wchar_t *text);
-
-#ifdef DBGFLAG_VALIDATE
- virtual void Validate( CValidator &validator, char *pchName );
-#endif // DBGFLAG_VALIDATE
-
-protected:
- ScrollBar *_vertScrollBar; // the scroll bar used in the window
-
-private:
- int GetLineHeight();
- HFont GetDefaultFont();
-
- const wchar_t *ResolveLocalizedTextAndVariables( char const *pchLookup, OUT_Z_BYTECAP(outbufsizeinbytes) wchar_t *outbuf, size_t outbufsizeinbytes );
- void CheckRecalcLineBreaks();
-
- void GotoWordRight(); // move cursor to start of next word
- void GotoWordLeft(); // move cursor to start of prev word
-
- void TruncateTextStream();
- bool GetSelectedRange(int& cx0,int& cx1);
- void CursorToPixelSpace(int cursorPos, int &cx, int &cy);
- int PixelToCursorSpace(int cx, int cy);
- void AddAnotherLine(int &cx, int &cy);
- void RecalculateDefaultState(int startIndex);
-
- void LayoutVerticalScrollBarSlider();
- void OpenEditMenu();
- void FinishingURL(int x, int y);
- // Returns the character index the drawing should Start at
- int GetStartDrawIndex(int &lineBreakIndexIndex);
- int GetCursorLine();
- int GetClickableTextIndexStart(int startIndex);
- void CreateEditMenu(); // create copy/cut/paste menu
-
- MESSAGE_FUNC_INT( MoveScrollBar, "MoveScrollBar", delta );
- MESSAGE_FUNC_INT( MoveScrollBarDirect, "MoveScrollBarDirect", delta );
-
- // linebreak stream functions
- void InvalidateLineBreakStream();
- void RecalculateLineBreaks();
-
- struct TFade
- {
- float flFadeStartTime;
- float flFadeLength;
- float flFadeSustain;
- int iOriginalAlpha;
- };
-
- // format stream - describes changes in formatting for the text stream
- struct TFormatStream
- {
- // render state
- Color color;
- int pixelsIndent;
- bool textClickable;
- CUtlSymbol m_sClickableTextAction;
-
- TFade fade;
-
- // position in TextStream that these changes take effect
- int textStreamIndex;
- };
-
- bool m_bResetFades;
- bool m_bInteractive;
- bool m_bUnusedScrollbarInvis;
- bool m_bAllTextAlphaIsZero;
-
- // data
- CUtlVector<wchar_t> m_TextStream; // the text in the text window is stored in this buffer
- CUtlVector<int> m_LineBreaks; // an array that holds the index in the buffer to wrap lines at
- CUtlVector<TFormatStream> m_FormatStream; // list of format changes
-
- bool m_bRecalcLineBreaks;
-
- int _recalculateBreaksIndex; // tells next linebreakindex index to Start recalculating line breaks
- bool _invalidateVerticalScrollbarSlider;
- int _cursorPos; // the position in the text buffer of the blinking cursor
- bool _mouseSelection; // whether we are highlighting text or not (selecting text)
- bool _mouseDragSelection; // tells weather mouse is outside window and button is down so we select text
- int _select[2]; // select[1] is the offset in the text to where the cursor is currently
- // select[0] is the offset to where the cursor was dragged to. or -1 if no drag.
- int _pixelsIndent;
- int _maxCharCount; // max number of chars that can be in the text buffer
- HFont _font; // font of chars in the text buffer
- HFont m_hFontUnderline;
- Color _selectionColor;
- Color _selectionTextColor; // color of the highlighted text
- bool _currentTextClickable;
- CUtlVector<ClickPanel *> _clickableTextPanels;
- int _clickableTextIndex;
- Color _defaultTextColor;
- int _drawOffsetX;
- int _drawOffsetY;
-
- Panel *m_pInterior;
- PHandle m_hPanelToHandleClickingURLs;
-
-
- // sub-controls
- Menu *m_pEditMenu; // cut/copy/paste popup
-
- char *m_pszInitialText; // initial text
-
- // saved state
- bool _recalcSavedRenderState;
-
- struct TRenderState
- {
- // rendering positions
- int x, y;
-
- // basic state
- Color textColor;
- int pixelsIndent;
- bool textClickable;
-
- // index into our current position in the formatting stream
- int formatStreamIndex;
- };
- TRenderState m_CachedRenderState; // cached render state for the beginning of painting
-
- // updates a render state based on the formatting and color streams
- // returns true if any state changed
- bool UpdateRenderState(int textStreamPos, TRenderState &renderState);
- void CalculateFade( TRenderState &renderState );
-
- void GenerateRenderStateForTextStreamIndex(int textStreamIndex, TRenderState &renderState);
- int FindFormatStreamIndexForTextStreamPos(int textStreamIndex);
-
- // draws a string of characters with the same formatting using the current render state
- int DrawString(int iFirst, int iLast, TRenderState &renderState, HFont font);
-};
-
-} // namespace vgui
-
-
-#endif // RICHTEXT_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef RICHTEXT_H +#define RICHTEXT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Panel.h> +#include <utlvector.h> + +namespace vgui +{ + +class ClickPanel; + +//----------------------------------------------------------------------------- +// Purpose: Non-editable display of a rich text control +//----------------------------------------------------------------------------- +class RichText : public Panel +{ + DECLARE_CLASS_SIMPLE( RichText, Panel ); + +public: + RichText(Panel *parent, const char *panelName); + ~RichText(); + + // text manipulation + virtual void SetText(const char *text); + virtual void SetText(const wchar_t *text); + void GetText(int offset, OUT_Z_BYTECAP(bufLenInBytes) wchar_t *buf, int bufLenInBytes); + void GetText(int offset, OUT_Z_BYTECAP(bufLenInBytes) char *pch, int bufLenInBytes); + + // configuration + void SetFont(HFont font); + + // inserts characters at the end of the stream + void InsertChar(wchar_t ch); + void InsertString(const char *text); + void InsertString(const wchar_t *wszText); + + // selection + void SelectNone(); + void SelectAllText(); + void SelectNoText(); + MESSAGE_FUNC( CutSelected, "DoCutSelected" ); + MESSAGE_FUNC( CopySelected, "DoCopySelected" ); + + // sets the RichText control interactive or not (meaning you can select/copy text in the window) + void SetPanelInteractive( bool bInteractive ){ m_bInteractive = bInteractive; } + + // sets the RichText scrollbar invisible if it's not going to be used + void SetUnusedScrollbarInvisible( bool bInvis ){ m_bUnusedScrollbarInvis = bInvis; } + + // cursor movement + void GotoTextStart(); // go to start of text buffer + void GotoTextEnd(); // go to end of text buffer + + // configuration + // sets visibility of scrollbar + void SetVerticalScrollbar(bool state); + // sets limit of number of characters insertable into field; set to -1 to remove maximum + // only works with if rich-edit is NOT enabled + void SetMaximumCharCount(int maxChars); + + // rich edit commands + void InsertColorChange(Color col); + // IndentChange doesn't take effect until the next newline character + void InsertIndentChange(int pixelsIndent); + // clickable text + // notification that text was clicked is through "TextClicked" message + void InsertClickableTextStart( const char *pchClickAction = NULL ); + void InsertClickableTextEnd(); + // inserts a string that needs to be scanned for urls/mailto commands to be made clickable + void InsertPossibleURLString(const char *text, Color URLTextColor, Color normalTextColor); + + void InsertFade( float flSustain, float flLength ); + + void ResetAllFades( bool bHold, bool bOnlyExpired = false, float flNewSustain = -1.0f ); + + // sets the height of the window so all text is visible. + // used by tooltips + void SetToFullHeight(); + int GetNumLines(); + + /* CUSTOM MESSAGE HANDLING + "SetText" + input: "text" - text is set to be this string + */ + + /* MESSAGE SENDING (to action signal targets) + "TextChanged" - sent when the text is edited by the user + + + "TextClicked" - sent when clickable text has been clicked on + "text" - the text that was clicked on + */ + + virtual bool RequestInfo(KeyValues *outputData); + /* INFO HANDLING + "GetText" + returns: + "text" - text contained in the text box + */ + virtual void SetFgColor( Color color ); + virtual void SetDrawOffsets( int ofsx, int ofsy ); + bool IsScrollbarVisible(); + + // sets how URL's are handled + // if set, a "URLClicked" "url" "<data>" message will be sent to that panel + void SetURLClickedHandler( Panel *pPanelToHandleClickMsg ); + + void SetUnderlineFont( HFont font ); + + bool IsAllTextAlphaZero() const; + bool HasText() const; + + void SetDrawTextOnly(); + +protected: + virtual void OnThink(); + virtual void PerformLayout(); // layout the text in the window + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void Paint(); + + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void GetSettings( KeyValues *outResourceData ); + virtual const char *GetDescription( void ); + MESSAGE_FUNC_WCHARPTR( OnSetText, "SetText", text ); + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); // respond to scroll bar events + virtual void OnKillFocus(); + virtual void OnMouseWheeled(int delta); // respond to mouse wheel events + virtual void OnKeyCodeTyped(KeyCode code); //respond to keyboard events + + MESSAGE_FUNC_INT( OnClickPanel, "ClickPanel", index); + + virtual void OnCursorMoved(int x, int y); // respond to moving the cursor with mouse button down + virtual void OnMousePressed(MouseCode code); // respond to mouse down events + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); // respond to mouse up events + + virtual void OnMouseFocusTicked(); // do while window has mouse focus + virtual void OnCursorEntered(); // handle cursor entering window + virtual void OnCursorExited(); // handle cursor exiting window + + virtual void OnMouseCaptureLost(); + virtual void OnSizeChanged(int newWide, int newTall); + virtual void OnSetFocus(); + + // clickable url handling + int ParseTextStringForUrls(const char *text, int startPos, char *pchURLText, int cchURLText, char *pchURL, int cchURL, bool &clickable); + virtual void OnTextClicked(const wchar_t *text); + +#ifdef DBGFLAG_VALIDATE + virtual void Validate( CValidator &validator, char *pchName ); +#endif // DBGFLAG_VALIDATE + +protected: + ScrollBar *_vertScrollBar; // the scroll bar used in the window + +private: + int GetLineHeight(); + HFont GetDefaultFont(); + + const wchar_t *ResolveLocalizedTextAndVariables( char const *pchLookup, OUT_Z_BYTECAP(outbufsizeinbytes) wchar_t *outbuf, size_t outbufsizeinbytes ); + void CheckRecalcLineBreaks(); + + void GotoWordRight(); // move cursor to start of next word + void GotoWordLeft(); // move cursor to start of prev word + + void TruncateTextStream(); + bool GetSelectedRange(int& cx0,int& cx1); + void CursorToPixelSpace(int cursorPos, int &cx, int &cy); + int PixelToCursorSpace(int cx, int cy); + void AddAnotherLine(int &cx, int &cy); + void RecalculateDefaultState(int startIndex); + + void LayoutVerticalScrollBarSlider(); + void OpenEditMenu(); + void FinishingURL(int x, int y); + // Returns the character index the drawing should Start at + int GetStartDrawIndex(int &lineBreakIndexIndex); + int GetCursorLine(); + int GetClickableTextIndexStart(int startIndex); + void CreateEditMenu(); // create copy/cut/paste menu + + MESSAGE_FUNC_INT( MoveScrollBar, "MoveScrollBar", delta ); + MESSAGE_FUNC_INT( MoveScrollBarDirect, "MoveScrollBarDirect", delta ); + + // linebreak stream functions + void InvalidateLineBreakStream(); + void RecalculateLineBreaks(); + + struct TFade + { + float flFadeStartTime; + float flFadeLength; + float flFadeSustain; + int iOriginalAlpha; + }; + + // format stream - describes changes in formatting for the text stream + struct TFormatStream + { + // render state + Color color; + int pixelsIndent; + bool textClickable; + CUtlSymbol m_sClickableTextAction; + + TFade fade; + + // position in TextStream that these changes take effect + int textStreamIndex; + }; + + bool m_bResetFades; + bool m_bInteractive; + bool m_bUnusedScrollbarInvis; + bool m_bAllTextAlphaIsZero; + + // data + CUtlVector<wchar_t> m_TextStream; // the text in the text window is stored in this buffer + CUtlVector<int> m_LineBreaks; // an array that holds the index in the buffer to wrap lines at + CUtlVector<TFormatStream> m_FormatStream; // list of format changes + + bool m_bRecalcLineBreaks; + + int _recalculateBreaksIndex; // tells next linebreakindex index to Start recalculating line breaks + bool _invalidateVerticalScrollbarSlider; + int _cursorPos; // the position in the text buffer of the blinking cursor + bool _mouseSelection; // whether we are highlighting text or not (selecting text) + bool _mouseDragSelection; // tells weather mouse is outside window and button is down so we select text + int _select[2]; // select[1] is the offset in the text to where the cursor is currently + // select[0] is the offset to where the cursor was dragged to. or -1 if no drag. + int _pixelsIndent; + int _maxCharCount; // max number of chars that can be in the text buffer + HFont _font; // font of chars in the text buffer + HFont m_hFontUnderline; + Color _selectionColor; + Color _selectionTextColor; // color of the highlighted text + bool _currentTextClickable; + CUtlVector<ClickPanel *> _clickableTextPanels; + int _clickableTextIndex; + Color _defaultTextColor; + int _drawOffsetX; + int _drawOffsetY; + + Panel *m_pInterior; + PHandle m_hPanelToHandleClickingURLs; + + + // sub-controls + Menu *m_pEditMenu; // cut/copy/paste popup + + char *m_pszInitialText; // initial text + + // saved state + bool _recalcSavedRenderState; + + struct TRenderState + { + // rendering positions + int x, y; + + // basic state + Color textColor; + int pixelsIndent; + bool textClickable; + + // index into our current position in the formatting stream + int formatStreamIndex; + }; + TRenderState m_CachedRenderState; // cached render state for the beginning of painting + + // updates a render state based on the formatting and color streams + // returns true if any state changed + bool UpdateRenderState(int textStreamPos, TRenderState &renderState); + void CalculateFade( TRenderState &renderState ); + + void GenerateRenderStateForTextStreamIndex(int textStreamIndex, TRenderState &renderState); + int FindFormatStreamIndexForTextStreamPos(int textStreamIndex); + + // draws a string of characters with the same formatting using the current render state + int DrawString(int iFirst, int iLast, TRenderState &renderState, HFont font); +}; + +} // namespace vgui + + +#endif // RICHTEXT_H diff --git a/mp/src/public/vgui_controls/RotatingProgressBar.h b/mp/src/public/vgui_controls/RotatingProgressBar.h index e06e3dcd..400838c3 100644 --- a/mp/src/public/vgui_controls/RotatingProgressBar.h +++ b/mp/src/public/vgui_controls/RotatingProgressBar.h @@ -1,67 +1,67 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef ROTATINGPROGRESSBAR_H
-#define ROTATINGPROGRESSBAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/ProgressBar.h>
-
-namespace vgui
-{
-
- //-----------------------------------------------------------------------------
- // Purpose: Progress Bar that rotates an image around its center
- //-----------------------------------------------------------------------------
- class RotatingProgressBar : public ProgressBar
- {
- DECLARE_CLASS_SIMPLE( RotatingProgressBar, ProgressBar );
-
- public:
- RotatingProgressBar(Panel *parent, const char *panelName);
- ~RotatingProgressBar();
-
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
- void SetImage( const char *imageName );
-
- protected:
- virtual void Paint();
- virtual void PaintBackground();
- virtual void OnTick();
-
- private:
- int m_nTextureId;
- char *m_pszImageName;
-
- float m_flStartRadians;
- float m_flEndRadians;
-
- float m_flLastAngle;
-
- float m_flTickDelay;
- float m_flApproachSpeed;
-
- float m_flRotOriginX;
- float m_flRotOriginY;
-
- float m_flRotatingX;
- float m_flRotatingY;
- float m_flRotatingWide;
- float m_flRotatingTall;
-
- };
-
-} // namespace vgui
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef ROTATINGPROGRESSBAR_H +#define ROTATINGPROGRESSBAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> +#include <vgui_controls/ProgressBar.h> + +namespace vgui +{ + + //----------------------------------------------------------------------------- + // Purpose: Progress Bar that rotates an image around its center + //----------------------------------------------------------------------------- + class RotatingProgressBar : public ProgressBar + { + DECLARE_CLASS_SIMPLE( RotatingProgressBar, ProgressBar ); + + public: + RotatingProgressBar(Panel *parent, const char *panelName); + ~RotatingProgressBar(); + + virtual void ApplySettings(KeyValues *inResourceData); + virtual void ApplySchemeSettings(IScheme *pScheme); + + void SetImage( const char *imageName ); + + protected: + virtual void Paint(); + virtual void PaintBackground(); + virtual void OnTick(); + + private: + int m_nTextureId; + char *m_pszImageName; + + float m_flStartRadians; + float m_flEndRadians; + + float m_flLastAngle; + + float m_flTickDelay; + float m_flApproachSpeed; + + float m_flRotOriginX; + float m_flRotOriginY; + + float m_flRotatingX; + float m_flRotatingY; + float m_flRotatingWide; + float m_flRotatingTall; + + }; + +} // namespace vgui + #endif // ROTATINGPROGRESSBAR_H
\ No newline at end of file diff --git a/mp/src/public/vgui_controls/ScalableImagePanel.h b/mp/src/public/vgui_controls/ScalableImagePanel.h index f86b9b25..7c4f1b7a 100644 --- a/mp/src/public/vgui_controls/ScalableImagePanel.h +++ b/mp/src/public/vgui_controls/ScalableImagePanel.h @@ -1,59 +1,59 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef SCALABLEIMAGEPANEL_H
-#define SCALABLEIMAGEPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
- //-----------------------------------------------------------------------------
- // Purpose: 9-way Segmented background
- //-----------------------------------------------------------------------------
- class ScalableImagePanel : public Panel
- {
- DECLARE_CLASS_SIMPLE( ScalableImagePanel, Panel );
- public:
- ScalableImagePanel(Panel *parent, const char *name);
- ~ScalableImagePanel();
-
- virtual void SetImage(const char *imageName);
- void SetDrawColor( Color color ) { m_DrawColor = color; }
-
- protected:
- virtual void PaintBackground();
- virtual void GetSettings(KeyValues *outResourceData);
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void PerformLayout( void );
- virtual const char *GetDescription();
-
- private:
- int m_iSrcCornerHeight; // in pixels, how tall is the corner inside the image
- int m_iSrcCornerWidth; // same for width
- int m_iCornerHeight; // output size of the corner height in pixels
- int m_iCornerWidth; // same for width
-
- int m_iTextureID;
-
- float m_flCornerWidthPercent; // corner width as percentage of image width
- float m_flCornerHeightPercent; // same for height
-
- char *m_pszImageName;
-
- char *m_pszDrawColorName;
- Color m_DrawColor;
- };
-
-} // namespace vgui
-
-#endif // SCALABLEIMAGEPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef SCALABLEIMAGEPANEL_H +#define SCALABLEIMAGEPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + //----------------------------------------------------------------------------- + // Purpose: 9-way Segmented background + //----------------------------------------------------------------------------- + class ScalableImagePanel : public Panel + { + DECLARE_CLASS_SIMPLE( ScalableImagePanel, Panel ); + public: + ScalableImagePanel(Panel *parent, const char *name); + ~ScalableImagePanel(); + + virtual void SetImage(const char *imageName); + void SetDrawColor( Color color ) { m_DrawColor = color; } + + protected: + virtual void PaintBackground(); + virtual void GetSettings(KeyValues *outResourceData); + virtual void ApplySettings(KeyValues *inResourceData); + virtual void PerformLayout( void ); + virtual const char *GetDescription(); + + private: + int m_iSrcCornerHeight; // in pixels, how tall is the corner inside the image + int m_iSrcCornerWidth; // same for width + int m_iCornerHeight; // output size of the corner height in pixels + int m_iCornerWidth; // same for width + + int m_iTextureID; + + float m_flCornerWidthPercent; // corner width as percentage of image width + float m_flCornerHeightPercent; // same for height + + char *m_pszImageName; + + char *m_pszDrawColorName; + Color m_DrawColor; + }; + +} // namespace vgui + +#endif // SCALABLEIMAGEPANEL_H diff --git a/mp/src/public/vgui_controls/ScrollBar.h b/mp/src/public/vgui_controls/ScrollBar.h index dcee9b01..c22e3a59 100644 --- a/mp/src/public/vgui_controls/ScrollBar.h +++ b/mp/src/public/vgui_controls/ScrollBar.h @@ -1,133 +1,133 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef SCROLLBAR_H
-#define SCROLLBAR_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-class Button;
-class ScrollBarSlider;
-
-//-----------------------------------------------------------------------------
-// Purpose: Generic scrollbar
-// Uses Buttons & SliderBars for the main functionality
-//-----------------------------------------------------------------------------
-class ScrollBar : public Panel
-{
- DECLARE_CLASS_SIMPLE( ScrollBar, Panel );
-
-public:
- ScrollBar(Panel *parent, const char *panelName, bool vertical);
-
- // Set the value of the scroll bar slider.
- virtual void SetValue(int value);
-
- // Get the value of the scroll bar slider.
- virtual int GetValue();
-
- // Set the rangeof numbers the slider can scroll through
- virtual void SetRange(int min,int max);
-
- virtual void GetRange(int &min, int &max);
-
- // Set how many lines are displayed at one time
- // in the window the scroll bar is attached to.
- virtual void SetRangeWindow(int rangeWindow);
-
- // Get how many lines are displayed at one time
- // in the window the scroll bar is attached to.
- virtual int GetRangeWindow();
-
- // Check if the scrollbar is vertical or horizontal
- virtual bool IsVertical();
-
- // Purpose: Check if the slider can move through one or more pixels per
- // unit of its range.
- virtual bool HasFullRange();
-
- // Setup the indexed scroll bar button with the input params.
- virtual void SetButton(Button* button,int index);
- // Return the indexed scroll bar button
- virtual Button *GetButton(int index);
- // Set up the slider.
- virtual void SetSlider(ScrollBarSlider* slider);
- // Return a pointer to the slider.
- virtual ScrollBarSlider *GetSlider();
- // Set how far the scroll bar slider moves
- // when a scroll bar button is pressed
- virtual void SetButtonPressedScrollValue(int value);
-
- virtual void Validate();
-
- // Update and look for clicks when mouse is in the scroll bar window.
- virtual void OnMouseFocusTicked();
-
- // Set the slider's Paint border enabled.
- virtual void SetPaintBorderEnabled(bool state);
- // Set the slider's Paint background enabled.
- virtual void SetPaintBackgroundEnabled(bool state);
- // Set the slider's Paint enabled.
- virtual void SetPaintEnabled(bool state);
-
- // Sets the scrollbar buttons visible or not
- virtual void SetScrollbarButtonsVisible(bool visible);
-
- void SetAutohideButtons( bool bAutohide ) { m_bAutoHideButtons = bAutohide; }
-
- void UseImages( const char *pszUpArrow, const char *pszDownArrow, const char *pszLine, const char *pszBox );
-
- /* MESSAGES SENT:
- "ScrollBarSliderMoved"
- "position" - new value of the slider
- */
-
- void SetOverriddenButtons( Button *pB1, Button *pB2 ) { m_pOverriddenButtons[0] = pB1; m_pOverriddenButtons[1] = pB2; }
-
- virtual void ApplySettings( KeyValues *pInResourceData );
-
-protected:
-
- virtual void PerformLayout();
- virtual void SendSliderMoveMessage(int value);
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void OnSizeChanged(int wide, int tall);
-
- MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
- virtual void RespondToScrollArrow(int const direction);
-
- virtual void UpdateButtonsForImages( void );
- virtual void UpdateSliderImages( void );
- Button *GetDepressedButton( int iIndex );
-
-private:
- Button* _button[2];
- ScrollBarSlider* _slider;
- int _buttonPressedScrollValue;
- int _scrollDelay; // used to control delays in scrolling
- bool _respond;
- bool m_bNoButtons;
- CPanelAnimationVar( bool, m_bAutoHideButtons, "autohide_buttons", "0" );
-
- vgui::ImagePanel *m_pUpArrow;
- vgui::ImagePanel *m_pLine;
- vgui::ImagePanel *m_pDownArrow;
- vgui::ImagePanel *m_pBox;
- Button *m_pOverriddenButtons[2];
-};
-
-}
-
-#endif // SCROLLBAR_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef SCROLLBAR_H +#define SCROLLBAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +class Button; +class ScrollBarSlider; + +//----------------------------------------------------------------------------- +// Purpose: Generic scrollbar +// Uses Buttons & SliderBars for the main functionality +//----------------------------------------------------------------------------- +class ScrollBar : public Panel +{ + DECLARE_CLASS_SIMPLE( ScrollBar, Panel ); + +public: + ScrollBar(Panel *parent, const char *panelName, bool vertical); + + // Set the value of the scroll bar slider. + virtual void SetValue(int value); + + // Get the value of the scroll bar slider. + virtual int GetValue(); + + // Set the rangeof numbers the slider can scroll through + virtual void SetRange(int min,int max); + + virtual void GetRange(int &min, int &max); + + // Set how many lines are displayed at one time + // in the window the scroll bar is attached to. + virtual void SetRangeWindow(int rangeWindow); + + // Get how many lines are displayed at one time + // in the window the scroll bar is attached to. + virtual int GetRangeWindow(); + + // Check if the scrollbar is vertical or horizontal + virtual bool IsVertical(); + + // Purpose: Check if the slider can move through one or more pixels per + // unit of its range. + virtual bool HasFullRange(); + + // Setup the indexed scroll bar button with the input params. + virtual void SetButton(Button* button,int index); + // Return the indexed scroll bar button + virtual Button *GetButton(int index); + // Set up the slider. + virtual void SetSlider(ScrollBarSlider* slider); + // Return a pointer to the slider. + virtual ScrollBarSlider *GetSlider(); + // Set how far the scroll bar slider moves + // when a scroll bar button is pressed + virtual void SetButtonPressedScrollValue(int value); + + virtual void Validate(); + + // Update and look for clicks when mouse is in the scroll bar window. + virtual void OnMouseFocusTicked(); + + // Set the slider's Paint border enabled. + virtual void SetPaintBorderEnabled(bool state); + // Set the slider's Paint background enabled. + virtual void SetPaintBackgroundEnabled(bool state); + // Set the slider's Paint enabled. + virtual void SetPaintEnabled(bool state); + + // Sets the scrollbar buttons visible or not + virtual void SetScrollbarButtonsVisible(bool visible); + + void SetAutohideButtons( bool bAutohide ) { m_bAutoHideButtons = bAutohide; } + + void UseImages( const char *pszUpArrow, const char *pszDownArrow, const char *pszLine, const char *pszBox ); + + /* MESSAGES SENT: + "ScrollBarSliderMoved" + "position" - new value of the slider + */ + + void SetOverriddenButtons( Button *pB1, Button *pB2 ) { m_pOverriddenButtons[0] = pB1; m_pOverriddenButtons[1] = pB2; } + + virtual void ApplySettings( KeyValues *pInResourceData ); + +protected: + + virtual void PerformLayout(); + virtual void SendSliderMoveMessage(int value); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void OnSizeChanged(int wide, int tall); + + MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position ); + virtual void RespondToScrollArrow(int const direction); + + virtual void UpdateButtonsForImages( void ); + virtual void UpdateSliderImages( void ); + Button *GetDepressedButton( int iIndex ); + +private: + Button* _button[2]; + ScrollBarSlider* _slider; + int _buttonPressedScrollValue; + int _scrollDelay; // used to control delays in scrolling + bool _respond; + bool m_bNoButtons; + CPanelAnimationVar( bool, m_bAutoHideButtons, "autohide_buttons", "0" ); + + vgui::ImagePanel *m_pUpArrow; + vgui::ImagePanel *m_pLine; + vgui::ImagePanel *m_pDownArrow; + vgui::ImagePanel *m_pBox; + Button *m_pOverriddenButtons[2]; +}; + +} + +#endif // SCROLLBAR_H diff --git a/mp/src/public/vgui_controls/ScrollBarSlider.h b/mp/src/public/vgui_controls/ScrollBarSlider.h index 0acd3b7c..8769222f 100644 --- a/mp/src/public/vgui_controls/ScrollBarSlider.h +++ b/mp/src/public/vgui_controls/ScrollBarSlider.h @@ -1,94 +1,94 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef SCROLLBARSLIDER_H
-#define SCROLLBARSLIDER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-class IBorder;
-
-//-----------------------------------------------------------------------------
-// Purpose: ScrollBarSlider bar, as used in ScrollBar's
-//-----------------------------------------------------------------------------
-class ScrollBarSlider : public Panel
-{
- DECLARE_CLASS_SIMPLE( ScrollBarSlider, Panel );
-
-public:
- ScrollBarSlider(Panel *parent, const char *panelName, bool vertical);
-
- // Set the ScrollBarSlider value of the nob.
- virtual void SetValue(int value);
- virtual int GetValue();
-
- // Check whether the scroll bar is vertical or not
- virtual bool IsVertical();
-
- // Set max and min range of lines to display
- virtual void SetRange(int min, int max);
-
- virtual void GetRange(int &min, int &max);
-
- // Set number of rows that can be displayed in window
- virtual void SetRangeWindow(int rangeWindow);
-
- // Get number of rows that can be displayed in window
- virtual int GetRangeWindow();
-
- // Set the size of the ScrollBarSlider nob
- virtual void SetSize(int wide, int tall);
-
- // Get current ScrollBarSlider bounds
- virtual void GetNobPos(int &min, int &max);
-
- virtual bool HasFullRange();
- virtual void SetButtonOffset(int buttonOffset);
- virtual void OnCursorMoved(int x, int y);
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseDoublePressed(MouseCode code);
- virtual void OnMouseReleased(MouseCode code);
-
- // Return true if this slider is actually drawing itself
- virtual bool IsSliderVisible( void );
-
- virtual void ApplySettings( KeyValues *pInResourceData );
-
-protected:
- virtual void Paint();
- virtual void PaintBackground();
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
-private:
- virtual void RecomputeNobPosFromValue();
- virtual void RecomputeValueFromNobPos();
- virtual void SendScrollBarSliderMovedMessage();
-
- bool _vertical;
- bool _dragging;
- int _nobPos[2];
- int _nobDragStartPos[2];
- int _dragStartPos[2];
- int _range[2];
- int _value; // the position of the ScrollBarSlider, in coordinates as specified by SetRange/SetRangeWindow
- int _rangeWindow;
- int _buttonOffset;
- IBorder *_ScrollBarSliderBorder;
-};
-
-} // namespace vgui
-
-#endif // SCROLLBARSLIDER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef SCROLLBARSLIDER_H +#define SCROLLBARSLIDER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +class IBorder; + +//----------------------------------------------------------------------------- +// Purpose: ScrollBarSlider bar, as used in ScrollBar's +//----------------------------------------------------------------------------- +class ScrollBarSlider : public Panel +{ + DECLARE_CLASS_SIMPLE( ScrollBarSlider, Panel ); + +public: + ScrollBarSlider(Panel *parent, const char *panelName, bool vertical); + + // Set the ScrollBarSlider value of the nob. + virtual void SetValue(int value); + virtual int GetValue(); + + // Check whether the scroll bar is vertical or not + virtual bool IsVertical(); + + // Set max and min range of lines to display + virtual void SetRange(int min, int max); + + virtual void GetRange(int &min, int &max); + + // Set number of rows that can be displayed in window + virtual void SetRangeWindow(int rangeWindow); + + // Get number of rows that can be displayed in window + virtual int GetRangeWindow(); + + // Set the size of the ScrollBarSlider nob + virtual void SetSize(int wide, int tall); + + // Get current ScrollBarSlider bounds + virtual void GetNobPos(int &min, int &max); + + virtual bool HasFullRange(); + virtual void SetButtonOffset(int buttonOffset); + virtual void OnCursorMoved(int x, int y); + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); + + // Return true if this slider is actually drawing itself + virtual bool IsSliderVisible( void ); + + virtual void ApplySettings( KeyValues *pInResourceData ); + +protected: + virtual void Paint(); + virtual void PaintBackground(); + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + +private: + virtual void RecomputeNobPosFromValue(); + virtual void RecomputeValueFromNobPos(); + virtual void SendScrollBarSliderMovedMessage(); + + bool _vertical; + bool _dragging; + int _nobPos[2]; + int _nobDragStartPos[2]; + int _dragStartPos[2]; + int _range[2]; + int _value; // the position of the ScrollBarSlider, in coordinates as specified by SetRange/SetRangeWindow + int _rangeWindow; + int _buttonOffset; + IBorder *_ScrollBarSliderBorder; +}; + +} // namespace vgui + +#endif // SCROLLBARSLIDER_H diff --git a/mp/src/public/vgui_controls/ScrollableEditablePanel.h b/mp/src/public/vgui_controls/ScrollableEditablePanel.h index 937f6f39..6796405d 100644 --- a/mp/src/public/vgui_controls/ScrollableEditablePanel.h +++ b/mp/src/public/vgui_controls/ScrollableEditablePanel.h @@ -1,55 +1,55 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================
-
-#ifndef SCROLLABLEEDITABLEPANEL_H
-#define SCROLLABLEEDITABLEPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/EditablePanel.h"
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-namespace vgui
-{
- class ScrollBar;
-}
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// An editable panel that has a scrollbar
-//-----------------------------------------------------------------------------
-class ScrollableEditablePanel : public vgui::EditablePanel
-{
- DECLARE_CLASS_SIMPLE( ScrollableEditablePanel, vgui::EditablePanel );
-
-public:
- ScrollableEditablePanel( vgui::Panel *pParent, vgui::EditablePanel *pChild, const char *pName );
- virtual ~ScrollableEditablePanel() {}
-
- virtual void ApplySettings( KeyValues *pInResourceData );
- virtual void PerformLayout();
-
- vgui::ScrollBar *GetScrollbar( void ) { return m_pScrollBar; }
-
- MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" );
- virtual void OnMouseWheeled(int delta); // respond to mouse wheel events
-
-private:
- vgui::ScrollBar *m_pScrollBar;
- vgui::EditablePanel *m_pChild;
-};
-
-
-} // end namespace vgui
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef SCROLLABLEEDITABLEPANEL_H +#define SCROLLABLEEDITABLEPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/EditablePanel.h" + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace vgui +{ + class ScrollBar; +} + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// An editable panel that has a scrollbar +//----------------------------------------------------------------------------- +class ScrollableEditablePanel : public vgui::EditablePanel +{ + DECLARE_CLASS_SIMPLE( ScrollableEditablePanel, vgui::EditablePanel ); + +public: + ScrollableEditablePanel( vgui::Panel *pParent, vgui::EditablePanel *pChild, const char *pName ); + virtual ~ScrollableEditablePanel() {} + + virtual void ApplySettings( KeyValues *pInResourceData ); + virtual void PerformLayout(); + + vgui::ScrollBar *GetScrollbar( void ) { return m_pScrollBar; } + + MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" ); + virtual void OnMouseWheeled(int delta); // respond to mouse wheel events + +private: + vgui::ScrollBar *m_pScrollBar; + vgui::EditablePanel *m_pChild; +}; + + +} // end namespace vgui + #endif // SCROLLABLEEDITABLEPANEL_H
\ No newline at end of file diff --git a/mp/src/public/vgui_controls/SectionedListPanel.h b/mp/src/public/vgui_controls/SectionedListPanel.h index ca6207c7..c38f6c74 100644 --- a/mp/src/public/vgui_controls/SectionedListPanel.h +++ b/mp/src/public/vgui_controls/SectionedListPanel.h @@ -1,317 +1,317 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef SECTIONEDLISTPANEL_H
-#define SECTIONEDLISTPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utlvector.h>
-#include <utllinkedlist.h>
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/PHandle.h>
-#include <vgui_controls/Label.h>
-
-namespace vgui
-{
-
-class SectionedListPanel;
-class SectionedListPanelHeader;
-class CItemButton;
-
-// sorting function, should return true if itemID1 should be displayed before itemID2
-typedef bool (*SectionSortFunc_t)(SectionedListPanel *list, int itemID1, int itemID2);
-
-//-----------------------------------------------------------------------------
-// Purpose: List panel control that is divided up into discrete sections
-//-----------------------------------------------------------------------------
-class SectionedListPanel : public Panel
-{
- DECLARE_CLASS_SIMPLE( SectionedListPanel, Panel );
-
-public:
- SectionedListPanel(vgui::Panel *parent, const char *name);
- ~SectionedListPanel();
-
- // adds a new section; returns false if section already exists
- virtual void AddSection(int sectionID, const char *name, SectionSortFunc_t sortFunc = NULL);
- virtual void AddSection(int sectionID, const wchar_t *name, SectionSortFunc_t sortFunc = NULL);
- virtual void AddSection(int sectionID, SectionedListPanelHeader *pHeader, SectionSortFunc_t sortFunc = NULL);
-
- // clears all the sections - leaves the items in place
- virtual void RemoveAllSections();
-
- // modifies section info
- virtual void SetSectionFgColor(int sectionID, Color color);
- virtual void SetSectionDividerColor( int sectionID, Color color);
- // forces a section to always be visible
- virtual void SetSectionAlwaysVisible(int sectionID, bool visible = true);
- virtual void SetSectionMinimumHeight(int sectionID, int iMinimumHeight);
-
- // adds a new column to a section
- enum ColumnFlags_e
- {
- HEADER_IMAGE = 0x01, // set if the header for the column is an image instead of text
- COLUMN_IMAGE = 0x02, // set if the column contains an image instead of text (images are looked up by index from the ImageList) (see SetImageList below)
- COLUMN_BRIGHT = 0x04, // set if the column text should be the bright color
- COLUMN_CENTER = 0x08, // set to center the text/image in the column
- COLUMN_RIGHT = 0x10, // set to right-align the text in the column
- };
- virtual bool AddColumnToSection(int sectionID, const char *columnName, const char *columnText, int columnFlags, int width, HFont fallbackFont = INVALID_FONT );
- virtual bool AddColumnToSection(int sectionID, const char *columnName, const wchar_t *columnText, int columnFlags, int width, HFont fallbackFont = INVALID_FONT );
-
- // modifies the text in an existing column
- virtual bool ModifyColumn(int sectionID, const char *columnName, const wchar_t *columnText);
-
- // adds an item to the list; returns the itemID of the new item
- virtual int AddItem(int sectionID, const KeyValues *data);
-
- // modifies an existing item; returns false if the item does not exist
- virtual bool ModifyItem(int itemID, int sectionID, const KeyValues *data);
-
- // removes an item from the list; returns false if the item does not exist or is already removed
- virtual bool RemoveItem(int itemID);
-
- // clears the list
- virtual void RemoveAll() { DeleteAllItems(); }
- // DeleteAllItems() is deprecated, use RemoveAll();
- virtual void DeleteAllItems();
-
- // set the text color of an item
- virtual void SetItemFgColor(int itemID, Color color);
- //=============================================================================
- // HPE_BEGIN:
- // [menglish] Getters and setters for several item and section objects
- //=============================================================================
- virtual void SetItemBgColor( int itemID, Color color );
- virtual int GetColumnIndexByName(int sectionID, char* name);
- virtual int GetLineSpacing() { return m_iLineSpacing; }
- //=============================================================================
- // HPE_END
- //=============================================================================
- virtual void SetItemFont( int itemID, HFont font );
- virtual void SetItemEnabled( int itemID, bool bEnabled );
-
- /* MESSAGES SENT:
- "RowSelected"
- "itemID" - the selected item id, -1 if nothing selected
-
- // when an item has been clicked on
- "RowContextMenu" "itemID"
- "RowLeftClick" "itemID"
- "RowDoubleLeftClick" "itemID"
- */
-
- // returns the number of columns in a section
- virtual int GetColumnCountBySection(int sectionID);
-
- // returns the name of a column by section and column index; returns NULL if there are no more columns
- // valid range of columnIndex is [0, GetColumnCountBySection)
- virtual const char *GetColumnNameBySection(int sectionID, int columnIndex);
- virtual const wchar_t *GetColumnTextBySection(int sectionID, int columnIndex);
- virtual int GetColumnFlagsBySection(int sectionID, int columnIndex);
- virtual int GetColumnWidthBySection(int sectionID, int columnIndex);
- virtual HFont GetColumnFallbackFontBySection( int sectionID, int columnIndex );
-
- // returns the id of the currently selected item, -1 if nothing is selected
- virtual int GetSelectedItem();
-
- // sets which item is currently selected
- virtual void SetSelectedItem(int itemID);
-
- // remove selection
- virtual void ClearSelection( void );
-
- // returns the data of a selected item
- // InvalidateItem(itemID) needs to be called if the KeyValues are modified
- virtual KeyValues *GetItemData(int itemID);
-
- // returns what section an item is in
- virtual int GetItemSection(int itemID);
-
- // forces an item to redraw (use when keyvalues have been modified)
- virtual void InvalidateItem(int itemID);
-
- // returns true if the itemID is valid for use
- virtual bool IsItemIDValid(int itemID);
- virtual int GetHighestItemID();
-
- // returns the number of items (ignoring section dividers)
- virtual int GetItemCount();
-
- // returns the item ID from the row, again ignoring section dividers - valid from [0, GetItemCount )
- virtual int GetItemIDFromRow(int row);
-
- // returns the row that this itemID occupies. -1 if the itemID is invalid
- virtual int GetRowFromItemID(int itemID);
-
- // gets the local coordinates of a cell
- virtual bool GetCellBounds(int itemID, int column, int &x, int &y, int &wide, int &tall);
-
- // Gets the coordinates of a section header
- virtual bool GetSectionHeaderBounds(int sectionID, int &x, int &y, int &wide, int &tall);
-
- //=============================================================================
- // HPE_BEGIN:
- // [menglish] Get the bounds of an item or column.
- //=============================================================================
-
- // gets the local coordinates of a cell using the max width for every column
- virtual bool GetMaxCellBounds(int itemID, int column, int &x, int &y, int &wide, int &tall);
-
- // gets the local coordinates of an item
- virtual bool GetItemBounds(int itemID, int &x, int &y, int &wide, int &tall);
-
- // [tj] Accessors for clickability
- void SetClickable(bool clickable) { m_clickable = clickable; }
- bool IsClickable() { return m_clickable; }
-
- // [tj] Accessors for header drawing
- void SetDrawHeaders(bool drawHeaders) { m_bDrawSectionHeaders = drawHeaders; }
- bool GetDrawHeaders() { return m_bDrawSectionHeaders; }
-
- //=============================================================================
- // HPE_END
- //=============================================================================
-
- // set up a field for editing
- virtual void EnterEditMode(int itemID, int column, vgui::Panel *editPanel);
-
- // leaves editing mode
- virtual void LeaveEditMode();
-
- // returns true if we are currently in inline editing mode
- virtual bool IsInEditMode();
-
- // sets whether or not the vertical scrollbar should ever be displayed
- virtual void SetVerticalScrollbar(bool state);
-
- // returns the size required to fully draw the contents of the panel
- virtual void GetContentSize(int &wide, int &tall);
-
- // image handling
- virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone);
-
- virtual void ScrollToItem(int iItem);
-
- virtual void SetProportional(bool state);
-
- HFont GetHeaderFont( void ) const;
- void SetHeaderFont( HFont hFont );
- HFont GetRowFont( void ) const;
- void SetRowFont( HFont hFont );
- void MoveSelectionDown( void );
- void MoveSelectionUp( void );
-
-protected:
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void OnSizeChanged(int wide, int tall);
- virtual void OnMouseWheeled(int delta);
- virtual void OnMousePressed( MouseCode code);
- virtual void NavigateTo( void );
- virtual void OnKeyCodePressed( KeyCode code );
- virtual void OnSetFocus(); // called after the panel receives the keyboard focus
-
-public:
- virtual void SetFontSection(int sectionID, HFont font);
-private:
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" );
-
- int GetSectionTall();
- void LayoutPanels(int &contentTall);
-
- // Returns the index of a new item button, reusing an existing item button if possible
- int GetNewItemButton();
-
- friend class CItemButton;
- void SetSelectedItem(CItemButton *item);
- DHANDLE<CItemButton> m_hSelectedItem;
-
- struct column_t
- {
- char m_szColumnName[32];
- wchar_t m_szColumnText[64];
- int m_iColumnFlags;
- int m_iWidth;
- HFont m_hFallbackFont;
- };
- struct section_t
- {
- int m_iID;
- bool m_bAlwaysVisible;
- SectionedListPanelHeader *m_pHeader;
- CUtlVector<column_t> m_Columns;
- SectionSortFunc_t m_pSortFunc;
- int m_iMinimumHeight;
- };
-
- CUtlVector<section_t> m_Sections;
- CUtlLinkedList<CItemButton *, int> m_Items;
- CUtlLinkedList<CItemButton *, int> m_FreeItems;
- CUtlVector<CItemButton *> m_SortedItems;
-
- PHandle m_hEditModePanel;
- int m_iEditModeItemID;
- int m_iEditModeColumn;
- int m_iContentHeight;
- int m_iLineSpacing;
- int m_iSectionGap;
-
- int FindSectionIndexByID(int sectionID);
- void ReSortList();
-
- ScrollBar *m_pScrollBar;
- ImageList *m_pImageList;
- bool m_bDeleteImageListWhenDone;
- bool m_bSortNeeded;
- bool m_bVerticalScrollbarEnabled;
-
- HFont m_hHeaderFont;
- HFont m_hRowFont;
- //=============================================================================
- // HPE_BEGIN:
- //=============================================================================
- // [tj] Whether or not this list should respond to the mouse
- bool m_clickable;
- // [tj] Whether or not this list should draw the headers for the sections
- bool m_bDrawSectionHeaders;
- //=============================================================================
- // HPE_END
- //=============================================================================
-
- CPanelAnimationVar( bool, m_bShowColumns, "show_columns", "false" );
-};
-
-class SectionedListPanelHeader : public Label
-{
- DECLARE_CLASS_SIMPLE( SectionedListPanelHeader, Label );
-
-public:
- SectionedListPanelHeader(SectionedListPanel *parent, const char *name, int sectionID);
- SectionedListPanelHeader(SectionedListPanel *parent, const wchar_t *name, int sectionID);
-
- virtual void ApplySchemeSettings(IScheme *pScheme) OVERRIDE;
- virtual void Paint() OVERRIDE;
- virtual void PerformLayout() OVERRIDE;
-
- void SetColor(Color col);
- void SetDividerColor(Color col );
-
-protected:
- int m_iSectionID;
- Color m_SectionDividerColor;
- SectionedListPanel *m_pListPanel;
-};
-
-} // namespace vgui
-
-#endif // SECTIONEDLISTPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef SECTIONEDLISTPANEL_H +#define SECTIONEDLISTPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utlvector.h> +#include <utllinkedlist.h> +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> +#include <vgui_controls/PHandle.h> +#include <vgui_controls/Label.h> + +namespace vgui +{ + +class SectionedListPanel; +class SectionedListPanelHeader; +class CItemButton; + +// sorting function, should return true if itemID1 should be displayed before itemID2 +typedef bool (*SectionSortFunc_t)(SectionedListPanel *list, int itemID1, int itemID2); + +//----------------------------------------------------------------------------- +// Purpose: List panel control that is divided up into discrete sections +//----------------------------------------------------------------------------- +class SectionedListPanel : public Panel +{ + DECLARE_CLASS_SIMPLE( SectionedListPanel, Panel ); + +public: + SectionedListPanel(vgui::Panel *parent, const char *name); + ~SectionedListPanel(); + + // adds a new section; returns false if section already exists + virtual void AddSection(int sectionID, const char *name, SectionSortFunc_t sortFunc = NULL); + virtual void AddSection(int sectionID, const wchar_t *name, SectionSortFunc_t sortFunc = NULL); + virtual void AddSection(int sectionID, SectionedListPanelHeader *pHeader, SectionSortFunc_t sortFunc = NULL); + + // clears all the sections - leaves the items in place + virtual void RemoveAllSections(); + + // modifies section info + virtual void SetSectionFgColor(int sectionID, Color color); + virtual void SetSectionDividerColor( int sectionID, Color color); + // forces a section to always be visible + virtual void SetSectionAlwaysVisible(int sectionID, bool visible = true); + virtual void SetSectionMinimumHeight(int sectionID, int iMinimumHeight); + + // adds a new column to a section + enum ColumnFlags_e + { + HEADER_IMAGE = 0x01, // set if the header for the column is an image instead of text + COLUMN_IMAGE = 0x02, // set if the column contains an image instead of text (images are looked up by index from the ImageList) (see SetImageList below) + COLUMN_BRIGHT = 0x04, // set if the column text should be the bright color + COLUMN_CENTER = 0x08, // set to center the text/image in the column + COLUMN_RIGHT = 0x10, // set to right-align the text in the column + }; + virtual bool AddColumnToSection(int sectionID, const char *columnName, const char *columnText, int columnFlags, int width, HFont fallbackFont = INVALID_FONT ); + virtual bool AddColumnToSection(int sectionID, const char *columnName, const wchar_t *columnText, int columnFlags, int width, HFont fallbackFont = INVALID_FONT ); + + // modifies the text in an existing column + virtual bool ModifyColumn(int sectionID, const char *columnName, const wchar_t *columnText); + + // adds an item to the list; returns the itemID of the new item + virtual int AddItem(int sectionID, const KeyValues *data); + + // modifies an existing item; returns false if the item does not exist + virtual bool ModifyItem(int itemID, int sectionID, const KeyValues *data); + + // removes an item from the list; returns false if the item does not exist or is already removed + virtual bool RemoveItem(int itemID); + + // clears the list + virtual void RemoveAll() { DeleteAllItems(); } + // DeleteAllItems() is deprecated, use RemoveAll(); + virtual void DeleteAllItems(); + + // set the text color of an item + virtual void SetItemFgColor(int itemID, Color color); + //============================================================================= + // HPE_BEGIN: + // [menglish] Getters and setters for several item and section objects + //============================================================================= + virtual void SetItemBgColor( int itemID, Color color ); + virtual int GetColumnIndexByName(int sectionID, char* name); + virtual int GetLineSpacing() { return m_iLineSpacing; } + //============================================================================= + // HPE_END + //============================================================================= + virtual void SetItemFont( int itemID, HFont font ); + virtual void SetItemEnabled( int itemID, bool bEnabled ); + + /* MESSAGES SENT: + "RowSelected" + "itemID" - the selected item id, -1 if nothing selected + + // when an item has been clicked on + "RowContextMenu" "itemID" + "RowLeftClick" "itemID" + "RowDoubleLeftClick" "itemID" + */ + + // returns the number of columns in a section + virtual int GetColumnCountBySection(int sectionID); + + // returns the name of a column by section and column index; returns NULL if there are no more columns + // valid range of columnIndex is [0, GetColumnCountBySection) + virtual const char *GetColumnNameBySection(int sectionID, int columnIndex); + virtual const wchar_t *GetColumnTextBySection(int sectionID, int columnIndex); + virtual int GetColumnFlagsBySection(int sectionID, int columnIndex); + virtual int GetColumnWidthBySection(int sectionID, int columnIndex); + virtual HFont GetColumnFallbackFontBySection( int sectionID, int columnIndex ); + + // returns the id of the currently selected item, -1 if nothing is selected + virtual int GetSelectedItem(); + + // sets which item is currently selected + virtual void SetSelectedItem(int itemID); + + // remove selection + virtual void ClearSelection( void ); + + // returns the data of a selected item + // InvalidateItem(itemID) needs to be called if the KeyValues are modified + virtual KeyValues *GetItemData(int itemID); + + // returns what section an item is in + virtual int GetItemSection(int itemID); + + // forces an item to redraw (use when keyvalues have been modified) + virtual void InvalidateItem(int itemID); + + // returns true if the itemID is valid for use + virtual bool IsItemIDValid(int itemID); + virtual int GetHighestItemID(); + + // returns the number of items (ignoring section dividers) + virtual int GetItemCount(); + + // returns the item ID from the row, again ignoring section dividers - valid from [0, GetItemCount ) + virtual int GetItemIDFromRow(int row); + + // returns the row that this itemID occupies. -1 if the itemID is invalid + virtual int GetRowFromItemID(int itemID); + + // gets the local coordinates of a cell + virtual bool GetCellBounds(int itemID, int column, int &x, int &y, int &wide, int &tall); + + // Gets the coordinates of a section header + virtual bool GetSectionHeaderBounds(int sectionID, int &x, int &y, int &wide, int &tall); + + //============================================================================= + // HPE_BEGIN: + // [menglish] Get the bounds of an item or column. + //============================================================================= + + // gets the local coordinates of a cell using the max width for every column + virtual bool GetMaxCellBounds(int itemID, int column, int &x, int &y, int &wide, int &tall); + + // gets the local coordinates of an item + virtual bool GetItemBounds(int itemID, int &x, int &y, int &wide, int &tall); + + // [tj] Accessors for clickability + void SetClickable(bool clickable) { m_clickable = clickable; } + bool IsClickable() { return m_clickable; } + + // [tj] Accessors for header drawing + void SetDrawHeaders(bool drawHeaders) { m_bDrawSectionHeaders = drawHeaders; } + bool GetDrawHeaders() { return m_bDrawSectionHeaders; } + + //============================================================================= + // HPE_END + //============================================================================= + + // set up a field for editing + virtual void EnterEditMode(int itemID, int column, vgui::Panel *editPanel); + + // leaves editing mode + virtual void LeaveEditMode(); + + // returns true if we are currently in inline editing mode + virtual bool IsInEditMode(); + + // sets whether or not the vertical scrollbar should ever be displayed + virtual void SetVerticalScrollbar(bool state); + + // returns the size required to fully draw the contents of the panel + virtual void GetContentSize(int &wide, int &tall); + + // image handling + virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone); + + virtual void ScrollToItem(int iItem); + + virtual void SetProportional(bool state); + + HFont GetHeaderFont( void ) const; + void SetHeaderFont( HFont hFont ); + HFont GetRowFont( void ) const; + void SetRowFont( HFont hFont ); + void MoveSelectionDown( void ); + void MoveSelectionUp( void ); + +protected: + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void ApplySettings(KeyValues *inResourceData); + virtual void OnSizeChanged(int wide, int tall); + virtual void OnMouseWheeled(int delta); + virtual void OnMousePressed( MouseCode code); + virtual void NavigateTo( void ); + virtual void OnKeyCodePressed( KeyCode code ); + virtual void OnSetFocus(); // called after the panel receives the keyboard focus + +public: + virtual void SetFontSection(int sectionID, HFont font); +private: + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); + + int GetSectionTall(); + void LayoutPanels(int &contentTall); + + // Returns the index of a new item button, reusing an existing item button if possible + int GetNewItemButton(); + + friend class CItemButton; + void SetSelectedItem(CItemButton *item); + DHANDLE<CItemButton> m_hSelectedItem; + + struct column_t + { + char m_szColumnName[32]; + wchar_t m_szColumnText[64]; + int m_iColumnFlags; + int m_iWidth; + HFont m_hFallbackFont; + }; + struct section_t + { + int m_iID; + bool m_bAlwaysVisible; + SectionedListPanelHeader *m_pHeader; + CUtlVector<column_t> m_Columns; + SectionSortFunc_t m_pSortFunc; + int m_iMinimumHeight; + }; + + CUtlVector<section_t> m_Sections; + CUtlLinkedList<CItemButton *, int> m_Items; + CUtlLinkedList<CItemButton *, int> m_FreeItems; + CUtlVector<CItemButton *> m_SortedItems; + + PHandle m_hEditModePanel; + int m_iEditModeItemID; + int m_iEditModeColumn; + int m_iContentHeight; + int m_iLineSpacing; + int m_iSectionGap; + + int FindSectionIndexByID(int sectionID); + void ReSortList(); + + ScrollBar *m_pScrollBar; + ImageList *m_pImageList; + bool m_bDeleteImageListWhenDone; + bool m_bSortNeeded; + bool m_bVerticalScrollbarEnabled; + + HFont m_hHeaderFont; + HFont m_hRowFont; + //============================================================================= + // HPE_BEGIN: + //============================================================================= + // [tj] Whether or not this list should respond to the mouse + bool m_clickable; + // [tj] Whether or not this list should draw the headers for the sections + bool m_bDrawSectionHeaders; + //============================================================================= + // HPE_END + //============================================================================= + + CPanelAnimationVar( bool, m_bShowColumns, "show_columns", "false" ); +}; + +class SectionedListPanelHeader : public Label +{ + DECLARE_CLASS_SIMPLE( SectionedListPanelHeader, Label ); + +public: + SectionedListPanelHeader(SectionedListPanel *parent, const char *name, int sectionID); + SectionedListPanelHeader(SectionedListPanel *parent, const wchar_t *name, int sectionID); + + virtual void ApplySchemeSettings(IScheme *pScheme) OVERRIDE; + virtual void Paint() OVERRIDE; + virtual void PerformLayout() OVERRIDE; + + void SetColor(Color col); + void SetDividerColor(Color col ); + +protected: + int m_iSectionID; + Color m_SectionDividerColor; + SectionedListPanel *m_pListPanel; +}; + +} // namespace vgui + +#endif // SECTIONEDLISTPANEL_H diff --git a/mp/src/public/vgui_controls/Slider.h b/mp/src/public/vgui_controls/Slider.h index 6d280d2a..ce75aef0 100644 --- a/mp/src/public/vgui_controls/Slider.h +++ b/mp/src/public/vgui_controls/Slider.h @@ -1,123 +1,123 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef SLIDER_H
-#define SLIDER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Labeled horizontal slider
-//-----------------------------------------------------------------------------
-class Slider : public Panel
-{
- DECLARE_CLASS_SIMPLE( Slider, Panel );
-public:
- Slider(Panel *parent, const char *panelName);
-
- // interface
- virtual void SetValue(int value, bool bTriggerChangeMessage = true);
- virtual int GetValue();
- virtual void SetRange(int min, int max); // set to max and min range of rows to display
- virtual void GetRange(int &min, int &max);
- virtual void GetNobPos(int &min, int &max); // get current Slider position
- virtual void SetButtonOffset(int buttonOffset);
- virtual void OnCursorMoved(int x, int y);
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseDoublePressed(MouseCode code);
- virtual void OnMouseReleased(MouseCode code);
- virtual void SetTickCaptions(const wchar_t *left, const wchar_t *right);
- virtual void SetTickCaptions(const char *left, const char *right);
- virtual void SetNumTicks(int ticks);
- virtual void SetThumbWidth( int width );
- virtual int EstimateValueAtPos( int localMouseX, int localMouseY );
- virtual void SetInverted( bool bInverted );
-
- // If you click on the slider outside of the nob, the nob jumps
- // to the click position, and if this setting is enabled, the nob
- // is then draggable from the new position until the mouse is released
- virtual void SetDragOnRepositionNob( bool state );
- virtual bool IsDragOnRepositionNob() const;
-
- // Get if the slider nob is being dragged by user, usually the application
- // should refuse from forcefully setting slider value if it is being dragged
- // by user since the next frame the nob will pop back to mouse position
- virtual bool IsDragged( void ) const;
-
- // This allows the slider to behave like it's larger than what's actually being drawn
- virtual void SetSliderThumbSubRange( bool bEnable, int nMin = 0, int nMax = 100 );
-
-protected:
- virtual void OnSizeChanged(int wide, int tall);
- virtual void Paint();
- virtual void PaintBackground();
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void GetSettings(KeyValues *outResourceData);
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual const char *GetDescription();
-#ifdef _X360
- virtual void OnKeyCodePressed(KeyCode code);
-#endif
- virtual void OnKeyCodeTyped(KeyCode code);
-
- virtual void DrawNob();
- virtual void DrawTicks();
- virtual void DrawTickLabels();
-
- virtual void GetTrackRect( int &x, int &y, int &w, int &h );
-
-protected:
- virtual void RecomputeNobPosFromValue();
- virtual void RecomputeValueFromNobPos();
-
- virtual void SendSliderMovedMessage();
- virtual void SendSliderDragStartMessage();
- virtual void SendSliderDragEndMessage();
-
- void ClampRange();
-
- bool _dragging;
- int _nobPos[2];
- int _nobDragStartPos[2];
- int _dragStartPos[2];
- int _range[2];
- int _subrange[ 2 ];
- int _value; // the position of the Slider, in coordinates as specified by SetRange/SetRangeWindow
- int _buttonOffset;
- IBorder *_sliderBorder;
- IBorder *_insetBorder;
- float _nobSize;
-
- TextImage *_leftCaption;
- TextImage *_rightCaption;
-
- Color m_TickColor;
- Color m_TrackColor;
- Color m_DisabledTextColor1;
- Color m_DisabledTextColor2;
-#ifdef _X360
- Color m_DepressedBgColor;
-#endif
-
- int m_nNumTicks;
- bool m_bIsDragOnRepositionNob : 1;
- bool m_bUseSubRange : 1;
- bool m_bInverted : 1;
-};
-
-}
-
-#endif // SLIDER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef SLIDER_H +#define SLIDER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Labeled horizontal slider +//----------------------------------------------------------------------------- +class Slider : public Panel +{ + DECLARE_CLASS_SIMPLE( Slider, Panel ); +public: + Slider(Panel *parent, const char *panelName); + + // interface + virtual void SetValue(int value, bool bTriggerChangeMessage = true); + virtual int GetValue(); + virtual void SetRange(int min, int max); // set to max and min range of rows to display + virtual void GetRange(int &min, int &max); + virtual void GetNobPos(int &min, int &max); // get current Slider position + virtual void SetButtonOffset(int buttonOffset); + virtual void OnCursorMoved(int x, int y); + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); + virtual void SetTickCaptions(const wchar_t *left, const wchar_t *right); + virtual void SetTickCaptions(const char *left, const char *right); + virtual void SetNumTicks(int ticks); + virtual void SetThumbWidth( int width ); + virtual int EstimateValueAtPos( int localMouseX, int localMouseY ); + virtual void SetInverted( bool bInverted ); + + // If you click on the slider outside of the nob, the nob jumps + // to the click position, and if this setting is enabled, the nob + // is then draggable from the new position until the mouse is released + virtual void SetDragOnRepositionNob( bool state ); + virtual bool IsDragOnRepositionNob() const; + + // Get if the slider nob is being dragged by user, usually the application + // should refuse from forcefully setting slider value if it is being dragged + // by user since the next frame the nob will pop back to mouse position + virtual bool IsDragged( void ) const; + + // This allows the slider to behave like it's larger than what's actually being drawn + virtual void SetSliderThumbSubRange( bool bEnable, int nMin = 0, int nMax = 100 ); + +protected: + virtual void OnSizeChanged(int wide, int tall); + virtual void Paint(); + virtual void PaintBackground(); + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void GetSettings(KeyValues *outResourceData); + virtual void ApplySettings(KeyValues *inResourceData); + virtual const char *GetDescription(); +#ifdef _X360 + virtual void OnKeyCodePressed(KeyCode code); +#endif + virtual void OnKeyCodeTyped(KeyCode code); + + virtual void DrawNob(); + virtual void DrawTicks(); + virtual void DrawTickLabels(); + + virtual void GetTrackRect( int &x, int &y, int &w, int &h ); + +protected: + virtual void RecomputeNobPosFromValue(); + virtual void RecomputeValueFromNobPos(); + + virtual void SendSliderMovedMessage(); + virtual void SendSliderDragStartMessage(); + virtual void SendSliderDragEndMessage(); + + void ClampRange(); + + bool _dragging; + int _nobPos[2]; + int _nobDragStartPos[2]; + int _dragStartPos[2]; + int _range[2]; + int _subrange[ 2 ]; + int _value; // the position of the Slider, in coordinates as specified by SetRange/SetRangeWindow + int _buttonOffset; + IBorder *_sliderBorder; + IBorder *_insetBorder; + float _nobSize; + + TextImage *_leftCaption; + TextImage *_rightCaption; + + Color m_TickColor; + Color m_TrackColor; + Color m_DisabledTextColor1; + Color m_DisabledTextColor2; +#ifdef _X360 + Color m_DepressedBgColor; +#endif + + int m_nNumTicks; + bool m_bIsDragOnRepositionNob : 1; + bool m_bUseSubRange : 1; + bool m_bInverted : 1; +}; + +} + +#endif // SLIDER_H diff --git a/mp/src/public/vgui_controls/Splitter.h b/mp/src/public/vgui_controls/Splitter.h index ad8173db..f788ebcb 100644 --- a/mp/src/public/vgui_controls/Splitter.h +++ b/mp/src/public/vgui_controls/Splitter.h @@ -1,98 +1,98 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef SPLITTER_H
-#define SPLITTER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/EditablePanel.h>
-
-namespace vgui
-{
-
-enum SplitterMode_t
-{
- SPLITTER_MODE_HORIZONTAL = 0,
- SPLITTER_MODE_VERTICAL
-};
-
-
-class SplitterHandle;
-class SplitterChildPanel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Thin line used to divide sections, can be moved dragged!
-//-----------------------------------------------------------------------------
-class Splitter : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( Splitter, EditablePanel );
-
-public:
- // nCount is the number of splitters to create.
- // NOTE: The constructor here will create (nCount+1) EditablePanel children
- // and name them child0...childN for .res file purposes.
- Splitter( Panel *parent, const char *name, SplitterMode_t mode, int nCount );
- ~Splitter();
-
- // Evenly respace all splitters
- void EvenlyRespaceSplitters();
-
- // respace splitters using given fractions (must sum to 1)
- void RespaceSplitters( float *flFractions );
-
- // Inherited from Panel
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void GetSettings( KeyValues *outResourceData );
- virtual void PerformLayout();
- virtual void OnSizeChanged(int newWide, int newTall);
- virtual void ApplyUserConfigSettings(KeyValues *userConfig);
- virtual void GetUserConfigSettings(KeyValues *userConfig);
- virtual bool HasUserConfigSettings() { return true; }
-
- // Sets the splitter color
- void SetSplitterColor( Color c );
-
- // Enables borders on the splitters
- void EnableBorders( bool bEnable );
-
- // Locks the size of a particular child in pixels.
- void LockChildSize( int nChildIndex, int nSize );
- void UnlockChildSize( int nChildIndex );
-
-private:
- void RecreateSplitters( int nCount );
-
- struct SplitterInfo_t
- {
- SplitterChildPanel *m_pPanel; // This panel is to the left or above the handle
- SplitterHandle *m_pHandle;
- float m_flPos;
- bool m_bLocked;
- int m_nLockedSize;
- };
-
- int GetPosRange();
- int GetSplitterCount() const;
- int GetSplitterPosition( int nIndex );
- void SetSplitterPosition( int nIndex, int nPos );
- int GetSubPanelCount() const;
- int ComputeLockedSize( int nStartingIndex );
-
- CUtlVector< SplitterInfo_t > m_Splitters;
- SplitterMode_t m_Mode;
-
- friend class SplitterHandle;
-};
-
-
-} // namespace vgui
-
-
-#endif // SPLITTER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef SPLITTER_H +#define SPLITTER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/EditablePanel.h> + +namespace vgui +{ + +enum SplitterMode_t +{ + SPLITTER_MODE_HORIZONTAL = 0, + SPLITTER_MODE_VERTICAL +}; + + +class SplitterHandle; +class SplitterChildPanel; + +//----------------------------------------------------------------------------- +// Purpose: Thin line used to divide sections, can be moved dragged! +//----------------------------------------------------------------------------- +class Splitter : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( Splitter, EditablePanel ); + +public: + // nCount is the number of splitters to create. + // NOTE: The constructor here will create (nCount+1) EditablePanel children + // and name them child0...childN for .res file purposes. + Splitter( Panel *parent, const char *name, SplitterMode_t mode, int nCount ); + ~Splitter(); + + // Evenly respace all splitters + void EvenlyRespaceSplitters(); + + // respace splitters using given fractions (must sum to 1) + void RespaceSplitters( float *flFractions ); + + // Inherited from Panel + virtual void ApplySettings(KeyValues *inResourceData); + virtual void GetSettings( KeyValues *outResourceData ); + virtual void PerformLayout(); + virtual void OnSizeChanged(int newWide, int newTall); + virtual void ApplyUserConfigSettings(KeyValues *userConfig); + virtual void GetUserConfigSettings(KeyValues *userConfig); + virtual bool HasUserConfigSettings() { return true; } + + // Sets the splitter color + void SetSplitterColor( Color c ); + + // Enables borders on the splitters + void EnableBorders( bool bEnable ); + + // Locks the size of a particular child in pixels. + void LockChildSize( int nChildIndex, int nSize ); + void UnlockChildSize( int nChildIndex ); + +private: + void RecreateSplitters( int nCount ); + + struct SplitterInfo_t + { + SplitterChildPanel *m_pPanel; // This panel is to the left or above the handle + SplitterHandle *m_pHandle; + float m_flPos; + bool m_bLocked; + int m_nLockedSize; + }; + + int GetPosRange(); + int GetSplitterCount() const; + int GetSplitterPosition( int nIndex ); + void SetSplitterPosition( int nIndex, int nPos ); + int GetSubPanelCount() const; + int ComputeLockedSize( int nStartingIndex ); + + CUtlVector< SplitterInfo_t > m_Splitters; + SplitterMode_t m_Mode; + + friend class SplitterHandle; +}; + + +} // namespace vgui + + +#endif // SPLITTER_H diff --git a/mp/src/public/vgui_controls/TextEntry.h b/mp/src/public/vgui_controls/TextEntry.h index c64e8159..7231acc4 100644 --- a/mp/src/public/vgui_controls/TextEntry.h +++ b/mp/src/public/vgui_controls/TextEntry.h @@ -1,390 +1,390 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: A Class to create a window that you can type and edit text in.
-// Window can hold single line or multiline text.
-// If it is single it can scroll horizontally in response to
-// key input and mouse selection.
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef TEXTENTRY_H
-#define TEXTENTRY_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <Color.h>
-#include <vgui_controls/Panel.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/ListPanel.h>
-
-#include <utlvector.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Text-input handler
-// Behaviour Specs:
-// This class handles input from mouse and keyboard.
-// TextEntry classes support several box styles, horizontal scrolling with no scrollbar
-// vertical scrolling with or without a scrollbar, single line, multiline,
-// editable and noneditable.
-//
-// Shared behaviour:
-// URL's are a different text color and are clickable. Clicking them brings up a web browser.
-// For vertical scroll bars, up and down arrows scroll one line at a time.
-// Clicking and dragging the nob scrolls through text lines.
-// Mouse wheel also moves the nob.
-// User can select and highlight text in the window.
-// Double clicking on a word selects it.
-//
-// Non editable:
-// No blinking cursor in non editable windows.
-// Right clicking mouse opens copy menu. Menu's top left corner is where mouse is.
-// Ctrl-c will also copy the text.
-// Editable:
-// Blinking cursor is positioned where text will be inserted.
-// Text keys type chars in the window.
-// ctrl-c copy highlighted text
-// ctrl-v paste highlighted text
-// ctrl-x cut highlighted text
-// ctrl-right arrow move cursor to the start of the next word
-// ctrl-left arrow move cursor to the start of the prev word
-// ctrl-enter delete the selected text (and inserts a newline if _catchEnterKey is true)
-// insert delete selected text and pastes text from the clipboard
-// delete delete the selected text
-// ctrl-home move cursor to the start of the text
-// ctrl-end move cursor to the end of the text.
-// left arrow move cursor before prev char
-// ctrl-shift left/right arrow selects text a word at a time
-// right arrow move cursor before next char
-// up arrow move cursor up one line.
-// down arrow move cursor down one line.
-// home move cursor to start of current line
-// end move cursor to end of current line
-// backspace delete prev char or selected text.
-// Trying to move to the prev/next char/line/word when there is none moves the cursor to the
-// start/end of the text.
-// Horizontal scrolling:
-// Trying to move to the prev/next char/line/word when there is none scrolls the text
-// horizontally in the window so the new text displays at the correct side.
-// When moving to prev chars scrolling is staggered. To next chars it is one char at a time.
-// Cut/Copy/Paste Menu:
-// Right clicking mouse brings up cut/copy/paste menu.
-// If no text is highlighted the cut/copy options are dimmed. Cut is dimmed in non editable panels
-// If there is no text in the clipboard or panel is not editable the paste option is dimmed.
-// If the mouse is right clicked over selected text, the text stays selected.
-// If the mouse is right clicked over unselected text, any selected text is deselected.
-//
-//
-//-----------------------------------------------------------------------------
-class TextEntry : public Panel
-{
- DECLARE_CLASS_SIMPLE( TextEntry, Panel );
-
-public:
- TextEntry(Panel *parent, const char *panelName);
- virtual ~TextEntry();
-
- virtual void SetText(const wchar_t *wszText);
- virtual void SetText(const char *text);
- virtual void GetText(OUT_Z_BYTECAP(bufLenInBytes) char *buf, int bufLenInBytes);
- virtual void GetText(OUT_Z_BYTECAP(bufLenInBytes) wchar_t *buf, int bufLenInBytes);
- virtual int GetTextLength() const;
- virtual bool IsTextFullySelected() const;
-
- // editing
- virtual void GotoLeft(); // move cursor one char left
- virtual void GotoRight(); // move cursor one char right
- virtual void GotoUp(); // move cursor one line up
- virtual void GotoDown(); // move cursor one line down
- virtual void GotoWordRight(); // move cursor to Start of next word
- virtual void GotoWordLeft(); // move cursor to Start of prev word
- virtual void GotoFirstOfLine(); // go to Start of the current line
- virtual void GotoEndOfLine(); // go to end of the current line
- virtual void GotoTextStart(); // go to Start of text buffer
- virtual void GotoTextEnd(); // go to end of text buffer
-
- virtual void InsertChar(wchar_t ch);
- virtual void InsertString(const char *text);
- virtual void InsertString(const wchar_t *wszText);
- virtual void Backspace();
- virtual void Delete();
- virtual void SelectNone();
- virtual void OpenEditMenu();
- MESSAGE_FUNC( CutSelected, "DoCutSelected" );
- MESSAGE_FUNC( CopySelected, "DoCopySelected" );
- MESSAGE_FUNC( Paste, "DoPaste" );
-
- MESSAGE_FUNC_INT( LanguageChanged, "DoLanguageChanged", handle );
- MESSAGE_FUNC_INT( ConversionModeChanged, "DoConversionModeChanged", handle );
- MESSAGE_FUNC_INT( SentenceModeChanged, "DoSentenceModeChanged", handle );
-
- MESSAGE_FUNC_WCHARPTR( CompositionString, "DoCompositionString", string );
-
- MESSAGE_FUNC( ShowIMECandidates, "DoShowIMECandidates" );
- MESSAGE_FUNC( HideIMECandidates, "DoHideIMECandidates" );
- MESSAGE_FUNC( UpdateIMECandidates, "DoUpdateIMECandidates" );
-
- virtual void DeleteSelected();
- virtual void Undo();
- virtual void SaveUndoState();
- virtual void SetFont(HFont font);
- virtual void SetTextHidden(bool bHideText);
- virtual void SetEditable(bool state);
- virtual bool IsEditable();
- virtual void SetEnabled(bool state);
- // move the cursor to line 'line', given how many pixels are in a line
- virtual void MoveCursor(int line, int pixelsAcross);
-
- // sets the color of the background when the control is disabled
- virtual void SetDisabledBgColor(Color col);
-
- // set whether the box handles more than one line of entry
- virtual void SetMultiline(bool state);
- virtual bool IsMultiline();
-
- // sets visibility of scrollbar
- virtual void SetVerticalScrollbar(bool state);
-
- // sets whether or not the edit catches and stores ENTER key presses
- virtual void SetCatchEnterKey(bool state);
-
- // sets whether or not to send "TextNewLine" msgs when ENTER key is pressed
- virtual void SendNewLine(bool send);
-
- // sets limit of number of characters insertable into field; set to -1 to remove maximum
- // only works with if rich-edit is NOT enabled
- virtual void SetMaximumCharCount(int maxChars);
- virtual int GetMaximumCharCount();
- virtual void SetAutoProgressOnHittingCharLimit(bool state);
-
- // sets whether to wrap text once maxChars is reached (on a line by line basis)
- virtual void SetWrap(bool wrap);
-
- virtual void RecalculateLineBreaks();
- virtual void LayoutVerticalScrollBarSlider();
-
- virtual bool RequestInfo(KeyValues *outputData);
-
- // sets the height of the window so all text is visible.
- // used by tooltips
- void SetToFullHeight();
-
- // sets the width of the window so all text is visible. (will create one line)
- // used by tooltips
- void SetToFullWidth();
-
- int GetNumLines();
-
- /* INFO HANDLING
- "GetText"
- returns:
- "text" - text contained in the text box
- */
-
- /* CUSTOM MESSAGE HANDLING
- "SetText"
- input: "text" - text is set to be this string
- */
-
- /* MESSAGE SENDING (to action signal targets)
- "TextChanged" - sent when the text is edited by the user
-
- "TextNewLine" - sent when the end key is pressed in the text entry AND _sendNewLines is true
-
- "TextKillFocus" - sent when focus leaves textentry field
- */
-
- // Selects all the text in the text entry.
- void SelectAllText(bool bResetCursorPos);
- void SelectNoText();
- void SelectAllOnFirstFocus( bool status );
- void SetDrawWidth(int width); // width from right side of window we have to draw in
- int GetDrawWidth();
- void SetHorizontalScrolling(bool status); // turn horizontal scrolling on or off.
-
- // sets whether non-asci characters (unicode chars > 127) are allowed in the control - defaults to OFF
- void SetAllowNonAsciiCharacters(bool state);
-
- // sets whether or not number input only is allowed
- void SetAllowNumericInputOnly(bool state);
-
- // By default, we draw the language shortname on the right hand side of the control
- void SetDrawLanguageIDAtLeft( bool state );
-
- virtual bool GetDropContextMenu( Menu *menu, CUtlVector< KeyValues * >& data );
- virtual bool IsDroppable( CUtlVector< KeyValues * >& data );
- virtual void OnPanelDropped( CUtlVector< KeyValues * >& data );
- virtual Panel *GetDragPanel();
- virtual void OnCreateDragData( KeyValues *msg );
-
- void SelectAllOnFocusAlways( bool status );
- void SetSelectionTextColor( const Color& clr );
- void SetSelectionBgColor( const Color& clr );
- void SetSelectionUnfocusedBgColor( const Color& clr );
-
- void SetUseFallbackFont( bool bState, HFont hFallback );
-
-protected:
- virtual void ResetCursorBlink();
- virtual void PerformLayout(); // layout the text in the window
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual void PaintBackground();
- virtual int DrawChar(wchar_t ch, HFont font, int index, int x, int y);
- virtual bool DrawCursor(int x, int y);
-
- virtual void SetCharAt(wchar_t ch, int index); // set the value of a char in the text buffer
- virtual void ApplySettings( KeyValues *inResourceData );
- virtual void GetSettings( KeyValues *outResourceData );
- virtual const char *GetDescription( void );
- virtual void FireActionSignal();
- virtual bool GetSelectedRange(int& cx0,int& cx1);
- virtual void CursorToPixelSpace(int cursorPos, int &cx, int &cy);
- virtual int PixelToCursorSpace(int cx, int cy);
- virtual void AddAnotherLine(int &cx, int &cy);
- virtual int GetYStart(); // works out ypixel position drawing started at
-
- virtual bool SelectCheck( bool fromMouse = false ); // check if we are in text selection mode
- MESSAGE_FUNC_WCHARPTR( OnSetText, "SetText", text );
- MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); // respond to scroll bar events
- virtual void OnKillFocus();
- virtual void OnMouseWheeled(int delta); // respond to mouse wheel events
- virtual void OnKeyCodePressed(KeyCode code); //respond to keyboard events
- virtual void OnKeyCodeTyped(KeyCode code); //respond to keyboard events
- virtual void OnKeyTyped(wchar_t unichar); //respond to keyboard events
-
- virtual void OnCursorMoved(int x, int y); // respond to moving the cursor with mouse button down
- virtual void OnMousePressed(MouseCode code); // respond to mouse down events
- virtual void OnMouseDoublePressed( MouseCode code );
- virtual void OnMouseTriplePressed( MouseCode code );
- virtual void OnMouseReleased( MouseCode code ); // respond to mouse up events
-
- virtual void OnKeyFocusTicked(); // do while window has keyboard focus
- virtual void OnMouseFocusTicked(); // do while window has mouse focus
- virtual void OnCursorEntered(); // handle cursor entering window
- virtual void OnCursorExited(); // handle cursor exiting window
-
- virtual void OnMouseCaptureLost();
- virtual void OnSizeChanged(int newWide, int newTall);
-
- // Returns the character index the drawing should Start at
- virtual int GetStartDrawIndex(int &lineBreakIndexIndex);
-
-public:
- // helper accessors for common gets
- virtual float GetValueAsFloat();
- virtual int GetValueAsInt();
-
-protected:
- void ScrollRight(); // scroll to right until cursor is visible
- void ScrollLeft(); // scroll to left
- bool IsCursorOffRightSideOfWindow(int cursorPos); // check if cursor is off right side of window
- bool IsCursorOffLeftSideOfWindow(int cursorPos); // check if cursor is off left side of window
- void ScrollLeftForResize();
-
- void OnSetFocus();
- // Change keyboard layout type
- void OnChangeIME( bool forward );
-
- bool NeedsEllipses( HFont font, int *pIndex );
-
-private:
- MESSAGE_FUNC_INT( OnSetState, "SetState", state );
- // get index in buffer of the Start of the current line we are on
- int GetCurrentLineStart();
- // get index in buffer of the end of the current line we are on
- int GetCurrentLineEnd();
- bool IsLineBreak(int index);
- int GetCursorLine();
- void MoveScrollBar(int delta);
- void CalcBreakIndex(); // calculate _recalculateLineBreaksIndex
- void CreateEditMenu(); // create copy/cut/paste menu
-
-public:
- Menu *GetEditMenu(); // retrieve copy/cut/paste menu
-
-private:
- void FlipToLastIME();
-
-public:
- virtual void GetTextRange( wchar_t *buf, int from, int numchars ); // copy a portion of the text to the buffer and add zero-termination
- virtual void GetTextRange( char *buf, int from, int numchars ); // copy a portion of the text to the buffer and add zero-termination
-
-private:
-
- CUtlVector<wchar_t> m_TextStream; // the text in the text window is stored in this buffer
- CUtlVector<wchar_t> m_UndoTextStream; // a copy of the text buffer to revert changes
- CUtlVector<int> m_LineBreaks; // an array that holds the index in the buffer to wrap lines at
-
- int _cursorPos; // the position in the text buffer of the blinking cursor
- bool _cursorIsAtEnd;
- bool _putCursorAtEnd;
- int _undoCursorPos; // a copy of the cursor position to revert changes
- bool _cursorBlink; // whether cursor is blinking or not
- bool _hideText; // whether text is visible on screen or not
- bool _editable; // whether text is editable or not
- bool _mouseSelection; // whether we are highlighting text or not (selecting text)
- bool _mouseDragSelection; // tells weather mouse is outside window and button is down so we select text
- int _mouseSelectCursorStart; // where mouse button was pressed down in text window
- long _cursorNextBlinkTime; // time of next cursor blink
- int _cursorBlinkRate; // speed of cursor blinking
- int _select[2]; // select[1] is the offset in the text to where the cursor is currently
- // select[0] is the offset to where the cursor was dragged to. or -1 if no drag.
- int _pixelsIndent;
- int _charCount;
- int _maxCharCount; // max number of chars that can be in the text buffer
- HFont _font; // font of chars in the text buffer
- HFont _smallfont;
- bool _dataChanged; // whether anything in the window has changed.
- bool _multiline; // whether buffer is multiline or just a single line
- bool _verticalScrollbar; // whether window has a vertical scroll bar
- ScrollBar *_vertScrollBar; // the scroll bar used in the window
- Color _cursorColor; // color of the text cursor
- Color _disabledFgColor;
- Color _disabledBgColor;
- Color _selectionColor;
- Color _selectionTextColor; // color of the highlighted text
- Color _defaultSelectionBG2Color;
- int _currentStartLine; // use for checking vertical text scrolling (multiline)
- int _currentStartIndex; // use for horizontal text scrolling (!multiline)
- bool _horizScrollingAllowed; // use to disable horizontal text scrolling period.
- Color _focusEdgeColor;
- bool _catchEnterKey;
- bool _wrap;
- bool _sendNewLines;
- int _drawWidth;
-
- // selection data
- Menu *m_pEditMenu; ///cut/copy/paste popup
-
- int _recalculateBreaksIndex; // tells next linebreakindex index to Start recalculating line breaks
- bool _selectAllOnFirstFocus : 1; // highlights all text in window when focus is gained.
- bool _selectAllOnFocusAlways : 1;
- bool _firstFocusStatus; // keep track if we've had that first focus or not
- bool m_bAllowNumericInputOnly;
- bool m_bAllowNonAsciiCharacters;
- bool m_bAutoProgressOnHittingCharLimit;
-
- enum
- {
- MAX_COMPOSITION_STRING = 256,
- };
-
- wchar_t m_szComposition[ MAX_COMPOSITION_STRING ];
- Menu *m_pIMECandidates;
- int m_hPreviousIME;
- bool m_bDrawLanguageIDAtLeft;
- int m_nLangInset;
-
- bool m_bUseFallbackFont : 1;
- HFont m_hFallbackFont;
-};
-
-}
-
-#endif // TEXTENTRY_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A Class to create a window that you can type and edit text in. +// Window can hold single line or multiline text. +// If it is single it can scroll horizontally in response to +// key input and mouse selection. +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef TEXTENTRY_H +#define TEXTENTRY_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <Color.h> +#include <vgui_controls/Panel.h> +#include <vgui_controls/Label.h> +#include <vgui_controls/ListPanel.h> + +#include <utlvector.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Text-input handler +// Behaviour Specs: +// This class handles input from mouse and keyboard. +// TextEntry classes support several box styles, horizontal scrolling with no scrollbar +// vertical scrolling with or without a scrollbar, single line, multiline, +// editable and noneditable. +// +// Shared behaviour: +// URL's are a different text color and are clickable. Clicking them brings up a web browser. +// For vertical scroll bars, up and down arrows scroll one line at a time. +// Clicking and dragging the nob scrolls through text lines. +// Mouse wheel also moves the nob. +// User can select and highlight text in the window. +// Double clicking on a word selects it. +// +// Non editable: +// No blinking cursor in non editable windows. +// Right clicking mouse opens copy menu. Menu's top left corner is where mouse is. +// Ctrl-c will also copy the text. +// Editable: +// Blinking cursor is positioned where text will be inserted. +// Text keys type chars in the window. +// ctrl-c copy highlighted text +// ctrl-v paste highlighted text +// ctrl-x cut highlighted text +// ctrl-right arrow move cursor to the start of the next word +// ctrl-left arrow move cursor to the start of the prev word +// ctrl-enter delete the selected text (and inserts a newline if _catchEnterKey is true) +// insert delete selected text and pastes text from the clipboard +// delete delete the selected text +// ctrl-home move cursor to the start of the text +// ctrl-end move cursor to the end of the text. +// left arrow move cursor before prev char +// ctrl-shift left/right arrow selects text a word at a time +// right arrow move cursor before next char +// up arrow move cursor up one line. +// down arrow move cursor down one line. +// home move cursor to start of current line +// end move cursor to end of current line +// backspace delete prev char or selected text. +// Trying to move to the prev/next char/line/word when there is none moves the cursor to the +// start/end of the text. +// Horizontal scrolling: +// Trying to move to the prev/next char/line/word when there is none scrolls the text +// horizontally in the window so the new text displays at the correct side. +// When moving to prev chars scrolling is staggered. To next chars it is one char at a time. +// Cut/Copy/Paste Menu: +// Right clicking mouse brings up cut/copy/paste menu. +// If no text is highlighted the cut/copy options are dimmed. Cut is dimmed in non editable panels +// If there is no text in the clipboard or panel is not editable the paste option is dimmed. +// If the mouse is right clicked over selected text, the text stays selected. +// If the mouse is right clicked over unselected text, any selected text is deselected. +// +// +//----------------------------------------------------------------------------- +class TextEntry : public Panel +{ + DECLARE_CLASS_SIMPLE( TextEntry, Panel ); + +public: + TextEntry(Panel *parent, const char *panelName); + virtual ~TextEntry(); + + virtual void SetText(const wchar_t *wszText); + virtual void SetText(const char *text); + virtual void GetText(OUT_Z_BYTECAP(bufLenInBytes) char *buf, int bufLenInBytes); + virtual void GetText(OUT_Z_BYTECAP(bufLenInBytes) wchar_t *buf, int bufLenInBytes); + virtual int GetTextLength() const; + virtual bool IsTextFullySelected() const; + + // editing + virtual void GotoLeft(); // move cursor one char left + virtual void GotoRight(); // move cursor one char right + virtual void GotoUp(); // move cursor one line up + virtual void GotoDown(); // move cursor one line down + virtual void GotoWordRight(); // move cursor to Start of next word + virtual void GotoWordLeft(); // move cursor to Start of prev word + virtual void GotoFirstOfLine(); // go to Start of the current line + virtual void GotoEndOfLine(); // go to end of the current line + virtual void GotoTextStart(); // go to Start of text buffer + virtual void GotoTextEnd(); // go to end of text buffer + + virtual void InsertChar(wchar_t ch); + virtual void InsertString(const char *text); + virtual void InsertString(const wchar_t *wszText); + virtual void Backspace(); + virtual void Delete(); + virtual void SelectNone(); + virtual void OpenEditMenu(); + MESSAGE_FUNC( CutSelected, "DoCutSelected" ); + MESSAGE_FUNC( CopySelected, "DoCopySelected" ); + MESSAGE_FUNC( Paste, "DoPaste" ); + + MESSAGE_FUNC_INT( LanguageChanged, "DoLanguageChanged", handle ); + MESSAGE_FUNC_INT( ConversionModeChanged, "DoConversionModeChanged", handle ); + MESSAGE_FUNC_INT( SentenceModeChanged, "DoSentenceModeChanged", handle ); + + MESSAGE_FUNC_WCHARPTR( CompositionString, "DoCompositionString", string ); + + MESSAGE_FUNC( ShowIMECandidates, "DoShowIMECandidates" ); + MESSAGE_FUNC( HideIMECandidates, "DoHideIMECandidates" ); + MESSAGE_FUNC( UpdateIMECandidates, "DoUpdateIMECandidates" ); + + virtual void DeleteSelected(); + virtual void Undo(); + virtual void SaveUndoState(); + virtual void SetFont(HFont font); + virtual void SetTextHidden(bool bHideText); + virtual void SetEditable(bool state); + virtual bool IsEditable(); + virtual void SetEnabled(bool state); + // move the cursor to line 'line', given how many pixels are in a line + virtual void MoveCursor(int line, int pixelsAcross); + + // sets the color of the background when the control is disabled + virtual void SetDisabledBgColor(Color col); + + // set whether the box handles more than one line of entry + virtual void SetMultiline(bool state); + virtual bool IsMultiline(); + + // sets visibility of scrollbar + virtual void SetVerticalScrollbar(bool state); + + // sets whether or not the edit catches and stores ENTER key presses + virtual void SetCatchEnterKey(bool state); + + // sets whether or not to send "TextNewLine" msgs when ENTER key is pressed + virtual void SendNewLine(bool send); + + // sets limit of number of characters insertable into field; set to -1 to remove maximum + // only works with if rich-edit is NOT enabled + virtual void SetMaximumCharCount(int maxChars); + virtual int GetMaximumCharCount(); + virtual void SetAutoProgressOnHittingCharLimit(bool state); + + // sets whether to wrap text once maxChars is reached (on a line by line basis) + virtual void SetWrap(bool wrap); + + virtual void RecalculateLineBreaks(); + virtual void LayoutVerticalScrollBarSlider(); + + virtual bool RequestInfo(KeyValues *outputData); + + // sets the height of the window so all text is visible. + // used by tooltips + void SetToFullHeight(); + + // sets the width of the window so all text is visible. (will create one line) + // used by tooltips + void SetToFullWidth(); + + int GetNumLines(); + + /* INFO HANDLING + "GetText" + returns: + "text" - text contained in the text box + */ + + /* CUSTOM MESSAGE HANDLING + "SetText" + input: "text" - text is set to be this string + */ + + /* MESSAGE SENDING (to action signal targets) + "TextChanged" - sent when the text is edited by the user + + "TextNewLine" - sent when the end key is pressed in the text entry AND _sendNewLines is true + + "TextKillFocus" - sent when focus leaves textentry field + */ + + // Selects all the text in the text entry. + void SelectAllText(bool bResetCursorPos); + void SelectNoText(); + void SelectAllOnFirstFocus( bool status ); + void SetDrawWidth(int width); // width from right side of window we have to draw in + int GetDrawWidth(); + void SetHorizontalScrolling(bool status); // turn horizontal scrolling on or off. + + // sets whether non-asci characters (unicode chars > 127) are allowed in the control - defaults to OFF + void SetAllowNonAsciiCharacters(bool state); + + // sets whether or not number input only is allowed + void SetAllowNumericInputOnly(bool state); + + // By default, we draw the language shortname on the right hand side of the control + void SetDrawLanguageIDAtLeft( bool state ); + + virtual bool GetDropContextMenu( Menu *menu, CUtlVector< KeyValues * >& data ); + virtual bool IsDroppable( CUtlVector< KeyValues * >& data ); + virtual void OnPanelDropped( CUtlVector< KeyValues * >& data ); + virtual Panel *GetDragPanel(); + virtual void OnCreateDragData( KeyValues *msg ); + + void SelectAllOnFocusAlways( bool status ); + void SetSelectionTextColor( const Color& clr ); + void SetSelectionBgColor( const Color& clr ); + void SetSelectionUnfocusedBgColor( const Color& clr ); + + void SetUseFallbackFont( bool bState, HFont hFallback ); + +protected: + virtual void ResetCursorBlink(); + virtual void PerformLayout(); // layout the text in the window + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual void PaintBackground(); + virtual int DrawChar(wchar_t ch, HFont font, int index, int x, int y); + virtual bool DrawCursor(int x, int y); + + virtual void SetCharAt(wchar_t ch, int index); // set the value of a char in the text buffer + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void GetSettings( KeyValues *outResourceData ); + virtual const char *GetDescription( void ); + virtual void FireActionSignal(); + virtual bool GetSelectedRange(int& cx0,int& cx1); + virtual void CursorToPixelSpace(int cursorPos, int &cx, int &cy); + virtual int PixelToCursorSpace(int cx, int cy); + virtual void AddAnotherLine(int &cx, int &cy); + virtual int GetYStart(); // works out ypixel position drawing started at + + virtual bool SelectCheck( bool fromMouse = false ); // check if we are in text selection mode + MESSAGE_FUNC_WCHARPTR( OnSetText, "SetText", text ); + MESSAGE_FUNC( OnSliderMoved, "ScrollBarSliderMoved" ); // respond to scroll bar events + virtual void OnKillFocus(); + virtual void OnMouseWheeled(int delta); // respond to mouse wheel events + virtual void OnKeyCodePressed(KeyCode code); //respond to keyboard events + virtual void OnKeyCodeTyped(KeyCode code); //respond to keyboard events + virtual void OnKeyTyped(wchar_t unichar); //respond to keyboard events + + virtual void OnCursorMoved(int x, int y); // respond to moving the cursor with mouse button down + virtual void OnMousePressed(MouseCode code); // respond to mouse down events + virtual void OnMouseDoublePressed( MouseCode code ); + virtual void OnMouseTriplePressed( MouseCode code ); + virtual void OnMouseReleased( MouseCode code ); // respond to mouse up events + + virtual void OnKeyFocusTicked(); // do while window has keyboard focus + virtual void OnMouseFocusTicked(); // do while window has mouse focus + virtual void OnCursorEntered(); // handle cursor entering window + virtual void OnCursorExited(); // handle cursor exiting window + + virtual void OnMouseCaptureLost(); + virtual void OnSizeChanged(int newWide, int newTall); + + // Returns the character index the drawing should Start at + virtual int GetStartDrawIndex(int &lineBreakIndexIndex); + +public: + // helper accessors for common gets + virtual float GetValueAsFloat(); + virtual int GetValueAsInt(); + +protected: + void ScrollRight(); // scroll to right until cursor is visible + void ScrollLeft(); // scroll to left + bool IsCursorOffRightSideOfWindow(int cursorPos); // check if cursor is off right side of window + bool IsCursorOffLeftSideOfWindow(int cursorPos); // check if cursor is off left side of window + void ScrollLeftForResize(); + + void OnSetFocus(); + // Change keyboard layout type + void OnChangeIME( bool forward ); + + bool NeedsEllipses( HFont font, int *pIndex ); + +private: + MESSAGE_FUNC_INT( OnSetState, "SetState", state ); + // get index in buffer of the Start of the current line we are on + int GetCurrentLineStart(); + // get index in buffer of the end of the current line we are on + int GetCurrentLineEnd(); + bool IsLineBreak(int index); + int GetCursorLine(); + void MoveScrollBar(int delta); + void CalcBreakIndex(); // calculate _recalculateLineBreaksIndex + void CreateEditMenu(); // create copy/cut/paste menu + +public: + Menu *GetEditMenu(); // retrieve copy/cut/paste menu + +private: + void FlipToLastIME(); + +public: + virtual void GetTextRange( wchar_t *buf, int from, int numchars ); // copy a portion of the text to the buffer and add zero-termination + virtual void GetTextRange( char *buf, int from, int numchars ); // copy a portion of the text to the buffer and add zero-termination + +private: + + CUtlVector<wchar_t> m_TextStream; // the text in the text window is stored in this buffer + CUtlVector<wchar_t> m_UndoTextStream; // a copy of the text buffer to revert changes + CUtlVector<int> m_LineBreaks; // an array that holds the index in the buffer to wrap lines at + + int _cursorPos; // the position in the text buffer of the blinking cursor + bool _cursorIsAtEnd; + bool _putCursorAtEnd; + int _undoCursorPos; // a copy of the cursor position to revert changes + bool _cursorBlink; // whether cursor is blinking or not + bool _hideText; // whether text is visible on screen or not + bool _editable; // whether text is editable or not + bool _mouseSelection; // whether we are highlighting text or not (selecting text) + bool _mouseDragSelection; // tells weather mouse is outside window and button is down so we select text + int _mouseSelectCursorStart; // where mouse button was pressed down in text window + long _cursorNextBlinkTime; // time of next cursor blink + int _cursorBlinkRate; // speed of cursor blinking + int _select[2]; // select[1] is the offset in the text to where the cursor is currently + // select[0] is the offset to where the cursor was dragged to. or -1 if no drag. + int _pixelsIndent; + int _charCount; + int _maxCharCount; // max number of chars that can be in the text buffer + HFont _font; // font of chars in the text buffer + HFont _smallfont; + bool _dataChanged; // whether anything in the window has changed. + bool _multiline; // whether buffer is multiline or just a single line + bool _verticalScrollbar; // whether window has a vertical scroll bar + ScrollBar *_vertScrollBar; // the scroll bar used in the window + Color _cursorColor; // color of the text cursor + Color _disabledFgColor; + Color _disabledBgColor; + Color _selectionColor; + Color _selectionTextColor; // color of the highlighted text + Color _defaultSelectionBG2Color; + int _currentStartLine; // use for checking vertical text scrolling (multiline) + int _currentStartIndex; // use for horizontal text scrolling (!multiline) + bool _horizScrollingAllowed; // use to disable horizontal text scrolling period. + Color _focusEdgeColor; + bool _catchEnterKey; + bool _wrap; + bool _sendNewLines; + int _drawWidth; + + // selection data + Menu *m_pEditMenu; ///cut/copy/paste popup + + int _recalculateBreaksIndex; // tells next linebreakindex index to Start recalculating line breaks + bool _selectAllOnFirstFocus : 1; // highlights all text in window when focus is gained. + bool _selectAllOnFocusAlways : 1; + bool _firstFocusStatus; // keep track if we've had that first focus or not + bool m_bAllowNumericInputOnly; + bool m_bAllowNonAsciiCharacters; + bool m_bAutoProgressOnHittingCharLimit; + + enum + { + MAX_COMPOSITION_STRING = 256, + }; + + wchar_t m_szComposition[ MAX_COMPOSITION_STRING ]; + Menu *m_pIMECandidates; + int m_hPreviousIME; + bool m_bDrawLanguageIDAtLeft; + int m_nLangInset; + + bool m_bUseFallbackFont : 1; + HFont m_hFallbackFont; +}; + +} + +#endif // TEXTENTRY_H diff --git a/mp/src/public/vgui_controls/TextImage.h b/mp/src/public/vgui_controls/TextImage.h index 676ae893..499785ff 100644 --- a/mp/src/public/vgui_controls/TextImage.h +++ b/mp/src/public/vgui_controls/TextImage.h @@ -1,143 +1,143 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef TEXTIMAGE_H
-#define TEXTIMAGE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui/ILocalize.h>
-#include <vgui_controls/Image.h>
-
-#include <utlvector.h>
-#include <UtlSortVector.h>
-
-class KeyValues;
-
-namespace vgui
-{
-
-struct label_colorchange_t
-{
- Color color;
- int textStreamIndex;
-};
-
-// Used to sort the color changes into sequential order.
-class CColorChangeListLess
-{
-public:
- bool Less( const label_colorchange_t &src1, const label_colorchange_t &src2, void *pCtx )
- {
- if ( src1.textStreamIndex < src2.textStreamIndex )
- return true;
-
- return false;
- }
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Image that handles drawing of a text string
-//-----------------------------------------------------------------------------
-class TextImage : public Image
-{
-public:
- TextImage(const char *text);
- TextImage(const wchar_t *wszText);
- ~TextImage();
-
-public:
- // takes the string and looks it up in the localization file to convert it to unicode
- virtual void SetText(const char *text);
- // sets unicode text directly
- virtual void SetText(const wchar_t *text, bool bClearUnlocalizedSymbol = false);
- // get the full text in the image
- virtual void GetText(char *buffer, int bufferSize);
- virtual void GetText(wchar_t *buffer, int bufferLength);
- // get the text in it's unlocalized form
- virtual void GetUnlocalizedText(char *buffer, int bufferSize);
- virtual StringIndex_t GetUnlocalizedTextSymbol();
-
- // set the font of the text
- virtual void SetFont(vgui::HFont font);
- // get the font of the text
- virtual vgui::HFont GetFont();
-
- // set the width of the text to be drawn
- // use this function if the textImage is in another window to cause
- // the text to be truncated to the width of the window (elipsis added)
- void SetDrawWidth(int width);
- // get the width of the text to be drawn
- void GetDrawWidth(int &width);
-
- void ResizeImageToContent();
- void ResizeImageToContentMaxWidth( int nMaxWidth );
-
- // set the size of the image
- virtual void SetSize(int wide,int tall);
-
- // get the full size of a text string
- virtual void GetContentSize(int &wide, int &tall);
-
- // draws the text
- virtual void Paint();
-
- void SetWrap( bool bWrap );
- void RecalculateNewLinePositions();
-
- void SetUseFallbackFont( bool bState, HFont hFallback );
-
- void SetAllCaps( bool bAllCaps );
-
- void SetCenterWrap( bool bWrap );
- void RecalculateCenterWrapIndents();
-
- const wchar_t *GetUText( void ) { return _utext; }
-
- void AddColorChange( Color col, int iTextStreamIndex );
- void SetColorChangeStream( CUtlSortVector<label_colorchange_t,CColorChangeListLess> *pUtlVecStream );
- void ClearColorChangeStream( void ) { m_ColorChangeStream.Purge(); }
-
-protected:
- // truncate the _text string to fit into the draw width
- void SizeText(wchar_t *tempText, int stringLength);
- // gets the size of a specified piece of text
- virtual void GetTextSize(int &wide, int &tall);
-
-private:
- void RecalculateEllipsesPosition();
-
- wchar_t *_utext; // unicode version of the text
- short _textBufferLen; // size of the text buffer
- short _textLen; // length of the text string
- vgui::HFont _font; // font of the text string
- vgui::HFont _fallbackFont;
- int _drawWidth; // this is the width of the window we are drawing into.
- // if there is not enough room truncate the txt and add an elipsis
-
- StringIndex_t _unlocalizedTextSymbol; // store off the unlocalized text index for build mode
- wchar_t *m_pwszEllipsesPosition;
-
- bool m_bRecalculateTruncation : 1;
- bool m_bWrap : 1;
- bool m_bUseFallbackFont : 1;
- bool m_bRenderUsingFallbackFont : 1;
- bool m_bAllCaps : 1;
- CUtlVector<wchar_t *> m_LineBreaks; // an array that holds the index in the buffer to wrap lines at
-
- bool m_bWrapCenter; // Separate from m_bWrap to ensure it doesn't break legacy code.
- CUtlVector<int> m_LineXIndent; // For centered word wrap. The X indent for each line.
-
- CUtlSortVector<label_colorchange_t,CColorChangeListLess> m_ColorChangeStream;
-};
-
-} // namespace vgui
-
-#endif // TEXTIMAGE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef TEXTIMAGE_H +#define TEXTIMAGE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui/ILocalize.h> +#include <vgui_controls/Image.h> + +#include <utlvector.h> +#include <UtlSortVector.h> + +class KeyValues; + +namespace vgui +{ + +struct label_colorchange_t +{ + Color color; + int textStreamIndex; +}; + +// Used to sort the color changes into sequential order. +class CColorChangeListLess +{ +public: + bool Less( const label_colorchange_t &src1, const label_colorchange_t &src2, void *pCtx ) + { + if ( src1.textStreamIndex < src2.textStreamIndex ) + return true; + + return false; + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Image that handles drawing of a text string +//----------------------------------------------------------------------------- +class TextImage : public Image +{ +public: + TextImage(const char *text); + TextImage(const wchar_t *wszText); + ~TextImage(); + +public: + // takes the string and looks it up in the localization file to convert it to unicode + virtual void SetText(const char *text); + // sets unicode text directly + virtual void SetText(const wchar_t *text, bool bClearUnlocalizedSymbol = false); + // get the full text in the image + virtual void GetText(char *buffer, int bufferSize); + virtual void GetText(wchar_t *buffer, int bufferLength); + // get the text in it's unlocalized form + virtual void GetUnlocalizedText(char *buffer, int bufferSize); + virtual StringIndex_t GetUnlocalizedTextSymbol(); + + // set the font of the text + virtual void SetFont(vgui::HFont font); + // get the font of the text + virtual vgui::HFont GetFont(); + + // set the width of the text to be drawn + // use this function if the textImage is in another window to cause + // the text to be truncated to the width of the window (elipsis added) + void SetDrawWidth(int width); + // get the width of the text to be drawn + void GetDrawWidth(int &width); + + void ResizeImageToContent(); + void ResizeImageToContentMaxWidth( int nMaxWidth ); + + // set the size of the image + virtual void SetSize(int wide,int tall); + + // get the full size of a text string + virtual void GetContentSize(int &wide, int &tall); + + // draws the text + virtual void Paint(); + + void SetWrap( bool bWrap ); + void RecalculateNewLinePositions(); + + void SetUseFallbackFont( bool bState, HFont hFallback ); + + void SetAllCaps( bool bAllCaps ); + + void SetCenterWrap( bool bWrap ); + void RecalculateCenterWrapIndents(); + + const wchar_t *GetUText( void ) { return _utext; } + + void AddColorChange( Color col, int iTextStreamIndex ); + void SetColorChangeStream( CUtlSortVector<label_colorchange_t,CColorChangeListLess> *pUtlVecStream ); + void ClearColorChangeStream( void ) { m_ColorChangeStream.Purge(); } + +protected: + // truncate the _text string to fit into the draw width + void SizeText(wchar_t *tempText, int stringLength); + // gets the size of a specified piece of text + virtual void GetTextSize(int &wide, int &tall); + +private: + void RecalculateEllipsesPosition(); + + wchar_t *_utext; // unicode version of the text + short _textBufferLen; // size of the text buffer + short _textLen; // length of the text string + vgui::HFont _font; // font of the text string + vgui::HFont _fallbackFont; + int _drawWidth; // this is the width of the window we are drawing into. + // if there is not enough room truncate the txt and add an elipsis + + StringIndex_t _unlocalizedTextSymbol; // store off the unlocalized text index for build mode + wchar_t *m_pwszEllipsesPosition; + + bool m_bRecalculateTruncation : 1; + bool m_bWrap : 1; + bool m_bUseFallbackFont : 1; + bool m_bRenderUsingFallbackFont : 1; + bool m_bAllCaps : 1; + CUtlVector<wchar_t *> m_LineBreaks; // an array that holds the index in the buffer to wrap lines at + + bool m_bWrapCenter; // Separate from m_bWrap to ensure it doesn't break legacy code. + CUtlVector<int> m_LineXIndent; // For centered word wrap. The X indent for each line. + + CUtlSortVector<label_colorchange_t,CColorChangeListLess> m_ColorChangeStream; +}; + +} // namespace vgui + +#endif // TEXTIMAGE_H diff --git a/mp/src/public/vgui_controls/ToggleButton.h b/mp/src/public/vgui_controls/ToggleButton.h index d14237e0..355e51a7 100644 --- a/mp/src/public/vgui_controls/ToggleButton.h +++ b/mp/src/public/vgui_controls/ToggleButton.h @@ -1,54 +1,54 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef TOGGLEBUTTON_H
-#define TOGGLEBUTTON_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Button.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Type of button that when pressed stays selected & depressed until pressed again
-//-----------------------------------------------------------------------------
-class ToggleButton : public Button
-{
- DECLARE_CLASS_SIMPLE( ToggleButton, Button );
-
-public:
- ToggleButton(Panel *parent, const char *panelName, const char *text);
-
- virtual void DoClick();
-
- /* messages sent (get via AddActionSignalTarget()):
- "ButtonToggled"
- int "state"
- */
-
-protected:
- // overrides
- virtual void OnMouseDoublePressed(MouseCode code);
-
- virtual Color GetButtonFgColor();
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
- virtual bool CanBeDefaultButton(void);
- virtual void OnKeyCodePressed(KeyCode code);
-
-private:
- Color _selectedColor;
-};
-
-} // namespace vgui
-
-#endif // TOGGLEBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef TOGGLEBUTTON_H +#define TOGGLEBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Button.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Type of button that when pressed stays selected & depressed until pressed again +//----------------------------------------------------------------------------- +class ToggleButton : public Button +{ + DECLARE_CLASS_SIMPLE( ToggleButton, Button ); + +public: + ToggleButton(Panel *parent, const char *panelName, const char *text); + + virtual void DoClick(); + + /* messages sent (get via AddActionSignalTarget()): + "ButtonToggled" + int "state" + */ + +protected: + // overrides + virtual void OnMouseDoublePressed(MouseCode code); + + virtual Color GetButtonFgColor(); + virtual void ApplySchemeSettings(IScheme *pScheme); + + virtual bool CanBeDefaultButton(void); + virtual void OnKeyCodePressed(KeyCode code); + +private: + Color _selectedColor; +}; + +} // namespace vgui + +#endif // TOGGLEBUTTON_H diff --git a/mp/src/public/vgui_controls/ToolWindow.h b/mp/src/public/vgui_controls/ToolWindow.h index 5d4db773..870f5339 100644 --- a/mp/src/public/vgui_controls/ToolWindow.h +++ b/mp/src/public/vgui_controls/ToolWindow.h @@ -1,78 +1,78 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef TOOLWINDOW_H
-#define TOOLWINDOW_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Frame.h>
-
-namespace vgui
-{
-
-class ToolWindow;
-
-// So that an app can have a "custom" tool window class created during window drag/drop operations on the property sheet
-class IToolWindowFactory
-{
-public:
- virtual ToolWindow *InstanceToolWindow( Panel *parent, bool contextLabel, Panel *firstPage, char const *title, bool contextMenu ) = 0;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Simple frame that holds a property sheet
-//-----------------------------------------------------------------------------
-class ToolWindow : public Frame
-{
- DECLARE_CLASS_SIMPLE( ToolWindow, Frame );
-
-public:
- ToolWindow(Panel *parent, bool contextLabel, IToolWindowFactory *factory = 0, Panel *page = NULL, char const *title = NULL, bool contextMenu = false, bool inGlobalList = true );
-
- ~ToolWindow();
-
- virtual bool IsDraggableTabContainer() const;
-
- // returns a pointer to the PropertySheet this dialog encapsulates
- PropertySheet *GetPropertySheet();
-
- // wrapper for PropertySheet interface
- void AddPage(Panel *page, const char *title, bool contextMenu );
- void RemovePage( Panel *page );
- Panel *GetActivePage();
- void SetActivePage( Panel *page );
-
- void SetToolWindowFactory( IToolWindowFactory *factory );
- IToolWindowFactory *GetToolWindowFactory();
-
- static int GetToolWindowCount();
- static ToolWindow *GetToolWindow( int index );
-
- static CUtlVector< ToolWindow * > s_ToolWindows;
-
- virtual void Grow( int edge = 0, int from_x = -1, int from_y = -1 );
- virtual void GrowFromClick();
-
-protected:
- // vgui overrides
- virtual void PerformLayout();
- virtual void ActivateBuildMode();
- virtual void RequestFocus(int direction = 0);
- virtual void OnMousePressed(MouseCode code);
- virtual void OnMouseDoublePressed(MouseCode code);
-
-private:
- PropertySheet *m_pPropertySheet;
- IToolWindowFactory *m_pFactory;
-};
-
-}; // vgui
-
-
-#endif // TOOLWINDOW_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef TOOLWINDOW_H +#define TOOLWINDOW_H +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Frame.h> + +namespace vgui +{ + +class ToolWindow; + +// So that an app can have a "custom" tool window class created during window drag/drop operations on the property sheet +class IToolWindowFactory +{ +public: + virtual ToolWindow *InstanceToolWindow( Panel *parent, bool contextLabel, Panel *firstPage, char const *title, bool contextMenu ) = 0; +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple frame that holds a property sheet +//----------------------------------------------------------------------------- +class ToolWindow : public Frame +{ + DECLARE_CLASS_SIMPLE( ToolWindow, Frame ); + +public: + ToolWindow(Panel *parent, bool contextLabel, IToolWindowFactory *factory = 0, Panel *page = NULL, char const *title = NULL, bool contextMenu = false, bool inGlobalList = true ); + + ~ToolWindow(); + + virtual bool IsDraggableTabContainer() const; + + // returns a pointer to the PropertySheet this dialog encapsulates + PropertySheet *GetPropertySheet(); + + // wrapper for PropertySheet interface + void AddPage(Panel *page, const char *title, bool contextMenu ); + void RemovePage( Panel *page ); + Panel *GetActivePage(); + void SetActivePage( Panel *page ); + + void SetToolWindowFactory( IToolWindowFactory *factory ); + IToolWindowFactory *GetToolWindowFactory(); + + static int GetToolWindowCount(); + static ToolWindow *GetToolWindow( int index ); + + static CUtlVector< ToolWindow * > s_ToolWindows; + + virtual void Grow( int edge = 0, int from_x = -1, int from_y = -1 ); + virtual void GrowFromClick(); + +protected: + // vgui overrides + virtual void PerformLayout(); + virtual void ActivateBuildMode(); + virtual void RequestFocus(int direction = 0); + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + +private: + PropertySheet *m_pPropertySheet; + IToolWindowFactory *m_pFactory; +}; + +}; // vgui + + +#endif // TOOLWINDOW_H diff --git a/mp/src/public/vgui_controls/Tooltip.h b/mp/src/public/vgui_controls/Tooltip.h index ec27fe76..2c7ec984 100644 --- a/mp/src/public/vgui_controls/Tooltip.h +++ b/mp/src/public/vgui_controls/Tooltip.h @@ -1,76 +1,76 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Creates a Message box with a question in it and yes/no buttons
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef TOOLTIP_H
-#define TOOLTIP_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Controls.h>
-#include <utlvector.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Tooltip for a panel - shows text when cursor hovers over a panel
-//-----------------------------------------------------------------------------
-class BaseTooltip
-{
-public:
- BaseTooltip(Panel *parent, const char *text = NULL);
-
- virtual void SetText(const char *text);
- virtual const char *GetText();
-
- virtual void ShowTooltip(Panel *currentPanel);
- virtual void HideTooltip();
-
- bool ShouldLayout( void );
- virtual void PerformLayout() { return; }
- virtual void PositionWindow( Panel *pTipPanel );
-
- void ResetDelay();
- void SetTooltipFormatToSingleLine();
- void SetTooltipFormatToMultiLine();
- void SetTooltipDelay(int tooltipDelayMilliseconds);
- int GetTooltipDelay();
- void SetEnabled( bool bState );
-
-private:
- Panel *m_pParent;
- virtual void ApplySchemeSettings(IScheme *pScheme) {};
-protected:
- CUtlVector<char> m_Text;
- int _delay; // delay that counts down
- int _tooltipDelay; // delay before tooltip comes up.
- bool _makeVisible : 1;
- bool _displayOnOneLine : 1;
- bool _isDirty : 1;
- bool _enabled : 1;
-};
-
-class TextTooltip : public BaseTooltip
-{
-public:
- TextTooltip(Panel *parent, const char *text = NULL);
- ~TextTooltip();
-
- virtual void SetText(const char *text);
- virtual void ShowTooltip(Panel *currentPanel);
- virtual void HideTooltip();
- virtual void SizeTextWindow();
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
-};
-
-};
-
-#endif // TOOLTIP_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Creates a Message box with a question in it and yes/no buttons +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef TOOLTIP_H +#define TOOLTIP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Controls.h> +#include <utlvector.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Tooltip for a panel - shows text when cursor hovers over a panel +//----------------------------------------------------------------------------- +class BaseTooltip +{ +public: + BaseTooltip(Panel *parent, const char *text = NULL); + + virtual void SetText(const char *text); + virtual const char *GetText(); + + virtual void ShowTooltip(Panel *currentPanel); + virtual void HideTooltip(); + + bool ShouldLayout( void ); + virtual void PerformLayout() { return; } + virtual void PositionWindow( Panel *pTipPanel ); + + void ResetDelay(); + void SetTooltipFormatToSingleLine(); + void SetTooltipFormatToMultiLine(); + void SetTooltipDelay(int tooltipDelayMilliseconds); + int GetTooltipDelay(); + void SetEnabled( bool bState ); + +private: + Panel *m_pParent; + virtual void ApplySchemeSettings(IScheme *pScheme) {}; +protected: + CUtlVector<char> m_Text; + int _delay; // delay that counts down + int _tooltipDelay; // delay before tooltip comes up. + bool _makeVisible : 1; + bool _displayOnOneLine : 1; + bool _isDirty : 1; + bool _enabled : 1; +}; + +class TextTooltip : public BaseTooltip +{ +public: + TextTooltip(Panel *parent, const char *text = NULL); + ~TextTooltip(); + + virtual void SetText(const char *text); + virtual void ShowTooltip(Panel *currentPanel); + virtual void HideTooltip(); + virtual void SizeTextWindow(); + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); +}; + +}; + +#endif // TOOLTIP_H diff --git a/mp/src/public/vgui_controls/TreeView.h b/mp/src/public/vgui_controls/TreeView.h index 141469c4..521d1691 100644 --- a/mp/src/public/vgui_controls/TreeView.h +++ b/mp/src/public/vgui_controls/TreeView.h @@ -1,203 +1,203 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef TREEVIEW_H
-#define TREEVIEW_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <utllinkedlist.h>
-#include <utlvector.h>
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-
-class KeyValues;
-
-namespace vgui
-{
-
-class ExpandButton;
-class TreeNode;
-class TreeViewSubPanel;
-
-// sorting function, should return true if node1 should be displayed before node2
-typedef bool (*TreeViewSortFunc_t)(KeyValues *node1, KeyValues *node2);
-
-class TreeView : public Panel
-{
- DECLARE_CLASS_SIMPLE( TreeView, Panel );
-
-public:
- TreeView(Panel *parent, const char *panelName);
- ~TreeView();
-
- void SetSortFunc(TreeViewSortFunc_t pSortFunc);
-
- virtual int AddItem(KeyValues *data, int parentItemIndex);
-
- virtual int GetRootItemIndex();
- virtual int GetNumChildren( int itemIndex );
- virtual int GetChild( int iParentItemIndex, int iChild ); // between 0 and GetNumChildren( iParentItemIndex ).
-
- virtual int GetItemCount(void);
- virtual KeyValues *GetItemData(int itemIndex);
- virtual void RemoveItem(int itemIndex, bool bPromoteChildren, bool bRecursivelyRemove = false );
- virtual void RemoveAll();
- virtual bool ModifyItem(int itemIndex, KeyValues *data);
- virtual int GetItemParent(int itemIndex);
-
- virtual void SetFont(HFont font);
-
- virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone);
-
- void SetAllowMultipleSelections( bool state );
- bool IsMultipleSelectionAllowed() const;
-
- virtual void ClearSelection();
- virtual void AddSelectedItem( int itemIndex, bool clearCurrentSelection, bool requestFocus = true, bool bMakeItemVisible = true );
- virtual void RemoveSelectedItem( int itemIndex );
- virtual void SelectAll();
-
- virtual bool IsItemSelected( int itemIndex );
- virtual void RangeSelectItems( int clickedItem );
- virtual void FindNodesInRange( int startItem, int endItem, CUtlVector< int >& itemIndices );
-
- // returns the id of the currently selected item, -1 if nothing is selected
- virtual int GetSelectedItemCount() const;
- virtual int GetFirstSelectedItem() const;
- virtual void GetSelectedItems( CUtlVector< int >& list );
- virtual void GetSelectedItemData( CUtlVector< KeyValues * >& list );
-
- // set colors for individual elments
- virtual void SetItemFgColor(int itemIndex, const Color& color);
- virtual void SetItemBgColor(int itemIndex, const Color& color);
- virtual void SetItemSelectionTextColor( int itemIndex, const Color& clr );
- virtual void SetItemSelectionBgColor( int itemIndex, const Color& clr );
- virtual void SetItemSelectionUnfocusedBgColor( int itemIndex, const Color& clr );
-
- // returns true if the itemID is valid for use
- virtual bool IsItemIDValid(int itemIndex);
-
- // item iterators
- // iterate from [0..GetHighestItemID()],
- // and check each with IsItemIDValid() before using
- virtual int GetHighestItemID();
-
- virtual void ExpandItem(int itemIndex, bool bExpand);
- virtual bool IsItemExpanded( int itemIndex );
-
- virtual void MakeItemVisible(int itemIndex);
-
- // This tells which of the visible items is the top one.
- virtual void GetVBarInfo( int &top, int &nItemsVisible, bool& hbarVisible );
-
- virtual HFont GetFont();
-
- virtual void GenerateDragDataForItem( int itemIndex, KeyValues *msg );
- virtual void SetDragEnabledItems( bool state );
-
- virtual void OnLabelChanged( int itemIndex, char const *oldString, char const *newString );
- virtual bool IsLabelEditingAllowed() const;
- virtual bool IsLabelBeingEdited() const;
- virtual void SetAllowLabelEditing( bool state );
-
- /* message sent
-
- "TreeViewItemSelected" int "itemIndex"
- called when the selected item changes
- "TreeViewItemDeselected" int "itemIndex"
- called when item is deselected
- */
- int GetRowHeight();
- int GetVisibleMaxWidth();
- virtual void OnMousePressed(MouseCode code);
-
- // By default, the tree view expands nodes on left-click. This enables/disables that feature
- void EnableExpandTreeOnLeftClick( bool bEnable );
-
- virtual void SetLabelEditingAllowed( int itemIndex, bool state );
- virtual void StartEditingLabel( int itemIndex );
-
- virtual bool IsItemDroppable( int itemIndex, CUtlVector< KeyValues * >& msglist );
- virtual void OnItemDropped( int itemIndex, CUtlVector< KeyValues * >& msglist );
- virtual bool GetItemDropContextMenu( int itemIndex, Menu *menu, CUtlVector< KeyValues * >& msglist );
- virtual HCursor GetItemDropCursor( int itemIndex, CUtlVector< KeyValues * >& msglist );
-
- virtual int GetPrevChildItemIndex( int itemIndex );
- virtual int GetNextChildItemIndex( int itemIndex );
-
- virtual void PerformLayout();
-
- // Makes the scrollbar parented to some other panel...
- ScrollBar *SetScrollBarExternal( bool vertical, Panel *newParent );
- void GetScrollBarSize( bool vertical, int& w, int& h );
-
- void SetMultipleItemDragEnabled( bool state ); // if this is set, then clicking on one row and dragging will select a run or items, etc.
- bool IsMultipleItemDragEnabled() const;
-
- int FindItemUnderMouse( int mx, int my );
-
-protected:
- // functions to override
- // called when a node, marked as "Expand", needs to generate it's child nodes when expanded
- virtual void GenerateChildrenOfNode(int itemIndex) {}
-
- // override to open a custom context menu on a node being selected and right-clicked
- virtual void GenerateContextMenu( int itemIndex, int x, int y ) {}
-
- // overrides
- virtual void OnMouseWheeled(int delta);
- virtual void OnSizeChanged(int wide, int tall);
- virtual void ApplySchemeSettings(IScheme *pScheme);
- MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
- virtual void SetBgColor( Color color );
-
-private:
- friend class TreeNode;
- friend class TreeNodeText;
-
- TreeNode* GetItem( int itemIndex );
- virtual void RemoveChildrenOfNode( int itemIndex );
- void SetLabelBeingEdited( bool state );
-
- // Clean up the image list
- void CleanUpImageList( );
-
- // to be accessed by TreeNodes
- IImage* GetImage(int index);
-
- // bools
- bool m_bAllowLabelEditing : 1;
- bool m_bDragEnabledItems : 1;
- bool m_bDeleteImageListWhenDone : 1;
- bool m_bLeftClickExpandsTree : 1;
- bool m_bLabelBeingEdited : 1;
- bool m_bMultipleItemDragging : 1;
- bool m_bAllowMultipleSelections : 1;
-
- // cross reference - no hierarchy ordering in this list
- CUtlLinkedList<TreeNode *, int> m_NodeList;
- ScrollBar *m_pHorzScrollBar, *m_pVertScrollBar;
- int m_nRowHeight;
-
- ImageList *m_pImageList;
- TreeNode *m_pRootNode;
- TreeViewSortFunc_t m_pSortFunc;
- HFont m_Font;
-
- CUtlVector< TreeNode * > m_SelectedItems;
- TreeViewSubPanel *m_pSubPanel;
-
- int m_nMostRecentlySelectedItem;
- bool m_bScrollbarExternal[ 2 ]; // 0 = vert, 1 = horz
-};
-
-}
-
-#endif // TREEVIEW_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef TREEVIEW_H +#define TREEVIEW_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <utllinkedlist.h> +#include <utlvector.h> +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> + +class KeyValues; + +namespace vgui +{ + +class ExpandButton; +class TreeNode; +class TreeViewSubPanel; + +// sorting function, should return true if node1 should be displayed before node2 +typedef bool (*TreeViewSortFunc_t)(KeyValues *node1, KeyValues *node2); + +class TreeView : public Panel +{ + DECLARE_CLASS_SIMPLE( TreeView, Panel ); + +public: + TreeView(Panel *parent, const char *panelName); + ~TreeView(); + + void SetSortFunc(TreeViewSortFunc_t pSortFunc); + + virtual int AddItem(KeyValues *data, int parentItemIndex); + + virtual int GetRootItemIndex(); + virtual int GetNumChildren( int itemIndex ); + virtual int GetChild( int iParentItemIndex, int iChild ); // between 0 and GetNumChildren( iParentItemIndex ). + + virtual int GetItemCount(void); + virtual KeyValues *GetItemData(int itemIndex); + virtual void RemoveItem(int itemIndex, bool bPromoteChildren, bool bRecursivelyRemove = false ); + virtual void RemoveAll(); + virtual bool ModifyItem(int itemIndex, KeyValues *data); + virtual int GetItemParent(int itemIndex); + + virtual void SetFont(HFont font); + + virtual void SetImageList(ImageList *imageList, bool deleteImageListWhenDone); + + void SetAllowMultipleSelections( bool state ); + bool IsMultipleSelectionAllowed() const; + + virtual void ClearSelection(); + virtual void AddSelectedItem( int itemIndex, bool clearCurrentSelection, bool requestFocus = true, bool bMakeItemVisible = true ); + virtual void RemoveSelectedItem( int itemIndex ); + virtual void SelectAll(); + + virtual bool IsItemSelected( int itemIndex ); + virtual void RangeSelectItems( int clickedItem ); + virtual void FindNodesInRange( int startItem, int endItem, CUtlVector< int >& itemIndices ); + + // returns the id of the currently selected item, -1 if nothing is selected + virtual int GetSelectedItemCount() const; + virtual int GetFirstSelectedItem() const; + virtual void GetSelectedItems( CUtlVector< int >& list ); + virtual void GetSelectedItemData( CUtlVector< KeyValues * >& list ); + + // set colors for individual elments + virtual void SetItemFgColor(int itemIndex, const Color& color); + virtual void SetItemBgColor(int itemIndex, const Color& color); + virtual void SetItemSelectionTextColor( int itemIndex, const Color& clr ); + virtual void SetItemSelectionBgColor( int itemIndex, const Color& clr ); + virtual void SetItemSelectionUnfocusedBgColor( int itemIndex, const Color& clr ); + + // returns true if the itemID is valid for use + virtual bool IsItemIDValid(int itemIndex); + + // item iterators + // iterate from [0..GetHighestItemID()], + // and check each with IsItemIDValid() before using + virtual int GetHighestItemID(); + + virtual void ExpandItem(int itemIndex, bool bExpand); + virtual bool IsItemExpanded( int itemIndex ); + + virtual void MakeItemVisible(int itemIndex); + + // This tells which of the visible items is the top one. + virtual void GetVBarInfo( int &top, int &nItemsVisible, bool& hbarVisible ); + + virtual HFont GetFont(); + + virtual void GenerateDragDataForItem( int itemIndex, KeyValues *msg ); + virtual void SetDragEnabledItems( bool state ); + + virtual void OnLabelChanged( int itemIndex, char const *oldString, char const *newString ); + virtual bool IsLabelEditingAllowed() const; + virtual bool IsLabelBeingEdited() const; + virtual void SetAllowLabelEditing( bool state ); + + /* message sent + + "TreeViewItemSelected" int "itemIndex" + called when the selected item changes + "TreeViewItemDeselected" int "itemIndex" + called when item is deselected + */ + int GetRowHeight(); + int GetVisibleMaxWidth(); + virtual void OnMousePressed(MouseCode code); + + // By default, the tree view expands nodes on left-click. This enables/disables that feature + void EnableExpandTreeOnLeftClick( bool bEnable ); + + virtual void SetLabelEditingAllowed( int itemIndex, bool state ); + virtual void StartEditingLabel( int itemIndex ); + + virtual bool IsItemDroppable( int itemIndex, CUtlVector< KeyValues * >& msglist ); + virtual void OnItemDropped( int itemIndex, CUtlVector< KeyValues * >& msglist ); + virtual bool GetItemDropContextMenu( int itemIndex, Menu *menu, CUtlVector< KeyValues * >& msglist ); + virtual HCursor GetItemDropCursor( int itemIndex, CUtlVector< KeyValues * >& msglist ); + + virtual int GetPrevChildItemIndex( int itemIndex ); + virtual int GetNextChildItemIndex( int itemIndex ); + + virtual void PerformLayout(); + + // Makes the scrollbar parented to some other panel... + ScrollBar *SetScrollBarExternal( bool vertical, Panel *newParent ); + void GetScrollBarSize( bool vertical, int& w, int& h ); + + void SetMultipleItemDragEnabled( bool state ); // if this is set, then clicking on one row and dragging will select a run or items, etc. + bool IsMultipleItemDragEnabled() const; + + int FindItemUnderMouse( int mx, int my ); + +protected: + // functions to override + // called when a node, marked as "Expand", needs to generate it's child nodes when expanded + virtual void GenerateChildrenOfNode(int itemIndex) {} + + // override to open a custom context menu on a node being selected and right-clicked + virtual void GenerateContextMenu( int itemIndex, int x, int y ) {} + + // overrides + virtual void OnMouseWheeled(int delta); + virtual void OnSizeChanged(int wide, int tall); + virtual void ApplySchemeSettings(IScheme *pScheme); + MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position ); + virtual void SetBgColor( Color color ); + +private: + friend class TreeNode; + friend class TreeNodeText; + + TreeNode* GetItem( int itemIndex ); + virtual void RemoveChildrenOfNode( int itemIndex ); + void SetLabelBeingEdited( bool state ); + + // Clean up the image list + void CleanUpImageList( ); + + // to be accessed by TreeNodes + IImage* GetImage(int index); + + // bools + bool m_bAllowLabelEditing : 1; + bool m_bDragEnabledItems : 1; + bool m_bDeleteImageListWhenDone : 1; + bool m_bLeftClickExpandsTree : 1; + bool m_bLabelBeingEdited : 1; + bool m_bMultipleItemDragging : 1; + bool m_bAllowMultipleSelections : 1; + + // cross reference - no hierarchy ordering in this list + CUtlLinkedList<TreeNode *, int> m_NodeList; + ScrollBar *m_pHorzScrollBar, *m_pVertScrollBar; + int m_nRowHeight; + + ImageList *m_pImageList; + TreeNode *m_pRootNode; + TreeViewSortFunc_t m_pSortFunc; + HFont m_Font; + + CUtlVector< TreeNode * > m_SelectedItems; + TreeViewSubPanel *m_pSubPanel; + + int m_nMostRecentlySelectedItem; + bool m_bScrollbarExternal[ 2 ]; // 0 = vert, 1 = horz +}; + +} + +#endif // TREEVIEW_H diff --git a/mp/src/public/vgui_controls/TreeViewListControl.h b/mp/src/public/vgui_controls/TreeViewListControl.h index 23a81a70..8a034709 100644 --- a/mp/src/public/vgui_controls/TreeViewListControl.h +++ b/mp/src/public/vgui_controls/TreeViewListControl.h @@ -1,130 +1,130 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#ifndef TREEVIEWLISTCONTROL_H
-#define TREEVIEWLISTCONTROL_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include <utllinkedlist.h>
-#include <utlvector.h>
-#include <vgui/VGUI.h>
-#include <vgui_controls/Panel.h>
-#include "utlsymbol.h"
-
-
-namespace vgui
-{
-
-// --------------------------------------------------------------------------------- //
-// CTreeViewListControl
-//
-// This control has N columns, with a tree view in the leftmost column.
-// --------------------------------------------------------------------------------- //
-
-class CTreeViewListControl : public vgui::Panel
-{
- DECLARE_CLASS_SIMPLE( CTreeViewListControl, Panel );
-
-public:
-
- CTreeViewListControl( vgui::Panel *pParent, const char *pName );
-
- // Set the tree view to be displayed on the left. If this isn't set, then nothing displays in here.
- virtual void SetTreeView( vgui::TreeView *pTree );
-
- // Set the height of the title bar.
- virtual void SetTitleBarInfo( vgui::HFont hFont, int titleBarHeight );
-
- // Set the color to draw the border lines in.
- virtual void SetBorderColor( Color clr );
-
- // Initialize the column headers.. This info includes the tree view on the left, so this
- virtual void SetNumColumns( int nColumns );
- virtual int GetNumColumns() const;
- // ciFlags is a combination of CI_ flags.
- virtual void SetColumnInfo( int iColumn, const char *pTitle, int width, int ciFlags=0 );
-
- // Use this to render your stuff. Iterate over the rows in the tree view and
- virtual int GetNumRows();
- virtual int GetTreeItemAtRow( int iRow ); // You can use m_pTree->GetItemData to get at the data for the row.
-
- // Use this to find out the client area to render in for each grid element.
- // The returned box is inclusive.
- // The rule is that the the top and left pixels in each grid element are reserved for lines.
- virtual void GetGridElementBounds( int iColumn, int iRow, int &left, int &top, int &right, int &bottom );
-
- virtual vgui::TreeView *GetTree();
-
- virtual int GetTitleBarHeight();
-
- virtual int GetScrollBarSize();
-
-// Overrides.
-public:
-
- // This is where it recalculates the row infos.
- virtual void PerformLayout();
-
- // Usually, you'll want to override paint. After calling the base, use GetNumRows() to
- // iterate over the data in the tree control and fill in the other columns.
- virtual void Paint();
- virtual void PostChildPaint();
-
- // You can override this to change the way the title bars are drawn.
- virtual void DrawTitleBars();
-
-
-public:
-
- enum
- {
- // By default, column header text is centered.
- CI_HEADER_LEFTALIGN =0x0001
- };
-
-
-protected:
-
- void RecalculateRows();
- void RecalculateRows_R( int index );
- void RecalculateColumns();
-
-private:
-
- vgui::TreeView *m_pTree;
-
- class CColumnInfo
- {
- public:
- CColumnInfo()
- {
- m_Width = m_Left = m_Right = m_ciFlags = 0;
- }
-
- CUtlSymbol m_Title;
- int m_Width;
- int m_Left;
- int m_Right;
- int m_ciFlags; // Combination of CI_ flags.
- };
- CUtlVector<CColumnInfo> m_Columns;
-
- vgui::HFont m_TitleBarFont;
- int m_TitleBarHeight;
-
- // These are indices into the tree view.
- CUtlVector<int> m_Rows;
-
- Color m_BorderColor;
-};
-
-} // namespace
-
-
-#endif // TREEVIEWLISTCONTROL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef TREEVIEWLISTCONTROL_H +#define TREEVIEWLISTCONTROL_H +#ifdef _WIN32 +#pragma once +#endif + + +#include <utllinkedlist.h> +#include <utlvector.h> +#include <vgui/VGUI.h> +#include <vgui_controls/Panel.h> +#include "utlsymbol.h" + + +namespace vgui +{ + +// --------------------------------------------------------------------------------- // +// CTreeViewListControl +// +// This control has N columns, with a tree view in the leftmost column. +// --------------------------------------------------------------------------------- // + +class CTreeViewListControl : public vgui::Panel +{ + DECLARE_CLASS_SIMPLE( CTreeViewListControl, Panel ); + +public: + + CTreeViewListControl( vgui::Panel *pParent, const char *pName ); + + // Set the tree view to be displayed on the left. If this isn't set, then nothing displays in here. + virtual void SetTreeView( vgui::TreeView *pTree ); + + // Set the height of the title bar. + virtual void SetTitleBarInfo( vgui::HFont hFont, int titleBarHeight ); + + // Set the color to draw the border lines in. + virtual void SetBorderColor( Color clr ); + + // Initialize the column headers.. This info includes the tree view on the left, so this + virtual void SetNumColumns( int nColumns ); + virtual int GetNumColumns() const; + // ciFlags is a combination of CI_ flags. + virtual void SetColumnInfo( int iColumn, const char *pTitle, int width, int ciFlags=0 ); + + // Use this to render your stuff. Iterate over the rows in the tree view and + virtual int GetNumRows(); + virtual int GetTreeItemAtRow( int iRow ); // You can use m_pTree->GetItemData to get at the data for the row. + + // Use this to find out the client area to render in for each grid element. + // The returned box is inclusive. + // The rule is that the the top and left pixels in each grid element are reserved for lines. + virtual void GetGridElementBounds( int iColumn, int iRow, int &left, int &top, int &right, int &bottom ); + + virtual vgui::TreeView *GetTree(); + + virtual int GetTitleBarHeight(); + + virtual int GetScrollBarSize(); + +// Overrides. +public: + + // This is where it recalculates the row infos. + virtual void PerformLayout(); + + // Usually, you'll want to override paint. After calling the base, use GetNumRows() to + // iterate over the data in the tree control and fill in the other columns. + virtual void Paint(); + virtual void PostChildPaint(); + + // You can override this to change the way the title bars are drawn. + virtual void DrawTitleBars(); + + +public: + + enum + { + // By default, column header text is centered. + CI_HEADER_LEFTALIGN =0x0001 + }; + + +protected: + + void RecalculateRows(); + void RecalculateRows_R( int index ); + void RecalculateColumns(); + +private: + + vgui::TreeView *m_pTree; + + class CColumnInfo + { + public: + CColumnInfo() + { + m_Width = m_Left = m_Right = m_ciFlags = 0; + } + + CUtlSymbol m_Title; + int m_Width; + int m_Left; + int m_Right; + int m_ciFlags; // Combination of CI_ flags. + }; + CUtlVector<CColumnInfo> m_Columns; + + vgui::HFont m_TitleBarFont; + int m_TitleBarHeight; + + // These are indices into the tree view. + CUtlVector<int> m_Rows; + + Color m_BorderColor; +}; + +} // namespace + + +#endif // TREEVIEWLISTCONTROL_H diff --git a/mp/src/public/vgui_controls/URLLabel.h b/mp/src/public/vgui_controls/URLLabel.h index 3421b3d2..66112513 100644 --- a/mp/src/public/vgui_controls/URLLabel.h +++ b/mp/src/public/vgui_controls/URLLabel.h @@ -1,49 +1,49 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef URLLABEL_H
-#define URLLABEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui/VGUI.h>
-#include <vgui_controls/Label.h>
-
-namespace vgui
-{
-
-class URLLabel : public Label
-{
- DECLARE_CLASS_SIMPLE( URLLabel, Label );
-
-public:
- URLLabel(Panel *parent, const char *panelName, const char *text, const char *pszURL);
- URLLabel(Panel *parent, const char *panelName, const wchar_t *wszText, const char *pszURL);
- ~URLLabel();
-
- void SetURL(const char *pszURL);
-
-protected:
- virtual void OnMousePressed(MouseCode code);
- virtual void ApplySettings( KeyValues *inResourceData );
- virtual void GetSettings( KeyValues *outResourceData );
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual const char *GetDescription( void );
-
- const char *GetURL( void ) { return m_pszURL; }
-
-private:
- char *m_pszURL;
- int m_iURLSize;
- bool m_bUnderline;
-};
-
-}
-
-#endif // URLLABEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef URLLABEL_H +#define URLLABEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui/VGUI.h> +#include <vgui_controls/Label.h> + +namespace vgui +{ + +class URLLabel : public Label +{ + DECLARE_CLASS_SIMPLE( URLLabel, Label ); + +public: + URLLabel(Panel *parent, const char *panelName, const char *text, const char *pszURL); + URLLabel(Panel *parent, const char *panelName, const wchar_t *wszText, const char *pszURL); + ~URLLabel(); + + void SetURL(const char *pszURL); + +protected: + virtual void OnMousePressed(MouseCode code); + virtual void ApplySettings( KeyValues *inResourceData ); + virtual void GetSettings( KeyValues *outResourceData ); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual const char *GetDescription( void ); + + const char *GetURL( void ) { return m_pszURL; } + +private: + char *m_pszURL; + int m_iURLSize; + bool m_bUnderline; +}; + +} + +#endif // URLLABEL_H diff --git a/mp/src/public/vgui_controls/WizardPanel.h b/mp/src/public/vgui_controls/WizardPanel.h index 1c902995..c6e014e8 100644 --- a/mp/src/public/vgui_controls/WizardPanel.h +++ b/mp/src/public/vgui_controls/WizardPanel.h @@ -1,127 +1,127 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef WIZARDPANEL_H
-#define WIZARDPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/Frame.h>
-
-namespace vgui
-{
-
-class WizardSubPanel;
-
-//-----------------------------------------------------------------------------
-// Purpose: Type of dialog that supports moving back and forth through a series
-// of sub-dialogs, WizardSubPanels
-//-----------------------------------------------------------------------------
-class WizardPanel : public Frame
-{
- DECLARE_CLASS_SIMPLE( WizardPanel, Frame );
-
-public:
- WizardPanel(Panel *parent, const char *panelName);
- ~WizardPanel();
-
- // Start the wizard, starting with the startPanel
- virtual void Run(WizardSubPanel *startPanel);
-
- // Called when the buttons are pressed
- // WizardSubPanels can also call these functions to simulate a button being pressed
- MESSAGE_FUNC( OnNextButton, "NextButton" );
- MESSAGE_FUNC( OnPrevButton, "PrevButton" );
- MESSAGE_FUNC( OnFinishButton, "FinishButton" );
- MESSAGE_FUNC( OnCancelButton, "CancelButton" );
-
- // sets whether or not a button is enabled
- // this state is managed, and will be reset whenever going to a new page
- virtual void SetNextButtonEnabled(bool state);
- virtual void SetPrevButtonEnabled(bool state);
- virtual void SetFinishButtonEnabled(bool state);
- virtual void SetCancelButtonEnabled(bool state);
-
- // sets whether or not a button is visible
- // this state is unmanaged, the user needs to ensure that the buttons state
- // is correct when going both back and prev through the wizard
- virtual void SetNextButtonVisible(bool state);
- virtual void SetPrevButtonVisible(bool state);
- virtual void SetFinishButtonVisible(bool state);
- virtual void SetCancelButtonVisible(bool state);
-
- // sets the text for a button
- // setting the text to be NULL resets the text to it's default state
- // this state is unmanaged, the user needs to ensure that the buttons state
- // is correct when going both back and prev through the wizard
- virtual void SetNextButtonText(const char *text);
- virtual void SetPrevButtonText(const char *text);
- virtual void SetFinishButtonText(const char *text);
- virtual void SetCancelButtonText(const char *text);
-
- // general wizard state for all the subpanels to access
- virtual KeyValues *GetWizardData();
-
- // recalculates where the key focus should be in the wizard
- virtual void ResetKeyFocus();
- virtual void ResetDefaultButton();
-
- // resets the sub panel history for the control
- virtual void ResetHistory();
-
- // returns a page by name
- virtual WizardSubPanel *GetSubPanelByName(const char *pageName);
-
- virtual void ShowButtons(bool state);
- virtual void GetClientArea(int &x, int &y, int &wide, int &tall);
-
-protected:
- MESSAGE_FUNC_PTR( InternalActivateNextSubPanel, "ActivateNextSubPanel", panel )
- {
- ActivateNextSubPanel( (WizardSubPanel *)panel );
- }
-
- virtual void ActivateNextSubPanel(WizardSubPanel *subPanel);
- virtual void ActivatePrevSubPanel();
- virtual void CreateButtons();
- virtual void RecalculateTabOrdering();
- virtual vgui::WizardSubPanel *GetCurrentSubPanel() { return _currentSubPanel; }
-
- // overrides
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(IScheme *pScheme);
-
- // reroute build messages to the currently active sub panel
- virtual void ActivateBuildMode();
-
- // close maps to the cancel button
- virtual void OnClose();
- virtual void OnCommand(const char *command);
- virtual void OnCloseFrameButtonPressed();
-
-private:
- WizardSubPanel *FindNextValidSubPanel(WizardSubPanel *currentPanel);
-
- Button *_prevButton;
- Button *_nextButton;
- Button *_cancelButton;
- Button *_finishButton;
-
- WizardSubPanel *_currentSubPanel;
- KeyValues *_currentData;
-
- Dar<WizardSubPanel *> _subPanelStack; // contains a list of all the subpanels (not including the current one)
-
- bool _showButtons;
-};
-
-} // namespace vgui
-
-
-#endif // WIZARDPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef WIZARDPANEL_H +#define WIZARDPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/Frame.h> + +namespace vgui +{ + +class WizardSubPanel; + +//----------------------------------------------------------------------------- +// Purpose: Type of dialog that supports moving back and forth through a series +// of sub-dialogs, WizardSubPanels +//----------------------------------------------------------------------------- +class WizardPanel : public Frame +{ + DECLARE_CLASS_SIMPLE( WizardPanel, Frame ); + +public: + WizardPanel(Panel *parent, const char *panelName); + ~WizardPanel(); + + // Start the wizard, starting with the startPanel + virtual void Run(WizardSubPanel *startPanel); + + // Called when the buttons are pressed + // WizardSubPanels can also call these functions to simulate a button being pressed + MESSAGE_FUNC( OnNextButton, "NextButton" ); + MESSAGE_FUNC( OnPrevButton, "PrevButton" ); + MESSAGE_FUNC( OnFinishButton, "FinishButton" ); + MESSAGE_FUNC( OnCancelButton, "CancelButton" ); + + // sets whether or not a button is enabled + // this state is managed, and will be reset whenever going to a new page + virtual void SetNextButtonEnabled(bool state); + virtual void SetPrevButtonEnabled(bool state); + virtual void SetFinishButtonEnabled(bool state); + virtual void SetCancelButtonEnabled(bool state); + + // sets whether or not a button is visible + // this state is unmanaged, the user needs to ensure that the buttons state + // is correct when going both back and prev through the wizard + virtual void SetNextButtonVisible(bool state); + virtual void SetPrevButtonVisible(bool state); + virtual void SetFinishButtonVisible(bool state); + virtual void SetCancelButtonVisible(bool state); + + // sets the text for a button + // setting the text to be NULL resets the text to it's default state + // this state is unmanaged, the user needs to ensure that the buttons state + // is correct when going both back and prev through the wizard + virtual void SetNextButtonText(const char *text); + virtual void SetPrevButtonText(const char *text); + virtual void SetFinishButtonText(const char *text); + virtual void SetCancelButtonText(const char *text); + + // general wizard state for all the subpanels to access + virtual KeyValues *GetWizardData(); + + // recalculates where the key focus should be in the wizard + virtual void ResetKeyFocus(); + virtual void ResetDefaultButton(); + + // resets the sub panel history for the control + virtual void ResetHistory(); + + // returns a page by name + virtual WizardSubPanel *GetSubPanelByName(const char *pageName); + + virtual void ShowButtons(bool state); + virtual void GetClientArea(int &x, int &y, int &wide, int &tall); + +protected: + MESSAGE_FUNC_PTR( InternalActivateNextSubPanel, "ActivateNextSubPanel", panel ) + { + ActivateNextSubPanel( (WizardSubPanel *)panel ); + } + + virtual void ActivateNextSubPanel(WizardSubPanel *subPanel); + virtual void ActivatePrevSubPanel(); + virtual void CreateButtons(); + virtual void RecalculateTabOrdering(); + virtual vgui::WizardSubPanel *GetCurrentSubPanel() { return _currentSubPanel; } + + // overrides + virtual void PerformLayout(); + virtual void ApplySchemeSettings(IScheme *pScheme); + + // reroute build messages to the currently active sub panel + virtual void ActivateBuildMode(); + + // close maps to the cancel button + virtual void OnClose(); + virtual void OnCommand(const char *command); + virtual void OnCloseFrameButtonPressed(); + +private: + WizardSubPanel *FindNextValidSubPanel(WizardSubPanel *currentPanel); + + Button *_prevButton; + Button *_nextButton; + Button *_cancelButton; + Button *_finishButton; + + WizardSubPanel *_currentSubPanel; + KeyValues *_currentData; + + Dar<WizardSubPanel *> _subPanelStack; // contains a list of all the subpanels (not including the current one) + + bool _showButtons; +}; + +} // namespace vgui + + +#endif // WIZARDPANEL_H diff --git a/mp/src/public/vgui_controls/WizardSubPanel.h b/mp/src/public/vgui_controls/WizardSubPanel.h index cb9da0ea..a7d71fb4 100644 --- a/mp/src/public/vgui_controls/WizardSubPanel.h +++ b/mp/src/public/vgui_controls/WizardSubPanel.h @@ -1,91 +1,91 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef WIZARDSUBPANEL_H
-#define WIZARDSUBPANEL_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <vgui_controls/EditablePanel.h>
-
-namespace vgui
-{
-
-//-----------------------------------------------------------------------------
-// Purpose: Base panel for use in Wizards and in property sheets
-//-----------------------------------------------------------------------------
-class WizardSubPanel : public EditablePanel
-{
- DECLARE_CLASS_SIMPLE( WizardSubPanel, EditablePanel );
-
-public:
- // constructor
- WizardSubPanel(Panel *parent, const char *panelName);
- ~WizardSubPanel();
-
- // called when the subpanel is displayed
- // All controls & data should be reinitialized at this time
- virtual void OnDisplayAsNext() {}
-
- // called anytime the panel is first displayed, whether the user is moving forward or back
- // called immediately after OnDisplayAsNext/OnDisplayAsPrev
- virtual void OnDisplay() {}
-
- // called when displayed as previous
- virtual void OnDisplayAsPrev() {}
-
- // called when one of the wizard buttons are pressed
- // returns true if the wizard should advance, false otherwise
- virtual bool OnNextButton() { return true; }
- virtual bool OnPrevButton() { return true; }
- virtual bool OnFinishButton() { return true; }
- virtual bool OnCancelButton() { return true; }
-
- // returns true if this panel should be displayed, or if we should just skip over it
- virtual bool ShouldDisplayPanel() { return true; }
-
- // return true if this subpanel doesn't need the next/prev/finish/cancel buttons or will do it itself
- virtual bool isNonWizardPanel() { return false; }
-
- // returns a pointer to the next subpanel that should be displayed
- virtual WizardSubPanel *GetNextSubPanel() = 0;
-
- // returns a pointer to the panel to return to
- // it must be a panel that is already in the wizards panel history
- // returning NULL tells it to use the immediate previous panel in the history
- virtual WizardSubPanel *GetPrevSubPanel() { return NULL; }
-
- virtual WizardPanel *GetWizardPanel() { return _wizardPanel; }
- virtual void SetWizardPanel(WizardPanel *wizardPanel) { _wizardPanel = wizardPanel; }
-
- // returns a pointer to the wizard's doc
- virtual KeyValues *GetWizardData();
-
- // returns a pointer
- virtual WizardSubPanel *GetSiblingSubPanelByName(const char *pageName);
-
- // gets the size this subpanel would like the wizard to be
- // returns true if it has a desired size
- virtual bool GetDesiredSize(int &wide, int &tall);
-
-protected:
- virtual void ApplySettings(KeyValues *inResourceData);
- virtual void GetSettings( KeyValues *outResourceData );
- virtual void ApplySchemeSettings(IScheme *pScheme);
- virtual const char *GetDescription();
-
-private:
- WizardPanel *_wizardPanel;
- int m_iDesiredWide, m_iDesiredTall;
-};
-
-} // namespace vgui
-
-
-#endif // WIZARDSUBPANEL_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef WIZARDSUBPANEL_H +#define WIZARDSUBPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include <vgui_controls/EditablePanel.h> + +namespace vgui +{ + +//----------------------------------------------------------------------------- +// Purpose: Base panel for use in Wizards and in property sheets +//----------------------------------------------------------------------------- +class WizardSubPanel : public EditablePanel +{ + DECLARE_CLASS_SIMPLE( WizardSubPanel, EditablePanel ); + +public: + // constructor + WizardSubPanel(Panel *parent, const char *panelName); + ~WizardSubPanel(); + + // called when the subpanel is displayed + // All controls & data should be reinitialized at this time + virtual void OnDisplayAsNext() {} + + // called anytime the panel is first displayed, whether the user is moving forward or back + // called immediately after OnDisplayAsNext/OnDisplayAsPrev + virtual void OnDisplay() {} + + // called when displayed as previous + virtual void OnDisplayAsPrev() {} + + // called when one of the wizard buttons are pressed + // returns true if the wizard should advance, false otherwise + virtual bool OnNextButton() { return true; } + virtual bool OnPrevButton() { return true; } + virtual bool OnFinishButton() { return true; } + virtual bool OnCancelButton() { return true; } + + // returns true if this panel should be displayed, or if we should just skip over it + virtual bool ShouldDisplayPanel() { return true; } + + // return true if this subpanel doesn't need the next/prev/finish/cancel buttons or will do it itself + virtual bool isNonWizardPanel() { return false; } + + // returns a pointer to the next subpanel that should be displayed + virtual WizardSubPanel *GetNextSubPanel() = 0; + + // returns a pointer to the panel to return to + // it must be a panel that is already in the wizards panel history + // returning NULL tells it to use the immediate previous panel in the history + virtual WizardSubPanel *GetPrevSubPanel() { return NULL; } + + virtual WizardPanel *GetWizardPanel() { return _wizardPanel; } + virtual void SetWizardPanel(WizardPanel *wizardPanel) { _wizardPanel = wizardPanel; } + + // returns a pointer to the wizard's doc + virtual KeyValues *GetWizardData(); + + // returns a pointer + virtual WizardSubPanel *GetSiblingSubPanelByName(const char *pageName); + + // gets the size this subpanel would like the wizard to be + // returns true if it has a desired size + virtual bool GetDesiredSize(int &wide, int &tall); + +protected: + virtual void ApplySettings(KeyValues *inResourceData); + virtual void GetSettings( KeyValues *outResourceData ); + virtual void ApplySchemeSettings(IScheme *pScheme); + virtual const char *GetDescription(); + +private: + WizardPanel *_wizardPanel; + int m_iDesiredWide, m_iDesiredTall; +}; + +} // namespace vgui + + +#endif // WIZARDSUBPANEL_H diff --git a/mp/src/public/vgui_controls/consoledialog.h b/mp/src/public/vgui_controls/consoledialog.h index 8483bf66..1a354a0b 100644 --- a/mp/src/public/vgui_controls/consoledialog.h +++ b/mp/src/public/vgui_controls/consoledialog.h @@ -1,171 +1,171 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef CONSOLEDIALOG_H
-#define CONSOLEDIALOG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include <Color.h>
-#include "tier1/utlvector.h"
-#include "vgui_controls/EditablePanel.h"
-#include "vgui_controls/Frame.h"
-#include "icvar.h"
-
-class ConCommandBase;
-
-
-namespace vgui
-{
-
-// Things the user typed in and hit submit/return with
-class CHistoryItem
-{
-public:
- CHistoryItem( void );
- CHistoryItem( const char *text, const char *extra = NULL );
- CHistoryItem( const CHistoryItem& src );
- ~CHistoryItem( void );
-
- const char *GetText() const;
- const char *GetExtra() const;
- void SetText( const char *text, const char *extra );
- bool HasExtra() { return m_bHasExtra; }
-
-private:
- char *m_text;
- char *m_extraText;
- bool m_bHasExtra;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Game/dev console dialog
-//-----------------------------------------------------------------------------
-class CConsolePanel : public vgui::EditablePanel, public IConsoleDisplayFunc
-{
- DECLARE_CLASS_SIMPLE( CConsolePanel, vgui::EditablePanel );
-
-public:
- CConsolePanel( Panel *pParent, const char *pName, bool bStatusVersion );
- ~CConsolePanel();
-
- // Inherited from IConsoleDisplayFunc
- virtual void ColorPrint( const Color& clr, const char *pMessage );
- virtual void Print( const char *pMessage );
- virtual void DPrint( const char *pMessage );
- virtual void GetConsoleText( char *pchText, size_t bufSize ) const;
-
- // clears the console
- void Clear();
-
- // writes console to a file
- void DumpConsoleTextToFile();
-
- // Hides the console
- void Hide();
-
- bool TextEntryHasFocus() const;
- void TextEntryRequestFocus();
-
-
-
-private:
- enum
- {
- MAX_HISTORY_ITEMS = 100,
- };
-
- class CompletionItem
- {
- public:
- CompletionItem( void );
- CompletionItem( const CompletionItem& src );
- CompletionItem& operator =( const CompletionItem& src );
- ~CompletionItem( void );
- const char *GetItemText( void );
- const char *GetCommand( void ) const;
- const char *GetName() const;
-
- bool m_bIsCommand;
- ConCommandBase *m_pCommand;
- CHistoryItem *m_pText;
- };
-
-protected:
- // methods
- void OnAutoComplete(bool reverse);
- MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
- void RebuildCompletionList(const char *partialText);
- void UpdateCompletionListPosition();
- MESSAGE_FUNC( CloseCompletionList, "CloseCompletionList" );
- MESSAGE_FUNC_CHARPTR( OnMenuItemSelected, "CompletionCommand", command );
- void ClearCompletionList();
- void AddToHistory( const char *commandText, const char *extraText );
-
- // vgui overrides
- virtual void PerformLayout();
- virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
- virtual void OnCommand(const char *command);
- virtual void OnKeyCodeTyped(vgui::KeyCode code);
- virtual void OnThink();
-
- vgui::RichText *m_pHistory;
- vgui::TextEntry *m_pEntry;
- vgui::Button *m_pSubmit;
- vgui::Menu *m_pCompletionList;
- Color m_PrintColor;
- Color m_DPrintColor;
-
- int m_iNextCompletion; // the completion that we'll next go to
- char m_szPartialText[256];
- char m_szPreviousPartialText[256];
- bool m_bAutoCompleteMode; // true if the user is currently tabbing through completion options
- bool m_bWasBackspacing;
- bool m_bStatusVersion;
-
- CUtlVector< CompletionItem * > m_CompletionList;
- CUtlVector< CHistoryItem > m_CommandHistory;
-
- friend class CConsoleDialog;
-};
-
-
-class CConsoleDialog : public vgui::Frame
-{
- DECLARE_CLASS_SIMPLE( CConsoleDialog, vgui::Frame );
-
-public:
- CConsoleDialog( vgui::Panel *pParent, const char *pName, bool bStatusVersion );
-
- virtual void OnScreenSizeChanged( int iOldWide, int iOldTall );
- virtual void Close();
- virtual void PerformLayout();
-
- // brings dialog to the fore
- MESSAGE_FUNC( Activate, "Activate" );
- MESSAGE_FUNC_CHARPTR( OnCommandSubmitted, "CommandSubmitted", command );
-
- // hides the console
- void Hide();
-
- // Chain to the page
- void Print( const char *msg );
- void DPrint( const char *msg );
- void ColorPrint( const Color& clr, const char *msg );
- void Clear();
- void DumpConsoleTextToFile();
-
- virtual void OnKeyCodePressed( vgui::KeyCode code );
-
-protected:
- CConsolePanel *m_pConsolePanel;
-};
-
-} // end namespace vgui
-
-#endif // CONSOLEDIALOG_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef CONSOLEDIALOG_H +#define CONSOLEDIALOG_H +#ifdef _WIN32 +#pragma once +#endif + +#include <Color.h> +#include "tier1/utlvector.h" +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/Frame.h" +#include "icvar.h" + +class ConCommandBase; + + +namespace vgui +{ + +// Things the user typed in and hit submit/return with +class CHistoryItem +{ +public: + CHistoryItem( void ); + CHistoryItem( const char *text, const char *extra = NULL ); + CHistoryItem( const CHistoryItem& src ); + ~CHistoryItem( void ); + + const char *GetText() const; + const char *GetExtra() const; + void SetText( const char *text, const char *extra ); + bool HasExtra() { return m_bHasExtra; } + +private: + char *m_text; + char *m_extraText; + bool m_bHasExtra; +}; + +//----------------------------------------------------------------------------- +// Purpose: Game/dev console dialog +//----------------------------------------------------------------------------- +class CConsolePanel : public vgui::EditablePanel, public IConsoleDisplayFunc +{ + DECLARE_CLASS_SIMPLE( CConsolePanel, vgui::EditablePanel ); + +public: + CConsolePanel( Panel *pParent, const char *pName, bool bStatusVersion ); + ~CConsolePanel(); + + // Inherited from IConsoleDisplayFunc + virtual void ColorPrint( const Color& clr, const char *pMessage ); + virtual void Print( const char *pMessage ); + virtual void DPrint( const char *pMessage ); + virtual void GetConsoleText( char *pchText, size_t bufSize ) const; + + // clears the console + void Clear(); + + // writes console to a file + void DumpConsoleTextToFile(); + + // Hides the console + void Hide(); + + bool TextEntryHasFocus() const; + void TextEntryRequestFocus(); + + + +private: + enum + { + MAX_HISTORY_ITEMS = 100, + }; + + class CompletionItem + { + public: + CompletionItem( void ); + CompletionItem( const CompletionItem& src ); + CompletionItem& operator =( const CompletionItem& src ); + ~CompletionItem( void ); + const char *GetItemText( void ); + const char *GetCommand( void ) const; + const char *GetName() const; + + bool m_bIsCommand; + ConCommandBase *m_pCommand; + CHistoryItem *m_pText; + }; + +protected: + // methods + void OnAutoComplete(bool reverse); + MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel ); + void RebuildCompletionList(const char *partialText); + void UpdateCompletionListPosition(); + MESSAGE_FUNC( CloseCompletionList, "CloseCompletionList" ); + MESSAGE_FUNC_CHARPTR( OnMenuItemSelected, "CompletionCommand", command ); + void ClearCompletionList(); + void AddToHistory( const char *commandText, const char *extraText ); + + // vgui overrides + virtual void PerformLayout(); + virtual void ApplySchemeSettings(vgui::IScheme *pScheme); + virtual void OnCommand(const char *command); + virtual void OnKeyCodeTyped(vgui::KeyCode code); + virtual void OnThink(); + + vgui::RichText *m_pHistory; + vgui::TextEntry *m_pEntry; + vgui::Button *m_pSubmit; + vgui::Menu *m_pCompletionList; + Color m_PrintColor; + Color m_DPrintColor; + + int m_iNextCompletion; // the completion that we'll next go to + char m_szPartialText[256]; + char m_szPreviousPartialText[256]; + bool m_bAutoCompleteMode; // true if the user is currently tabbing through completion options + bool m_bWasBackspacing; + bool m_bStatusVersion; + + CUtlVector< CompletionItem * > m_CompletionList; + CUtlVector< CHistoryItem > m_CommandHistory; + + friend class CConsoleDialog; +}; + + +class CConsoleDialog : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( CConsoleDialog, vgui::Frame ); + +public: + CConsoleDialog( vgui::Panel *pParent, const char *pName, bool bStatusVersion ); + + virtual void OnScreenSizeChanged( int iOldWide, int iOldTall ); + virtual void Close(); + virtual void PerformLayout(); + + // brings dialog to the fore + MESSAGE_FUNC( Activate, "Activate" ); + MESSAGE_FUNC_CHARPTR( OnCommandSubmitted, "CommandSubmitted", command ); + + // hides the console + void Hide(); + + // Chain to the page + void Print( const char *msg ); + void DPrint( const char *msg ); + void ColorPrint( const Color& clr, const char *msg ); + void Clear(); + void DumpConsoleTextToFile(); + + virtual void OnKeyCodePressed( vgui::KeyCode code ); + +protected: + CConsolePanel *m_pConsolePanel; +}; + +} // end namespace vgui + +#endif // CONSOLEDIALOG_H diff --git a/mp/src/public/vgui_controls/cvartogglecheckbutton.h b/mp/src/public/vgui_controls/cvartogglecheckbutton.h index 5e4f998f..5d9a9ba1 100644 --- a/mp/src/public/vgui_controls/cvartogglecheckbutton.h +++ b/mp/src/public/vgui_controls/cvartogglecheckbutton.h @@ -1,191 +1,191 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef CVARTOGGLECHECKBUTTON_H
-#define CVARTOGGLECHECKBUTTON_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui/VGUI.h"
-#include "vgui_controls/CheckButton.h"
-#include "tier1/utlstring.h"
-#include "tier1/KeyValues.h"
-namespace vgui
-{
-
-template< class T >
-class CvarToggleCheckButton : public CheckButton
-{
- DECLARE_CLASS_SIMPLE( CvarToggleCheckButton, CheckButton );
-
-public:
- CvarToggleCheckButton( Panel *parent, const char *panelName, const char *text = "",
- char const *cvarname = NULL, bool ignoreMissingCvar = false );
- ~CvarToggleCheckButton();
-
- virtual void SetSelected( bool state );
-
- virtual void Paint();
-
- void Reset();
- void ApplyChanges();
- bool HasBeenModified();
- virtual void ApplySettings( KeyValues *inResourceData );
-
-private:
- // Called when the OK / Apply button is pressed. Changed data should be written into cvar.
- MESSAGE_FUNC( OnApplyChanges, "ApplyChanges" );
- MESSAGE_FUNC( OnButtonChecked, "CheckButtonChecked" );
-
- T m_cvar;
- bool m_bStartValue;
- bool m_bIgnoreMissingCvar;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: Constructor
-//-----------------------------------------------------------------------------
-template< class T >
-CvarToggleCheckButton<T>::CvarToggleCheckButton( Panel *parent, const char *panelName, const char *text, char const *cvarname, bool ignoreMissingCvar )
- : CheckButton( parent, panelName, text ), m_cvar( (cvarname)?cvarname:"", (cvarname)?ignoreMissingCvar:true )
-{
- m_bIgnoreMissingCvar = ignoreMissingCvar;
-
- if (m_cvar.IsValid())
- {
- Reset();
- }
- AddActionSignalTarget( this );
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Destructor
-//-----------------------------------------------------------------------------
-template< class T >
-CvarToggleCheckButton<T>::~CvarToggleCheckButton()
-{
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::Paint()
-{
- if ( !m_cvar.IsValid() )
- {
- BaseClass::Paint();
- return;
- }
-
- bool value = m_cvar.GetBool();
-
- if ( value != m_bStartValue )
- {
- SetSelected( value );
- m_bStartValue = value;
- }
- BaseClass::Paint();
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Called when the OK / Apply button is pressed. Changed data should be written into cvar.
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::OnApplyChanges()
-{
- ApplyChanges();
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::ApplyChanges()
-{
- if ( !m_cvar.IsValid() )
- return;
-
- m_bStartValue = IsSelected();
- m_cvar.SetValue( m_bStartValue );
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::Reset()
-{
- if ( !m_cvar.IsValid() )
- return;
-
- m_bStartValue = m_cvar.GetBool();
- SetSelected(m_bStartValue);
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-template< class T >
-bool CvarToggleCheckButton<T>::HasBeenModified()
-{
- return IsSelected() != m_bStartValue;
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-// Input : *panel -
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::SetSelected( bool state )
-{
- BaseClass::SetSelected( state );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::OnButtonChecked()
-{
- if (HasBeenModified())
- {
- PostActionSignal(new KeyValues("ControlModified"));
- }
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-template< class T >
-void CvarToggleCheckButton<T>::ApplySettings( KeyValues *inResourceData )
-{
- BaseClass::ApplySettings( inResourceData );
-
- const char *cvarName = inResourceData->GetString("cvar_name", "");
- const char *cvarValue = inResourceData->GetString("cvar_value", "");
-
- if( Q_stricmp( cvarName, "") == 0 )
- return;// Doesn't have cvar set up in res file, must have been constructed with it.
-
- if( Q_stricmp( cvarValue, "1") == 0 )
- m_bStartValue = true;
- else
- m_bStartValue = false;
-
- m_cvar.Init( cvarName, m_bIgnoreMissingCvar );
- if ( m_cvar.IsValid() )
- {
- SetSelected( m_cvar.GetBool() );
- }
-}
-
-} // namespace vgui
-
-#endif // CVARTOGGLECHECKBUTTON_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef CVARTOGGLECHECKBUTTON_H +#define CVARTOGGLECHECKBUTTON_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui/VGUI.h" +#include "vgui_controls/CheckButton.h" +#include "tier1/utlstring.h" +#include "tier1/KeyValues.h" +namespace vgui +{ + +template< class T > +class CvarToggleCheckButton : public CheckButton +{ + DECLARE_CLASS_SIMPLE( CvarToggleCheckButton, CheckButton ); + +public: + CvarToggleCheckButton( Panel *parent, const char *panelName, const char *text = "", + char const *cvarname = NULL, bool ignoreMissingCvar = false ); + ~CvarToggleCheckButton(); + + virtual void SetSelected( bool state ); + + virtual void Paint(); + + void Reset(); + void ApplyChanges(); + bool HasBeenModified(); + virtual void ApplySettings( KeyValues *inResourceData ); + +private: + // Called when the OK / Apply button is pressed. Changed data should be written into cvar. + MESSAGE_FUNC( OnApplyChanges, "ApplyChanges" ); + MESSAGE_FUNC( OnButtonChecked, "CheckButtonChecked" ); + + T m_cvar; + bool m_bStartValue; + bool m_bIgnoreMissingCvar; +}; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +template< class T > +CvarToggleCheckButton<T>::CvarToggleCheckButton( Panel *parent, const char *panelName, const char *text, char const *cvarname, bool ignoreMissingCvar ) + : CheckButton( parent, panelName, text ), m_cvar( (cvarname)?cvarname:"", (cvarname)?ignoreMissingCvar:true ) +{ + m_bIgnoreMissingCvar = ignoreMissingCvar; + + if (m_cvar.IsValid()) + { + Reset(); + } + AddActionSignalTarget( this ); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +template< class T > +CvarToggleCheckButton<T>::~CvarToggleCheckButton() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::Paint() +{ + if ( !m_cvar.IsValid() ) + { + BaseClass::Paint(); + return; + } + + bool value = m_cvar.GetBool(); + + if ( value != m_bStartValue ) + { + SetSelected( value ); + m_bStartValue = value; + } + BaseClass::Paint(); +} + +//----------------------------------------------------------------------------- +// Purpose: Called when the OK / Apply button is pressed. Changed data should be written into cvar. +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::OnApplyChanges() +{ + ApplyChanges(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::ApplyChanges() +{ + if ( !m_cvar.IsValid() ) + return; + + m_bStartValue = IsSelected(); + m_cvar.SetValue( m_bStartValue ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::Reset() +{ + if ( !m_cvar.IsValid() ) + return; + + m_bStartValue = m_cvar.GetBool(); + SetSelected(m_bStartValue); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +template< class T > +bool CvarToggleCheckButton<T>::HasBeenModified() +{ + return IsSelected() != m_bStartValue; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : *panel - +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::SetSelected( bool state ) +{ + BaseClass::SetSelected( state ); +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::OnButtonChecked() +{ + if (HasBeenModified()) + { + PostActionSignal(new KeyValues("ControlModified")); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +template< class T > +void CvarToggleCheckButton<T>::ApplySettings( KeyValues *inResourceData ) +{ + BaseClass::ApplySettings( inResourceData ); + + const char *cvarName = inResourceData->GetString("cvar_name", ""); + const char *cvarValue = inResourceData->GetString("cvar_value", ""); + + if( Q_stricmp( cvarName, "") == 0 ) + return;// Doesn't have cvar set up in res file, must have been constructed with it. + + if( Q_stricmp( cvarValue, "1") == 0 ) + m_bStartValue = true; + else + m_bStartValue = false; + + m_cvar.Init( cvarName, m_bIgnoreMissingCvar ); + if ( m_cvar.IsValid() ) + { + SetSelected( m_cvar.GetBool() ); + } +} + +} // namespace vgui + +#endif // CVARTOGGLECHECKBUTTON_H diff --git a/mp/src/public/vgui_controls/pch_vgui_controls.h b/mp/src/public/vgui_controls/pch_vgui_controls.h index 80b3d771..7b09eb5b 100644 --- a/mp/src/public/vgui_controls/pch_vgui_controls.h +++ b/mp/src/public/vgui_controls/pch_vgui_controls.h @@ -1,115 +1,115 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef PCH_VGUI_CONTROLS_H
-#define PCH_VGUI_CONTROLS_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-// general includes
-#include <ctype.h>
-#include <stdlib.h>
-#include "tier0/dbg.h"
-#include "tier0/valve_off.h"
-#include "tier1/KeyValues.h"
-
-#include "tier0/valve_on.h"
-#include "tier0/memdbgon.h"
-
-#include "filesystem.h"
-#include "tier0/validator.h"
-
-// vgui includes
-#include "vgui/IBorder.h"
-#include "vgui/IInput.h"
-#include "vgui/ILocalize.h"
-#include "vgui/IPanel.h"
-#include "vgui/IScheme.h"
-#include "vgui/ISurface.h"
-#include "vgui/ISystem.h"
-#include "vgui/IVGui.h"
-#include "vgui/KeyCode.h"
-#include "vgui/Cursor.h"
-#include "vgui/MouseCode.h"
-
-// vgui controls includes
-#include "vgui_controls/Controls.h"
-
-#include "vgui_controls/AnimatingImagePanel.h"
-#include "vgui_controls/AnimationController.h"
-#include "vgui_controls/BitmapImagePanel.h"
-#include "vgui_controls/BuildGroup.h"
-#include "vgui_controls/BuildModeDialog.h"
-#include "vgui_controls/Button.h"
-#include "vgui_controls/CheckButton.h"
-#include "vgui_controls/CheckButtonList.h"
-#include "vgui_controls/ComboBox.h"
-#include "vgui_controls/Controls.h"
-#include "vgui_controls/DialogManager.h"
-#include "vgui_controls/DirectorySelectDialog.h"
-#include "vgui_controls/Divider.h"
-#include "vgui_controls/EditablePanel.h"
-#include "vgui_controls/FileOpenDialog.h"
-#include "vgui_controls/FocusNavGroup.h"
-#include "vgui_controls/Frame.h"
-#include "vgui_controls/GraphPanel.h"
-#include "vgui_controls/HTML.h"
-#include "vgui_controls/Image.h"
-#include "vgui_controls/ImageList.h"
-#include "vgui_controls/ImagePanel.h"
-#include "vgui_controls/Label.h"
-#include "vgui_controls/ListPanel.h"
-#include "vgui_controls/ListViewPanel.h"
-#include "vgui_controls/Menu.h"
-#include "vgui_controls/MenuBar.h"
-#include "vgui_controls/MenuButton.h"
-#include "vgui_controls/MenuItem.h"
-#include "vgui_controls/MessageBox.h"
-#include "vgui_controls/Panel.h"
-#ifndef HL1
-#include "vgui_controls/PanelAnimationVar.h"
-#endif
-#include "vgui_controls/PanelListPanel.h"
-#include "vgui_controls/PHandle.h"
-#include "vgui_controls/ProgressBar.h"
-#include "vgui_controls/ProgressBox.h"
-#include "vgui_controls/PropertyDialog.h"
-#include "vgui_controls/PropertyPage.h"
-#include "vgui_controls/PropertySheet.h"
-#include "vgui_controls/QueryBox.h"
-#include "vgui_controls/RadioButton.h"
-#include "vgui_controls/RichText.h"
-#include "vgui_controls/ScrollBar.h"
-#include "vgui_controls/ScrollBarSlider.h"
-#include "vgui_controls/SectionedListPanel.h"
-#include "vgui_controls/Slider.h"
-#ifndef HL1
-#include "vgui_controls/Splitter.h"
-#endif
-#include "vgui_controls/TextEntry.h"
-#include "vgui_controls/TextImage.h"
-#include "vgui_controls/ToggleButton.h"
-#include "vgui_controls/Tooltip.h"
-#ifndef HL1
-#include "vgui_controls/ToolWindow.h"
-#endif
-#include "vgui_controls/TreeView.h"
-#ifndef HL1
-#include "vgui_controls/TreeViewListControl.h"
-#endif
-#include "vgui_controls/URLLabel.h"
-#include "vgui_controls/WizardPanel.h"
-#include "vgui_controls/WizardSubPanel.h"
-
-#ifndef HL1
-#include "vgui_controls/KeyBoardEditorDialog.h"
-#include "vgui_controls/InputDialog.h"
-#endif
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef PCH_VGUI_CONTROLS_H +#define PCH_VGUI_CONTROLS_H + +#ifdef _WIN32 +#pragma once +#endif + +// general includes +#include <ctype.h> +#include <stdlib.h> +#include "tier0/dbg.h" +#include "tier0/valve_off.h" +#include "tier1/KeyValues.h" + +#include "tier0/valve_on.h" +#include "tier0/memdbgon.h" + +#include "filesystem.h" +#include "tier0/validator.h" + +// vgui includes +#include "vgui/IBorder.h" +#include "vgui/IInput.h" +#include "vgui/ILocalize.h" +#include "vgui/IPanel.h" +#include "vgui/IScheme.h" +#include "vgui/ISurface.h" +#include "vgui/ISystem.h" +#include "vgui/IVGui.h" +#include "vgui/KeyCode.h" +#include "vgui/Cursor.h" +#include "vgui/MouseCode.h" + +// vgui controls includes +#include "vgui_controls/Controls.h" + +#include "vgui_controls/AnimatingImagePanel.h" +#include "vgui_controls/AnimationController.h" +#include "vgui_controls/BitmapImagePanel.h" +#include "vgui_controls/BuildGroup.h" +#include "vgui_controls/BuildModeDialog.h" +#include "vgui_controls/Button.h" +#include "vgui_controls/CheckButton.h" +#include "vgui_controls/CheckButtonList.h" +#include "vgui_controls/ComboBox.h" +#include "vgui_controls/Controls.h" +#include "vgui_controls/DialogManager.h" +#include "vgui_controls/DirectorySelectDialog.h" +#include "vgui_controls/Divider.h" +#include "vgui_controls/EditablePanel.h" +#include "vgui_controls/FileOpenDialog.h" +#include "vgui_controls/FocusNavGroup.h" +#include "vgui_controls/Frame.h" +#include "vgui_controls/GraphPanel.h" +#include "vgui_controls/HTML.h" +#include "vgui_controls/Image.h" +#include "vgui_controls/ImageList.h" +#include "vgui_controls/ImagePanel.h" +#include "vgui_controls/Label.h" +#include "vgui_controls/ListPanel.h" +#include "vgui_controls/ListViewPanel.h" +#include "vgui_controls/Menu.h" +#include "vgui_controls/MenuBar.h" +#include "vgui_controls/MenuButton.h" +#include "vgui_controls/MenuItem.h" +#include "vgui_controls/MessageBox.h" +#include "vgui_controls/Panel.h" +#ifndef HL1 +#include "vgui_controls/PanelAnimationVar.h" +#endif +#include "vgui_controls/PanelListPanel.h" +#include "vgui_controls/PHandle.h" +#include "vgui_controls/ProgressBar.h" +#include "vgui_controls/ProgressBox.h" +#include "vgui_controls/PropertyDialog.h" +#include "vgui_controls/PropertyPage.h" +#include "vgui_controls/PropertySheet.h" +#include "vgui_controls/QueryBox.h" +#include "vgui_controls/RadioButton.h" +#include "vgui_controls/RichText.h" +#include "vgui_controls/ScrollBar.h" +#include "vgui_controls/ScrollBarSlider.h" +#include "vgui_controls/SectionedListPanel.h" +#include "vgui_controls/Slider.h" +#ifndef HL1 +#include "vgui_controls/Splitter.h" +#endif +#include "vgui_controls/TextEntry.h" +#include "vgui_controls/TextImage.h" +#include "vgui_controls/ToggleButton.h" +#include "vgui_controls/Tooltip.h" +#ifndef HL1 +#include "vgui_controls/ToolWindow.h" +#endif +#include "vgui_controls/TreeView.h" +#ifndef HL1 +#include "vgui_controls/TreeViewListControl.h" +#endif +#include "vgui_controls/URLLabel.h" +#include "vgui_controls/WizardPanel.h" +#include "vgui_controls/WizardSubPanel.h" + +#ifndef HL1 +#include "vgui_controls/KeyBoardEditorDialog.h" +#include "vgui_controls/InputDialog.h" +#endif + #endif // PCH_VGUI_CONTROLS_H
\ No newline at end of file diff --git a/mp/src/public/vgui_controls/perforcefilelistframe.h b/mp/src/public/vgui_controls/perforcefilelistframe.h index 4b4dca29..7744bf23 100644 --- a/mp/src/public/vgui_controls/perforcefilelistframe.h +++ b/mp/src/public/vgui_controls/perforcefilelistframe.h @@ -1,151 +1,151 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// List of perforce files and operations
-//
-//=============================================================================
-
-#ifndef PERFORCEFILELISTFRAME_H
-#define PERFORCEFILELISTFRAME_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/Frame.h"
-#include "tier1/utlvector.h"
-#include "tier1/utlstring.h"
-#include "p4lib/ip4.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// Enumeration of operation dialog ids
-//-----------------------------------------------------------------------------
-enum
-{
- OPERATION_DIALOG_ID_PERFORCE = 0,
-
- OPERATION_DIALOG_STANDARD_ID_COUNT,
- OPERATION_DIALOG_STANDARD_ID_MAX = OPERATION_DIALOG_STANDARD_ID_COUNT - 1,
-};
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Modal dialog for a list of files + an operation to perform
-//-----------------------------------------------------------------------------
-class COperationFileListFrame : public vgui::Frame
-{
- DECLARE_CLASS_SIMPLE( COperationFileListFrame, vgui::Frame );
-
-public:
- // NOTE: The dialog ID is used to allow dialogs to have different configurations saved
- COperationFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, bool bShowDescription, bool bShowOkOnly = false, int nDialogID = 1 );
- virtual ~COperationFileListFrame();
-
- // Command handler
- virtual void OnCommand( const char *pCommand );
- virtual void PerformLayout();
-
- // Adds files to the frame
- void ClearAllOperations();
- void AddOperation( const char *pOperation, const char *pFileName );
- void AddOperation( const char *pOperation, const char *pFileName, const Color& clr );
-
- // Resizes the operation column to fit the operation text
- void ResizeOperationColumnToContents();
-
- // Sets the column header for the 'operation' column
- void SetOperationColumnHeaderText( const char *pText );
-
- // Shows the panel
- void DoModal( KeyValues *pContextKeyValues = NULL, const char *pMessage = NULL );
-
- // Retrieves the number of files, the file names, and operations
- int GetOperationCount();
- const char *GetFileName( int i );
- const char *GetOperation( int i );
-
- // Retreives the description (only if it was shown)
- const char *GetDescription();
-
-private:
- virtual bool PerformOperation() { return true; }
- const char *CompletionMessage();
- void CleanUpMessage();
-
- vgui::ListPanel *m_pFileBrowser;
- vgui::Splitter *m_pSplitter;
- vgui::TextEntry *m_pDescription;
- vgui::Button *m_pYesButton;
- vgui::Button *m_pNoButton;
- KeyValues *m_pContextKeyValues;
- CUtlString m_MessageName;
- char *m_pText;
-};
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Modal dialog for picker
-//-----------------------------------------------------------------------------
-enum PerforceAction_t
-{
- PERFORCE_ACTION_NONE = -1,
- PERFORCE_ACTION_FILE_ADD = 0,
- PERFORCE_ACTION_FILE_EDIT,
- PERFORCE_ACTION_FILE_DELETE,
- PERFORCE_ACTION_FILE_REVERT,
- PERFORCE_ACTION_FILE_SUBMIT,
-};
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Modal dialog for picker
-//-----------------------------------------------------------------------------
-class CPerforceFileListFrame : public COperationFileListFrame
-{
- DECLARE_CLASS_SIMPLE( CPerforceFileListFrame, COperationFileListFrame );
-
-public:
- CPerforceFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, PerforceAction_t action );
- virtual ~CPerforceFileListFrame();
-
- // Adds files to the frame
- void ClearAllFiles();
- void AddFile( const char *pFullPath );
- void AddFile( const char *pRelativePath, const char *pPathId );
-
- void DoModal( KeyValues *pContextKeys = NULL, const char *pMessage = NULL );
-
-private:
- virtual bool PerformOperation();
-
- // Adds files for open, submit
- void AddFileForOpen( const char *pFullPath );
- void AddFileForSubmit( const char *pFullPath, P4FileState_t state );
-
- // Does the perforce operation
- void PerformPerforceAction( );
-
- PerforceAction_t m_Action;
- CUtlVector< P4File_t > m_OpenedFiles;
- CUtlString m_LastOpenedFilePathId;
-};
-
-
-//-----------------------------------------------------------------------------
-// Show the perforce query dialog
-// The specified keyvalues message will be sent either
-// 1) If you open the file for add/edit
-// 2) If you indicate to not add a file for add but don't hit cancel
-// If a specific perforce action is specified, then the dialog will only
-// be displayed if that action is appropriate
-//-----------------------------------------------------------------------------
-void ShowPerforceQuery( vgui::Panel *pParent, const char *pFileName, vgui::Panel *pActionSignalTarget, KeyValues *pKeyValues, PerforceAction_t actionFilter = PERFORCE_ACTION_NONE );
-
-
-#endif // PERFORCEFILELISTFRAME_H
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// List of perforce files and operations +// +//============================================================================= + +#ifndef PERFORCEFILELISTFRAME_H +#define PERFORCEFILELISTFRAME_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Frame.h" +#include "tier1/utlvector.h" +#include "tier1/utlstring.h" +#include "p4lib/ip4.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// Enumeration of operation dialog ids +//----------------------------------------------------------------------------- +enum +{ + OPERATION_DIALOG_ID_PERFORCE = 0, + + OPERATION_DIALOG_STANDARD_ID_COUNT, + OPERATION_DIALOG_STANDARD_ID_MAX = OPERATION_DIALOG_STANDARD_ID_COUNT - 1, +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for a list of files + an operation to perform +//----------------------------------------------------------------------------- +class COperationFileListFrame : public vgui::Frame +{ + DECLARE_CLASS_SIMPLE( COperationFileListFrame, vgui::Frame ); + +public: + // NOTE: The dialog ID is used to allow dialogs to have different configurations saved + COperationFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, bool bShowDescription, bool bShowOkOnly = false, int nDialogID = 1 ); + virtual ~COperationFileListFrame(); + + // Command handler + virtual void OnCommand( const char *pCommand ); + virtual void PerformLayout(); + + // Adds files to the frame + void ClearAllOperations(); + void AddOperation( const char *pOperation, const char *pFileName ); + void AddOperation( const char *pOperation, const char *pFileName, const Color& clr ); + + // Resizes the operation column to fit the operation text + void ResizeOperationColumnToContents(); + + // Sets the column header for the 'operation' column + void SetOperationColumnHeaderText( const char *pText ); + + // Shows the panel + void DoModal( KeyValues *pContextKeyValues = NULL, const char *pMessage = NULL ); + + // Retrieves the number of files, the file names, and operations + int GetOperationCount(); + const char *GetFileName( int i ); + const char *GetOperation( int i ); + + // Retreives the description (only if it was shown) + const char *GetDescription(); + +private: + virtual bool PerformOperation() { return true; } + const char *CompletionMessage(); + void CleanUpMessage(); + + vgui::ListPanel *m_pFileBrowser; + vgui::Splitter *m_pSplitter; + vgui::TextEntry *m_pDescription; + vgui::Button *m_pYesButton; + vgui::Button *m_pNoButton; + KeyValues *m_pContextKeyValues; + CUtlString m_MessageName; + char *m_pText; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for picker +//----------------------------------------------------------------------------- +enum PerforceAction_t +{ + PERFORCE_ACTION_NONE = -1, + PERFORCE_ACTION_FILE_ADD = 0, + PERFORCE_ACTION_FILE_EDIT, + PERFORCE_ACTION_FILE_DELETE, + PERFORCE_ACTION_FILE_REVERT, + PERFORCE_ACTION_FILE_SUBMIT, +}; + + +//----------------------------------------------------------------------------- +// Purpose: Modal dialog for picker +//----------------------------------------------------------------------------- +class CPerforceFileListFrame : public COperationFileListFrame +{ + DECLARE_CLASS_SIMPLE( CPerforceFileListFrame, COperationFileListFrame ); + +public: + CPerforceFileListFrame( vgui::Panel *pParent, const char *pTitle, const char *pColumnHeader, PerforceAction_t action ); + virtual ~CPerforceFileListFrame(); + + // Adds files to the frame + void ClearAllFiles(); + void AddFile( const char *pFullPath ); + void AddFile( const char *pRelativePath, const char *pPathId ); + + void DoModal( KeyValues *pContextKeys = NULL, const char *pMessage = NULL ); + +private: + virtual bool PerformOperation(); + + // Adds files for open, submit + void AddFileForOpen( const char *pFullPath ); + void AddFileForSubmit( const char *pFullPath, P4FileState_t state ); + + // Does the perforce operation + void PerformPerforceAction( ); + + PerforceAction_t m_Action; + CUtlVector< P4File_t > m_OpenedFiles; + CUtlString m_LastOpenedFilePathId; +}; + + +//----------------------------------------------------------------------------- +// Show the perforce query dialog +// The specified keyvalues message will be sent either +// 1) If you open the file for add/edit +// 2) If you indicate to not add a file for add but don't hit cancel +// If a specific perforce action is specified, then the dialog will only +// be displayed if that action is appropriate +//----------------------------------------------------------------------------- +void ShowPerforceQuery( vgui::Panel *pParent, const char *pFileName, vgui::Panel *pActionSignalTarget, KeyValues *pKeyValues, PerforceAction_t actionFilter = PERFORCE_ACTION_NONE ); + + +#endif // PERFORCEFILELISTFRAME_H + diff --git a/mp/src/public/vgui_controls/savedocumentquery.h b/mp/src/public/vgui_controls/savedocumentquery.h index a33393b7..fd738f46 100644 --- a/mp/src/public/vgui_controls/savedocumentquery.h +++ b/mp/src/public/vgui_controls/savedocumentquery.h @@ -1,37 +1,37 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// This dialog asks if you want to save your work
-//
-//=============================================================================
-
-#ifndef SAVEDOCUMENTQUERY_H
-#define SAVEDOCUMENTQUERY_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-class KeyValues;
-namespace vgui
-{
-class Panel;
-}
-
-
-//-----------------------------------------------------------------------------
-// Show the save document query dialog
-// NOTE: The following commands will be posted to the action signal target:
-// "OnExit" - when we want to quit
-// "OnSave" - when we want to save the file
-// "OnCloseNoSave" - when we want to close the file without saving it
-// "commandname" - additional command send after saving (SAVEDOC_POSTCOMMAND_AFTER_SAVE)
-// "OnMarkNotDirty" - when we want to mark the file not dirty
-//-----------------------------------------------------------------------------
-void ShowSaveDocumentQuery( vgui::Panel *pParent, const char *pFileName, const char *pFileType, int nContext, vgui::Panel *pActionSignalTarget, KeyValues *pPostSaveCommand );
-
-
-#endif // SAVEDOCUMENTQUERY_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// This dialog asks if you want to save your work +// +//============================================================================= + +#ifndef SAVEDOCUMENTQUERY_H +#define SAVEDOCUMENTQUERY_H + +#ifdef _WIN32 +#pragma once +#endif + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class KeyValues; +namespace vgui +{ +class Panel; +} + + +//----------------------------------------------------------------------------- +// Show the save document query dialog +// NOTE: The following commands will be posted to the action signal target: +// "OnExit" - when we want to quit +// "OnSave" - when we want to save the file +// "OnCloseNoSave" - when we want to close the file without saving it +// "commandname" - additional command send after saving (SAVEDOC_POSTCOMMAND_AFTER_SAVE) +// "OnMarkNotDirty" - when we want to mark the file not dirty +//----------------------------------------------------------------------------- +void ShowSaveDocumentQuery( vgui::Panel *pParent, const char *pFileName, const char *pFileType, int nContext, vgui::Panel *pActionSignalTarget, KeyValues *pPostSaveCommand ); + + +#endif // SAVEDOCUMENTQUERY_H diff --git a/mp/src/public/vgui_controls/subrectimage.h b/mp/src/public/vgui_controls/subrectimage.h index 7831f85e..b7738c4b 100644 --- a/mp/src/public/vgui_controls/subrectimage.h +++ b/mp/src/public/vgui_controls/subrectimage.h @@ -1,51 +1,51 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef SUBRECTIMAGE_H
-#define SUBRECTIMAGE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "vgui_controls/Image.h"
-#include "vgui/VGUI.h"
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Check box image
-//-----------------------------------------------------------------------------
-class CSubRectImage : public vgui::Image
-{
-public:
- CSubRectImage( const char *filename, bool hardwareFiltered, int subx, int suby, int subw, int subh );
- virtual ~CSubRectImage();
-
- void GetSize( int &wide, int &tall );
- void GetContentSize( int &wide, int &tall );
- void SetSize( int x, int y );
- void SetPos( int x, int y );
- void SetColor( Color col );
- const char *GetName();
- void Paint();
- void ForceUpload();
- vgui::HTexture GetID();
- bool IsValid();
-
-private:
- vgui::HTexture _id;
- int sub[ 4 ];
- char *_filename;
- int _pos[2];
- int _wide,_tall;
- Color _color;
- bool _uploaded;
- bool _valid;
- bool _filtered;
-};
-
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef SUBRECTIMAGE_H +#define SUBRECTIMAGE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/Image.h" +#include "vgui/VGUI.h" + + +//----------------------------------------------------------------------------- +// Purpose: Check box image +//----------------------------------------------------------------------------- +class CSubRectImage : public vgui::Image +{ +public: + CSubRectImage( const char *filename, bool hardwareFiltered, int subx, int suby, int subw, int subh ); + virtual ~CSubRectImage(); + + void GetSize( int &wide, int &tall ); + void GetContentSize( int &wide, int &tall ); + void SetSize( int x, int y ); + void SetPos( int x, int y ); + void SetColor( Color col ); + const char *GetName(); + void Paint(); + void ForceUpload(); + vgui::HTexture GetID(); + bool IsValid(); + +private: + vgui::HTexture _id; + int sub[ 4 ]; + char *_filename; + int _pos[2]; + int _wide,_tall; + Color _color; + bool _uploaded; + bool _valid; + bool _filtered; +}; + + #endif // SUBRECTIMAGE_H
\ No newline at end of file diff --git a/mp/src/public/vgui_controls/vgui_controls.cpp b/mp/src/public/vgui_controls/vgui_controls.cpp index ac6a1811..261ff983 100644 --- a/mp/src/public/vgui_controls/vgui_controls.cpp +++ b/mp/src/public/vgui_controls/vgui_controls.cpp @@ -1,58 +1,58 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================
-#include "vgui/IVGui.h"
-#include "vgui_controls/Controls.h"
-
-#include "vgui_controls/AnimatingImagePanel.h"
-#include "vgui_controls/BitmapImagePanel.h"
-#include "vgui_controls/ExpandButton.h"
-#include "vgui_controls/TreeViewListControl.h"
-#include "vgui_controls/HTML.h"
-
-// NOTE: This has to be the last file included!
-#include "tier0/memdbgon.h"
-
-
-using namespace vgui;
-
-USING_BUILD_FACTORY( Button );
-USING_BUILD_FACTORY( EditablePanel );
-USING_BUILD_FACTORY( ImagePanel );
-USING_BUILD_FACTORY( Label );
-USING_BUILD_FACTORY( Panel );
-USING_BUILD_FACTORY( ToggleButton );
-USING_BUILD_FACTORY( AnimatingImagePanel );
-USING_BUILD_FACTORY( CBitmapImagePanel );
-USING_BUILD_FACTORY( CheckButton );
-USING_BUILD_FACTORY( ComboBox );
-USING_BUILD_FACTORY_ALIAS( CvarToggleCheckButton<ConVarRef>, CvarToggleCheckButton );
-USING_BUILD_FACTORY( Divider );
-USING_BUILD_FACTORY( ExpandButton );
-USING_BUILD_FACTORY( GraphPanel );
-//USING_BUILD_FACTORY_ALIAS( HTML, HTML_NoJavascript );
-//USING_BUILD_FACTORY_ALIAS( HTML, HTML_Javascript );
-USING_BUILD_FACTORY( ListPanel );
-USING_BUILD_FACTORY( ListViewPanel );
-USING_BUILD_FACTORY( Menu );
-USING_BUILD_FACTORY( MenuBar );
-USING_BUILD_FACTORY( MenuButton );
-USING_BUILD_FACTORY( MenuItem );
-USING_BUILD_FACTORY( MessageBox );
-USING_BUILD_FACTORY( ProgressBar );
-USING_BUILD_FACTORY( CircularProgressBar );
-USING_BUILD_FACTORY( RadioButton );
-USING_BUILD_FACTORY( RichText );
-USING_BUILD_FACTORY( ScalableImagePanel );
-USING_BUILD_FACTORY_ALIAS( ScrollBar, ScrollBar_Vertical );
-USING_BUILD_FACTORY_ALIAS( ScrollBar, ScrollBar_Horizontal );
-USING_BUILD_FACTORY( ScrollBar );
-USING_BUILD_FACTORY( Slider );
-USING_BUILD_FACTORY( TextEntry );
-USING_BUILD_FACTORY( TreeView );
-USING_BUILD_FACTORY( CTreeViewListControl );
-USING_BUILD_FACTORY( URLLabel );
-
-int g_nYou_Must_Add_Public_Vgui_Controls_Vgui_ControlsCpp_To_Your_Project = 0;
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= +#include "vgui/IVGui.h" +#include "vgui_controls/Controls.h" + +#include "vgui_controls/AnimatingImagePanel.h" +#include "vgui_controls/BitmapImagePanel.h" +#include "vgui_controls/ExpandButton.h" +#include "vgui_controls/TreeViewListControl.h" +#include "vgui_controls/HTML.h" + +// NOTE: This has to be the last file included! +#include "tier0/memdbgon.h" + + +using namespace vgui; + +USING_BUILD_FACTORY( Button ); +USING_BUILD_FACTORY( EditablePanel ); +USING_BUILD_FACTORY( ImagePanel ); +USING_BUILD_FACTORY( Label ); +USING_BUILD_FACTORY( Panel ); +USING_BUILD_FACTORY( ToggleButton ); +USING_BUILD_FACTORY( AnimatingImagePanel ); +USING_BUILD_FACTORY( CBitmapImagePanel ); +USING_BUILD_FACTORY( CheckButton ); +USING_BUILD_FACTORY( ComboBox ); +USING_BUILD_FACTORY_ALIAS( CvarToggleCheckButton<ConVarRef>, CvarToggleCheckButton ); +USING_BUILD_FACTORY( Divider ); +USING_BUILD_FACTORY( ExpandButton ); +USING_BUILD_FACTORY( GraphPanel ); +//USING_BUILD_FACTORY_ALIAS( HTML, HTML_NoJavascript ); +//USING_BUILD_FACTORY_ALIAS( HTML, HTML_Javascript ); +USING_BUILD_FACTORY( ListPanel ); +USING_BUILD_FACTORY( ListViewPanel ); +USING_BUILD_FACTORY( Menu ); +USING_BUILD_FACTORY( MenuBar ); +USING_BUILD_FACTORY( MenuButton ); +USING_BUILD_FACTORY( MenuItem ); +USING_BUILD_FACTORY( MessageBox ); +USING_BUILD_FACTORY( ProgressBar ); +USING_BUILD_FACTORY( CircularProgressBar ); +USING_BUILD_FACTORY( RadioButton ); +USING_BUILD_FACTORY( RichText ); +USING_BUILD_FACTORY( ScalableImagePanel ); +USING_BUILD_FACTORY_ALIAS( ScrollBar, ScrollBar_Vertical ); +USING_BUILD_FACTORY_ALIAS( ScrollBar, ScrollBar_Horizontal ); +USING_BUILD_FACTORY( ScrollBar ); +USING_BUILD_FACTORY( Slider ); +USING_BUILD_FACTORY( TextEntry ); +USING_BUILD_FACTORY( TreeView ); +USING_BUILD_FACTORY( CTreeViewListControl ); +USING_BUILD_FACTORY( URLLabel ); + +int g_nYou_Must_Add_Public_Vgui_Controls_Vgui_ControlsCpp_To_Your_Project = 0; |