# HG changeset patch # User mhessling@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1087471334 0 # Node ID f6de197ecbe96e8b7ea64da85439a9eca6297054 # Parent 355a6d46adb1143db31d8b060af8e91df1b532b5 Add dw_color_choose() diff -r 355a6d46adb1 -r f6de197ecbe9 Makefile.in --- a/Makefile.in Sat May 08 06:53:12 2004 +0000 +++ b/Makefile.in Thu Jun 17 11:22:14 2004 +0000 @@ -124,8 +124,8 @@ dwtest: dwtest.o $(CC) -o dwtest dwtest.o -L$(PREFIX)/lib -ldw -ldwcompat $(LFLAGS) - chmod +x mac/finishup.sh - mac/finishup.sh + -chmod +x mac/finishup.sh + -mac/finishup.sh zip: zip dwindows$(VER_MAJ)$(VER_MIN).zip $(srcdir)/license.txt $(srcdir)/makefile.* $(srcdir)/readme $(srcdir)/*.c $(srcdir)/dw.h $(srcdir)/compat.h \ diff -r 355a6d46adb1 -r f6de197ecbe9 dw.def --- a/dw.def Sat May 08 06:53:12 2004 +0000 +++ b/dw.def Thu Jun 17 11:22:14 2004 +0000 @@ -151,6 +151,7 @@ dw_color_depth_get @260 dw_color_foreground_set @261 dw_color_background_set @262 + dw_color_choose @263 dw_notebook_new @270 dw_notebook_page_new @271 @@ -206,7 +207,7 @@ dw_signal_disconnect_by_window @361 dw_signal_disconnect_by_data @362 dw_signal_disconnect_by_name @363 - + dw_timer_connect @365 dw_timer_disconnect @366 @@ -248,7 +249,7 @@ dw_taskbar_insert @440 dw_taskbar_delete @441 - + dw_named_memory_new @450 dw_named_memory_get @451 dw_named_memory_free @452 diff -r 355a6d46adb1 -r f6de197ecbe9 dw.h --- a/dw.h Sat May 08 06:53:12 2004 +0000 +++ b/dw.h Thu Jun 17 11:22:14 2004 +0000 @@ -1074,6 +1074,7 @@ HWND API dw_render_new(unsigned long id); void API dw_color_foreground_set(unsigned long value); void API dw_color_background_set(unsigned long value); +unsigned long API dw_color_choose(unsigned long value); void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y); void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2); void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height); diff -r 355a6d46adb1 -r f6de197ecbe9 dwtest.c --- a/dwtest.c Sat May 08 06:53:12 2004 +0000 +++ b/dwtest.c Thu Jun 17 11:22:14 2004 +0000 @@ -27,6 +27,8 @@ unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; +unsigned long current_color = DW_CLR_GREEN; + void create_button( int); #ifdef __MAC__ @@ -52,6 +54,7 @@ HWND mainwindow, entryfield, cursortogglebutton, + colorchoosebutton, okbutton, cancelbutton, lbbox, @@ -281,8 +284,16 @@ } } + +int DWSIGNAL colorchoose_callback(HWND window, void *data) +{ + current_color = dw_color_choose(current_color); + return FALSE; +} + int DWSIGNAL cursortoggle_callback(HWND window, void *data) { + if(cursor_arrow) { dw_window_set_text((HWND)cursortogglebutton,"Set Cursor pointer - ARROW"); @@ -556,15 +567,15 @@ dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); cursortogglebutton = dw_button_new("Set Cursor pointer - CLOCK", 1003L); - dw_box_pack_start(buttonbox, cursortogglebutton, 130, 30, TRUE, TRUE, 2); + colorchoosebutton = dw_button_new("Color Chooser Dialog", 1004L); + dw_box_pack_start(buttonbox, colorchoosebutton, 130, 30, TRUE, TRUE, 2); + okbutton = dw_button_new("Turn Off Annoying Beep!", 1001L); - dw_box_pack_start(buttonbox, okbutton, 130, 30, TRUE, TRUE, 2); cancelbutton = dw_button_new("Exit", 1002L); - dw_box_pack_start(buttonbox, cancelbutton, 130, 30, TRUE, TRUE, 2); /* Set some nice fonts and colors */ @@ -576,6 +587,7 @@ dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1); dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); dw_signal_connect(cursortogglebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(cursortoggle_callback), (void *)mainwindow); + dw_signal_connect(colorchoosebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(colorchoose_callback), (void *)mainwindow); } @@ -771,11 +783,11 @@ buttonboxperm = dw_box_new( BOXVERT, 0 ); dw_box_pack_start( buttonsbox, buttonboxperm, 25, 0, FALSE, TRUE, 2 ); dw_window_set_color(buttonboxperm, DW_CLR_WHITE, DW_CLR_WHITE); - abutton1 = dw_bitmapbutton_new_from_file( "Top", 0, "junk" ); + abutton1 = dw_bitmapbutton_new_from_file( "Top", 0, FILE_ICON_NAME ); dw_box_pack_start( buttonboxperm, abutton1, 25, 25, FALSE, FALSE, 0 ); dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); dw_box_pack_start( buttonboxperm, 0, 25, 5, FALSE, FALSE, 0 ); - abutton2 = dw_bitmapbutton_new_from_file( "Bottom", 0, "junk" ); + abutton2 = dw_bitmapbutton_new_from_file( "Bottom", 0, FOLDER_ICON_NAME ); dw_box_pack_start( buttonsbox, abutton2, 25, 25, FALSE, FALSE, 0 ); dw_signal_connect( abutton2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL ); diff -r 355a6d46adb1 -r f6de197ecbe9 dww.def --- a/dww.def Sat May 08 06:53:12 2004 +0000 +++ b/dww.def Thu Jun 17 11:22:14 2004 +0000 @@ -20,7 +20,7 @@ dw_free @22 dw_main_sleep @23 dw_main_iteration @24 - + dw_box_new @40 dw_groupbox_new @41 dw_box_pack_start @42 @@ -145,9 +145,10 @@ dw_screen_width @250 dw_screen_height @251 - dw_color_depth_get @260 + dw_color_depth_get @260 dw_color_foreground_set @261 dw_color_background_set @262 + dw_color_choose @263 dw_notebook_new @270 dw_notebook_page_new @271 @@ -194,7 +195,7 @@ dw_pixmap_grab @342 dw_pixmap_destroy @343 dw_pixmap_new_from_file @344 - + dw_dialog_new @350 dw_dialog_dismiss @351 dw_dialog_wait @352 @@ -203,7 +204,7 @@ dw_signal_disconnect_by_window @361 dw_signal_disconnect_by_data @362 dw_signal_disconnect_by_name @363 - + dw_timer_connect @365 dw_timer_disconnect @366 @@ -245,7 +246,7 @@ dw_taskbar_insert @440 dw_taskbar_delete @441 - + dw_named_memory_new @450 dw_named_memory_get @451 dw_named_memory_free @452 diff -r 355a6d46adb1 -r f6de197ecbe9 gtk/dw.c --- a/gtk/dw.c Sat May 08 06:53:12 2004 +0000 +++ b/gtk/dw.c Thu Jun 17 11:22:14 2004 +0000 @@ -80,7 +80,7 @@ GtkWidget *last_window = NULL, *popup = NULL; -static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_ignore_expand = 0; +static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0; static pthread_t _dw_thread = (pthread_t)-1; static int _dw_mutex_locked[DW_THREAD_LIMIT]; /* Use default border size for the default enlightenment theme */ @@ -183,7 +183,7 @@ #define DW_RIGHT 1.0f /* MDI Support Code */ -#if GTK_MAJOR_VERSION > 1 +#if GTK_MAJOR_VERSION > 1 #define GTK_MDI(obj) GTK_CHECK_CAST (obj, gtk_mdi_get_type (), GtkMdi) #define GTK_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass) #define GTK_IS_MDI(obj) GTK_CHECK_TYPE (obj, gtk_mdi_get_type ()) @@ -1427,7 +1427,7 @@ { GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); GtkTreeIter iter; - + if(sel && gtk_tree_selection_get_selected(sel, NULL, &iter)) { GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); @@ -1588,7 +1588,7 @@ int z; GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); - + if(pagearray && thispage) { for(z=0;z<256;z++) @@ -1747,7 +1747,7 @@ *userwidth = gdk_pixbuf_get_width(icon_pixbuf); if(userheight) *userheight = gdk_pixbuf_get_height(icon_pixbuf); - + gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, bitmap, 1); g_object_unref(icon_pixbuf); #elif defined(USE_IMLIB) @@ -1801,9 +1801,9 @@ sizehints.height_inc = 1; sizehints.min_width = 8; sizehints.min_height = 8; - + sizehints.flags = (PBaseSize|PMinSize|PResizeInc); - + XSetWMNormalHints (GDK_DISPLAY(), GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), &sizehints); @@ -2485,7 +2485,7 @@ } #else PangoFontDescription *font = pango_font_description_from_string(fontname); - + if(font) { gtk_widget_modify_font(handle, font); @@ -3355,7 +3355,7 @@ gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col); gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); - + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); #else @@ -3452,7 +3452,7 @@ gtk_container_add (GTK_CONTAINER(tmpbox), tmp); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE); - scroller = NULL; + scroller = NULL; #else tmpbox = gtk_hbox_new(FALSE, 0); tmp = gtk_text_new(NULL, NULL); @@ -4079,7 +4079,7 @@ char *impbuf = malloc(strlen(buffer)+1); GtkTextBuffer *tbuffer; GtkTextIter iter; - + _strip_cr(impbuf, buffer); tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); @@ -4091,7 +4091,7 @@ } #else GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_gdkfont"); - + if(tmp && GTK_IS_TEXT(tmp)) { GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk"); @@ -4193,7 +4193,7 @@ if(tmp && GTK_IS_TEXT_VIEW(tmp)) { GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); - + if(bytes) *bytes = gtk_text_buffer_get_char_count(buffer) + 1; if(lines) @@ -4294,7 +4294,7 @@ if(tmp && GTK_IS_TEXT_VIEW(tmp)) { GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); - + length = -1; gtk_text_buffer_set_text(buffer, "", length); } @@ -4534,7 +4534,7 @@ tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL); - retval = gtk_text_iter_get_offset(&found); + retval = gtk_text_iter_get_offset(&found); } #else if(tmp && GTK_IS_TEXT(tmp)) @@ -4896,7 +4896,7 @@ (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) { iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); - + pixbuf = _find_pixbuf(icon); gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); @@ -4906,7 +4906,7 @@ retval = (HTREEITEM)iter; } DW_MUTEX_UNLOCK; - + return retval; #else GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; @@ -5049,7 +5049,7 @@ (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) { iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); - + pixbuf = _find_pixbuf(icon); gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); @@ -5395,10 +5395,10 @@ if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) && GTK_IS_TREE_VIEW(tree) && (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) - { + { GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item); GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); - + gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE); gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item); gtk_tree_path_free(path); @@ -5427,7 +5427,7 @@ { void *data; GtkTreeIter iter; - + gtk_tree_model_get(store, &parent, 3, &data, -1); if(data) free(data); @@ -5450,7 +5450,7 @@ void dw_tree_clear(HWND handle) { #if GTK_MAJOR_VERSION > 1 - GtkWidget *tree; + GtkWidget *tree; GtkTreeStore *store; int _locked_by_me = FALSE; @@ -6625,6 +6625,90 @@ DW_MUTEX_UNLOCK; } +/* Internal function to handle the color OK press */ +static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait) +{ + GdkColor color; + unsigned long dw_color; + GtkColorSelection *colorsel; + + if(!dwwait) + return FALSE; + + colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dwwait->data)->colorsel); + gtk_color_selection_get_current_color(colorsel,&color); + gtk_widget_destroy(GTK_WIDGET(dwwait->data)); + _dw_color_active = 0; + dw_color = DW_RGB( (color.red & 0xFF), (color.green & 0xFF), (color.blue & 0xFF)); + dw_dialog_dismiss(dwwait, (void *)dw_color); + return FALSE; +} + +/* Internal function to handle the color Cancel press */ +static gint _gtk_color_cancel(GtkWidget *widget, DWDialog *dwwait) +{ + if(!dwwait) + return FALSE; + + gtk_widget_destroy(GTK_WIDGET(dwwait->data)); + _dw_color_active = 0; + dw_dialog_dismiss(dwwait, (void *)-1); + return FALSE; +} + +/* Allows the user to choose a color using the system's color chooser dialog. + * Parameters: + * value: current color + * Returns: + * The selected color or the current color if cancelled. + */ +unsigned long API dw_color_choose(unsigned long value) +{ + GtkWidget *colorw; + int _locked_by_me = FALSE; + DWDialog *dwwait; + GtkColorSelection *colorsel; + GdkColor color = _internal_color(value); + unsigned long dw_color; + + DW_MUTEX_LOCK; + + /* The DW mutex should be sufficient for + * insuring no thread changes this unknowingly. + */ + if(_dw_color_active) + { + DW_MUTEX_UNLOCK; + return value; + } + + _dw_color_active = 1; + + colorw = gtk_color_selection_dialog_new("Select Color"); + + dwwait = dw_dialog_new((void *)colorw); + + gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colorw)->ok_button), "clicked", (GtkSignalFunc) _gtk_color_ok, dwwait); + gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colorw)->cancel_button), "clicked", (GtkSignalFunc) _gtk_color_cancel, dwwait); + + colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorw)->colorsel); + gtk_color_selection_set_previous_color(colorsel,&color); + gtk_color_selection_set_current_color(colorsel,&color); + gtk_color_selection_set_has_palette(colorsel,TRUE); + + gtk_widget_show(colorw); + + dw_color = (unsigned long)dw_dialog_wait(dwwait); + if ((unsigned long)dw_color == -1) + dw_color = value; + DW_MUTEX_UNLOCK; + return (unsigned long)dw_color; +/* + dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported."); + return value; +*/ +} + GdkGC *_set_colors(GdkWindow *window) { GdkGC *gc = NULL; @@ -8272,7 +8356,7 @@ pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); if(pagearray) - { + { for(z=0;z<256;z++) { if(!pagearray[z]) @@ -8292,7 +8376,7 @@ } } DW_MUTEX_UNLOCK; - + /* Hopefully this won't happen. */ return 256; } @@ -8314,7 +8398,7 @@ } } } - return 256; + return 256; } /* @@ -8331,7 +8415,7 @@ DW_MUTEX_LOCK; realpage = _get_physical_page(handle, pageid); if(realpage > -1 && realpage < 256) - { + { gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage); if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"))) pagearray[pageid] = NULL; @@ -8392,14 +8476,14 @@ { char ptext[100]; int num; - + sprintf(ptext, "_dw_page%d", (int)pageid); num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); realpage = 0xFF & num; } - + if(realpage > -1 && realpage < 256) - { + { child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage); if(child) gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); @@ -8462,7 +8546,7 @@ } } } - + pagearray[pageid] = page; label = gtk_label_new(text ? text : ""); @@ -8994,12 +9078,12 @@ int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); - /* Prevent infinite recursion ;) */ + /* Prevent infinite recursion ;) */ if(!percent || (lastwidth == event->width && lastheight == event->height)) return FALSE; lastwidth = event->width; lastheight = event->height; - + gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); @@ -9046,7 +9130,7 @@ GtkWidget *tmp = NULL; int _locked_by_me = FALSE; float *percent = malloc(sizeof(float)); - + DW_MUTEX_LOCK; if(type == DW_HORZ) tmp = gtk_hpaned_new(); @@ -9088,7 +9172,7 @@ *mypercent = percent; if(size > 10) - { + { position = (int)((float)size * (percent / 100.0)); gtk_paned_set_position(GTK_PANED(handle), position); @@ -9510,7 +9594,7 @@ * Returns: * NULL on error. A malloced buffer containing * the file path on success. - * + * */ char *dw_file_browse(char *title, char *defpath, char *ext, int flags) { @@ -10054,4 +10138,3 @@ } DW_MUTEX_UNLOCK; } - diff -r 355a6d46adb1 -r f6de197ecbe9 mac/dw.c --- a/mac/dw.c Sat May 08 06:53:12 2004 +0000 +++ b/mac/dw.c Thu Jun 17 11:22:14 2004 +0000 @@ -2472,6 +2472,18 @@ { } +/* Allows the user to choose a color using the system's color chooser dialog. + * Parameters: + * value: current color + * Returns: + * The selected color or the current color if cancelled. + */ +unsigned long API dw_color_choose(unsigned long value) +{ + dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported."); + return value; +} + /* Draw a point on a window (preferably a render window). * Parameters: * handle: Handle to the window. diff -r 355a6d46adb1 -r f6de197ecbe9 os2/dw.c --- a/os2/dw.c Sat May 08 06:53:12 2004 +0000 +++ b/os2/dw.c Thu Jun 17 11:22:14 2004 +0000 @@ -7241,6 +7241,18 @@ _background = value; } +/* Allows the user to choose a color using the system's color chooser dialog. + * Parameters: + * value: current color + * Returns: + * The selected color or the current color if cancelled. + */ +unsigned long API dw_color_choose(unsigned long value) +{ + dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported."); + return value; +} + HPS _set_hps(HPS hps) { LONG alTable[2]; @@ -8693,7 +8705,7 @@ * Returns: * NULL on error. A malloced buffer containing * the file path on success. - * + * */ char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) { diff -r 355a6d46adb1 -r f6de197ecbe9 win/dw.c --- a/win/dw.c Sat May 08 06:53:12 2004 +0000 +++ b/win/dw.c Thu Jun 17 11:22:14 2004 +0000 @@ -3636,7 +3636,7 @@ lf.lfClipPrecision = 0; lf.lfQuality = DEFAULT_QUALITY; lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE; - /* + /* * remove any font modifiers */ myFontName = strdup(&fontname[z+1]); @@ -3821,7 +3821,7 @@ * at the bottom seems to work, so I'll leave * it like this for now. */ -#if 0 +#if 0 if(hwndOwner) flStyleEx |= WS_EX_MDICHILD; #endif @@ -4325,7 +4325,7 @@ */ HWND API dw_mle_new(ULONG id) { - + HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, EDITCLASSNAME, "", @@ -5132,7 +5132,7 @@ { int bpp; HDC hdc = GetDC(HWND_DESKTOP); - + bpp = GetDeviceCaps(hdc, BITSPIXEL); ReleaseDC(HWND_DESKTOP, hdc); @@ -7174,7 +7174,7 @@ void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) { NOTIFYICONDATA tnid; - + tnid.cbSize = sizeof(NOTIFYICONDATA); tnid.hWnd = handle; tnid.uID = icon; @@ -7278,6 +7278,34 @@ _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); } +/* Allows the user to choose a color using the system's color chooser dialog. + * Parameters: + * value: current color + * Returns: + * The selected color or the current color if cancelled. + */ +unsigned long API dw_color_choose(unsigned long value) +{ + CHOOSECOLOR cc; + unsigned long newcolor; + COLORREF acrCustClr[16] = {0}; + + value = _internal_color(value); + if(value == DW_RGB_TRANSPARENT) + newcolor = DW_RGB_TRANSPARENT; + else + newcolor = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); + ZeroMemory(&cc, sizeof(CHOOSECOLOR)); + cc.lStructSize = sizeof(CHOOSECOLOR); + cc.rgbResult = newcolor; + cc.hwndOwner = HWND_DESKTOP; + cc.lpCustColors = (LPDWORD)acrCustClr; + cc.Flags = CC_FULLOPEN | CC_RGBINIT; + if (ChooseColor(&cc) == TRUE) + newcolor = DW_RGB(DW_RED_VALUE(cc.rgbResult), DW_GREEN_VALUE(cc.rgbResult), DW_BLUE_VALUE(cc.rgbResult)); + return newcolor; +} + /* Draw a point on a window (preferably a render window). * Parameters: * handle: Handle to the window. @@ -8345,7 +8373,7 @@ * Returns: * NULL on error. A malloced buffer containing * the file path on success. - * + * */ char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) {