/usr/include/codeblocks/editorbase.h is in codeblocks-dev 16.01+dfsg-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | /*
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
* http://www.gnu.org/licenses/lgpl-3.0.html
*/
#ifndef EDITORBASE_H
#define EDITORBASE_H
#include "prep.h"
#include <wx/hashmap.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include "globals.h"
#include "settings.h"
#include "cbexception.h"
class wxMenu;
class EditorBase;
struct EditorBaseInternalData;
class cbDebuggerPlugin;
WX_DECLARE_HASH_MAP(int, EditorBase*, wxIntegerHash, wxIntegerEqual, SwitchToMap);
/** @brief Base class that all "editors" should inherit from.
*
* @note This class descends from wxPanel, so it provides all wxPanel methods
* as well...
*/
class DLLIMPORT EditorBase : public wxPanel
{
DECLARE_EVENT_TABLE()
public:
EditorBase(wxWindow* parent, const wxString& filename);
virtual ~EditorBase();
/** Don't use this. It throws an exception if you do. */
void operator=(cb_optional const EditorBase& rhs){ cbThrow(_T("Can't assign an EditorBase* !!!")); }
/** @brief Get the editor's filename (if applicable).
*
* @return The editor's filename.
*/
virtual const wxString& GetFilename() const { return m_Filename; }
/** @brief Sets the editor's filename.
* @param filename The filename to set.
*/
virtual void SetFilename(const wxString& filename){ m_Filename = filename; }
/** @brief Returns the editor's short name.
*
* This is the name displayed on the editor's tab...
*
* Synonym to GetTitle().
*/
virtual const wxString& GetShortName() const { return m_Shortname; }
/** @brief Is it modified?
*
* @return true If editor is modified, false otherwise.
* @note This function should always be overriden by implementations
* because the default implementation in EditorBase always
* returns false.
*/
virtual bool GetModified() const { return false; }
/** @brief Set the modification status.
*
* @param modified If true, mark as modified. If false, mark as clean (unmodified).
*/
virtual void SetModified(bool /*modified*/ = true) {}
/** @brief The editor's title.
*
* @return The editor's title.
*/
virtual const wxString& GetTitle();
/** @brief Set the editor's title.
*
* @param newTitle The new title to set.
*/
virtual void SetTitle(const wxString& newTitle);
/** @brief Activate this editor.
*
* Causes this editor to be activated, i.e. brought to front.
*/
virtual void Activate();
/** @brief Can this be closed (destroyed)?
*
* This is used internally and queries the editor if it is safe to
* close it (i.e. it is not modified).
* @return True if this editor can be closed.
*/
virtual bool QueryClose();
/** @brief Close this editor.
*
* The default implementation closes (destroys) the editor and returns true.
* @return True if editor closed successfully
*/
virtual bool Close();
/** @brief Save contents.
*
* Save the editor's contents. The default implementation does nothing
* and returns true.
* @return True on success, false otherwise. */
virtual bool Save() { return true; }
/** @brief Save editor contents under a different filename.
*
* Save editor contents under a different filename.
* The default implementation does nothing and returns true.
* @return True on success, false otherwise. */
virtual bool SaveAs() { return true; }
/** @brief Is this a built-in editor?
*
* Query if this is a built-in editor (a.k.a cbEditor).
* @return True if it is a cbEditor, false otherwise.
*/
virtual bool IsBuiltinEditor() const;
/** @brief Are there other editors besides this?
* @return True if there are more editors open, false otherwise.
*/
virtual bool ThereAreOthers() const;
/** @brief Display context menu.
*
* Displays the editor's context menu. This is called automatically
* if the user right-clicks in the editor area.
* @param position The position to popup the context menu.
* @param type The module's type.
*/
virtual void DisplayContextMenu(const wxPoint& position, ModuleType type = mtUnknown);
/** Should this kind of editor be visible in the open files tree?
*
* There are rare cases where an editor should not be visible in the
* open files tree. One such example is the "Start here" page...
*
* @return True if it should be visible in the open files tree, false
* if not.
*/
virtual bool VisibleToTree() const { return true; }
/** Move the caret at the specified line.
*
* @param line The line to move the caret to.
* @param centerOnScreen If true, the line in question will be in the center
* of the editor's area (if possible). If false,
* it will be just made visible.
*/
virtual void GotoLine(int /*line*/, bool /*centerOnScreen*/ = true){}
/** Toggle breakpoint at specified line.
* @param line The line to toggle the breakpoint on. If @c line is -1,
* use current line.
* @param notifyDebugger If true (and a debugger plugin is loaded),
* tell the debugger about this breakpoint.
*/
virtual void ToggleBreakpoint(int /*line*/ = -1, bool /*notifyDebugger*/ = true){}
/** Does @c line has breakpoint?
* @param line The line to check for breakpoint existence.
* @return True if there is a breakpoint on this line, false if not.
*/
virtual bool HasBreakpoint(cb_optional int line) const { return false; }
/** Go to next breakpoint. */
virtual void GotoNextBreakpoint(){}
/** Go to previous breakpoint. */
virtual void GotoPreviousBreakpoint(){}
/** Refresh all markers for the breakpoints (only the markers for the current debugger will be shown) */
virtual void RefreshBreakpointMarkers(){}
/** Toggle bookmark at specified line.
* @param line The line to toggle the bookmark on. If @c line is -1,
* use current line.
*/
virtual void ToggleBookmark(int /*line*/ = -1){}
/** Does @c line has bookmark?
* @param line The line to check for bookmark existence.
* @return True if there is a bookmark on this line, false if not.
*/
virtual bool HasBookmark(cb_optional int line) const { return false; }
/** Go to next bookmark. */
virtual void GotoNextBookmark(){}
/** Go to previous bookmark. */
virtual void GotoPreviousBookmark(){}
/** @brief Mark the debugger's active line.
*
* Highlight the line the debugger will execute next.
* @param line The line in question.
*/
virtual void SetDebugLine(cb_optional int line){}
/** @brief Mark line as error.
*
* Highlight the specified line as compiler error.
* @param line The line in question.
*/
virtual void SetErrorLine(cb_optional int line){}
/** Undo changes. */
virtual void Undo(){}
/** Redo changes. */
virtual void Redo(){}
/** Clear Undo- (and Changebar-) history */
virtual void ClearHistory(){}
/** Goto next changed line */
virtual void GotoNextChanged(){}
/** Goto previous changed line */
virtual void GotoPreviousChanged(){}
/** Enable or disable changebar */
virtual void SetChangeCollection(cb_optional bool collectChange){}
/** Cut selected text/object to clipboard. */
virtual void Cut(){}
/** Copy selected text/object to clipboard. */
virtual void Copy(){}
/** Paste selected text/object from clipboard. */
virtual void Paste(){}
/** Is there something to undo?
*
* @return True if there is something to undo, false if not.
*/
virtual bool CanUndo() const { return false; }
/** Is there something to redo?
*
* @return True if there is something to redo, false if not.
*/
virtual bool CanRedo() const { return false; }
/** Is there a selection?
*
* @return True if there is text/object selected, false if not.
*/
virtual bool HasSelection() const { return false; }
/** Is there something to paste?
*
* @return True if there is something to paste, false if not.
*/
virtual bool CanPaste() const { return false; }
/** Is the editor read-only?
*
* @return True if the editor is read-only, false if not.
*/
virtual bool IsReadOnly() const { return false; }
/** Set the editor read-only.
*
* @param readonly If true, mark as readonly. If false, mark as read-write.
*/
virtual void SetReadOnly(bool /*readonly*/ = true) {}
/** Can the editor select everything?
*
* @return True if the editor can select all content, false if not.
*/
virtual bool CanSelectAll() const { return false; }
/** Select everything in the editor
*/
virtual void SelectAll() { return; }
/** Is there a context (right click) menu open
*
* @return True if a context menu is open, false if not.
*/
virtual bool IsContextMenuOpened() const;
protected:
/** Initializes filename data.
* @param filename The editor's filename for initialization.
*/
virtual void InitFilename(const wxString& filename);
/** Creates context submenus. See cbEditor code for details.
* @param id An event handler's ID.
* @return The created submenu or NULL if not applicable.
*/
virtual wxMenu* CreateContextSubMenu(long id); // For context menus
/** Creates context menu items, both before and after creating plugins menu items.
* @param popup The popup menu.
* @param type The module's type.
* @param pluginsdone True if plugin menus have been created, false if not.
*/
virtual void AddToContextMenu(cb_optional wxMenu* popup, cb_optional ModuleType type, cb_optional bool pluginsdone) {}
/** Creates unique filename when asking to save the file.
* @return A unique filename suggestion.
*/
virtual wxString CreateUniqueFilename();
/** Informs the editor we 're just about to create a context menu.
* Default implementation, just returns true.
* @param position specifies the position of the popup menu.
* @param type specifies the "ModuleType" popup menu.
* @return If the editor returns false, the context menu creation is aborted.
*/
virtual bool OnBeforeBuildContextMenu(cb_optional const wxPoint& position, cb_optional ModuleType type){ return true; }
/** Informs the editor we 're done creating the context menu (just about to display it).
* Default implementation does nothing.
* @param type specifies the "ModuleType" context popup menu.
*/
virtual void OnAfterBuildContextMenu(cb_optional ModuleType type){}
bool m_IsBuiltinEditor; // do not mess with it!
wxString m_Shortname;
wxString m_Filename;
EditorBaseInternalData* m_pData; ///< Use this to add new vars/functions w/out breaking the ABI
private:
EditorBase(cb_unused const EditorBase& rhs); // prevent copy construction
/** one event handler for all popup menu entries */
void OnContextMenuEntry(wxCommandEvent& event);
void BasicAddToContextMenu(wxMenu* popup, ModuleType type); //pecan 2006/03/22
SwitchToMap m_SwitchTo;
wxString m_WinTitle;
wxString lastWord;
};
#endif // EDITORBASE_H
|