Hello,
I have made a patch for comdlg32 on Mac OS X that replaces Wine's own color picker dialog with the native one. Bellow are the sources for colordlg.c, cocoa_colordlg.m and Makefile.in (without comments).
-------------------- colordlg.c --------------------
static BOOL ChooseColor_CocoaCommon(COLORREF *color, BOOL init);
BOOL WINAPI ChooseColorW( CHOOSECOLORW *lpChCol ) { if (!lpChCol) return FALSE; return ChooseColor_CocoaCommon(&lpChCol->rgbResult, lpChCol->Flags & CC_RGBINIT); }
BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol ) { if (!lpChCol) return FALSE; return ChooseColor_CocoaCommon(&lpChCol->rgbResult, lpChCol->Flags & CC_RGBINIT); }
struct RGBColor { unsigned short red; unsigned short green; unsigned short blue; };
int cocoa_run_color_dialog_modal(struct RGBColor *color);
static BOOL ChooseColor_CocoaCommon(COLORREF *color, BOOL init) { struct RGBColor rgb = { 0, 0, 0 }; if (init) { rgb.red = GetRValue(*color) * 257; rgb.green = GetGValue(*color) * 257; rgb.blue = GetBValue(*color) * 257; } BOOL ret = cocoa_run_color_dialog_modal(&rgb); if (ret) *color = RGB(rgb.red / 257, rgb.green / 257, rgb.blue / 257); return ret; }
-------------------- cocoa_colordlg.m --------------------
#import <AppKit/AppKit.h> #import <Carbon/Carbon.h>
int cocoa_run_color_dialog_modal(RGBColor *color) { __block int ret = 0;
void (^block)(void) = ^{ ret = GetColor((Point){ 0, 0 }, (const unsigned char *)"Color", color, color); };
if ([NSThread isMainThread]) block(); else dispatch_sync(dispatch_get_main_queue(), block);
return ret; }
-------------------- Makefile.in --------------------
MODULE = comdlg32.dll IMPORTLIB = comdlg32 IMPORTS = uuid shell32 shlwapi comctl32 winspool user32 gdi32 advapi32 DELAYIMPORTS = ole32 EXTRALIBS = -framework AppKit -framework Carbon
C_SRCS = \ cdlg32.c \ colordlg.c \ filedlg.c \ filedlg31.c \ filedlgbrowser.c \ finddlg.c \ fontdlg.c \ itemdlg.c \ printdlg.c
RC_SRCS = comdlg32.rc
SVG_SRCS = \ pd32_collate.svg \ pd32_landscape.svg \ pd32_nocollate.svg \ pd32_portrait.svg
OBJC_SRCS = \ cocoa_colordlg.m
IDL_R_SRCS = comdlg32_classes.idl
@MAKE_DLL_RULES@
------------------------------------------------------------
Any comments are welcome.