Mercurial > dwindows
comparison gtk/dw.c @ 566:f6de197ecbe9
Add dw_color_choose()
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 17 Jun 2004 11:22:14 +0000 |
parents | d7c61755a57b |
children | a126f4ec9570 |
comparison
equal
deleted
inserted
replaced
565:355a6d46adb1 | 566:f6de197ecbe9 |
---|---|
78 GdkColor _background[DW_THREAD_LIMIT]; | 78 GdkColor _background[DW_THREAD_LIMIT]; |
79 int _transparent[DW_THREAD_LIMIT]; | 79 int _transparent[DW_THREAD_LIMIT]; |
80 | 80 |
81 GtkWidget *last_window = NULL, *popup = NULL; | 81 GtkWidget *last_window = NULL, *popup = NULL; |
82 | 82 |
83 static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_ignore_expand = 0; | 83 static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0; |
84 static pthread_t _dw_thread = (pthread_t)-1; | 84 static pthread_t _dw_thread = (pthread_t)-1; |
85 static int _dw_mutex_locked[DW_THREAD_LIMIT]; | 85 static int _dw_mutex_locked[DW_THREAD_LIMIT]; |
86 /* Use default border size for the default enlightenment theme */ | 86 /* Use default border size for the default enlightenment theme */ |
87 static int _dw_border_width = 12, _dw_border_height = 28; | 87 static int _dw_border_width = 12, _dw_border_height = 28; |
88 | 88 |
181 #define DW_CENTER 0.5f | 181 #define DW_CENTER 0.5f |
182 #define DW_LEFT 0.0f | 182 #define DW_LEFT 0.0f |
183 #define DW_RIGHT 1.0f | 183 #define DW_RIGHT 1.0f |
184 | 184 |
185 /* MDI Support Code */ | 185 /* MDI Support Code */ |
186 #if GTK_MAJOR_VERSION > 1 | 186 #if GTK_MAJOR_VERSION > 1 |
187 #define GTK_MDI(obj) GTK_CHECK_CAST (obj, gtk_mdi_get_type (), GtkMdi) | 187 #define GTK_MDI(obj) GTK_CHECK_CAST (obj, gtk_mdi_get_type (), GtkMdi) |
188 #define GTK_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass) | 188 #define GTK_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass) |
189 #define GTK_IS_MDI(obj) GTK_CHECK_TYPE (obj, gtk_mdi_get_type ()) | 189 #define GTK_IS_MDI(obj) GTK_CHECK_TYPE (obj, gtk_mdi_get_type ()) |
190 | 190 |
191 typedef struct _GtkMdi GtkMdi; | 191 typedef struct _GtkMdi GtkMdi; |
1425 | 1425 |
1426 if(widget && GTK_IS_TREE_VIEW(widget)) | 1426 if(widget && GTK_IS_TREE_VIEW(widget)) |
1427 { | 1427 { |
1428 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | 1428 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); |
1429 GtkTreeIter iter; | 1429 GtkTreeIter iter; |
1430 | 1430 |
1431 if(sel && gtk_tree_selection_get_selected(sel, NULL, &iter)) | 1431 if(sel && gtk_tree_selection_get_selected(sel, NULL, &iter)) |
1432 { | 1432 { |
1433 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); | 1433 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); |
1434 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, -1); | 1434 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, -1); |
1435 } | 1435 } |
1586 int _get_logical_page(HWND handle, unsigned long pageid) | 1586 int _get_logical_page(HWND handle, unsigned long pageid) |
1587 { | 1587 { |
1588 int z; | 1588 int z; |
1589 GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); | 1589 GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); |
1590 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); | 1590 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); |
1591 | 1591 |
1592 if(pagearray && thispage) | 1592 if(pagearray && thispage) |
1593 { | 1593 { |
1594 for(z=0;z<256;z++) | 1594 for(z=0;z<256;z++) |
1595 { | 1595 { |
1596 if(thispage == pagearray[z]) | 1596 if(thispage == pagearray[z]) |
1745 | 1745 |
1746 if(userwidth) | 1746 if(userwidth) |
1747 *userwidth = gdk_pixbuf_get_width(icon_pixbuf); | 1747 *userwidth = gdk_pixbuf_get_width(icon_pixbuf); |
1748 if(userheight) | 1748 if(userheight) |
1749 *userheight = gdk_pixbuf_get_height(icon_pixbuf); | 1749 *userheight = gdk_pixbuf_get_height(icon_pixbuf); |
1750 | 1750 |
1751 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, bitmap, 1); | 1751 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, bitmap, 1); |
1752 g_object_unref(icon_pixbuf); | 1752 g_object_unref(icon_pixbuf); |
1753 #elif defined(USE_IMLIB) | 1753 #elif defined(USE_IMLIB) |
1754 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); | 1754 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); |
1755 #else | 1755 #else |
1799 sizehints.base_height = 1; | 1799 sizehints.base_height = 1; |
1800 sizehints.width_inc = 1; | 1800 sizehints.width_inc = 1; |
1801 sizehints.height_inc = 1; | 1801 sizehints.height_inc = 1; |
1802 sizehints.min_width = 8; | 1802 sizehints.min_width = 8; |
1803 sizehints.min_height = 8; | 1803 sizehints.min_height = 8; |
1804 | 1804 |
1805 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | 1805 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); |
1806 | 1806 |
1807 XSetWMNormalHints (GDK_DISPLAY(), | 1807 XSetWMNormalHints (GDK_DISPLAY(), |
1808 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | 1808 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), |
1809 &sizehints); | 1809 &sizehints); |
1810 gdk_flush (); | 1810 gdk_flush (); |
1811 } | 1811 } |
2483 gtk_widget_set_style(handle, style); | 2483 gtk_widget_set_style(handle, style); |
2484 retval = TRUE; | 2484 retval = TRUE; |
2485 } | 2485 } |
2486 #else | 2486 #else |
2487 PangoFontDescription *font = pango_font_description_from_string(fontname); | 2487 PangoFontDescription *font = pango_font_description_from_string(fontname); |
2488 | 2488 |
2489 if(font) | 2489 if(font) |
2490 { | 2490 { |
2491 gtk_widget_modify_font(handle, font); | 2491 gtk_widget_modify_font(handle, font); |
2492 pango_font_description_free(font); | 2492 pango_font_description_free(font); |
2493 } | 2493 } |
3353 gtk_tree_view_column_add_attribute(col, rend, "text", 0); | 3353 gtk_tree_view_column_add_attribute(col, rend, "text", 0); |
3354 | 3354 |
3355 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col); | 3355 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col); |
3356 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col); | 3356 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col); |
3357 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); | 3357 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); |
3358 | 3358 |
3359 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | 3359 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
3360 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); | 3360 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); |
3361 #else | 3361 #else |
3362 tree = gtk_tree_new(); | 3362 tree = gtk_tree_new(); |
3363 #endif | 3363 #endif |
3450 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tmpbox), GTK_SHADOW_ETCHED_IN); | 3450 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tmpbox), GTK_SHADOW_ETCHED_IN); |
3451 tmp = gtk_text_view_new(); | 3451 tmp = gtk_text_view_new(); |
3452 gtk_container_add (GTK_CONTAINER(tmpbox), tmp); | 3452 gtk_container_add (GTK_CONTAINER(tmpbox), tmp); |
3453 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE); | 3453 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE); |
3454 | 3454 |
3455 scroller = NULL; | 3455 scroller = NULL; |
3456 #else | 3456 #else |
3457 tmpbox = gtk_hbox_new(FALSE, 0); | 3457 tmpbox = gtk_hbox_new(FALSE, 0); |
3458 tmp = gtk_text_new(NULL, NULL); | 3458 tmp = gtk_text_new(NULL, NULL); |
3459 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | 3459 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); |
3460 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | 3460 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); |
4077 if(tmp && GTK_IS_TEXT_VIEW(tmp)) | 4077 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
4078 { | 4078 { |
4079 char *impbuf = malloc(strlen(buffer)+1); | 4079 char *impbuf = malloc(strlen(buffer)+1); |
4080 GtkTextBuffer *tbuffer; | 4080 GtkTextBuffer *tbuffer; |
4081 GtkTextIter iter; | 4081 GtkTextIter iter; |
4082 | 4082 |
4083 _strip_cr(impbuf, buffer); | 4083 _strip_cr(impbuf, buffer); |
4084 | 4084 |
4085 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); | 4085 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
4086 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint); | 4086 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint); |
4087 gtk_text_buffer_place_cursor(tbuffer, &iter); | 4087 gtk_text_buffer_place_cursor(tbuffer, &iter); |
4089 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(impbuf); | 4089 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(impbuf); |
4090 free(impbuf); | 4090 free(impbuf); |
4091 } | 4091 } |
4092 #else | 4092 #else |
4093 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_gdkfont"); | 4093 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_gdkfont"); |
4094 | 4094 |
4095 if(tmp && GTK_IS_TEXT(tmp)) | 4095 if(tmp && GTK_IS_TEXT(tmp)) |
4096 { | 4096 { |
4097 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk"); | 4097 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk"); |
4098 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_backgdk"); | 4098 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_backgdk"); |
4099 char *impbuf = malloc(strlen(buffer)+1); | 4099 char *impbuf = malloc(strlen(buffer)+1); |
4191 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | 4191 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
4192 | 4192 |
4193 if(tmp && GTK_IS_TEXT_VIEW(tmp)) | 4193 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
4194 { | 4194 { |
4195 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); | 4195 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); |
4196 | 4196 |
4197 if(bytes) | 4197 if(bytes) |
4198 *bytes = gtk_text_buffer_get_char_count(buffer) + 1; | 4198 *bytes = gtk_text_buffer_get_char_count(buffer) + 1; |
4199 if(lines) | 4199 if(lines) |
4200 *lines = gtk_text_buffer_get_line_count(buffer) + 1; | 4200 *lines = gtk_text_buffer_get_line_count(buffer) + 1; |
4201 } | 4201 } |
4292 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | 4292 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
4293 | 4293 |
4294 if(tmp && GTK_IS_TEXT_VIEW(tmp)) | 4294 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
4295 { | 4295 { |
4296 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); | 4296 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); |
4297 | 4297 |
4298 length = -1; | 4298 length = -1; |
4299 gtk_text_buffer_set_text(buffer, "", length); | 4299 gtk_text_buffer_set_text(buffer, "", length); |
4300 } | 4300 } |
4301 } | 4301 } |
4302 #else | 4302 #else |
4532 GtkTextIter iter, found; | 4532 GtkTextIter iter, found; |
4533 | 4533 |
4534 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); | 4534 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
4535 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); | 4535 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); |
4536 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL); | 4536 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL); |
4537 retval = gtk_text_iter_get_offset(&found); | 4537 retval = gtk_text_iter_get_offset(&found); |
4538 } | 4538 } |
4539 #else | 4539 #else |
4540 if(tmp && GTK_IS_TEXT(tmp)) | 4540 if(tmp && GTK_IS_TEXT(tmp)) |
4541 { | 4541 { |
4542 int len = gtk_text_get_length(GTK_TEXT(tmp)); | 4542 int len = gtk_text_get_length(GTK_TEXT(tmp)); |
4894 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) | 4894 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
4895 && GTK_IS_TREE_VIEW(tree) && | 4895 && GTK_IS_TREE_VIEW(tree) && |
4896 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) | 4896 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
4897 { | 4897 { |
4898 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); | 4898 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); |
4899 | 4899 |
4900 pixbuf = _find_pixbuf(icon); | 4900 pixbuf = _find_pixbuf(icon); |
4901 | 4901 |
4902 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); | 4902 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); |
4903 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); | 4903 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); |
4904 if(pixbuf && !(icon & (1 << 31))) | 4904 if(pixbuf && !(icon & (1 << 31))) |
4905 g_object_unref(pixbuf); | 4905 g_object_unref(pixbuf); |
4906 retval = (HTREEITEM)iter; | 4906 retval = (HTREEITEM)iter; |
4907 } | 4907 } |
4908 DW_MUTEX_UNLOCK; | 4908 DW_MUTEX_UNLOCK; |
4909 | 4909 |
4910 return retval; | 4910 return retval; |
4911 #else | 4911 #else |
4912 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; | 4912 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
4913 GdkPixmap *gdkpix; | 4913 GdkPixmap *gdkpix; |
4914 GdkBitmap *gdkbmp = NULL; | 4914 GdkBitmap *gdkbmp = NULL; |
5047 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) | 5047 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
5048 && GTK_IS_TREE_VIEW(tree) && | 5048 && GTK_IS_TREE_VIEW(tree) && |
5049 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) | 5049 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
5050 { | 5050 { |
5051 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); | 5051 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); |
5052 | 5052 |
5053 pixbuf = _find_pixbuf(icon); | 5053 pixbuf = _find_pixbuf(icon); |
5054 | 5054 |
5055 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); | 5055 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); |
5056 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); | 5056 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); |
5057 if(pixbuf && !(icon & (1 << 31))) | 5057 if(pixbuf && !(icon & (1 << 31))) |
5393 | 5393 |
5394 DW_MUTEX_LOCK; | 5394 DW_MUTEX_LOCK; |
5395 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) | 5395 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
5396 && GTK_IS_TREE_VIEW(tree) && | 5396 && GTK_IS_TREE_VIEW(tree) && |
5397 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) | 5397 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
5398 { | 5398 { |
5399 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item); | 5399 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item); |
5400 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | 5400 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
5401 | 5401 |
5402 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE); | 5402 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE); |
5403 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item); | 5403 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item); |
5404 gtk_tree_path_free(path); | 5404 gtk_tree_path_free(path); |
5405 } | 5405 } |
5406 DW_MUTEX_UNLOCK; | 5406 DW_MUTEX_UNLOCK; |
5425 #if GTK_MAJOR_VERSION > 1 | 5425 #if GTK_MAJOR_VERSION > 1 |
5426 static void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent) | 5426 static void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent) |
5427 { | 5427 { |
5428 void *data; | 5428 void *data; |
5429 GtkTreeIter iter; | 5429 GtkTreeIter iter; |
5430 | 5430 |
5431 gtk_tree_model_get(store, &parent, 3, &data, -1); | 5431 gtk_tree_model_get(store, &parent, 3, &data, -1); |
5432 if(data) | 5432 if(data) |
5433 free(data); | 5433 free(data); |
5434 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1); | 5434 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1); |
5435 | 5435 |
5448 * handle: Handle to the window (widget) to be cleared. | 5448 * handle: Handle to the window (widget) to be cleared. |
5449 */ | 5449 */ |
5450 void dw_tree_clear(HWND handle) | 5450 void dw_tree_clear(HWND handle) |
5451 { | 5451 { |
5452 #if GTK_MAJOR_VERSION > 1 | 5452 #if GTK_MAJOR_VERSION > 1 |
5453 GtkWidget *tree; | 5453 GtkWidget *tree; |
5454 GtkTreeStore *store; | 5454 GtkTreeStore *store; |
5455 int _locked_by_me = FALSE; | 5455 int _locked_by_me = FALSE; |
5456 | 5456 |
5457 if(!handle) | 5457 if(!handle) |
5458 return; | 5458 return; |
6621 else | 6621 else |
6622 _transparent[index] = 0; | 6622 _transparent[index] = 0; |
6623 | 6623 |
6624 _background[index] = color; | 6624 _background[index] = color; |
6625 DW_MUTEX_UNLOCK; | 6625 DW_MUTEX_UNLOCK; |
6626 } | |
6627 | |
6628 /* Internal function to handle the color OK press */ | |
6629 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait) | |
6630 { | |
6631 GdkColor color; | |
6632 unsigned long dw_color; | |
6633 GtkColorSelection *colorsel; | |
6634 | |
6635 if(!dwwait) | |
6636 return FALSE; | |
6637 | |
6638 colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dwwait->data)->colorsel); | |
6639 gtk_color_selection_get_current_color(colorsel,&color); | |
6640 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); | |
6641 _dw_color_active = 0; | |
6642 dw_color = DW_RGB( (color.red & 0xFF), (color.green & 0xFF), (color.blue & 0xFF)); | |
6643 dw_dialog_dismiss(dwwait, (void *)dw_color); | |
6644 return FALSE; | |
6645 } | |
6646 | |
6647 /* Internal function to handle the color Cancel press */ | |
6648 static gint _gtk_color_cancel(GtkWidget *widget, DWDialog *dwwait) | |
6649 { | |
6650 if(!dwwait) | |
6651 return FALSE; | |
6652 | |
6653 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); | |
6654 _dw_color_active = 0; | |
6655 dw_dialog_dismiss(dwwait, (void *)-1); | |
6656 return FALSE; | |
6657 } | |
6658 | |
6659 /* Allows the user to choose a color using the system's color chooser dialog. | |
6660 * Parameters: | |
6661 * value: current color | |
6662 * Returns: | |
6663 * The selected color or the current color if cancelled. | |
6664 */ | |
6665 unsigned long API dw_color_choose(unsigned long value) | |
6666 { | |
6667 GtkWidget *colorw; | |
6668 int _locked_by_me = FALSE; | |
6669 DWDialog *dwwait; | |
6670 GtkColorSelection *colorsel; | |
6671 GdkColor color = _internal_color(value); | |
6672 unsigned long dw_color; | |
6673 | |
6674 DW_MUTEX_LOCK; | |
6675 | |
6676 /* The DW mutex should be sufficient for | |
6677 * insuring no thread changes this unknowingly. | |
6678 */ | |
6679 if(_dw_color_active) | |
6680 { | |
6681 DW_MUTEX_UNLOCK; | |
6682 return value; | |
6683 } | |
6684 | |
6685 _dw_color_active = 1; | |
6686 | |
6687 colorw = gtk_color_selection_dialog_new("Select Color"); | |
6688 | |
6689 dwwait = dw_dialog_new((void *)colorw); | |
6690 | |
6691 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colorw)->ok_button), "clicked", (GtkSignalFunc) _gtk_color_ok, dwwait); | |
6692 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colorw)->cancel_button), "clicked", (GtkSignalFunc) _gtk_color_cancel, dwwait); | |
6693 | |
6694 colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorw)->colorsel); | |
6695 gtk_color_selection_set_previous_color(colorsel,&color); | |
6696 gtk_color_selection_set_current_color(colorsel,&color); | |
6697 gtk_color_selection_set_has_palette(colorsel,TRUE); | |
6698 | |
6699 gtk_widget_show(colorw); | |
6700 | |
6701 dw_color = (unsigned long)dw_dialog_wait(dwwait); | |
6702 if ((unsigned long)dw_color == -1) | |
6703 dw_color = value; | |
6704 DW_MUTEX_UNLOCK; | |
6705 return (unsigned long)dw_color; | |
6706 /* | |
6707 dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported."); | |
6708 return value; | |
6709 */ | |
6626 } | 6710 } |
6627 | 6711 |
6628 GdkGC *_set_colors(GdkWindow *window) | 6712 GdkGC *_set_colors(GdkWindow *window) |
6629 { | 6713 { |
6630 GdkGC *gc = NULL; | 6714 GdkGC *gc = NULL; |
8270 | 8354 |
8271 DW_MUTEX_LOCK; | 8355 DW_MUTEX_LOCK; |
8272 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); | 8356 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); |
8273 | 8357 |
8274 if(pagearray) | 8358 if(pagearray) |
8275 { | 8359 { |
8276 for(z=0;z<256;z++) | 8360 for(z=0;z<256;z++) |
8277 { | 8361 { |
8278 if(!pagearray[z]) | 8362 if(!pagearray[z]) |
8279 { | 8363 { |
8280 char text[100]; | 8364 char text[100]; |
8290 return z; | 8374 return z; |
8291 } | 8375 } |
8292 } | 8376 } |
8293 } | 8377 } |
8294 DW_MUTEX_UNLOCK; | 8378 DW_MUTEX_UNLOCK; |
8295 | 8379 |
8296 /* Hopefully this won't happen. */ | 8380 /* Hopefully this won't happen. */ |
8297 return 256; | 8381 return 256; |
8298 } | 8382 } |
8299 | 8383 |
8300 /* Return the physical page id from the logical page id */ | 8384 /* Return the physical page id from the logical page id */ |
8312 if(thispage == pagearray[pageid]) | 8396 if(thispage == pagearray[pageid]) |
8313 return z; | 8397 return z; |
8314 } | 8398 } |
8315 } | 8399 } |
8316 } | 8400 } |
8317 return 256; | 8401 return 256; |
8318 } | 8402 } |
8319 | 8403 |
8320 /* | 8404 /* |
8321 * Remove a page from a notebook. | 8405 * Remove a page from a notebook. |
8322 * Parameters: | 8406 * Parameters: |
8329 GtkWidget **pagearray; | 8413 GtkWidget **pagearray; |
8330 | 8414 |
8331 DW_MUTEX_LOCK; | 8415 DW_MUTEX_LOCK; |
8332 realpage = _get_physical_page(handle, pageid); | 8416 realpage = _get_physical_page(handle, pageid); |
8333 if(realpage > -1 && realpage < 256) | 8417 if(realpage > -1 && realpage < 256) |
8334 { | 8418 { |
8335 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage); | 8419 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage); |
8336 if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"))) | 8420 if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"))) |
8337 pagearray[pageid] = NULL; | 8421 pagearray[pageid] = NULL; |
8338 } | 8422 } |
8339 DW_MUTEX_UNLOCK; | 8423 DW_MUTEX_UNLOCK; |
8390 realpage = _get_physical_page(handle, pageid); | 8474 realpage = _get_physical_page(handle, pageid); |
8391 if(realpage < 0 || realpage > 255) | 8475 if(realpage < 0 || realpage > 255) |
8392 { | 8476 { |
8393 char ptext[100]; | 8477 char ptext[100]; |
8394 int num; | 8478 int num; |
8395 | 8479 |
8396 sprintf(ptext, "_dw_page%d", (int)pageid); | 8480 sprintf(ptext, "_dw_page%d", (int)pageid); |
8397 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); | 8481 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); |
8398 realpage = 0xFF & num; | 8482 realpage = 0xFF & num; |
8399 } | 8483 } |
8400 | 8484 |
8401 if(realpage > -1 && realpage < 256) | 8485 if(realpage > -1 && realpage < 256) |
8402 { | 8486 { |
8403 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage); | 8487 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage); |
8404 if(child) | 8488 if(child) |
8405 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); | 8489 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); |
8406 } | 8490 } |
8407 DW_MUTEX_UNLOCK; | 8491 DW_MUTEX_UNLOCK; |
8460 realpage = z; | 8544 realpage = z; |
8461 break; | 8545 break; |
8462 } | 8546 } |
8463 } | 8547 } |
8464 } | 8548 } |
8465 | 8549 |
8466 pagearray[pageid] = page; | 8550 pagearray[pageid] = page; |
8467 | 8551 |
8468 label = gtk_label_new(text ? text : ""); | 8552 label = gtk_label_new(text ? text : ""); |
8469 | 8553 |
8470 if(GTK_IS_TABLE(page)) | 8554 if(GTK_IS_TABLE(page)) |
8992 { | 9076 { |
8993 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); | 9077 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); |
8994 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); | 9078 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); |
8995 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); | 9079 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); |
8996 | 9080 |
8997 /* Prevent infinite recursion ;) */ | 9081 /* Prevent infinite recursion ;) */ |
8998 if(!percent || (lastwidth == event->width && lastheight == event->height)) | 9082 if(!percent || (lastwidth == event->width && lastheight == event->height)) |
8999 return FALSE; | 9083 return FALSE; |
9000 | 9084 |
9001 lastwidth = event->width; lastheight = event->height; | 9085 lastwidth = event->width; lastheight = event->height; |
9002 | 9086 |
9003 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); | 9087 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); |
9004 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); | 9088 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); |
9005 | 9089 |
9006 if(GTK_IS_HPANED(widget)) | 9090 if(GTK_IS_HPANED(widget)) |
9007 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); | 9091 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); |
9044 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) | 9128 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) |
9045 { | 9129 { |
9046 GtkWidget *tmp = NULL; | 9130 GtkWidget *tmp = NULL; |
9047 int _locked_by_me = FALSE; | 9131 int _locked_by_me = FALSE; |
9048 float *percent = malloc(sizeof(float)); | 9132 float *percent = malloc(sizeof(float)); |
9049 | 9133 |
9050 DW_MUTEX_LOCK; | 9134 DW_MUTEX_LOCK; |
9051 if(type == DW_HORZ) | 9135 if(type == DW_HORZ) |
9052 tmp = gtk_hpaned_new(); | 9136 tmp = gtk_hpaned_new(); |
9053 else | 9137 else |
9054 tmp = gtk_vpaned_new(); | 9138 tmp = gtk_vpaned_new(); |
9086 | 9170 |
9087 if(mypercent) | 9171 if(mypercent) |
9088 *mypercent = percent; | 9172 *mypercent = percent; |
9089 | 9173 |
9090 if(size > 10) | 9174 if(size > 10) |
9091 { | 9175 { |
9092 position = (int)((float)size * (percent / 100.0)); | 9176 position = (int)((float)size * (percent / 100.0)); |
9093 | 9177 |
9094 gtk_paned_set_position(GTK_PANED(handle), position); | 9178 gtk_paned_set_position(GTK_PANED(handle), position); |
9095 } | 9179 } |
9096 } | 9180 } |
9508 * ext: Default file extention. | 9592 * ext: Default file extention. |
9509 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN | 9593 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN |
9510 * Returns: | 9594 * Returns: |
9511 * NULL on error. A malloced buffer containing | 9595 * NULL on error. A malloced buffer containing |
9512 * the file path on success. | 9596 * the file path on success. |
9513 * | 9597 * |
9514 */ | 9598 */ |
9515 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | 9599 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) |
9516 { | 9600 { |
9517 GtkWidget *filew; | 9601 GtkWidget *filew; |
9518 int _locked_by_me = FALSE; | 9602 int _locked_by_me = FALSE; |
10052 if(sh.data == data) | 10136 if(sh.data == data) |
10053 _remove_signal_handler(thiswindow, z); | 10137 _remove_signal_handler(thiswindow, z); |
10054 } | 10138 } |
10055 DW_MUTEX_UNLOCK; | 10139 DW_MUTEX_UNLOCK; |
10056 } | 10140 } |
10057 |