Gtkmm

Gtkmm
Templat:Kotak info perangkat lunak/simple
Ditulis dalamC++
PlatformGTK
JenisPengikat bahasa
LisensiGNU Lesser General Public License
Situs webwww.gtkmm.org
Repositori

gtkmm (sebelumnya dikenal sebagai gtk-- atau gtk minus minus[1]) adalah antarmuka resmi C++ untuk GTK. gtkmm merupakan perangkat lunak bebas yang didistribusikan dibawah LGPL.

gtkmm memperbolehkan pembuatan antarmuka pengguna di dalam kode atau dengan Glade, dengan menggunakan kelas Gtk::Builder. Fitur lainnya mencakup typesafe callbacks, kumpulan elemen kontrol grafis, and ekstensibilitas widget melalui inheritance.

Contoh

//HelloWorldWindow.h

#ifndef HELLOWORLDWINDOW_H
#define HELLOWORLDWINDOW_H

#include <gtkmm/window.h>
#include <gtkmm/button.h>

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

  protected:
    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([] () {
          std::cout << "Hello world" << std::endl;
    });
    // Display all the child widgets of the window.
    show_all_children();
}
//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;
}

Program di atas akan membuat sebuah jendela dengan tombol berlabel "Hello World". Tombol tersebut akan mengirimkan "Hello World" ke output standar ketika diklik.

Program tersebut dapat dijalankan dengan perintah berikut:

$ g++ -std=c++11 *.cc -o example `pkg-config gtkmm-3.0 --cflags --libs`
$ ./example

Ini biasanya dilakukan menggunakan makefile simpel.

Referensi

  1. ^ "The gtkmm FAQ". Diarsipkan dari asli tanggal 2023-03-31. Diakses tanggal 2021-02-23.

Pranala luar

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.