Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

ScriptEditorView.cpp

00001 /* QuestDesigner - Open Zelda's Project
00002    Copyright (C) 2003 Kronuz
00003    Copyright (C) 2001/2003 Open Zelda's Project
00004  
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00021 // ScriptEditorView.cpp : implementation of the CScriptEditorView class
00022 //
00023 
00024 #include "stdafx.h"
00025 
00026 #include "ScriptEditorView.h"
00027 #include "ScriptEditorFrm.h"
00028 #include <ssfiledialog.h>
00029 
00030 CScriptEditorView::CScriptEditorView(CScriptEditorFrame *pParentFrame) :
00031 m_pParentFrame(pParentFrame)
00032 {
00033 }
00034 
00035 // Called to translate window messages before they are dispatched 
00036 BOOL CScriptEditorView::PreTranslateMessage(MSG *pMsg)
00037 {
00038     return FALSE;
00039 }
00040 // Called to do idle processing
00041 BOOL CScriptEditorView::OnIdle ()
00042 {
00043     // Update all the menu items
00044 //  UIUpdateMenuItems ();
00045     
00046     // Update position display in the status bar
00047 //  UIUpdateStatusBar ();   
00048 
00049     return FALSE;
00050 }
00051 // Called to clean up after window is destroyed (called when WM_NCDESTROY is sent)
00052 void CScriptEditorView::OnFinalMessage(HWND /*hWnd*/)
00053 {
00054 /*
00055     // Update position display in the status bar (remove it)
00056     CMainFrame * pMainFrm = m_pParentFrame->GetMainFrame ();
00057     CMultiPaneStatusBarCtrl * pStatusBar = pMainFrm->GetMultiPaneStatusBarCtrl ();
00058     pStatusBar->SetPaneText ( ID_POSITION_PANE, _T ( "" ) );
00059 */
00060     delete this;
00061 }
00062 
00063 LRESULT CScriptEditorView::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
00064 {
00065     // Let the CodeMax control be created
00066     LONG lRet = DefWindowProc();
00067     // Set the current language and enable syntax highlighting
00068     CME_VERIFY ( SetLanguage ( CMLANG_ZES ) );
00069     CME_VERIFY ( EnableColorSyntax () );
00070 
00071     return lRet;
00072 }
00073 LRESULT CScriptEditorView::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &bHandled)
00074 {
00075     return 0;
00076 }
00077 
00080 LRESULT CScriptEditorView::OnFileReload(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00081 {
00082     return 0;
00083 }
00084 
00085 // Save handlers
00086 LRESULT CScriptEditorView::OnFileSave(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00087 {
00088     return 0;
00089 }
00090 LRESULT CScriptEditorView::OnFileSaveAs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00091 {
00092     return 0;
00093 }
00094 
00095 // Indent/Unindent the current selection
00096 LRESULT CScriptEditorView::OnEditTab(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00097 {
00098     return 0;
00099 }
00100 LRESULT CScriptEditorView::OnEditUntab(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00101 {
00102     return 0;
00103 }
00104 
00105 // Find next/previous search match in the buffer
00106 LRESULT CScriptEditorView::OnEditFindNext(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00107 {
00108     return 0;
00109 }
00110 LRESULT CScriptEditorView::OnEditFindPrev(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00111 {
00112     return 0;
00113 }
00114 
00115 // Searches the buffer using the current selection as the search parameter
00116 LRESULT CScriptEditorView::OnEditFindSelection(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00117 {
00118     return 0;
00119 }
00120 // Jump to the desired line
00121 LRESULT CScriptEditorView::OnEditGotoLine(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00122 {
00123     return 0;
00124 }
00125 
00126 // Find the current brace's 'sibling'
00127 LRESULT CScriptEditorView::OnEditMatchBrace(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00128 {
00129     return 0;
00130 }
00131 
00132 // Set buffer to read-only
00133 LRESULT CScriptEditorView::OnEditReadOnly(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00134 {
00135     return 0;
00136 }
00137 
00138 // Advanced edit commands
00139 LRESULT CScriptEditorView::OnEditUppercase(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00140 {
00141     return 0;
00142 }
00143 LRESULT CScriptEditorView::OnEditLowercase(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00144 {
00145     return 0;
00146 }
00147 LRESULT CScriptEditorView::OnEditTabify(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00148 {
00149     return 0;
00150 }
00151 LRESULT CScriptEditorView::OnEditUntabify(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00152 {
00153     return 0;
00154 }
00155 LRESULT CScriptEditorView::OnShowWhiteSpace(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00156 {
00157     return 0;
00158 }
00159 
00160 // Bookmark functions
00161 LRESULT CScriptEditorView::OnEditToggleBookmark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00162 {
00163     return 0;
00164 }
00165 LRESULT CScriptEditorView::OnEditGotoNextBookmark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00166 {
00167     return 0;
00168 }
00169 LRESULT CScriptEditorView::OnUpdateEditGotoPrevBookmark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00170 {
00171     return 0;
00172 }
00173 LRESULT CScriptEditorView::OnEditClearAllBookmarks(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
00174 {
00175     return 0;
00176 }
00177 
00179 // Open a file
00180 BOOL CScriptEditorView::DoFileOpen ( LPCTSTR lpszPathName, LPCTSTR lpszTitle /*=_T("Untitled")*/ ) 
00181 {
00182     ATLTRACE ( _T ( "Entering : CCodeMaxWTLSampleView::DoFileOpen ( %s )\n" ), lpszPathName );
00183     
00184     // open the requested file
00185     CME_CODE lRet = OpenFile(lpszPathName);
00186 
00187     if(CME_FAILED(lRet)) {
00188         ATLTRACE ( _T ( "Error: Failed to load file: %s\n" ), lpszPathName );
00189 
00190         // show the error message
00191         CString sMessage;
00192         sMessage.Format ( _T( "Failed to load: %s\n\n" ), lpszPathName );
00193         //ShowLastError ( sMessage, ::GetLastError () );
00194         
00195         return FALSE;
00196     }
00197 
00198     // Save file name for later
00199     m_sFileName = lpszPathName;
00200 
00201     // Save the tittle for later
00202     m_sTitle = lpszTitle;
00203 
00204     m_pParentFrame->SetTabText(m_sTitle);
00205 
00206     // If the CodeMax control has normalized case enabled, forcing
00207     //  a reload of the file will makes CodeMax normalize the entire file
00208     if(IsNormalizeCaseEnabled()) {
00209         // force a reload...
00210         //DoReload();
00211     }
00212 
00213     return TRUE;
00214 }
00215 // Save a file
00216 BOOL CScriptEditorView::DoFileSave ( const CString & sPathName ) 
00217 {
00218     // open the requested file
00219     CME_CODE lRet = SaveFile(sPathName, FALSE /*bClearUndo*/);
00220 
00221     if(CME_FAILED(lRet)) {
00222         ATLTRACE(_T("Error: Failed to save: %s\n"), sPathName);
00223 
00224         // show the error message
00225         CString sMessage;
00226         sMessage.Format(_T("Error: Failed to save: %s\n\n"), sPathName);
00227 //      MessageBox(sMessage, ::GetLastError());
00228 
00229         return FALSE;
00230     }
00231 
00232     // Save file name for later
00233     m_sFileName = sPathName;    
00234 
00235     return TRUE;
00236 }
00237 BOOL CScriptEditorView::DoFileSaveAs () 
00238 {
00239     static TCHAR szFilter[] = "OZ Script files (*.zes;*.inc)|*.zes; *.inc|All Files (*.*)|*.*||";
00240     CSSFileDialog wndFileDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter, m_hWnd);
00241     
00242     if(IDOK == wndFileDialog.DoModal()) {
00243         if(!DoFileSave (wndFileDialog.m_ofn.lpstrFile)) {
00244             return FALSE;
00245         }
00246         // save the title
00247         //m_sTitle = wndFileDialog.GetFileTitle ();
00248         // save the title
00249         //m_sFilename = wndFileDialog.GetFileTitle();
00250         return TRUE;
00251     }
00252     return FALSE;
00253 }
00254 
00255 // Reload a file    
00256 BOOL CScriptEditorView::DoReload ()
00257 {
00258     // simply re-open the file we opend
00259     CME_CODE lRet = OpenFile(m_sFileName);
00260 
00261     if(CME_FAILED(lRet)) {      
00262         ATLTRACE(_T ( "Error: Failed to reload file: %s\n" ), m_sFileName);
00263         return FALSE;
00264     }
00265     return TRUE;
00266 }

Generated on Wed Apr 16 19:12:22 2003 for QuestDesigner by doxygen1.2.18