libyui  3.4.2
YApplication Class Referenceabstract

Class for application-wide values and functions. More...

#include <YApplication.h>

Public Member Functions

YWidgetfindWidget (YWidgetID *id, bool doThrow=true) const
 Find a widget in the topmost dialog by its ID. More...
 
virtual std::string iconBasePath () const
 Get the base path for icons used by the UI. More...
 
virtual void setIconBasePath (const std::string &newIconBasePath)
 Set the icon base path.
 
YIconLoadericonLoader ()
 
int defaultFunctionKey (const std::string &label) const
 Return the default function key number for a widget with the specified label or 0 if there is none. More...
 
void setDefaultFunctionKey (const std::string &label, int fkey)
 Add a mapping from the specified label to the specified F-key number. More...
 
void clearDefaultFunctionKeys ()
 Clear all previous label-to-function-key mappings.
 
virtual void setLanguage (const std::string &language, const std::string &encoding=std::string())
 Set language and encoding for the locale environment ($LANG). More...
 
std::string language (bool stripEncoding=false) const
 Return the current language from the locale environment ($LANG). More...
 
virtual std::string glyph (const std::string &glyphSymbolName)
 Return a string for a named glyph: More...
 
virtual std::string askForExistingDirectory (const std::string &startDir, const std::string &headline)=0
 Open a directory selection box and prompt the user for an existing directory. More...
 
virtual std::string askForExistingFile (const std::string &startWith, const std::string &filter, const std::string &headline)=0
 Open a file selection box and prompt the user for an existing file. More...
 
virtual std::string askForSaveFileName (const std::string &startWith, const std::string &filter, const std::string &headline)=0
 Open a file selection box and prompt the user for a file to save data to. More...
 
virtual bool openContextMenu (const YItemCollection &itemCollection)
 Open a context menu for a widget. More...
 
virtual void setProductName (const std::string &productName)
 Set the current product name ("openSUSE", "SLES", ...). More...
 
std::string productName () const
 Get the current product name ("openSUSE", "SLES", ...).
 
void setReleaseNotes (const std::map< std::string, std::string > &relNotes)
 Set release notes; map product => text. More...
 
std::map< std::string, std::string > releaseNotes () const
 Get the current release notes map.
 
void setShowProductLogo (bool show)
 Set whether the product logo (in top bar) should be shown.
 
bool showProductLogo () const
 Return true if product logo should be shown.
 
virtual int deviceUnits (YUIDimension dim, float layoutUnits)
 Convert logical layout spacing units into device dependent units. More...
 
virtual float layoutUnits (YUIDimension dim, int deviceUnits)
 Convert device dependent units into logical layout spacing units. More...
 
virtual void setReverseLayout (bool reverse)
 Set reverse layout for Arabic / Hebrew support. More...
 
bool reverseLayout () const
 Returns 'true' if widget geometry should be reversed for languages that have right-to-left writing direction (Arabic, Hebrew).
 
virtual void busyCursor ()
 Change the (mouse) cursor to indicate busy status. More...
 
virtual void normalCursor ()
 Change the (mouse) cursor back from busy status to normal. More...
 
virtual void makeScreenShot (const std::string &fileName)
 Make a screen shot and save it to the specified file. More...
 
virtual void beep ()
 Beep. More...
 
virtual void redrawScreen ()
 Redraw the screen. More...
 
virtual void initConsoleKeyboard ()
 Initialize the (text) console keyboard. More...
 
virtual void setConsoleFont (const std::string &console_magic, const std::string &font, const std::string &screen_map, const std::string &unicode_map, const std::string &language)
 Set the (text) console font according to the current encoding etc. More...
 
virtual int runInTerminal (const std::string &command)
 Run a shell command (typically an interactive program using NCurses) in a terminal (window). More...
 
virtual int displayWidth ()=0
 
virtual int displayHeight ()=0
 
virtual int displayDepth ()=0
 
virtual long displayColors ()=0
 
virtual int defaultWidth ()=0
 
virtual int defaultHeight ()=0
 
virtual bool isTextMode ()=0
 
virtual bool hasImageSupport ()=0
 
virtual bool hasIconSupport ()=0
 
virtual bool hasAnimationSupport ()=0
 
virtual bool hasFullUtf8Support ()=0
 
virtual bool richTextSupportsTable ()=0
 
virtual bool leftHandedMouse ()=0
 
virtual bool hasWizardDialogSupport ()
 
virtual void setApplicationTitle (const std::string &title)
 Set the application title.
 
virtual const std::string & applicationTitle () const
 Get the application title. More...
 
virtual void setApplicationIcon (const std::string &icon)
 Set the application Icon.
 
virtual const std::string & applicationIcon () const
 Get the application Icon. More...
 
virtual void openUI ()
 To mix TUI (NCurses) with stdio, enclose the UI parts within openUI/closeUI. More...
 
virtual void closeUI ()
 

Protected Member Functions

 YApplication ()
 Constructor. More...
 
virtual ~YApplication ()
 Destructor.
 

Friends

class YUI
 

Detailed Description

Class for application-wide values and functions.

This is a singleton. Access and create it via the static functions in YUI.

Definition at line 45 of file YApplication.h.

Constructor & Destructor Documentation

◆ YApplication()

YApplication::YApplication ( )
protected

Constructor.

Use YUI::app() to get the singleton for this class.

Definition at line 63 of file YApplication.cc.

Member Function Documentation

◆ applicationIcon()

const std::string & YApplication::applicationIcon ( ) const
virtual

Get the application Icon.

Default icon is an empty string

Definition at line 296 of file YApplication.cc.

◆ applicationTitle()

const std::string & YApplication::applicationTitle ( ) const
virtual

Get the application title.

Default title is the running command (argv[0])

Definition at line 287 of file YApplication.cc.

◆ askForExistingDirectory()

virtual std::string YApplication::askForExistingDirectory ( const std::string &  startDir,
const std::string &  headline 
)
pure virtual

Open a directory selection box and prompt the user for an existing directory.

'startDir' is the initial directory that is displayed.

'headline' is an explanatory text for the directory selection box. Graphical UIs may omit that if no window manager is running.

Returns the selected directory name or an empty string if the user canceled the operation.

Derived classes are required to implement this.

◆ askForExistingFile()

virtual std::string YApplication::askForExistingFile ( const std::string &  startWith,
const std::string &  filter,
const std::string &  headline 
)
pure virtual

Open a file selection box and prompt the user for an existing file.

'startWith' is the initial directory or file.

'filter' is one or more blank-separated file patterns, e.g. "*.png *.jpg"

'headline' is an explanatory text for the file selection box. Graphical UIs may omit that if no window manager is running.

Returns the selected file name or an empty string if the user canceled the operation.

Derived classes are required to implement this.

◆ askForSaveFileName()

virtual std::string YApplication::askForSaveFileName ( const std::string &  startWith,
const std::string &  filter,
const std::string &  headline 
)
pure virtual

Open a file selection box and prompt the user for a file to save data to.

Automatically asks for confirmation if the user selects an existing file.

'startWith' is the initial directory or file.

'filter' is one or more blank-separated file patterns, e.g. "*.png *.jpg"

'headline' is an explanatory text for the file selection box. Graphical UIs may omit that if no window manager is running.

Returns the selected file name or an empty string if the user canceled the operation.

Derived classes are required to implement this.

◆ beep()

virtual void YApplication::beep ( )
inlinevirtual

Beep.

This default implementation does nothing.

Definition at line 327 of file YApplication.h.

◆ busyCursor()

virtual void YApplication::busyCursor ( )
inlinevirtual

Change the (mouse) cursor to indicate busy status.

This default implementation does nothing.

Definition at line 309 of file YApplication.h.

◆ defaultFunctionKey()

int YApplication::defaultFunctionKey ( const std::string &  label) const

Return the default function key number for a widget with the specified label or 0 if there is none.

Any keyboard shortcuts that may be contained in 'label' are stripped away before any comparison.

The basic idea behind this concept is to have an easy default mapping from buttons etc. with the same semantics to function keys:

"OK" -> F10 "Accept" -> F10 "Yes" -> F10 "Next" -> F10

"Cancel" -> F9 "No" -> F9 ...

This function returns 10 for F10, F for F9 etc.; 0 means "no function key".

Definition at line 162 of file YApplication.cc.

◆ deviceUnits()

int YApplication::deviceUnits ( YUIDimension  dim,
float  layoutUnits 
)
virtual

Convert logical layout spacing units into device dependent units.

A default size dialog is assumed to be 80x25 layout spacing units.

Derived classes may want to reimplement this method.

Definition at line 261 of file YApplication.cc.

◆ findWidget()

YWidget * YApplication::findWidget ( YWidgetID id,
bool  doThrow = true 
) const

Find a widget in the topmost dialog by its ID.

If there is no widget with that ID (or no dialog at all), this function throws a YUIWidgetNotFoundException if 'doThrow' is 'true'. It returns 0 if 'doThrow' is 'false'.

Definition at line 81 of file YApplication.cc.

◆ glyph()

std::string YApplication::glyph ( const std::string &  glyphSymbolName)
virtual

Return a string for a named glyph:

YUIGlyph_ArrowLeft YUIGlyph_ArrowRight YUIGlyph_ArrowUp YUIGlyph_ArrowDown YUIGlyph_CheckMark YUIGlyph_BulletArrowRight YUIGlyph_BulletCircle YUIGlyph_BulletSquare

Using this is discouraged in new applications. This method is available for backward compatibility.

This default implementation returns simple textual representations for each glyph simbol (e.g., "->" for YUIGlyphArrorRight).

Derived classes are free to overwrite this. It does not make sense to call this base class method in a new implementation.

Definition at line 234 of file YApplication.cc.

◆ iconBasePath()

std::string YApplication::iconBasePath ( ) const
virtual

Get the base path for icons used by the UI.

Selection widgets like YSelectionBox, YComboBox, etc. or YWizard prepend this to icon specifications that don't use an absolute path.

Definition at line 93 of file YApplication.cc.

◆ initConsoleKeyboard()

virtual void YApplication::initConsoleKeyboard ( )
inlinevirtual

Initialize the (text) console keyboard.

This default implementation does nothing.

Definition at line 344 of file YApplication.h.

◆ language()

std::string YApplication::language ( bool  stripEncoding = false) const

Return the current language from the locale environment ($LANG).

If 'stripEncoding' is true, any encoding (".utf8" etc.) is removed.

Definition at line 210 of file YApplication.cc.

◆ layoutUnits()

float YApplication::layoutUnits ( YUIDimension  dim,
int  deviceUnits 
)
virtual

Convert device dependent units into logical layout spacing units.

A default size dialog is assumed to be 80x25 layout spacing units.

Derived classes may want to reimplement this method.

Definition at line 268 of file YApplication.cc.

◆ makeScreenShot()

virtual void YApplication::makeScreenShot ( const std::string &  fileName)
inlinevirtual

Make a screen shot and save it to the specified file.

This default implementation does nothing.

Definition at line 321 of file YApplication.h.

◆ normalCursor()

virtual void YApplication::normalCursor ( )
inlinevirtual

Change the (mouse) cursor back from busy status to normal.

This default implementation does nothing.

Definition at line 315 of file YApplication.h.

◆ openContextMenu()

bool YApplication::openContextMenu ( const YItemCollection itemCollection)
virtual

Open a context menu for a widget.

'itemCollection' describes the menu structure

Returns true on success (otherwise false).

Derived classes are free to overwrite this.

Definition at line 252 of file YApplication.cc.

◆ openUI()

virtual void YApplication::openUI ( )
inlinevirtual

To mix TUI (NCurses) with stdio, enclose the UI parts within openUI/closeUI.

This default implementation does nothing.

Definition at line 379 of file YApplication.h.

◆ redrawScreen()

virtual void YApplication::redrawScreen ( )
inlinevirtual

Redraw the screen.

This default implementation does nothing.

Definition at line 338 of file YApplication.h.

◆ runInTerminal()

int YApplication::runInTerminal ( const std::string &  command)
virtual

Run a shell command (typically an interactive program using NCurses) in a terminal (window).

This is useful for text UIs (e.g., NCurses) that need special preparation prior to running an NCurses-based application and special clean-up afterwards.

This default implementation logs an error and returns -1.

Definition at line 275 of file YApplication.cc.

◆ setConsoleFont()

virtual void YApplication::setConsoleFont ( const std::string &  console_magic,
const std::string &  font,
const std::string &  screen_map,
const std::string &  unicode_map,
const std::string &  language 
)
inlinevirtual

Set the (text) console font according to the current encoding etc.

See the setfont(8) command and the console HowTo for details.

This default implementation does nothing.

Definition at line 352 of file YApplication.h.

◆ setDefaultFunctionKey()

void YApplication::setDefaultFunctionKey ( const std::string &  label,
int  fkey 
)

Add a mapping from the specified label to the specified F-key number.

This is the counterpart to defaultFunctionKey().

This only affects widgets that are created after this call.

Definition at line 175 of file YApplication.cc.

◆ setLanguage()

void YApplication::setLanguage ( const std::string &  language,
const std::string &  encoding = std::string() 
)
virtual

Set language and encoding for the locale environment ($LANG).

This affects UI-internal translations (e.g. for predefined dialogs like file selection), encoding and fonts.

'language' is the ISO short code ("de_DE", "en_US", ...).

'encoding' an (optional) encoding ("utf8", ...) that will be appended if present.

Derived classes can overwrite this method, but they should call this base class method at the beginning of the new implementation.

Definition at line 192 of file YApplication.cc.

◆ setProductName()

void YApplication::setProductName ( const std::string &  productName)
virtual

Set the current product name ("openSUSE", "SLES", ...).

This name will be expanded in help texts when the entity is used.

Derived classes can overwrite this method, but they should call this base class method in the new implementation.

Definition at line 112 of file YApplication.cc.

◆ setReleaseNotes()

void YApplication::setReleaseNotes ( const std::map< std::string, std::string > &  relNotes)

Set release notes; map product => text.

Definition at line 125 of file YApplication.cc.

◆ setReverseLayout()

void YApplication::setReverseLayout ( bool  reverse)
virtual

Set reverse layout for Arabic / Hebrew support.

Derived classes can overwrite this method, but they should call this base class method in the new implementation.

Definition at line 149 of file YApplication.cc.


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