tProgress bars added to Win32 GTK+ emulation; tweaks for better usage of gtk_wi… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 290ec78c3d45f04c68b420451c2a3100fba912d8 | |
parent cbe75c4a064236ea7d99cde4091576c75fa63254 | |
Author: Ben Webb <[email protected]> | |
Date: Sat, 7 Apr 2001 22:48:45 +0000 | |
Progress bars added to Win32 GTK+ emulation; tweaks for better usage of | |
gtk_widget_set_usize | |
Diffstat: | |
M src/gtk.c | 103 +++++++++++++++++++++++++++++… | |
M src/gtk.h | 29 +++++++++++++++++++++++++++++ | |
2 files changed, 132 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/src/gtk.c b/src/gtk.c | |
t@@ -180,6 +180,9 @@ static void gtk_window_handle_auto_size(GtkWindow *window, | |
GtkAllocation *allocation); | |
static void gtk_window_set_initial_position(GtkWindow *window, | |
GtkAllocation *allocation); | |
+static void gtk_progress_bar_size_request(GtkWidget *widget, | |
+ GtkRequisition *requisition); | |
+static void gtk_progress_bar_realize(GtkWidget *widget); | |
typedef struct _GdkInput GdkInput; | |
t@@ -239,6 +242,20 @@ static GtkSignalType GtkSeparatorSignals[] = { | |
{ "",NULL,NULL } | |
}; | |
+static GtkClass GtkMiscClass = { | |
+ "misc",&GtkWidgetClass,sizeof(GtkMisc),NULL | |
+}; | |
+ | |
+static GtkSignalType GtkProgressBarSignals[] = { | |
+ { "size_request",gtk_marshal_VOID__GPOIN,gtk_progress_bar_size_request }, | |
+ { "realize",gtk_marshal_VOID__VOID,gtk_progress_bar_realize }, | |
+ { "",NULL,NULL } | |
+}; | |
+ | |
+static GtkClass GtkProgressBarClass = { | |
+ "progressbar",&GtkWidgetClass,sizeof(GtkProgressBar),GtkProgressBarSignals | |
+}; | |
+ | |
static GtkClass GtkSeparatorClass = { | |
"separator",&GtkWidgetClass,sizeof(GtkSeparator),GtkSeparatorSignals | |
}; | |
t@@ -1037,6 +1054,8 @@ void gtk_widget_realize(GtkWidget *widget) { | |
void gtk_widget_create(GtkWidget *widget) { | |
GTK_WIDGET_SET_FLAGS(widget,GTK_SENSITIVE); | |
+ widget->usize.width=0; | |
+ widget->usize.height=0; | |
} | |
void gtk_widget_destroy(GtkWidget *widget) { | |
t@@ -1071,6 +1090,10 @@ void gtk_widget_size_request(GtkWidget *widget,GtkRequi… | |
if (GTK_WIDGET_VISIBLE(widget)) { | |
gtk_signal_emit(GTK_OBJECT(widget),"size_request",requisition); | |
} | |
+ if (requisition->width < widget->usize.width) | |
+ requisition->width = widget->usize.width; | |
+ if (requisition->height < widget->usize.height) | |
+ requisition->height = widget->usize.height; | |
if (requisition->width != widget->requisition.width || | |
requisition->height != widget->requisition.height) { | |
memcpy(&widget->requisition,requisition,sizeof(GtkRequisition)); | |
t@@ -2439,6 +2462,26 @@ GtkWidget *gtk_table_new(guint rows,guint cols,gboolean… | |
return GTK_WIDGET(table); | |
} | |
+void gtk_table_resize(GtkTable *table,guint rows,guint cols) { | |
+ gint i; | |
+ table->rows = g_realloc(table->rows,sizeof(GtkTableRowCol)*rows); | |
+ table->cols = g_realloc(table->cols,sizeof(GtkTableRowCol)*cols); | |
+ | |
+ for (i=table->nrows;i<rows;i++) { | |
+ table->rows[i].requisition=0; | |
+ table->rows[i].allocation=0; | |
+ table->rows[i].spacing=table->row_spacing; | |
+ } | |
+ for (i=table->ncols;i<cols;i++) { | |
+ table->cols[i].requisition=0; | |
+ table->cols[i].allocation=0; | |
+ table->cols[i].spacing=table->column_spacing; | |
+ } | |
+ table->nrows = rows; | |
+ table->ncols = cols; | |
+ gtk_widget_update(GTK_WIDGET(table),FALSE); | |
+} | |
+ | |
void gtk_table_attach_defaults(GtkTable *table,GtkWidget *widget, | |
guint left_attach,guint right_attach, | |
guint top_attach,guint bottom_attach) { | |
t@@ -3928,6 +3971,10 @@ guint gtk_label_parse_uline(GtkLabel *label,const gchar… | |
return 0; | |
} | |
+void gtk_label_get(GtkLabel *label,gchar **str) { | |
+ *str = label->text; | |
+} | |
+ | |
void gtk_clist_set_row_data(GtkCList *clist,gint row,gpointer data) { | |
GtkCListRow *list_row; | |
if (row>=0 && row<g_slist_length(clist->rows)) { | |
t@@ -3957,6 +4004,8 @@ void gtk_text_set_point(GtkText *text,guint index) { | |
} | |
void gtk_widget_set_usize(GtkWidget *widget,gint width,gint height) { | |
+ widget->usize.width = width; | |
+ widget->usize.height = height; | |
} | |
void gtk_clist_select_row(GtkCList *clist,gint row,gint column) { | |
t@@ -4071,3 +4120,57 @@ void gtk_paned_set_position(GtkPaned *paned,gint positi… | |
memcpy(&allocation,&paned->true_alloc,sizeof(GtkAllocation)); | |
gtk_widget_set_size(GTK_WIDGET(paned),&allocation); | |
} | |
+ | |
+void gtk_misc_set_alignment(GtkMisc *misc,gfloat xalign,gfloat yalign) { | |
+} | |
+ | |
+GtkWidget *gtk_progress_bar_new() { | |
+ GtkProgressBar *prog; | |
+ | |
+ prog=GTK_PROGRESS_BAR(GtkNewObject(&GtkProgressBarClass)); | |
+ prog->orient=GTK_PROGRESS_LEFT_TO_RIGHT; | |
+ prog->position=0; | |
+ | |
+ return GTK_WIDGET(prog); | |
+} | |
+ | |
+void gtk_progress_bar_set_orientation(GtkProgressBar *pbar, | |
+ GtkProgressBarOrientation orientation) { | |
+ pbar->orient=orientation; | |
+} | |
+ | |
+void gtk_progress_bar_update(GtkProgressBar *pbar,gfloat percentage) { | |
+ GtkWidget *widget; | |
+ | |
+ widget=GTK_WIDGET(pbar); | |
+ pbar->position = percentage; | |
+ if (GTK_WIDGET_REALIZED(widget)) { | |
+ SendMessage(widget->hWnd,PBM_SETPOS,(WPARAM)(10000.0*pbar->position),0); | |
+ } | |
+} | |
+ | |
+void gtk_progress_bar_size_request(GtkWidget *widget, | |
+ GtkRequisition *requisition) { | |
+ SIZE size; | |
+ | |
+ if (GetTextSize(widget->hWnd,"Sample",&size)) { | |
+ requisition->width = size.cx; | |
+ requisition->height = size.cy; | |
+ } | |
+} | |
+ | |
+void gtk_progress_bar_realize(GtkWidget *widget) { | |
+ HWND Parent; | |
+ GtkProgressBar *prog; | |
+ | |
+ prog=GTK_PROGRESS_BAR(widget); | |
+ Parent=gtk_get_parent_hwnd(widget); | |
+ widget->hWnd = CreateWindowEx(WS_EX_CLIENTEDGE,PROGRESS_CLASS,"", | |
+ WS_CHILD, | |
+ widget->allocation.x,widget->allocation.y, | |
+ widget->allocation.width,widget->allocation.height, | |
+ Parent,NULL,hInst,NULL); | |
+ gtk_set_default_font(widget->hWnd); | |
+ SendMessage(widget->hWnd,PBM_SETRANGE,0,MAKELPARAM(0,10000)); | |
+ SendMessage(widget->hWnd,PBM_SETPOS,(WPARAM)(10000.0*prog->position),0); | |
+} | |
diff --git a/src/gtk.h b/src/gtk.h | |
t@@ -21,6 +21,13 @@ typedef enum { | |
} GtkVisibility; | |
typedef enum { | |
+ GTK_PROGRESS_LEFT_TO_RIGHT, | |
+ GTK_PROGRESS_RIGHT_TO_LEFT, | |
+ GTK_PROGRESS_BOTTOM_TO_TOP, | |
+ GTK_PROGRESS_TOP_TO_BOTTOM | |
+} GtkProgressBarOrientation; | |
+ | |
+typedef enum { | |
GTK_EXPAND = 1 << 0, | |
GTK_SHRINK = 1 << 1, | |
GTK_FILL = 1 << 2 | |
t@@ -74,6 +81,8 @@ typedef struct _GtkMenuItem GtkMenuItem; | |
typedef struct _GtkMenu GtkMenu; | |
typedef struct _GtkAdjustment GtkAdjustment; | |
typedef struct _GtkSeparator GtkSeparator; | |
+typedef struct _GtkMisc GtkMisc; | |
+typedef struct _GtkProgressBar GtkProgressBar; | |
typedef struct _GtkHSeparator GtkHSeparator; | |
typedef struct _GtkVSeparator GtkVSeparator; | |
typedef struct _GtkAccelGroup GtkAccelGroup; | |
t@@ -128,9 +137,20 @@ struct _GtkWidget { | |
HWND hWnd; | |
GtkRequisition requisition; | |
GtkAllocation allocation; | |
+ GtkRequisition usize; | |
GtkWidget *parent; | |
}; | |
+struct _GtkMisc { | |
+ GtkWidget widget; | |
+}; | |
+ | |
+struct _GtkProgressBar { | |
+ GtkWidget widget; | |
+ GtkProgressBarOrientation orient; | |
+ gfloat position; | |
+}; | |
+ | |
struct _GtkSeparator { | |
GtkWidget widget; | |
}; | |
t@@ -429,6 +449,8 @@ struct _GtkTableRowCol { | |
#define GTK_MENU_BAR(obj) ((GtkMenuBar *)(obj)) | |
#define GTK_MENU_ITEM(obj) ((GtkMenuItem *)(obj)) | |
#define GTK_MENU(obj) ((GtkMenu *)(obj)) | |
+#define GTK_MISC(obj) ((GtkMisc *)(obj)) | |
+#define GTK_PROGRESS_BAR(obj) ((GtkProgressBar *)(obj)) | |
#define GTK_SIGNAL_FUNC(f) ((GtkSignalFunc) f) | |
#define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT(obj)->flags) | |
t@@ -473,6 +495,7 @@ GtkWidget *gtk_scrolled_text_new(GtkAdjustment *hadj,GtkAd… | |
GtkWidget **pack_widg); | |
GtkWidget *gtk_entry_new(); | |
GtkWidget *gtk_table_new(guint rows,guint cols,gboolean homogeneous); | |
+void gtk_table_resize(GtkTable *table,guint rows,guint cols); | |
GtkItemFactory *gtk_item_factory_new(GtkType container_type, | |
const gchar *path, | |
GtkAccelGroup *accel_group); | |
t@@ -617,6 +640,7 @@ void gtk_option_menu_set_menu(GtkOptionMenu *option_menu,G… | |
void gtk_option_menu_set_history(GtkOptionMenu *option_menu,guint index); | |
void gtk_label_set_text(GtkLabel *label,const gchar *str); | |
guint gtk_label_parse_uline(GtkLabel *label,const gchar *str); | |
+void gtk_label_get(GtkLabel *label,gchar **str); | |
void gtk_clist_set_row_data(GtkCList *clist,gint row,gpointer data); | |
gpointer gtk_clist_get_row_data(GtkCList *clist,gint row); | |
void gtk_clist_set_auto_sort(GtkCList *clist,gboolean auto_sort); | |
t@@ -634,6 +658,11 @@ gint gtk_spin_button_get_value_as_int(GtkSpinButton *spin… | |
void gtk_spin_button_set_value(GtkSpinButton *spin_button,gfloat value); | |
void gtk_spin_button_set_adjustment(GtkSpinButton *spin_button, | |
GtkAdjustment *adjustment); | |
+void gtk_misc_set_alignment(GtkMisc *misc,gfloat xalign,gfloat yalign); | |
+GtkWidget *gtk_progress_bar_new(); | |
+void gtk_progress_bar_set_orientation(GtkProgressBar *pbar, | |
+ GtkProgressBarOrientation orientation); | |
+void gtk_progress_bar_update(GtkProgressBar *pbar,gfloat percentage); | |
extern long AsyncSocketError; | |