1 #ifndef HEADER_CAE2DA833173DBFA
2 #define HEADER_CAE2DA833173DBFA
3 
4 /***************************************************************
5  * Name:      NassiShneiderman
6  * Purpose:   Code::Blocks plugin
7  * Author:    Daniel Anselmi (danselmi@NOSPAM@gmx.ch)
8  * Created:   2008-10-23
9  * Copyright: Daniel Anselmi
10  * License:   GPL
11  **************************************************************/
12 
13 #ifndef NASSISHNEIDERMAN_H_INCLUDED
14 #define NASSISHNEIDERMAN_H_INCLUDED
15 
16 // For compilers that support precompilation, includes <wx/wx.h>
17 #include <wx/wxprec.h>
18 
19 #ifndef WX_PRECOMP
20     #include <wx/wx.h>
21 #endif
22 
23 #include <cbplugin.h> // for "class cbMimePlugin"
24 
25 class NassiPlugin : public cbMimePlugin
26 {
27      public:
28         /** Constructor. */
29         NassiPlugin();
30         /** Destructor. */
31         virtual ~NassiPlugin();
32     private:
33         NassiPlugin(const NassiPlugin &p);
34         NassiPlugin &operator=(const NassiPlugin &rhs);
35 
36     /// configuration interface
37     //{
38 
39         /** Return the plugin's configuration priority.
40           * This is a number (default is 50) that is used to sort plugins
41           * in configuration dialogs. Lower numbers mean the plugin's
42           * configuration is put higher in the list.
43           */
GetConfigurationPriority()44         virtual int GetConfigurationPriority() const { return 50; }
45 
46         /** Return the configuration group for this plugin. Default is cgUnknown.
47           * Notice that you can logically OR more than one configuration groups,
48           * so you could set it, for example, as "cgCompiler | cgContribPlugin".
49           */
GetConfigurationGroup()50         virtual int GetConfigurationGroup() const { return cgUnknown; }
51 
52         /** Return plugin's configuration panel.
53           * @param parent The parent window.
54           * @return A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.
55           */
GetConfigurationPanel(wxWindow *)56         virtual cbConfigurationPanel* GetConfigurationPanel(wxWindow* /*parent*/){ return 0; }
57 
58         /** Return plugin's configuration panel for projects.
59           * The panel returned from this function will be added in the project's
60           * configuration dialog.
61           * @param parent The parent window.
62           * @param project The project that is being edited.
63           * @return A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.
64           */
GetProjectConfigurationPanel(wxWindow *,cbProject *)65         virtual cbConfigurationPanel* GetProjectConfigurationPanel(wxWindow* /*parent*/, cbProject* /*project*/){ return 0; }//}
66 
67 
68     /// gui interface
69     //{
70         /** This method is called by Code::Blocks and is used by the plugin
71           * to add any menu items it needs on Code::Blocks's menu bar.\n
72           * It is a pure virtual method that needs to be implemented by all
73           * plugins. If the plugin does not need to add items on the menu,
74           * just do nothing ;)
75           * @param menuBar the wxMenuBar to create items in
76           */
77         virtual void BuildMenu(wxMenuBar* menuBar);
78 
79         /** This method is called by Code::Blocks core modules (EditorManager,
80           * ProjectManager etc) and is used by the plugin to add any menu
81           * items it needs in the module's popup menu. For example, when
82           * the user right-clicks on a project file in the project tree,
83           * ProjectManager prepares a popup menu to display with context
84           * sensitive options for that file. Before it displays this popup
85           * menu, it asks all attached plugins (by asking PluginManager to call
86           * this method), if they need to add any entries
87           * in that menu. This method is called.\n
88           * If the plugin does not need to add items in the menu,
89           * just do nothing ;)
90           * @param type the module that's preparing a popup menu
91           * @param menu pointer to the popup menu
92           * @param data pointer to FileTreeData object (to access/modify the file tree)
93           */
94         virtual void BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data = 0);
95 
96         /** This method is called by Code::Blocks and is used by the plugin
97           * to add any toolbar items it needs on Code::Blocks's toolbar.\n
98           * It is a pure virtual method that needs to be implemented by all
99           * plugins. If the plugin does not need to add items on the toolbar,
100           * just do nothing ;)
101           * @param toolBar the wxToolBar to create items on
102           * @return The plugin should return true if it needed the toolbar, false if not
103           */
104         virtual bool BuildToolBar(wxToolBar* toolBar);
105     //}
106 
107 
108     /// mime interface
109     //{
110 
111         /** @brief Can a file be handled by this plugin?
112           *
113           * @param filename The file in question.
114           * @return The plugin should return true if it can handle this file,
115           * false if not.
116           */
117         virtual bool CanHandleFile(const wxString& filename) const;
118 
119         /** @brief Open the file.
120           *
121           * @param filename The file to open.
122           * @return The plugin should return zero on success, other value on error.
123           */
124         virtual int OpenFile(const wxString& filename);
HandlesEverything()125         virtual bool  HandlesEverything () const{return false;}
126     //}
127     protected:
128         /** Any descendent plugin should override this virtual method and
129           * perform any necessary initialization. This method is called by
130           * Code::Blocks (PluginManager actually) when the plugin has been
131           * loaded and should attach in Code::Blocks. When Code::Blocks
132           * starts up, it finds and <em>loads</em> all plugins but <em>does
133           * not</em> activate (attaches) them. It then activates all plugins
134           * that the user has selected to be activated on start-up.\n
135           * This means that a plugin might be loaded but <b>not</b> activated...\n
136           * Think of this method as the actual constructor...
137           */
138         virtual void OnAttach();
139 
140         /** Any descendent plugin should override this virtual method and
141           * perform any necessary de-initialization. This method is called by
142           * Code::Blocks (PluginManager actually) when the plugin has been
143           * loaded, attached and should de-attach from Code::Blocks.\n
144           * Think of this method as the actual destructor...
145           * @param appShutDown If true, the application is shutting down. In this
146           *         case *don't* use Manager::Get()->Get...() functions or the
147           *         behaviour is undefined...
148           */
149         virtual void OnRelease(bool appShutDown);
150 
151     private:
152         void OnUpdateTools(wxUpdateUIEvent &event);
153         void OnUpdateExport(wxUpdateUIEvent &event);
154         void OnUpdateZoom(wxUpdateUIEvent &event);
155 
156         void OnUpdateToggleText(wxUpdateUIEvent &event);
157         void OnToggleText(wxCommandEvent &event);
158         void OnChangeTool(wxCommandEvent &event);
159         void OnToolSelect(wxCommandEvent &event);
160 
161         void OnZoom(wxCommandEvent &event);
162         void OnExport(wxCommandEvent &event);
163 
164         void OnNewDiagram(wxCommandEvent &event);
165         void ParseC(wxCommandEvent &event);
166         void OnInsertCFromDiagram(wxCommandEvent &event);
167         void OnUpdateUIMenuItem(wxUpdateUIEvent &event);
168 
169         void OnSettingsChanged(CodeBlocksEvent &event);
170 
171         bool IsNassiEditorPanelActive();
172 
173     private:
174         DECLARE_EVENT_TABLE();
175 };
176 
177 
178 #endif // NASSISHNEIDERMAN_H_INCLUDED
179 
180 #endif // header guard
181