]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - misc/mediasource/netradiant-src/contrib/bobtoolz/dialogs/PolygonDialog.cpp
Move all other sources in a separate subfolder
[voretournament/voretournament.git] / misc / mediasource / netradiant-src / 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 #ifdef _DEBUG
28 #define new DEBUG_NEW
29 #undef THIS_FILE
30 static char THIS_FILE[] = __FILE__;
31 #endif
32
33 /////////////////////////////////////////////////////////////////////////////
34 // CPolygonDialog dialog
35
36
37 CPolygonDialog::CPolygonDialog(CWnd* pParent /*=NULL*/)
38         : CDialog(CPolygonDialog::IDD, pParent)
39 {
40         //{{AFX_DATA_INIT(CPolygonDialog)
41         m_nSideCount = 3;
42         m_bInverse = FALSE;
43         m_bBorder = FALSE;
44         m_nBorderSize = 8;
45         m_bAlignTop = FALSE;
46         //}}AFX_DATA_INIT
47 }
48
49 void CPolygonDialog::DoDataExchange(CDataExchange* pDX)
50 {
51         CDialog::DoDataExchange(pDX);
52         //{{AFX_DATA_MAP(CPolygonDialog)
53         DDX_Text(pDX, IDC_EDIT1, m_nSideCount);
54         DDV_MinMaxUInt(pDX, m_nSideCount, 3, MAX_POLYGON_FACES);
55         DDX_Check(pDX, IDC_INVERSE_CHK, m_bInverse);
56         DDX_Check(pDX, IDC_BORDER_CHK, m_bBorder);
57         DDX_Text(pDX, IDC_BORDER_EDIT, m_nBorderSize);
58         DDV_MinMaxUInt(pDX, m_nBorderSize, 1, 1024);
59         DDX_Check(pDX, IDC_ALIGN_CHK, m_bAlignTop);
60         //}}AFX_DATA_MAP
61 }
62
63
64 BEGIN_MESSAGE_MAP(CPolygonDialog, CDialog)
65         //{{AFX_MSG_MAP(CPolygonDialog)
66         ON_BN_CLICKED(IDC_BORDER_CHK, OnBorderChkClicked)
67         ON_BN_CLICKED(IDC_INVERSE_CHK, OnInverseChkClickrd)
68         //}}AFX_MSG_MAP
69 END_MESSAGE_MAP()
70
71 /////////////////////////////////////////////////////////////////////////////
72 // CPolygonDialog message handlers
73
74 BOOL CPolygonDialog::OnInitDialog() 
75 {
76         CDialog::OnInitDialog();
77         
78         EnableBordered(!GetChkBool(IDC_INVERSE_CHK));
79         EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
80                 
81         return TRUE;  // return TRUE unless you set the focus to a control
82                       // EXCEPTION: OCX Property Pages should return FALSE
83 }
84
85 void CPolygonDialog::EnableBordered(BOOL bEnable)
86 {
87         CWnd* dtlChk = GetDlgItem(IDC_BORDER_CHK);
88         if(dtlChk)
89                 dtlChk->EnableWindow(bEnable);
90 }
91
92 void CPolygonDialog::EnableBorderEdit(BOOL bEnable)
93 {
94         CWnd* dtlChk = GetDlgItem(IDC_BORDER_EDIT);
95         if(dtlChk)
96                 dtlChk->EnableWindow(bEnable);
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         return FALSE;
116 }