doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DialogAFName.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "../../sys/win32/rc/AFEditor_resource.h"
33 
34 #include "DialogAF.h"
35 #include "DialogAFName.h"
36 
37 // DialogAFName dialog
38 
39 IMPLEMENT_DYNAMIC(DialogAFName, CDialog)
40 
41 /*
42 ================
43 DialogAFName::DialogAFName
44 ================
45 */
46 DialogAFName::DialogAFName(CWnd* pParent /*=NULL*/)
47  : CDialog(DialogAFName::IDD, pParent)
48  , m_combo(NULL)
49 {
50 }
51 
52 /*
53 ================
54 DialogAFName::~DialogAFName
55 ================
56 */
58 }
59 
60 /*
61 ================
62 DialogAFName::DoDataExchange
63 ================
64 */
65 void DialogAFName::DoDataExchange(CDataExchange* pDX) {
66  CDialog::DoDataExchange(pDX);
67  DDX_Text(pDX, IDC_EDIT_AF_NAME, m_editName);
68 }
69 
70 /*
71 ================
72 DialogAFName::SetName
73 ================
74 */
75 void DialogAFName::SetName( CString &str ) {
76  m_editName = str;
77 }
78 
79 /*
80 ================
81 DialogAFName::GetName
82 ================
83 */
84 void DialogAFName::GetName( CString &str ) {
85  str = m_editName;
86 }
87 
88 /*
89 ================
90 DialogAFName::SetComboBox
91 ================
92 */
93 void DialogAFName::SetComboBox( CComboBox *combo ) {
94  m_combo = combo;
95 }
96 
97 /*
98 ================
99 DialogAFName::OnInitDialog
100 ================
101 */
103  CEdit *edit;
104  CString str;
105 
106  CDialog::OnInitDialog();
107 
108  edit = (CEdit *)GetDlgItem( IDC_EDIT_AF_NAME );
109  edit->SetFocus();
110  edit->GetWindowText( str );
111  edit->SetSel( 0, str.GetLength() );
112 
113  return FALSE;
114 }
115 
116 /*
117 ================
118 EditVerifyName
119 ================
120 */
121 void EditVerifyName( CEdit *edit ) {
122  CString strIn, strOut;
123  int start, end;
124  static bool entered = false;
125 
126  if ( entered ) {
127  return;
128  }
129  entered = true;
130 
131  edit->GetSel( start, end );
132  edit->GetWindowText( strIn );
133  for ( int i = 0; i < strIn.GetLength(); i++ ) {
134  if ( ( strIn[i] >= 'a' && strIn[i] <= 'z' ) ||
135  ( strIn[i] >= 'A' && strIn[i] <= 'Z' ) ||
136  ( strIn[i] == '_' ) || ( strIn[i] >= '0' && strIn[i] <= '9' ) ) {
137  strOut.AppendChar( strIn[i] );
138  }
139  }
140  edit->SetWindowText( strOut );
141  edit->SetSel( start, end );
142 
143  entered = false;
144 }
145 
146 
147 BEGIN_MESSAGE_MAP(DialogAFName, CDialog)
148  ON_BN_CLICKED(IDOK, OnBnClickedOk)
149  ON_EN_CHANGE(IDC_EDIT_AF_NAME, OnEnChangeEditAfName)
150 END_MESSAGE_MAP()
151 
152 
153 // DialogAFName message handlers
154 
155 void DialogAFName::OnBnClickedOk() {
156 
157  UpdateData( TRUE );
158  if ( m_combo && m_combo->FindStringExact( -1, m_editName ) != -1 ) {
159  MessageBox( va( "The name %s is already used.", m_editName.GetBuffer() ), "Name", MB_OK );
160  }
161  else {
162  OnOK();
163  }
164 }
165 
167  EditVerifyName( (CEdit *) GetDlgItem( IDC_EDIT_AF_NAME ) );
168 }
void GetName(CString &str)
void SetComboBox(CComboBox *combo)
int i
Definition: process.py:33
#define BOOL
Definition: mprintf.c:71
virtual BOOL OnInitDialog()
virtual ~DialogAFName()
GLuint GLuint end
Definition: glext.h:2845
#define NULL
Definition: Lib.h:88
void EditVerifyName(CEdit *edit)
CString m_editName
Definition: DialogAFName.h:54
void SetName(CString &str)
virtual void DoDataExchange(CDataExchange *pDX)
CComboBox * m_combo
Definition: DialogAFName.h:55
afx_msg void OnEnChangeEditAfName()
#define FALSE
Definition: mprintf.c:70
#define TRUE
Definition: mprintf.c:69
char * va(const char *fmt,...)
Definition: Str.cpp:1568
#define IDC_EDIT_AF_NAME
GLuint start
Definition: glext.h:2845