]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/colordlg.cpp
implemented menu drawing in the GTK theme
[wxWidgets.git] / src / msw / colordlg.cpp
index 78a01e7dde036d1e6e0c0d903f85df44d70b1ab2..494928bb644bffb4a7693e49812fd9da1a875175 100644 (file)
@@ -1,43 +1,51 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        colordlg.cpp
+// Name:        src/msw/colordlg.cpp
 // Purpose:     wxColourDialog class
 // Author:      Julian Smart
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
 // Purpose:     wxColourDialog class
 // Author:      Julian Smart
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////////////////////////
 
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
 #ifdef __GNUG__
 #ifdef __GNUG__
-#pragma implementation "colordlg.h"
+    #pragma implementation "colordlg.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
 #endif
 
 #ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/defs.h"
-#include "wx/bitmap.h"
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/colour.h"
-#include "wx/gdicmn.h"
-#include "wx/utils.h"
-#include "wx/frame.h"
-#include "wx/dialog.h"
-#include "wx/msgdlg.h"
+    #include <stdio.h>
+    #include "wx/defs.h"
+    #include "wx/bitmap.h"
+    #include "wx/pen.h"
+    #include "wx/brush.h"
+    #include "wx/colour.h"
+    #include "wx/gdicmn.h"
+    #include "wx/utils.h"
+    #include "wx/frame.h"
+    #include "wx/dialog.h"
+    #include "wx/msgdlg.h"
 #endif
 
 #include <windows.h>
 
 #endif
 
 #include <windows.h>
 
-#if !defined(__WIN32__) || defined(__SALFORDC__)
-#include <commdlg.h>
+#if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
+    #include <commdlg.h>
 #endif
 
 #include "wx/msw/private.h"
 #endif
 
 #include "wx/msw/private.h"
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#define wxDIALOG_DEFAULT_X 300
-#define wxDIALOG_DEFAULT_Y 300
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
 
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
-#endif
 
 
-/*
- * wxColourDialog
- */
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// colour dialog hook proc
+// ----------------------------------------------------------------------------
+
+UINT CALLBACK wxColourDialogHookProc(HWND hwnd,
+                                     UINT uiMsg,
+                                     WPARAM WXUNUSED(wParam),
+                                     LPARAM lParam)
+{
+    if ( uiMsg == WM_INITDIALOG )
+    {
+        CHOOSECOLOR *pCC = (CHOOSECOLOR *)lParam;
+        wxColourDialog *dialog = (wxColourDialog *)pCC->lCustData;
+
+        ::SetWindowText(hwnd, dialog->GetTitle());
+    }
+
+    return 0;
+}
 
 
-wxColourDialog::wxColourDialog(void)
+// ----------------------------------------------------------------------------
+// wxColourDialog
+// ----------------------------------------------------------------------------
+
+wxColourDialog::wxColourDialog()
 {
 {
-  m_dialogParent = NULL;
 }
 
 wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
 {
 }
 
 wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
 {
-  Create(parent, data);
+    Create(parent, data);
 }
 
 bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
 {
 }
 
 bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
 {
-  m_dialogParent = parent;
+    m_parent = parent;
+    if (data)
+        m_colourData = *data;
 
 
-  if (data)
-    m_colourData = *data;
-  return TRUE;
+    return TRUE;
 }
 
 }
 
-int wxColourDialog::ShowModal(void)
+int wxColourDialog::ShowModal()
 {
     CHOOSECOLOR chooseColorStruct;
     COLORREF custColours[16];
 {
     CHOOSECOLOR chooseColorStruct;
     COLORREF custColours[16];
@@ -86,20 +116,23 @@ int wxColourDialog::ShowModal(void)
 
     int i;
     for (i = 0; i < 16; i++)
 
     int i;
     for (i = 0; i < 16; i++)
-      custColours[i] = RGB(m_colourData.custColours[i].Red(), m_colourData.custColours[i].Green(), m_colourData.custColours[i].Blue());
+      custColours[i] = wxColourToRGB(m_colourData.custColours[i]);
 
     chooseColorStruct.lStructSize = sizeof(CHOOSECOLOR);
 
     chooseColorStruct.lStructSize = sizeof(CHOOSECOLOR);
-    chooseColorStruct.hwndOwner = (HWND) (m_dialogParent ? (HWND) m_dialogParent->GetHWND() : (HWND) NULL);
-    chooseColorStruct.rgbResult = RGB(m_colourData.dataColour.Red(), m_colourData.dataColour.Green(), m_colourData.dataColour.Blue());
+    if ( m_parent )
+        chooseColorStruct.hwndOwner = GetHwndOf(m_parent);
+    chooseColorStruct.rgbResult = wxColourToRGB(m_colourData.dataColour);
     chooseColorStruct.lpCustColors = custColours;
 
     chooseColorStruct.lpCustColors = custColours;
 
-    chooseColorStruct.Flags = CC_RGBINIT;
+    chooseColorStruct.Flags = CC_RGBINIT | CC_ENABLEHOOK;
+    chooseColorStruct.lCustData = (LPARAM)this;
+    chooseColorStruct.lpfnHook = wxColourDialogHookProc;
 
 
-    if (!m_colourData.GetChooseFull())
-      chooseColorStruct.Flags |= CC_PREVENTFULLOPEN;
+    if (m_colourData.GetChooseFull())
+        chooseColorStruct.Flags |= CC_FULLOPEN;
 
     // Do the modal dialog
 
     // Do the modal dialog
-    bool success = (ChooseColor(&(chooseColorStruct)) != 0);
+    bool success = ::ChooseColor(&(chooseColorStruct)) != 0;
 
     // Try to highlight the correct window (the parent)
     HWND hWndParent = 0;
 
     // Try to highlight the correct window (the parent)
     HWND hWndParent = 0;
@@ -114,13 +147,56 @@ int wxColourDialog::ShowModal(void)
     // Restore values
     for (i = 0; i < 16; i++)
     {
     // Restore values
     for (i = 0; i < 16; i++)
     {
-      m_colourData.custColours[i].Set(GetRValue(custColours[i]), GetGValue(custColours[i]),
-         GetBValue(custColours[i]));
+      wxRGBToColour(m_colourData.custColours[i], custColours[i]);
     }
 
     }
 
-    m_colourData.dataColour.Set(GetRValue(chooseColorStruct.rgbResult), GetGValue(chooseColorStruct.rgbResult),
-     GetBValue(chooseColorStruct.rgbResult));
+    wxRGBToColour(m_colourData.dataColour, chooseColorStruct.rgbResult);
 
     return success ? wxID_OK : wxID_CANCEL;
 }
 
 
     return success ? wxID_OK : wxID_CANCEL;
 }
 
+// ----------------------------------------------------------------------------
+// title
+// ----------------------------------------------------------------------------
+
+void wxColourDialog::SetTitle(const wxString& title)
+{
+    m_title = title;
+}
+
+wxString wxColourDialog::GetTitle()
+{
+    return m_title;
+}
+
+// ----------------------------------------------------------------------------
+// position/size
+// ----------------------------------------------------------------------------
+
+void wxColourDialog::DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
+                               int WXUNUSED(width), int WXUNUSED(height),
+                               int WXUNUSED(sizeFlags))
+{
+    // ignore - we can't change the size of this standard dialog
+    return;
+}
+
+// NB: of course, both of these functions are completely bogus, but it's better
+//     than nothing
+void wxColourDialog::DoGetSize(int *width, int *height) const
+{
+    // the standard dialog size
+    if ( width )
+        *width = 225;
+    if ( height )
+        *height = 324;
+}
+
+void wxColourDialog::DoGetClientSize(int *width, int *height) const
+{
+    // the standard dialog size
+    if ( width )
+        *width = 219;
+    if ( height )
+        *height = 299;
+}