Xfce Foundation Classes
 « Main Page | Index


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. The Arrow widget is a 'no window' widget and emits no signals.

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


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

The 'arrow_type' argument can be one of the values from the Gtk::ArrowType enum:
The 'shadow_type' argument can be one of the values from the Gtk::ShadowType enum:
  • SHADOW_OUT (the default)
The first constructor creates a default arrow widget with an arrow type of ARROW_RIGHT and a shadow type 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);

Arrow Buttons Example

The Arrow Buttons example creates a small window containing four arrow buttons. Each button displays an arrow pointing in one of the four cardinal directions up, down, left and right.

The  header file for Arrow Buttons is <arrow.hh>:

#include <xfc/main.hh>
#include <xfc/gtk/arrow.hh>
#include <xfc/gtk/button.hh>
#include <xfc/gtk/window.hh>

using namespace Xfc;

// ArrowButton

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

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

// ArrowWindow

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

    virtual ~ArrowWindow();

and the source file is <arrow.cc>:

#include "arrow.hh"
#include <xfc/gtk/box.hh>

// 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);


// ArrowWindow

    set_title("Arrow Buttons");

    // Create a box to hold the arrows/buttons
    Gtk::HBox *hbox = new Gtk::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);


// Convenience macro for a simple main function


Compiling Arrow Buttons

If you compiled and installed XFC yourself, you will find the source code for Arrow Buttons in the <examples/howto/arrow> source directory along with a Makefile. If XFC came pre-installed, or you installed it from an RPM package, you will find the source code in the </usr/share/doc/xfcui-X.X/examples/howto/arrow> subdirectory. In this case you will have to create the Makefile yourself (replace X.X with the version number of the libXFCui library you have installed).

To create a Makefile for Arrow Buttons, add the following lines to a new text file and save it using the name "Makefile":

CC = g++

CFLAGS = -Wall -O2

arrow: arrow.cc arrow.hh
    $(CC) arrow.cc -o arrow $(CFLAGS) `pkg-config xfcui-X.X --cflags --libs`

    rm -f *.o arrow

If you cut and paste these lines make sure the whitespace before $(CC) and rm is a tab character. When you compile and run this program you will see the following window appear:

The XFC_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 <xfc/main.hh> as:

#define XFC_MAIN(MainWidget)\
    int main (int argc, char *argv[])\
        Xfc::Main::init(&argc, &argv);\
        MainWidget main_widget;\
        return 0;\

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

Copyright © 2004-2005 The XFC Development Team Top
XFC 4.4