Tutorial

Inti Logo

« AccelLabel
The Tooltips Object »

Arrows

The Arrow widget draws an arrowhead, facing in a number of possible directions and having a number of possible styles. It can be very useful when placed on a button in many applications. Like the Label widget, it emits no signals.

To create a new arrow, use one of the following constructors:

Arrow();

Arrow(Gtk::ArrowType arrow_type, Gtk::ShadowType shadow_type);


The values for ArrowType are:
and the values for ShadowType are
The first constructor creates a default arrow widget with an ArrowType of ARROW_RIGHT and a ShadowType of SHADOW_OUT. The second constructor creates an arrow widget with the specified arrow_type and shadow_type.

You can set the arrow type with this method:

void set(Gtk::ArrowType arrow_type, Gtk::ShadowType shadow_type);

Here's a brief example to illustrate their use.

Arrows

The  header file for Arrow Buttons is arrow.h:

#include<inti/main.h>
#include <inti/core.h>
#include <inti/gtk/arrow.h>
#include <inti/gtk/button.h>


using namespace Inti;

// ArrowButton

class ArrowButton : public Gtk::Button
{
    ArrowButton(const ArrowButton&);
    ArrowButton& operator=(const ArrowButton&);

public:
    ArrowButton(Gtk::ArrowType  arrow_type, Gtk::ShadowType shadow_type);
    virtual ~ArrowButton();
};

// ArrowWindow

class ArrowWindow : public Gtk::Window
{
    ArrowWindow(const ArrowWindow&);
    ArrowWindow& operator=(const ArrowWindow&);

public:
    ArrowWindow();
    virtual ~ArrowWindow();
};

and the source file is arrow.cc:

#include"arrow.h"

// ArrowButton

ArrowButton::ArrowButton(Gtk::ArrowType  arrow_type, Gtk::ShadowType shadow_type)
{
    // Create an Arrow widget with the specified parameters and pack it into the button.
    Gtk::Arrow *arrow = new Gtk::Arrow(arrow_type, shadow_type);
    add(*arrow);
}

ArrowButton::~ArrowButton()
{
}

// ArrowWindow

ArrowWindow::ArrowWindow()
{
    set_title("Arrow Buttons");
    set_border_width(10);

    // Create a box to hold the arrows/buttons
    Gtk::HBox *hbox = new Gtk::HBox;
    hbox->set_border_width(2);
    add(*hbox);

    // Pack and show all the widgets.
    ArrowButton *button = new ArrowButton(Gtk::ARROW_UP, Gtk::SHADOW_IN);
    hbox->pack_start(*button, false,false, 3);

    button = new ArrowButton(Gtk::ARROW_DOWN, Gtk::SHADOW_OUT);
    hbox->pack_start(*button, false,false, 3);

    button = new ArrowButton(Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_IN);
    hbox->pack_start(*button, false,false, 3);

    button = new ArrowButton(Gtk::ARROW_RIGHT, Gtk::SHADOW_ETCHED_OUT);
    hbox->pack_start(*button, false,false, 3);
    show_all();
}

ArrowWindow::~ArrowWindow()
{
}

// Convenience macro for a simple main function

GCODE_MAIN(ArrowWindow)


The INTI_MAIN macro is a convenience macro that writes a simple main function, its only argument is the name of the main window class. The macro is defined in <inti/main.h> as

#define INTI_MAIN(MainWidget)\
    int main (int argc, char *argv[])\
    {\
        Inti::Main::init(&argc, &argv);\
        MainWidget main_widget;\
        main_widget.sig_destroy().connect(slot(&Inti::Main::quit));\
        main_widget.show();\
        Inti::Main::run();\
        return 0;\
    }

Most main functions in C++ are as simple as this because all the creation work for the main window is done inside its constructor, not the main function.


« AccelLabel Index
Miscellaneous Widgets
Top
The Tooltips Object »