Back to index

lightning-sunbird  0.9+nobinonly
Dialogs.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: Mozilla-sample-code 1.0
00004  *
00005  * Copyright (c) 2002 Netscape Communications Corporation and
00006  * other contributors
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a
00009  * copy of this Mozilla sample software and associated documentation files
00010  * (the "Software"), to deal in the Software without restriction, including
00011  * without limitation the rights to use, copy, modify, merge, publish,
00012  * distribute, sublicense, and/or sell copies of the Software, and to permit
00013  * persons to whom the Software is furnished to do so, subject to the
00014  * following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included
00017  * in all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00022  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00025  * DEALINGS IN THE SOFTWARE.
00026  *
00027  * Contributor(s):
00028  *   Chak Nanga <chak@netscape.com>
00029  *
00030  * ***** END LICENSE BLOCK ***** */
00031 
00032 #include "stdafx.h"
00033 #include "Dialogs.h"
00034 #include "BrowserView.h"
00035 
00036 // File overview....
00037 //
00038 // contains Find dialog box code
00039 //
00040 
00041 //--------------------------------------------------------------------------//
00042 //                CFindDialog Stuff
00043 //--------------------------------------------------------------------------//
00044 
00045 CFindDialog::CFindDialog(CString& csSearchStr, PRBool bMatchCase,
00046                 PRBool bMatchWholeWord, PRBool bWrapAround,
00047                 PRBool bSearchBackwards, CBrowserView* pOwner)
00048                 : CFindReplaceDialog()
00049 {
00050     // Save these initial settings off in member vars
00051     // We'll use these to initialize the controls
00052     // in InitDialog()
00053     m_csSearchStr = csSearchStr;
00054     m_bMatchCase = bMatchCase;
00055     m_bMatchWholeWord = bMatchWholeWord;
00056     m_bWrapAround = bWrapAround;
00057     m_bSearchBackwards = bSearchBackwards;
00058     m_pOwner = pOwner;
00059 
00060     // Set up to load our customized Find dialog template
00061     // rather than the default one MFC provides
00062     m_fr.Flags |= FR_ENABLETEMPLATE;
00063     m_fr.hInstance = AfxGetInstanceHandle();
00064     m_fr.lpTemplateName = MAKEINTRESOURCE(IDD_FINDDLG);
00065 }
00066 
00067 BOOL CFindDialog::OnInitDialog() 
00068 {
00069     CFindReplaceDialog::OnInitDialog();
00070 
00071     CEdit* pEdit = (CEdit *)GetDlgItem(IDC_FIND_EDIT);
00072     if(pEdit)
00073         pEdit->SetWindowText(m_csSearchStr);
00074 
00075     CButton* pChk = (CButton *)GetDlgItem(IDC_MATCH_CASE);
00076     if(pChk)
00077         pChk->SetCheck(m_bMatchCase);
00078 
00079     pChk = (CButton *)GetDlgItem(IDC_MATCH_WHOLE_WORD);
00080     if(pChk)
00081         pChk->SetCheck(m_bMatchWholeWord);
00082 
00083     pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND);    
00084     if(pChk)
00085         pChk->SetCheck(m_bWrapAround);
00086 
00087     pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS);
00088     if(pChk)
00089         pChk->SetCheck(m_bSearchBackwards);
00090 
00091     return TRUE; 
00092 }
00093 
00094 void CFindDialog::PostNcDestroy()    
00095 {
00096     // Let the owner know we're gone
00097     if(m_pOwner != NULL)    
00098         m_pOwner->ClearFindDialog();
00099 
00100     CFindReplaceDialog::PostNcDestroy();
00101 }
00102 
00103 BOOL CFindDialog::WrapAround()
00104 {
00105     CButton* pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND);
00106 
00107     return pChk ? pChk->GetCheck() : FALSE;
00108 }
00109 
00110 BOOL CFindDialog::SearchBackwards()
00111 {
00112     CButton* pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS);
00113 
00114     return pChk ? pChk->GetCheck() : FALSE;
00115 }
00116 
00118 // CLinkPropertiesDlg dialog
00119 CLinkPropertiesDlg::CLinkPropertiesDlg(CWnd* pParent /*=NULL*/)
00120        : CDialog(CLinkPropertiesDlg::IDD, pParent)
00121 {
00122        m_LinkText = _T("");
00123        m_LinkLocation = _T("");
00124 }
00125 
00126 void CLinkPropertiesDlg::DoDataExchange(CDataExchange* pDX)
00127 {
00128        CDialog::DoDataExchange(pDX);
00129        DDX_Text(pDX, IDC_EDIT_LINK_TEXT, m_LinkText);
00130        DDX_Text(pDX, IDC_EDIT_LINK_LOCATION, m_LinkLocation);
00131 }
00132 
00133 
00134 BEGIN_MESSAGE_MAP(CLinkPropertiesDlg, CDialog)
00135 END_MESSAGE_MAP()
00136 
00137 void CLinkPropertiesDlg::OnOK() 
00138 {
00139        UpdateData(TRUE);
00140 
00141        if (m_LinkLocation.IsEmpty() || (m_LinkText.IsEmpty() && m_LinkLocation.IsEmpty()))
00142        {
00143               MessageBox(_T("Please enter a Link Location"));
00144               return;
00145        }
00146 
00147        if (m_LinkText.IsEmpty())
00148        {
00149               m_LinkText = m_LinkLocation;
00150        }
00151 
00152        EndDialog(IDOK);
00153 }