AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
PlatformAbstractionGtk.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12#pragma once
   13
   14#include <gio/gio.h>
   15#include "gtk_types.h"
   16#include "AUI/Platform/linux/IPlatformAbstraction.h"
   17#include "AUI/Platform/linux/AGlibPtr.h"
   18
   19class PlatformAbstractionGtk: public IPlatformAbstraction {
   20public:
   21    static aui::gtk4_fake::GtkWindow*& nativeHandle(AWindow& window) {
   22        return reinterpret_cast<aui::gtk4_fake::GtkWindow*&>(IPlatformAbstraction::nativeHandle(window));
   23    }
   24
   25    PlatformAbstractionGtk();
   26    ~PlatformAbstractionGtk() override;
   27    void init() override;
   28    _<ACursor::Custom> createCustomCursor(AImageView image) override;
   29    void applyNativeCursor(const ACursor &cursor, AWindow *pWindow) override;
   30    void copyToClipboard(const AString &text) override;
   31    AString pasteFromClipboard() override;
   32    glm::ivec2 desktopGetMousePosition() override;
   33    void desktopSetMousePosition(glm::ivec2 pos) override;
   34    float platformGetDpiRatio() override;
   35    AInput::Key inputFromNative(int k) override;
   36    int inputToNative(AInput::Key key) override;
   37    bool inputIsKeyDown(AInput::Key k) override;
   38    void windowSetStyle(AWindow &window, WindowStyle ws) override;
   39    float windowFetchDpiFromSystem(AWindow &window) override;
   40    void windowRestore(AWindow &window) override;
   41    void windowMinimize(AWindow &window) override;
   42    bool windowIsMinimized(AWindow &window) const override;
   43    bool windowIsMaximized(AWindow &window) const override;
   44    void windowMaximize(AWindow &window) override;
   45    glm::ivec2 windowGetPosition(AWindow &window) const override;
   46    void windowFlagRedraw(AWindow &window) override;
   47    void windowShow(AWindow &window) override;
   48    void windowSetSize(AWindow &window, glm::ivec2 size) override;
   49    void windowSetGeometry(AWindow &window, int x, int y, int width, int height) override;
   50    void windowSetIcon(AWindow &window, const AImage &image) override;
   51    void windowHide(AWindow &window) override;
   52    void windowManagerNotifyProcessMessages() override;
   53    void windowManagerLoop() override;
   54    void windowManagerIteration();
   55    void windowBlockUserInput(AWindow &window, bool blockUserInput) override;
   56    void windowAllowDragNDrop(AWindow &window) override;
   57    void windowShowTouchscreenKeyboardImpl(AWindow &window) override;
   58    void windowHideTouchscreenKeyboardImpl(AWindow &window) override;
   59    void windowMoveToCenter(AWindow &window) override;
   60    void windowQuit(AWindow &window) override;
   61    void windowAnnounceMinMaxSize(AWindow &window) override;
   62    void windowManagerInitNativeWindow(const IRenderingContext::Init &init) override;
   63    float windowGetDpiRatio(AWindow &window) override;
   64    AMessageBox::ResultButton messageBoxShow(
   65        AWindow *parent, const AString &title, const AString &message, AMessageBox::Icon icon,
   66        AMessageBox::Button b) override;
   67
   68    static AInput::Key inputFromNative2(unsigned key);
   69
   70protected:
   71    AGlibPtr<GApplication> mApplication;
   72    aui::gtk4_fake::GtkWidget* windowManagerInitGtkBox(const IRenderingContext::Init &init) const;
   73    void windowManagerInitCommon(const IRenderingContext::Init &init, aui::gtk4_fake::GtkWindow* window);
   74
   75private:
   76    GMainContext* mMainContext;
   77};
Represents cursor type.
Definition ACursor.h:26
Takes care of g_object_ref and g_object_unref() reference counting mechanism of Glib objects.
Definition AGlibPtr.h:25
Non-owning read-only image representation of some format.
Definition AImageView.h:58
Owning image representation.
Definition AImage.h:25
Represents a Unicode character string.
Definition AString.h:38
Represents a window in the underlying windowing system.
Definition AWindow.h:45
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
ResultButton
Button that the user has clicked.
Definition AMessageBox.h:104
Button
Specifies button(s) to be displayed.
Definition AMessageBox.h:79
Icon
Specifies icon to be displayed.
Definition AMessageBox.h:51
Definition IRenderingContext.h:38