Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

WindowController Class Reference

#include <WindowController.h>

Collaboration diagram for WindowController:

Collaboration graph
[legend]
List of all members.

Detailed Description

A singleton class for keeping track the window components of HippoDraw.

It can be used as a helper function to an application.

Todo:
There are circular references between WindowController and CanvasWindow.
Probably, WindowController should be an observer of CanvasWindow.

Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 42 of file WindowController.h.

Public Member Functions

void aboutToClose (CanvasWindow *window)
 Removes the window from the window list.
void closeAllWindows ()
 Closes all Windows.
void createInspector ()
 Creates the Inspector object and positions it on the desktop.
CanvasWindowcurrentCanvas ()
 Returns a pointer to the current CanvasWindow.
InspectorgetInspector ()
 returns the Inspector.
void hasBeenHidden (CanvasWindow *window)
 Responds to hide event from a document window.
void newWindow (CanvasWindow *)
 Registers the new CanvasWindow and finishes its initialization.
bool okToQuit ()
 Queries application if it is Ok to quit.
void quitOnLastWindowClose (bool yes=true)
 Sets the flag that determines if the applicaiton will be terminated when the last window is closed.
void setCurrentCanvas (CanvasWindow *canvas)
 Sets the current canvas.
void setFirstWindow ()
 Sets up the first CanvasWindow object.
void unHide (CanvasWindow *window)
 Reponds to document window being shown.
void updateActions ()
 Update the actions in all CanvasWindow objects.
 WindowController ()
 Private Constructor.
 ~WindowController ()
 The destructor.

Static Public Member Functions

static WindowControllerinstance ()
 Returns the application instance.
static const std::stringversion ()
 Returns the version number of HippoDraw.

Private Member Functions

const QRectgetScreenRect ()
 Returns a rectangle of the screen.
void positionCanvas (CanvasWindow *window)
 Positions and sets the size of the window taking into account the size of the screen.
void positionInspector ()
 Positions the Inspector based on size of screen and width of Inspector.
void resizeCanvas (CanvasWindow *window)
 Resizes the CanvasWindow so that it doesn't overlap with the Inspector window.

Private Attributes

CanvasWindowm_active_window
 The CanvasWindow object.
Inspectorm_inspector
 The Inspector.
bool m_quit
 A flag that when set true will terminate the application when the last canvas window closes.
std::list< CanvasWindow * > m_window_list
 The list of CanvasWindow objects created by the application.

Static Private Attributes

static WindowControllers_instance = 0
 The instance of the application.
static std::string s_version
 The version number of HippoDraw.


Constructor & Destructor Documentation

WindowController::WindowController  ) 
 

Private Constructor.

Todo:
Had to make this public for boost.python.
Maybe there is a better way.

Definition at line 50 of file WindowController.cxx.

References s_instance.

Referenced by instance().

WindowController::~WindowController  ) 
 

The destructor.

Definition at line 58 of file WindowController.cxx.


Member Function Documentation

void WindowController::aboutToClose CanvasWindow window  ) 
 

Removes the window from the window list.

Todo:
If only one window remains, informs that window to disable the close button.

Definition at line 108 of file WindowController.cxx.

References CanvasWindow::inhibitClose(), m_inspector, m_quit, and m_window_list.

void WindowController::closeAllWindows  ) 
 

Closes all Windows.

Closes all Document windows as well as the Inspector window. Effectively this will terminate the application.

Definition at line 179 of file WindowController.cxx.

References m_inspector, and m_window_list.

void WindowController::createInspector  ) 
 

Creates the Inspector object and positions it on the desktop.

Definition at line 71 of file WindowController.cxx.

References m_inspector, and positionInspector().

Referenced by setFirstWindow().

CanvasWindow * WindowController::currentCanvas  ) 
 

Returns a pointer to the current CanvasWindow.

Definition at line 266 of file WindowController.cxx.

References m_active_window.

Referenced by Inspector::cutNew(), Inspector::fillPlotterList(), and Inspector::summaryNew().

Inspector * WindowController::getInspector  ) 
 

returns the Inspector.

Definition at line 271 of file WindowController.cxx.

References m_inspector.

const QRect & WindowController::getScreenRect  )  [private]
 

Returns a rectangle of the screen.

Definition at line 194 of file WindowController.cxx.

References QApplication::desktop(), QDesktopWidget::primaryScreen(), and QDesktopWidget::screenGeometry().

Referenced by positionCanvas(), positionInspector(), and resizeCanvas().

void WindowController::hasBeenHidden CanvasWindow window  ) 
 

Responds to hide event from a document window.

If all document windows are hidden, then hides the Inspector window as well. Otherwise, does nothing.

Definition at line 130 of file WindowController.cxx.

References m_inspector, and m_window_list.

WindowController * WindowController::instance  )  [static]
 

Returns the application instance.

Definition at line 62 of file WindowController.cxx.

References s_instance, and WindowController().

Referenced by CanvasWindow::CanvasWindow(), CanvasWindow::closeEvent(), Inspector::createResiduals(), QtApp::currentCanvas(), Inspector::cutNew(), CanvasWindow::editClear(), CanvasWindow::editCopy(), CanvasWindow::editCut(), CanvasWindow::editDelete(), CanvasWindow::editSelectAll(), CanvasWindow::fileNew(), Inspector::fillPlotterList(), CanvasWindow::hideEvent(), Inspector::newPlotButton_clicked(), CanvasWindow::on_fileExit_activated(), Inspector::pushButtonNewErrorPlotClicked(), CanvasWindow::setChanged(), QtApp::setFirstWindow(), CanvasWindow::showEvent(), Inspector::summaryNew(), and CanvasWindow::windowActivationChange().

void WindowController::newWindow CanvasWindow  ) 
 

Registers the new CanvasWindow and finishes its initialization.

Definition at line 79 of file WindowController.cxx.

References CanvasWindow::getCanvasView(), CanvasWindow::inhibitClose(), m_inspector, m_quit, m_window_list, positionCanvas(), resizeCanvas(), setCurrentCanvas(), CanvasView::setInspector(), and num_util::size().

Referenced by CanvasWindow::CanvasWindow().

bool WindowController::okToQuit  ) 
 

Queries application if it is Ok to quit.

The application queries each document window for unsaved changes. If any window refuses to close, the application returns false Otherwise, returns true.

See also:
CanvasWindow::allowClose().

Definition at line 152 of file WindowController.cxx.

References CanvasWindow::allowClose(), m_quit, and m_window_list.

void WindowController::positionCanvas CanvasWindow window  )  [private]
 

Positions and sets the size of the window taking into account the size of the screen.

Definition at line 205 of file WindowController.cxx.

References getScreenRect(), m_active_window, QRect::size(), num_util::size(), and QRect::topLeft().

Referenced by newWindow().

void WindowController::positionInspector  )  [private]
 

Positions the Inspector based on size of screen and width of Inspector.

Definition at line 250 of file WindowController.cxx.

References getScreenRect(), m_inspector, QPoint::setX(), num_util::size(), QSize::width(), and QRect::width().

Referenced by createInspector().

void WindowController::quitOnLastWindowClose bool  yes = true  ) 
 

Sets the flag that determines if the applicaiton will be terminated when the last window is closed.

Definition at line 103 of file WindowController.cxx.

References m_quit.

Referenced by setFirstWindow().

void WindowController::resizeCanvas CanvasWindow window  )  [private]
 

Resizes the CanvasWindow so that it doesn't overlap with the Inspector window.

Definition at line 223 of file WindowController.cxx.

References getScreenRect(), QSize::height(), m_inspector, QSize::setHeight(), QSize::setWidth(), QRect::size(), num_util::size(), QSize::width(), and QPoint::x().

Referenced by newWindow().

void WindowController::setCurrentCanvas CanvasWindow canvas  ) 
 

Sets the current canvas.

This method does not change the canvas' window active state which is control by the windowing system. The intent of this method is to allow CanvasWindow object to inform the application that it has become active.

Definition at line 261 of file WindowController.cxx.

References m_active_window.

Referenced by newWindow().

void WindowController::setFirstWindow  ) 
 

Sets up the first CanvasWindow object.

Definition at line 278 of file WindowController.cxx.

References createInspector(), quitOnLastWindowClose(), and CanvasWindow::setCaption().

void WindowController::unHide CanvasWindow window  ) 
 

Reponds to document window being shown.

Shows the Inspector window if it had been hidden.

Definition at line 147 of file WindowController.cxx.

References m_inspector.

void WindowController::updateActions  ) 
 

Update the actions in all CanvasWindow objects.

Update the enabled status of all actions, such as menu items and tool bar icons, of all windows. Sends CanvasWindow::updateActions to all windows.

Definition at line 173 of file WindowController.cxx.

References std::for_each(), m_window_list, std::mem_fun(), and CanvasWindow::updateActions().

const std::string & WindowController::version  )  [static]
 

Returns the version number of HippoDraw.

Definition at line 45 of file WindowController.cxx.

References s_version.

Referenced by CanvasView::helpAbout().


Member Data Documentation

CanvasWindow* WindowController::m_active_window [private]
 

The CanvasWindow object.

Definition at line 54 of file WindowController.h.

Referenced by currentCanvas(), positionCanvas(), and setCurrentCanvas().

Inspector* WindowController::m_inspector [private]
 

The Inspector.

Definition at line 57 of file WindowController.h.

Referenced by aboutToClose(), closeAllWindows(), createInspector(), getInspector(), hasBeenHidden(), newWindow(), positionInspector(), resizeCanvas(), and unHide().

bool WindowController::m_quit [private]
 

A flag that when set true will terminate the application when the last canvas window closes.

Definition at line 69 of file WindowController.h.

Referenced by aboutToClose(), newWindow(), okToQuit(), and quitOnLastWindowClose().

std::list< CanvasWindow * > WindowController::m_window_list [private]
 

The list of CanvasWindow objects created by the application.

Definition at line 51 of file WindowController.h.

Referenced by aboutToClose(), closeAllWindows(), hasBeenHidden(), newWindow(), okToQuit(), and updateActions().

WindowController * WindowController::s_instance = 0 [static, private]
 

The instance of the application.

Definition at line 41 of file WindowController.cxx.

Referenced by instance(), and WindowController().

std::string WindowController::s_version [static, private]
 

The version number of HippoDraw.

Requests:
@ Windows only, Need to get the version number insto the Windows installer file.

Referenced by version().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3