(Up to GLayout)

GToolBar

This is a toolbar class. It will automatically arrange itself at the top of the GAppWindow's client area. It should be attached first to the GAppWindow object so that it gets first cut at the client area.

Use the function LgiLoadToolbar to allocate the object and load the image list in from a graphics file:

GToolBar *LgiLoadToolbar(GWindow *Parent, char *File, int x = 24, int y = 24);

class GToolBar :
    public GLayout
{
public:
    // _Constructor
    ~GToolBar()
    GToolBar()

    // Buttons
    bool AppendBreak()
    bool AppendControl(GWindow *Ctrl)
    bool AppendSeparator()
    bool Delete(GWindow *Ctrl)
    virtual GToolButton *AppendButton(char *Tip, int Id, int Type = TBT_PUSH, int Enabled = TRUE, int IconId = -1)
    void Empty()

    // Properties
    bool IsVertical(bool i)
    bool IsVertical()
    bool SetBitmap(char *File, int Bx, int By)
    bool SetDC(GdcBasePrimitives *pDC, int Bx, int By)
    bool SetImageList(bool Own = true, GImageList *l, int Bx, int By)
};

GToolBar::~GToolBar

~GToolBar()

Destroys the toolbar.


GToolBar::GToolBar

GToolBar()

Constructs the toolbar.


GToolBar::AppendBreak

bool AppendBreak()

A break wraps the buttons onto the next line. This allows multi column tool bars.


GToolBar::AppendControl

bool AppendControl(GWindow *Ctrl)

Argument Description
GWindow *Ctrl Control to append.

You can append custom controls on the toolbar. Things like edit and combo boxes. Build a class for the control and then pass an instance into this function. The X() and Y() functions of the window will be used to determin it's size and allocated space for the window in the toolbar.


GToolBar::AppendSeparator

bool AppendSeparator()

Inserts a separator between buttons. A separator can be used to group buttons with the radio style. Radio buttons only allow one option to be selected from their group at a time.


GToolBar::Delete

bool Delete(GWindow *Ctrl)

Argument Description
GWindow *Ctrl The button to delete.

Deletes the specified button.


GToolBar::AppendButton

virtual GToolButton *AppendButton(char *Tip, int Id, int Type = TBT_PUSH, int Enabled = TRUE, int IconId = -1)

Argument Description
char *Tip The tooltip for the button to display when the mouse is over the button.

Note: Not currently implemented on BeOS.

int Id The command id to return to the main window OnCommand handler when the button is pressed.
int Type = TBT_PUSH The type of the button. Can be:
  • TBT_PUSH
  • TBT_RADIO
  • TBT_TOGGLE
Radio type buttons are grouped between separators.
int Enabled = TRUE Whether the button should be enbled.
int IconId = -1 The index of the icon in the image list to use on the button. Requires that you have set the image list of the toolbar.

Append a button to the toolbar.


GToolBar::Empty

void Empty()

Empties all the buttons out of the toolbar.


GToolBar::IsVertical

bool IsVertical(bool i)

Argument Description
bool i

Sets the toolbars orientation.


GToolBar::IsVertical

bool IsVertical()

Returns true if the toolbar is vertical and therefor down the lefthand side of the container or false if the toolbar is horizontal and along the top of the container.


GToolBar::SetBitmap

bool SetBitmap(char *File, int Bx, int By)

Argument Description
char *File The filename of the graphics file.
int Bx, int By The size of the buttons. Typically 16x16 or 24x24.

Sets the bitmap containing the graphics for the toolbar buttons.


GToolBar::SetDC

bool SetDC(GdcBasePrimitives *pDC, int Bx, int By)

Argument Description
GdcBasePrimitives *pDC Pointer to bitmap in memory.
int Bx, int By Size of the buttons.

Sets the bitmap used to draw the button faces.

Buttons are allocated part of the bitmap starting from the first button taking Bx pixels from the left, and then the next (non-separator) button taking the next Bx pixels and so on.


GToolBar::SetImageList

bool SetImageList(bool Own = true, GImageList *l, int Bx, int By)

Argument Description
bool Own = true true if the toolbar is going to be responsible for deleting the ImageList.
GImageList *l The list of images to use on the buttons.
int Bx, int By The size of the buttons.

By using an image list for the button faces you can assign images to buttons out of order, using some or all of the available images in the list. Unlike the SetDC and SetBitmap functions that allocate images in sequential order.

When using the image list you can specify the image to use on the button when you append the button.


Built: 13/9/2001 2:28:30 PM
© 2001 Matthew Allen
Lgi HomePage