]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/colordlg.cpp
make IsEnabled() return false even if the window parent, and not the window itself...
[wxWidgets.git] / src / msw / colordlg.cpp
index 8fc614cff74c147a1c6b6482fa58bf797cd8fb1f..66a70b0eb50d13a9d172cfc3057c201580d47913 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
+// Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
-    #pragma implementation "colordlg.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
     #pragma hdrstop
 #endif
 
+#if wxUSE_COLOURDLG && !(defined(__SMARTPHONE__) && defined(__WXWINCE__))
+
+#include "wx/colordlg.h"
+
 #ifndef WX_PRECOMP
+    #include "wx/msw/wrapcdlg.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>
-
-#if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
-    #include <commdlg.h>
+    #include "wx/cmndata.h"
+    #include "wx/math.h"
 #endif
 
 #include "wx/msw/private.h"
-#include "wx/colordlg.h"
-#include "wx/cmndata.h"
 
-#include <math.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -70,10 +58,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
 // colour dialog hook proc
 // ----------------------------------------------------------------------------
 
-UINT CALLBACK wxColourDialogHookProc(HWND hwnd,
-                                     UINT uiMsg,
-                                     WPARAM wParam,
-                                     LPARAM lParam)
+UINT_PTR CALLBACK
+wxColourDialogHookProc(HWND hwnd,
+                       UINT uiMsg,
+                       WPARAM WXUNUSED(wParam),
+                       LPARAM lParam)
 {
     if ( uiMsg == WM_INITDIALOG )
     {
@@ -81,6 +70,14 @@ UINT CALLBACK wxColourDialogHookProc(HWND hwnd,
         wxColourDialog *dialog = (wxColourDialog *)pCC->lCustData;
 
         ::SetWindowText(hwnd, dialog->GetTitle());
+
+        wxPoint pos = dialog->GetPosition();
+        if ( pos != wxDefaultPosition )
+        {
+            ::SetWindowPos(hwnd, NULL /* Z-order: ignored */,
+                           pos.x, pos.y, -1, -1,
+                           SWP_NOSIZE | SWP_NOZORDER);
+        }
     }
 
     return 0;
@@ -92,10 +89,13 @@ UINT CALLBACK wxColourDialogHookProc(HWND hwnd,
 
 wxColourDialog::wxColourDialog()
 {
+    m_pos = wxDefaultPosition;
 }
 
 wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
 {
+    m_pos = wxDefaultPosition;
+
     Create(parent, data);
 }
 
@@ -105,7 +105,7 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
     if (data)
         m_colourData = *data;
 
-    return TRUE;
+    return true;
 }
 
 int wxColourDialog::ShowModal()
@@ -116,12 +116,17 @@ int wxColourDialog::ShowModal()
 
     int i;
     for (i = 0; i < 16; i++)
-      custColours[i] = wxColourToRGB(m_colourData.custColours[i]);
+    {
+        if (m_colourData.m_custColours[i].Ok())
+            custColours[i] = wxColourToRGB(m_colourData.m_custColours[i]);
+        else
+            custColours[i] = RGB(255,255,255);
+    }
 
     chooseColorStruct.lStructSize = sizeof(CHOOSECOLOR);
     if ( m_parent )
         chooseColorStruct.hwndOwner = GetHwndOf(m_parent);
-    chooseColorStruct.rgbResult = wxColourToRGB(m_colourData.dataColour);
+    chooseColorStruct.rgbResult = wxColourToRGB(m_colourData.m_dataColour);
     chooseColorStruct.lpCustColors = custColours;
 
     chooseColorStruct.Flags = CC_RGBINIT | CC_ENABLEHOOK;
@@ -135,10 +140,9 @@ int wxColourDialog::ShowModal()
     bool success = ::ChooseColor(&(chooseColorStruct)) != 0;
 
     // Try to highlight the correct window (the parent)
-    HWND hWndParent = 0;
     if (GetParent())
     {
-      hWndParent = (HWND) GetParent()->GetHWND();
+      HWND hWndParent = (HWND) GetParent()->GetHWND();
       if (hWndParent)
         ::BringWindowToTop(hWndParent);
     }
@@ -147,10 +151,10 @@ int wxColourDialog::ShowModal()
     // Restore values
     for (i = 0; i < 16; i++)
     {
-      wxRGBToColour(m_colourData.custColours[i], custColours[i]);
+      wxRGBToColour(m_colourData.m_custColours[i], custColours[i]);
     }
 
-    wxRGBToColour(m_colourData.dataColour, chooseColorStruct.rgbResult);
+    wxRGBToColour(m_colourData.m_dataColour, chooseColorStruct.rgbResult);
 
     return success ? wxID_OK : wxID_CANCEL;
 }
@@ -164,7 +168,7 @@ void wxColourDialog::SetTitle(const wxString& title)
     m_title = title;
 }
 
-wxString wxColourDialog::GetTitle()
+wxString wxColourDialog::GetTitle() const
 {
     return m_title;
 }
@@ -173,11 +177,25 @@ wxString wxColourDialog::GetTitle()
 // position/size
 // ----------------------------------------------------------------------------
 
-void wxColourDialog::DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
+void wxColourDialog::DoGetPosition(int *x, int *y) const
+{
+    if ( x )
+        *x = m_pos.x;
+    if ( y )
+        *y = m_pos.y;
+}
+
+void wxColourDialog::DoSetSize(int x, int y,
                                int WXUNUSED(width), int WXUNUSED(height),
                                int WXUNUSED(sizeFlags))
 {
-    // ignore - we can't change the size of this standard dialog
+    if ( x != wxDefaultCoord )
+        m_pos.x = x;
+
+    if ( y != wxDefaultCoord )
+        m_pos.y = y;
+
+    // ignore the size params - we can't change the size of a standard dialog
     return;
 }
 
@@ -200,3 +218,5 @@ void wxColourDialog::DoGetClientSize(int *width, int *height) const
     if ( height )
         *height = 299;
 }
+
+#endif // wxUSE_COLOURDLG && !(__SMARTPHONE__ && __WXWINCE__)