Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
EditorBase Class Reference

Base class that all "editors" should inherit from. More...

#include <editorbase.h>

Inheritance diagram for EditorBase:
Collaboration diagram for EditorBase:

Public Member Functions

 EditorBase (wxWindow *parent, const wxString &filename)
 
 ~EditorBase () override
 
void operator= (cb_optional const EditorBase &rhs)
 Don't use this. More...
 
virtual const wxStringGetFilename () const
 Get the editor's filename (if applicable). More...
 
virtual void SetFilename (const wxString &filename)
 Sets the editor's filename. More...
 
virtual const wxStringGetShortName () const
 Returns the editor's short name. More...
 
virtual bool GetModified () const
 Is it modified? More...
 
virtual void SetModified (bool=true)
 Set the modification status. More...
 
virtual const wxStringGetTitle ()
 The editor's title. More...
 
virtual void SetTitle (const wxString &newTitle)
 Set the editor's title. More...
 
virtual void Activate ()
 Activate this editor. More...
 
virtual bool QueryClose ()
 Can this be closed (destroyed)? More...
 
virtual bool Close ()
 Close this editor. More...
 
virtual bool Save ()
 Save contents. More...
 
virtual bool SaveAs ()
 Save editor contents under a different filename. More...
 
virtual bool IsBuiltinEditor () const
 Is this a built-in editor? More...
 
virtual bool ThereAreOthers () const
 Are there other editors besides this? More...
 
virtual void DisplayContextMenu (const wxPoint &position, ModuleType type=mtUnknown)
 Display context menu. More...
 
virtual bool VisibleToTree () const
 Should this kind of editor be visible in the open files tree? More...
 
virtual void GotoLine (int, bool=true)
 Move the caret at the specified line. More...
 
virtual void Undo ()
 Undo changes. More...
 
virtual void Redo ()
 Redo changes. More...
 
virtual void ClearHistory ()
 Clear Undo- (and Changebar-) history. More...
 
virtual void GotoNextChanged ()
 Goto next changed line. More...
 
virtual void GotoPreviousChanged ()
 Goto previous changed line. More...
 
virtual void SetChangeCollection (cb_optional bool collectChange)
 Enable or disable changebar. More...
 
virtual void Cut ()
 Cut selected text/object to clipboard. More...
 
virtual void Copy ()
 Copy selected text/object to clipboard. More...
 
virtual void Paste ()
 Paste selected text/object from clipboard. More...
 
virtual bool CanUndo () const
 Is there something to undo? More...
 
virtual bool CanRedo () const
 Is there something to redo? More...
 
virtual bool HasSelection () const
 Is there a selection? More...
 
virtual bool CanPaste () const
 Is there something to paste? More...
 
virtual bool IsReadOnly () const
 Is the editor read-only? More...
 
virtual void SetReadOnly (bool=true)
 Set the editor read-only. More...
 
virtual bool CanSelectAll () const
 Can the editor select everything? More...
 
virtual void SelectAll ()
 Select everything in the editor. More...
 
virtual bool IsContextMenuOpened () const
 Is there a context (right click) menu open. More...
 

Protected Member Functions

virtual void InitFilename (const wxString &filename)
 Initializes filename data. More...
 
virtual wxMenuCreateContextSubMenu (long id)
 Creates context submenus. More...
 
virtual void AddToContextMenu (cb_optional wxMenu *popup, cb_optional ModuleType type, cb_optional bool pluginsdone)
 Creates context menu items, both before and after creating plugins menu items. More...
 
virtual wxString CreateUniqueFilename ()
 Creates unique filename when asking to save the file. More...
 
virtual bool OnBeforeBuildContextMenu (cb_optional const wxPoint &position, cb_optional ModuleType type)
 Informs the editor we 're just about to create a context menu. More...
 
virtual void OnAfterBuildContextMenu (cb_optional ModuleType type)
 Informs the editor we 're done creating the context menu (just about to display it). More...
 

Protected Attributes

bool m_IsBuiltinEditor
 
wxString m_Shortname
 
wxString m_Filename
 
EditorBaseInternalDatam_pData
 Use this to add new vars/functions w/out breaking the ABI. More...
 

Private Member Functions

 EditorBase (cb_unused const EditorBase &rhs)
 
void OnContextMenuEntry (wxCommandEvent &event)
 one event handler for all popup menu entries More...
 
void BasicAddToContextMenu (wxMenu *popup, ModuleType type)
 

Private Attributes

SwitchToMap m_SwitchTo
 
wxString m_WinTitle
 
wxString lastWord
 

Detailed Description

Base class that all "editors" should inherit from.

Note
This class descends from wxPanel, so it provides all wxPanel methods as well...

Definition at line 30 of file editorbase.h.

Constructor & Destructor Documentation

◆ EditorBase() [1/2]

EditorBase::EditorBase ( wxWindow parent,
const wxString filename 
)

◆ ~EditorBase()

EditorBase::~EditorBase ( )
override

◆ EditorBase() [2/2]

EditorBase::EditorBase ( cb_unused const EditorBase rhs)
private

Member Function Documentation

◆ Activate()

void EditorBase::Activate ( )
virtual

◆ AddToContextMenu()

virtual void EditorBase::AddToContextMenu ( cb_optional wxMenu popup,
cb_optional ModuleType  type,
cb_optional bool  pluginsdone 
)
inlineprotectedvirtual

Creates context menu items, both before and after creating plugins menu items.

Parameters
popupThe popup menu.
typeThe module's type.
pluginsdoneTrue if plugin menus have been created, false if not.

Definition at line 257 of file editorbase.h.

Referenced by DisplayContextMenu(), and cbEditor::GetLastModificationTime().

◆ BasicAddToContextMenu()

void EditorBase::BasicAddToContextMenu ( wxMenu popup,
ModuleType  type 
)
private

◆ CanPaste()

virtual bool EditorBase::CanPaste ( ) const
inlinevirtual

Is there something to paste?

Returns
True if there is something to paste, false if not.

Reimplemented in cbEditor.

Definition at line 211 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditMenuUpdateUI(), and ScriptBindings::RegisterBindings().

◆ CanRedo()

virtual bool EditorBase::CanRedo ( ) const
inlinevirtual

Is there something to redo?

Returns
True if there is something to redo, false if not.

Reimplemented in cbEditor.

Definition at line 199 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditMenuUpdateUI(), and ScriptBindings::RegisterBindings().

◆ CanSelectAll()

virtual bool EditorBase::CanSelectAll ( ) const
inlinevirtual

Can the editor select everything?

Returns
True if the editor can select all content, false if not.

Reimplemented in cbEditor.

Definition at line 229 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), and MainFrame::OnEditMenuUpdateUI().

◆ CanUndo()

virtual bool EditorBase::CanUndo ( ) const
inlinevirtual

Is there something to undo?

Returns
True if there is something to undo, false if not.

Reimplemented in cbEditor.

Definition at line 193 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditMenuUpdateUI(), MainFrame::OnEditUndo(), and ScriptBindings::RegisterBindings().

◆ ClearHistory()

virtual void EditorBase::ClearHistory ( )
inlinevirtual

Clear Undo- (and Changebar-) history.

Reimplemented in cbEditor.

Definition at line 169 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), and MainFrame::OnEditClearHistory().

◆ Close()

bool EditorBase::Close ( )
virtual

Close this editor.

The default implementation closes (destroys) the editor and returns true.

Returns
True if editor closed successfully

Definition at line 203 of file editorbase.cpp.

Referenced by EditorManager::CheckForExternallyModifiedFiles(), and ScriptBindings::RegisterBindings().

◆ Copy()

virtual void EditorBase::Copy ( )
inlinevirtual

Copy selected text/object to clipboard.

Reimplemented in cbEditor.

Definition at line 184 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditCopy(), and ScriptBindings::RegisterBindings().

◆ CreateContextSubMenu()

wxMenu * EditorBase::CreateContextSubMenu ( long  id)
protectedvirtual

Creates context submenus.

See cbEditor code for details.

Parameters
idAn event handler's ID.
Returns
The created submenu or NULL if not applicable.

Reimplemented in cbEditor.

Definition at line 219 of file editorbase.cpp.

References wxMenu::Append(), EditorMaxSwitchTo, Manager::Get(), EditorManager::GetEditor(), Manager::GetEditorManager(), EditorManager::GetEditorsCount(), wxMenu::GetMenuItemCount(), GetModified(), GetShortName(), idSwitchFile1, idSwitchTo, m_SwitchTo, wxEmptyString, and wxT.

Referenced by BasicAddToContextMenu(), cbEditor::CreateContextSubMenu(), DisplayContextMenu(), and cbEditor::GetLastModificationTime().

◆ CreateUniqueFilename()

wxString EditorBase::CreateUniqueFilename ( )
protectedvirtual

Creates unique filename when asking to save the file.

Returns
A unique filename suggestion.

Definition at line 96 of file editorbase.cpp.

References _(), _T, wxString::Clear(), wxString::Format(), Manager::Get(), wxFileExists(), and wxGetCwd().

◆ Cut()

virtual void EditorBase::Cut ( )
inlinevirtual

Cut selected text/object to clipboard.

Reimplemented in cbEditor.

Definition at line 181 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditCut(), and ScriptBindings::RegisterBindings().

◆ DisplayContextMenu()

void EditorBase::DisplayContextMenu ( const wxPoint position,
ModuleType  type = mtUnknown 
)
virtual

◆ GetFilename()

virtual const wxString& EditorBase::GetFilename ( ) const
inlinevirtual

Get the editor's filename (if applicable).

Returns
The editor's filename.

Definition at line 45 of file editorbase.h.

Referenced by NativeParser::AddProjectToParser(), EditorColourSet::Apply(), EditorManager::CheckForExternallyModifiedFiles(), CrashHandlerSaveEditorFiles(), CodeCompletion::DoAllMethodsImpl(), CompilerGCC::DoBuild(), CodeCompletion::DoClassMethodDeclImpl(), CodeCompletion::DoCodeComplete(), CodeCompletion::DoCodeCompleteIncludes(), CodeRefactoring::DoFindReferences(), MainFrame::DoOpenFile(), MainFrame::DoUpdateStatusBar(), cbDebuggerPlugin::EditorLinesAddedOrRemoved(), FindReplace::FindInFiles(), NativeParser::GetCallTips(), MainFrame::GetEditorDescription(), CodeRefactoring::GetOpenedFiles(), NativeParser::GetProjectByEditor(), CodeCompletion::GetProviderStatusFor(), EditorManager::IsOpen(), FileManager::Load(), NativeParser::MarkItemsByAI(), EditorManager::New(), CompilerGCC::OnCompileFileRequest(), cbEditor::OnContextMenuEntry(), NativeParser::OnEditorActivated(), CodeCompletion::OnEditorActivatedTimer(), CodeCompletion::OnEditorClosed(), NativeParser::OnEditorClosed(), CodeCompletion::OnEditorOpen(), cbDebuggerPlugin::OnEditorOpened(), CodeCompletion::OnOpenIncludeFile(), CodeCompletion::OnReparsingTimer(), DebuggerMenuHandler::OnRunToCursor(), DebuggerMenuHandler::OnSetNextStatement(), EditorManager::Open(), EditorManager::OpenContainingFolder(), CodeRefactoring::Parse(), CodeCompletion::ParseFunctionsAndFillToolbar(), CompilerGCC::PrepareCompileFile(), QueryClose(), MacrosManager::RecalcVars(), cbEditor::RefreshBreakpointMarkers(), ScriptBindings::RegisterBindings(), FindReplace::ReplaceInFiles(), MacrosManager::ReplaceMacros(), cbEditor::Save(), EditorManager::SaveAll(), cbEditor::SetProjectFile(), SetTitle(), EditorManager::SwapActiveHeaderSource(), ClassBrowser::UpdateClassBrowserView(), and CodeCompletion::UpdateEditorSyntax().

◆ GetModified()

virtual bool EditorBase::GetModified ( ) const
inlinevirtual

Is it modified?

Returns
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.

Reimplemented in cbEditor.

Definition at line 67 of file editorbase.h.

Referenced by BasicAddToContextMenu(), CreateContextSubMenu(), cbEditor::IsOK(), MainFrame::OnFileMenuUpdateUI(), EditorManager::OnPageContextMenu(), QueryClose(), ScriptBindings::RegisterBindings(), and EditorManager::SaveAll().

◆ GetShortName()

virtual const wxString& EditorBase::GetShortName ( ) const
inlinevirtual

◆ GetTitle()

const wxString & EditorBase::GetTitle ( )
virtual

The editor's title.

Returns
The editor's title.

Definition at line 144 of file editorbase.cpp.

References m_WinTitle.

Referenced by EditorManager::AddEditorBase(), MainFrame::DoUpdateAppTitle(), and ScriptBindings::RegisterBindings().

◆ GotoLine()

virtual void EditorBase::GotoLine ( int  ,
bool  = true 
)
inlinevirtual

Move the caret at the specified line.

Parameters
lineThe line to move the caret to.
centerOnScreenIf 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.

Reimplemented in cbEditor.

Definition at line 160 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), CodeBlocksApp::LoadDelayedFiles(), and ScriptBindings::RegisterBindings().

◆ GotoNextChanged()

virtual void EditorBase::GotoNextChanged ( )
inlinevirtual

Goto next changed line.

Reimplemented in cbEditor.

Definition at line 172 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime().

◆ GotoPreviousChanged()

virtual void EditorBase::GotoPreviousChanged ( )
inlinevirtual

Goto previous changed line.

Reimplemented in cbEditor.

Definition at line 175 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime().

◆ HasSelection()

virtual bool EditorBase::HasSelection ( ) const
inlinevirtual

Is there a selection?

Returns
True if there is text/object selected, false if not.

Reimplemented in cbEditor.

Definition at line 205 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditMenuUpdateUI(), and ScriptBindings::RegisterBindings().

◆ InitFilename()

void EditorBase::InitFilename ( const wxString filename)
protectedvirtual

Initializes filename data.

Parameters
filenameThe editor's filename for initialization.

Definition at line 84 of file editorbase.cpp.

References wxFileName::Assign(), wxFileName::GetFullName(), and realpath().

Referenced by cbEditor::DoInitializations(), and EditorBase().

◆ IsBuiltinEditor()

bool EditorBase::IsBuiltinEditor ( ) const
virtual

◆ IsContextMenuOpened()

bool EditorBase::IsContextMenuOpened ( ) const
virtual

Is there a context (right click) menu open.

Returns
True if a context menu is open, false if not.

Definition at line 441 of file editorbase.cpp.

References EditorBaseInternalData::m_DisplayingPopupMenu, and m_pData.

Referenced by CCManager::OnEditorTooltip(), and cbDebuggerPlugin::ProcessValueTooltip().

◆ IsReadOnly()

virtual bool EditorBase::IsReadOnly ( ) const
inlinevirtual

Is the editor read-only?

Returns
True if the editor is read-only, false if not.

Reimplemented in cbEditor.

Definition at line 217 of file editorbase.h.

Referenced by EditorManager::CheckForExternallyModifiedFiles(), cbEditor::GetLastModificationTime(), MainFrame::OnEditMenuUpdateUI(), ScriptBindings::RegisterBindings(), and SetTitle().

◆ OnAfterBuildContextMenu()

virtual void EditorBase::OnAfterBuildContextMenu ( cb_optional ModuleType  type)
inlineprotectedvirtual

Informs the editor we 're done creating the context menu (just about to display it).

Default implementation does nothing.

Parameters
typespecifies the "ModuleType" context popup menu.

Definition at line 276 of file editorbase.h.

Referenced by DisplayContextMenu().

◆ OnBeforeBuildContextMenu()

virtual bool EditorBase::OnBeforeBuildContextMenu ( cb_optional const wxPoint position,
cb_optional ModuleType  type 
)
inlineprotectedvirtual

Informs the editor we 're just about to create a context menu.

Default implementation, just returns true.

Parameters
positionspecifies the position of the popup menu.
typespecifies the "ModuleType" popup menu.
Returns
If the editor returns false, the context menu creation is aborted.

Definition at line 270 of file editorbase.h.

Referenced by DisplayContextMenu(), and cbEditor::OnBeforeBuildContextMenu().

◆ OnContextMenuEntry()

void EditorBase::OnContextMenuEntry ( wxCommandEvent event)
private

◆ operator=()

void EditorBase::operator= ( cb_optional const EditorBase rhs)
inline

Don't use this.

It throws an exception if you do.

Definition at line 39 of file editorbase.h.

References _T, and cbThrow.

◆ Paste()

virtual void EditorBase::Paste ( )
inlinevirtual

Paste selected text/object from clipboard.

Reimplemented in cbEditor.

Definition at line 187 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditPaste(), and ScriptBindings::RegisterBindings().

◆ QueryClose()

bool EditorBase::QueryClose ( )
virtual

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).

Returns
True if this editor can be closed.

Definition at line 180 of file editorbase.cpp.

References _(), cbMessageBox(), GetFilename(), GetModified(), wxString::Printf(), Save(), SetModified(), wxCANCEL, wxICON_QUESTION, wxID_CANCEL, wxID_NO, wxID_YES, and wxYES_NO.

Referenced by EditorManager::QueryClose().

◆ Redo()

virtual void EditorBase::Redo ( )
inlinevirtual

Redo changes.

Reimplemented in cbEditor.

Definition at line 166 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditRedo(), and ScriptBindings::RegisterBindings().

◆ Save()

virtual bool EditorBase::Save ( )
inlinevirtual

Save contents.

Save the editor's contents. The default implementation does nothing and returns true.

Returns
True on success, false otherwise.

Reimplemented in cbEditor.

Definition at line 113 of file editorbase.h.

Referenced by EditorManager::CheckForExternallyModifiedFiles(), cbEditor::GetProjectFile(), OnContextMenuEntry(), QueryClose(), ScriptBindings::RegisterBindings(), EditorManager::Save(), EditorManager::SaveActive(), and EditorManager::SaveAll().

◆ SaveAs()

virtual bool EditorBase::SaveAs ( )
inlinevirtual

Save editor contents under a different filename.

Save editor contents under a different filename. The default implementation does nothing and returns true.

Returns
True on success, false otherwise.

Reimplemented in cbEditor.

Definition at line 120 of file editorbase.h.

References mtUnknown.

Referenced by cbEditor::GetProjectFile(), EditorManager::SaveActiveAs(), and EditorManager::SaveAs().

◆ SelectAll()

virtual void EditorBase::SelectAll ( )
inlinevirtual

Select everything in the editor.

Reimplemented in cbEditor.

Definition at line 233 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), and MainFrame::OnEditSelectAll().

◆ SetChangeCollection()

virtual void EditorBase::SetChangeCollection ( cb_optional bool  collectChange)
inlinevirtual

Enable or disable changebar.

Definition at line 178 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime().

◆ SetFilename()

virtual void EditorBase::SetFilename ( const wxString filename)
inlinevirtual

Sets the editor's filename.

Parameters
filenameThe filename to set.

Definition at line 50 of file editorbase.h.

Referenced by NewFromTemplateDlg::EditScript(), and ScriptBindings::RegisterBindings().

◆ SetModified()

virtual void EditorBase::SetModified ( bool  = true)
inlinevirtual

Set the modification status.

Parameters
modifiedIf true, mark as modified. If false, mark as clean (unmodified).

Reimplemented in cbEditor.

Definition at line 73 of file editorbase.h.

Referenced by EditorManager::CheckForExternallyModifiedFiles(), cbEditor::IsOK(), QueryClose(), and ScriptBindings::RegisterBindings().

◆ SetReadOnly()

virtual void EditorBase::SetReadOnly ( bool  = true)
inlinevirtual

Set the editor read-only.

Parameters
readonlyIf true, mark as readonly. If false, mark as read-write.

Reimplemented in cbEditor.

Definition at line 223 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime().

◆ SetTitle()

void EditorBase::SetTitle ( const wxString newTitle)
virtual

◆ ThereAreOthers()

bool EditorBase::ThereAreOthers ( ) const
virtual

Are there other editors besides this?

Returns
True if there are more editors open, false otherwise.

Definition at line 214 of file editorbase.cpp.

References Manager::Get().

Referenced by BasicAddToContextMenu(), and ScriptBindings::RegisterBindings().

◆ Undo()

virtual void EditorBase::Undo ( )
inlinevirtual

Undo changes.

Reimplemented in cbEditor.

Definition at line 163 of file editorbase.h.

Referenced by cbEditor::GetLastModificationTime(), MainFrame::OnEditUndo(), and ScriptBindings::RegisterBindings().

◆ VisibleToTree()

virtual bool EditorBase::VisibleToTree ( ) const
inlinevirtual

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...

Returns
True if it should be visible in the open files tree, false if not.

Reimplemented in StartHerePage.

Definition at line 151 of file editorbase.h.

Member Data Documentation

◆ lastWord

wxString EditorBase::lastWord
private

Definition at line 290 of file editorbase.h.

Referenced by DisplayContextMenu(), and OnContextMenuEntry().

◆ m_Filename

wxString EditorBase::m_Filename
protected

◆ m_IsBuiltinEditor

bool EditorBase::m_IsBuiltinEditor
protected

Definition at line 278 of file editorbase.h.

Referenced by cbEditor::DoInitializations(), and IsBuiltinEditor().

◆ m_pData

EditorBaseInternalData* EditorBase::m_pData
protected

Use this to add new vars/functions w/out breaking the ABI.

Definition at line 281 of file editorbase.h.

Referenced by DisplayContextMenu(), EditorBase(), IsContextMenuOpened(), OnContextMenuEntry(), and ~EditorBase().

◆ m_Shortname

wxString EditorBase::m_Shortname
protected

◆ m_SwitchTo

SwitchToMap EditorBase::m_SwitchTo
private

Definition at line 288 of file editorbase.h.

Referenced by CreateContextSubMenu(), and OnContextMenuEntry().

◆ m_WinTitle

wxString EditorBase::m_WinTitle
private

Definition at line 289 of file editorbase.h.

Referenced by GetTitle(), and SetTitle().


The documentation for this class was generated from the following files: