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