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