ContentsWhat is fGUI ?
fGUI basics The classesfApplicationfClassInfo fColor fGroup fObject fPoint |
The flexible GUI: fObjectDerived from: public fClassInfo Declared in: fGUI/fObject.h Library: fGUI.so
OverviewfObject is the base class for all classes that draw something on screen in fGUI. It declares the methods that are used within the layout system and implements most of them to reasonable defaults. See fGroup for methods not included in fObject. fObject cannot be instantiated because it contains a true virtual methods, drawObject(). It is meant as a base for derived classes fGUI is based on fObjects. All gadgets that can be handled by the fGUI system have to inherit from fObject. Principles: In fGUI every graphical object is a gadget. At the moment you can only use gadgets that are provided by fGUI. fGUI uses only one BView to render itself, an instance of fView. Therefore fGUI has to do its own layout. The following will try to introduce you to the principles that are used. Every gadget in fGUI has 4 different sizes. This may seem a little bit much, but read on :)
Additionally each gadget has these attributes:
Message FormatThe messages that are used in the event model of fGUI have to conform to some strict rules:
Derived ClassesAs already stated above any gadget that wants to participate in the layout must inherit from fObject. At least two methods have to be overridden by a derived class: drawObject() to actualle draw the class on screen and either recalculateSizeLimits() or all three of calculateMinimumSize(), calculatePreferredSize() and calculateMaximumSize() to set the correct size limits for the class. If the object shall react to user input one or more of the mouseXXX-methods has to be reimplemented in the derived class.
Hook Functions
Constructor and DestructorfObject()
fObject( void) fObject( const char *ObjectName)Initializes the fObject to reasonible default values:
~fObject()
virtual ~fObject( void)Deletes the fObject and frees all resources that where allocated in the constructor.
Protected FunctionssetMinimumSize(), setPreferredSize(), setMaximumSize()
virtual void setMinimumSize( fPoint &Size) virtual void setPreferredSize( fPoint &Size) virtual void setMaximumSize( fPoint &Size)Sets the minimum, preferred or maximum size of the gadget, respectively. This method adds the current horizontal and vertical borders correctly so you don't have to worry about them.
calculateMinimumSize(), calculatePreferredSize(), calculateMaximumSize()
virtual void calculateMinimumSize( void) virtual void calculatePreferredSize( void) virtual void calculateMaximumSize( void)In fObject these methods call the corresponding setXXXSize() method with a size of fPoint( 0.0, 0.0). In derived classes these emthods should be overridden when the calculation of the size limits differs from each other. If it is possible to determine all size limits in one calculation ist better to override recalculateSizeLimits().
recalculateSizeLimits()
virtual void recalculateSizeLimits( void)recalculateSizeLimits is a shortcut for:
calculateMinimumSize();
setClippingRegion()
void setClippingRegion( const BRegion &ClippingRegion)This method sets the cliping region the object has to use when drawing outside of the regular drawObject() calls. This is for example used in redraw().
removeEventRoutes()
void removeEventRoutes( int32 fEvent)This method removes all event reouytes from the internal list that match the given Event.
redraw()
void redraw( BRect RedrawRectangle) constredraw() calls drawObject() with a region according to the rectangle given. Call this method when you have drawing to do outside the normal call to drawObject().
Member Functions
setWeights(), setHorizontalWeight(), setVerticalWeight(), getHorizontalWeight(), getVerticalWeight()
virtual void setWeights( float Weight) virtual void setHorizontalWeight( float Weight) virtual void setVerticalWeight( float Weight) float getHorizontalWeight( void) const float getVerticalWeight( void) constsetHorizontalWeight() and setVerticalWeight() set the horizontal and vertical weight of the object, respectively. setWeights() is a shortcut to set both weights to the same value. getHorizontalWeight() and getVerticalWeight() return the current weight. The weight of an object is the basis of all layouting activity. All objects with the same weight can expect to get the same space, except when that size would collide with the size limits of that object. A special case is a weight of 0.0. Such a weight tells the parent group to resize the object to its preferred size and not to calculate its size.
getMinimumSize(), getMaximumSize(), getPreferredSize()
void getMinimumSize( fPoint &Size) const fPoint getMinimumSize( void) const void getMaximumSize( fPoint &Size) const fPoint getMaximumSize( void) const void getPreferredSize( fPoint &Size) const fPoint getPreferredSize( void) constThese methods return the size limits or modify given point according to the size limits. They are used by groups to determine wether a certain size is allowed for an object.
setSize(), getSize()
virtual void setSize( const fPoint &NewSize) virtual void getSize( fPoint &Size) const fPoint getSize( void) constsetSize() sets the size of the object to NewSize. getSize() either returns the current size or it modifies Size so that it is equal to the current size.
setPosition(), getPosition()
virtual void setPosition( const fPoint &NewPosition) void getPosition( fPoint &Position) const fPoint getPosition( void) constsetPosition() sets the position of the object to NewPosition, the position is given in the coordinate system of the BView in which the object will draw. getPosition() either returns the current position or it modifies Position so that it is equal to the current position.
getObjectFrame()
void getObjectFrame( BRect &Position) const BRect getObjectFrame( void) constgetObjectFrame() returns the rectangle the object occupies. This rectangle is calculated from the current position and the current size. If a rectangle is given it is modified to the size and position of the objects frame. This method is used by drawObject() and containsPoint().
setBorders(), setHorizontalBorder(), setVerticalBorder(), getHorizontalBorder(), getVerticalBorder()
virtual void setBorders( float NewBorder) virtual void setHorizontalBorder( float NewHorizontalBorder) virtual void setVerticalBorder( float NewVerticalBorder) float getHorizontalBorder( void) const float getVerticalBorder( void) constsetHorizontalBorder() and setVerticalBorder() set the horizontal and vertical border of the object, respectively. setBorders() is a shortcut to set both borders to the same value. getHorizontalBorder() and getVerticalBorder() return the current border value. The border of an object determines the space that the objects frame is inset in both horizontal and vertical direction before drawing. This increases the distances of the objects and makes the interface less crowded.
setHorizontalAlignment(), setVerticalAlignment(), getHorizontalAlignment(), getVerticalAlignment()
virtual void setHorizontalAlignment( HorizontalAlignment NewAlignment) virtual void setVerticalAlignment( VerticalAlignment NewAlignment) HorizontalAlignment getHorizontalAlignment( void) const VerticalAlignment getVerticalAlignment( void) constthese method set and get the alignment of the object. Possible values are F_HALIGN_RIGHT, F_HALIGN_CENTER and F_HALIGN_LEFT for the horizontal alignment and F_VALIGN_TOP, F_VALIGN_CENTER and F_VALIGN_BOTTOM for the vertical alignment. Alignment is used in two ways: First the group which contains the object acts upon the alignment values and secondly the object itself, if it has something to align can use these values.
setEnabled(), getEnabled()
virtual void setEnabled( bool Enabled) bool getEnabled( void) constsetEnabled() enables or disables the object according to the value Enabled. Disabled objects should not except user input.This method is not normally called from outside the object but from within a href="#dispatchMessage()">dispatchMessage() in response to F_ENABLE_OBJECT and F_DISABLE_OBJECT events. getEnabled() returns true if the ibject is enabled and false otherwise.
setFont()
virtual void setFont( const BFont *Font)This method sets the font the object should use when drawing. This method is empty in fObject.
setFontColor(), getFontColor()
virtual void setFontColor( const fColor &FontColor) virtual void setFontColor( uint8 Red, uint8 Green, uint8 Blue, uint8 Alpha = 255) fColor getFontColor( void) constSets the color the object uses when drawing text. This method excepts either fColors or RGBA values. getFontColor() returns the color used to draw text as a fColor.
setBackgroundColor(), getBackgroundColor()
virtual void setBackgroundColor( const fColor &BackgroundColor) virtual void setBackgroundColor( uint8 Red, uint8 Green, uint8 Blue, uint8 Alpha = 255) fColor getBackgroundColor( void) constSets the color the object uses when drawing its background. This method excepts either fColors or RGBA values. getFontColor() returns the color used to draw the background.
setBackgroundBitmap()
virtual void setBackgroundBitmap( BBitmap *BackgroundBitmap)This method is to set the background bitmap the object should use to clear its frame rectangle. This is currently not implemented, the method is empty.
containsPoint()
virtual const fObject *containsPoint( const fPoint &Point) constThis method checks if the point Point falls within the objects frame rectangle, insetted by the horizontal and vertical border. This method is used by the objects parent group find the object for example a mouse button was pressed in. Another use is in derived classes where in mouseUp() is checked if the mouse went up within the frame of the object.
mouseDown()
virtual void mouseDown( MouseButton Button, const fPoint &Point, int32 Clicks)Implemented by derived classes to react to the user pressing a mouse button. Point is the location of the click given in the coordinate system of the objects view. Button can currently have one of four values:
The Clicks variable is one if that click is a solitary event and greater than one if it is part of a multiple click.
mouseUp()
virtual void mouseUp( MouseButton Button, const fPoint &Point, int32 Clicks)Implemented by derived classes to react to the user releasing a mouse button. Point is the location of the click given in the coordinate system of the objects view. Button can currently have four values, seel above.
The Clicks variable is one if that click is a solitary event and greater than one if
it is part of a multiple click.
Note:Because this method is called very often derived classes which implement it
whould only do very fast things, otherwise the system will not keep up with the user moving the
mouse.
getFocus() return true if the object has the focus and false otherwise.
Note that for example Alt-X, Alt-C and Alt-V are translated to events ( F_CUT,
F_COPY and F_PASTE) and that if a default button is set the return key will
not show up in the focussed object.
processEvent() look through the list of event routes and when a route has the same event
value as the event to process the event route is activated.
Note:Message can be NULL!
Note:Message can be NULL!
getName() returns a pointer to the name of the object or NULL if no name was set.
getView returns the view or NULL if none is set.
getParent returns the parent object or NULL if the object is not assigned to a group.
detachedFromWindow() is called when the object is removed from the hierarchy or when the
fView object the object belongs to is removed from the window.
getWindowActivated() returns true if the window the object is in is currently
the activ window and false otherwise.
The flexible GUI, in HTML for
the BeOS Release 3.
Copyright © 1997-1998 Stegemann & Co.
All rights reserved.
Last modified May 19, 1998.
|