]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bobtoolz/dialogs/PolygonDialog.cpp
reformat code! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / contrib / bobtoolz / dialogs / PolygonDialog.cpp
1 /*
2    BobToolz plugin for GtkRadiant
3    Copyright (C) 2001 Gordon Biggans
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 // PolygonDialog.cpp : implementation file
21 //
22
23 #include "../StdAfx.h"
24 #include "PolygonDialog.h"
25 #include "../shapes.h"
26
27 /////////////////////////////////////////////////////////////////////////////
28 // CPolygonDialog dialog
29
30
31 CPolygonDialog::CPolygonDialog(CWnd *pParent /*=NULL*/ )
32         : CDialog(CPolygonDialog::IDD, pParent)
33 {
34     //{{AFX_DATA_INIT(CPolygonDialog)
35     m_nSideCount = 3;
36     m_bInverse = FALSE;
37     m_bBorder = FALSE;
38     m_nBorderSize = 8;
39     m_bAlignTop = FALSE;
40     //}}AFX_DATA_INIT
41 }
42
43 void CPolygonDialog::DoDataExchange(CDataExchange *pDX)
44 {
45     CDialog::DoDataExchange(pDX);
46     //{{AFX_DATA_MAP(CPolygonDialog)
47     DDX_Text(pDX, IDC_EDIT1, m_nSideCount);
48     DDV_MinMaxUInt(pDX, m_nSideCount, 3, MAX_POLYGON_FACES);
49     DDX_Check(pDX, IDC_INVERSE_CHK, m_bInverse);
50     DDX_Check(pDX, IDC_BORDER_CHK, m_bBorder);
51     DDX_Text(pDX, IDC_BORDER_EDIT, m_nBorderSize);
52     DDV_MinMaxUInt(pDX, m_nBorderSize, 1, 1024);
53     DDX_Check(pDX, IDC_ALIGN_CHK, m_bAlignTop);
54     //}}AFX_DATA_MAP
55 }
56
57
58 BEGIN_MESSAGE_MAP( CPolygonDialog, CDialog
59 )
60 //{{AFX_MSG_MAP(CPolygonDialog)
61 ON_BN_CLICKED( IDC_BORDER_CHK, OnBorderChkClicked
62 )
63 ON_BN_CLICKED( IDC_INVERSE_CHK, OnInverseChkClickrd
64 )
65
66 //}}AFX_MSG_MAP
67 END_MESSAGE_MAP()
68
69 /////////////////////////////////////////////////////////////////////////////
70 // CPolygonDialog message handlers
71
72 BOOL CPolygonDialog::OnInitDialog()
73 {
74     CDialog::OnInitDialog();
75
76     EnableBordered(!GetChkBool(IDC_INVERSE_CHK));
77     EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
78
79     return TRUE;  // return TRUE unless you set the focus to a control
80     // EXCEPTION: OCX Property Pages should return FALSE
81 }
82
83 void CPolygonDialog::EnableBordered(BOOL bEnable)
84 {
85     CWnd *dtlChk = GetDlgItem(IDC_BORDER_CHK);
86     if (dtlChk) {
87         dtlChk->EnableWindow(bEnable);
88     }
89 }
90
91 void CPolygonDialog::EnableBorderEdit(BOOL bEnable)
92 {
93     CWnd *dtlChk = GetDlgItem(IDC_BORDER_EDIT);
94     if (dtlChk) {
95         dtlChk->EnableWindow(bEnable);
96     }
97 }
98
99 void CPolygonDialog::OnBorderChkClicked()
100 {
101     EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
102 }
103
104 void CPolygonDialog::OnInverseChkClickrd()
105 {
106     EnableBordered(!GetChkBool(IDC_INVERSE_CHK));
107     EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
108 }
109
110 BOOL CPolygonDialog::GetChkBool(int nID)
111 {
112     CButton *btn = (CButton *) GetDlgItem(nID);
113     if (btn) {
114         return btn->GetCheck();
115     }
116     return FALSE;
117 }