doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DialogGoToLine.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/Common_resource.h"
33 
34 #include "DialogGoToLine.h"
35 
36 #ifdef ID_DEBUG_MEMORY
37 #undef new
38 #undef DEBUG_NEW
39 #define DEBUG_NEW new
40 #endif
41 
42 
43 IMPLEMENT_DYNAMIC(DialogGoToLine, CDialog)
44 
45 /*
46 ================
47 DialogGoToLine::DialogGoToLine
48 ================
49 */
50 DialogGoToLine::DialogGoToLine( CWnd* pParent /*=NULL*/ )
51  : CDialog(DialogGoToLine::IDD, pParent)
52  , firstLine(0)
53  , lastLine(0)
54  , line(0)
55 {
56 }
57 
58 /*
59 ================
60 DialogGoToLine::~DialogGoToLine
61 ================
62 */
64 }
65 
66 /*
67 ================
68 DialogGoToLine::DoDataExchange
69 ================
70 */
71 void DialogGoToLine::DoDataExchange(CDataExchange* pDX) {
72  CDialog::DoDataExchange(pDX);
73  //{{AFX_DATA_MAP(DialogGoToLine)
74  DDX_Control( pDX, IDC_GOTOLINE_EDIT, numberEdit);
75  //}}AFX_DATA_MAP
76 }
77 
78 /*
79 ================
80 DialogGoToLine::SetRange
81 ================
82 */
83 void DialogGoToLine::SetRange( int firstLine, int lastLine ) {
84  this->firstLine = firstLine;
85  this->lastLine = lastLine;
86 }
87 
88 /*
89 ================
90 DialogGoToLine::GetLine
91 ================
92 */
93 int DialogGoToLine::GetLine( void ) const {
94  return line;
95 }
96 
97 /*
98 ================
99 DialogGoToLine::OnInitDialog
100 ================
101 */
103 
104  CDialog::OnInitDialog();
105 
106  GetDlgItem( IDC_GOTOLINE_STATIC )->SetWindowText( va( "&Line number (%d - %d):", firstLine, lastLine ) );
107 
108  numberEdit.SetWindowText( va( "%d", firstLine ) );
109  numberEdit.SetSel( 0, -1 );
110  numberEdit.SetFocus();
111 
112  return FALSE; // return TRUE unless you set the focus to a control
113  // EXCEPTION: OCX Property Pages should return FALSE
114 }
115 
116 
117 BEGIN_MESSAGE_MAP(DialogGoToLine, CDialog)
118  ON_BN_CLICKED(IDOK, OnBnClickedOk)
119 END_MESSAGE_MAP()
120 
121 
122 // DialogGoToLine message handlers
123 
124 /*
125 ================
126 DialogGoToLine::OnBnClickedOk
127 ================
128 */
129 void DialogGoToLine::OnBnClickedOk() {
130  CString text;
131  numberEdit.GetWindowText( text );
132  line = idMath::ClampInt( firstLine, lastLine, atoi( text ) );
133  OnOK();
134 }
int GetLine(void) const
void SetRange(int firstLine, int lastLine)
virtual void DoDataExchange(CDataExchange *pDX)
static int ClampInt(int min, int max, int value)
Definition: Math.h:883
#define IDC_GOTOLINE_STATIC
#define BOOL
Definition: mprintf.c:71
virtual BOOL OnInitDialog()
#define IDC_GOTOLINE_EDIT
virtual ~DialogGoToLine()
#define FALSE
Definition: mprintf.c:70
char * va(const char *fmt,...)
Definition: Str.cpp:1568