scripteditor.h

Go to the documentation of this file.
00001 /************************************************************************   
00002  *      ScriptEd.h - wrapper classes for script editor windows          *
00003  *                                                                      *
00004  *      Author: Ravi Karra                                              *
00005  ************************************************************************/
00006 
00007 #pragma once
00008 
00009 
00010 #include "..\util\listener.h"
00011 
00012 // defines for script editor window menu items
00013 #define IDM_NEW         10
00014 #define IDM_OPEN        11
00015 #define IDM_EVAL_ALL    40026
00016 #define IDM_CLOSE       40024
00017 
00018 // wrapper class for script editor windows
00019 class ScriptEditor
00020 {
00021         MCHAR*          editScript;
00022         MSTR            title;
00023     protected:
00024         WNDPROC         originalWndProc;        
00025         IntTab          disable_menus;
00026         edit_window     *ew;
00027         HWND            hScript;
00028     
00029     public:
00030         ScriptEditor(MCHAR* ititle=NULL) : 
00031             title(ititle), 
00032             ew(NULL), 
00033             hScript(NULL), 
00034             editScript(NULL) { }
00035 
00036         ScripterExport virtual ~ScriptEditor();
00037         
00038         virtual LRESULT APIENTRY proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { 
00039                             return CallWindowProc(originalWndProc, hwnd, uMsg, wParam, lParam); 
00040                             }
00041 
00042         ScripterExport virtual  HWND    DisplayWindow(HWND hParent=NULL/*for future use*/);
00043         ScripterExport virtual void     CloseWindow(bool notify=false);
00044         ScripterExport virtual const MCHAR* GetEditScript();
00045         ScripterExport virtual void     SetEditScript(const MCHAR* script);     
00046         ScripterExport virtual void     SetTitle(const MCHAR* t) { title = t; }                     
00047         ScripterExport virtual bool     OnFileOpen(HWND hwnd);
00048         ScripterExport virtual bool     OnClose(HWND hwnd);
00049         
00050         virtual const MCHAR*    GetTitle()          { return title; }
00051         virtual Value*  GetValueTitle()     { return (ew) ? ew->file_name : NULL; }
00053         virtual bool    OnExecute(HWND hwnd){ UNUSED_PARAM(hwnd); return false; } 
00054         virtual bool    IsDisplayed()       { return ew!=NULL; }
00055         virtual IntTab& GetDisabledMenuTab(){ return disable_menus; }
00056 };
00057 
00058 // open new editor on existing file, pop openfilename dialog if no filename supplied
00059 // if ew is NULL, a new editor window is opened. If openfilename dialog is opened, initial
00060 // path will be as specified by path arg, current path if NULL
00061 ScripterExport void open_script(const MCHAR* filename=NULL, edit_window *ew=NULL, const MCHAR* path=NULL);
00062 
00063 // open editor window on existing file, jump to specified character offset
00064 ScripterExport edit_window* show_editor_pos(const MCHAR* file_name, int pos);
00065 
00066 // returns existing edit_window for specified file name.
00067 ScripterExport edit_window* get_editor_window(const MCHAR* file_name);
00068 
00069 // open editor on existing file, jump to specified character offset
00070 ScripterExport bool show_editor_pos_ex(const MCHAR* file_name, int pos);
00071