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

GView Class Reference

The base class for all windows in the GUI. More...

#include <LgiClasses.h>

Inheritance diagram for GView:

GTarget GEvent GFlags GButton GCheckBox GCombo GControl GLayout GPopup GRadioButton GRadioGroup GTabView GText GToolButton GToolTip GWindow List of all members.

Public Member Functions

 GView (OsView wnd=0)
 Creates a view/window.
virtual ~GView ()
 Destructor.
OsView Handle ()
 Returns the OS handle of the view.
virtual OsWindow WindowHandle ()
 Returns the OS handle of the top level window.
virtual bool Attach (GView *p)
 Attaches the view to a parent view.
virtual bool AttachChildren ()
 Attachs all the views in the Children list if not already attached.
virtual bool Detach ()
 Detachs a window from it's parent.
virtual bool IsAttached ()
 Returns true if the window is attached.
virtual void Quit (bool DontDelete=false)
 Destroys the window async.
GWindowGetWindow ()
 Gets the top level window that this view belongs to.
GViewGetParent ()
 Gets the parent view.
virtual void SetParent (GView *p)
 Sets the parent view.
void SendNotify (int Data=0)
 Sends a notification to the notify target or the parent chain.
GViewGetNotify ()
 Gets the window that receives event notifications.
virtual void SetNotify (GView *n)
 Sets the view to receive event notifications.
bool Lock (int TimeOut=-1)
 Each top level window (GWindow) has a lock. By calling this function you lock the whole GWindow and all it's children.
void Unlock ()
 Unlocks the GWindow and that this view belongs to.
int OnEvent (GMessage *Msg)
 Called to process every message received by this window.
bool Enabled ()
 true if the view is enabled
void Enabled (bool e)
 Sets the enabled state.
bool Visible ()
 true if the view is visible
void Visible (bool v)
 Hides/Shows the view.
bool Focus ()
 true if the view has keyboard focus
void Focus (bool f)
 Sets the keyboard focus state on the view.
bool DropTarget ()
 true if this view is a drop target
bool DropTarget (bool t)
 Sets the drop target state of this view.
bool Sunken ()
 Gives this view a 1 or 2 px sunken border.
void Sunken (bool i)
 Sets a sunken border around the control.
bool Flat ()
 true if the view has a flat border
void Flat (bool i)
 Sets the flat border state.
bool Raised ()
 true if the view has a raised border
void Raised (bool i)
 Sets the raised border state.
bool InThread ()
 true if the control is currently executing in the GUI thread
bool PostEvent (int Cmd, int a=0, int b=0)
 Asyncronously posts an event to be received by this window.
bool Name (char *n)
 Sets the utf-8 text associated with this view.
char * Name ()
 Returns the utf-8 text associated with this view.
virtual bool NameW (char16 *n)
 Sets the wide char text associated with this view.
virtual char16NameW ()
 Returns the wide char text associated with this view.
virtual GFontGetFont ()
 Gets the font this control should draw with.
virtual void SetFont (GFont *Fnt, bool OwnIt=false)
 Sets the font for this control.
bool SetCursor (int Cursor)
 Sets the mouse cursor to display when the mouse is over this control.
virtual GRectGetPos ()
 Get the position of the view relitive to it's parent.
virtual GRectGetClient ()
 Get the client region of the window relitive to itself (ie always 0,0-x,y).
virtual bool SetPos (GRect &p, bool Repaint=false)
 Set the position of the view in terms of it's parent.
int X ()
 Gets the width of the view in pixels.
int Y ()
 Gets the height of the view in pixels.
GdcPt2 GetMinimumSize ()
 Gets the minimum size of the view.
void SetMinimumSize (GdcPt2 Size)
 Set the minimum size of the view.
void MoveOnScreen ()
 Moves a top level window on screen.
void MoveToCenter ()
 Moves a top level to the center of the screen.
void MoveToMouse ()
 Moves a top level window to where the mouse is.
bool Capture (bool c)
 Captures all mouse events to this view.
bool IsCapturing ()
 true if this view is capturing mouse events.
bool GetMouse (GMouse &m, bool ScreenCoords=false)
 Gets the current mouse location.
int GetId ()
 Gets the ID associated with the view.
void SetId (int i)
 Sets the view's ID.
bool GetTabStop ()
 true if this control is a tab stop.
void SetTabStop (bool b)
 Sets whether this control is a tab stop.
virtual int Value ()
 Gets the integer representation of the view's contents.
virtual void Value (int i)
 Sets the integer representation of the view's contents.
virtual GViewFindControl (OsView hnd)
 Find a view by it's os handle.
virtual GViewFindControl (int Id)
 Returns the view by it's ID.
int GetCtrlValue (int Id)
 Gets the value of the control identified by the ID.
void SetCtrlValue (int Id, int i)
 Sets the value of the control identified by the ID.
char * GetCtrlName (int Id)
 Gets the name (text) of the control identified by the ID.
void SetCtrlName (int Id, char *s)
 Sets the name (text) of the control identified by the ID.
bool GetCtrlEnabled (int Id)
 Gets the enabled state of the control identified by the ID.
void SetCtrlEnabled (int Id, bool Enabled)
 Sets the enabled state of the control identified by the ID.
bool GetCtrlVisible (int Id)
 Gets the visible state of the control identified by the ID.
void SetCtrlVisible (int Id, bool Visible)
 Sets the visible state of the control identified by the ID.
bool Invalidate (GRect *r=NULL, bool Repaint=false, bool NonClient=false)
 Causes the given area of the view to be repainted to update the screen.
bool Invalidate (GRegion *r, bool Repaint=false, bool NonClient=false)
 Causes the given area of the view to be repainted to update the screen.
bool IsOver (GMouse &m)
 true if the mouse event is over the view
GViewWindowFromPoint (int x, int y)
 returns the sub window located at the point x,y
void SetPulse (int Ms=-1)
 Sets a timer to call the OnPulse() event.
void PointToScreen (GdcPt2 &p)
 Convert a point form view coordinates to screen coordinates.
void PointToView (GdcPt2 &p)
 Convert a point form screen coordinates to view coordinates.
bool WindowVirtualOffset (GdcPt2 *Offset)
 Get the x,y offset from the virtual window to the first real view in the parent chain.
GdcPt2GetWindowBorderSize ()
 Get the size of the window borders.
virtual bool Pour (GRegion &r)
 Layout all the child views.
void OnMouseClick (GMouse &m)
 The mouse was clicked over this view.
void OnMouseEnter (GMouse &m)
 Mouse moves into the area over the control.
void OnMouseExit (GMouse &m)
 Mouse leaves the area over the control.
void OnMouseMove (GMouse &m)
 The mouse moves over the control.
void OnMouseWheel (double Lines)
 The mouse wheel was scrolled.
bool OnKey (GKey &k)
 A key was pressed while this view has focus.
void OnCreate ()
 The view is attached.
void OnDestroy ()
 The view is detached.
void OnFocus (bool f)
 The view gains or loses the keyboard focus.
void OnPulse ()
 Called every so often by the timer system.
void OnPosChange ()
 Called when the view position changes.
bool OnRequestClose (bool OsShuttingDown)
 Called on a top level window when something requests to close the window.
int OnHitTest (int x, int y)
 Return the type of cursor that should be visible when the mouse is at x,y.
void OnChildrenChanged (GView *Wnd, bool Attaching)
 Called when the contents of the Children list have changed.
void OnPaint (GSurface *pDC)
 Called to paint the onscreen representation of the view.
int OnNotify (GView *Ctrl, int Flags)
 Called when a child view or view with it's SetNotify() set to this window changes.
int OnCommand (int Cmd, int Event, OsView Wnd)
 Called when a menu command is activated by the user.

Public Attributes

List< GViewChildren
 List of children views.
GEventScript
 Script handler to receive UI events.

Protected Member Functions

GRectFindLargest (GRegion &r)
 Finds the largest rectangle in the region.
GRectFindSmallestFit (GRegion &r, int Sx, int Sy)
 Finds the smallest rectangle that would fit a window 'Sx' by 'Sy'.
GRectFindLargestEdge (GRegion &r, int Edge)
 Finds the largest rectangle on the specified.

Friends

class GWindow
class GLayout
class GControl
class GMenu
class GSubMenu
class GScrollBar
class GDialog
class GPopup

Detailed Description

The base class for all windows in the GUI.

This is the core object that all on screen windows inherit from. It encapsulates a HWND on Win32, a BView on BeOS and a Window on X11. Used by itself it's not a top level window, for that see the GWindow class.

To create a top level window see GWindow or GDialog.

For a GView with scroll bars use GLayout.


Constructor & Destructor Documentation

GView::GView OsView  wnd = 0  ) 
 

Creates a view/window.

On non-Win32 platforms the default argument is the class that redirects the C++ virtual event handlers to the GView handlers. Which is usually the 'DefaultOsView' class. If you pass NULL in a DefaultOsView will be created to do the job. On BeOS you can subclass the native controls by passing in an instance of the BView based class.

Parameters:
Hnd  The handle that the OS knows the window by


Member Function Documentation

bool GView::Attach GView p  )  [virtual]
 

Attaches the view to a parent view.

Each GView starts in an un-attached state. When you attach it to a Parent GView the view gains a OS-specific handle and becomes visible on the screen (if the Visible() property is TRUE). However if a view is inserted into the Children list of a GView and it's parent pointer is set correctly it will still paint on the screen without the OS knowing about it. This is known in Lgi as a "virtual window" and is primarily used to cut down on windowing resources. Mouse clicks are handled by the parent window and passed down to the virtual children. Virtual children are somewhat limited. They can't receive focus, or participate in drag and drop operations. If you want to see an example have a look at the GToolBar code.

Parameters:
p  The parent view or NULL for a top level window

Reimplemented in GPopup, GScrollBar, GTabView, GLayout, GWindow, GToolTip, and GSplitter.

bool GView::Capture bool  c  ) 
 

Captures all mouse events to this view.

Once you have mouse capture all mouse events will be passed to this view. i.e. during a mouse click.

GRect * GView::FindLargestEdge GRegion r,
int  Edge
[protected]
 

Finds the largest rectangle on the specified.

Parameters:
r  The region to search
Edge  The edge to look at:
See also:
GV_EDGE_TOP, GV_EDGE_RIGHT, GV_EDGE_BOTTOM or GV_EDGE_LEFT

GFont * GView::GetFont  )  [virtual]
 

Gets the font this control should draw with.

The default font is the system font, owned by the GApp object.

Reimplemented in GProgressPane, GTextView3, and GToolBar.

int GView::GetId  ) 
 

Gets the ID associated with the view.

The ID of a view is designed to associate controls defined in resource files with a object at runtime via a C header file define.

bool GView::GetMouse GMouse m,
bool  ScreenCoords = false
 

Gets the current mouse location.

Returns:
true on success
Parameters:
m  The mouse location information returned
ScreenCoords  Get the location in screen coordinates

bool GView::InThread  ) 
 

true if the control is currently executing in the GUI thread

Some OS functions are not thread safe, and can only be called in the GUI thread. In the Linux implementation the GUI thread can change from time to time. On Win32 it stays the same. In any case if this function returns true it's safe to do just about anything.

bool GView::Invalidate GRegion r,
bool  Repaint = false,
bool  NonClient = false
 

Causes the given area of the view to be repainted to update the screen.

Parameters:
r  The region of the view to repaint
Repaint  true if you want to wait for the update to happen
NonClient  false to update in client coordinates, true to update the non client region

bool GView::Invalidate GRect r = NULL,
bool  Repaint = false,
bool  NonClient = false
 

Causes the given area of the view to be repainted to update the screen.

Parameters:
r  The rectangle of the view to repaint, or NULL for the entire view
Repaint  true if you want to wait for the update to happen
Frame  false to update in client coordinates, true to update the non client region

bool GView::Lock int  TimeOut = -1  ) 
 

Each top level window (GWindow) has a lock. By calling this function you lock the whole GWindow and all it's children.

Parameters:
TimeOut  The timeout in milli-seconds or -1 to block until locked.

bool GView::Name char *  n  ) 
 

Sets the utf-8 text associated with this view.

Name and NameW are interchangable. Using them in any order will convert the text between utf-8 and wide to satify any requirement. Generally once the opposing version of the string is required both the utf-8 and wide copies of the string remain cached in RAM until the Name is changed.

Reimplemented in GButton, GCheckBox, GCombo, GEdit, GHtml, GRadioGroup, GRadioButton, GText, GTextView3, and GWindow.

char16 * GView::NameW  )  [virtual]
 

Returns the wide char text associated with this view.

On Win32 the wide characters are 16 bits, on unix systems they are 32-bit characters.

Reimplemented in GButton, GCheckBox, GEdit, GRadioGroup, GRadioButton, GText, and GTextView3.

void GView::OnFocus bool  f  )  [virtual]
 

The view gains or loses the keyboard focus.

Parameters:
f  True if the control is receiving focus

Reimplemented from GEvent.

Reimplemented in GButton, GCheckBox, GCombo, GList, GDropDown, GRadioButton, GTabView, GTextView3, and GTree.

int GView::OnHitTest int  x,
int  y
[virtual]
 

Return the type of cursor that should be visible when the mouse is at x,y.

Parameters:
x  The x coordinate in view coordinates
y  The y coordinate in view coordinates

Reimplemented from GEvent.

Reimplemented in GList, GTextView3, and GSplitter.

void GView::OnMouseClick GMouse m  )  [virtual]
 

The mouse was clicked over this view.

Parameters:
m  The event parameters

Reimplemented from GEvent.

Reimplemented in GBitmap, GButton, GCheckBox, GCombo, GTimePopup, GDatePopup, GHtml, GList, GDropDown, GRadioButton, GScrollBar, GTabView, GTextView3, GToolButton, GToolBar, GTree, and GSplitter.

void GView::OnMouseEnter GMouse m  )  [virtual]
 

Mouse moves into the area over the control.

Parameters:
m  The event parameters

Reimplemented from GEvent.

Reimplemented in GButton, GCheckBox, GRadioButton, GToolButton, and GToolBar.

void GView::OnMouseExit GMouse m  )  [virtual]
 

Mouse leaves the area over the control.

Parameters:
m  The event parameters

Reimplemented from GEvent.

Reimplemented in GButton, GCheckBox, GRadioButton, GToolButton, GToolBar, and GSplitter.

void GView::OnMouseMove GMouse m  )  [virtual]
 

The mouse moves over the control.

Parameters:
m  The event parameters

Reimplemented from GEvent.

Reimplemented in GHtml, GList, GScrollBar, GTextView3, GToolButton, GToolBar, GTree, and GSplitter.

void GView::OnMouseWheel double  Lines  )  [virtual]
 

The mouse wheel was scrolled.

Parameters:
Lines  The amount scrolled

Reimplemented from GEvent.

Reimplemented in GHtml, GList, GScrollBar, GTextView3, and GTree.

int GView::OnNotify GView Ctrl,
int  Flags
[virtual]
 

Called when a child view or view with it's SetNotify() set to this window changes.

The event by default will bubble up to the GWindow at the top of the window heirarchy visiting each GView on the way. If it reaches a GView that processes it then the event stops propergating up the heirarchy.

Reimplemented from GEvent.

Reimplemented in GTimeDrop, GAbout, GEdit, GFindDlg, GReplaceDlg, GFontSelect, GHtml, GInput, GItemEdit, GList, GDropDown, GProgressPane, GRadioGroup, GTabView, GTextView3, GTree, GLayout, and GAlert.

void GView::OnPulse  )  [virtual]
 

Called every so often by the timer system.

See also:
SetPulse()

Reimplemented from GEvent.

Reimplemented in GHtml, GList, GScrollBar, and GTextView3.

bool GView::OnRequestClose bool  OsShuttingDown  )  [virtual]
 

Called on a top level window when something requests to close the window.

Parameters:
OsShuttingDown  True if the operating system is shutting down.

Reimplemented from GEvent.

Reimplemented in GDocApp, GWindow, and GDialog.

bool GView::PostEvent int  Cmd,
int  a = 0,
int  b = 0
 

Asyncronously posts an event to be received by this window.

This calls PostMessage on Win32 and XSendEvent on X11. XSendEvent is called with a ClientMessage with the a and b parameters in the data section.

Parameters:
Cmd  The command ID.
See also:
Should be M_USER or higher for custom events.
a  The first 32-bits of data. Equivilent to wParam on Win32.
b  The second 32-bits of data. Equivilent to lParam on Win32.

virtual bool GView::Pour GRegion r  )  [inline, virtual]
 

Layout all the child views.

Parameters:
r  The available space to lay out the views into

Reimplemented in GProgressPane, GToolBar, GLayout, and GSplitter.

bool GView::Raised  )  [virtual]
 

true if the view has a raised border

The size is set by the _BorderSize member variable. This border is not considered part of the client area. Mouse and drawing coordinates do not take it into account.

Reimplemented from GFlags.

bool GView::SetCursor int  Cursor  ) 
 

Sets the mouse cursor to display when the mouse is over this control.

This currently only works on Win32, as I can't get the X11 cursor functions to work. They seem horribly broken. (Surprise surprise)

Parameters:
Cursor  The cursor to change to.
See also:
the defines starting with LCUR_Normal from LgiDefs.h

void GView::SetFont GFont Fnt,
bool  OwnIt = false
[virtual]
 

Sets the font for this control.

The lifetime of the font passed in is the responsibility of the caller. The GView object assumes the pointer will be valid at all times.

Reimplemented in GButton, GCheckBox, GCombo, GRadioGroup, GRadioButton, GText, and GTextView3.

void GView::SetMinimumSize GdcPt2  Size  ) 
 

Set the minimum size of the view.

Only works for top level windows.

void GView::SetNotify GView n  )  [virtual]
 

Sets the view to receive event notifications.

The notify window will receive events when this view changes. By default the parent view receives the events.

void GView::SetParent GView p  )  [virtual]
 

Sets the parent view.

This doesn't attach the window so that it will display. You should use GView::Attach for that.

void GView::SetPulse int  Ms = -1  ) 
 

Sets a timer to call the OnPulse() event.

Parameters:
Length  The milliseconds between calls to OnPulse() or -1 to disable

void GView::SetTabStop bool  b  ) 
 

Sets whether this control is a tab stop.

A top stop is a control that receives focus if the user scrolls through the controls with the tab key.

bool GView::Sunken  )  [virtual]
 

Gives this view a 1 or 2 px sunken border.

The size is set by the _BorderSize member variable. This border is not considered part of the client area. Mouse and drawing coordinates do not take it into account.

Reimplemented from GFlags.

void GView::Visible bool  v  )  [virtual]
 

Hides/Shows the view.

Parameters:
i  True if you want to show the view, False to hide the view/

Reimplemented from GFlags.

Reimplemented in GItemEdit, GPopup, and GWindow.


The documentation for this class was generated from the following files:
Generated on Wed Oct 26 14:47:04 2005 for Lgi by  doxygen 1.4.1