[dasher: 8/217] Fixed minimum window size calculations.



commit c56fbef3005a3f35ea55265e179332ab533b8008
Author: ipomoena <amajorek google com>
Date:   Thu Jul 9 11:11:10 2015 -0700

    Fixed minimum window size calculations.

 Src/Win32/DasherWindow.cpp |   31 ++++++++++++++++++-------------
 Src/Win32/DasherWindow.h   |    3 +++
 2 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp
index 725f47c..d6ffdbd 100644
--- a/Src/Win32/DasherWindow.cpp
+++ b/Src/Win32/DasherWindow.cpp
@@ -292,17 +292,24 @@ LRESULT CDasherWindow::OnGetMinMaxInfo(UINT message, WPARAM wParam, LPARAM lPara
     return 0;
   }
 
-  LPPOINT lppt;
-  lppt = (LPPOINT)lParam;    // lParam points to array of POINTs
-  lppt[3].x = 100;            // Set minimum width (arbitrary)
-  // Set minimum height:
+  RECT rect = { 0, 0, 0, 0 };
+  int iStyle = m_pAppSettings->GetLongParameter(APP_LP_STYLE);
+
+  rect.right = GetMinCanvasWidth();
+  if (iStyle == APP_STYLE_COMPOSE)
+    rect.right *= 2;
+
+  rect.bottom = GetMinCanvasHeight() + m_pSpeedAlphabetBar->GetHeight();
+  if (iStyle == APP_STYLE_TRAD)
+    rect.bottom += GetMinEditHeight() + m_pSplitter->GetHeight();
   if (m_pAppSettings->GetBoolParameter(APP_BP_SHOW_TOOLBAR))
-    lppt[3].y = m_pToolbar->GetHeight() + m_pSplitter->GetPos()
-    + m_pSplitter->GetHeight() + m_pSpeedAlphabetBar->GetHeight() + GetSystemMetrics(SM_CYEDGE) * 10;
-  else
-    lppt[3].y = m_pSplitter->GetPos()
-    + m_pSplitter->GetHeight() + m_pSpeedAlphabetBar->GetHeight() + GetSystemMetrics(SM_CYEDGE) * 10;
+    rect.bottom += m_pToolbar->GetHeight();
 
+  //min size including non-client area
+  ::AdjustWindowRectEx(&rect, GetStyle(), GetMenu() != NULL, GetExStyle());
+  LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
+  mmi->ptMinTrackSize.x = rect.right - rect.left;
+  mmi->ptMinTrackSize.y = rect.bottom - rect.top;
   return 0;
 }
 
@@ -404,10 +411,8 @@ void CDasherWindow::Layout() {
 
   default:
     int SplitterHeight = m_pSplitter->GetHeight();
-    int MinEditHeight = 3 * SplitterHeight;
-    int MinDasherHeight = 3 * SplitterHeight;
-    int SplitterY = max(CanvasY + MinEditHeight, m_pSplitter->GetPos());
-    SplitterY = min(SplitterY, CanvasHeight - MinDasherHeight - SplitterHeight);
+    int SplitterY = max(CanvasY + GetMinEditHeight(), m_pSplitter->GetPos());
+    SplitterY = min(SplitterY, CanvasY + CanvasHeight - GetMinCanvasHeight() - SplitterHeight);
     int EditHeight = SplitterY - CanvasY;
     int DasherY = SplitterY + SplitterHeight;
 
diff --git a/Src/Win32/DasherWindow.h b/Src/Win32/DasherWindow.h
index 979b038..471e539 100644
--- a/Src/Win32/DasherWindow.h
+++ b/Src/Win32/DasherWindow.h
@@ -78,6 +78,9 @@ private:
  
        void SaveWindowState() const;
        bool LoadWindowState();
+  int GetMinCanvasWidth() const { return 100; }
+  int GetMinCanvasHeight() const { return 100; }
+  int GetMinEditHeight() const { return 50; }
 
   bool m_bFullyCreated;
        Dasher::CDasher *m_pDasher;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]