Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

FindTextureDlg.cpp

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 // FindTextureDlg.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include "Radiant.h"
00027 #include "FindTextureDlg.h"
00028 
00029 #ifdef _DEBUG
00030 #define new DEBUG_NEW
00031 #undef THIS_FILE
00032 static char THIS_FILE[] = __FILE__;
00033 #endif
00034 
00036 // CFindTextureDlg dialog
00037 
00038 CFindTextureDlg g_TexFindDlg;
00039 CFindTextureDlg& g_dlgFind = g_TexFindDlg;
00040 static bool g_bFindActive = true;
00041 
00042 void CFindTextureDlg::updateTextures(const char *p)
00043 {
00044   if (isOpen())
00045   {
00046     if (g_bFindActive)
00047     {
00048       setFindStr(p);
00049     }
00050     else
00051     {
00052       setReplaceStr(p);
00053     }
00054   }
00055 }
00056 
00057 CFindTextureDlg::CFindTextureDlg(CWnd* pParent /*=NULL*/)
00058     : CDialog(CFindTextureDlg::IDD, pParent)
00059 {
00060     //{{AFX_DATA_INIT(CFindTextureDlg)
00061     m_bSelectedOnly = FALSE;
00062     m_strFind = _T("");
00063     m_strReplace = _T("");
00064     m_bForce = FALSE;
00065     m_bLive = TRUE;
00066     //}}AFX_DATA_INIT
00067 }
00068 
00069 
00070 void CFindTextureDlg::DoDataExchange(CDataExchange* pDX)
00071 {
00072     CDialog::DoDataExchange(pDX);
00073     //{{AFX_DATA_MAP(CFindTextureDlg)
00074     DDX_Check(pDX, IDC_CHECK_SELECTED, m_bSelectedOnly);
00075     DDX_Text(pDX, IDC_EDIT_FIND, m_strFind);
00076     DDX_Text(pDX, IDC_EDIT_REPLACE, m_strReplace);
00077     DDX_Check(pDX, IDC_CHECK_FORCE, m_bForce);
00078     DDX_Check(pDX, IDC_CHECK_LIVE, m_bLive);
00079     //}}AFX_DATA_MAP
00080 }
00081 
00082 
00083 BEGIN_MESSAGE_MAP(CFindTextureDlg, CDialog)
00084     //{{AFX_MSG_MAP(CFindTextureDlg)
00085     ON_BN_CLICKED(ID_BTN_APPLY, OnBtnApply)
00086     ON_EN_SETFOCUS(IDC_EDIT_FIND, OnSetfocusEditFind)
00087     ON_EN_SETFOCUS(IDC_EDIT_REPLACE, OnSetfocusEditReplace)
00088     //}}AFX_MSG_MAP
00089 END_MESSAGE_MAP()
00090 
00091 void CFindTextureDlg::OnBtnApply() 
00092 {
00093   UpdateData(TRUE);
00094   CRect rct;
00095   GetWindowRect(rct);
00096   SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
00097   FindReplaceTextures(m_strFind, m_strReplace, m_bSelectedOnly, m_bForce);
00098 }
00099 
00100 void CFindTextureDlg::OnOK() 
00101 {
00102   UpdateData(TRUE);
00103   CRect rct;
00104   GetWindowRect(rct);
00105   SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
00106   FindReplaceTextures(m_strFind, m_strReplace, m_bSelectedOnly, m_bForce);
00107     CDialog::OnOK();
00108 }
00109 
00110 void CFindTextureDlg::show()
00111 {
00112   if (g_dlgFind.GetSafeHwnd() == NULL || IsWindow(g_dlgFind.GetSafeHwnd()) == FALSE)
00113   {
00114     g_dlgFind.Create(IDD_DIALOG_FINDREPLACE);
00115     g_dlgFind.ShowWindow(SW_SHOW);
00116   }
00117   else
00118   {
00119     g_dlgFind.ShowWindow(SW_SHOW);
00120   }
00121   CRect rct;
00122   LONG lSize = sizeof(rct);
00123   if (LoadRegistryInfo("Radiant::TextureFindWindow", &rct, &lSize))
00124     g_dlgFind.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);
00125 }       
00126 
00127 
00128 bool CFindTextureDlg::isOpen()
00129 {
00130   return (g_dlgFind.GetSafeHwnd() == NULL || ::IsWindowVisible(g_dlgFind.GetSafeHwnd()) == FALSE) ? false : true;
00131 }
00132 
00133 void CFindTextureDlg::setFindStr(const char * p)
00134 {
00135   g_dlgFind.UpdateData(TRUE);
00136   if (g_dlgFind.m_bLive)
00137   {
00138     g_dlgFind.m_strFind = p;
00139     g_dlgFind.UpdateData(FALSE);
00140   }
00141 }
00142 
00143 void CFindTextureDlg::setReplaceStr(const char * p)
00144 {
00145   g_dlgFind.UpdateData(TRUE);
00146   if (g_dlgFind.m_bLive)
00147   {
00148     g_dlgFind.m_strReplace = p;
00149     g_dlgFind.UpdateData(FALSE);
00150   }
00151 }
00152 
00153 
00154 void CFindTextureDlg::OnCancel() 
00155 {
00156   CRect rct;
00157   GetWindowRect(rct);
00158   SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
00159     CDialog::OnCancel();
00160 }
00161 
00162 BOOL CFindTextureDlg::DestroyWindow() 
00163 {
00164     return CDialog::DestroyWindow();
00165 }
00166 
00167 void CFindTextureDlg::OnSetfocusEditFind() 
00168 {
00169   g_bFindActive = true;
00170 }
00171 
00172 void CFindTextureDlg::OnSetfocusEditReplace() 
00173 {
00174   g_bFindActive = false;
00175 }

Generated on Thu Aug 25 12:38:29 2005 for Quake III Arena by  doxygen 1.3.9.1