private:
GtkWidget *m_pWidget;
GtkWidget *m_pTabLabel;
-GtkWidget *m_pFileLabel;
+ui::Label m_pFileLabel;
GtkWidget *m_pPosLabel;
VIEWTYPE m_vt;
bool m_bValidFile;
if ( m_pImage->Load( newfile ) ) {
m_bValidFile = true;
- gtk_label_set_text( GTK_LABEL( m_pFileLabel ),newfile );
+ m_pFileLabel.text(newfile);
}
}
// TODO no snprintf ?
sprintf( s, "Size/Position (%d,%d) (%d,%d)",(int)( m_pImage->m_xmin ),
(int)( m_pImage->m_ymin ),(int)( m_pImage->m_xmax ),(int)( m_pImage->m_ymax ) );
- gtk_label_set_text( GTK_LABEL( m_pPosLabel ),s );
+ m_pPosLabel.text(s);
}
CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){
return ::file_dialog(this, open, title, path, pattern, want_load, want_import, want_save);
}
+ bool IWidget::visible()
+ {
+ return gtk_widget_get_visible(this) != 0;
+ }
+
void IWidget::show()
{
gtk_widget_show(this);
}
+ Dimensions IWidget::dimensions()
+ {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(this, &allocation);
+ return Dimensions{allocation.width, allocation.height};
+ }
+
+ void IWidget::dimensions(int width, int height)
+ {
+ gtk_widget_set_size_request(this, width, height);
+ }
+
IMPL(Container, GTK_CONTAINER);
void IContainer::add(Widget widget)
IMPL(CheckButton, GTK_CHECK_BUTTON);
+ CheckButton::CheckButton() : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new()))
+ {}
+
CheckButton::CheckButton(const char *label) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_label(label)))
{}
ScrolledWindow::ScrolledWindow() : ScrolledWindow(GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(nullptr, nullptr)))
{}
+ void IScrolledWindow::overflow(Policy x, Policy y)
+ {
+ gtk_scrolled_window_set_policy(this, static_cast<GtkPolicyType>(x), static_cast<GtkPolicyType>(y));
+ }
+
IMPL(VBox, GTK_VBOX);
VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing)))
TextView::TextView() : TextView(GTK_TEXT_VIEW(gtk_text_view_new()))
{}
+ void ITextView::text(char const *str)
+ {
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(this);
+ gtk_text_buffer_set_text(buffer, str, -1);
+ }
+
TreeView::TreeView() : TreeView(GTK_TREE_VIEW(gtk_tree_view_new()))
{}
Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label)))
{}
+ void ILabel::text(char const *str)
+ {
+ gtk_label_set_text(this, str);
+ }
+
IMPL(Image, GTK_IMAGE);
Image::Image() : Image(GTK_IMAGE(gtk_image_new()))
gtk_entry_set_max_length(this, static_cast<gint>(max_length));
}
+ char const *IEntry::text()
+ {
+ return gtk_entry_get_text(this);
+ }
+
+ void IEntry::text(char const *str)
+ {
+ return gtk_entry_set_text(this, str);
+ }
+
IMPL(SpinButton, GTK_SPIN_BUTTON);
SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton(
using native = _GtkObject *;
native _handle;
- Object(native h) : _handle(h)
+ explicit Object(native h) : _handle(h)
{}
explicit operator bool() const
);
WRAP(Editable, Object, _GtkEditable, (),
- Editable();
+ explicit Editable();
,
void editable(bool value);
);
// GObject
+ struct Dimensions {
+ int width;
+ int height;
+ };
+
WRAP(Widget, Object, _GtkWidget, (),
- Widget();
+ explicit Widget();
,
alert_response alert(
std::string text,
bool want_import = false,
bool want_save = false
);
+ bool visible();
void show();
+ Dimensions dimensions();
+ void dimensions(int width, int height);
);
WRAP(Container, Widget, _GtkContainer, (),
class AccelGroup;
WRAP(Window, Bin, _GtkWindow, (),
- Window(window_type type);
+ explicit Window(window_type type);
,
Window create_dialog_window(
const char *title,
);
WRAP(Frame, Bin, _GtkFrame, (),
- Frame(const char *label = nullptr);
+ explicit Frame(const char *label = nullptr);
,
);
WRAP(Button, Bin, _GtkButton, (),
- Button();
- Button(const char *label);
+ explicit Button();
+ explicit Button(const char *label);
,
);
);
WRAP(CheckButton, ToggleButton, _GtkCheckButton, (),
- CheckButton(const char *label);
+ explicit CheckButton();
+ explicit CheckButton(const char *label);
,
);
);
WRAP(MenuItem, Item, _GtkMenuItem, (),
- MenuItem();
- MenuItem(const char *label, bool mnemonic = false);
+ explicit MenuItem();
+ explicit MenuItem(const char *label, bool mnemonic = false);
,
);
);
WRAP(TearoffMenuItem, MenuItem, _GtkTearoffMenuItem, (),
- TearoffMenuItem();
+ explicit TearoffMenuItem();
,
);
);
WRAP(ComboBoxText, ComboBox, _GtkComboBoxText, (),
- ComboBoxText();
+ explicit ComboBoxText();
,
);
);
WRAP(ScrolledWindow, Bin, _GtkScrolledWindow, (),
- ScrolledWindow();
+ explicit ScrolledWindow();
,
+ void overflow(Policy x, Policy y);
);
WRAP(Box, Container, _GtkBox, (),
);
WRAP(HPaned, Paned, _GtkHPaned, (),
- HPaned();
+ explicit HPaned();
,
);
WRAP(VPaned, Paned, _GtkVPaned, (),
- VPaned();
+ explicit VPaned();
,
);
);
WRAP(Menu, MenuShell, _GtkMenu, (),
- Menu();
+ explicit Menu();
,
);
);
WRAP(TextView, Container, _GtkTextView, (),
- TextView();
+ explicit TextView();
,
+ void text(char const *str);
);
WRAP(Toolbar, Container, _GtkToolbar, (),
class TreeModel;
WRAP(TreeView, Widget, _GtkTreeView, (),
- TreeView();
+ explicit TreeView();
TreeView(TreeModel model);
,
);
);
WRAP(Label, Widget, _GtkLabel, (),
- Label(const char *label);
+ explicit Label(const char *label);
,
+ void text(char const *str);
);
WRAP(Image, Widget, _GtkImage, (),
- Image();
+ explicit Image();
,
);
WRAP(Entry, Widget, _GtkEntry, (IEditable, ICellEditable),
- Entry();
- Entry(std::size_t max_length);
+ explicit Entry();
+ explicit Entry(std::size_t max_length);
,
+ char const *text();
+ void text(char const *str);
);
class Adjustment;
);
WRAP(HScale, Scale, _GtkHScale, (),
- HScale(Adjustment adjustment);
+ explicit HScale(Adjustment adjustment);
HScale(double min, double max, double step);
,
);
);
WRAP(CellRendererText, CellRenderer, _GtkCellRendererText, (),
- CellRendererText();
+ explicit CellRendererText();
,
);
);
WRAP(AccelGroup, Object, _GtkAccelGroup, (),
- AccelGroup();
+ explicit AccelGroup();
,
);
// GBoxed
WRAP(TreePath, Object, _GtkTreePath, (),
- TreePath();
- TreePath(const char *path);
+ explicit TreePath();
+ explicit TreePath(const char *path);
,
);
#endif
void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){
- if ( gtk_widget_get_visible( self.m_gl_widget ) ) {
+ if ( self.m_gl_widget.visible() ) {
self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ) );
}
}
}
inline WindowVector windowvector_for_widget_centre( ui::Widget widget ){
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
+ auto allocation = widget.dimensions();
return WindowVector( static_cast<float>( allocation.width / 2 ), static_cast<float>(allocation.height / 2 ) );
}
}
}
-ui::Widget g_console;
+ui::TextView g_console{ui::null};
void console_clear(){
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) );
- gtk_text_buffer_set_text( buffer, "", -1 );
+ g_console.text("");
}
-void console_populate_popup( GtkTextView* textview, ui::Menu menu, gpointer user_data ){
+void console_populate_popup( ui::TextView textview, ui::Menu menu, gpointer user_data ){
menu_separator( menu );
ui::Widget item(ui::MenuItem( "Clear" ));
ui::Widget Console_constructWindow( ui::Window toplevel ){
auto scr = ui::ScrolledWindow();
- gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+ scr.overflow(ui::Policy::AUTOMATIC, ui::Policy::AUTOMATIC);
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
scr.show();
{
- ui::Widget text = ui::TextView();
+ auto text = ui::TextView();
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 );
}
if ( level != SYS_NOCON ) {
- if ( g_console != 0 ) {
+ if ( g_console ) {
GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) );
GtkTextIter iter;
typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
void TextEntryImport( GtkEntry& widget, const char* text ){
- gtk_entry_set_text( &widget, text );
+ ui::Entry(&widget).text(text);
}
void TextEntryExport( GtkEntry& widget, const StringImportCallback& importCallback ){
importCallback( gtk_entry_get_text( &widget ) );
ui::Entry numeric_entry_new(){
auto entry = ui::Entry();
entry.show();
- gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
+ entry.dimensions(64, -1);
return entry;
}
class BooleanAttribute : public EntityAttribute
{
CopiedString m_key;
-GtkCheckButton* m_check;
+ui::CheckButton m_check;
static gboolean toggled( ui::Widget widget, BooleanAttribute* self ){
self->apply();
public:
BooleanAttribute( const char* key ) :
m_key( key ),
- m_check( 0 ){
- auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() ));
+ m_check( ui::null ){
+ auto check = ui::CheckButton();
check.show();
m_check = check;
update();
}
ui::Widget getWidget() const {
- return ui::Widget(GTK_WIDGET( m_check ));
+ return m_check;
}
void release(){
delete this;
}
void apply(){
- Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( m_check ) ) ? "1" : "0" );
+ Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_check.active() ? "1" : "0" );
}
typedef MemberCaller<BooleanAttribute, &BooleanAttribute::apply> ApplyCaller;
void update(){
const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
if ( !string_empty( value ) ) {
- toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), atoi( value ) != 0 );
+ toggle_button_set_active_no_signal( m_check, atoi( value ) != 0 );
}
else
{
- toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), false );
+ toggle_button_set_active_no_signal( m_check, false );
}
}
typedef MemberCaller<BooleanAttribute, &BooleanAttribute::update> UpdateCaller;
m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
auto entry = ui::Entry();
entry.show();
- gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
+ entry.dimensions(50, -1);
m_entry = entry;
m_nonModal.connect( m_entry );
}
ui::Widget getWidget() const {
- return ui::Widget(GTK_WIDGET( m_entry ));
+ return m_entry;
}
ui::Entry getEntry() const {
return m_entry;
}
void apply(){
StringOutputStream value( 64 );
- value << gtk_entry_get_text( m_entry );
+ value << m_entry.text();
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
}
typedef MemberCaller<StringAttribute, &StringAttribute::apply> ApplyCaller;
void update(){
StringOutputStream value( 64 );
value << SelectedEntity_getValueForKey( m_key.c_str() );
- gtk_entry_set_text( m_entry, value.c_str() );
+ m_entry.text(value.c_str());
}
typedef MemberCaller<StringAttribute, &StringAttribute::update> UpdateCaller;
};
delete this;
}
ui::Widget getWidget() const {
- return ui::Widget(GTK_WIDGET( m_entry.m_entry.m_frame ));
+ return m_entry.m_entry.m_frame;
}
void apply(){
StringOutputStream value( 64 );
- value << gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) );
+ value << m_entry.m_entry.m_entry.text();
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
}
typedef MemberCaller<ModelAttribute, &ModelAttribute::apply> ApplyCaller;
void update(){
StringOutputStream value( 64 );
value << SelectedEntity_getValueForKey( m_key.c_str() );
- gtk_entry_set_text( GTK_ENTRY( m_entry.m_entry.m_entry ), value.c_str() );
+ m_entry.m_entry.m_entry.text(value.c_str());
}
typedef MemberCaller<ModelAttribute, &ModelAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
}
void apply(){
StringOutputStream value( 64 );
- value << gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) );
+ value << m_entry.m_entry.m_entry.text();
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
}
typedef MemberCaller<SoundAttribute, &SoundAttribute::apply> ApplyCaller;
void update(){
StringOutputStream value( 64 );
value << SelectedEntity_getValueForKey( m_key.c_str() );
- gtk_entry_set_text( GTK_ENTRY( m_entry.m_entry.m_entry ), value.c_str() );
+ m_entry.m_entry.m_entry.text(value.c_str());
}
typedef MemberCaller<SoundAttribute, &SoundAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
if ( !string_empty( value ) ) {
StringOutputStream angle( 32 );
angle << angle_normalised( atof( value ) );
- gtk_entry_set_text( m_entry, angle.c_str() );
+ m_entry.text(angle.c_str());
}
else
{
- gtk_entry_set_text( m_entry, "0" );
+ m_entry.text("0");
}
}
typedef MemberCaller<AngleAttribute, &AngleAttribute::update> UpdateCaller;
if ( f == -1 ) {
gtk_widget_set_sensitive( GTK_WIDGET( m_entry ), FALSE );
radio_button_set_active_no_signal( m_radio.m_radio, 0 );
- gtk_entry_set_text( m_entry, "" );
+ m_entry.text("");
}
else if ( f == -2 ) {
gtk_widget_set_sensitive( GTK_WIDGET( m_entry ), FALSE );
radio_button_set_active_no_signal( m_radio.m_radio, 1 );
- gtk_entry_set_text( m_entry, "" );
+ m_entry.text("");
}
else
{
radio_button_set_active_no_signal( m_radio.m_radio, 2 );
StringOutputStream angle( 32 );
angle << angle_normalised( f );
- gtk_entry_set_text( m_entry, angle.c_str() );
+ m_entry.text(angle.c_str());
}
}
else
{
- gtk_entry_set_text( m_entry, "0" );
+ m_entry.text("0");
}
}
typedef MemberCaller<DirectionAttribute, &DirectionAttribute::update> UpdateCaller;
}
angle << angle_normalised( pitch_yaw_roll.x() );
- gtk_entry_set_text( m_angles.m_pitch, angle.c_str() );
+ m_angles.m_pitch.text(angle.c_str());
angle.clear();
angle << angle_normalised( pitch_yaw_roll.y() );
- gtk_entry_set_text( m_angles.m_yaw, angle.c_str() );
+ m_angles.m_yaw.text(angle.c_str());
angle.clear();
angle << angle_normalised( pitch_yaw_roll.z() );
- gtk_entry_set_text( m_angles.m_roll, angle.c_str() );
+ m_angles.m_roll.text(angle.c_str());
angle.clear();
}
else
{
- gtk_entry_set_text( m_angles.m_pitch, "0" );
- gtk_entry_set_text( m_angles.m_yaw, "0" );
- gtk_entry_set_text( m_angles.m_roll, "0" );
+ m_angles.m_pitch.text("0");
+ m_angles.m_yaw.text("0");
+ m_angles.m_roll.text("0");
}
}
typedef MemberCaller<AnglesAttribute, &AnglesAttribute::update> UpdateCaller;
}
buffer << x_y_z.x();
- gtk_entry_set_text( m_vector3.m_x, buffer.c_str() );
+ m_vector3.m_x.text(buffer.c_str());
buffer.clear();
buffer << x_y_z.y();
- gtk_entry_set_text( m_vector3.m_y, buffer.c_str() );
+ m_vector3.m_y.text(buffer.c_str());
buffer.clear();
buffer << x_y_z.z();
- gtk_entry_set_text( m_vector3.m_z, buffer.c_str() );
+ m_vector3.m_z.text(buffer.c_str());
buffer.clear();
}
else
{
- gtk_entry_set_text( m_vector3.m_x, "0" );
- gtk_entry_set_text( m_vector3.m_y, "0" );
- gtk_entry_set_text( m_vector3.m_z, "0" );
+ m_vector3.m_x.text("0");
+ m_vector3.m_y.text("0");
+ m_vector3.m_z.text("0");
}
}
typedef MemberCaller<Vector3Attribute, &Vector3Attribute::update> UpdateCaller;
bool g_entityInspector_windowConstructed = false;
GtkTreeView* g_entityClassList;
-GtkTextView* g_entityClassComment;
+ui::TextView g_entityClassComment;
GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS];
-GtkEntry* g_entityKeyEntry;
-GtkEntry* g_entityValueEntry;
+ui::Entry g_entityKeyEntry;
+ui::Entry g_entityValueEntry;
ui::ListStore g_entlist_store{ui::null};
ui::ListStore g_entprops_store{ui::null};
g_current_comment = eclass;
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( g_entityClassComment );
- gtk_text_buffer_set_text( buffer, eclass->comments(), -1 );
+ g_entityClassComment.text(eclass->comments());
}
void SurfaceFlags_setEntityClass( EntityClass* eclass ){
{
for ( int i = 0; i < g_spawnflag_count; ++i )
{
- ui::Widget widget = ui::Widget(GTK_WIDGET( g_entitySpawnflagsCheck[i] ));
- gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), " " );
+ auto widget = ui::Widget(GTK_WIDGET(g_entitySpawnflagsCheck[i]));
+ auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget))));
+ label.text(" ");
gtk_widget_hide( widget );
g_object_ref( widget );
gtk_container_remove( GTK_CONTAINER( g_spawnflagsTable ), widget );
(GtkAttachOptions)( GTK_FILL ), 0, 0 );
widget.unref();
- gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN(widget)) ), str.c_str() );
+ auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)) ));
+ label.text(str.c_str());
}
}
}
// save current key/val pair around filling epair box
// row_select wipes it and sets to first in list
- CopiedString strKey( gtk_entry_get_text( g_entityKeyEntry ) );
- CopiedString strVal( gtk_entry_get_text( g_entityValueEntry ) );
+ CopiedString strKey( g_entityKeyEntry.text() );
+ CopiedString strVal( g_entityValueEntry.text() );
gtk_list_store_clear( store );
// Walk through list and add pairs
gtk_list_store_set( store, &iter, 0, key.c_str(), 1, value.c_str(), -1 );
}
- gtk_entry_set_text( g_entityKeyEntry, strKey.c_str() );
- gtk_entry_set_text( g_entityValueEntry, strVal.c_str() );
+ g_entityKeyEntry.text( strKey.c_str() );
+ g_entityValueEntry.text( strVal.c_str() );
for ( EntityAttributes::const_iterator i = g_entityAttributes.begin(); i != g_entityAttributes.end(); ++i )
{
char* val;
gtk_tree_model_get( model, &iter, 0, &key, 1, &val, -1 );
- gtk_entry_set_text( g_entityKeyEntry, key );
- gtk_entry_set_text( g_entityValueEntry, val );
+ g_entityKeyEntry.text( key );
+ g_entityValueEntry.text( val );
g_free( key );
g_free( val );
static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer data ){
if ( event->keyval == GDK_KEY_Return ) {
if ( widget == g_entityKeyEntry ) {
- gtk_entry_set_text( g_entityValueEntry, "" );
+ g_entityValueEntry.text( "" );
gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityValueEntry ) );
}
else
m_selection_disabled( false ){
}
-bool visible() const {
- return gtk_widget_get_visible( m_window );
+bool visible() {
+ return m_window.visible();
}
};
}
bool FindTextureDialog::isOpen(){
- return gtk_widget_get_visible( g_FindTextureDialog.GetWidget() ) == TRUE;
+ return g_FindTextureDialog.GetWidget().visible();
}
void FindTextureDialog::setFindStr( const char* name ){
struct GameCombo
{
ui::ComboBoxText game_select;
- GtkEntry* fsgame_entry;
+ ui::Entry fsgame_entry;
};
gboolean OnSelchangeComboWhatgame( ui::Widget widget, GameCombo* combo ){
gamecombo_t gamecombo = gamecombo_for_gamename( gamename );
- gtk_entry_set_text( combo->fsgame_entry, gamecombo.fs_game );
+ combo->fsgame_entry.text( gamecombo.fs_game );
gtk_widget_set_sensitive( GTK_WIDGET( combo->fsgame_entry ), gamecombo.sensitive );
return FALSE;
gamecombo_t gamecombo = gamecombo_for_dir( dir );
gtk_combo_box_set_active( dialog.game_combo.game_select, gamecombo.game );
- gtk_entry_set_text( dialog.game_combo.fsgame_entry, gamecombo.fs_game );
+ dialog.game_combo.fsgame_entry.text( gamecombo.fs_game );
gtk_widget_set_sensitive( GTK_WIDGET( dialog.game_combo.fsgame_entry ), gamecombo.sensitive );
if ( globalMappingMode().do_mapping_mode ) {
auto text_extensions = ui::TextView();
gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE );
sc_extensions.add(text_extensions);
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) );
- gtk_text_buffer_set_text( buffer, reinterpret_cast<const char*>( glGetString( GL_EXTENSIONS ) ), -1 );
+ text_extensions.text(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD );
text_extensions.show();
}
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkEntry* x;
- GtkEntry* y;
+ ui::Entry x;
+ ui::Entry y;
auto window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog );
char buf[16];
sprintf( buf, "%f", last_used_texture_layout_scale_x );
- gtk_entry_set_text( x, buf );
+ x.text( buf );
sprintf( buf, "%f", last_used_texture_layout_scale_y );
- gtk_entry_set_text( y, buf );
+ y.text( buf );
// Set focus after intializing the values
gtk_widget_grab_focus( GTK_WIDGET( x ) );
EMessageBoxReturn DoLightIntensityDlg( int *intensity ){
ModalDialog dialog;
- GtkEntry* intensity_entry;
+ ui::Entry intensity_entry;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
char buf[16];
sprintf( buf, "%d", *intensity );
- gtk_entry_set_text( intensity_entry, buf );
+ intensity_entry.text(buf);
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
if ( ret == eIDOK ) {
const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) );
if ( filename != 0 ) {
- gtk_entry_set_text( entry, filename );
+ entry.text(filename);
}
}
if ( dir != 0 ) {
gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 );
- gtk_entry_set_text( entry, converted );
+ entry.text(converted);
g_free( dir );
g_free( converted );
}
frame.add(vbox2);
{
- PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) );
+ PreferencesPage preferencesPage( *this, vbox2 );
Paths_constructPreferences( preferencesPage );
}
}
void ScreenUpdates_process(){
- if ( redrawRequired() && gtk_widget_get_visible( g_wait.m_window ) ) {
+ if ( redrawRequired() && g_wait.m_window.visible() ) {
ui::process();
}
}
ScreenUpdates_process();
}
}
- else if ( gtk_widget_get_visible( g_wait.m_window ) ) {
- gtk_label_set_text( g_wait.m_label, message );
+ else if ( g_wait.m_window.visible() ) {
+ g_wait.m_label.text(message);
ScreenUpdates_process();
}
g_wait_stack.push_back( message );
//gtk_window_present(MainFrame_getWindow());
}
- else if ( gtk_widget_get_visible( g_wait.m_window ) ) {
- gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() );
+ else if ( g_wait.m_window.visible() ) {
+ g_wait.m_label.text(g_wait_stack.back().c_str());
ScreenUpdates_process();
}
}
class MainWindowActive
{
static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){
- if ( g_wait.m_window && gtk_window_is_active( window ) && !gtk_widget_get_visible( g_wait.m_window ) ) {
+ if ( g_wait.m_window && gtk_window_is_active( window ) && !g_wait.m_window.visible() ) {
g_wait.m_window.show();
}
for ( int n = 0; n < c_count_status; n++ )
{
- m_pStatusLabel[n] = ui::root;
+ m_pStatusLabel[n] = ui::Label(ui::null);
}
m_bSleeping = false;
}
void MainFrame::RedrawStatusText(){
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_command_status] ), m_command_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_position_status] ), m_position_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_brushcount_status] ), m_brushcount_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_texture_status] ), m_texture_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_grid_status] ), m_grid_status.c_str() );
+ ui::Label::from(m_pStatusLabel[c_command_status]).text(m_command_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_position_status]).text(m_position_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_brushcount_status]).text(m_brushcount_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_texture_status]).text(m_texture_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_grid_status]).text(m_grid_status.c_str());
}
void MainFrame::UpdateStatusText(){
void DoMapInfo(){
ModalDialog dialog;
- GtkEntry* brushes_entry;
- GtkEntry* entities_entry;
+ ui::Entry brushes_entry;
+ ui::Entry entities_entry;
ui::ListStore EntityBreakdownWalker{ui::null};
ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog );
char tmp[16];
sprintf( tmp, "%u", Unsigned( g_brushCount.get() ) );
- gtk_entry_set_text( GTK_ENTRY( brushes_entry ), tmp );
+ brushes_entry.text(tmp);
sprintf( tmp, "%u", Unsigned( g_entityCount.get() ) );
- gtk_entry_set_text( GTK_ENTRY( entities_entry ), tmp );
+ entities_entry.text(tmp);
modal_dialog_show( window, dialog );
void DoFind(){
ModalDialog dialog;
- GtkEntry* entity;
- GtkEntry* brush;
+ ui::Entry entity;
+ ui::Entry brush;
ui::Window window = MainFrame_getWindow().create_dialog_window("Find Brush", G_CALLBACK(dialog_delete_callback ), &dialog );
GetSelectionIndex( &ent, &br );
sprintf( buf, "%i", ent );
- gtk_entry_set_text( entity, buf );
+ entity.text(buf);
sprintf( buf, "%i", br );
- gtk_entry_set_text( brush, buf );
+ brush.text(buf);
if ( modal_dialog_show( window, dialog ) == eIDOK ) {
const char *entstr = gtk_entry_get_text( entity );
MRU_SetText( i, MRU_GetText( i + 1 ) );
if ( MRU_used == 0 ) {
- gtk_label_set_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN( MRU_items[0] )) ), "Recent Files" );
+ auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(MRU_items[0] )) ));
+ label.text("Recent Files");
gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), FALSE );
}
else
}
else
{
- gtk_entry_set_text( m_horizontal, "" );
- gtk_entry_set_text( m_vertical, "" );
+ m_horizontal.text("");
+ m_vertical.text("");
gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), FALSE );
gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), FALSE );
}
}
bool visible(){
- return gtk_widget_get_visible( GetWidget() );
+ return GetWidget().visible();
}
// void UpdateInfo();
struct ScaleDialog
{
- ui::Widget x;
- ui::Widget y;
- ui::Widget z;
+ ui::Entry x;
+ ui::Entry y;
+ ui::Entry z;
ui::Window window{ui::null};
};
static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){
gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->y ), "1.0" );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->z ), "1.0" );
+ scaleDialog->x.text("1.0");
+ scaleDialog->y.text("1.0");
+ scaleDialog->z.text("1.0");
return TRUE;
}
(GtkAttachOptions) ( 0 ), 0, 0 );
}
{
- ui::Widget entry = ui::Entry();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
+ auto entry = ui::Entry();
+ entry.text("1.0");
entry.show();
gtk_table_attach( table, entry, 1, 2, 0, 1,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
g_scale_dialog.x = entry;
}
{
- ui::Widget entry = ui::Entry();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
+ auto entry = ui::Entry();
+ entry.text("1.0");
entry.show();
gtk_table_attach( table, entry, 1, 2, 1, 2,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
g_scale_dialog.y = entry;
}
{
- ui::Widget entry = ui::Entry();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
+ auto entry = ui::Entry();
+ entry.text("1.0");
entry.show();
gtk_table_attach( table, entry, 1, 2, 2, 3,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
Increment m_hscaleIncrement;
Increment m_vscaleIncrement;
Increment m_rotateIncrement;
-GtkEntry* m_texture;
+ui::Entry m_texture;
SurfaceInspector() :
m_textureEntry( ApplyShaderCaller( *this ), UpdateCaller( *this ) ),
void destroyWindow(){
Destroy();
}
-bool visible() const {
- return gtk_widget_get_visible( GetWidget() );
+bool visible() {
+ return GetWidget().visible();
}
void queueDraw(){
if ( visible() ) {
const char * name = SurfaceInspector_GetSelectedShader();
if ( shader_is_texture( name ) ) {
- gtk_entry_set_text( m_texture, shader_get_textureName( name ) );
+ m_texture.text(shader_get_textureName(name));
}
else
{
- gtk_entry_set_text( m_texture, "" );
+ m_texture.text("");
}
texdef_t shiftScaleRotate;
Shader* XYWnd::m_state_selected = 0;
void xy_update_xor_rectangle( XYWnd& self, rect_t area ){
- if ( gtk_widget_get_visible( self.GetWidget() ) ) {
+ if ( self.GetWidget().visible() ) {
self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.Width(), self.Height() ) );
}
}