doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FindTextureDlg.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 "qe3.h"
33 #include "Radiant.h"
34 #include "FindTextureDlg.h"
35 
36 #ifdef _DEBUG
37 #define new DEBUG_NEW
38 #undef THIS_FILE
39 static char THIS_FILE[] = __FILE__;
40 #endif
41 
43 // CFindTextureDlg dialog
44 
47 static bool g_bFindActive = true;
48 
50 {
51  if (isOpen())
52  {
53  if (g_bFindActive)
54  {
55  setFindStr(p);
56  }
57  else
58  {
59  setReplaceStr(p);
60  }
61  }
62 }
63 
64 CFindTextureDlg::CFindTextureDlg(CWnd* pParent /*=NULL*/)
65  : CDialog(CFindTextureDlg::IDD, pParent)
66 {
67  //{{AFX_DATA_INIT(CFindTextureDlg)
69  m_strFind = _T("");
70  m_strReplace = _T("");
71  m_bForce = FALSE;
72  m_bLive = TRUE;
73  //}}AFX_DATA_INIT
74 }
75 
76 
77 void CFindTextureDlg::DoDataExchange(CDataExchange* pDX)
78 {
79  CDialog::DoDataExchange(pDX);
80  //{{AFX_DATA_MAP(CFindTextureDlg)
81  DDX_Check(pDX, IDC_CHECK_SELECTED, m_bSelectedOnly);
82  DDX_Text(pDX, IDC_EDIT_FIND, m_strFind);
83  DDX_Text(pDX, IDC_EDIT_REPLACE, m_strReplace);
84  DDX_Check(pDX, IDC_CHECK_FORCE, m_bForce);
85  DDX_Check(pDX, IDC_CHECK_LIVE, m_bLive);
86  //}}AFX_DATA_MAP
87 }
88 
89 
90 BEGIN_MESSAGE_MAP(CFindTextureDlg, CDialog)
91  //{{AFX_MSG_MAP(CFindTextureDlg)
92  ON_BN_CLICKED(IDC_BTN_APPLY, OnBtnApply)
93  ON_EN_SETFOCUS(IDC_EDIT_FIND, OnSetfocusEditFind)
94  ON_EN_SETFOCUS(IDC_EDIT_REPLACE, OnSetfocusEditReplace)
95  //}}AFX_MSG_MAP
96 END_MESSAGE_MAP()
97 
98 void CFindTextureDlg::OnBtnApply()
99 {
100  UpdateData(TRUE);
101  CRect rct;
102  GetWindowRect(rct);
103  SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
104  FindReplaceTextures( m_strFind, m_strReplace, ( m_bSelectedOnly != FALSE ), ( m_bForce != FALSE ) );
105 }
106 
108 {
109  UpdateData(TRUE);
110  CRect rct;
111  GetWindowRect(rct);
112  SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
113  FindReplaceTextures( m_strFind, m_strReplace, ( m_bSelectedOnly != FALSE ), ( m_bForce != FALSE ) );
114  CDialog::OnOK();
115 }
116 
118 {
119  if (g_dlgFind.GetSafeHwnd() == NULL || IsWindow(g_dlgFind.GetSafeHwnd()) == FALSE)
120  {
121  g_dlgFind.Create(IDD_DIALOG_FINDREPLACE);
122  g_dlgFind.ShowWindow(SW_SHOW);
123  }
124  else
125  {
126  g_dlgFind.ShowWindow(SW_SHOW);
127  }
128  CRect rct;
129  LONG lSize = sizeof(rct);
130  if (LoadRegistryInfo("Radiant::TextureFindWindow", &rct, &lSize))
131  g_dlgFind.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);
132 }
133 
134 
136 {
137  return (g_dlgFind.GetSafeHwnd() == NULL || ::IsWindowVisible(g_dlgFind.GetSafeHwnd()) == FALSE) ? false : true;
138 }
139 
140 void CFindTextureDlg::setFindStr(const char * p)
141 {
142  g_dlgFind.UpdateData(TRUE);
143  if (g_dlgFind.m_bLive)
144  {
145  g_dlgFind.m_strFind = p;
146  g_dlgFind.UpdateData(FALSE);
147  }
148 }
149 
151 {
152  g_dlgFind.UpdateData(TRUE);
153  if (g_dlgFind.m_bLive)
154  {
155  g_dlgFind.m_strReplace = p;
156  g_dlgFind.UpdateData(FALSE);
157  }
158 }
159 
160 
162 {
163  CRect rct;
164  GetWindowRect(rct);
165  SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
166  CDialog::OnCancel();
167 }
168 
170 {
171  return CDialog::DestroyWindow();
172 }
173 
175 {
176  g_bFindActive = true;
177 }
178 
180 {
181  g_bFindActive = false;
182 }
static void show()
CFindTextureDlg & g_dlgFind
CFindTextureDlg g_TexFindDlg
virtual BOOL DestroyWindow()
virtual void OnCancel()
afx_msg void OnSetfocusEditReplace()
#define IDC_CHECK_SELECTED
bool LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize)
Definition: Radiant.cpp:405
#define BOOL
Definition: mprintf.c:71
#define IDC_CHECK_LIVE
static bool isOpen()
virtual void OnOK()
#define NULL
Definition: Lib.h:88
bool SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize)
Definition: Radiant.cpp:398
static void setReplaceStr(const char *p)
#define IDD_DIALOG_FINDREPLACE
#define IDC_EDIT_REPLACE
afx_msg void OnSetfocusEditFind()
long LONG
static void setFindStr(const char *p)
#define FALSE
Definition: mprintf.c:70
static void updateTextures(const char *p)
#define TRUE
Definition: mprintf.c:69
#define IDC_CHECK_FORCE
CString m_strReplace
#define IDC_BTN_APPLY
GLfloat GLfloat p
Definition: glext.h:4674
#define IDC_EDIT_FIND
virtual void DoDataExchange(CDataExchange *pDX)
CFindTextureDlg(CWnd *pParent=NULL)