Gtkmm
Encyclopedia
gtkmm is the official C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 interface for the popular GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...

 library GTK+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

. gtkmm is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 distributed under the GNU Lesser General Public License
GNU Lesser General Public License
The GNU Lesser General Public License or LGPL is a free software license published by the Free Software Foundation . It was designed as a compromise between the strong-copyleft GNU General Public License or GPL and permissive licenses such as the BSD licenses and the MIT License...

 (LGPL).

gtkmm allows the creation of user interfaces either in code or with the Glade Interface Designer
Glade Interface Designer
Glade Interface Designer is a graphical user interface builder for GTK+, with additional components for GNOME. In its third version, Glade is programming language–independent, and does not produce code for events, but rather an XML file that is then used with an appropriate binding .Glade is...

, using the Gtk::Builder class. Other features include typesafe callbacks, a comprehensive set of widget
Widget (computing)
In computer programming, a widget is an element of a graphical user interface that displays an information arrangement changeable by the user, such as a window or a text box. The defining characteristic of a widget is to provide a single interaction point for the direct manipulation of a given...

s, and the extensibility of widgets via inheritance
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

.

Features

Due to the fact that gtkmm is the official C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 interface of the GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...

 library GTK+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

, C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 programmers can use the common OOP
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 techniques such as inheritance
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

, and C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

-specific facilities such as STL
Standard Template Library
The Standard Template Library is a C++ software library which later evolved into the C++ Standard Library. It provides four components called algorithms, containers, functors, and iterators. More specifically, the C++ Standard Library is based on the STL published by SGI. Both include some...

 (In fact, many of the gtkmm interfaces, especially those for widget
Widget (computing)
In computer programming, a widget is an element of a graphical user interface that displays an information arrangement changeable by the user, such as a window or a text box. The defining characteristic of a widget is to provide a single interaction point for the direct manipulation of a given...

 containers
Container (data structure)
In computer science, a container is a class, a data structure, or an abstract data type whose instances are collections of other objects. In other words; they are used for storing objects in an organized way following specific access rules...

, are designed to be similar to the Standard Template Library
Standard Template Library
The Standard Template Library is a C++ software library which later evolved into the C++ Standard Library. It provides four components called algorithms, containers, functors, and iterators. More specifically, the C++ Standard Library is based on the STL published by SGI. Both include some...

 (STL)).

Main features of gtkmm are listed as follows:
  • Use inheritance
    Inheritance (computer science)
    In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

     to derive custom widgets
    Widget (computing)
    In computer programming, a widget is an element of a graphical user interface that displays an information arrangement changeable by the user, such as a window or a text box. The defining characteristic of a widget is to provide a single interaction point for the direct manipulation of a given...

    .
  • Type-safe signal handlers
    Signal programming
    Signal programming is used in the same sense as dataflow programming, and is similar to event-driven programming.The word signal is used instead of the word dataflow in documentation of such libraries as Qt, GTK+ and libsigc++...

    , in standard C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

    .
  • Polymorphism
    Polymorphism in object-oriented programming
    Subtype polymorphism, almost universally called just polymorphism in the context of object-oriented programming, is the ability to create a variable, a function, or an object that has more than one form. The word derives from the Greek "πολυμορφισμός" meaning "having multiple forms"...

    .
  • Use of Standard C++ Library, including strings
    String (computer science)
    In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

    , containers
    Container (data structure)
    In computer science, a container is a class, a data structure, or an abstract data type whose instances are collections of other objects. In other words; they are used for storing objects in an organized way following specific access rules...

    , and iterators.
  • Full internationalisation with UTF-8
    UTF-8
    UTF-8 is a multibyte character encoding for Unicode. Like UTF-16 and UTF-32, UTF-8 can represent every character in the Unicode character set. Unlike them, it is backward-compatible with ASCII and avoids the complications of endianness and byte order marks...

    .
  • Complete C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

     memory management.
    • Object composition
      Object composition
      In computer science, object composition is a way to combine simple objects or data types into more complex ones...

      .
    • Automatic deallocation of dynamically allocated widgets
      Widget (computing)
      In computer programming, a widget is an element of a graphical user interface that displays an information arrangement changeable by the user, such as a window or a text box. The defining characteristic of a widget is to provide a single interaction point for the direct manipulation of a given...

      .
  • Full use of C++ namespaces
    Namespace (computer science)
    A namespace is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols . An identifier defined in a namespace is associated only with that namespace. The same identifier can be independently defined in multiple namespaces...

    .
  • No macros.
  • Cross-platform: Linux
    Linux
    Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

     (gcc
    GNU Compiler Collection
    The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

    ), FreeBSD
    FreeBSD
    FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...

     (gcc
    GNU Compiler Collection
    The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

    ), NetBSD
    NetBSD
    NetBSD is a freely available open source version of the Berkeley Software Distribution Unix operating system. It was the second open source BSD descendant to be formally released, after 386BSD, and continues to be actively developed. The NetBSD project is primarily focused on high quality design,...

     (gcc
    GNU Compiler Collection
    The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

    ), Solaris (gcc
    GNU Compiler Collection
    The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

    , Forte), Win32 (gcc
    GNU Compiler Collection
    The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

    , MSVC++
    Visual C++
    Microsoft Visual C++ is a commercial , integrated development environment product from Microsoft for the C, C++, and C++/CLI programming languages...

    , .Net 2003
    .NET Framework
    The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

    ), Mac OS X
    Mac OS X
    Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

     (gcc
    GNU Compiler Collection
    The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

    ), others.

Hello World in Gtkmm


//HelloWorldWindow.h
  1. ifndef HELLOWORLDWINDOW_H__
  2. define HELLOWORLDWINDOW_H__

  1. include
  2. include


// Derive a new window widget from an existing one.
// This window will only contain a button labelled "Hello World"
class HelloWorldWindow : public Gtk::Window
{
public:
HelloWorldWindow;
~HelloWorldWindow;

protected:
void on_button_clicked; //event handler

Gtk::Button hello_world;
};
  1. endif




//HelloWorldWindow.cc
  1. include
  2. include "HelloWorldWindow.h"


HelloWorldWindow::HelloWorldWindow
: hello_world( "Hello World" )
{
// Set the title of the window.
set_title( "Hello World" );

// Add the member button to the window,
add( hello_world );

// Handle the 'click' event.
hello_world.signal_clicked.connect(
sigc::mem_fun( *this, &HelloWorldWindow::on_button_clicked ) );

// Display all the child widgets of the window.
show_all_children;
}

void HelloWorldWindow::on_button_clicked
{
std::cout << "Hello world" << std::endl;
}

HelloWorldWindow::~HelloWorldWindow
{
}




//main.cc
  1. include
  2. include "HelloWorldWindow.h"


int main( int argc, char *argv[] )/* Hello World in Gtkmm */
{
// Initialization
Gtk::Main kit( argc, argv );

// Create a hello world window object
HelloWorldWindow example;

// gtkmm main loop
Gtk::Main::run( example );
return 0;
}


This program will create a window with a button labeled "Hello World". The button sends "Hello world" to standard output when clicked.

To run this program, just type the following command at your terminal:

g++ *.cc -o example `pkg-config gtkmm-2.4 --cflags --libs`


./example

or you can write a simple makefile.

To run gtkmm programs on Windows, see official manual.

Applications

Some notable applications that use Gtkmm include:
  • Inkscape
    Inkscape
    Inkscape is a free software vector graphics editor, licensed under the GNU General Public License. Its goal is to implement full support for the Scalable Vector Graphics 1.1 standard....

     Vector graphics drawing.
  • K-3D 3D modelling and animation.
  • Workrave
    Workrave
    Workrave is a free software application intended to prevent computer users from developing or aggravating occupational diseases such as carpal tunnel syndrome, repetitive strain injuries, or myopia....

     Assists in recovery and prevention of RSI.
  • GParted
    GParted
    GParted is a GTK+ front-end to GNU Parted and the official GNOME Partition Editor application.It is used for creating, deleting, resizing, moving, checking and copying partitions, and the file systems on them...

     disk partitioning tool.
  • Gobby
    Gobby
    Gobby is a free software collaborative real-time editor available on Windows and Unix-like platforms. It was initially released in June 2005 by the 0x539 dev group....

     Collaborative text editor.
  • Nemiver
    Nemiver
    Nemiver is a standalone graphical C and C++ debugger that integrates in the GNOME desktop environment.It currently features a backend which uses the well known GNU Debugger .The creator and the current lead developer is Dodji Seketeli.- General :...

     GUI for the GNU debugger gdb.
  • Referencer
    Referencer
    Referencer is a GNOME application to organize documents or references, and ultimately generate a BibTeX bibliography file. It is designed with the scientist/researcher in mind, and "document" may be taken to mean "paper" in general, although Referencer can deal with any kind of document that BibTeX...

     document organiser and bibliography manager
  • MySQL
    MySQL
    MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

     Administrator Database GUI.
  • Ardour Open Source digital audio workstation (DAW) for Linux and MacOS.
  • Gnote
    Gnote
    Gnote is a free and open-source desktop notetaking application written for Linux, cloned from Tomboy by Hubert Figuiere. It uses a Wiki-like linking system to connect notes together. Gnote is part of the GNOME desktop environment, often filling the need for personal information management. The main...

     desktop notetaking application.

See also

  • GTK+
    GTK+
    GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

  • Widget toolkit
    Widget toolkit
    In computing, a widget toolkit, widget library, or GUI toolkit is a set of widgets for use in designing applications with graphical user interfaces...

  • Qt
    Qt (toolkit)
    Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface , and also used for developing non-GUI programs such as command-line tools and consoles for servers...

  • wxWidgets
    WxWidgets
    wxWidgets is a widget toolkit for creating graphical user interfaces for cross-platform applications. wxWidgets enables a program's GUI code to compile and run on several computer platforms with minimal or no code changes...

  • FLTK
    FLTK
    FLTK is a cross-platform GUI library developed by Bill Spitzak and others. Made with 3D graphics programming in mind, it has an interface to OpenGL, but it is also suitable for general GUI programming....

  • FOX toolkit
    FOX toolkit
    The FOX toolkit is an open source, cross-platform widget toolkit, that is, a library of basic elements for building a graphical user interface...

  • VCF
    Visual Component Framework
    The Visual Component Framework is an open source project for development under Microsoft Windows and Apple Macintosh that is distributed under the BSD license. It is an advanced C++ application framework that makes it easier to produce GUI-based C++ applications. The framework is based on a...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK