static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) { WCHAR *wstring; WCHAR *p; size_t count; SDL_bool status; if (!string) { string = ""; } wstring = WIN_UTF8ToString(string); if (!wstring) { return SDL_FALSE; } /* Find out how many characters we have, including null terminator */ count = 0; for (p = wstring; *p; ++p) { ++count; } ++count; status = AddDialogData(dialog, wstring, count*sizeof(WCHAR)); SDL_free(wstring); return status; }
static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) { WIN_DialogData *dialog; DLGTEMPLATE dialogTemplate; SDL_zero(dialogTemplate); dialogTemplate.style = (WS_CAPTION | DS_CENTER); dialogTemplate.x = 0; dialogTemplate.y = 0; dialogTemplate.cx = w; dialogTemplate.cy = h; dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog)); if (!dialog) { return NULL; } if (!AddDialogData(dialog, &dialogTemplate, sizeof(dialogTemplate))) { FreeDialogData(dialog); return NULL; } /* There is no menu or special class */ if (!AddDialogString(dialog, "") || !AddDialogString(dialog, "")) { FreeDialogData(dialog); return NULL; } if (!AddDialogString(dialog, caption)) { FreeDialogData(dialog); return NULL; } return dialog; }
static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption) { DLGITEMTEMPLATEEX item; WORD marker = 0xFFFF; WORD extraData = 0; SDL_zero(item); item.style = style; item.exStyle = exStyle; item.x = x; item.y = y; item.cx = w; item.cy = h; item.id = id; Vec2ToDLU(&item.x, &item.y); Vec2ToDLU(&item.cx, &item.cy); if (!AlignDialogData(dialog, sizeof(DWORD))) { return SDL_FALSE; } if (!AddDialogData(dialog, &item, sizeof(item))) { return SDL_FALSE; } if (!AddDialogData(dialog, &marker, sizeof(marker))) { return SDL_FALSE; } if (!AddDialogData(dialog, &type, sizeof(type))) { return SDL_FALSE; } if (!AddDialogString(dialog, caption)) { return SDL_FALSE; } if (!AddDialogData(dialog, &extraData, sizeof(extraData))) { return SDL_FALSE; } ++dialog->lpDialog->cDlgItems; return SDL_TRUE; }
static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) { WIN_DialogData *dialog; DLGTEMPLATEEX dialogTemplate; WORD WordToPass; SDL_zero(dialogTemplate); dialogTemplate.dlgVer = 1; dialogTemplate.signature = 0xffff; dialogTemplate.style = (WS_CAPTION | DS_CENTER | DS_SHELLFONT); dialogTemplate.x = 0; dialogTemplate.y = 0; dialogTemplate.cx = w; dialogTemplate.cy = h; Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy); dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog)); if (!dialog) { return NULL; } if (!AddDialogData(dialog, &dialogTemplate, sizeof(dialogTemplate))) { FreeDialogData(dialog); return NULL; } /* No menu */ WordToPass = 0; if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } /* No custom class */ if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } /* title */ if (!AddDialogString(dialog, caption)) { FreeDialogData(dialog); return NULL; } /* Font stuff */ { /* * We want to use the system messagebox font. */ BYTE ToPass; NONCLIENTMETRICSA NCM; NCM.cbSize = sizeof(NCM); SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0); /* Font size - convert to logical font size for dialog parameter. */ { HDC ScreenDC = GetDC(NULL); int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY); if (!LogicalPixelsY) /* This can happen if the application runs out of GDI handles */ LogicalPixelsY = 72; WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY); ReleaseDC(NULL, ScreenDC); } if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } /* Font weight */ WordToPass = (WORD)NCM.lfMessageFont.lfWeight; if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } /* italic? */ ToPass = NCM.lfMessageFont.lfItalic; if (!AddDialogData(dialog, &ToPass, 1)) { FreeDialogData(dialog); return NULL; } /* charset? */ ToPass = NCM.lfMessageFont.lfCharSet; if (!AddDialogData(dialog, &ToPass, 1)) { FreeDialogData(dialog); return NULL; } /* font typeface. */ if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) { FreeDialogData(dialog); return NULL; } } return dialog; }
void FindTextureDialog::BuildDialog(){ GtkWidget *dlg, *vbox, *hbox, *table, *label; GtkWidget *button, *check, *entry, *arrow; dlg = m_pWidget; gtk_window_set_title( GTK_WINDOW( dlg ), _( "Find / Replace Texture(s)" ) ); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pParentWnd->m_pWidget ) ); hbox = gtk_hbox_new( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( dlg ), hbox ); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); gtk_widget_show( hbox ); vbox = gtk_vbox_new( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 5 ); gtk_widget_show( vbox ); table = gtk_table_new( 2, 3, FALSE ); gtk_box_pack_start( GTK_BOX( vbox ), table, TRUE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_widget_show( table ); label = gtk_label_new( _( "Find:" ) ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 ); gtk_widget_show( label ); label = gtk_label_new( _( "Replace:" ) ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 ); gtk_widget_show( label ); entry = gtk_entry_new(); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( entry ); g_signal_connect( G_OBJECT( entry ), "focus-in-event", G_CALLBACK( find_focus_in ), NULL ); AddDialogData( entry, &m_strFind, DLG_ENTRY_TEXT ); button = gtk_button_new(); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_widget_show( button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( find_clicked ), entry ); arrow = gtk_arrow_new( GTK_ARROW_DOWN, GTK_SHADOW_OUT ); gtk_container_add( GTK_CONTAINER( button ), arrow ); gtk_widget_show( arrow ); entry = gtk_entry_new(); gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_show( entry ); g_signal_connect( G_OBJECT( entry ), "focus-in-event", G_CALLBACK( replace_focus_in ), NULL ); AddDialogData( entry, &m_strReplace, DLG_ENTRY_TEXT ); button = gtk_button_new(); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); gtk_widget_show( button ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( find_clicked ), entry ); arrow = gtk_arrow_new( GTK_ARROW_DOWN, GTK_SHADOW_OUT ); gtk_container_add( GTK_CONTAINER( button ), arrow ); gtk_widget_show( arrow ); check = gtk_check_button_new_with_label( _( "Use selected brushes only" ) ); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); gtk_widget_show( check ); AddDialogData( check, &m_bSelectedOnly, DLG_CHECK_BOOL ); check = gtk_check_button_new_with_label( _( "Replace everywhere (selected/active), don't test against Find" ) ); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); gtk_widget_show( check ); AddDialogData( check, &m_bForce, DLG_CHECK_BOOL ); check = gtk_check_button_new_with_label( _( "Live updates from Texture/Camera windows" ) ); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); gtk_widget_show( check ); AddDialogData( check, &m_bLive, DLG_CHECK_BOOL ); vbox = gtk_vbox_new( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( hbox ), vbox, TRUE, TRUE, 0 ); gtk_widget_show( vbox ); button = gtk_button_new_with_label( _( "Find" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnFind ), NULL ); gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( button ); button = gtk_button_new_with_label( _( "OK" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnOK ), NULL ); gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( button ); button = gtk_button_new_with_label( _( "Apply" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnApply ), NULL ); gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( button ); button = gtk_button_new_with_label( _( "Close" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnClose ), NULL ); gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( dlg ); }
GtkWindow* FindTextureDialog::BuildDialog() { GtkWidget* vbox, *hbox, *table, *label; GtkWidget* button, *check, *entry; GtkWindow* dlg = create_floating_window("Find / Replace Texture(s)", m_parent); hbox = gtk_hbox_new (FALSE, 5); gtk_widget_show (hbox); gtk_container_add(GTK_CONTAINER(dlg), GTK_WIDGET(hbox)); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); vbox = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), TRUE, TRUE, 0); table = gtk_table_new (2, 2, FALSE); gtk_widget_show (table); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(table), TRUE, TRUE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), 5); gtk_table_set_col_spacings (GTK_TABLE (table), 5); label = gtk_label_new ("Find:"); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); label = gtk_label_new ("Replace:"); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); entry = gtk_entry_new(); gtk_widget_show (entry); gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL), (GtkAttachOptions) (0), 0, 0); g_signal_connect(G_OBJECT(entry), "focus_in_event", G_CALLBACK(find_focus_in), 0); AddDialogData(*GTK_ENTRY(entry), m_strFind); GlobalTextureEntryCompletion::instance().connect(GTK_ENTRY(entry)); entry = gtk_entry_new(); gtk_widget_show (entry); gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL), (GtkAttachOptions) (0), 0, 0); g_signal_connect(G_OBJECT(entry), "focus_in_event", G_CALLBACK(replace_focus_in), 0); AddDialogData(*GTK_ENTRY(entry), m_strReplace); GlobalTextureEntryCompletion::instance().connect(GTK_ENTRY(entry)); check = gtk_check_button_new_with_label ("Within selected brushes only"); gtk_widget_show (check); gtk_box_pack_start(GTK_BOX(vbox), check, TRUE, TRUE, 0); AddDialogData(*GTK_TOGGLE_BUTTON(check), m_bSelectedOnly); vbox = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 0); button = gtk_button_new_with_label ("Apply"); gtk_widget_show (button); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(OnApply), 0); gtk_widget_set_usize (button, 60, -2); button = gtk_button_new_with_label ("Close"); gtk_widget_show (button); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(OnClose), 0); gtk_widget_set_usize (button, 60, -2); return dlg; }
void SurfaceDlg::BuildDialog(){ GtkWidget *dlg, *vbox, *hbox2, *frame, *table, *label; GtkWidget *button, *entry, *spin; dlg = m_pWidget; load_window_pos( dlg, g_PrefsDlg.mWindowInfo.posSurfaceWnd ); gtk_window_set_title( GTK_WINDOW( dlg ), _( "Surface inspector" ) ); //g_signal_connect (G_OBJECT (dlg), "delete_event", G_CALLBACK (OnCancel), NULL); // we catch 'Enter' and interpret is as OnDone gtk_signal_connect( GTK_OBJECT( dlg ), "key_press_event", GTK_SIGNAL_FUNC( OnDialogKey ), NULL ); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pParentWnd->m_pWidget ) ); // replaced by only the vbox: vbox = gtk_vbox_new( FALSE, 5 ); gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); hbox2 = gtk_hbox_new( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); label = gtk_label_new( _( "Texture" ) ); gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); entry = gtk_entry_new(); gtk_signal_connect( GTK_OBJECT( entry ), "key_press_event", GTK_SIGNAL_FUNC( OnTextureKey ), NULL ); gtk_widget_show( entry ); gtk_box_pack_start( GTK_BOX( hbox2 ), entry, TRUE, TRUE, 0 ); g_object_set_data( G_OBJECT( m_pWidget ), "texture", entry ); // table = gtk_table_new (5, 4, FALSE); table = gtk_table_new( 6, 4, FALSE ); gtk_widget_show( table ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); label = gtk_label_new( _( "Horizontal shift" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 8 ) ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hshift", spin ); gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed", GTK_SIGNAL_FUNC( OnUpdate ), NULL ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); g_object_set_data( G_OBJECT( dlg ), "hshift_inc", entry ); gtk_signal_connect( GTK_OBJECT( entry ), "changed", GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL ); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( entry, 50, -2 ); label = gtk_label_new( _( "Vertical shift" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 8 ) ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vshift", spin ); gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed", GTK_SIGNAL_FUNC( OnUpdate ), NULL ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); g_object_set_data( G_OBJECT( dlg ), "vshift_inc", entry ); gtk_signal_connect( GTK_OBJECT( entry ), "changed", GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL ); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( entry, 50, -2 ); label = gtk_label_new( _( "Horizontal stretch" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 10, 10 ) ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "hscale", spin ); gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed", GTK_SIGNAL_FUNC( OnUpdate ), NULL ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 2, 3 ); entry = gtk_entry_new(); g_object_set_data( G_OBJECT( dlg ), "hscale_inc", entry ); gtk_signal_connect( GTK_OBJECT( entry ), "changed", GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL ); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 2, 3 ); gtk_widget_set_usize( entry, 50, -2 ); label = gtk_label_new( _( "Vertical stretch" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 10, 10 ) ), 0, 0 ); g_object_set_data( G_OBJECT( dlg ), "vscale", spin ); gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed", GTK_SIGNAL_FUNC( OnUpdate ), NULL ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); g_object_set_data( G_OBJECT( dlg ), "vscale_inc", entry ); gtk_signal_connect( GTK_OBJECT( entry ), "changed", GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL ); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( entry, 50, -2 ); label = gtk_label_new( _( "Rotate" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -360, 360, 1, 10, 10 ) ), 1, 0 ); g_object_set_data( G_OBJECT( dlg ), "rotate", spin ); gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed", GTK_SIGNAL_FUNC( OnUpdate ), NULL ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE ); label = gtk_label_new( _( "Step" ) ); gtk_widget_show( label ); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); g_object_set_data( G_OBJECT( dlg ), "rotate_inc", entry ); gtk_signal_connect( GTK_OBJECT( entry ), "changed", GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL ); gtk_widget_show( entry ); gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 4, 5, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( entry, 50, -2 ); // match grid button button = gtk_button_new_with_label( _( "Match Grid" ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnMatchGrid ), NULL ); frame = gtk_frame_new( _( "Texturing" ) ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = gtk_table_new( 4, 4, FALSE ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER( frame ), table ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); label = gtk_label_new( "Brush" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); label = gtk_label_new( "Patch" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); label = gtk_label_new( "Width" ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); label = gtk_label_new( _( "Height" ) ); gtk_widget_show( label ); gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); button = gtk_button_new_with_label( _( "Axial" ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnAxial ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "Fit" ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnFaceFit ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "CAP" ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnPatchdetails ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "Set..." ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnPatchreset ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "Natural" ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnPatchnatural ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "Fit" ) ); gtk_widget_show( button ); gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnPatchFit ), NULL ); gtk_widget_set_usize( button, 60, -2 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 32, 1, 10, 10 ) ), 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); AddDialogData( spin, &m_nWidth, DLG_SPIN_INT ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 32, 1, 10, 10 ) ), 1, 0 ); gtk_widget_show( spin ); gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_widget_set_usize( spin, 60, -2 ); AddDialogData( spin, &m_nHeight, DLG_SPIN_INT ); hbox2 = gtk_hbox_new( FALSE, 5 ); gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); button = gtk_button_new_with_label( _( "Done" ) ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnDone ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "Apply" ) ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnApply ), NULL ); gtk_widget_set_usize( button, 60, -2 ); button = gtk_button_new_with_label( _( "Cancel" ) ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnCancel ), NULL ); gtk_widget_set_usize( button, 60, -2 ); // that's a bit of trashy stuff from Textool-v2 branch #ifdef _DEBUG // FIXME: testing only, scaling in BP mode button = gtk_button_new_with_label( _( "Test" ) ); gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnTest ), NULL ); gtk_widget_set_usize( button, 60, -2 ); #endif // Initialize SetTexMods(); }
BOOL ResizeDlg::SetData(const DialogSizerSizingItem *psd, BOOL bShowSizingGrip, HKEY hkRootSave, LPCTSTR pcszName, SIZE *psizeMax) // // Setting a dialog sizeable involves subclassing the window and handling it's // WM_SIZE messages, if we have a hkRootSave and pcszName then we will also be loading/saving // the size and position of the window from the registry. We load from the registry when we // subclass the window and we save to the registry when we get a WM_DESTROY. // // It will return non-zero for success and zero if it fails { R_ASSERT( psd ); R_ASSERT( ( hkRootSave != NULL && pcszName != NULL ) || ( hkRootSave == NULL && pcszName == NULL ) ); // // Make sure all of the parameters are valid. if( ::IsWindow( *this ) && psd && ( ( hkRootSave != NULL && pcszName != NULL && !IsBadStringPtr( pcszName, 0xFFFF ) ) || ( hkRootSave == NULL && pcszName == NULL ) ) && ( psizeMax == NULL || !IsBadReadPtr( psizeMax, sizeof( SIZE ) ) ) ) { DialogData *pdd = (DialogData *)AddDialogData(); if( pdd ) { pdd->hkRootSave = hkRootSave; pdd->pcszName = pcszName; pdd->m_bShowSizingGrip = bShowSizingGrip; pdd->nItemCount = ResizeDlgGetItemCount( psd ) + 1; pdd->psd = (DialogSizerSizingItem *) calloc(pdd->nItemCount, sizeof(DialogSizerSizingItem )); if( pdd->psd ) { // // Copy all of the user controls etc. for later, this way the user can quite happily // let the structure go out of scope. ResizeDlgCopyItems( pdd->psd, psd ); if( psizeMax ) { pdd->m_ptLargest.x = psizeMax->cx; pdd->m_ptLargest.y = psizeMax->cy; pdd->m_bLargestSet = true; } // // If the there was save info passed in then we need to make damn good use of it // by attempting to load the RegistryData structure if( hkRootSave && pcszName ) { RegistryData rd; DWORD dwSize = sizeof( RegistryData ); DWORD dwType = REG_BINARY; if( RegQueryValueExRecursive( hkRootSave, pcszName, NULL, &dwType, reinterpret_cast<LPBYTE>( &rd ), &dwSize ) == ERROR_SUCCESS && dwSize == sizeof( rd ) ) { if( !(GetWindowLong( *this, GWL_STYLE ) & WS_VISIBLE) ) rd.m_wpl.showCmd = SW_HIDE; VAPI( SetWindowPlacement( &rd.m_wpl ) ); } } return TRUE; } else { free(pdd); } } } return FALSE; }