forked from gscept/CubeMapGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIRegionManager.h
104 lines (75 loc) · 2.95 KB
/
UIRegionManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "LocalDXUT\\dxstdafx.h"
#include "d3d9types.h"
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <wincon.h>
#include <stdarg.h>
#include <wtypes.h>
#define UI_ELEMENT_HEIGHT 16
const static int UIR_ID_MOVE = 622;
const static int UIR_ID_MINIMIZE = 623;
const static int UIR_ID_MAXIMIZE = 624;
const static int UIR_ID_TITLE = 625;
class UIRegion
{
public:
D3DRECT m_BackgroundRect;
CDXUTDialog m_Dialog;
CDXUTDialog m_minDialog;
UIRegion( const WCHAR* cpszTitle );
~UIRegion( void );
void SetSize( int iWidth, int iHeight );
// Sets the position of the window
void SetPosition( int iX, int iY );
// Sets the position of the window and stores it's percentage position in relation to the parent (for resizing)
void SetPosition( int iX, int iY, int iParentWidth, int iParentHeight );
int getHeight( void ) { return m_BackgroundRect.y2 - m_BackgroundRect.y1; }
int getWidth( void ) { return m_BackgroundRect.x2 - m_BackgroundRect.x1; }
int getTop( void ) { return m_BackgroundRect.y1; }
int getLeft( void ) { return m_BackgroundRect.x1; }
void SetColor( D3DCOLOR rgbaColor );
void SetVisible( bool bIsVisible );
bool IsVisible( void );
void SetMoving( bool bIsMoving );
bool IsMoving( void );
void SetCallback( PCALLBACKDXUTGUIEVENT pCallbackFunc );
void SetMinimized( bool bMinimized );
bool IsMinimized( void );
void Display( IDirect3DDevice9* pDevice, float fElapsedTime );
bool MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
struct RegionPosition
{
float x;
float y;
};
RegionPosition m_positionPercentage;
private:
bool m_bVisible;
bool m_bMinimized;
int m_nMaximizedHeight;
bool m_bMoving;
D3DCOLOR m_backgroundColor;
const static int UIR_MAX_TITLE_LENGTH = 32;
WCHAR szName[UIR_MAX_TITLE_LENGTH];
};
class UIRegionManager
{
public:
static UIRegionManager* GetInstance();
~UIRegionManager();
UIRegion* CreateRegion( const WCHAR* cpszTitle );
// callback for moving, minimizing, and maximizing UIRegions
void OnGUIRegionEvent( UINT nEvent, int nControlID, CDXUTControl* pControl );
void OnMouseEvent( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos );
void OnResize( const D3DSURFACE_DESC* pNewBackBufferDesc /*, D3DSURFACE_DESC* pPrevBackBufferDesc = NULL */ );
bool MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
void DisplayRegions( IDirect3DDevice9* pDevice, D3DSURFACE_DESC* pBackBufferSurfaceDesc, float fElapsedTime );
private:
// private constructor for a singleton
UIRegionManager();
D3DSURFACE_DESC* m_pBackBuffer;
unsigned int m_uiNumRegions;
const static int UIRM_MAX_REGIONS = 10;
UIRegion* m_pRegionArray[UIRM_MAX_REGIONS];
};