This repository was archived by the owner on Mar 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangularisationCombo.cpp
More file actions
127 lines (107 loc) · 3.65 KB
/
TriangularisationCombo.cpp
File metadata and controls
127 lines (107 loc) · 3.65 KB
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
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
// TriangularisationCombo.cpp : implementation file
//
#include "StdH.h"
#ifdef _DEBUG
#undef new
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTriangularisationCombo
CTriangularisationCombo::CTriangularisationCombo()
{
}
CTriangularisationCombo::~CTriangularisationCombo()
{
}
BEGIN_MESSAGE_MAP(CTriangularisationCombo, CComboBox)
//{{AFX_MSG_MAP(CTriangularisationCombo)
ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropdown)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTriangularisationCombo message handlers
BOOL CTriangularisationCombo::OnIdle(LONG lCount)
{
// get document ptr
CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
if( (pDoc == NULL) ||
(pDoc->GetEditingMode() != CSG_MODE) ||
(!pDoc->m_bPrimitiveMode) )
{
// we should disable triangularisation combo
if(GetCount() == 1) return TRUE; // we allready have "not available" in combo
// remove all combo entries
ResetContent();
// set none available message
AddString( _T("None Available"));
SetCurSel( 0);
}
// we should enable triangularisation combo
else
{
// if it is allready enabled
if(GetCount() != 1) return TRUE;
ResetContent();
// add all possible triangularisation types
AddString( _T("None"));
AddString( _T("Center"));
AddString( _T("Vertex 1"));
AddString( _T("Vertex 2"));
AddString( _T("Vertex 3"));
AddString( _T("Vertex 4"));
AddString( _T("Vertex 5"));
AddString( _T("Vertex 6"));
AddString( _T("Vertex 7"));
AddString( _T("Vertex 8"));
AddString( _T("Vertex 9"));
AddString( _T("Vertex 10"));
AddString( _T("Vertex 11"));
AddString( _T("Vertex 12"));
AddString( _T("Vertex 13"));
AddString( _T("Vertex 14"));
AddString( _T("Vertex 15"));
AddString( _T("Vertex 16"));
// select currently selected triangularisation type
SetCurSel( (int)theApp.m_vfpCurrent.vfp_ttTriangularisationType);
}
return TRUE;
}
void CTriangularisationCombo::OnSelchange()
{
// get document ptr
CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
if( pDoc == NULL) return;
int iSelected = GetCurSel();
theApp.m_vfpCurrent.vfp_ttTriangularisationType = (enum TriangularisationType) iSelected;
pDoc->CreatePrimitive();
pDoc->UpdateAllViews(NULL);
}
void CTriangularisationCombo::OnDropdown()
{
INDEX ctItems = GetCount();
if( ctItems == CB_ERR) return;
CRect rectCombo;
GetWindowRect( &rectCombo);
PIX pixScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
PIX pixMaxHeight = pixScreenHeight - rectCombo.top;
CWnd *pwndParent = GetParent();
if( pwndParent == NULL) return;
pwndParent->ScreenToClient( &rectCombo);
PIX pixNewHeight = GetItemHeight(0)*(ctItems+2);
rectCombo.bottom = rectCombo.top + ClampUp( pixNewHeight, pixMaxHeight);
MoveWindow( rectCombo);
}