-
Notifications
You must be signed in to change notification settings - Fork 2
/
VertexMiniDB.cpp
147 lines (115 loc) · 5.36 KB
/
VertexMiniDB.cpp
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//-----------------------------------------------------------------------------
// File: VertexMiniDB.cpp
//
// Desc: Processing for the mini vertex dialog, which appears when a single
// vertex is selected in the polygon tree.
//
// Copyright (c) 2002 Dan
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Includes
#include <windows.h>
#include <commctrl.h>
#include "VertexMiniDB.h"
#include "CustomMsg.h"
#include "PolygonManager.h"
#include "resource.h"
//-----------------------------------------------------------------------------
// These globals are only used here to reduce repetitive calls to 'Get'
// functions
int g_R, g_G, g_B;
//-----------------------------------------------------------------------------
// Name: OnVertexMini_WMInitDialog()
// Desc: Creates all the UpDown controls after getting the current vertex's
// information.
//-----------------------------------------------------------------------------
void OnVertexMini_WMInitDialog( HWND hWnd )
{
ShowWindow( hWnd, true );
UpdateWindow( hWnd );
// Get handles to each edit box
HWND hTextureU = GetDlgItem( hWnd, IDC_EDIT_TEXTUREU );
HWND hTextureV = GetDlgItem( hWnd, IDC_EDIT_TEXTUREV );
HWND hRed = GetDlgItem( hWnd, IDC_EDIT_RED );
HWND hGreen = GetDlgItem( hWnd, IDC_EDIT_GREEN );
HWND hBlue = GetDlgItem( hWnd, IDC_EDIT_BLUE );
// Gather the current vertex information
int r, g, b, u, v;
PolygonManager->GetVertexInfo( r, g, b, u, v );
// Create all the controls
CreateUpDownControl( WS_CHILD | WS_BORDER | WS_VISIBLE |
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_WRAP,
10, 10, 50, 50, hWnd, ID_TEXTUREUUPDOWN, NULL, hTextureU, 10, 0, u );
CreateUpDownControl( WS_CHILD | WS_BORDER | WS_VISIBLE |
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_WRAP,
10, 10, 50, 50, hWnd, ID_TEXTUREUUPDOWN, NULL, hTextureV, 10, 0, v );
CreateUpDownControl( WS_CHILD | WS_BORDER | WS_VISIBLE |
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_WRAP,
10, 10, 50, 50, hWnd, ID_COLORRED, NULL, hRed, 255, 0, r );
CreateUpDownControl( WS_CHILD | WS_BORDER | WS_VISIBLE |
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_WRAP,
10, 10, 50, 50, hWnd, ID_COLORGREEN, NULL, hGreen, 255, 0, g );
CreateUpDownControl( WS_CHILD | WS_BORDER | WS_VISIBLE |
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_WRAP,
10, 10, 50, 50, hWnd, ID_COLORBLUE, NULL, hBlue, 255, 0, b );
}
//-----------------------------------------------------------------------------
// Name: OnVertexMini_WMDestroy()
// Desc: Updates the polygon with the dialog info
//-----------------------------------------------------------------------------
void OnVertexMini_WMDestroy( HWND hWnd )
{
BOOL bBool;
// Get all the values
int r = GetDlgItemInt( hWnd, IDC_EDIT_RED, &bBool, true );
int g = GetDlgItemInt( hWnd, IDC_EDIT_GREEN, &bBool, true );
int b = GetDlgItemInt( hWnd, IDC_EDIT_BLUE, &bBool, true );
int u = GetDlgItemInt( hWnd, IDC_EDIT_TEXTUREU, &bBool, true );
int v = GetDlgItemInt( hWnd, IDC_EDIT_TEXTUREV, &bBool, true );
// Set them all before exiting
PolygonManager->SetVertexInfo( r, g, b, u, v );
EndDialog( hWnd, 0 );
}
//-----------------------------------------------------------------------------
// Name: OnVertexMini_WMPaint()
// Desc: Fills the color box to the correct color
//-----------------------------------------------------------------------------
void OnVertexMini_WMPaint( HWND hWnd )
{
BOOL bBool; // Not reall used
HDC hDC = GetDC( hWnd );
// Get the current values
g_R = GetDlgItemInt( hWnd, IDC_EDIT_RED, &bBool, true );
g_G = GetDlgItemInt( hWnd, IDC_EDIT_GREEN, &bBool, true );
g_B = GetDlgItemInt( hWnd, IDC_EDIT_BLUE, &bBool, true );
// Create a color brush
HBRUSH hBrush = CreateSolidBrush( RGB( g_R, g_G, g_B ) );
// Set thedrawing box
RECT rcBox = { 8, 43, 177, 72 };
// Draw it
FillRect( hDC, &rcBox, hBrush );
// Not sure if the hDC has to be deleted, but it is
ReleaseDC( hWnd, hDC );
DeleteObject( hBrush );
DeleteObject( hDC );
}
//-----------------------------------------------------------------------------
// Name: OnVertexMini_WMCommand()
// Desc: Process system messages
//-----------------------------------------------------------------------------
void OnVertexMini_WMCommand( HWND hWnd, WPARAM wParam )
{
BOOL bBool;
// If the color Edit-Box's have changed, update the color box
if( HIWORD( wParam ) == EN_UPDATE && LOWORD( wParam ) == IDC_EDIT_RED ||
LOWORD( wParam ) == IDC_EDIT_GREEN || LOWORD( wParam ) == IDC_EDIT_BLUE )
{
// Updates the current color
OnVertexMini_WMPaint( hWnd );
// To keep things correct, just get the tex coords too
int u = GetDlgItemInt( hWnd, IDC_EDIT_TEXTUREU, &bBool, true );
int v = GetDlgItemInt( hWnd, IDC_EDIT_TEXTUREV, &bBool, true );
// Sets the vertex to the dialog values
PolygonManager->SetVertexInfo( g_R, g_G, g_B, u, v );
}
}