vmap/libs/gtkutil/window.h

106 lines
2.9 KiB
C
Raw Normal View History

2020-11-17 11:16:16 +00:00
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined( INCLUDED_GTKUTIL_WINDOW_H )
#define INCLUDED_GTKUTIL_WINDOW_H
#include <uilib/uilib.h>
#include "debugging/debugging.h"
#include "generic/callback.h"
#include "widget.h"
gboolean window_focus_in_clear_focus_widget(ui::Window widget, GdkEventKey *event, gpointer data);
guint window_connect_focus_in_clear_focus_widget(ui::Window window);
unsigned int connect_floating(ui::Window main_window, ui::Window floating);
ui::Window create_floating_window(const char *title, ui::Window parent);
void destroy_floating_window(ui::Window window);
ui::Window create_persistent_floating_window(const char *title, ui::Window main_window);
gboolean persistent_floating_window_delete(ui::Window floating, GdkEvent *event, ui::Window main_window);
void window_remove_minmax(ui::Window window);
ui::ScrolledWindow create_scrolled_window(ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border = 0);
struct WindowPosition {
2021-08-04 20:23:18 +00:00
int x, y, w, h;
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
WindowPosition()
{
}
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
WindowPosition(int _x, int _y, int _w, int _h)
: x(_x), y(_y), w(_w), h(_h)
{
}
2020-11-17 11:16:16 +00:00
};
const WindowPosition c_default_window_pos(50, 25, 400, 300);
void window_get_position(ui::Window window, WindowPosition &position);
void window_set_position(ui::Window window, const WindowPosition &position);
struct WindowPosition_String {
2021-08-04 20:23:18 +00:00
static void Export(const WindowPosition &self, const Callback<void(const char *)> &returnz);
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
static void Import(WindowPosition &self, const char *value);
2020-11-17 11:16:16 +00:00
};
class WindowPositionTracker {
2021-08-04 20:23:18 +00:00
WindowPosition m_position;
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
static gboolean configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self);
2020-11-17 11:16:16 +00:00
public:
2021-08-04 20:23:18 +00:00
WindowPositionTracker()
: m_position(c_default_window_pos)
{
}
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
void sync(ui::Window window);
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
void connect(ui::Window window);
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
const WindowPosition &getPosition() const;
2020-11-17 11:16:16 +00:00
//hack
2021-08-04 20:23:18 +00:00
void setPosition(const WindowPosition &position);
2020-11-17 11:16:16 +00:00
};
struct WindowPositionTracker_String {
2021-08-04 20:23:18 +00:00
static void Export(const WindowPositionTracker &self, const Callback<void(const char *)> &returnz);
2020-11-17 11:16:16 +00:00
2021-08-04 20:23:18 +00:00
static void Import(WindowPositionTracker &self, const char *value);
2020-11-17 11:16:16 +00:00
};
#endif