This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

45
public/vgui/Cursor.h Normal file
View File

@@ -0,0 +1,45 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Holds the enumerated list of default cursors
//
// $NoKeywords: $
//=============================================================================//
#ifndef CURSOR_H
#define CURSOR_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
namespace vgui
{
enum CursorCode
{
dc_user,
dc_none,
dc_arrow,
dc_ibeam,
dc_hourglass,
dc_waitarrow,
dc_crosshair,
dc_up,
dc_sizenwse,
dc_sizenesw,
dc_sizewe,
dc_sizens,
dc_sizeall,
dc_no,
dc_hand,
dc_blank, // don't show any custom vgui cursor, just let windows do it stuff (for HTML widget)
dc_last,
};
typedef unsigned long HCursor;
}
#endif // CURSOR_H

134
public/vgui/Dar.h Normal file
View File

@@ -0,0 +1,134 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Holds the enumerated list of default cursors
//
// $NoKeywords: $
//=============================================================================//
#ifndef DAR_H
#define DAR_H
#ifdef _WIN32
#pragma once
#endif
#include <stdlib.h>
#include <string.h>
#include <vgui/vgui.h>
#include "tier1/utlvector.h"
#include "tier0/memdbgon.h"
namespace vgui
{
//-----------------------------------------------------------------------------
// Purpose: Simple lightweight dynamic array implementation
//-----------------------------------------------------------------------------
template<class ELEMTYPE> class Dar : public CUtlVector< ELEMTYPE >
{
typedef CUtlVector< ELEMTYPE > BaseClass;
public:
Dar()
{
}
Dar(int initialCapacity) :
BaseClass( 0, initialCapacity )
{
}
public:
void SetCount(int count)
{
this->EnsureCount( count );
}
int GetCount()
{
return this->Count();
}
int AddElement(ELEMTYPE elem)
{
return this->AddToTail( elem );
}
void MoveElementToEnd( ELEMTYPE elem )
{
if ( this->Count() == 0 )
return;
// quick check to see if it's already at the end
if ( this->Element( this->Count() - 1 ) == elem )
return;
int idx = this->Find( elem );
if ( idx == this->InvalidIndex() )
return;
this->Remove( idx );
this->AddToTail( elem );
}
// returns the index of the element in the array, -1 if not found
int FindElement(ELEMTYPE elem)
{
return this->Find( elem );
}
bool HasElement(ELEMTYPE elem)
{
if ( FindElement(elem) != this->InvalidIndex() )
{
return true;
}
return false;
}
int PutElement(ELEMTYPE elem)
{
int index = FindElement(elem);
if (index >= 0)
{
return index;
}
return AddElement(elem);
}
// insert element at index and move all the others down 1
void InsertElementAt(ELEMTYPE elem,int index)
{
this->InsertBefore( index, elem );
}
void SetElementAt(ELEMTYPE elem,int index)
{
this->EnsureCount( index + 1 );
this->Element( index ) = elem;
}
void RemoveElementAt(int index)
{
this->Remove( index );
}
void RemoveElementsBefore(int index)
{
if ( index <= 0 )
return;
this->RemoveMultiple( 0, index - 1 );
}
void RemoveElement(ELEMTYPE elem)
{
this->FindAndRemove( elem );
}
void *GetBaseData()
{
return this->Base();
}
void CopyFrom(Dar<ELEMTYPE> &dar)
{
CoypArray( dar.Base(), dar.Count() );
}
};
}
#include "tier0/memdbgoff.h"
#endif // DAR_H

63
public/vgui/IBorder.h Normal file
View File

@@ -0,0 +1,63 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IBORDER_H
#define IBORDER_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
class KeyValues;
namespace vgui
{
class IScheme;
//-----------------------------------------------------------------------------
// Purpose: Interface to panel borders
// Borders have a close relationship with panels
// They are the edges of the panel.
//-----------------------------------------------------------------------------
class IBorder
{
public:
virtual void Paint(VPANEL panel) = 0;
virtual void Paint(int x0, int y0, int x1, int y1) = 0;
virtual void Paint(int x0, int y0, int x1, int y1, int breakSide, int breakStart, int breakStop) = 0;
virtual void SetInset(int left, int top, int right, int bottom) = 0;
virtual void GetInset(int &left, int &top, int &right, int &bottom) = 0;
virtual void ApplySchemeSettings(IScheme *pScheme, KeyValues *inResourceData) = 0;
virtual const char *GetName() = 0;
virtual void SetName(const char *name) = 0;
enum backgroundtype_e
{
BACKGROUND_FILLED,
BACKGROUND_TEXTURED,
BACKGROUND_ROUNDEDCORNERS,
};
virtual backgroundtype_e GetBackgroundType() = 0;
enum sides_e
{
SIDE_LEFT = 0,
SIDE_TOP = 1,
SIDE_RIGHT = 2,
SIDE_BOTTOM = 3
};
virtual bool PaintFirst( void ) = 0;
};
} // namespace vgui
#endif // IBORDER_H

View File

@@ -0,0 +1,94 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef ICLIENTPANEL_H
#define ICLIENTPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
#ifdef GetClassName
#undef GetClassName
#endif
class KeyValues;
namespace vgui
{
class Panel;
class SurfaceBase;
enum EInterfaceID
{
ICLIENTPANEL_STANDARD_INTERFACE = 0,
};
//-----------------------------------------------------------------------------
// Purpose: Interface from vgui panels -> Client panels
// This interface cannot be changed without rebuilding all vgui projects
// Primarily this interface handles dispatching messages from core vgui to controls
// The additional functions are all their for debugging or optimization reasons
// To add to this later, use QueryInterface() to see if they support new interfaces
//-----------------------------------------------------------------------------
class IClientPanel
{
public:
virtual VPANEL GetVPanel() = 0;
// straight interface to Panel functions
virtual void Think() = 0;
virtual void PerformApplySchemeSettings() = 0;
virtual void PaintTraverse(bool forceRepaint, bool allowForce) = 0;
virtual void Repaint() = 0;
virtual VPANEL IsWithinTraverse(int x, int y, bool traversePopups) = 0;
virtual void GetInset(int &top, int &left, int &right, int &bottom) = 0;
virtual void GetClipRect(int &x0, int &y0, int &x1, int &y1) = 0;
virtual void OnChildAdded(VPANEL child) = 0;
virtual void OnSizeChanged(int newWide, int newTall) = 0;
virtual void InternalFocusChanged(bool lost) = 0;
virtual bool RequestInfo(KeyValues *outputData) = 0;
virtual void RequestFocus(int direction) = 0;
virtual bool RequestFocusPrev(VPANEL existingPanel) = 0;
virtual bool RequestFocusNext(VPANEL existingPanel) = 0;
virtual void OnMessage(const KeyValues *params, VPANEL ifromPanel) = 0;
virtual VPANEL GetCurrentKeyFocus() = 0;
virtual int GetTabPosition() = 0;
// for debugging purposes
virtual const char *GetName() = 0;
virtual const char *GetClassName() = 0;
// get scheme handles from panels
virtual HScheme GetScheme() = 0;
// gets whether or not this panel should scale with screen resolution
virtual bool IsProportional() = 0;
// auto-deletion
virtual bool IsAutoDeleteSet() = 0;
// deletes this
virtual void DeletePanel() = 0;
// interfaces
virtual void *QueryInterface(EInterfaceID id) = 0;
// returns a pointer to the vgui controls baseclass Panel *
virtual Panel *GetPanel() = 0;
// returns the name of the module this panel is part of
virtual const char *GetModuleName() = 0;
virtual void OnTick() = 0;
};
} // namespace vgui
#endif // ICLIENTPANEL_H

198
public/vgui/IHTML.h Normal file
View File

@@ -0,0 +1,198 @@
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IHTML_H
#define IHTML_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
#include <vgui/MouseCode.h>
#include <vgui/KeyCode.h>
#include <vgui/Cursor.h>
#include <vgui/IImage.h>
namespace vgui
{
//-----------------------------------------------------------------------------
// Purpose: basic interface for a HTML window
//-----------------------------------------------------------------------------
class IHTML
{
public:
// open a new page
virtual void OpenURL(const char *)=0;
// stops the existing page from loading
virtual bool StopLoading()=0;
// refreshes the current page
virtual bool Refresh()=0;
// display the control -- deprecated !! Use SetVisible() instead!
virtual bool Show(bool shown)=0;
// return the currently opened page
virtual const char *GetOpenedPage()=0;
// called when the browser needs to be resized
virtual void Obsolete_OnSize(int x,int y, int w,int h)=0;
// returns the width and height (in pixels) of the HTML full page (not just the displayed region)
virtual void GetHTMLSize(int &wide,int &tall) = 0;
// clear the text in an existing control
virtual void Clear()=0;
// add text to the browser control (as a HTML formated string)
virtual void AddText(const char *text)=0;
enum MOUSE_STATE { UP,DOWN,MOVE,DBLCLICK };
// unused functions we keep around so the vtable layout is binary compatible
virtual void Obsolete_OnMouse(MouseCode code,MOUSE_STATE s,int x,int y)=0;
virtual void Obsolete_OnChar(wchar_t unichar)=0;
virtual void Obsolete_OnKeyDown(KeyCode code)=0;
virtual vgui::IImage *GetBitmap()=0;
virtual void SetVisible( bool state ) = 0;
virtual void SetSize( int wide,int tall )=0;
virtual void OnMouse(MouseCode code,MOUSE_STATE s,int x,int y, bool bPopupMenuMenu )=0;
virtual void OnChar(wchar_t unichar, bool bPopupMenu)=0;
virtual void OnKeyDown(KeyCode code, bool bPopupMenu)=0;
virtual void ScrollV( int nPixels ) = 0;
virtual void ScrollH( int nPixels ) = 0;
virtual void OnMouseWheeled( int delta, bool bPopupMenu )= 0;
// called when the browser needs to be resized
virtual void OnKeyUp(KeyCode code, bool bPopupMenu)=0;
// open a URL with the provided POST data (which can be much larger than the max URL of 512 chars)
// NOTE - You CANNOT have get params (i.e a "?" ) in pchURL if pchPostData is set (due to an IE bug)
virtual void PostURL( const char *pchURL, const char *pchPostData ) = 0;
// Run javascript within the browser control
virtual void RunJavascript( const char *pchScript ) = 0;
virtual void SetMousePosition( int x, int y, bool bPopupMenu ) = 0;
virtual void SetUserAgentInfo( const wchar_t *pwchUserAgent ) = 0;
// can't add custom headers to IE
virtual void AddHeader( const char *pchHeader, const char *pchValue ) = 0;
virtual void SetFileDialogChoice( const char *pchFileName ) = 0;
// we are hiding the popup, so make sure webkit knows
virtual void HidePopup() = 0;
virtual void SetHTMLFocus() = 0;
virtual void KillHTMLFocus() = 0;
// ask webkit about the size of any scrollbars it wants to render
virtual void HorizontalScrollBarSize( int &x, int &y, int &wide, int &tall) = 0;
virtual void VerticalScrollBarSize( int &x, int &y, int &wide, int &tall) = 0;
virtual int HorizontalScroll() = 0;
virtual int VerticalScroll() = 0;
virtual int HorizontalScrollMax() =0;
virtual int VerticalScrollMax() =0;
virtual bool IsHorizontalScrollBarVisible() =0;
virtual bool IsVeritcalScrollBarVisible() =0;
virtual void SetHorizontalScroll( int scroll ) =0;
virtual void SetVerticalScroll( int scroll ) =0;
virtual void ViewSource() = 0;
virtual void Copy() = 0;
virtual void Paste() = 0;
// IE specific calls
virtual bool IsIERender() = 0;
virtual void GetIDispatchPtr( void **pIDispatch ) = 0;
virtual void GetHTMLScroll( int &top, int &left ) = 0;
};
//-----------------------------------------------------------------------------
// Purpose: possible load errors when you open a url in the web browser
//-----------------------------------------------------------------------------
enum EWebPageLoadError
{
eLoadErrorNone = 0,
eMimeTypeNotSupported, // probably trying to download an exe or something
eCacheMiss, // Usually caused by navigating to a page with POST data via back or forward buttons
eBadURL, // bad url passed in (invalid hostname, malformed)
eConnectionProblem, // network connectivity problem, server offline or user not on internet
eProxyConnectionProblem, // User is configured to use proxy, but we can't use it
eLoadErrorUnknown, // not a load type we classify right now, check out cef_handler_errorcode_t for the full list we could translate
};
//-----------------------------------------------------------------------------
// Purpose: basic callback interface for a HTML window
//-----------------------------------------------------------------------------
class IHTMLEvents
{
public:
// unused functions we keep around so the vtable layout is binary compatible
virtual bool Obsolete_OnStartURL(const char *url, const char *target, bool first)=0;
virtual void Obsolete_OnFinishURL(const char *url)=0;
virtual void Obsolete_OnProgressURL(long current, long maximum)=0;
virtual void Obsolete_OnSetStatusText(const char *text) =0;
virtual void Obsolete_OnUpdate() =0;
virtual void Obsolete_OnLink()=0;
virtual void Obsolete_OffLink()=0;
// call backs for events
// when the top level browser is changing the page they are looking at (not sub iframes or the like loading)
virtual void OnURLChanged( const char *url, const char *pchPostData, bool bIsRedirect ) = 0;
// the control has finished loading a request, could be a sub request in the page
virtual void OnFinishRequest( const char *url, const char *pageTitle ) = 0;
// the lower html control wants to load a url, do we allow it?
virtual bool OnStartRequestInternal( const char *url, const char *target, const char *pchPostData, bool bIsRedirect ) = 0;
// show a popup menu for this html control
virtual void ShowPopup( int x, int y, int wide, int tall ) = 0;
// hide any popup menu you are showing
virtual void HidePopup() = 0;
// show an external html window at this position and side
virtual bool OnPopupHTMLWindow( const char *pchURL, int x, int y, int wide, int tall ) = 0;
// the browser is telling us the title it would like us to show
virtual void SetHTMLTitle( const char *pchTitle ) = 0;
// the browser is loading a sub url for a page, usually an image or css
virtual void OnLoadingResource( const char *pchURL ) = 0;
// the browser is telling us the user is hovering a url or the like
virtual void OnSetStatusText(const char *text) =0;
// the browser wants the cursor changed please
virtual void OnSetCursor( vgui::CursorCode cursor ) = 0;
// the browser wants to ask the user to select a local file and tell it about it
virtual void OnFileLoadDialog( const char *pchTitle, const char *pchInitialFile ) = 0;
// show and hide tooltip text
virtual void OnShowToolTip( const char *pchText ) = 0;
virtual void OnUpdateToolTip( const char *pchText ) = 0;
virtual void OnHideToolTip() = 0;
// IE only code
virtual bool BOnCreateNewWindow( void **ppDispatch ) = 0;
virtual void OnLink()=0;
virtual void OffLink()=0;
virtual void OnCloseWindow() = 0;
virtual void OnUpdate() =0;
virtual void OnProgressRequest(long current, long maximum)=0;
};
}
#endif // IHTML_H

75
public/vgui/IImage.h Normal file
View File

@@ -0,0 +1,75 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IIMAGE_H
#define IIMAGE_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
class Color;
namespace vgui
{
typedef unsigned long HTexture;
enum iimage_rotation_t
{
ROTATED_UNROTATED = 0,
ROTATED_CLOCKWISE_90,
ROTATED_ANTICLOCKWISE_90,
ROTATED_FLIPPED,
};
//-----------------------------------------------------------------------------
// Purpose: Interface to drawing an image
//-----------------------------------------------------------------------------
class IImage
{
public:
// Call to Paint the image
// Image will draw within the current panel context at the specified position
virtual void Paint() = 0;
// Set the position of the image
virtual void SetPos(int x, int y) = 0;
// Gets the size of the content
virtual void GetContentSize(int &wide, int &tall) = 0;
// Get the size the image will actually draw in (usually defaults to the content size)
virtual void GetSize(int &wide, int &tall) = 0;
// Sets the size of the image
virtual void SetSize(int wide, int tall) = 0;
// Set the draw color
virtual void SetColor(Color col) = 0;
// virtual destructor
virtual ~IImage() {}
// not for general purpose use
// evicts the underlying image from memory if refcounts permit, otherwise ignored
// returns true if eviction occurred, otherwise false
virtual bool Evict() = 0;
virtual int GetNumFrames() = 0;
virtual void SetFrame( int nFrame ) = 0;
virtual HTexture GetID() = 0;
virtual void SetRotation( int iRotation ) = 0;
};
} // namespace vgui
#endif // IIMAGE_H

196
public/vgui/IInput.h Normal file
View File

@@ -0,0 +1,196 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef VGUI_IINPUT_H
#define VGUI_IINPUT_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
#include "tier1/interface.h"
#include "vgui/MouseCode.h"
#include "vgui/KeyCode.h"
namespace vgui
{
class Cursor;
typedef unsigned long HCursor;
#define VGUI_GCS_COMPREADSTR 0x0001
#define VGUI_GCS_COMPREADATTR 0x0002
#define VGUI_GCS_COMPREADCLAUSE 0x0004
#define VGUI_GCS_COMPSTR 0x0008
#define VGUI_GCS_COMPATTR 0x0010
#define VGUI_GCS_COMPCLAUSE 0x0020
#define VGUI_GCS_CURSORPOS 0x0080
#define VGUI_GCS_DELTASTART 0x0100
#define VGUI_GCS_RESULTREADSTR 0x0200
#define VGUI_GCS_RESULTREADCLAUSE 0x0400
#define VGUI_GCS_RESULTSTR 0x0800
#define VGUI_GCS_RESULTCLAUSE 0x1000
// style bit flags for WM_IME_COMPOSITION
#define VGUI_CS_INSERTCHAR 0x2000
#define VGUI_CS_NOMOVECARET 0x4000
#define MESSAGE_CURSOR_POS -1
#define MESSAGE_CURRENT_KEYFOCUS -2
class IInput : public IBaseInterface
{
public:
virtual void SetMouseFocus(VPANEL newMouseFocus) = 0;
virtual void SetMouseCapture(VPANEL panel) = 0;
// returns the string name of a scan code
virtual void GetKeyCodeText(KeyCode code, char *buf, int buflen) = 0;
// focus
virtual VPANEL GetFocus() = 0;
virtual VPANEL GetCalculatedFocus() = 0;// to handle cases where the focus changes inside a frame.
virtual VPANEL GetMouseOver() = 0; // returns the panel the mouse is currently over, ignoring mouse capture
// mouse state
virtual void SetCursorPos(int x, int y) = 0;
virtual void GetCursorPos(int &x, int &y) = 0;
virtual bool WasMousePressed(MouseCode code) = 0;
virtual bool WasMouseDoublePressed(MouseCode code) = 0;
virtual bool IsMouseDown(MouseCode code) = 0;
// cursor override
virtual void SetCursorOveride(HCursor cursor) = 0;
virtual HCursor GetCursorOveride() = 0;
// key state
virtual bool WasMouseReleased(MouseCode code) = 0;
virtual bool WasKeyPressed(KeyCode code) = 0;
virtual bool IsKeyDown(KeyCode code) = 0;
virtual bool WasKeyTyped(KeyCode code) = 0;
virtual bool WasKeyReleased(KeyCode code) = 0;
virtual VPANEL GetAppModalSurface() = 0;
// set the modal dialog panel.
// all events will go only to this panel and its children.
virtual void SetAppModalSurface(VPANEL panel) = 0;
// release the modal dialog panel
// do this when your modal dialog finishes.
virtual void ReleaseAppModalSurface() = 0;
virtual void GetCursorPosition( int &x, int &y ) = 0;
virtual void SetIMEWindow( void *hwnd ) = 0;
virtual void *GetIMEWindow() = 0;
virtual void OnChangeIME( bool forward ) = 0;
virtual int GetCurrentIMEHandle() = 0;
virtual int GetEnglishIMEHandle() = 0;
// Returns the Language Bar label (Chinese, Korean, Japanese, Russion, Thai, etc.)
virtual void GetIMELanguageName( OUT_Z_BYTECAP(unicodeBufferSizeInBytes) wchar_t *buf, int unicodeBufferSizeInBytes ) = 0;
// Returns the short code for the language (EN, CH, KO, JP, RU, TH, etc. ).
virtual void GetIMELanguageShortCode( OUT_Z_BYTECAP(unicodeBufferSizeInBytes) wchar_t *buf, int unicodeBufferSizeInBytes ) = 0;
struct LanguageItem
{
wchar_t shortname[ 4 ];
wchar_t menuname[ 128 ];
int handleValue;
bool active; // true if this is the active language
};
struct ConversionModeItem
{
wchar_t menuname[ 128 ];
int handleValue;
bool active; // true if this is the active conversion mode
};
struct SentenceModeItem
{
wchar_t menuname[ 128 ];
int handleValue;
bool active; // true if this is the active sentence mode
};
// Call with NULL dest to get item count
virtual int GetIMELanguageList( LanguageItem *dest, int destcount ) = 0;
virtual int GetIMEConversionModes( ConversionModeItem *dest, int destcount ) = 0;
virtual int GetIMESentenceModes( SentenceModeItem *dest, int destcount ) = 0;
virtual void OnChangeIMEByHandle( int handleValue ) = 0;
virtual void OnChangeIMEConversionModeByHandle( int handleValue ) = 0;
virtual void OnChangeIMESentenceModeByHandle( int handleValue ) = 0;
virtual void OnInputLanguageChanged() = 0;
virtual void OnIMEStartComposition() = 0;
virtual void OnIMEComposition( int flags ) = 0;
virtual void OnIMEEndComposition() = 0;
virtual void OnIMEShowCandidates() = 0;
virtual void OnIMEChangeCandidates() = 0;
virtual void OnIMECloseCandidates() = 0;
virtual void OnIMERecomputeModes() = 0;
virtual int GetCandidateListCount() = 0;
virtual void GetCandidate( int num, OUT_Z_BYTECAP(destSizeBytes) wchar_t *dest, int destSizeBytes ) = 0;
virtual int GetCandidateListSelectedItem() = 0;
virtual int GetCandidateListPageSize() = 0;
virtual int GetCandidateListPageStart() = 0;
//NOTE: We render our own candidate lists most of the time...
virtual void SetCandidateWindowPos( int x, int y ) = 0;
virtual bool GetShouldInvertCompositionString() = 0;
virtual bool CandidateListStartsAtOne() = 0;
virtual void SetCandidateListPageStart( int start ) = 0;
// Passes in a keycode which allows hitting other mouse buttons w/o cancelling capture mode
virtual void SetMouseCaptureEx(VPANEL panel, MouseCode captureStartMouseCode ) = 0;
// Because OnKeyCodeTyped uses CallParentFunction and is therefore message based, there's no way
// to know if handler actually swallowed the specified keycode. To get around this, I set a global before calling the
// kb focus OnKeyCodeTyped function and if we ever get to a Panel::OnKeyCodeTypes we know that nobody handled the message
// and in that case we can post a message to any "unhandled keycode" listeners
// This will generate an MESSAGE_FUNC_INT( "KeyCodeUnhandled" "code" code ) message to each such listener
virtual void RegisterKeyCodeUnhandledListener( VPANEL panel ) = 0;
virtual void UnregisterKeyCodeUnhandledListener( VPANEL panel ) = 0;
// Posts unhandled message to all interested panels
virtual void OnKeyCodeUnhandled( int keyCode ) = 0;
// Assumes subTree is a child panel of the root panel for the vgui contect
// if restrictMessagesToSubTree is true, then mouse and kb messages are only routed to the subTree and it's children and mouse/kb focus
// can only be on one of the subTree children, if a mouse click occurs outside of the subtree, and "UnhandledMouseClick" message is sent to unhandledMouseClickListener panel
// if it's set
// if restrictMessagesToSubTree is false, then mouse and kb messages are routed as normal except that they are not routed down into the subtree
// however, if a mouse click occurs outside of the subtree, and "UnhandleMouseClick" message is sent to unhandledMouseClickListener panel
// if it's set
virtual void SetModalSubTree( VPANEL subTree, VPANEL unhandledMouseClickListener, bool restrictMessagesToSubTree = true ) = 0;
virtual void ReleaseModalSubTree() = 0;
virtual VPANEL GetModalSubTree() = 0;
// These toggle whether the modal subtree is exclusively receiving messages or conversely whether it's being excluded from receiving messages
// Sends a "ModalSubTree", state message
virtual void SetModalSubTreeReceiveMessages( bool state ) = 0;
virtual bool ShouldModalSubTreeReceiveMessages() const = 0;
virtual VPANEL GetMouseCapture() = 0;
virtual VPANEL GetMouseFocus() = 0;
virtual void SetModalSubTreeShowMouse( bool state ) = 0;
virtual bool ShouldModalSubTreeShowMouse() const = 0;
};
} // namespace vgui
#endif // VGUI_IINPUT_H

View File

@@ -0,0 +1,112 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef IINPUTINTERNAL_H
#define IINPUTINTERNAL_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/IInput.h>
namespace vgui
{
enum MouseCodeState_t
{
BUTTON_RELEASED = 0,
BUTTON_PRESSED,
BUTTON_DOUBLECLICKED,
};
typedef int HInputContext;
#define DEFAULT_INPUT_CONTEXT ((vgui::HInputContext)~0)
class IInputInternal : public IInput
{
public:
// processes input for a frame
virtual void RunFrame() = 0;
virtual void UpdateMouseFocus(int x, int y) = 0;
// called when a panel becomes invalid
virtual void PanelDeleted(VPANEL panel) = 0;
// inputs into vgui input handling
virtual bool InternalCursorMoved(int x,int y) = 0; //expects input in surface space
virtual bool InternalMousePressed(MouseCode code) = 0;
virtual bool InternalMouseDoublePressed(MouseCode code) = 0;
virtual bool InternalMouseReleased(MouseCode code) = 0;
virtual bool InternalMouseWheeled(int delta) = 0;
virtual bool InternalKeyCodePressed(KeyCode code) = 0;
virtual void InternalKeyCodeTyped(KeyCode code) = 0;
virtual void InternalKeyTyped(wchar_t unichar) = 0;
virtual bool InternalKeyCodeReleased(KeyCode code) = 0;
//=============================================================================
// HPE_BEGIN
// [dwenger] Handle gamepad joystick movement.
//=============================================================================
virtual bool InternalJoystickMoved(int axis, int value) = 0;
//=============================================================================
// HPE_END
//=============================================================================
// Creates/ destroys "input" contexts, which contains information
// about which controls have mouse + key focus, for example.
virtual HInputContext CreateInputContext() = 0;
virtual void DestroyInputContext( HInputContext context ) = 0;
// Associates a particular panel with an input context
// Associating NULL is valid; it disconnects the panel from the context
virtual void AssociatePanelWithInputContext( HInputContext context, VPANEL pRoot ) = 0;
// Activates a particular input context, use DEFAULT_INPUT_CONTEXT
// to get the one normally used by VGUI
virtual void ActivateInputContext( HInputContext context ) = 0;
// This method is called to post a cursor message to the current input context
virtual void PostCursorMessage() = 0;
// Cursor position; this is the current position read from the input queue.
// We need to set it because client code may read this during Mouse Pressed
// events, etc.
virtual void UpdateCursorPosInternal( int x, int y ) = 0;
//=============================================================================
// HPE_BEGIN
// [dwenger] Handle gamepad joystick movement.
//=============================================================================
virtual void UpdateJoystickXPosInternal( int pos ) = 0;
virtual void UpdateJoystickYPosInternal( int pos ) = 0;
virtual int GetJoystickXPos( ) = 0;
virtual int GetJoystickYPos( ) = 0;
//=============================================================================
// HPE_END
//=============================================================================
// Called to handle explicit calls to CursorSetPos after input processing is complete
virtual void HandleExplicitSetCursor( ) = 0;
// Resets a particular input context, use DEFAULT_INPUT_CONTEXT
// to get the one normally used by VGUI
virtual void ResetInputContext( HInputContext context ) = 0;
// Updates the internal key/mouse state associated with the current input context without sending messages
virtual void SetKeyCodeState( KeyCode code, bool bPressed ) = 0;
virtual void SetMouseCodeState( MouseCode code, MouseCodeState_t state ) = 0;
virtual void UpdateButtonState( const InputEvent_t &event ) = 0;
};
} // namespace vgui
#define VGUI_INPUTINTERNAL_INTERFACE_VERSION "VGUI_InputInternal001"
#endif // IINPUTINTERNAL_H

32
public/vgui/ILocalize.h Normal file
View File

@@ -0,0 +1,32 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef VGUI_ILOCALIZE_H
#define VGUI_ILOCALIZE_H
#ifdef _WIN32
#pragma once
#endif
#include "localize/ilocalize.h"
// Everything moved to localize lib; this is here for backward compat.
namespace vgui
{
// direct references to localized strings
typedef uint32 StringIndex_t;
const uint32 INVALID_STRING_INDEX = (uint32) -1;
abstract_class ILocalize : public ::ILocalize
{
public:
virtual const char *FindAsUTF8( const char *tokenName ) = 0;
};
}; // namespace vgui
#endif // VGUI_ILOCALIZE_H

148
public/vgui/IPanel.h Normal file
View File

@@ -0,0 +1,148 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IPANEL_H
#define IPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
#include "tier1/interface.h"
#include "tier1/utlvector.h"
#ifdef SendMessage
#undef SendMessage
#endif
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class KeyValues;
struct DmxElementUnpackStructure_t;
class CDmxElement;
namespace vgui
{
class SurfacePlat;
class IClientPanel;
//!! must be removed
class Panel;
//-----------------------------------------------------------------------------
// Purpose: interface from Client panels -> vgui panels
//-----------------------------------------------------------------------------
class IPanel : public IBaseInterface
{
public:
virtual void Init(VPANEL vguiPanel, IClientPanel *panel) = 0;
// methods
virtual void SetPos(VPANEL vguiPanel, int x, int y) = 0;
virtual void GetPos(VPANEL vguiPanel, int &x, int &y) = 0;
virtual void SetSize(VPANEL vguiPanel, int wide,int tall) = 0;
virtual void GetSize(VPANEL vguiPanel, int &wide, int &tall) = 0;
virtual void SetMinimumSize(VPANEL vguiPanel, int wide, int tall) = 0;
virtual void GetMinimumSize(VPANEL vguiPanel, int &wide, int &tall) = 0;
virtual void SetZPos(VPANEL vguiPanel, int z) = 0;
virtual int GetZPos(VPANEL vguiPanel) = 0;
virtual void GetAbsPos(VPANEL vguiPanel, int &x, int &y) = 0;
virtual void GetClipRect(VPANEL vguiPanel, int &x0, int &y0, int &x1, int &y1) = 0;
virtual void SetInset(VPANEL vguiPanel, int left, int top, int right, int bottom) = 0;
virtual void GetInset(VPANEL vguiPanel, int &left, int &top, int &right, int &bottom) = 0;
virtual void SetVisible(VPANEL vguiPanel, bool state) = 0;
virtual bool IsVisible(VPANEL vguiPanel) = 0;
virtual void SetParent(VPANEL vguiPanel, VPANEL newParent) = 0;
virtual int GetChildCount(VPANEL vguiPanel) = 0;
virtual VPANEL GetChild(VPANEL vguiPanel, int index) = 0;
virtual CUtlVector< VPANEL > &GetChildren( VPANEL vguiPanel ) = 0;
virtual VPANEL GetParent(VPANEL vguiPanel) = 0;
virtual void MoveToFront(VPANEL vguiPanel) = 0;
virtual void MoveToBack(VPANEL vguiPanel) = 0;
virtual bool HasParent(VPANEL vguiPanel, VPANEL potentialParent) = 0;
virtual bool IsPopup(VPANEL vguiPanel) = 0;
virtual void SetPopup(VPANEL vguiPanel, bool state) = 0;
virtual bool IsFullyVisible( VPANEL vguiPanel ) = 0;
// gets the scheme this panel uses
virtual HScheme GetScheme(VPANEL vguiPanel) = 0;
// gets whether or not this panel should scale with screen resolution
virtual bool IsProportional(VPANEL vguiPanel) = 0;
// returns true if auto-deletion flag is set
virtual bool IsAutoDeleteSet(VPANEL vguiPanel) = 0;
// deletes the Panel * associated with the vpanel
virtual void DeletePanel(VPANEL vguiPanel) = 0;
// input interest
virtual void SetKeyBoardInputEnabled(VPANEL vguiPanel, bool state) = 0;
virtual void SetMouseInputEnabled(VPANEL vguiPanel, bool state) = 0;
virtual bool IsKeyBoardInputEnabled(VPANEL vguiPanel) = 0;
virtual bool IsMouseInputEnabled(VPANEL vguiPanel) = 0;
// calculates the panels current position within the hierarchy
virtual void Solve(VPANEL vguiPanel) = 0;
// gets names of the object (for debugging purposes)
virtual const char *GetName(VPANEL vguiPanel) = 0;
virtual const char *GetClassName(VPANEL vguiPanel) = 0;
// delivers a message to the panel
virtual void SendMessage(VPANEL vguiPanel, KeyValues *params, VPANEL ifromPanel) = 0;
// these pass through to the IClientPanel
virtual void Think(VPANEL vguiPanel) = 0;
virtual void PerformApplySchemeSettings(VPANEL vguiPanel) = 0;
virtual void PaintTraverse(VPANEL vguiPanel, bool forceRepaint, bool allowForce = true) = 0;
virtual void Repaint(VPANEL vguiPanel) = 0;
virtual VPANEL IsWithinTraverse(VPANEL vguiPanel, int x, int y, bool traversePopups) = 0;
virtual void OnChildAdded(VPANEL vguiPanel, VPANEL child) = 0;
virtual void OnSizeChanged(VPANEL vguiPanel, int newWide, int newTall) = 0;
virtual void InternalFocusChanged(VPANEL vguiPanel, bool lost) = 0;
virtual bool RequestInfo(VPANEL vguiPanel, KeyValues *outputData) = 0;
virtual void RequestFocus(VPANEL vguiPanel, int direction = 0) = 0;
virtual bool RequestFocusPrev(VPANEL vguiPanel, VPANEL existingPanel) = 0;
virtual bool RequestFocusNext(VPANEL vguiPanel, VPANEL existingPanel) = 0;
virtual VPANEL GetCurrentKeyFocus(VPANEL vguiPanel) = 0;
virtual int GetTabPosition(VPANEL vguiPanel) = 0;
// used by ISurface to store platform-specific data
virtual SurfacePlat *Plat(VPANEL vguiPanel) = 0;
virtual void SetPlat(VPANEL vguiPanel, SurfacePlat *Plat) = 0;
// returns a pointer to the vgui controls baseclass Panel *
// destinationModule needs to be passed in to verify that the returned Panel * is from the same module
// it must be from the same module since Panel * vtbl may be different in each module
virtual Panel *GetPanel(VPANEL vguiPanel, const char *destinationModule) = 0;
virtual bool IsEnabled(VPANEL vguiPanel) = 0;
virtual void SetEnabled(VPANEL vguiPanel, bool state) = 0;
// Used by the drag/drop manager to always draw on top
virtual bool IsTopmostPopup( VPANEL vguiPanel) = 0;
virtual void SetTopmostPopup( VPANEL vguiPanel, bool state ) = 0;
virtual void SetMessageContextId( VPANEL vguiPanel, int nContextId ) = 0;
virtual int GetMessageContextId( VPANEL vguiPanel ) = 0;
virtual const DmxElementUnpackStructure_t *GetUnpackStructure( VPANEL vguiPanel ) const = 0;
virtual void OnUnserialized( VPANEL vguiPanel, CDmxElement *pElement ) = 0;
// sibling pins
virtual void SetSiblingPin(VPANEL vguiPanel, VPANEL newSibling, byte iMyCornerToPin = 0, byte iSiblingCornerToPinTo = 0 ) = 0;
};
} // namespace vgui
#endif // IPANEL_H

140
public/vgui/IScheme.h Normal file
View File

@@ -0,0 +1,140 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef ISCHEME_H
#define ISCHEME_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui/vgui.h"
#include "tier1/interface.h"
#include "tier1/utlsymbol.h"
class Color;
class KeyValues;
class ISchemeSurface;
namespace vgui
{
typedef unsigned long HScheme;
typedef unsigned long HTexture;
class IBorder;
class IImage;
//-----------------------------------------------------------------------------
// Purpose: Holds all panel rendering data
// This functionality is all wrapped in the Panel::GetScheme*() functions
//-----------------------------------------------------------------------------
class IScheme : public IBaseInterface
{
public:
#pragma pack(1)
struct fontalias_t
{
CUtlSymbol _fontName;
CUtlSymbol _trueFontName;
unsigned short _font : 15;
unsigned short m_bProportional : 1;
};
#pragma pack()
struct fontrange_t
{
CUtlSymbol _fontName;
int _min;
int _max;
};
// gets a string from the default settings section
virtual const char *GetResourceString(const char *stringName) = 0;
// returns a pointer to an existing border
virtual IBorder *GetBorder(const char *borderName) = 0;
// returns a pointer to an existing font
virtual HFont GetFont(const char *fontName, bool proportional = false) = 0;
// inverse font lookup
virtual char const *GetFontName( const HFont& font ) = 0;
// colors
virtual Color GetColor(const char *colorName, Color defaultColor) = 0;
// Gets at the scheme's short name
virtual const char *GetName() const = 0;
// Gets at the scheme's resource file name
virtual const char *GetFileName() const = 0;
};
class ISchemeManager: public IBaseInterface
{
public:
// loads a scheme from a file
// first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
virtual HScheme LoadSchemeFromFile(const char *fileName, const char *tag) = 0;
// reloads the scheme from the file - should only be used during development
virtual void ReloadSchemes() = 0;
// reloads scheme fonts
virtual void ReloadFonts( int inScreenTall = -1 ) = 0;
// returns a handle to the default (first loaded) scheme
virtual HScheme GetDefaultScheme() = 0;
// returns a handle to the scheme identified by "tag"
virtual HScheme GetScheme(const char *tag) = 0;
// returns a pointer to an image
virtual IImage *GetImage(const char *imageName, bool hardwareFiltered) = 0;
virtual HTexture GetImageID(const char *imageName, bool hardwareFiltered) = 0;
// This can only be called at certain times, like during paint()
// It will assert-fail if you call it at the wrong time...
// FIXME: This interface should go away!!! It's an icky back-door
// If you're using this interface, try instead to cache off the information
// in ApplySchemeSettings
virtual IScheme *GetIScheme( HScheme scheme ) = 0;
// unload all schemes
virtual void Shutdown( bool full = true ) = 0;
// gets the proportional coordinates for doing screen-size independant panel layouts
// use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
virtual int GetProportionalScaledValue( int normalizedValue) = 0;
virtual int GetProportionalNormalizedValue(int scaledValue) = 0;
// loads a scheme from a file
// first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
virtual HScheme LoadSchemeFromFileEx( VPANEL sizingPanel, const char *fileName, const char *tag) = 0;
// gets the proportional coordinates for doing screen-size independant panel layouts
// use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
virtual int GetProportionalScaledValueEx( HScheme scheme, int normalizedValue ) = 0;
virtual int GetProportionalNormalizedValueEx( HScheme scheme, int scaledValue ) = 0;
// Returns true if image evicted, false otherwise
virtual bool DeleteImage( const char *pImageName ) = 0;
virtual ISchemeSurface *GetSurface() = 0;
virtual void SetLanguage( const char *pLanguage ) = 0;
virtual const char *GetLanguage() = 0;
};
} // namespace vgui
#endif // ISCHEME_H

391
public/vgui/ISurface.h Normal file
View File

@@ -0,0 +1,391 @@
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef ISURFACE_H
#define ISURFACE_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui/vgui.h"
#include "vgui/IHTML.h" // CreateHTML, PaintHTML
#include "tier1/interface.h"
#include "bitmap/imageformat.h"
#include "appframework/iappsystem.h"
#include "mathlib/vector2d.h" // must be before the namespace line
#include "vgui/ischemesurface.h"
#include "IVguiMatInfo.h"
#ifdef PlaySound
#undef PlaySound
#endif
#define MENUROLLOVERSOUND "UI/menu_click04.wav"
#define MENUROLLOVERSOUNDSMALL "UI/buttonrollover.wav"
#define MENUCLOSESOUND "UI/menu_back.wav"
#define MENUACCEPTSOUND "UI/menu_accept.wav"
#define MENUOPTIONSOUND "UI/buttonclick_L4D.wav"
#define MENUBINDSOUND "UI/buttonclick.wav"
class Color;
namespace vgui
{
class IImage;
class Image;
class Point;
typedef FontHandle_t HFont;
typedef FontVertex_t Vertex_t;
struct IntRect
{
int x0;
int y0;
int x1;
int y1;
};
struct DrawTexturedRectParms_t
{
DrawTexturedRectParms_t()
{
s0 = t0 = 0;
s1 = t1 = 1.0f;
alpha_ul = alpha_ur = alpha_lr = alpha_ll = 255;
angle = 0;
}
int x0;
int y0;
int x1;
int y1;
float s0;
float t0;
float s1;
float t1;
unsigned char alpha_ul;
unsigned char alpha_ur;
unsigned char alpha_lr;
unsigned char alpha_ll;
float angle;
};
//-----------------------------------------------------------------------------
// Purpose: Wraps contextless windows system functions
//-----------------------------------------------------------------------------
class ISurface : public IAppSystem
{
public:
// call to Shutdown surface; surface can no longer be used after this is called
virtual void Shutdown() = 0;
// frame
virtual void RunFrame() = 0;
// hierarchy root
virtual VPANEL GetEmbeddedPanel() = 0;
virtual void SetEmbeddedPanel( VPANEL pPanel ) = 0;
// drawing context
virtual void PushMakeCurrent(VPANEL panel, bool useInsets) = 0;
virtual void PopMakeCurrent(VPANEL panel) = 0;
// rendering functions
virtual void DrawSetColor(int r, int g, int b, int a) = 0;
virtual void DrawSetColor(Color col) = 0;
virtual void DrawFilledRect(int x0, int y0, int x1, int y1) = 0;
virtual void DrawFilledRectArray( IntRect *pRects, int numRects ) = 0;
virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1) = 0;
virtual void DrawLine(int x0, int y0, int x1, int y1) = 0;
virtual void DrawPolyLine(int *px, int *py, int numPoints) = 0;
virtual void DrawSetApparentDepth( float depth ) = 0;
virtual void DrawClearApparentDepth() = 0;
virtual void DrawSetTextFont(HFont font) = 0;
virtual void DrawSetTextColor(int r, int g, int b, int a) = 0;
virtual void DrawSetTextColor(Color col) = 0;
virtual void DrawSetTextPos(int x, int y) = 0;
virtual void DrawGetTextPos(int& x,int& y) = 0;
virtual void DrawPrintText(const wchar_t *text, int textLen, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void DrawUnicodeChar(wchar_t wch, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void DrawFlushText() = 0; // flushes any buffered text (for rendering optimizations)
virtual IHTML *CreateHTMLWindow(vgui::IHTMLEvents *events,VPANEL context)=0;
virtual void PaintHTMLWindow(vgui::IHTML *htmlwin) =0;
virtual void DeleteHTMLWindow(IHTML *htmlwin)=0;
enum ETextureFormat
{
eTextureFormat_RGBA,
eTextureFormat_BGRA,
eTextureFormat_BGRA_Opaque, // bgra format but alpha is always 255, CEF does this, we can use this fact for better perf on win32 gdi
};
virtual int DrawGetTextureId( char const *filename ) = 0;
virtual bool DrawGetTextureFile( int id, char *filename, int maxlen ) = 0;
virtual void DrawSetTextureFile( int id, const char *filename, int hardwareFilter, bool forceReload ) = 0;
virtual void DrawSetTextureRGBA( int id, const unsigned char *rgba, int wide, int tall ) = 0 ;
virtual void DrawSetTexture(int id) = 0;
virtual bool DeleteTextureByID(int id) = 0;
#if defined( _X360 )
//
// Local gamerpic
//
// Get the texture id for the local gamerpic.
virtual int GetLocalGamerpicTextureID( void ) = 0;
// Update the local gamerpic texture. Use the given texture if a gamerpic cannot be loaded.
virtual bool SetLocalGamerpicTexture( DWORD userIndex, const char *pDefaultGamerpicFileName ) = 0;
// Set the current texture to be the local gamerpic.
// Returns false if the local gamerpic texture has not been set.
virtual bool DrawSetTextureLocalGamerpic( void ) = 0;
//
// Remote gamerpic
//
// Get the texture id for a remote gamerpic with the given xuid.
virtual int GetRemoteGamerpicTextureID( XUID xuid ) = 0;
// Update the remote gamerpic texture for the given xuid. Use the given texture if a gamerpic cannot be loaded.
virtual bool SetRemoteGamerpicTextureID( XUID xuid, const char *pDefaultGamerpicFileName ) = 0;
// Set the current texture to be the remote player's gamerpic.
// Returns false if the remote gamerpic texture has not been set for the given xuid.
virtual bool DrawSetTextureRemoteGamerpic( XUID xuid ) = 0;
#endif // _X360
virtual void DrawGetTextureSize(int id, int &wide, int &tall) = 0;
virtual void DrawTexturedRect(int x0, int y0, int x1, int y1) = 0;
virtual bool IsTextureIDValid(int id) = 0;
virtual int CreateNewTextureID( bool procedural = false ) = 0;
virtual void GetScreenSize(int &wide, int &tall) = 0;
virtual void SetAsTopMost(VPANEL panel, bool state) = 0;
virtual void BringToFront(VPANEL panel) = 0;
virtual void SetForegroundWindow (VPANEL panel) = 0;
virtual void SetPanelVisible(VPANEL panel, bool state) = 0;
virtual void SetMinimized(VPANEL panel, bool state) = 0;
virtual bool IsMinimized(VPANEL panel) = 0;
virtual void FlashWindow(VPANEL panel, bool state) = 0;
virtual void SetTitle(VPANEL panel, const wchar_t *title) = 0;
virtual void SetAsToolBar(VPANEL panel, bool state) = 0; // removes the window's task bar entry (for context menu's, etc.)
// windows stuff
virtual void CreatePopup(VPANEL panel, bool minimised, bool showTaskbarIcon = true, bool disabled = false, bool mouseInput = true , bool kbInput = true) = 0;
virtual void SwapBuffers(VPANEL panel) = 0;
virtual void Invalidate(VPANEL panel) = 0;
virtual void SetCursor(HCursor cursor) = 0;
virtual bool IsCursorVisible() = 0;
virtual void ApplyChanges() = 0;
virtual bool IsWithin(int x, int y) = 0;
virtual bool HasFocus() = 0;
// returns true if the surface supports minimize & maximize capabilities
enum SurfaceFeature_t
{
ANTIALIASED_FONTS = FONT_FEATURE_ANTIALIASED_FONTS,
DROPSHADOW_FONTS = FONT_FEATURE_DROPSHADOW_FONTS,
ESCAPE_KEY = 3,
OPENING_NEW_HTML_WINDOWS = 4,
FRAME_MINIMIZE_MAXIMIZE = 5,
OUTLINE_FONTS = FONT_FEATURE_OUTLINE_FONTS,
DIRECT_HWND_RENDER = 7,
};
virtual bool SupportsFeature( SurfaceFeature_t feature ) = 0;
// restricts what gets drawn to one panel and it's children
// currently only works in the game
virtual void RestrictPaintToSinglePanel(VPANEL panel, bool bForceAllowNonModalSurface = false) = 0;
// these two functions obselete, use IInput::SetAppModalSurface() instead
virtual void SetModalPanel(VPANEL ) = 0;
virtual VPANEL GetModalPanel() = 0;
virtual void UnlockCursor() = 0;
virtual void LockCursor() = 0;
virtual void SetTranslateExtendedKeys(bool state) = 0;
virtual VPANEL GetTopmostPopup() = 0;
// engine-only focus handling (replacing WM_FOCUS windows handling)
virtual void SetTopLevelFocus(VPANEL panel) = 0;
// fonts
// creates an empty handle to a vgui font. windows fonts can be add to this via SetFontGlyphSet().
virtual HFont CreateFont() = 0;
virtual bool SetFontGlyphSet(HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags, int nRangeMin = 0, int nRangeMax = 0) = 0;
// adds a custom font file (only supports true type font files (.ttf) for now)
virtual bool AddCustomFontFile(const char *fontFileName) = 0;
// returns the details about the font
virtual int GetFontTall(HFont font) = 0;
virtual int GetFontAscent(HFont font, wchar_t wch) = 0;
virtual bool IsFontAdditive(HFont font) = 0;
virtual void GetCharABCwide(HFont font, int ch, int &a, int &b, int &c) = 0;
virtual int GetCharacterWidth(HFont font, int ch) = 0;
virtual void GetTextSize(HFont font, const wchar_t *text, int &wide, int &tall) = 0;
// notify icons?!?
virtual VPANEL GetNotifyPanel() = 0;
virtual void SetNotifyIcon(VPANEL context, HTexture icon, VPANEL panelToReceiveMessages, const char *text) = 0;
// plays a sound
virtual void PlaySound(const char *fileName) = 0;
//!! these functions should not be accessed directly, but only through other vgui items
//!! need to move these to seperate interface
virtual int GetPopupCount() = 0;
virtual VPANEL GetPopup(int index) = 0;
virtual bool ShouldPaintChildPanel(VPANEL childPanel) = 0;
virtual bool RecreateContext(VPANEL panel) = 0;
virtual void AddPanel(VPANEL panel) = 0;
virtual void ReleasePanel(VPANEL panel) = 0;
virtual void MovePopupToFront(VPANEL panel) = 0;
virtual void MovePopupToBack(VPANEL panel) = 0;
virtual void SolveTraverse(VPANEL panel, bool forceApplySchemeSettings = false) = 0;
virtual void PaintTraverse(VPANEL panel) = 0;
virtual void EnableMouseCapture(VPANEL panel, bool state) = 0;
// returns the size of the workspace
virtual void GetWorkspaceBounds(int &x, int &y, int &wide, int &tall) = 0;
// gets the absolute coordinates of the screen (in windows space)
virtual void GetAbsoluteWindowBounds(int &x, int &y, int &wide, int &tall) = 0;
// gets the base resolution used in proportional mode
virtual void GetProportionalBase( int &width, int &height ) = 0;
virtual void CalculateMouseVisible() = 0;
virtual bool NeedKBInput() = 0;
virtual bool HasCursorPosFunctions() = 0;
virtual void SurfaceGetCursorPos(int &x, int &y) = 0;
virtual void SurfaceSetCursorPos(int x, int y) = 0;
// SRC only functions!!!
virtual void DrawTexturedLine( const Vertex_t &a, const Vertex_t &b ) = 0;
virtual void DrawOutlinedCircle(int x, int y, int radius, int segments) = 0;
virtual void DrawTexturedPolyLine( const Vertex_t *p,int n ) = 0; // (Note: this connects the first and last points).
virtual void DrawTexturedSubRect( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1 ) = 0;
virtual void DrawTexturedPolygon(int n, Vertex_t *pVertice, bool bClipVertices = true ) = 0;
virtual const wchar_t *GetTitle(VPANEL panel) = 0;
virtual bool IsCursorLocked( void ) const = 0;
virtual void SetWorkspaceInsets( int left, int top, int right, int bottom ) = 0;
// squarish comic book word bubble with pointer, rect params specify the space inside the bubble
virtual void DrawWordBubble( int x0, int y0, int x1, int y1, int nBorderThickness, Color rgbaBackground, Color rgbaBorder,
bool bPointer = false, int nPointerX = 0, int nPointerY = 0, int nPointerBaseThickness = 16 ) = 0;
// Lower level char drawing code, call DrawGet then pass in info to DrawRender
virtual bool DrawGetUnicodeCharRenderInfo( wchar_t ch, FontCharRenderInfo& info ) = 0;
virtual void DrawRenderCharFromInfo( const FontCharRenderInfo& info ) = 0;
// global alpha setting functions
// affect all subsequent draw calls - shouldn't normally be used directly, only in Panel::PaintTraverse()
virtual void DrawSetAlphaMultiplier( float alpha /* [0..1] */ ) = 0;
virtual float DrawGetAlphaMultiplier() = 0;
// web browser
virtual void SetAllowHTMLJavaScript( bool state ) = 0;
// video mode changing
virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight ) = 0;
virtual vgui::HCursor CreateCursorFromFile( char const *curOrAniFile, char const *pPathID = 0 ) = 0;
// create IVguiMatInfo object ( IMaterial wrapper in VguiMatSurface, NULL in CWin32Surface )
virtual IVguiMatInfo *DrawGetTextureMatInfoFactory( int id ) = 0;
virtual void PaintTraverseEx(VPANEL panel, bool paintPopups = false ) = 0;
virtual float GetZPos() const = 0;
// From the Xbox
virtual void SetPanelForInput( VPANEL vpanel ) = 0;
virtual void DrawFilledRectFastFade( int x0, int y0, int x1, int y1, int fadeStartPt, int fadeEndPt, unsigned int alpha0, unsigned int alpha1, bool bHorizontal ) = 0;
virtual void DrawFilledRectFade( int x0, int y0, int x1, int y1, unsigned int alpha0, unsigned int alpha1, bool bHorizontal ) = 0;
virtual void DrawSetTextureRGBAEx(int id, const unsigned char *rgba, int wide, int tall, ImageFormat imageFormat ) = 0;
virtual void DrawSetTextScale(float sx, float sy) = 0;
virtual bool SetBitmapFontGlyphSet(HFont font, const char *windowsFontName, float scalex, float scaley, int flags) = 0;
// adds a bitmap font file
virtual bool AddBitmapFontFile(const char *fontFileName) = 0;
// sets a symbol for the bitmap font
virtual void SetBitmapFontName( const char *pName, const char *pFontFilename ) = 0;
// gets the bitmap font filename
virtual const char *GetBitmapFontName( const char *pName ) = 0;
virtual void ClearTemporaryFontCache( void ) = 0;
virtual IImage *GetIconImageForFullPath( char const *pFullPath ) = 0;
virtual void DrawUnicodeString( const wchar_t *pwString, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void PrecacheFontCharacters(HFont font, wchar_t *pCharacters) = 0;
virtual const char *GetFontName( HFont font ) = 0;
virtual bool ForceScreenSizeOverride( bool bState, int wide, int tall ) = 0;
// LocalToScreen, ParentLocalToScreen fixups for explicit PaintTraverse calls on Panels not at 0, 0 position
virtual bool ForceScreenPosOffset( bool bState, int x, int y ) = 0;
virtual void OffsetAbsPos( int &x, int &y ) = 0;
virtual void SetAbsPosForContext( int id, int x, int y ) = 0;
virtual void GetAbsPosForContext( int id, int &x, int& y ) = 0;
// Causes fonts to get reloaded, etc.
virtual void ResetFontCaches() = 0;
virtual bool IsScreenSizeOverrideActive( void ) = 0;
virtual bool IsScreenPosOverrideActive( void ) = 0;
virtual void DestroyTextureID( int id ) = 0;
virtual int GetTextureNumFrames( int id ) = 0;
virtual void DrawSetTextureFrame( int id, int nFrame, unsigned int *pFrameCache ) = 0;
virtual void GetClipRect( int &x0, int &y0, int &x1, int &y1 ) = 0;
virtual void SetClipRect( int x0, int y0, int x1, int y1 ) = 0;
virtual void DrawTexturedRectEx( DrawTexturedRectParms_t *pDrawParms ) = 0;
virtual void GetKernedCharWidth( HFont font, wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC ) = 0;
virtual void DrawUpdateRegionTextureRGBA( int nTextureID, int x, int y, const unsigned char *pchData, int wide, int tall, ImageFormat imageFormat ) = 0;
virtual bool BHTMLWindowNeedsPaint(IHTML *htmlwin) = 0 ;
virtual void DrawSetTextureRGBALinear( int id, const unsigned char *rgba, int wide, int tall ) = 0 ;
virtual const char *GetWebkitHTMLUserAgentString() = 0;
virtual void *Deprecated_AccessChromeHTMLController() = 0;
};
}
#endif // ISURFACE_H

375
public/vgui/ISurfaceV30.h Normal file
View File

@@ -0,0 +1,375 @@
//========= Copyright <20> 1996-2003, Valve LLC, All rights reserved. ============
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef ISURFACE_V30_H
#define ISURFACE_V30_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/VGUI.h>
#include <vgui/IHTML.h> // CreateHTML, PaintHTML
#include "interface.h"
#include "IVguiMatInfo.h"
#include "appframework/IAppSystem.h"
#include "bitmap/ImageFormat.h"
#include "Vector2D.h" // must be before the namespace line
#ifdef CreateFont
#undef CreateFont
#endif
#ifdef PlaySound
#undef PlaySound
#endif
class Color;
namespace vgui
{
class Image;
class Point;
// handles
typedef unsigned long HCursor;
typedef unsigned long HTexture;
typedef unsigned long HFont;
}
namespace SurfaceV30
{
//SRC only defines
struct Vertex_t
{
Vertex_t() {}
Vertex_t( const Vector2D &pos, const Vector2D &coord = Vector2D( 0, 0 ) )
{
m_Position = pos;
m_TexCoord = coord;
}
void Init( const Vector2D &pos, const Vector2D &coord = Vector2D( 0, 0 ) )
{
m_Position = pos;
m_TexCoord = coord;
}
Vector2D m_Position;
Vector2D m_TexCoord;
};
enum FontDrawType_t
{
// Use the "additive" value from the scheme file
FONT_DRAW_DEFAULT = 0,
// Overrides
FONT_DRAW_NONADDITIVE,
FONT_DRAW_ADDITIVE,
FONT_DRAW_TYPE_COUNT = 2,
};
// Refactor these two
struct CharRenderInfo
{
// In:
FontDrawType_t drawType;
wchar_t ch;
// Out
bool valid;
// In/Out (true by default)
bool shouldclip;
// Text pos
int x, y;
// Top left and bottom right
Vertex_t verts[ 2 ];
int textureId;
int abcA;
int abcB;
int abcC;
int fontTall;
vgui::HFont currentFont;
};
struct IntRect
{
int x0;
int y0;
int x1;
int y1;
};
//-----------------------------------------------------------------------------
// Purpose: Wraps contextless windows system functions
//-----------------------------------------------------------------------------
class ISurface : public IAppSystem
{
public:
// call to Shutdown surface; surface can no longer be used after this is called
virtual void Shutdown() = 0;
// frame
virtual void RunFrame() = 0;
// hierarchy root
virtual vgui::VPANEL GetEmbeddedPanel() = 0;
virtual void SetEmbeddedPanel( vgui::VPANEL pPanel ) = 0;
// drawing context
virtual void PushMakeCurrent(vgui::VPANEL panel, bool useInsets) = 0;
virtual void PopMakeCurrent(vgui::VPANEL panel) = 0;
// rendering functions
virtual void DrawSetColor(int r, int g, int b, int a) = 0;
virtual void DrawSetColor(Color col) = 0;
virtual void DrawFilledRect(int x0, int y0, int x1, int y1) = 0;
virtual void DrawFilledRectArray( IntRect *pRects, int numRects ) = 0;
virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1) = 0;
virtual void DrawLine(int x0, int y0, int x1, int y1) = 0;
virtual void DrawPolyLine(int *px, int *py, int numPoints) = 0;
virtual void DrawSetTextFont(vgui::HFont font) = 0;
virtual void DrawSetTextColor(int r, int g, int b, int a) = 0;
virtual void DrawSetTextColor(Color col) = 0;
virtual void DrawSetTextPos(int x, int y) = 0;
virtual void DrawGetTextPos(int& x,int& y) = 0;
virtual void DrawPrintText(const wchar_t *text, int textLen, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void DrawUnicodeChar(wchar_t wch, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void DrawFlushText() = 0; // flushes any buffered text (for rendering optimizations)
virtual vgui::IHTML *CreateHTMLWindow(vgui::IHTMLEvents *events,vgui::VPANEL context)=0;
virtual void PaintHTMLWindow(vgui::IHTML *htmlwin) =0;
virtual void DeleteHTMLWindow(vgui::IHTML *htmlwin)=0;
virtual int DrawGetTextureId( char const *filename ) = 0;
virtual bool DrawGetTextureFile(int id, char *filename, int maxlen ) = 0;
virtual void DrawSetTextureFile(int id, const char *filename, int hardwareFilter, bool forceReload) = 0;
virtual void DrawSetTextureRGBA(int id, const unsigned char *rgba, int wide, int tall, int hardwareFilter, bool forceReload)=0;
virtual void DrawSetTexture(int id) = 0;
virtual void DrawGetTextureSize(int id, int &wide, int &tall) = 0;
virtual void DrawTexturedRect(int x0, int y0, int x1, int y1) = 0;
virtual bool IsTextureIDValid(int id) = 0;
virtual int CreateNewTextureID( bool procedural = false ) = 0;
#ifdef _XBOX
virtual void DestroyTextureID( int id ) = 0;
virtual bool IsCachedForRendering( int id, bool bSyncWait ) = 0;
virtual void CopyFrontBufferToBackBuffer() = 0;
virtual void UncacheUnusedMaterials() = 0;
#endif
virtual void GetScreenSize(int &wide, int &tall) = 0;
virtual void SetAsTopMost(vgui::VPANEL panel, bool state) = 0;
virtual void BringToFront(vgui::VPANEL panel) = 0;
virtual void SetForegroundWindow (vgui::VPANEL panel) = 0;
virtual void SetPanelVisible(vgui::VPANEL panel, bool state) = 0;
virtual void SetMinimized(vgui::VPANEL panel, bool state) = 0;
virtual bool IsMinimized(vgui::VPANEL panel) = 0;
virtual void FlashWindow(vgui::VPANEL panel, bool state) = 0;
virtual void SetTitle(vgui::VPANEL panel, const wchar_t *title) = 0;
virtual void SetAsToolBar(vgui::VPANEL panel, bool state) = 0; // removes the window's task bar entry (for context menu's, etc.)
// windows stuff
virtual void CreatePopup(vgui::VPANEL panel, bool minimised, bool showTaskbarIcon = true, bool disabled = false, bool mouseInput = true , bool kbInput = true) = 0;
virtual void SwapBuffers(vgui::VPANEL panel) = 0;
virtual void Invalidate(vgui::VPANEL panel) = 0;
virtual void SetCursor(vgui::HCursor cursor) = 0;
virtual bool IsCursorVisible() = 0;
virtual void ApplyChanges() = 0;
virtual bool IsWithin(int x, int y) = 0;
virtual bool HasFocus() = 0;
// returns true if the surface supports minimize & maximize capabilities
enum SurfaceFeature_e
{
ANTIALIASED_FONTS = 1,
DROPSHADOW_FONTS = 2,
ESCAPE_KEY = 3,
OPENING_NEW_HTML_WINDOWS = 4,
FRAME_MINIMIZE_MAXIMIZE = 5,
OUTLINE_FONTS = 6,
DIRECT_HWND_RENDER = 7,
};
virtual bool SupportsFeature(SurfaceFeature_e feature) = 0;
// restricts what gets drawn to one panel and it's children
// currently only works in the game
virtual void RestrictPaintToSinglePanel(vgui::VPANEL panel, bool bForceAllowNonModalSurface = false) = 0;
// these two functions obselete, use IInput::SetAppModalSurface() instead
virtual void SetModalPanel(vgui::VPANEL ) = 0;
virtual vgui::VPANEL GetModalPanel() = 0;
virtual void UnlockCursor() = 0;
virtual void LockCursor() = 0;
virtual void SetTranslateExtendedKeys(bool state) = 0;
virtual vgui::VPANEL GetTopmostPopup() = 0;
// engine-only focus handling (replacing WM_FOCUS windows handling)
virtual void SetTopLevelFocus(vgui::VPANEL panel) = 0;
// fonts
// creates an empty handle to a vgui font. windows fonts can be add to this via SetFontGlyphSet().
virtual vgui::HFont CreateFont() = 0;
// adds to the font
enum EFontFlags
{
FONTFLAG_NONE,
FONTFLAG_ITALIC = 0x001,
FONTFLAG_UNDERLINE = 0x002,
FONTFLAG_STRIKEOUT = 0x004,
FONTFLAG_SYMBOL = 0x008,
FONTFLAG_ANTIALIAS = 0x010,
FONTFLAG_GAUSSIANBLUR = 0x020,
FONTFLAG_ROTARY = 0x040,
FONTFLAG_DROPSHADOW = 0x080,
FONTFLAG_ADDITIVE = 0x100,
FONTFLAG_OUTLINE = 0x200,
FONTFLAG_CUSTOM = 0x400, // custom generated font - never fall back to asian compatibility mode
FONTFLAG_BITMAP = 0x800, // compiled bitmap font - no fallbacks
};
virtual bool SetFontGlyphSet(vgui::HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags) = 0;
// adds a custom font file (only supports true type font files (.ttf) for now)
virtual bool AddCustomFontFile(const char *fontFileName) = 0;
// returns the details about the font
virtual int GetFontTall(vgui::HFont font) = 0;
virtual int GetFontAscent(vgui::HFont font, wchar_t wch) = 0;
virtual bool IsFontAdditive(vgui::HFont font) = 0;
virtual void GetCharABCwide(vgui::HFont font, int ch, int &a, int &b, int &c) = 0;
virtual int GetCharacterWidth(vgui::HFont font, int ch) = 0;
virtual void GetTextSize(vgui::HFont font, const wchar_t *text, int &wide, int &tall) = 0;
// notify icons?!?
virtual vgui::VPANEL GetNotifyPanel() = 0;
virtual void SetNotifyIcon(vgui::VPANEL context, vgui::HTexture icon, vgui::VPANEL panelToReceiveMessages, const char *text) = 0;
// plays a sound
virtual void PlaySound(const char *fileName) = 0;
//!! these functions should not be accessed directly, but only through other vgui items
//!! need to move these to seperate interface
virtual int GetPopupCount() = 0;
virtual vgui::VPANEL GetPopup(int index) = 0;
virtual bool ShouldPaintChildPanel(vgui::VPANEL childPanel) = 0;
virtual bool RecreateContext(vgui::VPANEL panel) = 0;
virtual void AddPanel(vgui::VPANEL panel) = 0;
virtual void ReleasePanel(vgui::VPANEL panel) = 0;
virtual void MovePopupToFront(vgui::VPANEL panel) = 0;
virtual void MovePopupToBack(vgui::VPANEL panel) = 0;
virtual void SolveTraverse(vgui::VPANEL panel, bool forceApplySchemeSettings = false) = 0;
virtual void PaintTraverse(vgui::VPANEL panel) = 0;
virtual void EnableMouseCapture(vgui::VPANEL panel, bool state) = 0;
// returns the size of the workspace
virtual void GetWorkspaceBounds(int &x, int &y, int &wide, int &tall) = 0;
// gets the absolute coordinates of the screen (in windows space)
virtual void GetAbsoluteWindowBounds(int &x, int &y, int &wide, int &tall) = 0;
// gets the base resolution used in proportional mode
virtual void GetProportionalBase( int &width, int &height ) = 0;
virtual void CalculateMouseVisible() = 0;
virtual bool NeedKBInput() = 0;
virtual bool HasCursorPosFunctions() = 0;
virtual void SurfaceGetCursorPos(int &x, int &y) = 0;
virtual void SurfaceSetCursorPos(int x, int y) = 0;
// SRC only functions!!!
virtual void DrawTexturedLine( const Vertex_t &a, const Vertex_t &b ) = 0;
virtual void DrawOutlinedCircle(int x, int y, int radius, int segments) = 0;
virtual void DrawTexturedPolyLine( const Vertex_t *p,int n ) = 0; // (Note: this connects the first and last points).
virtual void DrawTexturedSubRect( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1 ) = 0;
virtual void DrawTexturedPolygon(int n, Vertex_t *pVertices) = 0;
virtual const wchar_t *GetTitle(vgui::VPANEL panel) = 0;
virtual bool IsCursorLocked( void ) const = 0;
virtual void SetWorkspaceInsets( int left, int top, int right, int bottom ) = 0;
// Lower level char drawing code, call DrawGet then pass in info to DrawRender
virtual bool DrawGetUnicodeCharRenderInfo( wchar_t ch, CharRenderInfo& info ) = 0;
virtual void DrawRenderCharFromInfo( const CharRenderInfo& info ) = 0;
// global alpha setting functions
// affect all subsequent draw calls - shouldn't normally be used directly, only in Panel::PaintTraverse()
virtual void DrawSetAlphaMultiplier( float alpha /* [0..1] */ ) = 0;
virtual float DrawGetAlphaMultiplier() = 0;
// web browser
virtual void SetAllowHTMLJavaScript( bool state ) = 0;
// video mode changing
virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight ) = 0;
#if !defined( _XBOX )
virtual vgui::HCursor CreateCursorFromFile( char const *curOrAniFile, char const *pPathID = 0 ) = 0;
#endif
// create IVguiMatInfo object ( IMaterial wrapper in VguiMatSurface, NULL in CWin32Surface )
virtual IVguiMatInfo *DrawGetTextureMatInfoFactory( int id ) = 0;
virtual void PaintTraverseEx(vgui::VPANEL panel, bool paintPopups = false ) = 0;
virtual float GetZPos() const = 0;
// From the Xbox
virtual void SetPanelForInput( vgui::VPANEL vpanel ) = 0;
virtual void DrawFilledRectFade( int x0, int y0, int x1, int y1, unsigned int alpha0, unsigned int alpha1, bool bHorizontal ) = 0;
virtual void DrawSetTextureRGBAEx(int id, const unsigned char *rgba, int wide, int tall, ImageFormat imageFormat ) = 0;
virtual void DrawSetTextScale(float sx, float sy) = 0;
virtual bool SetBitmapFontGlyphSet(vgui::HFont font, const char *windowsFontName, float scalex, float scaley, int flags) = 0;
// adds a bitmap font file
virtual bool AddBitmapFontFile(const char *fontFileName) = 0;
// sets a symbol for the bitmap font
virtual void SetBitmapFontName( const char *pName, const char *pFontFilename ) = 0;
// gets the bitmap font filename
virtual const char *GetBitmapFontName( const char *pName ) = 0;
virtual vgui::IImage *GetIconImageForFullPath( char const *pFullPath ) = 0;
virtual void DrawUnicodeString( const wchar_t *pwString, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
};
} // end namespace
//-----------------------------------------------------------------------------
// FIXME: This works around using scoped interfaces w/ EXPOSE_SINGLE_INTERFACE
//-----------------------------------------------------------------------------
class ISurfaceV30 : public SurfaceV30::ISurface
{
public:
};
#define VGUI_SURFACE_INTERFACE_VERSION_30 "VGUI_Surface030"
#endif // ISURFACE_V30_H

132
public/vgui/ISystem.h Normal file
View File

@@ -0,0 +1,132 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef ISYSTEM_H
#define ISYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/interface.h"
#include "tier1/keyvalues.h"
#include <vgui/vgui.h>
#include <vgui/KeyCode.h>
#ifdef PlaySound
#undef PlaySound
#endif
namespace vgui
{
//-----------------------------------------------------------------------------
// Purpose: Wraps contextless windows system functions
//-----------------------------------------------------------------------------
class ISystem : public IBaseInterface
{
public:
// call when done with ISystem to clean up any memory allocation
virtual void Shutdown() = 0;
// called every frame
virtual void RunFrame() = 0;
// use this with the "open" command to launch web browsers/explorer windows, eg. ShellExecute("open", "www.valvesoftware.com")
virtual void ShellExecute(const char *command, const char *file) = 0;
// returns the time at the start of the frame, in seconds
virtual double GetFrameTime() = 0;
// returns the current time, in seconds
virtual double GetCurrentTime() = 0;
// returns the current time, in milliseconds
virtual long GetTimeMillis() = 0;
// clipboard access
virtual int GetClipboardTextCount() = 0;
virtual void SetClipboardText(const char *text, int textLen) = 0;
virtual void SetClipboardText(const wchar_t *text, int textLen) = 0;
virtual int GetClipboardText(int offset, char *buf, int bufLen) = 0;
virtual int GetClipboardText(int offset, wchar_t *buf, int bufLen) = 0;
// windows registry
virtual bool SetRegistryString(const char *key, const char *value) = 0;
virtual bool GetRegistryString(const char *key, char *value, int valueLen) = 0;
virtual bool SetRegistryInteger(const char *key, int value) = 0;
virtual bool GetRegistryInteger(const char *key, int &value) = 0;
// user config
virtual KeyValues *GetUserConfigFileData(const char *dialogName, int dialogID) = 0;
// sets the name of the config file to save/restore from. Settings are loaded immediately.
virtual void SetUserConfigFile(const char *fileName, const char *pathName) = 0;
// saves all the current settings to the user config file
virtual void SaveUserConfigFile() = 0;
// sets the watch on global computer use
// returns true if supported
virtual bool SetWatchForComputerUse(bool state) = 0;
// returns the time, in seconds, since the last computer use.
virtual double GetTimeSinceLastUse() = 0;
// Get a string containing the available drives
// If the function succeeds, the return value is the length, in characters,
// of the strings copied to the buffer,
// not including the terminating null character.
virtual int GetAvailableDrives(char *buf, int bufLen) = 0;
// exe command line options accessors
// returns whether or not the parameter was on the command line
virtual bool CommandLineParamExists(const char *paramName) = 0;
// returns the full command line, including the exe name
virtual const char *GetFullCommandLine() = 0;
// Convert a windows virtual key code to a VGUI key code.
virtual KeyCode KeyCode_VirtualKeyToVGUI( int keyCode ) = 0;
// returns the current local time and date
// fills in every field that a pointer is given to it for
virtual bool GetCurrentTimeAndDate(int *year, int *month, int *dayOfWeek, int *day, int *hour, int *minute, int *second) = 0;
// returns the amount of available disk space, in bytes, on the drive
// path can be any path, drive letter is stripped out
virtual double GetFreeDiskSpace(const char *path) = 0;
// shortcut (.lnk) modification functions
virtual bool CreateShortcut(const char *linkFileName, const char *targetPath, const char *arguments, const char *workingDirectory, const char *iconFile) = 0;
virtual bool GetShortcutTarget(const char *linkFileName, char *targetPath, char *arguments, int destBufferSizes) = 0;
virtual bool ModifyShortcutTarget(const char *linkFileName, const char *targetPath, const char *arguments, const char *workingDirectory) = 0;
// gets the string following a command line param
//!! move this function up on changing interface version number
virtual bool GetCommandLineParamValue(const char *paramName, char *value, int valueBufferSize) = 0;
// recursively deletes a registry key and all it's subkeys
//!! move this function next to other registry function on changing interface version number
virtual bool DeleteRegistryKey(const char *keyName) = 0;
virtual const char *GetDesktopFolderPath() = 0;
// use this with the "open" command to launch web browsers/explorer windows, eg. ShellExecute("open", "www.valvesoftware.com")
virtual void ShellExecuteEx( const char *command, const char *file, const char *pParams ) = 0;
// Copy a portion of the application client area to the clipboard
// (x1,y1) specifies the top-left corner of the client rect to copy
// (x2,y2) specifies the bottom-right corner of the client rect to copy
// Requires: x2 > x1 && y2 > y1
// Dimensions of the copied rectangle are (x2 - x1) x (y2 - y1)
// Pixel at (x1,y1) is copied, pixels at column x2 and row y2 are *not* copied
virtual void SetClipboardImage( void *pWnd, int x1, int y1, int x2, int y2 ) = 0;
};
}
#endif // ISYSTEM_H

113
public/vgui/IVGui.h Normal file
View File

@@ -0,0 +1,113 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef IVGUI_H
#define IVGUI_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/interface.h"
#include <vgui/vgui.h>
#include "appframework/iappsystem.h"
class KeyValues;
namespace vgui
{
// safe handle to a panel - can be converted to and from a VPANEL
typedef unsigned long HPanel;
typedef int HContext;
enum
{
DEFAULT_VGUI_CONTEXT = ((vgui::HContext)~0)
};
// safe handle to a panel - can be converted to and from a VPANEL
typedef unsigned long HPanel;
class IMessageContextIdHandler
{
public:
virtual void SetMessageContextId( int id ) = 0;
};
//-----------------------------------------------------------------------------
// Purpose: Interface to core vgui components
//-----------------------------------------------------------------------------
class IVGui : public IAppSystem
{
public:
// activates vgui message pump
virtual void Start() = 0;
// signals vgui to Stop running
virtual void Stop() = 0;
// returns true if vgui is current active
virtual bool IsRunning() = 0;
// runs a single frame of vgui
virtual void RunFrame() = 0;
// broadcasts "ShutdownRequest" "id" message to all top-level panels in the app
virtual void ShutdownMessage(unsigned int shutdownID) = 0;
// panel allocation
virtual VPANEL AllocPanel() = 0;
virtual void FreePanel(VPANEL panel) = 0;
// debugging prints
virtual void DPrintf(PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void DPrintf2(PRINTF_FORMAT_STRING const char *format, ...) = 0;
virtual void SpewAllActivePanelNames() = 0;
// safe-pointer handle methods
virtual HPanel PanelToHandle(VPANEL panel) = 0;
virtual VPANEL HandleToPanel(HPanel index) = 0;
virtual void MarkPanelForDeletion(VPANEL panel) = 0;
// makes panel receive a 'Tick' message every frame (~50ms, depending on sleep times/framerate)
// panel is automatically removed from tick signal list when it's deleted
virtual void AddTickSignal(VPANEL panel, int intervalMilliseconds = 0 ) = 0;
virtual void RemoveTickSignal(VPANEL panel) = 0;
// message sending
virtual void PostMessage(VPANEL target, KeyValues *params, VPANEL from, float delaySeconds = 0.0f) = 0;
// Creates/ destroys vgui contexts, which contains information
// about which controls have mouse + key focus, for example.
virtual HContext CreateContext() = 0;
virtual void DestroyContext( HContext context ) = 0;
// Associates a particular panel with a vgui context
// Associating NULL is valid; it disconnects the panel from the context
virtual void AssociatePanelWithContext( HContext context, VPANEL pRoot ) = 0;
// Activates a particular context, use DEFAULT_VGUI_CONTEXT
// to get the one normally used by VGUI
virtual void ActivateContext( HContext context ) = 0;
// whether to sleep each frame or not, true = sleep
virtual void SetSleep( bool state) = 0;
// data accessor for above
virtual bool GetShouldVGuiControlSleep() = 0;
// Resets a particular context, use DEFAULT_VGUI_CONTEXT
// to get the one normally used by VGUI
virtual void ResetContext( HContext context ) = 0;
};
};
#endif // IVGUI_H

View File

@@ -0,0 +1,25 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IVGUIMATINFO_H
#define IVGUIMATINFO_H
#include "IVguiMatInfoVar.h"
// wrapper for IMaterial
class IVguiMatInfo
{
public:
// make sure to delete the returned object after use!
virtual IVguiMatInfoVar* FindVarFactory ( const char *varName, bool *found ) = 0;
virtual int GetNumAnimationFrames ( ) = 0;
// todo: if you need to add more IMaterial functions add them here
};
#endif //IVGUIMATINFO_H

View File

@@ -0,0 +1,22 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IVGUIMATINFOVAR_H
#define IVGUIMATINFOVAR_H
// wrapper for IMaterialVar
class IVguiMatInfoVar
{
public:
virtual int GetIntValue ( void ) const = 0;
virtual void SetIntValue ( int val ) = 0;
// todo: if you need to add more IMaterialVar functions add them here
};
#endif //IVGUIMATINFOVAR_H

24
public/vgui/KeyCode.h Normal file
View File

@@ -0,0 +1,24 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: this is a map for virtual key codes
// virtual key codes may exist outside this range for other languages
// NOTE: Button codes also contain mouse codes, but we won't worry about that
//
// $NoKeywords: $
//===========================================================================//
#ifndef KEYCODE_H
#define KEYCODE_H
#ifdef _WIN32
#pragma once
#endif
#include "inputsystem/ButtonCode.h"
namespace vgui
{
typedef ButtonCode_t KeyCode;
}
#endif // KEYCODE_H

23
public/vgui/MouseCode.h Normal file
View File

@@ -0,0 +1,23 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: names mouse button inputs
// NOTE: Button codes also contain key codes, but we won't worry about that
//
// $NoKeywords: $
//===========================================================================//
#ifndef MOUSECODE_H
#define MOUSECODE_H
#ifdef _WIN32
#pragma once
#endif
#include "inputsystem/ButtonCode.h"
namespace vgui
{
typedef ButtonCode_t MouseCode;
}
#endif // MOUSECODE_H

61
public/vgui/Point.h Normal file
View File

@@ -0,0 +1,61 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef POINT_H
#define POINT_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
namespace vgui
{
//-----------------------------------------------------------------------------
// Purpose: Basic handler for a Points in 2 dimensions
// This class is fully inline
//-----------------------------------------------------------------------------
class Point
{
public:
// constructors
Point()
{
SetPoint(0, 0);
}
Point(int x,int y)
{
SetPoint(x,y);
}
void SetPoint(int x1, int y1)
{
x=x1;
y=y1;
}
void GetPoint(int &x1, int &y1) const
{
x1 = x;
y1 = y;
}
bool operator == (Point &rhs) const
{
return (x == rhs.x && y == rhs.y);
}
private:
int x, y;
};
} // namespace vgui
#endif // POINT_H

54
public/vgui/ipainthtml.h Normal file
View File

@@ -0,0 +1,54 @@
//========= Copyright, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef IPAINTHTML_H
#define IPAINTHTML_H
class IPaintHTML
{
public:
enum EPaintTarget
{
ePaintBrowser,
ePaintPopup,
ePaintMAX
};
// returns the texture id used, pass in -1 to create a new texture
virtual int DrawSubTextureRGBA( EPaintTarget eTarget, int textureID, int x, int y, const unsigned char *pRGBA, int wide, int tall ) = 0;
virtual void DeleteTexture( EPaintTarget eTarget, int textureID ) = 0;
};
class IInputEventHTML
{
public:
enum EMouseButton
{
eButtonLeft,
eButtonMiddle,
eButtonRight
};
virtual bool ChromeHandleMouseClick( EMouseButton eButton, bool bUp, int nClickCount ) = 0;
virtual bool ChromeHandleMouseMove( int x, int y ) = 0;
virtual bool ChromeHandleMouseWheel( int delta ) = 0;
enum EKeyType
{
KeyDown,
KeyUp,
Char
};
enum EKeyModifier
{
AltDown = 1,
CrtlDown = 2,
ShiftDown = 4,
};
virtual bool ChromeHandleKeyEvent( EKeyType type, int key, int modifiers, bool bKeyUp ) = 0;
};
#endif // IPAINTHTML_H

View File

@@ -0,0 +1,81 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef ISCHEMESURFACE_H
#define ISCHEMESURFACE_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_surfacelib/ifontsurface.h"
#include "appframework/iappsystem.h"
class IMaterial;
//-----------------------------------------------------------------------------
// Purpose: Wraps functions that the scheme system needs access to.
//-----------------------------------------------------------------------------
abstract_class ISchemeSurface : public IAppSystem
{
public:
virtual InitReturnVal_t Init() = 0;
// creates an empty handle to a vgui font. windows fonts can be add to this via SetFontGlyphSet().
virtual FontHandle_t CreateFont() = 0;
virtual bool SetFontGlyphSet( FontHandle_t font, const char *windowsFontName, int tall, int weight,
int blur, int scanlines, int flags, int nRangeMin = 0, int nRangeMax = 0) = 0;
virtual const char *GetFontName( FontHandle_t font ) = 0;
virtual int GetFontTall( FontHandle_t font ) = 0;
virtual int GetCharacterWidth( FontHandle_t font, int ch ) = 0;
virtual void GetCharABCwide( FontHandle_t font, int ch, int &a, int &b, int &c ) = 0;
// Custom font support
virtual bool AddCustomFontFile(const char *fontFileName) = 0;
// Bitmap Font support
virtual bool AddBitmapFontFile(const char *fontFileName) = 0;
virtual void SetBitmapFontName( const char *pName, const char *pFontFilename ) = 0;
virtual const char *GetBitmapFontName( const char *pName ) = 0;
virtual bool SetBitmapFontGlyphSet( FontHandle_t font, const char *windowsFontName, float scalex,
float scaley, int flags) = 0;
virtual bool SupportsFontFeature( FontFeature_t feature ) = 0;
virtual void GetScreenSize(int &wide, int &tall) = 0;
// Gets the base resolution used in proportional mode
virtual void GetProportionalBase( int &width, int &height ) = 0;
// Functions used by game ui editor.
virtual IMaterial *GetTextureForChar( FontCharRenderInfo &info, float **texCoords )
{
Assert(0);
return NULL;
}
// Returns an array of the 4 render positions for the character.
virtual bool GetUnicodeCharRenderPositions( FontCharRenderInfo& info, Vector2D *pPositions )
{
Assert(0);
return false;
}
virtual IMaterial *GetMaterial( int textureId )
{
Assert(0);
return NULL;
}
virtual void SetLanguage( const char *pLanguage ) = 0;
virtual const char *GetLanguage() = 0;
virtual void PrecacheFontCharacters( FontHandle_t font, wchar_t *pCharacters ) = 0;
};
#endif // ISCHEMESURFACE_H

47
public/vgui/keyrepeat.h Normal file
View File

@@ -0,0 +1,47 @@
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef KEYREPEAT_H
#define KEYREPEAT_H
#ifdef _WIN32
#pragma once
#endif
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();
void Reset();
void KeyDown( vgui::KeyCode code );
void KeyUp( vgui::KeyCode code );
vgui::KeyCode KeyRepeated();
void SetKeyRepeatTime( vgui::KeyCode code, float flRepeat );
private:
bool m_bAliasDown[MAX_JOYSTICKS][FM_NUM_KEYREPEAT_ALIASES];
float m_flRepeatTimes[FM_NUM_KEYREPEAT_ALIASES];
float m_flNextKeyRepeat[MAX_JOYSTICKS];
bool m_bHaveKeyDown;
};
} // namespace vgui
#endif // KEYREPEAT_H

64
public/vgui/vgui.h Normal file
View File

@@ -0,0 +1,64 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Basic header for using vgui
//
// $NoKeywords: $
//=============================================================================//
#ifndef VGUI_H
#define VGUI_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/platform.h"
#pragma warning( disable: 4786 ) // disables 'identifier truncated in browser information' warning
#pragma warning( disable: 4355 ) // disables 'this' : used in base member initializer list
#pragma warning( disable: 4097 ) // warning C4097: typedef-name 'BaseClass' used as synonym for class-name
#pragma warning( disable: 4514 ) // warning C4514: 'Color::Color' : unreferenced inline function has been removed
#pragma warning( disable: 4100 ) // warning C4100: 'code' : unreferenced formal parameter
#pragma warning( disable: 4127 ) // warning C4127: conditional expression is constant
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
#ifndef _WCHAR_T_DEFINED
// DAL - wchar_t is a built in define in gcc 3.2 with a size of 4 bytes
#if !defined( __x86_64__ ) && !defined( __WCHAR_TYPE__ )
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif
#endif
// do this in GOLDSRC only!!!
//#define Assert assert
namespace vgui
{
// handle to an internal vgui panel
// this is the only handle to a panel that is valid across dll boundaries
typedef uintp VPANEL;
// handles to vgui objects
// NULL values signify an invalid value
typedef unsigned long HScheme;
typedef unsigned long HTexture;
typedef unsigned long HCursor;
typedef unsigned long HPanel;
const HPanel INVALID_PANEL = 0xffffffff;
typedef unsigned long HFont;
const HFont INVALID_FONT = 0; // the value of an invalid font handle
const float STEREO_NOOP = 1.0f;
const float STEREO_INVALID = 0.0f;
}
#include "tier1/strtools.h"
#endif // VGUI_H