// spaces to make label nice and big
#define NO_FILE_MSG " (no file loaded) "
-static GtkWidget *pDialogWnd;
+static ui::Window pDialogWnd{ui::null};
static GtkWidget *pNotebook;
static GtkTooltips *pTooltips;
CBackgroundDialogPage *pPage;
pDialogWnd = gtk_dialog_new_with_buttons( "Background Images",
- GTK_WINDOW( g_pMainWidget ),
+ g_pMainWidget,
(GtkDialogFlags)( GTK_DIALOG_DESTROY_WITH_PARENT ),
// TODO dialog with no buttons
// GTK_STOCK_CLOSE,
}
void ShowBackgroundDialog(){
- gtk_window_present( GTK_WINDOW( pDialogWnd ) );
+ gtk_window_present( pDialogWnd );
}
void ShowBackgroundDialogPG( int page ){
static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge";
// globals
-ui::Widget g_pRadiantWnd{ui::null};
+ui::Window g_pRadiantWnd{ui::null};
static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n"
"by digibob (digibob@splashdamage.com)\n"
"MarsMattel, RR2DO2\n";
extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
- g_pRadiantWnd = ui::Widget::from(pMainWidget);
+ g_pRadiantWnd = ui::Window::from(pMainWidget);
return "bobToolz for GTKradiant";
}
gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check );
}
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop;
EMessageBoxReturn *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
auto window = ui::Window( ui::window_type::TOP );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
+ gtk_window_set_title( window, lpCaption );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
ret = eIDNO;
}
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Intersect" );
+ gtk_window_set_title( window, "Intersect" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" );
+ gtk_window_set_title( window, "Polygon Builder" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" );
+ gtk_window_set_title( window, "Stair Builder" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
ret = eIDCANCEL;
// +djbob: need our "little" modal loop mars :P
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
+ gtk_window_set_title( window, "Door Builder" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
// ----------------- //
//+djbob
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
+ gtk_window_set_title( window, "Texture Reset" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
// ----------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
+ gtk_window_set_title( window, "CTF Colour Changer" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
+ gtk_window_set_title( window, "Texture Reset" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
+ gtk_window_set_title( window, "Train Thing" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
+ gtk_window_set_title( window, "Make Chain" );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
ret = eIDCANCEL;
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
}
void OnExportClicked( ui::Button button, gpointer user_data ){
- ui::Widget window = lookup_widget( button , "w_plugplug2" );
+ auto window = ui::Window::from(lookup_widget( button , "w_plugplug2" ));
ASSERT_TRUE( window );
const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true );
if ( !cpath ) {
std::set<std::string> ignore;
GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) );
- ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) ));
+ ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model( view ));
GtkTreeIter iter;
gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter );
const gchar* name = gtk_entry_get_text( edit );
if ( g_utf8_strlen( name, -1 ) > 0 ) {
- ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ) ) ));
+ ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ) ) );
list.append(0, name);
gtk_entry_set_text( edit, "" );
}
void OnRemoveMaterial( ui::Button button, gpointer user_data ){
GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) );
- ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) ));
+ ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( view ) );
GtkTreeSelection* sel = gtk_tree_view_get_selection( view );
GtkTreeIter iter;
auto w_plugplug2 = ui::Window( ui::window_type::TOP );
gtk_widget_set_name( w_plugplug2, "w_plugplug2" );
- gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" );
- gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER );
- gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE );
+ gtk_window_set_title( w_plugplug2, "BrushExport-Plugin 3.0 by namespace" );
+ gtk_window_set_position( w_plugplug2, GTK_WIN_POS_CENTER );
+ gtk_window_set_destroy_with_parent( w_plugplug2, TRUE );
auto vbox1 = ui::VBox( FALSE, 0 );
gtk_widget_set_name( vbox1, "vbox1" );
ui::Window g_mainwnd{ui::null};
const char* init( void* hApp, void* pMainWidget ){
- g_mainwnd = ui::Window(GTK_WINDOW(pMainWidget));
+ g_mainwnd = ui::Window::from(pMainWidget);
ASSERT_TRUE( g_mainwnd );
return "";
}
static const char *PLUGIN_COMMANDS = "About...,-,Load Camera...,-,Preview Camera,-,Camera Inspector...,-,New Spline Camera,New Interpolated Camera,New Fixed Camera";
// globals
-GtkWidget *g_pRadiantWnd = NULL;
-GtkWidget *g_pCameraInspectorWnd = NULL;
+ui::Window g_pRadiantWnd{ui::null};
+ui::Window g_pCameraInspectorWnd{ui::null};
CCamera *firstCam = NULL; // double linked list
CCamera *firstFreeCam = NULL; // single linked list
CCamera *currentCam = NULL; // single item
CCamera *GetCurrentCam();
// globals
-extern GtkWidget *g_pRadiantWnd;
-extern GtkWidget *g_pCameraInspectorWnd;
+extern ui::Window g_pRadiantWnd;
+extern ui::Window g_pCameraInspectorWnd;
extern CCamera *firstCam;
extern bool g_bEditOn;
extern int g_iEditMode;
// create the window
auto window = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( window ), "New Camera" );
+ gtk_window_set_title( window, "New Camera" );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
// create the window
auto window = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" );
+ gtk_window_set_title( window, "Rename Path" );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
// create the window
auto window = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( window ), "Add Target" );
+ gtk_window_set_title( window, "Add Target" );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
// create the window
auto window = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( window ), "Add Event" );
+ gtk_window_set_title( window, "Add Event" );
window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
window.show();
gtk_grab_add( window );
// create the window
auto window = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" );
+ gtk_window_set_title( window, "Camera Inspector" );
window.connect( "delete_event", G_CALLBACK( ci_close ), NULL );
window.connect( "expose_event", G_CALLBACK( ci_expose ), NULL );
// window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_transient_for( window, g_pRadiantWnd );
// don't use show, as you don't want to have it displayed on startup ;-)
gtk_widget_realize( window );
#include "camera.h"
-void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
"GenSurf", eMB_OK, eMB_ICONWARNING );
sprintf( Text, "%d", (int)xyz[Vertex[0].i][Vertex[0].j].fixed_value );
gtk_entry_set_text( GTK_ENTRY( widget ), Text );
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), widget );
+ gtk_window_set_focus( widget.window(), widget );
}
else if ( i != xyz[Vertex[0].i][Vertex[0].j].fixed_value ) {
for ( k = 0; k < NumVerticesSelected; k++ )
"Wall facing 180","Wall facing 270" };
auto dlg = g_pWnd = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption );
+ gtk_window_set_title( dlg, gszCaption );
dlg.connect( "delete_event", G_CALLBACK( main_close ), NULL );
// dlg.connect( "destroy", G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
+ gtk_window_set_transient_for( dlg, g_pRadiantWnd );
auto hbox = ui::HBox( FALSE, 5 );
hbox.show();
extern HCURSOR ghCursorDefault;
extern HCURSOR ghCursorVertex;
extern HINSTANCE ghInst;*/
-extern GtkWidget *g_pRadiantWnd;
+extern ui::Window g_pRadiantWnd;
extern ui::Window g_pWnd;
/*extern HWND ghwndAngles;
extern HWND ghwndFix;
#endif
auto dlg = g_pWndPreview = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" );
+ gtk_window_set_title( dlg, "GtkGenSurf Preview" );
dlg.connect( "delete_event", G_CALLBACK( preview_close ), NULL );
dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pWnd ) );
- gtk_window_set_default_size( GTK_WINDOW( dlg ), 300, 400 );
+ gtk_window_set_transient_for( dlg, g_pWnd );
+ gtk_window_set_default_size( dlg, 300, 400 );
auto vbox = ui::VBox( FALSE, 5 );
vbox.show();
// =============================================================================
// Ripped from TexTool.cpp
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "loop" );
ret = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "ret" );
G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy",
G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
+ gtk_window_set_title( window, lpCaption );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop );
gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret );
#include "prtview.h"
#include "ConfigDialog.h"
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
#include "prtview.h"
#include "portals.h"
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
int loop = 1, ret = IDCANCEL;
auto dlg = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" );
+ gtk_window_set_title( dlg, "Portal Viewer Configuration" );
dlg.connect( "delete_event",
G_CALLBACK( dialog_delete_callback ), NULL );
dlg.connect( "destroy",
#include "prtview.h"
#include "portals.h"
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
int loop = 1, ret = IDCANCEL;
auto dlg = ui::Window( ui::window_type::TOP );
- gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" );
+ gtk_window_set_title( dlg, "Load .prt" );
dlg.connect( "delete_event",
G_CALLBACK( dialog_delete_callback ), NULL );
dlg.connect( "destroy",
void CreateTagFile();
const char* init( void* hApp, void* pMainWidget ){
- g_window = ui::Window(GTK_WINDOW( pMainWidget ));
+ g_window = ui::Window::from(pMainWidget);
return "";
}
const char* getName(){
}
// function for close button to destroy the toplevel widget
-static void close_window( GtkWidget *widget, gpointer data ){
- ui::Widget(gtk_widget_get_toplevel( widget ) ).destroy();
+static void close_window( ui::Widget widget, gpointer data ){
+ widget.window().destroy();
}
// callback function to assign the optimal mapcoords to the spinboxes
}
// write the values of the Spinner-Boxes to the worldspawn
-static void set_coordinates( GtkWidget *widget, gpointer data ){
+static void set_coordinates( ui::Widget widget, gpointer data ){
//Str str_min, str_max;
char buffer[10], str_min[20], str_max[20];
char MenuList[100] = "";
const char* init( void* hApp, void* pMainWidget ){
- main_window = ui::Window(GTK_WINDOW( pMainWidget ));
+ main_window = ui::Window::from(pMainWidget);
return "Initializing SunPlug for GTKRadiant";
}
const char* getName(){
// About dialog
void about_plugin_window(){
auto window = ui::Window( ui::window_type::TOP ); // create a window
- gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
+ gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window
window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
- gtk_window_set_title( GTK_WINDOW( window ), "About SunPlug" ); // set the title of the window for the window
- gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window
- gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows
+ gtk_window_set_title( window, "About SunPlug" ); // set the title of the window for the window
+ gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window
+ gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), (void *) window ); // connect the click event to close the window
vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box
- gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window on screen
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window on screen
gtk_widget_show_all( window ); // show the window and all subelements
}
// in any case we need a window to show the user what to do
auto window = ui::Window( ui::window_type::TOP ); // create the window
- gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
+ gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window
window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
- gtk_window_set_title( GTK_WINDOW( window ), "ET-MapCoordinator" ); // set the title of the window for the window
- gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window
- gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows
+ gtk_window_set_title( window, "ET-MapCoordinator" ); // set the title of the window for the window
+ gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window
+ gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box
}
- gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window
gtk_widget_show_all( window ); // show the window and all subelements
}
ui::Window g_mainwnd{ui::null};
const char* init( void* hApp, void* pMainWidget ){
- g_mainwnd = ui::Window(GTK_WINDOW( pMainWidget ));
+ g_mainwnd = ui::Window::from(pMainWidget);
return "Initializing GTKRadiant UFOAI plugin";
}
const char* getName(){
/**
* @brief function for close button to destroy the toplevel widget
*/
-static void close_window( GtkWidget *widget, gpointer data ){
- ui::Widget(gtk_widget_get_toplevel( widget ) ).destroy();
+static void close_window( ui::Widget widget, gpointer data ){
+ widget.window().destroy();
}
/* =============================== */
// simple Message Box, see above for the 'type' flags
-typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Widget parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ );
+typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Window parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ );
// file and directory selection functions return null if the user hits cancel
// - 'title' is the dialog title (can be null)
// - 'path' is used to set the initial directory (can be null)
// - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
-typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Widget parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ );
+typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Window parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ );
// returns a gchar* string that must be g_free'd by the user
-typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Widget parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ );
+typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Window parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ );
// return true if the user closed the dialog with 'Ok'
// 'color' is used to set the initial value and store the selected value
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
-typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color,
+typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Window parent, Vector3& color,
const char* title /* = "Choose Color"*/ );
// load a .bmp file and create a GtkImage widget from it
return FALSE;
}
-gboolean FreezePointer::motion_delta(ui::Widget widget, GdkEventMotion *event, FreezePointer *self)
+gboolean FreezePointer::motion_delta(ui::Window widget, GdkEventMotion *event, FreezePointer *self)
{
int current_x, current_y;
- Sys_GetCursorPos( ui::Window(GTK_WINDOW( widget )), ¤t_x, ¤t_y );
+ Sys_GetCursorPos( widget, ¤t_x, ¤t_y );
int dx = current_x - self->last_x;
int dy = current_y - self->last_y;
int ddx = current_x - self->recorded_x;
if ( dx != 0 || dy != 0 ) {
//globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n";
if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) {
- Sys_SetCursorPos( ui::Window(GTK_WINDOW( widget )), self->recorded_x, self->recorded_y );
+ Sys_SetCursorPos( widget, self->recorded_x, self->recorded_y );
self->last_x = self->recorded_x;
self->last_y = self->recorded_y;
}
public:
FreezePointer() : handle_motion( 0 ), m_function( 0 ), m_data( 0 ){
}
-static gboolean motion_delta( ui::Widget widget, GdkEventMotion *event, FreezePointer* self );
+static gboolean motion_delta( ui::Window widget, GdkEventMotion *event, FreezePointer* self );
void freeze_pointer( ui::Window window, MotionDeltaFunction function, void* data );
return table;
}
-void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ){
+void DialogVBox_packRow( ui::Box vbox, ui::Widget row ){
vbox.pack_start( row, FALSE, FALSE, 0 );
}
ui::Label DialogLabel_new( const char* name );
ui::Table DialogRow_new( const char* name, ui::Widget widget );
-void DialogVBox_packRow( ui::VBox vbox, ui::Widget row );
+void DialogVBox_packRow( ui::Box vbox, ui::Widget row );
#endif
static char g_file_dialog_file[1024];
-const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
+const char* file_dialog_show( ui::Window parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
filetype_t type;
if ( pattern == 0 ) {
title = open ? "Open File" : "Save File";
}
- GtkWidget* dialog;
+ ui::Dialog dialog{ui::null};
if ( open ) {
- dialog = gtk_file_chooser_dialog_new( title,
- GTK_WINDOW( parent ),
+ dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title,
+ parent,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL );
+ NULL ));
}
else
{
- dialog = gtk_file_chooser_dialog_new( title,
- GTK_WINDOW( parent ),
+ dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title,
+ parent,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL );
+ NULL ));
gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER( dialog ), "unnamed" );
}
- gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
- gtk_window_set_position( GTK_WINDOW( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( dialog, TRUE );
+ gtk_window_set_position( dialog, GTK_WIN_POS_CENTER_ON_PARENT );
// we expect an actual path below, if the path is 0 we might crash
if ( path != 0 && !string_empty( path ) ) {
return g_file_dialog_file;
}
-char* dir_dialog( ui::Widget parent, const char* title, const char* path ){
- GtkWidget* dialog = gtk_file_chooser_dialog_new( title,
- GTK_WINDOW( parent ),
+char* dir_dialog( ui::Window parent, const char* title, const char* path ){
+ auto dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title,
+ parent,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL );
+ NULL ));
- gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
- gtk_window_set_position( GTK_WINDOW( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( dialog, TRUE );
+ gtk_window_set_position( dialog, GTK_WIN_POS_CENTER_ON_PARENT );
if ( !string_empty( path ) ) {
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), path );
filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog ) );
}
- ui::Widget(dialog).destroy();
+ dialog.destroy();
return filename;
}
-const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
+const char* file_dialog( ui::Window parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
for (;; )
{
const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save );
/// \file
/// GTK+ file-chooser dialogs.
-const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false );
+const char* file_dialog( ui::Window parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false );
/// \brief Prompts the user to browse for a directory.
/// The prompt window will be transient to \p parent.
/// The directory will initially default to \p path, which must be an absolute path.
/// The returned string is allocated with \c g_malloc and must be freed with \c g_free.
-char* dir_dialog( ui::Widget parent, const char* title = "Choose Directory", const char* path = "" );
+char* dir_dialog( ui::Window parent, const char* title = "Choose Directory", const char* path = "" );
#endif
}
}
-EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){
+EMessageBoxReturn gtk_MessageBox( ui::Window parentWindow, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
ModalDialogButton yes_button( dialog, eIDYES );
ModalDialogButton no_button( dialog, eIDNO );
- ui::Window parentWindow = ui::Window(parent ? GTK_WINDOW( parent ) : 0);
-
ui::Window window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 );
if ( parentWindow ) {
#include "qerplugin.h"
/// \brief Shows a modal message-box.
-EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT );
+EMessageBoxReturn gtk_MessageBox( ui::Window parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT );
#endif
gboolean escape_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data)
{
if (event->keyval == GDK_KEY_Escape) {
- gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(widget)), NULL);
+ gtk_window_set_focus(widget.window(), NULL);
return TRUE;
}
return FALSE;
if (event->keyval == GDK_KEY_Return) {
self->m_apply();
self->m_editing = false;
- gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(entry)), NULL);
+ gtk_window_set_focus(entry.window(), NULL);
return TRUE;
}
return FALSE;
if (event->keyval == GDK_KEY_Escape) {
self->m_cancel();
self->m_editing = false;
- gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(entry)), NULL);
+ gtk_window_set_focus(entry.window(), NULL);
return TRUE;
}
return FALSE;
gboolean NonModalSpinner::enter(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self)
{
if (event->keyval == GDK_KEY_Return) {
- gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(spin)), NULL);
+ gtk_window_set_focus(spin.window(), NULL);
return TRUE;
}
return FALSE;
{
if (event->keyval == GDK_KEY_Escape) {
self->m_cancel();
- gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(spin)), NULL);
+ gtk_window_set_focus(spin.window(), NULL);
return TRUE;
}
return FALSE;
}
ui::Window create_persistent_floating_window( const char* title, ui::Window main_window ){
- ui::Window window = ui::Window(GTK_WINDOW( create_floating_window( title, main_window ) ));
+ auto window = create_floating_window( title, main_window );
gtk_widget_set_events( window , GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
return scr;
}
-gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data)
+gboolean window_focus_in_clear_focus_widget(ui::Window widget, GdkEventKey *event, gpointer data)
{
- gtk_window_set_focus( GTK_WINDOW( widget ), NULL );
+ gtk_window_set_focus( widget, NULL );
return FALSE;
}
#include "generic/callback.h"
#include "widget.h"
-gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data);
+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);
Widget::Widget(ui::New_t) : Widget(nullptr)
{}
- alert_response IWidget::alert(std::string text, std::string title, alert_type type, alert_icon icon)
+ Window IWidget::window()
{
- auto ret = gtk_MessageBox(this, text.c_str(),
- title.c_str(),
- type == alert_type::OK ? eMB_OK :
- type == alert_type::OKCANCEL ? eMB_OKCANCEL :
- type == alert_type::YESNO ? eMB_YESNO :
- type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL :
- type == alert_type::NOYES ? eMB_NOYES :
- eMB_OK,
- icon == alert_icon::Default ? eMB_ICONDEFAULT :
- icon == alert_icon::Error ? eMB_ICONERROR :
- icon == alert_icon::Warning ? eMB_ICONWARNING :
- icon == alert_icon::Question ? eMB_ICONQUESTION :
- icon == alert_icon::Asterisk ? eMB_ICONASTERISK :
- eMB_ICONDEFAULT
- );
- return
- ret == eIDOK ? alert_response::OK :
- ret == eIDCANCEL ? alert_response::CANCEL :
- ret == eIDYES ? alert_response::YES :
- ret == eIDNO ? alert_response::NO :
- alert_response::OK;
+ return Window::from(gtk_widget_get_toplevel(this));
}
const char *
IWidget::file_dialog(bool open, const char *title, const char *path, const char *pattern, bool want_load,
bool want_import, bool want_save)
{
- return ::file_dialog(this, open, title, path, pattern, want_load, want_import, want_save);
+ return ::file_dialog(this.window(), open, title, path, pattern, want_load, want_import, want_save);
}
bool IWidget::visible()
)))
{}
+ alert_response IWindow::alert(std::string text, std::string title, alert_type type, alert_icon icon)
+ {
+ auto ret = gtk_MessageBox(this, text.c_str(),
+ title.c_str(),
+ type == alert_type::OK ? eMB_OK :
+ type == alert_type::OKCANCEL ? eMB_OKCANCEL :
+ type == alert_type::YESNO ? eMB_YESNO :
+ type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL :
+ type == alert_type::NOYES ? eMB_NOYES :
+ eMB_OK,
+ icon == alert_icon::Default ? eMB_ICONDEFAULT :
+ icon == alert_icon::Error ? eMB_ICONERROR :
+ icon == alert_icon::Warning ? eMB_ICONWARNING :
+ icon == alert_icon::Question ? eMB_ICONQUESTION :
+ icon == alert_icon::Asterisk ? eMB_ICONASTERISK :
+ eMB_ICONDEFAULT
+ );
+ return
+ ret == eIDOK ? alert_response::OK :
+ ret == eIDCANCEL ? alert_response::CANCEL :
+ ret == eIDYES ? alert_response::YES :
+ ret == eIDNO ? alert_response::NO :
+ alert_response::OK;
+ }
+
Window IWindow::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h)
{
return Window(::create_dialog_window(this, title, func, data, default_w, default_h));
int height;
};
+ class Window;
WRAP(Widget, Object, _GtkWidget, (),
,
- alert_response alert(
- std::string text,
- std::string title = "NetRadiant",
- alert_type type = alert_type::OK,
- alert_icon icon = alert_icon::Default
- );
+ Window window();
const char *file_dialog(
bool open,
const char *title,
WRAP(Window, Bin, _GtkWindow, (),
explicit Window(window_type type);
,
+ alert_response alert(
+ std::string text,
+ std::string title = "NetRadiant",
+ alert_type type = alert_type::OK,
+ alert_icon icon = alert_icon::Default
+ );
+
Window create_dialog_window(
const char *title,
void func(),
#include "StdAfx.h"
static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
G_CALLBACK( dialog_delete_callback ), NULL );
window.connect( "destroy",
G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
+ gtk_window_set_title( window, lpCaption );
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
void CamWnd::Cam_PositionDrag(){
int x, y;
- Sys_GetCursorPos( GTK_WINDOW( m_gl_widget ), &x, &y );
+ Sys_GetCursorPos( m_gl_widget, &x, &y );
if ( x != m_PositionDragCursorX || y != m_PositionDragCursorY ) {
x -= m_PositionDragCursorX;
vector3_add( m_Camera.origin, vector3_scaled( m_Camera.vright, x ) );
CamWnd_Update( camwnd );
CameraMovedNotify();
- Sys_SetCursorPos( GTK_WINDOW( m_parent ), m_PositionDragCursorX, m_PositionDragCursorY );
+ Sys_SetCursorPos( m_parent, m_PositionDragCursorX, m_PositionDragCursorY );
}
}
#endif
if ( dialog.m_waiting_for_key ) {
// just unhighlight, user wanted to cancel
dialog.m_waiting_for_key = false;
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
gtk_widget_set_sensitive( dialog.m_list , true );
dialog.m_model = NULL;
return;
}
thisShortcutIterator->second.first = accelerator_null();
- gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 1, "", -1 );
+ gtk_list_store_set( ui::ListStore::from( model ), &iter, 1, "", -1 );
g_value_unset( &val );
}
//gtk_widget_set_sensitive(dialog.m_list, false);
// 3. highlight the row
- gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 2, true, -1 );
+ gtk_list_store_set( ui::ListStore::from( model ), &iter, 2, true, -1 );
// 4. grab keyboard focus
dialog.m_waiting_for_key = true;
}
-bool accelerator_window_key_press( ui::Widget widget, GdkEventKey *event, gpointer dialogptr ){
+bool accelerator_window_key_press( ui::Window widget, GdkEventKey *event, gpointer dialogptr ){
command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr;
if ( !dialog.m_waiting_for_key ) {
const char *commandName = g_value_get_string( &val );;
Shortcuts::iterator thisShortcutIterator = g_shortcuts.find( commandName );
if ( thisShortcutIterator == g_shortcuts.end() ) {
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
gtk_widget_set_sensitive( dialog.m_list , true );
return true;
}
StringOutputStream msg;
msg << "The command " << name << " is already assigned to the key " << accelerator << ".\n\n"
<< "Do you want to unassign " << name << " first?";
- auto r = widget.alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL );
+ auto r = widget.window().alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL );
if ( r == ui::alert_response::YES ) {
// clear the ACTUAL accelerator too!
disconnect_accelerator( name );
gtk_tree_model_get_value( GTK_TREE_MODEL( model ), &i, 0, &val );
const char *thisName = g_value_get_string( &val );;
if ( !strcmp( thisName, name ) ) {
- gtk_list_store_set( GTK_LIST_STORE( model ), &i, 1, "", -1 );
+ gtk_list_store_set( ui::ListStore::from( model ), &i, 1, "", -1 );
}
g_value_unset( &val );
if ( !gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), &i ) ) {
} verify_visitor( commandName, newAccel, widget, dialog.m_model );
GlobalShortcuts_foreach( verify_visitor );
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
gtk_widget_set_sensitive( dialog.m_list , true );
if ( verify_visitor.allow ) {
// write into the cell
StringOutputStream modifiers;
modifiers << newAccel;
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 1, modifiers.c_str(), -1 );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 1, modifiers.c_str(), -1 );
// set the ACTUAL accelerator too!
connect_accelerator( commandName );
accelerator_parse(i->second.first, new_text);
StringOutputStream modifiers;
modifiers << i->second.first;
- gtk_list_store_set(GTK_LIST_STORE(model), &row, 1, modifiers.c_str(), -1);
+ gtk_list_store_set(ui::ListStore::from(model), &row, 1, modifiers.c_str(), -1);
}
};
*/
ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Mapped Commands", dialog, -1, 400);
window.on_key_press([](ui::Widget widget, GdkEventKey *event, gpointer dialogptr) {
- return accelerator_window_key_press(widget, event, dialogptr);
+ return accelerator_window_key_press(ui::Window::from(widget), event, dialogptr);
}, &dialog);
auto accel = ui::AccelGroup(ui::New);
<< "This is NetRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n";
}
else{
- ui::root.alert( "Failed to create log file, check write permissions in Radiant directory.\n",
+ ui::root.window().alert( "Failed to create log file, check write permissions in Radiant directory.\n",
"Console logging", ui::alert_type::OK, ui::alert_icon::Error );
}
}
{
auto text = ui::TextView(ui::New);
gtk_widget_set_size_request( text, 0, -1 ); // allow shrinking
- gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text ), GTK_WRAP_WORD );
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), FALSE );
+ gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD );
+ gtk_text_view_set_editable( text, FALSE );
scr.add(text);
text.show();
g_console = text;
if ( level != SYS_NOCON ) {
if ( g_console ) {
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) );
+ GtkTextBuffer* buffer = gtk_text_view_get_buffer( g_console );
GtkTextIter iter;
gtk_text_buffer_get_end_iter( buffer, &iter );
// update console widget immediatly if we're doing something time-consuming
if ( contains_newline ) {
- gtk_text_view_scroll_mark_onscreen( GTK_TEXT_VIEW( g_console ), end );
+ gtk_text_view_scroll_mark_onscreen( g_console, end );
if ( !ScreenUpdates_Enabled() && gtk_widget_get_realized( g_console ) ) {
ScreenUpdates_process();
}
-ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
+ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
auto check = ui::CheckButton( flag );
check.show();
AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(DialogRow_new( name, check ) ));
+ DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, check ) ));
return check;
}
-ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ){
+ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ){
return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) );
}
-void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
alignment.show();
{
}
auto row = DialogRow_new( name, alignment );
- DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row );
+ DialogVBox_packRow( vbox, row );
}
-void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){
+void Dialog::addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ){
addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) );
}
-void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
+void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
#if 0
if ( draw_value == FALSE ) {
auto hbox2 = ui::HBox( FALSE, 0 );
gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
auto row = DialogRow_new( name, alignment );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
+ DialogVBox_packRow( vbox, row );
}
-void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
alignment.show();;
{
}
auto row = DialogRow_new( name, alignment );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
+ DialogVBox_packRow( vbox, row );
}
-void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){
+void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ){
addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) );
}
-void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE );
table.show();;
AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) );
+ DialogVBox_packRow( vbox, DialogRow_new( name, table ) );
}
-void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){
+void Dialog::addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ){
addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) );
}
-ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
DialogEntryRow row( DialogEntryRow_new( name ) );
AddIntEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
+ DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
+ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
DialogEntryRow row( DialogEntryRow_new( name ) );
AddSizeEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
+ DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
+ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
DialogEntryRow row( DialogEntryRow_new( name ) );
AddFloatEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
+ DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
+ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
PathEntry pathEntry = PathEntry_new();
pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
AddTextEntryData( *GTK_ENTRY(pathEntry.m_entry), importViewer, exportViewer );
auto row = DialogRow_new( name, ui::Widget(pathEntry.m_frame ) );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
+ DialogVBox_packRow( vbox, row );
return ui::Widget(row );
}
-ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool browse_directory ){
+ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool browse_directory ){
return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) );
}
-ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
+ DialogVBox_packRow( vbox, row.m_row );
return ui::SpinButton(row.m_spin);
}
-ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ){
return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) );
}
-ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer );
- DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
+ DialogVBox_packRow( vbox, row.m_row );
return ui::SpinButton(row.m_spin);
}
return m_window;
}
-ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
-ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data );
-void addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values );
-void addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment );
-void addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names );
-void addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons );
-ui::Widget addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-ui::Widget addEntry( ui::Widget vbox, const char* name, int& data ){
+ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
+ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data );
+void addCombo( ui::VBox vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+void addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values );
+void addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment );
+void addRadio( ui::VBox vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+void addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names );
+void addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+void addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons );
+ui::Widget addIntEntry( ui::VBox vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+ui::Widget addEntry( ui::VBox vbox, const char* name, int& data ){
return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) );
}
-ui::Widget addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
-ui::Widget addEntry( ui::Widget vbox, const char* name, std::size_t& data ){
+ui::Widget addSizeEntry( ui::VBox vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
+ui::Widget addEntry( ui::VBox vbox, const char* name, std::size_t& data ){
return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) );
}
-ui::Widget addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
-ui::Widget addEntry( ui::Widget vbox, const char* name, float& data ){
+ui::Widget addFloatEntry( ui::VBox vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
+ui::Widget addEntry( ui::VBox vbox, const char* name, float& data ){
return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) );
}
-ui::Widget addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
-ui::Widget addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool directory );
-ui::SpinButton addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper );
-ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
+ui::Widget addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
+ui::Widget addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool directory );
+ui::SpinButton addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper );
+ui::SpinButton addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
+ui::SpinButton addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
protected:
}
typedef MemberCaller<ModelAttribute, &ModelAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
- const char *filename = misc_model_dialog( ui::Widget(gtk_widget_get_toplevel( m_entry.m_entry.m_frame ) ));
+ const char *filename = misc_model_dialog( m_entry.m_entry.m_frame.window() );
if ( filename != 0 ) {
setPath( filename );
}
typedef MemberCaller<SoundAttribute, &SoundAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
- const char *filename = browse_sound( ui::Widget(gtk_widget_get_toplevel( m_entry.m_entry.m_frame )) );
+ const char *filename = browse_sound( m_entry.m_entry.m_frame.window() );
if ( filename != 0 ) {
setPath( filename );
// Creates a new entity based on the currently selected brush and entity type.
//
void EntityClassList_createEntity(){
- GtkTreeView* view = g_entityClassList;
+ auto view = ui::Widget::from(g_entityClassList);
// find out what type of entity we are trying to create
GtkTreeModel* model;
GtkTreeIter iter;
- if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE ) {
- ui::Widget(gtk_widget_get_toplevel( ui::TreeView(g_entityClassList) )).alert( "You must have a selected class to create an entity", "info" );
+ if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( g_entityClassList ), &model, &iter ) == FALSE ) {
+ view.window().alert( "You must have a selected class to create an entity", "info" );
return;
}
// TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity
if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) {
- ui::Widget(gtk_widget_get_toplevel( g_entityKeyEntry ) ).alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK );
+ g_entityKeyEntry.window().alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK );
return;
}
// RR2DO2: we don't want spaces in entity keys
if ( strstr( key.c_str(), " " ) ) {
- ui::Widget(gtk_widget_get_toplevel( g_entityKeyEntry ) ).alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK );
+ g_entityKeyEntry.window().alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK );
return;
}
if ( event->keyval == GDK_KEY_Return ) {
if ( widget._handle == g_entityKeyEntry._handle ) {
g_entityValueEntry.text( "" );
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), g_entityValueEntry );
+ gtk_window_set_focus( widget.window(), g_entityValueEntry );
}
else
{
return TRUE;
}
if ( event->keyval == GDK_KEY_Escape ) {
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), NULL );
+ gtk_window_set_focus( widget.window(), NULL );
return TRUE;
}
}
static gboolean switch_page( GtkNotebook *notebook, gpointer page, guint page_num, gpointer data ){
- GroupDialog_updatePageTitle( ui::Window(GTK_WINDOW( data )), page_num );
+ GroupDialog_updatePageTitle( ui::Window::from(data), page_num );
g_current_page = page_num;
return FALSE;
frame.add(sc_extensions);
{
auto text_extensions = ui::TextView(ui::New);
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE );
+ gtk_text_view_set_editable( text_extensions, FALSE );
sc_extensions.add(text_extensions);
text_extensions.text(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
- gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD );
+ gtk_text_view_set_wrap_mode( text_extensions, GTK_WRAP_WORD );
text_extensions.show();
}
}
// Text Editor dialog
// master window widget
-static ui::Widget text_editor{ui::null};
+static ui::Window text_editor{ui::null};
static ui::Widget text_widget{ui::null}; // slave, text widget from the gtk editor
static gint editor_delete( ui::Widget widget, gpointer data ){
- if ( widget.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
+ if ( widget.window().alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
return TRUE;
}
gpointer text = g_object_get_data( G_OBJECT( data ), "text" );
if ( f == 0 ) {
- ui::Widget::from(data).alert( "Error saving file !" );
+ ui::Widget::from(data).window().alert( "Error saving file !" );
return;
}
}
static void editor_close( ui::Widget widget, gpointer data ){
- if ( text_editor.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
+ if ( text_editor.window().alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
return;
}
dlg.connect( "delete_event",
G_CALLBACK( editor_delete ), 0 );
- gtk_window_set_default_size( GTK_WINDOW( dlg ), 600, 300 );
+ gtk_window_set_default_size( dlg, 600, 300 );
auto vbox = ui::VBox( FALSE, 5 );
vbox.show();
scr.add(text);
text.show();
g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text );
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE );
+ gtk_text_view_set_editable( text, TRUE );
auto hbox = ui::HBox( FALSE, 5 );
hbox.show();
rewind( f );
fread( buf, 1, len, f );
- gtk_window_set_title( GTK_WINDOW( text_editor ), filename );
+ gtk_window_set_title( text_editor, filename );
- GtkTextBuffer* text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_widget ) );
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(ui::TextView::from(text_widget));
gtk_text_buffer_set_text( text_buffer, (char*)buf, len );
old_filename = g_object_get_data( G_OBJECT( text_editor ), "filename" );
// =============================================================================
// File dialog
-bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){
+bool color_dialog( ui::Window parent, Vector3& color, const char* title ){
GdkColor clr = { 0, guint16(color[0] * 65535), guint16(color[1] * 65535), guint16(color[2] * 65535) };
ModalDialog dialog;
- auto dlg = ui::Widget(gtk_color_selection_dialog_new( title ));
+ auto dlg = ui::Window::from(gtk_color_selection_dialog_new( title ));
gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr );
dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog );
GtkWidget *ok_button, *cancel_button;
- g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr);
+ g_object_get(G_OBJECT(dlg), "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr);
ui::Widget(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog );
ui::Widget(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog );
if ( parent ) {
- gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) );
+ gtk_window_set_transient_for( dlg, parent );
}
- bool ok = modal_dialog_show( ui::Window(GTK_WINDOW( dlg )), dialog ) == eIDOK;
+ bool ok = modal_dialog_show( dlg, dialog ) == eIDOK;
if ( ok ) {
gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr );
color[0] = clr.red / 65535.0f;
}
void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ){
- const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) );
+ const char *filename = widget.file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) );
if ( filename != 0 ) {
entry.text(filename);
void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ){
const char* text = gtk_entry_get_text( entry );
- char *dir = dir_dialog( ui::Widget(gtk_widget_get_toplevel( widget )), "Choose Directory", path_is_absolute( text ) ? text : "" );
+ char *dir = dir_dialog( widget.window(), "Choose Directory", path_is_absolute( text ) ? text : "" );
if ( dir != 0 ) {
gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 );
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
-bool color_dialog( ui::Widget parent, Vector3& color, const char* title = "Choose Color" );
+bool color_dialog( ui::Window parent, Vector3& color, const char* title = "Choose Color" );
void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry );
void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry );
ScopedLock lock( m_lock );
#if GDEF_DEBUG
m_buffer << "Break into the debugger?\n";
- bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO;
+ bool handled = ui::root.window().alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO;
m_buffer.clear();
return handled;
#else
m_buffer << "Please report this error to the developers\n";
- ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::root.window().alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error );
m_buffer.clear();
#endif
}
msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n"
"Make sure you run the right/latest editor binary you installed\n"
<< AppPath_get();
- ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default);
+ ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default);
}
return bVerIsGood;
#else
if ( remove( g_pidFile.c_str() ) == -1 ) {
StringOutputStream msg( 256 );
msg << "WARNING: Could not delete " << g_pidFile.c_str();
- ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
}
// in debug, never prompt to clean registry, turn console logging auto after a failed start
"The failure may be related to current global preferences.\n"
"Do you want to reset global preferences to defaults?";
- if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) {
+ if ( ui::root.window().alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) {
g_GamesDialog.Reset();
}
msg.clear();
msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again.";
- ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK );
+ ui::root.window().alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK );
#endif
// set without saving, the class is not in a coherent state yet
if ( remove( g_pidFile.c_str() ) == -1 ) {
StringOutputStream msg( 256 );
msg << "WARNING: Could not delete " << g_pidFile.c_str();
- ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
}
}
if ( remove( g_pidGameFile.c_str() ) == -1 ) {
StringOutputStream msg;
msg << "WARNING: Could not delete " << g_pidGameFile.c_str();
- ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
}
// in debug, never prompt to clean registry, turn console logging auto after a failed start
"The failure may be caused by current preferences.\n"
"Do you want to reset all preferences to defaults?";
- if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) {
+ if ( ui::root.window().alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) {
Preferences_Reset();
}
msg.clear();
msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again.";
- ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK );
+ ui::root.window().alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK );
#endif
// force console logging on! (will go in prefs too)
for ( GList* i = list; i != 0; i = g_list_next( i ) )
{
//globalOutputStream() << "toplevel.. ";
- if ( gtk_window_is_active( GTK_WINDOW( i->data ) ) ) {
+ if ( gtk_window_is_active( ui::Window::from( i->data ) ) ) {
//globalOutputStream() << "is active\n";
return true;
}
#if 0
CamWnd* camwnd = g_pParentWnd->GetCamWnd();
- gtk_window_get_position( GTK_WINDOW( camwnd->m_window ), x, y );
+ gtk_window_get_position( camwnd->m_window, x, y );
*width = camwnd->Camera()->width;
*height = camwnd->Camera()->height;
frame.add(vbox2);
{
- PreferencesPage preferencesPage( *this, ui::Widget(vbox2 ) );
+ PreferencesPage preferencesPage( *this, vbox2 );
Global_constructPreferences( preferencesPage );
CreateGlobalFrame( preferencesPage );
}
static void OnButtonClean( ui::Widget widget, gpointer data ){
// make sure this is what the user wants
- if ( ui::Widget(g_Preferences.GetWidget( )).alert( "This will close Radiant and clean the corresponding registry entries.\n"
+ if ( g_Preferences.GetWidget().alert( "This will close Radiant and clean the corresponding registry entries.\n"
"Next time you start Radiant it will be good as new. Do you wish to continue?",
"Reset Registry", ui::alert_type::YESNO, ui::alert_icon::Asterisk ) == ui::alert_response::YES ) {
PrefsDlg *dlg = (PrefsDlg*)data;
}
-inline ui::Widget getVBox( ui::Widget page ){
- return ui::Widget(gtk_bin_get_child( GTK_BIN( page ) ));
+inline ui::VBox getVBox( ui::Bin page ){
+ return ui::VBox::from(gtk_bin_get_child(page));
}
GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, ui::Widget page ){
return group;
}
-ui::Widget PreferencePages_addPage( ui::Widget notebook, const char* name ){
+ui::Bin PreferencePages_addPage( ui::Widget notebook, const char* name ){
ui::Widget preflabel = ui::Label( name );
preflabel.show();
m_group( group ){
}
PreferencesPage createPage( const char* treeName, const char* frameName ){
- ui::Widget page = PreferencePages_addPage( m_notebook, frameName );
+ auto page = PreferencePages_addPage( m_notebook, frameName );
PreferenceTree_appendPage( m_store, &m_group, treeName, page );
return PreferencesPage( m_dialog, getVBox( page ) );
}
PreferencePages_addPage( m_notebook, "Front Page" );
{
- ui::Widget global = PreferencePages_addPage( m_notebook, "Global Preferences" );
+ auto global = PreferencePages_addPage( m_notebook, "Global Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( global ) );
Global_constructPreferences( preferencesPage );
}
GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global );
{
- ui::Widget game = PreferencePages_addPage( m_notebook, "Game" );
+ auto game = PreferencePages_addPage( m_notebook, "Game" );
PreferencesPage preferencesPage( *this, getVBox( game ) );
g_GamesDialog.CreateGlobalFrame( preferencesPage );
}
{
- ui::Widget interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" );
+ auto interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( interfacePage ) );
PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage );
}
{
- ui::Widget display = PreferencePages_addPage( m_notebook, "Display Preferences" );
+ auto display = PreferencePages_addPage( m_notebook, "Display Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( display ) );
PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage );
}
{
- ui::Widget settings = PreferencePages_addPage( m_notebook, "General Settings" );
+ auto settings = PreferencePages_addPage( m_notebook, "General Settings" );
{
PreferencesPage preferencesPage( *this, getVBox( settings ) );
PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage );
class PreferencesPage
{
Dialog& m_dialog;
-ui::Widget m_vbox;
+ui::VBox m_vbox;
public:
-PreferencesPage( Dialog& dialog, ui::Widget vbox ) : m_dialog( dialog ), m_vbox( vbox ){
+PreferencesPage( Dialog& dialog, ui::VBox vbox ) : m_dialog( dialog ), m_vbox( vbox ){
}
ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){
return m_dialog.addCheckBox( m_vbox, name, flag, data );
}
else
{
- ui::Widget(g_TextureBrowser.m_parent ).alert( "Select a single tag for renaming." );
+ g_TextureBrowser.m_parent.alert( "Select a single tag for renaming." );
}
}
gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected );
if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag
- auto result = ui::Widget(g_TextureBrowser.m_parent ).alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question );
+ auto result = g_TextureBrowser.m_parent.alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question );
if ( result == ui::alert_response::YES ) {
GtkTreeIter iterSelected;
}
}
else {
- ui::Widget(g_TextureBrowser.m_parent ).alert( "Select a single tag for deletion." );
+ g_TextureBrowser.m_parent.alert( "Select a single tag for deletion." );
}
}
}
void TextureBrowser_showUntagged(){
- auto result = ui::Widget(g_TextureBrowser.m_parent ).alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning );
+ auto result = g_TextureBrowser.m_parent.alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning );
if ( result == ui::alert_response::YES ) {
g_TextureBrowser.m_found_shaders.clear();
void WXY_BackgroundSelect( void ){
bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0;
if ( !brushesSelected ) {
- ui::root.alert( "You have to select some brushes to get the bounding box for.\n",
+ ui::root.window().alert( "You have to select some brushes to get the bounding box for.\n",
"No selection", ui::alert_type::OK, ui::alert_icon::Error );
return;
}