UI Class Reference

Back to the index.

Classes | Public Member Functions | Protected Attributes | List of all members
UI Class Referenceabstract

Base class for a User Interface. More...

#include <UI.h>

Inheritance diagram for UI:
ReferenceCountable ConsoleUI NullUI

Classes

class  SetIndentationMessageHelper
 

Public Member Functions

 UI (GXemul *gxemul)
 Constructs a User Interface. More...
 
virtual ~UI ()
 
virtual void Initialize ()=0
 Initializes the UI. More...
 
virtual void ShowStartupBanner ()=0
 Shows a startup banner. More...
 
virtual void UpdateUI ()=0
 Updates various UI elements. More...
 
void SetIndentationMessage (const string &msg)
 Sets an indentation message, which indents all debug output. More...
 
string GetIndentationMessage () const
 Gets the indentation message. More...
 
virtual void ShowDebugMessage (const string &msg)=0
 Shows a debug message. More...
 
virtual void ShowDebugMessage (Component *component, const string &msg)=0
 Shows a debug message for a Component. More...
 
virtual void ShowCommandMessage (const string &command)=0
 Shows a command being executed. More...
 
virtual void FatalError (const string &msg)=0
 Shows a fatal error message. More...
 
virtual void RedisplayInputLine (const string &inputline, size_t cursorPosition)=0
 Redisplays the interactive command input line. More...
 
virtual void InputLineDone ()=0
 Executed by the CommandInterpreter when a line has been completed (with a newline). More...
 
virtual int MainLoop ()=0
 Runs the UI's main loop. More...
 
virtual void Shutdown ()=0
 Shuts down the UI. More...
 
- Public Member Functions inherited from ReferenceCountable
 ReferenceCountable ()
 Default constructor, which initializes the reference count to zero. More...
 
 ~ReferenceCountable ()
 

Protected Attributes

GXemulm_gxemul
 
string m_indentationMsg
 

Detailed Description

Base class for a User Interface.

Definition at line 40 of file UI.h.

Constructor & Destructor Documentation

◆ UI()

UI::UI ( GXemul gxemul)
inline

Constructs a User Interface.

Parameters
gxemulA pointer to the GXemul owner instance.

Definition at line 70 of file UI.h.

◆ ~UI()

virtual UI::~UI ( )
inlinevirtual

Definition at line 75 of file UI.h.

References Initialize(), ShowStartupBanner(), and UpdateUI().

Member Function Documentation

◆ FatalError()

virtual void UI::FatalError ( const string &  msg)
pure virtual

Shows a fatal error message.

After showing the fatal error message, the application is expected to terminate. In a GUI implementation, it is therefore good to wait for the user to acknowledge the error message before returning.

Parameters
msgThe message to show.

Implemented in ConsoleUI, and NullUI.

Referenced by GetIndentationMessage(), and GXemul::Run().

◆ GetIndentationMessage()

string UI::GetIndentationMessage ( ) const
inline

Gets the indentation message.

Returns
The indentation message. If the message is an empty string, indentation is not used.

Definition at line 121 of file UI.h.

References FatalError(), InputLineDone(), m_indentationMsg, MainLoop(), RedisplayInputLine(), ShowCommandMessage(), ShowDebugMessage(), and Shutdown().

Referenced by UI::SetIndentationMessageHelper::SetIndentationMessageHelper().

◆ Initialize()

virtual void UI::Initialize ( )
pure virtual

Initializes the UI.

Implemented in ConsoleUI, and NullUI.

Referenced by GXemul::InitUI(), and ~UI().

◆ InputLineDone()

virtual void UI::InputLineDone ( )
pure virtual

Executed by the CommandInterpreter when a line has been completed (with a newline).

Usually this clears the current line, and (if possible) moves down to a new line.

Implemented in ConsoleUI, and NullUI.

Referenced by CommandInterpreter::AddKey(), and GetIndentationMessage().

◆ MainLoop()

virtual int UI::MainLoop ( )
pure virtual

Runs the UI's main loop.

The return code should be the exit code that the gxemul binary should return.

Returns
0 on success, non-zero on failure.

Implemented in ConsoleUI, and NullUI.

Referenced by GetIndentationMessage(), and GXemul::Run().

◆ RedisplayInputLine()

virtual void UI::RedisplayInputLine ( const string &  inputline,
size_t  cursorPosition 
)
pure virtual

Redisplays the interactive command input line.

This function generally displays a prompt (e.g. "GXemul> ") followed by the input line, placing the cursor position at the correct position on the input line.

Parameters
inputlineThe entire input line.
cursorPositionThe current cursor position. 0 is at the leftmost position.

Implemented in ConsoleUI, and NullUI.

Referenced by GetIndentationMessage(), and CommandInterpreter::ReshowCurrentCommandBuffer().

◆ SetIndentationMessage()

void UI::SetIndentationMessage ( const string &  msg)
inline

Sets an indentation message, which indents all debug output.

Note: An UI implementation may change the indentation string. E.g. from "step X: " to " ".

Parameters
msgThe indentation message. If the message is an empty string, indentation is not used.

Definition at line 110 of file UI.h.

References m_indentationMsg.

Referenced by UI::SetIndentationMessageHelper::SetIndentationMessageHelper(), and UI::SetIndentationMessageHelper::~SetIndentationMessageHelper().

◆ ShowCommandMessage()

virtual void UI::ShowCommandMessage ( const string &  command)
pure virtual

Shows a command being executed.

Parameters
commandThe command being executed.

Implemented in ConsoleUI, and NullUI.

Referenced by GetIndentationMessage().

◆ ShowDebugMessage() [1/2]

virtual void UI::ShowDebugMessage ( const string &  msg)
pure virtual

◆ ShowDebugMessage() [2/2]

virtual void UI::ShowDebugMessage ( Component component,
const string &  msg 
)
pure virtual

Shows a debug message for a Component.

Usually, this involves formatting the debug message using Component::GenerateShortestPossiblePath().

If the runstate is GXemul::Running, the debug message is encapsulated by "[ ]" brackets, making the debug message very similar to pre-0.6.0 debug output style.

Parameters
componentA pointer to the Component.
msgThe message to show.

Implemented in ConsoleUI, and NullUI.

◆ ShowStartupBanner()

virtual void UI::ShowStartupBanner ( )
pure virtual

Shows a startup banner.

Implemented in ConsoleUI, and NullUI.

Referenced by GXemul::Run(), and ~UI().

◆ Shutdown()

virtual void UI::Shutdown ( )
pure virtual

Shuts down the UI.

Called from e.g. the "quit" command.

Implemented in ConsoleUI, and NullUI.

Referenced by QuitCommand::Execute(), and GetIndentationMessage().

◆ UpdateUI()

virtual void UI::UpdateUI ( )
pure virtual

Updates various UI elements.

Called whenever:

  • the undo/redo-applicability changes
  • the name of the emulation changes
  • the RunState changes

Implemented in ConsoleUI, and NullUI.

Referenced by GXemul::ClearEmulation(), GXemul::SetEmulationFilename(), GXemul::SetRootComponent(), GXemul::SetRunState(), and ~UI().

Member Data Documentation

◆ m_gxemul

GXemul* UI::m_gxemul
protected

Definition at line 208 of file UI.h.

Referenced by ConsoleUI::Initialize(), ConsoleUI::MainLoop(), and ConsoleUI::ShowDebugMessage().

◆ m_indentationMsg

string UI::m_indentationMsg
protected

Definition at line 209 of file UI.h.

Referenced by GetIndentationMessage(), and SetIndentationMessage().


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

Generated on Sun Sep 30 2018 16:05:18 for GXemul by doxygen 1.8.13