summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleo2002-08-09 01:11:03 +0000
committerleo2002-08-09 01:11:03 +0000
commit0833cf8d134af4d7dc5a236b6d198da711b02865 (patch)
treebaa24cd3abf2afc4a4712dd51867328021484b82
parente4aeb305835b6490eb4f7f6e337511cd815b02ae (diff)
Made the Terrain Editor resizable.
git-svn-id: http://svn.leocad.org/trunk@296 c7d43263-9d01-0410-8a33-9dba5d9f93d6
-rw-r--r--win/LeoCAD.rc10
-rw-r--r--win/Terrdlg.cpp64
-rw-r--r--win/Terrdlg.h2
-rw-r--r--win/resource.h1
4 files changed, 47 insertions, 30 deletions
diff --git a/win/LeoCAD.rc b/win/LeoCAD.rc
index ef6d7c8..00c425a 100644
--- a/win/LeoCAD.rc
+++ b/win/LeoCAD.rc
@@ -1325,16 +1325,14 @@ BEGIN
WS_TABSTOP,102,7,191,186
END
-IDD_TERRAIN DIALOG DISCARDABLE 0, 0, 320, 200
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+IDD_TERRAIN DIALOG DISCARDABLE 0, 0, 320, 201
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Terrain Editor"
MENU IDR_TERRAIN
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Terrain Grid",IDC_GRID,"TerrainCtrl",WS_BORDER |
- WS_TABSTOP,7,7,145,186
- CTEXT "Dummy",IDC_TERRAIN_DUMMY,153,7,160,186,SS_CENTERIMAGE |
- NOT WS_VISIBLE | WS_DISABLED | WS_BORDER | NOT WS_GROUP
+ WS_TABSTOP,7,7,145,187
END
IDD_TERRAIN_OPTIONS DIALOG DISCARDABLE 0, 0, 234, 126
@@ -1610,7 +1608,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 313
TOPMARGIN, 7
- BOTTOMMARGIN, 193
+ BOTTOMMARGIN, 194
END
IDD_TERRAIN_OPTIONS, DIALOG
diff --git a/win/Terrdlg.cpp b/win/Terrdlg.cpp
index 0b8167b..3258d89 100644
--- a/win/Terrdlg.cpp
+++ b/win/Terrdlg.cpp
@@ -24,6 +24,7 @@ CTerrainDlg::CTerrainDlg(Terrain* pTerrain, bool bLinear, CWnd* pParent /*=NULL*
//{{AFX_DATA_INIT(CTerrainDlg)
//}}AFX_DATA_INIT
+ m_pTerrainWnd = NULL;
m_pTerrain = pTerrain;
m_bLinear = bLinear;
}
@@ -41,6 +42,8 @@ void CTerrainDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CTerrainDlg, CDialog)
//{{AFX_MSG_MAP(CTerrainDlg)
+ ON_WM_SIZE()
+ ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_LC_EDIT_CLOSED, OnGridChange)
END_MESSAGE_MAP()
@@ -53,54 +56,38 @@ BOOL CTerrainDlg::OnInitDialog()
CDialog::OnInitDialog();
// Add the ToolBar.
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_TERRAIN))
+ if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TERRAIN))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
-
+
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
-
+
// We need to resize the dialog to make room for control bars.
// First, figure out how big the control bars are.
CRect rcClientStart;
CRect rcClientNow;
GetClientRect(rcClientStart);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);
-
+
// Now move all the controls so they are in the same relative
// position within the remaining client area as they would be
// with no control bars.
CPoint ptOffset(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top);
-
- CRect rcChild;
- CWnd* pwndChild = GetWindow(GW_CHILD);
- while (pwndChild)
- {
- pwndChild->GetWindowRect(rcChild);
- ScreenToClient(rcChild);
- rcChild.OffsetRect(ptOffset);
- pwndChild->MoveWindow(rcChild, FALSE);
- pwndChild = pwndChild->GetNextWindow();
- }
-
+
// Adjust the dialog window dimensions
CRect rcWindow;
GetWindowRect(rcWindow);
rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
MoveWindow(rcWindow, FALSE);
-
+
// And position the control bars
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
- RECT r;
- ::GetWindowRect (::GetDlgItem(m_hWnd, IDC_TERRAIN_DUMMY), &r);
- ScreenToClient (&r);
-
m_pTerrainWnd = new CTerrainWnd(m_pTerrain);
- m_pTerrainWnd->Create (NULL, NULL, WS_BORDER | WS_CHILD | WS_VISIBLE, r, this, 501);
+ m_pTerrainWnd->Create (NULL, NULL, WS_BORDER | WS_CHILD | WS_VISIBLE, CRect (0,0,20,20), this, 501);
m_pTerrainWnd->LoadTexture(m_bLinear);
m_Grid.SetControlPoints(m_pTerrain->GetCountU(), m_pTerrain->GetCountV(), m_pTerrain->GetControlPoints());
@@ -239,3 +226,34 @@ BOOL CTerrainDlg::PreTranslateMessage(MSG* pMsg)
return CDialog::PreTranslateMessage(pMsg);
}
+
+void CTerrainDlg::OnSize(UINT nType, int cx, int cy)
+{
+ CDialog::OnSize(nType, cx, cy);
+
+ // Fix the toolbar and menu.
+ RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
+
+ if (m_pTerrainWnd)
+ {
+ CRect rcClient;
+
+ // Find out how much space is left.
+ RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClient);
+
+ m_Grid.MoveWindow (rcClient.left + 5, rcClient.top + 5, rcClient.Width()/2 - 7, rcClient.Height() - 10);
+ m_pTerrainWnd->MoveWindow (rcClient.left + rcClient.Width()/2 + 2, rcClient.top + 5, rcClient.Width()/2 - 7, rcClient.Height() - 10);
+ }
+}
+
+void CTerrainDlg::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+ CDialog::OnShowWindow(bShow, nStatus);
+
+ if (bShow)
+ {
+ CRect rcWindow;
+ GetWindowRect(rcWindow);
+ OnSize(SIZE_RESTORED, rcWindow.Width(), rcWindow.Height());
+ }
+}
diff --git a/win/Terrdlg.h b/win/Terrdlg.h
index 97547b2..f807c0b 100644
--- a/win/Terrdlg.h
+++ b/win/Terrdlg.h
@@ -50,6 +50,8 @@ protected:
// Generated message map functions
//{{AFX_MSG(CTerrainDlg)
virtual BOOL OnInitDialog();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
//}}AFX_MSG
afx_msg LRESULT OnGridChange(WPARAM wParam, LPARAM lParam);
diff --git a/win/resource.h b/win/resource.h
index a9210d4..287b70a 100644
--- a/win/resource.h
+++ b/win/resource.h
@@ -347,7 +347,6 @@
#define IDC_MF_TORSOCOLOR 1191
#define IDC_GRID 1191
#define IDC_MF_NECKCOLOR 1192
-#define IDC_TERRAIN_DUMMY 1192
#define IDC_MF_ARMLCOLOR 1193
#define IDC_MF_ARMRCOLOR 1194
#define IDC_MF_HANDLCOLOR 1195