Explorar o código

better GUI resize and combo box fixes

Ken Martin %!s(int64=24) %!d(string=hai) anos
pai
achega
78cc9b21e0

+ 5 - 5
Source/MFCDialog/CMakeSetup.rc

@@ -98,8 +98,8 @@ BEGIN
     COMBOBOX        IDC_WhereBuild,148,26,133,68,CBS_DROPDOWN | 
                     CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
     PUSHBUTTON      "Browse...",IDC_BUTTON3,286,25,43,13
-    DEFPUSHBUTTON   "Build Project Files",IDC_BuildProjects,95,205,67,15
-    PUSHBUTTON      "Close",IDOK,219,205,50,14
+    DEFPUSHBUTTON   "Build Project Files",IDC_BuildProjects,112,206,67,15
+    PUSHBUTTON      "Close",IDOK,190,206,67,15
     LISTBOX         IDC_LIST2,15,55,344,122,LBS_OWNERDRAWVARIABLE | 
                     LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | 
                     WS_HSCROLL
@@ -107,9 +107,9 @@ BEGIN
     RTEXT           "Where do you want to build the binaries:",IDC_STATIC,10,
                     27,128,9
     GROUPBOX        "Cache Values",IDC_FRAME,9,43,356,141
-    LTEXT           "Right click on cache entries for additional options",
-                    IDC_MouseHelpCaption,106,190,156,8
-    LTEXT           "Static",IDC_CMAKE_VERSION,3,211,70,13,SS_CENTERIMAGE
+    CTEXT           "Right click on cache entries for additional options",
+                    IDC_MouseHelpCaption,106,189,156,8
+    LTEXT           "Static",IDC_CMAKE_VERSION,3,211,58,13,SS_CENTERIMAGE
 END
 
 

+ 54 - 11
Source/MFCDialog/CMakeSetupDialog.cpp

@@ -81,6 +81,9 @@ CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
   m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
   // add the cmake.exe to the path
   m_PathToExecutable += "/cmake.exe";
+  
+  m_oldCX = -1;
+  m_deltaXRemainder = 0;
 }
 
 void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
@@ -95,8 +98,8 @@ void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
 	DDX_Control(pDX, IDC_WhereSource, m_WhereSourceControl);
 	DDX_Control(pDX, IDC_WhereBuild, m_WhereBuildControl);
 	DDX_Control(pDX, IDC_LIST2, m_CacheEntriesList);
-	DDX_CBString(pDX, IDC_WhereBuild, m_WhereBuild);
-	DDX_CBString(pDX, IDC_WhereSource, m_WhereSource);
+	DDX_CBStringExact(pDX, IDC_WhereBuild, m_WhereBuild);
+	DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource);
 	//}}AFX_DATA_MAP
 }
 
@@ -451,6 +454,7 @@ void CMakeSetupDialog::OnSelendokWhereBuild()
 {
   m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(), 
                                 m_WhereBuild);
+  m_WhereBuildControl.SetWindowText( m_WhereBuild);
   this->UpdateData(FALSE);
   this->OnChangeWhereBuild();
 }
@@ -582,23 +586,62 @@ void CMakeSetupDialog::SaveCacheFromGUI()
 
 void CMakeSetupDialog::OnSize(UINT nType, int cx, int cy) 
 {
+  if (m_oldCX == -1)
+    {
+    m_oldCX = cx;
+    m_oldCY = cy;
+    }
+  int deltax = cx - m_oldCX;
+  int deltay = cy - m_oldCY;
+
+  m_oldCX = cx;
+  m_oldCY = cy;
+
   CDialog::OnSize(nType, cx, cy);
+
+  if (deltax == 0 && deltay == 0)
+    {
+    return;
+    }
   
   if(m_CacheEntriesList.m_hWnd)
     {
-    m_ListFrame.SetWindowPos(&wndTop, 0, 0, cx-28, cy-137,
+    // get the original sizes/positions
+    CRect cRect;
+    m_ListFrame.GetWindowRect(&cRect);
+    m_ListFrame.SetWindowPos(&wndTop, cRect.left, cRect.top, 
+                             cRect.Width() + deltax, 
+                             cRect.Height() + deltay, 
                              SWP_NOMOVE | SWP_NOZORDER);
-    m_CacheEntriesList.SetWindowPos(&wndTop, 0, 0, cx-48, cy-168,
-                                    SWP_NOMOVE | SWP_NOZORDER);
-    m_BuildProjects.SetWindowPos(&wndTop, 143, cy-33, 0, 0, 
-                                 SWP_NOSIZE | SWP_NOZORDER);
-    m_MouseHelp.SetWindowPos(&wndTop, 159, cy-57,
+    m_CacheEntriesList.GetWindowRect(&cRect);
+    m_CacheEntriesList.SetWindowPos(&wndTop, cRect.left, cRect.top, 
+                             cRect.Width() + deltax, 
+                             cRect.Height() + deltay, 
+                             SWP_NOMOVE | SWP_NOZORDER);
+    m_VersionDisplay.SetWindowPos(&wndTop, 5, cy-23, 0, 0,
+                                  SWP_NOSIZE | SWP_NOZORDER);
+
+    deltax = deltax + m_deltaXRemainder;
+    m_deltaXRemainder = deltax%2;
+    m_MouseHelp.GetWindowRect(&cRect);
+    this->ScreenToClient(&cRect);
+    m_MouseHelp.SetWindowPos(&wndTop, cRect.left + deltax/2, 
+                             cRect.top + deltay, 
                              0, 0,
                              SWP_NOSIZE | SWP_NOZORDER);
-    m_CancelButton.SetWindowPos(&wndTop, 329, cy-33, 0, 0, 
+
+    m_BuildProjects.GetWindowRect(&cRect);
+    this->ScreenToClient(&cRect);
+    m_BuildProjects.SetWindowPos(&wndTop, cRect.left + deltax/2, 
+                                 cRect.top + deltay, 
+                                 0, 0,
                                  SWP_NOSIZE | SWP_NOZORDER);
-    m_VersionDisplay.SetWindowPos(&wndTop, 5, cy-23, 0, 0,
-                                  SWP_NOSIZE | SWP_NOZORDER);
+    m_CancelButton.GetWindowRect(&cRect);
+    this->ScreenToClient(&cRect);
+    m_CancelButton.SetWindowPos(&wndTop, cRect.left + deltax/2, 
+                                cRect.top + deltay, 
+                                0, 0,
+                                SWP_NOSIZE | SWP_NOZORDER);
     }
   
 }

+ 4 - 0
Source/MFCDialog/CMakeSetupDialog.h

@@ -81,6 +81,10 @@ protected:
   afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
   //}}AFX_MSG
   DECLARE_MESSAGE_MAP()
+
+    int m_oldCX;
+    int m_oldCY;
+  float m_deltaXRemainder;
 };
 
 //{{AFX_INSERT_LOCATION}}