SA-MP/saco/d3d9/common/DXUTgui.h

164 lines
4.8 KiB
C++

//--------------------------------------------------------------------------------------
// File: DXUTgui.h
//
// Desc:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#ifndef DXUT_GUI_H
#define DXUT_GUI_H
//--------------------------------------------------------------------------------------
// Enums for pre-defined control types
//--------------------------------------------------------------------------------------
enum DXUT_CONTROL_TYPE
{
DXUT_CONTROL_BUTTON,
DXUT_CONTROL_STATIC,
DXUT_CONTROL_CHECKBOX,
DXUT_CONTROL_RADIOBUTTON,
DXUT_CONTROL_COMBOBOX,
DXUT_CONTROL_SLIDER,
DXUT_CONTROL_EDITBOX,
DXUT_CONTROL_IMEEDITBOX,
DXUT_CONTROL_LISTBOX,
DXUT_CONTROL_SCROLLBAR,
};
enum DXUT_CONTROL_STATE
{
DXUT_STATE_NORMAL = 0,
DXUT_STATE_DISABLED,
DXUT_STATE_HIDDEN,
DXUT_STATE_FOCUS,
DXUT_STATE_MOUSEOVER,
DXUT_STATE_PRESSED,
};
#define MAX_CONTROL_STATES 6
struct DXUTBlendColor
{
void Init( D3DCOLOR defaultColor, D3DCOLOR disabledColor = D3DCOLOR_ARGB(200, 128, 128, 128), D3DCOLOR hiddenColor = 0 );
void Blend( UINT iState, float fElapsedTime, float fRate = 0.7f );
D3DCOLOR States[ MAX_CONTROL_STATES ]; // Modulate colors for all possible control states
D3DXCOLOR Current;
};
//-----------------------------------------------------------------------------
// Contains all the display tweakables for a sub-control
//-----------------------------------------------------------------------------
class CDXUTElement
{
public:
UINT iTexture; // Index of the texture for this Element
UINT iFont; // Index of the font for this Element
DWORD dwTextFormat; // The format argument to DrawText
RECT rcTexture; // Bounding rect of this element on the composite texture
DXUTBlendColor TextureColor;
DXUTBlendColor FontColor;
};
//--------------------------------------------------------------------------------------
// Structs for shared resources
//--------------------------------------------------------------------------------------
struct DXUTTextureNode
{
TCHAR strFilename[MAX_PATH];
IDirect3DTexture9* pTexture;
DWORD dwWidth;
DWORD dwHeight;
};
struct DXUTFontNode
{
TCHAR strFace[MAX_PATH];
ID3DXFont* pFont;
LONG nHeight;
LONG nWeight;
};
//-----------------------------------------------------------------------------
// Manages shared resources of dialogs
//-----------------------------------------------------------------------------
class CDXUTDialogResourceManager
{
public:
CDXUTDialogResourceManager();
HRESULT OnResetDevice();
void OnLostDevice();
void OnDestroyDevice();
// Shared between all dialogs
IDirect3DStateBlock9* m_pStateBlock;
ID3DXSprite* m_pSprite; // Sprite used for drawing
protected:
CGrowableArray< DXUTTextureNode* > m_TextureCache; // Shared textures
CGrowableArray< DXUTFontNode* > m_FontCache; // Shared fonts
IDirect3DDevice9* m_pd3dDevice;
};
//-----------------------------------------------------------------------------
// Base class for controls
//-----------------------------------------------------------------------------
class CDXUTControl
{
public:
CDXUTControl( CDXUTDialog *pDialog = NULL );
bool m_bVisible; // Shown/hidden flag
bool m_bMouseOver; // Mouse pointer is above control
bool m_bHasFocus; // Control has input focus
bool m_bIsDefault; // Is the default control
// Size, scale, and positioning members
int m_x, m_y;
int m_width, m_height;
// These members are set by the container
CDXUTDialog* m_pDialog; // Parent container
UINT m_Index; // Index within the control list
CGrowableArray< CDXUTElement* > m_Elements; // All display elements
protected:
int m_ID; // ID number
DXUT_CONTROL_TYPE m_Type; // Control type, set once in constructor
UINT m_nHotkey; // Virtual key code for this control's hotkey
void *m_pUserData; // Data associated with this control that is set by user.
bool m_bEnabled; // Enabled/disabled flag
RECT m_rcBoundingBox; // Rectangle defining the active region of the control
};
//-----------------------------------------------------------------------------
// Static control
//-----------------------------------------------------------------------------
class CDXUTStatic : public CDXUTControl
{
public:
HRESULT GetTextCopy( PCHAR strDest, UINT bufferCount );
protected:
TCHAR m_strText[MAX_PATH]; // Window text
};
#endif // DXUT_GUI_H