User:arthurcy
This is a Wikipedia user page. This is not an encyclopedia article or the talk page for an encyclopedia article. If you find this page on any site other than Wikipedia, you are viewing a mirror site. Be aware that the page may be outdated and that the user whom this page is about may have no personal affiliation with any site other than Wikipedia. The original page is located at https://en.wikipedia.org/wiki/User:Arthurcy. |
gtkmm (formerly known as gtk-- or gtk minus minus[1]) is the official C++ interface for the popular GUI library GTK+. gtkmm is free software distributed under the GNU Lesser General Public License (LGPL).
gtkmm allows the creation of user interfaces either in code or with the Glade Interface Designer, using libglademm. Other features include typesafe callbacks, a comprehensive set of widgets, and the extensibility of widgets via inheritance.
Features
[edit]Due to the fact that gtkmm is the official C++ interface of the graphical user interface (GUI) library GTK+, C++ programmers can use the common OOP techniques such as inheritance, and C++-specific facilities such as STL (In fact, many of the gtkmm interfaces, especially those for widget containers, are designed to be STL-like).
Main features of gtkmm are listed as follows:
- Use inheritance to derive custom widgets.
- Type-safe signal handlers, in standard C++.
- Polymorphism.
- Use of Standard C++ Library, including strings, containers, and iterators.
- Full internationalisation with UTF-8.
- Complete C++ memory management.
- Object composition.
- Automatic deallocation of dynamically allocated widgets.
- Full use of C++ namespaces.
- No macros.
- Cross-platform: Linux (gcc), FreeBSD (gcc), NetBSD (gcc), Solaris (gcc, Forte), Win32 (gcc, MSVC++, .NET 2003), macOS (gcc), others.
- Free software and free of cost for both Open Source and proprietary development.
- Discussed, designed and implemented in public.
Hello World in Gtkmm
[edit]//HelloWorldWindnow.h
#ifndef __HELLOWORLDWINDOW_H__
#define __HELLOWORLDWINDOW_H__
#include<gtkmm/window.h>
#include<gtkmm/button.h>
//derive a new window widger from an existing one
//this window will only contain a button labelled "Hello World"
class HelloWorldWindow : public Gtk::Window {
public:
HelloWorldWindow( );
virtual ~HelloWorldWindow( ) { }
protected:
virtual void on_button_clicked( ); //event handler
Gtk::Button hello_world;
};
#endif
//HelloWorldWindow.cc
#include<iostream>
#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;
}
//main.cc
#include<gtkmm/main.h>
#include"HelloWorldWindow.h"
int main( int argc, char *argv[] )
{
//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 labelled "hello world".
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[2].
Applications
[edit]Some notable applications that use GTK+ as a widget toolkit include:
- Inkscape Vector graphics drawing.
- Gnomoradio peer to peer sharing of freely licensed music.
- K-3D 3D modelling and animation.
- Workrave Assists in recovery and prevention of RSI.
- GParted disk partitioning tool.
- Gobby Collaborative text editor.
- Nemiver GUI for the GNU debugger gdb.
- Referencer document organiser and bibliography manager
- MySQL Administrator Database GUI.