Commit 70c3e886d93e62fa27c89a61c37c94c8a1f533ac
1 parent
c22bc376
feat<central_clearing_system>:基本完成下单流程开发
Showing
19 changed files
with
1210 additions
and
678 deletions
central_clearing_system/ETradeClient.rc
@@ -203,7 +203,7 @@ BEGIN | @@ -203,7 +203,7 @@ BEGIN | ||
203 | CONTROL "新中新电子读卡器",IDC_RADIO_XINZHONGXIN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,174,186,71,10 | 203 | CONTROL "新中新电子读卡器",IDC_RADIO_XINZHONGXIN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,174,186,71,10 |
204 | END | 204 | END |
205 | 205 | ||
206 | -IDD_DIALOG_PLACE_ORDER DIALOGEX 0, 0, 338, 238 | 206 | +IDD_DIALOG_PLACE_ORDER DIALOGEX 0, 0, 342, 238 |
207 | STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | 207 | STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
208 | CAPTION "结算下单" | 208 | CAPTION "结算下单" |
209 | FONT 12, "微软雅黑", 400, 0, 0x86 | 209 | FONT 12, "微软雅黑", 400, 0, 0x86 |
@@ -212,7 +212,6 @@ BEGIN | @@ -212,7 +212,6 @@ BEGIN | ||
212 | LTEXT "货 主",IDC_STATIC_OWNER,1,19,25,14 | 212 | LTEXT "货 主",IDC_STATIC_OWNER,1,19,25,14 |
213 | EDITTEXT IDC_EDIT_NAME,91,18,44,14,ES_MULTILINE | ES_AUTOHSCROLL | 213 | EDITTEXT IDC_EDIT_NAME,91,18,44,14,ES_MULTILINE | ES_AUTOHSCROLL |
214 | LTEXT "商 品",IDC_STATIC_COMM,2,33,26,12 | 214 | LTEXT "商 品",IDC_STATIC_COMM,2,33,26,12 |
215 | - EDITTEXT IDC_EDIT_CARD,29,18,53,15,ES_MULTILINE | ES_AUTOHSCROLL | ||
216 | EDITTEXT IDC_EDIT_COMM_NUM,29,36,53,15,ES_MULTILINE | ES_AUTOHSCROLL | 215 | EDITTEXT IDC_EDIT_COMM_NUM,29,36,53,15,ES_MULTILINE | ES_AUTOHSCROLL |
217 | EDITTEXT IDC_EDIT_COMM_NAME,92,37,44,13,ES_MULTILINE | ES_AUTOHSCROLL | 216 | EDITTEXT IDC_EDIT_COMM_NAME,92,37,44,13,ES_MULTILINE | ES_AUTOHSCROLL |
218 | LTEXT "单 位",IDC_STATIC_UNIT,1,54,26,12 | 217 | LTEXT "单 位",IDC_STATIC_UNIT,1,54,26,12 |
@@ -224,10 +223,29 @@ BEGIN | @@ -224,10 +223,29 @@ BEGIN | ||
224 | EDITTEXT IDC_EDIT_PRICE,30,70,53,15,ES_MULTILINE | ES_AUTOHSCROLL | 223 | EDITTEXT IDC_EDIT_PRICE,30,70,53,15,ES_MULTILINE | ES_AUTOHSCROLL |
225 | LTEXT "数 量",IDC_STATIC_COUNT,92,70,30,14 | 224 | LTEXT "数 量",IDC_STATIC_COUNT,92,70,30,14 |
226 | EDITTEXT IDC_EDIT_COUNT,114,69,44,13,ES_MULTILINE | ES_AUTOHSCROLL | 225 | EDITTEXT IDC_EDIT_COUNT,114,69,44,13,ES_MULTILINE | ES_AUTOHSCROLL |
227 | - PUSHBUTTON "去支付(&S)",IDC_BUTTON_PAY,284,10,50,14 | ||
228 | - LTEXT "合计:",IDC_STATIC_HEJI,246,227,20,8 | 226 | + LTEXT "交易金额:",IDC_STATIC_HEJI,246,227,33,8 |
229 | LTEXT "",IDC_STATIC_TOTAL_MONEY,289,227,8,8 | 227 | LTEXT "",IDC_STATIC_TOTAL_MONEY,289,227,8,8 |
230 | LTEXT "",IDC_STATIC_ERROR,262,67,8,8 | 228 | LTEXT "",IDC_STATIC_ERROR,262,67,8,8 |
229 | + LTEXT "买 家",IDC_STATIC_BUYER,170,40,25,14 | ||
230 | + EDITTEXT IDC_EDIT_BUYER_NAME,260,39,44,14,ES_MULTILINE | ES_AUTOHSCROLL | ||
231 | + EDITTEXT IDC_EDIT_BUYER_CARD,198,39,53,15,ES_MULTILINE | ES_AUTOHSCROLL | ||
232 | + EDITTEXT IDC_EDIT_CARD,29,18,53,15,ES_MULTILINE | ES_AUTOHSCROLL | ||
233 | + PUSHBUTTON "去支付(&S)",IDC_BUTTON_PAY,287,10,50,14 | ||
234 | + PUSHBUTTON "买家刷卡(F11)",IDC_BUTTON_SWIP_CARD,287,53,50,14 | ||
235 | +END | ||
236 | + | ||
237 | +IDD_DIALOG_PAY DIALOGEX 0, 0, 229, 119 | ||
238 | +STYLE DS_SETFONT | WS_POPUP | WS_BORDER | WS_SYSMENU | ||
239 | +FONT 12, "微软雅黑", 400, 0, 0x0 | ||
240 | +BEGIN | ||
241 | + LTEXT "总计金额:",IDC_PAY_STATIC_TOTAL_MONEY,18,20,41,8 | ||
242 | + LTEXT "",IDC_PAY_STATIC_MONEY,73,20,8,8 | ||
243 | + LTEXT "密 码:",IDC_PAY_STATIC_PASSWORD,18,50,31,8 | ||
244 | + EDITTEXT IDC_PAY_EDIT_PASSWORD,56,46,40,14,ES_MULTILINE | ES_AUTOHSCROLL | ||
245 | + PUSHBUTTON "输入密码(&A)",IDC_PAY_BUTTON_PASSWORD,151,51,71,18 | ||
246 | + PUSHBUTTON "关闭(&S)",IDC_PAY_BUTTON_CLOSE,155,95,67,17 | ||
247 | + PUSHBUTTON "付款(&F)",IDC_PAY_BUTTON_PAY,72,95,67,17 | ||
248 | + LTEXT "",IDC_PAY_STATIC_REAL_MONEY,65,20,57,8 | ||
231 | END | 249 | END |
232 | 250 | ||
233 | 251 | ||
@@ -302,9 +320,18 @@ BEGIN | @@ -302,9 +320,18 @@ BEGIN | ||
302 | IDD_DIALOG_PLACE_ORDER, DIALOG | 320 | IDD_DIALOG_PLACE_ORDER, DIALOG |
303 | BEGIN | 321 | BEGIN |
304 | MOCKUP, 1, 50, -25, -30, "C:\Users\WangGY\Desktop\TIM图片20180918183513.png" | 322 | MOCKUP, 1, 50, -25, -30, "C:\Users\WangGY\Desktop\TIM图片20180918183513.png" |
305 | - RIGHTMARGIN, 334 | 323 | + RIGHTMARGIN, 337 |
306 | HORZGUIDE, 67 | 324 | HORZGUIDE, 67 |
307 | END | 325 | END |
326 | + | ||
327 | + IDD_DIALOG_PAY, DIALOG | ||
328 | + BEGIN | ||
329 | + MOCKUP, 1, 50, -5, -34, "C:\Users\WangGY\Desktop\无标题.png" | ||
330 | + LEFTMARGIN, 7 | ||
331 | + RIGHTMARGIN, 222 | ||
332 | + TOPMARGIN, 7 | ||
333 | + BOTTOMMARGIN, 112 | ||
334 | + END | ||
308 | END | 335 | END |
309 | #endif // APSTUDIO_INVOKED | 336 | #endif // APSTUDIO_INVOKED |
310 | 337 |
central_clearing_system/ETradeClient.vcxproj
@@ -141,6 +141,8 @@ | @@ -141,6 +141,8 @@ | ||
141 | <ClInclude Include="ETradeClient\mfc_ui\LoginDialog.h" /> | 141 | <ClInclude Include="ETradeClient\mfc_ui\LoginDialog.h" /> |
142 | <ClInclude Include="ETradeClient\mfc_ui\LoginEdit.h" /> | 142 | <ClInclude Include="ETradeClient\mfc_ui\LoginEdit.h" /> |
143 | <ClInclude Include="ETradeClient\mfc_ui\MainFrm.h" /> | 143 | <ClInclude Include="ETradeClient\mfc_ui\MainFrm.h" /> |
144 | + <ClInclude Include="ETradeClient\mfc_ui\MemDC.h" /> | ||
145 | + <ClInclude Include="ETradeClient\mfc_ui\pay_dlg.h" /> | ||
144 | <ClInclude Include="ETradeClient\mfc_ui\place_order_dlg.h" /> | 146 | <ClInclude Include="ETradeClient\mfc_ui\place_order_dlg.h" /> |
145 | <ClInclude Include="ETradeClient\mfc_ui\PopupBrowserDlgView.h" /> | 147 | <ClInclude Include="ETradeClient\mfc_ui\PopupBrowserDlgView.h" /> |
146 | <ClInclude Include="ETradeClient\mfc_ui\ConfigDialog.h" /> | 148 | <ClInclude Include="ETradeClient\mfc_ui\ConfigDialog.h" /> |
@@ -190,6 +192,7 @@ | @@ -190,6 +192,7 @@ | ||
190 | <ClCompile Include="ETradeClient\mfc_ui\LoginDialog.cpp" /> | 192 | <ClCompile Include="ETradeClient\mfc_ui\LoginDialog.cpp" /> |
191 | <ClCompile Include="ETradeClient\mfc_ui\LoginEdit.cpp" /> | 193 | <ClCompile Include="ETradeClient\mfc_ui\LoginEdit.cpp" /> |
192 | <ClCompile Include="ETradeClient\mfc_ui\MainFrm.cpp" /> | 194 | <ClCompile Include="ETradeClient\mfc_ui\MainFrm.cpp" /> |
195 | + <ClCompile Include="ETradeClient\mfc_ui\pay_dlg.cpp" /> | ||
193 | <ClCompile Include="ETradeClient\mfc_ui\place_order_dlg.cpp" /> | 196 | <ClCompile Include="ETradeClient\mfc_ui\place_order_dlg.cpp" /> |
194 | <ClCompile Include="ETradeClient\mfc_ui\PopupBrowserDlgView.cpp" /> | 197 | <ClCompile Include="ETradeClient\mfc_ui\PopupBrowserDlgView.cpp" /> |
195 | <ClCompile Include="ETradeClient\mfc_ui\ConfigDialog.cpp" /> | 198 | <ClCompile Include="ETradeClient\mfc_ui\ConfigDialog.cpp" /> |
central_clearing_system/ETradeClient.vcxproj.filters
@@ -210,6 +210,12 @@ | @@ -210,6 +210,12 @@ | ||
210 | <ClInclude Include="ETradeClient\mfc_ui\etrade_edit_control.h"> | 210 | <ClInclude Include="ETradeClient\mfc_ui\etrade_edit_control.h"> |
211 | <Filter>Header Files\mfc_ui</Filter> | 211 | <Filter>Header Files\mfc_ui</Filter> |
212 | </ClInclude> | 212 | </ClInclude> |
213 | + <ClInclude Include="ETradeClient\mfc_ui\MemDC.h"> | ||
214 | + <Filter>Header Files\mfc_ui</Filter> | ||
215 | + </ClInclude> | ||
216 | + <ClInclude Include="ETradeClient\mfc_ui\pay_dlg.h"> | ||
217 | + <Filter>Header Files</Filter> | ||
218 | + </ClInclude> | ||
213 | </ItemGroup> | 219 | </ItemGroup> |
214 | <ItemGroup> | 220 | <ItemGroup> |
215 | <ClCompile Include="stdafx.cpp"> | 221 | <ClCompile Include="stdafx.cpp"> |
@@ -338,6 +344,9 @@ | @@ -338,6 +344,9 @@ | ||
338 | <ClCompile Include="ETradeClient\mfc_ui\etrade_edit_control.cpp"> | 344 | <ClCompile Include="ETradeClient\mfc_ui\etrade_edit_control.cpp"> |
339 | <Filter>Source Files\mfc_ui</Filter> | 345 | <Filter>Source Files\mfc_ui</Filter> |
340 | </ClCompile> | 346 | </ClCompile> |
347 | + <ClCompile Include="ETradeClient\mfc_ui\pay_dlg.cpp"> | ||
348 | + <Filter>Source Files</Filter> | ||
349 | + </ClCompile> | ||
341 | </ItemGroup> | 350 | </ItemGroup> |
342 | <ItemGroup> | 351 | <ItemGroup> |
343 | <ResourceCompile Include="ETradeClient.rc"> | 352 | <ResourceCompile Include="ETradeClient.rc"> |
central_clearing_system/ETradeClient/mfc_ui/GridCell.cpp
@@ -5,8 +5,8 @@ | @@ -5,8 +5,8 @@ | ||
5 | // Provides the implementation for the "default" cell type of the | 5 | // Provides the implementation for the "default" cell type of the |
6 | // grid control. Adds in cell editing. | 6 | // grid control. Adds in cell editing. |
7 | // | 7 | // |
8 | -// Written by Chris Maunder <chris@codeproject.com> | ||
9 | -// Copyright (c) 1998-2005. All Rights Reserved. | 8 | +// Written by Chris Maunder <cmaunder@mail.com> |
9 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
10 | // | 10 | // |
11 | // This code may be used in compiled form in any way you desire. This | 11 | // This code may be used in compiled form in any way you desire. This |
12 | // file may be redistributed unmodified by any means PROVIDING it is | 12 | // file may be redistributed unmodified by any means PROVIDING it is |
@@ -60,8 +60,9 @@ CGridCell::~CGridCell() | @@ -60,8 +60,9 @@ CGridCell::~CGridCell() | ||
60 | 60 | ||
61 | ///////////////////////////////////////////////////////////////////////////// | 61 | ///////////////////////////////////////////////////////////////////////////// |
62 | // GridCell Attributes | 62 | // GridCell Attributes |
63 | - | ||
64 | -void CGridCell::operator=(const CGridCell& cell) | 63 | +//Used for merge cells,remove const |
64 | +//by Huang Wei | ||
65 | +void CGridCell::operator=( CGridCell& cell) | ||
65 | { | 66 | { |
66 | if (this != &cell) CGridCellBase::operator=(cell); | 67 | if (this != &cell) CGridCellBase::operator=(cell); |
67 | } | 68 | } |
@@ -72,7 +73,6 @@ void CGridCell::Reset() | @@ -72,7 +73,6 @@ void CGridCell::Reset() | ||
72 | 73 | ||
73 | m_strText.Empty(); | 74 | m_strText.Empty(); |
74 | m_nImage = -1; | 75 | m_nImage = -1; |
75 | - m_lParam = NULL; // BUG FIX J. Bloggs 20/10/03 | ||
76 | m_pGrid = NULL; | 76 | m_pGrid = NULL; |
77 | m_bEditing = FALSE; | 77 | m_bEditing = FALSE; |
78 | m_pEditWnd = NULL; | 78 | m_pEditWnd = NULL; |
@@ -223,28 +223,9 @@ CGridDefaultCell::CGridDefaultCell() | @@ -223,28 +223,9 @@ CGridDefaultCell::CGridDefaultCell() | ||
223 | GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &lf); | 223 | GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &lf); |
224 | SetFont(&lf); | 224 | SetFont(&lf); |
225 | #else // not CE | 225 | #else // not CE |
226 | - | ||
227 | NONCLIENTMETRICS ncm; | 226 | NONCLIENTMETRICS ncm; |
228 | -#if defined(_MSC_VER) && (_MSC_VER < 1300) | ||
229 | - ncm.cbSize = sizeof(NONCLIENTMETRICS); // NONCLIENTMETRICS has an extra element after VC6 | ||
230 | -#else | ||
231 | - // Check the operating system's version | ||
232 | - OSVERSIONINFOEX osvi; | ||
233 | - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); | ||
234 | - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); | ||
235 | - if( !GetVersionEx((OSVERSIONINFO *) &osvi)) | ||
236 | - { | ||
237 | - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | ||
238 | - GetVersionEx ((OSVERSIONINFO *)&osvi); | ||
239 | - } | ||
240 | - | ||
241 | - if (osvi.dwMajorVersion > 5) | ||
242 | - ncm.cbSize = sizeof(NONCLIENTMETRICS); | ||
243 | - else | ||
244 | - ncm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(ncm.iPaddedBorderWidth); | ||
245 | -#endif | 227 | + ncm.cbSize = sizeof(NONCLIENTMETRICS); |
246 | VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)); | 228 | VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)); |
247 | - | ||
248 | SetFont(&(ncm.lfMessageFont)); | 229 | SetFont(&(ncm.lfMessageFont)); |
249 | #endif | 230 | #endif |
250 | } | 231 | } |
central_clearing_system/ETradeClient/mfc_ui/GridCell.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | // | 3 | // |
4 | // MFC Grid Control - Grid cell class header file | 4 | // MFC Grid Control - Grid cell class header file |
5 | // | 5 | // |
6 | -// Written by Chris Maunder <chris@codeproject.com> | ||
7 | -// Copyright (c) 1998-2005. All Rights Reserved. | 6 | +// Written by Chris Maunder <cmaunder@mail.com> |
7 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
8 | // | 8 | // |
9 | // This code may be used in compiled form in any way you desire. This | 9 | // This code may be used in compiled form in any way you desire. This |
10 | // file may be redistributed unmodified by any means PROVIDING it is | 10 | // file may be redistributed unmodified by any means PROVIDING it is |
@@ -48,7 +48,7 @@ public: | @@ -48,7 +48,7 @@ public: | ||
48 | 48 | ||
49 | // Attributes | 49 | // Attributes |
50 | public: | 50 | public: |
51 | - void operator=(const CGridCell& cell); | 51 | + void operator=( CGridCell& cell); |
52 | 52 | ||
53 | virtual void SetText(LPCTSTR szText) { m_strText = szText; } | 53 | virtual void SetText(LPCTSTR szText) { m_strText = szText; } |
54 | virtual void SetImage(int nImage) { m_nImage = nImage; } | 54 | virtual void SetImage(int nImage) { m_nImage = nImage; } |
central_clearing_system/ETradeClient/mfc_ui/GridCellBase.cpp
@@ -7,8 +7,8 @@ | @@ -7,8 +7,8 @@ | ||
7 | // implementations of drawing, printingetc provided. MUST be derived | 7 | // implementations of drawing, printingetc provided. MUST be derived |
8 | // from to be used. | 8 | // from to be used. |
9 | // | 9 | // |
10 | -// Written by Chris Maunder <chris@codeproject.com> | ||
11 | -// Copyright (c) 1998-2005. All Rights Reserved. | 10 | +// Written by Chris Maunder <cmaunder@mail.com> |
11 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
12 | // | 12 | // |
13 | // This code may be used in compiled form in any way you desire. This | 13 | // This code may be used in compiled form in any way you desire. This |
14 | // file may be redistributed unmodified by any means PROVIDING it is | 14 | // file may be redistributed unmodified by any means PROVIDING it is |
@@ -30,7 +30,6 @@ | @@ -30,7 +30,6 @@ | ||
30 | // C Maunder - 29 Aug 2000 - operator= checks for NULL font before setting (Martin Richter) | 30 | // C Maunder - 29 Aug 2000 - operator= checks for NULL font before setting (Martin Richter) |
31 | // C Maunder - 15 Oct 2000 - GetTextExtent fixed (Martin Richter) | 31 | // C Maunder - 15 Oct 2000 - GetTextExtent fixed (Martin Richter) |
32 | // C Maunder - 1 Jan 2001 - Added ValidateEdit | 32 | // C Maunder - 1 Jan 2001 - Added ValidateEdit |
33 | -// Yogurt - 13 Mar 2004 - GetCellExtent fixed | ||
34 | // | 33 | // |
35 | // NOTES: Each grid cell should take care of it's own drawing, though the Draw() | 34 | // NOTES: Each grid cell should take care of it's own drawing, though the Draw() |
36 | // method takes an "erase background" paramter that is called if the grid | 35 | // method takes an "erase background" paramter that is called if the grid |
@@ -71,10 +70,19 @@ CGridCellBase::~CGridCellBase() | @@ -71,10 +70,19 @@ CGridCellBase::~CGridCellBase() | ||
71 | 70 | ||
72 | void CGridCellBase::Reset() | 71 | void CGridCellBase::Reset() |
73 | { | 72 | { |
73 | + m_Hide=false; | ||
74 | m_nState = 0; | 74 | m_nState = 0; |
75 | + m_MergeRange.Set(); | ||
76 | + m_IsMergeWithOthers=false; | ||
77 | + m_MergeCellID.row=-1; | ||
78 | + m_MergeCellID.col=-1; | ||
79 | + | ||
80 | + | ||
75 | } | 81 | } |
82 | +//Used for merge cells,remove const | ||
83 | +//by Huang Wei | ||
76 | 84 | ||
77 | -void CGridCellBase::operator=(const CGridCellBase& cell) | 85 | +void CGridCellBase::operator=( CGridCellBase& cell) |
78 | { | 86 | { |
79 | if (this == &cell) return; | 87 | if (this == &cell) return; |
80 | 88 | ||
@@ -89,6 +97,11 @@ void CGridCellBase::operator=(const CGridCellBase& cell) | @@ -89,6 +97,11 @@ void CGridCellBase::operator=(const CGridCellBase& cell) | ||
89 | SetBackClr(cell.GetBackClr()); | 97 | SetBackClr(cell.GetBackClr()); |
90 | SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); | 98 | SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); |
91 | SetMargin(cell.GetMargin()); | 99 | SetMargin(cell.GetMargin()); |
100 | +//Used for merge cells | ||
101 | +//by Huang Wei | ||
102 | + SetMergeCellID(cell.GetMergeCellID()); | ||
103 | + SetMergeRange(cell.GetMergeRange()); | ||
104 | + Show(cell.IsShow()); | ||
92 | } | 105 | } |
93 | 106 | ||
94 | ///////////////////////////////////////////////////////////////////////////// | 107 | ///////////////////////////////////////////////////////////////////////////// |
@@ -115,6 +128,14 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | @@ -115,6 +128,14 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | ||
115 | // Note - all through this function we totally brutalise 'rect'. Do not | 128 | // Note - all through this function we totally brutalise 'rect'. Do not |
116 | // depend on it's value being that which was passed in. | 129 | // depend on it's value being that which was passed in. |
117 | 130 | ||
131 | + //Used for merge cells | ||
132 | + //by Huang Wei | ||
133 | + if( m_Hide && !IsMerged()) | ||
134 | + { | ||
135 | + return TRUE; | ||
136 | + } | ||
137 | + | ||
138 | + | ||
118 | CGridCtrl* pGrid = GetGrid(); | 139 | CGridCtrl* pGrid = GetGrid(); |
119 | ASSERT(pGrid); | 140 | ASSERT(pGrid); |
120 | 141 | ||
@@ -206,7 +227,7 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | @@ -206,7 +227,7 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | ||
206 | rect.bottom--; | 227 | rect.bottom--; |
207 | } | 228 | } |
208 | 229 | ||
209 | - //rect.DeflateRect(0,1,1,1); - Removed by Yogurt | 230 | + rect.DeflateRect(0,1,1,1); |
210 | } | 231 | } |
211 | else if ((GetState() & GVIS_SELECTED)) | 232 | else if ((GetState() & GVIS_SELECTED)) |
212 | { | 233 | { |
@@ -277,10 +298,7 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | @@ -277,10 +298,7 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | ||
277 | pDC->SelectObject(pFont); | 298 | pDC->SelectObject(pFont); |
278 | } | 299 | } |
279 | 300 | ||
280 | - //rect.DeflateRect(GetMargin(), 0); - changed by Yogurt | ||
281 | - rect.DeflateRect(GetMargin(), GetMargin()); | ||
282 | - rect.right++; | ||
283 | - rect.bottom++; | 301 | + rect.DeflateRect(GetMargin(), 0); |
284 | 302 | ||
285 | if (pGrid->GetImageList() && GetImage() >= 0) | 303 | if (pGrid->GetImageList() && GetImage() >= 0) |
286 | { | 304 | { |
@@ -296,21 +314,14 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | @@ -296,21 +314,14 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | ||
296 | // pDC->SelectClipRgn(&rgn); | 314 | // pDC->SelectClipRgn(&rgn); |
297 | // rgn.DeleteObject(); | 315 | // rgn.DeleteObject(); |
298 | 316 | ||
299 | - /* | ||
300 | - // removed by Yogurt | ||
301 | int nImageWidth = Info.rcImage.right-Info.rcImage.left+1; | 317 | int nImageWidth = Info.rcImage.right-Info.rcImage.left+1; |
302 | int nImageHeight = Info.rcImage.bottom-Info.rcImage.top+1; | 318 | int nImageHeight = Info.rcImage.bottom-Info.rcImage.top+1; |
319 | + | ||
303 | if( nImageWidth + rect.left <= rect.right + (int)(2*GetMargin()) | 320 | if( nImageWidth + rect.left <= rect.right + (int)(2*GetMargin()) |
304 | && nImageHeight + rect.top <= rect.bottom + (int)(2*GetMargin()) ) | 321 | && nImageHeight + rect.top <= rect.bottom + (int)(2*GetMargin()) ) |
305 | { | 322 | { |
306 | pGrid->GetImageList()->Draw(pDC, GetImage(), rect.TopLeft(), ILD_NORMAL); | 323 | pGrid->GetImageList()->Draw(pDC, GetImage(), rect.TopLeft(), ILD_NORMAL); |
307 | } | 324 | } |
308 | - */ | ||
309 | - // Added by Yogurt | ||
310 | - int nImageWidth = Info.rcImage.right-Info.rcImage.left; | ||
311 | - int nImageHeight = Info.rcImage.bottom-Info.rcImage.top; | ||
312 | - if ((nImageWidth + rect.left <= rect.right) && (nImageHeight + rect.top <= rect.bottom)) | ||
313 | - pGrid->GetImageList()->Draw(pDC, GetImage(), rect.TopLeft(), ILD_NORMAL); | ||
314 | 325 | ||
315 | //rect.left += nImageWidth+GetMargin(); | 326 | //rect.left += nImageWidth+GetMargin(); |
316 | } | 327 | } |
@@ -336,8 +347,7 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | @@ -336,8 +347,7 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | ||
336 | BOOL bVertical = (GetFont()->lfEscapement == 900); | 347 | BOOL bVertical = (GetFont()->lfEscapement == 900); |
337 | 348 | ||
338 | // Only draw if it'll fit! | 349 | // Only draw if it'll fit! |
339 | - //if (size.cx + rect.left < rect.right + (int)(2*GetMargin())) - changed / Yogurt | ||
340 | - if (size.cx + rect.left < rect.right) | 350 | + if (size.cx + rect.left < rect.right + (int)(2*GetMargin())) |
341 | { | 351 | { |
342 | int nTriangleBase = rect.bottom - nOffset - size.cy; // Triangle bottom right | 352 | int nTriangleBase = rect.bottom - nOffset - size.cy; // Triangle bottom right |
343 | //int nTriangleBase = (rect.top + rect.bottom - size.cy)/2; // Triangle middle right | 353 | //int nTriangleBase = (rect.top + rect.bottom - size.cy)/2; // Triangle middle right |
@@ -395,9 +405,6 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | @@ -395,9 +405,6 @@ BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseB | ||
395 | 405 | ||
396 | // We want to see '&' characters so use DT_NOPREFIX | 406 | // We want to see '&' characters so use DT_NOPREFIX |
397 | GetTextRect(rect); | 407 | GetTextRect(rect); |
398 | - rect.right++; | ||
399 | - rect.bottom++; | ||
400 | - | ||
401 | DrawText(pDC->m_hDC, GetText(), -1, rect, GetFormat() | DT_NOPREFIX); | 408 | DrawText(pDC->m_hDC, GetText(), -1, rect, GetFormat() | DT_NOPREFIX); |
402 | 409 | ||
403 | pDC->RestoreDC(nSavedDC); | 410 | pDC->RestoreDC(nSavedDC); |
@@ -547,17 +554,16 @@ CSize CGridCellBase::GetTextExtent(LPCTSTR szText, CDC* pDC /*= NULL*/) | @@ -547,17 +554,16 @@ CSize CGridCellBase::GetTextExtent(LPCTSTR szText, CDC* pDC /*= NULL*/) | ||
547 | size = rect.Size(); | 554 | size = rect.Size(); |
548 | } | 555 | } |
549 | else | 556 | else |
550 | - size = pDC->GetTextExtent(szText, (int)_tcslen(szText)); | 557 | + size = pDC->GetTextExtent(szText, _tcslen(szText)); |
551 | 558 | ||
552 | - // Removed by Yogurt | ||
553 | - //TEXTMETRIC tm; | ||
554 | - //pDC->GetTextMetrics(&tm); | ||
555 | - //size.cx += (tm.tmOverhang); | 559 | + TEXTMETRIC tm; |
560 | + pDC->GetTextMetrics(&tm); | ||
561 | + size.cx += (tm.tmOverhang); | ||
556 | 562 | ||
557 | if (pOldFont) | 563 | if (pOldFont) |
558 | pDC->SelectObject(pOldFont); | 564 | pDC->SelectObject(pOldFont); |
559 | 565 | ||
560 | - size += CSize(2*GetMargin(), 2*GetMargin()); | 566 | + size += CSize(4*GetMargin(), 2*GetMargin()); |
561 | 567 | ||
562 | // Kludge for vertical text | 568 | // Kludge for vertical text |
563 | LOGFONT *pLF = GetFont(); | 569 | LOGFONT *pLF = GetFont(); |
@@ -575,41 +581,40 @@ CSize CGridCellBase::GetTextExtent(LPCTSTR szText, CDC* pDC /*= NULL*/) | @@ -575,41 +581,40 @@ CSize CGridCellBase::GetTextExtent(LPCTSTR szText, CDC* pDC /*= NULL*/) | ||
575 | return size; | 581 | return size; |
576 | } | 582 | } |
577 | 583 | ||
578 | - | ||
579 | CSize CGridCellBase::GetCellExtent(CDC* pDC) | 584 | CSize CGridCellBase::GetCellExtent(CDC* pDC) |
580 | -{ | ||
581 | - CSize size = GetTextExtent(GetText(), pDC); | ||
582 | - CSize ImageSize(0,0); | 585 | +{ |
586 | + CSize size = GetTextExtent(GetText(), pDC); | ||
587 | + CSize ImageSize(0,0); | ||
588 | + | ||
589 | + int nImage = GetImage(); | ||
590 | + if (nImage >= 0) | ||
591 | + { | ||
592 | + CGridCtrl* pGrid = GetGrid(); | ||
593 | + ASSERT(pGrid); | ||
594 | + | ||
595 | + if (pGrid->GetImageList()) | ||
596 | + { | ||
597 | + IMAGEINFO Info; | ||
598 | + if (pGrid->GetImageList()->GetImageInfo(nImage, &Info)) | ||
599 | + ImageSize = CSize(Info.rcImage.right-Info.rcImage.left+1, | ||
600 | + Info.rcImage.bottom-Info.rcImage.top+1); | ||
601 | + } | ||
602 | + } | ||
583 | 603 | ||
584 | - int nImage = GetImage(); | ||
585 | - if (nImage >= 0) | ||
586 | - { | ||
587 | - CGridCtrl* pGrid = GetGrid(); | ||
588 | - ASSERT(pGrid); | ||
589 | - IMAGEINFO Info; | ||
590 | - if (pGrid->GetImageList() && pGrid->GetImageList()->GetImageInfo(nImage, &Info)) | ||
591 | - { | ||
592 | - ImageSize = CSize(Info.rcImage.right-Info.rcImage.left, | ||
593 | - Info.rcImage.bottom-Info.rcImage.top); | ||
594 | - if (size.cx > 2*(int)GetMargin ()) | ||
595 | - ImageSize.cx += GetMargin(); | ||
596 | - ImageSize.cy += 2*(int)GetMargin (); | ||
597 | - } | ||
598 | - } | ||
599 | - size.cx += ImageSize.cx + 1; | ||
600 | - size.cy = max(size.cy, ImageSize.cy) + 1; | ||
601 | - if (IsFixed()) | ||
602 | - { | ||
603 | - size.cx++; | ||
604 | - size.cy++; | ||
605 | - } | ||
606 | - return size; | 604 | + return CSize(size.cx + ImageSize.cx, max(size.cy, ImageSize.cy)); |
607 | } | 605 | } |
608 | 606 | ||
609 | // EFW - Added to print cells so that grids that use different colors are | 607 | // EFW - Added to print cells so that grids that use different colors are |
610 | // printed correctly. | 608 | // printed correctly. |
611 | BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | 609 | BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) |
612 | { | 610 | { |
611 | + //Used for merge cells | ||
612 | + //by Huang Wei | ||
613 | + if( m_Hide && !IsMerged()) | ||
614 | + { | ||
615 | + return TRUE; | ||
616 | + } | ||
617 | + | ||
613 | #if defined(_WIN32_WCE_NO_PRINTING) || defined(GRIDCONTROL_NO_PRINTING) | 618 | #if defined(_WIN32_WCE_NO_PRINTING) || defined(GRIDCONTROL_NO_PRINTING) |
614 | return FALSE; | 619 | return FALSE; |
615 | #else | 620 | #else |
@@ -627,6 +632,11 @@ BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | @@ -627,6 +632,11 @@ BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | ||
627 | int nSavedDC = pDC->SaveDC(); | 632 | int nSavedDC = pDC->SaveDC(); |
628 | 633 | ||
629 | pDC->SetBkMode(TRANSPARENT); | 634 | pDC->SetBkMode(TRANSPARENT); |
635 | + //Used for merge cells | ||
636 | + //by Huang Wei | ||
637 | + rect.InflateRect(1,1); | ||
638 | + pDC->Rectangle(rect); | ||
639 | + rect.DeflateRect(1,1); | ||
630 | 640 | ||
631 | if (pGrid->GetShadedPrintOut()) | 641 | if (pGrid->GetShadedPrintOut()) |
632 | { | 642 | { |
@@ -729,6 +739,11 @@ BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | @@ -729,6 +739,11 @@ BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | ||
729 | rect.DeflateRect(1,1); | 739 | rect.DeflateRect(1,1); |
730 | pDC->SelectObject(pOldPen); | 740 | pDC->SelectObject(pOldPen); |
731 | } | 741 | } |
742 | + else | ||
743 | + { | ||
744 | +// pDC->Rectangle(rect); | ||
745 | + | ||
746 | + } | ||
732 | 747 | ||
733 | rect.DeflateRect(GetMargin(), 0); | 748 | rect.DeflateRect(GetMargin(), 0); |
734 | 749 | ||
@@ -751,6 +766,7 @@ BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | @@ -751,6 +766,7 @@ BOOL CGridCellBase::PrintCell(CDC* pDC, int /*nRow*/, int /*nCol*/, CRect rect) | ||
751 | 766 | ||
752 | // Draw without clipping so as not to lose text when printed for real | 767 | // Draw without clipping so as not to lose text when printed for real |
753 | // DT_NOCLIP removed 01.01.01. Slower, but who cares - we are printing! | 768 | // DT_NOCLIP removed 01.01.01. Slower, but who cares - we are printing! |
769 | + | ||
754 | DrawText(pDC->m_hDC, GetText(), -1, rect, | 770 | DrawText(pDC->m_hDC, GetText(), -1, rect, |
755 | GetFormat() | /*DT_NOCLIP | */ DT_NOPREFIX); | 771 | GetFormat() | /*DT_NOCLIP | */ DT_NOPREFIX); |
756 | 772 | ||
@@ -770,4 +786,67 @@ LRESULT CGridCellBase::SendMessageToParent(int nRow, int nCol, int nMessage) | @@ -770,4 +786,67 @@ LRESULT CGridCellBase::SendMessageToParent(int nRow, int nCol, int nMessage) | ||
770 | return pGrid->SendMessageToParent(nRow, nCol, nMessage); | 786 | return pGrid->SendMessageToParent(nRow, nCol, nMessage); |
771 | else | 787 | else |
772 | return 0; | 788 | return 0; |
773 | -} | ||
774 | \ No newline at end of file | 789 | \ No newline at end of file |
790 | +} | ||
791 | +//Used for merge cells | ||
792 | +//by Huang Wei | ||
793 | +void CGridCellBase::Show(bool IsShow) | ||
794 | +{ | ||
795 | + m_Hide=!IsShow; | ||
796 | +} | ||
797 | +//Used for merge cells | ||
798 | +//by Huang Wei | ||
799 | +void CGridCellBase::SetMergeRange(CCellRange range) | ||
800 | +{ | ||
801 | + m_MergeRange=range; | ||
802 | +} | ||
803 | +//Used for merge cells | ||
804 | +//by Huang Wei | ||
805 | +CCellRange CGridCellBase::GetMergeRange() | ||
806 | +{ | ||
807 | + return m_MergeRange; | ||
808 | +} | ||
809 | +//Used for merge cells | ||
810 | +//by Huang Wei | ||
811 | +bool CGridCellBase::IsMerged() | ||
812 | +{ | ||
813 | + return m_MergeRange.Count()>1; | ||
814 | +} | ||
815 | +//Used for merge cells | ||
816 | +//by Huang Wei | ||
817 | +void CGridCellBase::SetMergeCellID(CCellID cell) | ||
818 | +{ | ||
819 | + m_MergeCellID=cell; | ||
820 | + if(cell.row!=-1) | ||
821 | + m_IsMergeWithOthers=true; | ||
822 | + else | ||
823 | + m_IsMergeWithOthers=false; | ||
824 | + | ||
825 | +} | ||
826 | +//Used for merge cells | ||
827 | +//by Huang Wei | ||
828 | +CCellID CGridCellBase::GetMergeCellID() | ||
829 | +{ | ||
830 | + return m_MergeCellID; | ||
831 | +} | ||
832 | +//Used for merge cells | ||
833 | +//by Huang Wei | ||
834 | +bool CGridCellBase::IsMergeWithOthers() | ||
835 | +{ | ||
836 | + return m_IsMergeWithOthers; | ||
837 | +} | ||
838 | +//Used for merge cells | ||
839 | +//by Huang Wei | ||
840 | +bool CGridCellBase::IsShow() | ||
841 | +{ | ||
842 | + return !m_Hide; | ||
843 | +} | ||
844 | +//Used for merge cells | ||
845 | +//by Huang Wei | ||
846 | +void CGridCellBase::UnMerge() | ||
847 | +{ | ||
848 | + m_Hide=false; | ||
849 | + m_MergeRange.Set(); | ||
850 | + m_IsMergeWithOthers=false; | ||
851 | + m_MergeCellID.row=-1; | ||
852 | + m_MergeCellID.col=-1; | ||
853 | +} |
central_clearing_system/ETradeClient/mfc_ui/GridCellBase.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | // | 3 | // |
4 | // MFC Grid Control - Grid cell base class header file | 4 | // MFC Grid Control - Grid cell base class header file |
5 | // | 5 | // |
6 | -// Written by Chris Maunder <chris@codeproject.com> | ||
7 | -// Copyright (c) 1998-2005. All Rights Reserved. | 6 | +// Written by Chris Maunder <cmaunder@mail.com> |
7 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
8 | // | 8 | // |
9 | // This code may be used in compiled form in any way you desire. This | 9 | // This code may be used in compiled form in any way you desire. This |
10 | // file may be redistributed unmodified by any means PROVIDING it is | 10 | // file may be redistributed unmodified by any means PROVIDING it is |
@@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
25 | #if !defined(AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_) | 25 | #if !defined(AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_) |
26 | #define AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_ | 26 | #define AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_ |
27 | 27 | ||
28 | +#include "CellRange.h" // Added by ClassView | ||
28 | #if _MSC_VER >= 1000 | 29 | #if _MSC_VER >= 1000 |
29 | #pragma once | 30 | #pragma once |
30 | #endif // _MSC_VER >= 1000 | 31 | #endif // _MSC_VER >= 1000 |
@@ -127,10 +128,13 @@ public: | @@ -127,10 +128,13 @@ public: | ||
127 | 128 | ||
128 | // Operators | 129 | // Operators |
129 | public: | 130 | public: |
130 | - virtual void operator=(const CGridCellBase& cell); | 131 | + virtual void operator=( CGridCellBase& cell); |
131 | 132 | ||
132 | // Operations | 133 | // Operations |
133 | public: | 134 | public: |
135 | + bool IsMerged(); | ||
136 | + void SetMergeRange(CCellRange range); | ||
137 | + void Show(bool IsShow); | ||
134 | virtual void Reset(); | 138 | virtual void Reset(); |
135 | 139 | ||
136 | virtual BOOL Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd = TRUE); | 140 | virtual BOOL Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd = TRUE); |
@@ -162,8 +166,20 @@ protected: | @@ -162,8 +166,20 @@ protected: | ||
162 | virtual void OnDblClick( CPoint PointCellRelative); | 166 | virtual void OnDblClick( CPoint PointCellRelative); |
163 | virtual BOOL OnSetCursor(); | 167 | virtual BOOL OnSetCursor(); |
164 | 168 | ||
169 | +public: | ||
170 | + void UnMerge(); | ||
171 | + virtual bool IsShow() ; | ||
172 | + virtual CCellRange GetMergeRange(); | ||
173 | + virtual bool IsMergeWithOthers(); | ||
174 | + virtual CCellID GetMergeCellID(); | ||
175 | + virtual void SetMergeCellID(CCellID cell); | ||
165 | protected: | 176 | protected: |
166 | DWORD m_nState; // Cell state (selected/focus etc) | 177 | DWORD m_nState; // Cell state (selected/focus etc) |
178 | +private: | ||
179 | + CCellRange m_MergeRange; | ||
180 | + bool m_IsMergeWithOthers; | ||
181 | + CCellID m_MergeCellID; | ||
182 | + bool m_Hide; | ||
167 | }; | 183 | }; |
168 | 184 | ||
169 | //{{AFX_INSERT_LOCATION}} | 185 | //{{AFX_INSERT_LOCATION}} |
central_clearing_system/ETradeClient/mfc_ui/GridCtrl.cpp
1 | // GridCtrl.cpp : implementation file | 1 | // GridCtrl.cpp : implementation file |
2 | // | 2 | // |
3 | -// MFC Grid Control v2.26 | 3 | +// MFC Grid Control v2.24 |
4 | +// | ||
5 | +// Written by Chris Maunder <cmaunder@mail.com> | ||
6 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
4 | // | 7 | // |
5 | -// Written by Chris Maunder <chris@codeproject.com> | ||
6 | -// Copyright (c) 1998-2005. All Rights Reserved. | ||
7 | -/ | ||
8 | // The code contained in this file was based on the original | 8 | // The code contained in this file was based on the original |
9 | // WorldCom Grid control written by Joe Willcoxson, | 9 | // WorldCom Grid control written by Joe Willcoxson, |
10 | // mailto:chinajoe@aol.com | 10 | // mailto:chinajoe@aol.com |
@@ -94,25 +94,18 @@ | @@ -94,25 +94,18 @@ | ||
94 | // - WS_EX_CLIENTEDGE style now implicit | 94 | // - WS_EX_CLIENTEDGE style now implicit |
95 | // | 95 | // |
96 | // [ Only the latest version and major version changes will be shown ] | 96 | // [ Only the latest version and major version changes will be shown ] |
97 | -//// | ||
98 | -// 2.25 13 Mar 2004 - Chris Maunder | ||
99 | -// - Minor changes so it will compile in VS.NET (inc. Whidbey) | ||
100 | -// - Fixed minor bug in EnsureVisible - Junlin Xu | ||
101 | -// - Changed AfxGetInstanceHandle for AfxGetResourceHandle in RegisterWindowClass | ||
102 | -// - Various changes thanks to Yogurt | ||
103 | // | 97 | // |
104 | -// 2.26 13 Dec 2005 - Pierre Couderc | ||
105 | -// - Added sort in Virtual mode | ||
106 | -// - Change row/column order programatically or via drag and drop | ||
107 | -// - Added save/restore layer (for undoing row/column order changes) | 98 | +// 2.24 13 Jul 2002 - Chris Maunder |
99 | +// - Optimised OnDraw for invisible cells. | ||
108 | // | 100 | // |
109 | // TODO: 1) Implement sparse grids (super easy now) | 101 | // TODO: 1) Implement sparse grids (super easy now) |
110 | // 2) Fix it so that as you drag select, the speed of selection increases | 102 | // 2) Fix it so that as you drag select, the speed of selection increases |
111 | // with time. | 103 | // with time. |
112 | // 3) Scrolling is still a little dodgy (too much grey area). I know there | 104 | // 3) Scrolling is still a little dodgy (too much grey area). I know there |
113 | // is a simple fix but it's been a low priority | 105 | // is a simple fix but it's been a low priority |
106 | +// 4) Get some sleep | ||
114 | // | 107 | // |
115 | -// ISSUES: 1) WindowFromPoint seems to do weird things in W2K. Causing problems for | 108 | +// ISSUES: 2) WindowFromPoint seems to do weird things in W2K. Causing problems for |
116 | // the rigt-click-on-titletip code. | 109 | // the rigt-click-on-titletip code. |
117 | // | 110 | // |
118 | ///////////////////////////////////////////////////////////////////////////// | 111 | ///////////////////////////////////////////////////////////////////////////// |
@@ -120,7 +113,6 @@ | @@ -120,7 +113,6 @@ | ||
120 | #include "stdafx.h" | 113 | #include "stdafx.h" |
121 | #include "MemDC.h" | 114 | #include "MemDC.h" |
122 | #include "GridCtrl.h" | 115 | #include "GridCtrl.h" |
123 | -#include <algorithm> | ||
124 | 116 | ||
125 | // OLE stuff for clipboard operations | 117 | // OLE stuff for clipboard operations |
126 | #include <afxadv.h> // For CSharedFile | 118 | #include <afxadv.h> // For CSharedFile |
@@ -215,7 +207,6 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | @@ -215,7 +207,6 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | ||
215 | m_nCols = 0; | 207 | m_nCols = 0; |
216 | m_nFixedRows = 0; | 208 | m_nFixedRows = 0; |
217 | m_nFixedCols = 0; | 209 | m_nFixedCols = 0; |
218 | - m_InDestructor = false; | ||
219 | 210 | ||
220 | m_bVirtualMode = FALSE; | 211 | m_bVirtualMode = FALSE; |
221 | m_pfnCallback = NULL; | 212 | m_pfnCallback = NULL; |
@@ -259,7 +250,7 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | @@ -259,7 +250,7 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | ||
259 | m_bAscending = TRUE; // sorting stuff | 250 | m_bAscending = TRUE; // sorting stuff |
260 | m_nSortColumn = -1; | 251 | m_nSortColumn = -1; |
261 | m_pfnCompare = NULL; | 252 | m_pfnCompare = NULL; |
262 | - m_pfnVirtualCompare = NULL; | 253 | + |
263 | m_nAutoSizeColumnStyle = GVS_BOTH; // Autosize grid using header and data info | 254 | m_nAutoSizeColumnStyle = GVS_BOTH; // Autosize grid using header and data info |
264 | 255 | ||
265 | m_nTimerID = 0; // For drag-selection | 256 | m_nTimerID = 0; // For drag-selection |
@@ -271,10 +262,7 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | @@ -271,10 +262,7 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | ||
271 | m_bAllowDragAndDrop = FALSE; // for drag and drop - EFW - off by default | 262 | m_bAllowDragAndDrop = FALSE; // for drag and drop - EFW - off by default |
272 | m_bTrackFocusCell = TRUE; // Track Focus cell? | 263 | m_bTrackFocusCell = TRUE; // Track Focus cell? |
273 | m_bFrameFocus = TRUE; // Frame the selected cell? | 264 | m_bFrameFocus = TRUE; // Frame the selected cell? |
274 | - m_AllowReorderColumn = false; | ||
275 | - m_QuitFocusOnTab = false; | ||
276 | - m_AllowSelectRowInFixedCol = false; | ||
277 | - m_bDragRowMode = TRUE; // allow to drop a line over another one to change row order | 265 | + |
278 | m_pRtcDefault = RUNTIME_CLASS(CGridCell); | 266 | m_pRtcDefault = RUNTIME_CLASS(CGridCell); |
279 | 267 | ||
280 | SetupDefaultCells(); | 268 | SetupDefaultCells(); |
@@ -303,7 +291,6 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | @@ -303,7 +291,6 @@ CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols) | ||
303 | 291 | ||
304 | CGridCtrl::~CGridCtrl() | 292 | CGridCtrl::~CGridCtrl() |
305 | { | 293 | { |
306 | - m_InDestructor = true; | ||
307 | DeleteAllItems(); | 294 | DeleteAllItems(); |
308 | 295 | ||
309 | #ifndef GRIDCONTROL_NO_TITLETIPS | 296 | #ifndef GRIDCONTROL_NO_TITLETIPS |
@@ -325,8 +312,8 @@ CGridCtrl::~CGridCtrl() | @@ -325,8 +312,8 @@ CGridCtrl::~CGridCtrl() | ||
325 | BOOL CGridCtrl::RegisterWindowClass() | 312 | BOOL CGridCtrl::RegisterWindowClass() |
326 | { | 313 | { |
327 | WNDCLASS wndcls; | 314 | WNDCLASS wndcls; |
328 | - //HINSTANCE hInst = AfxGetInstanceHandle(); | ||
329 | - HINSTANCE hInst = AfxGetResourceHandle(); | 315 | + HINSTANCE hInst = AfxGetInstanceHandle(); |
316 | + //HINSTANCE hInst = AfxGetResourceHandle(); | ||
330 | 317 | ||
331 | if (!(::GetClassInfo(hInst, GRIDCTRL_CLASSNAME, &wndcls))) | 318 | if (!(::GetClassInfo(hInst, GRIDCTRL_CLASSNAME, &wndcls))) |
332 | { | 319 | { |
@@ -429,9 +416,6 @@ BOOL CGridCtrl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwSty | @@ -429,9 +416,6 @@ BOOL CGridCtrl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwSty | ||
429 | return TRUE; | 416 | return TRUE; |
430 | } | 417 | } |
431 | 418 | ||
432 | - | ||
433 | - | ||
434 | - | ||
435 | void CGridCtrl::SetupDefaultCells() | 419 | void CGridCtrl::SetupDefaultCells() |
436 | { | 420 | { |
437 | m_cellDefault.SetGrid(this); // Normal editable cell | 421 | m_cellDefault.SetGrid(this); // Normal editable cell |
@@ -523,42 +507,6 @@ LRESULT CGridCtrl::SendCacheHintToParent(const CCellRange& range) const | @@ -523,42 +507,6 @@ LRESULT CGridCtrl::SendCacheHintToParent(const CCellRange& range) const | ||
523 | return 0; | 507 | return 0; |
524 | } | 508 | } |
525 | 509 | ||
526 | -#define LAYER_SIGNATURE (0x5FD4E64) | ||
527 | -int CGridCtrl::GetLayer(int** pLayer) // used to save and restore order of columns | ||
528 | -{ // gives back the size of the area (do not forget to delete pLayer) | ||
529 | - int Length = 2+GetColumnCount()*2; | ||
530 | - int *Layer = new int[Length]; // the caller is supposed to delete it | ||
531 | - Layer[0]= LAYER_SIGNATURE; | ||
532 | - Layer[1]= GetColumnCount(); | ||
533 | - memcpy(&Layer[2], &m_arColOrder[0], GetColumnCount()*sizeof(int)); | ||
534 | - memcpy(&Layer[2+GetColumnCount()], &m_arColWidths[0], GetColumnCount()*sizeof(int)); | ||
535 | - *pLayer = Layer; | ||
536 | - return Length; | ||
537 | -} | ||
538 | -void CGridCtrl::SetLayer(int* pLayer) | ||
539 | -{ // coming from a previous GetLayer (ignored if not same number of column, or the same revision number) | ||
540 | - if(pLayer[0] != LAYER_SIGNATURE) return; | ||
541 | - if(pLayer[1] != GetColumnCount()) return; | ||
542 | -/* TRACE(" %d == %d \n",m_arColOrder[0],pLayer[2]); | ||
543 | - TRACE(" %d == %d \n",m_arColOrder[1],pLayer[3]); | ||
544 | - TRACE(" %d == %d \n",m_arColOrder[2],pLayer[4]); | ||
545 | - TRACE(" %d == %d \n",m_arColWidths[0],pLayer[2+3]); | ||
546 | - TRACE(" %d == %d \n",m_arColWidths[1],pLayer[3+3]); | ||
547 | - TRACE(" %d == %d \n",m_arColWidths[2],pLayer[4+3]); | ||
548 | - TRACE(" %d == %d \n",GetColumnCount(),3); | ||
549 | - | ||
550 | - | ||
551 | - ASSERT(m_arColOrder[0]==pLayer[2]); | ||
552 | - ASSERT(m_arColOrder[1]==pLayer[3]); | ||
553 | - ASSERT(m_arColOrder[2]==pLayer[4]); | ||
554 | - ASSERT(m_arColWidths[0]==pLayer[2+3]); | ||
555 | - ASSERT(m_arColWidths[1]==pLayer[3+3]); | ||
556 | - ASSERT(m_arColWidths[2]==pLayer[4+3]); | ||
557 | - ASSERT(GetColumnCount()==3); | ||
558 | -*/ memcpy(&m_arColOrder[0],&pLayer[2], GetColumnCount()*sizeof(int)); | ||
559 | - memcpy(&m_arColWidths[0],&pLayer[2+GetColumnCount()], GetColumnCount()*sizeof(int)); | ||
560 | -} | ||
561 | - | ||
562 | BEGIN_MESSAGE_MAP(CGridCtrl, CWnd) | 510 | BEGIN_MESSAGE_MAP(CGridCtrl, CWnd) |
563 | //EFW - Added ON_WM_RBUTTONUP | 511 | //EFW - Added ON_WM_RBUTTONUP |
564 | //{{AFX_MSG_MAP(CGridCtrl) | 512 | //{{AFX_MSG_MAP(CGridCtrl) |
@@ -672,8 +620,8 @@ void CGridCtrl::EraseBkgnd(CDC* pDC) | @@ -672,8 +620,8 @@ void CGridCtrl::EraseBkgnd(CDC* pDC) | ||
672 | // Draw non-fixed cell background | 620 | // Draw non-fixed cell background |
673 | if (rect.IntersectRect(VisRect, ClipRect)) | 621 | if (rect.IntersectRect(VisRect, ClipRect)) |
674 | { | 622 | { |
675 | - CRect CellRect(__max(nFixedColumnWidth, rect.left), | ||
676 | - __max(nFixedRowHeight, rect.top), | 623 | + CRect CellRect(max(nFixedColumnWidth, rect.left), |
624 | + max(nFixedRowHeight, rect.top), | ||
677 | rect.right, rect.bottom); | 625 | rect.right, rect.bottom); |
678 | pDC->FillRect(CellRect, &TextBack); | 626 | pDC->FillRect(CellRect, &TextBack); |
679 | } | 627 | } |
@@ -910,6 +858,7 @@ void CGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | @@ -910,6 +858,7 @@ void CGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
910 | CWnd::OnKeyDown(nChar, nRepCnt, nFlags); | 858 | CWnd::OnKeyDown(nChar, nRepCnt, nFlags); |
911 | return; | 859 | return; |
912 | } | 860 | } |
861 | + | ||
913 | CCellID next = m_idCurrentCell; | 862 | CCellID next = m_idCurrentCell; |
914 | BOOL bChangeLine = FALSE; | 863 | BOOL bChangeLine = FALSE; |
915 | BOOL bHorzScrollAction = FALSE; | 864 | BOOL bHorzScrollAction = FALSE; |
@@ -922,10 +871,6 @@ void CGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | @@ -922,10 +871,6 @@ void CGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
922 | case 'A': | 871 | case 'A': |
923 | OnEditSelectAll(); | 872 | OnEditSelectAll(); |
924 | break; | 873 | break; |
925 | - case 'k': // This is ctrl+ on french keyboard, may need to be better processed for other locales | ||
926 | - AutoSizeColumns(); | ||
927 | - Invalidate(); | ||
928 | - break; | ||
929 | #ifndef GRIDCONTROL_NO_CLIPBOARD | 874 | #ifndef GRIDCONTROL_NO_CLIPBOARD |
930 | case 'X': | 875 | case 'X': |
931 | OnEditCut(); | 876 | OnEditCut(); |
@@ -991,13 +936,6 @@ void CGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | @@ -991,13 +936,6 @@ void CGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) | ||
991 | } | 936 | } |
992 | else if (nChar == VK_RIGHT || (nChar == VK_TAB && !IsSHIFTpressed()) ) | 937 | else if (nChar == VK_RIGHT || (nChar == VK_TAB && !IsSHIFTpressed()) ) |
993 | { | 938 | { |
994 | - if( (nChar == VK_TAB) && m_QuitFocusOnTab ) | ||
995 | - { | ||
996 | - CDialog* p= (CDialog*) GetParent(); | ||
997 | - if(p) p->NextDlgCtrl(); | ||
998 | - return; | ||
999 | - | ||
1000 | - } | ||
1001 | // don't let user go to a hidden column | 939 | // don't let user go to a hidden column |
1002 | bFoundVisible = FALSE; | 940 | bFoundVisible = FALSE; |
1003 | iOrig = next.col; | 941 | iOrig = next.col; |
@@ -1317,7 +1255,7 @@ LRESULT CGridCtrl::OnImeChar(WPARAM wCharCode, LPARAM) | @@ -1317,7 +1255,7 @@ LRESULT CGridCtrl::OnImeChar(WPARAM wCharCode, LPARAM) | ||
1317 | { | 1255 | { |
1318 | // EFW - BUG FIX | 1256 | // EFW - BUG FIX |
1319 | if (!IsCTRLpressed() && m_MouseMode == MOUSE_NOTHING && wCharCode != VK_ESCAPE) | 1257 | if (!IsCTRLpressed() && m_MouseMode == MOUSE_NOTHING && wCharCode != VK_ESCAPE) |
1320 | - OnEditCell(m_idCurrentCell.row, m_idCurrentCell.col, CPoint( -1, -1), (UINT)wCharCode); | 1258 | + OnEditCell(m_idCurrentCell.row, m_idCurrentCell.col, CPoint( -1, -1), wCharCode); |
1321 | return 0; | 1259 | return 0; |
1322 | } | 1260 | } |
1323 | 1261 | ||
@@ -1347,8 +1285,8 @@ void CGridCtrl::OnEndInPlaceEdit(NMHDR* pNMHDR, LRESULT* pResult) | @@ -1347,8 +1285,8 @@ void CGridCtrl::OnEndInPlaceEdit(NMHDR* pNMHDR, LRESULT* pResult) | ||
1347 | case VK_PRIOR: | 1285 | case VK_PRIOR: |
1348 | case VK_HOME: | 1286 | case VK_HOME: |
1349 | case VK_END: | 1287 | case VK_END: |
1350 | - OnKeyDown((UINT)pgvItem->lParam, 0, 0); | ||
1351 | - OnEditCell(m_idCurrentCell.row, m_idCurrentCell.col, CPoint( -1, -1), (UINT)pgvItem->lParam); | 1288 | + OnKeyDown(pgvItem->lParam, 0, 0); |
1289 | + OnEditCell(m_idCurrentCell.row, m_idCurrentCell.col, CPoint( -1, -1), pgvItem->lParam); | ||
1352 | } | 1290 | } |
1353 | 1291 | ||
1354 | *pResult = 0; | 1292 | *pResult = 0; |
@@ -1406,7 +1344,7 @@ void CGridCtrl::OnHScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | @@ -1406,7 +1344,7 @@ void CGridCtrl::OnHScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | ||
1406 | } | 1344 | } |
1407 | 1345 | ||
1408 | int xScroll = GetColumnWidth(iColToUse); | 1346 | int xScroll = GetColumnWidth(iColToUse); |
1409 | - SetScrollPos32(SB_HORZ, __max(0, scrollPos - xScroll)); | 1347 | + SetScrollPos32(SB_HORZ, max(0, scrollPos - xScroll)); |
1410 | rect.left = GetFixedColumnWidth(); | 1348 | rect.left = GetFixedColumnWidth(); |
1411 | //ScrollWindow(xScroll, 0, rect); | 1349 | //ScrollWindow(xScroll, 0, rect); |
1412 | //rect.right = rect.left + xScroll; | 1350 | //rect.right = rect.left + xScroll; |
@@ -1431,7 +1369,7 @@ void CGridCtrl::OnHScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | @@ -1431,7 +1369,7 @@ void CGridCtrl::OnHScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | ||
1431 | { | 1369 | { |
1432 | rect.left = GetFixedColumnWidth(); | 1370 | rect.left = GetFixedColumnWidth(); |
1433 | int offset = -rect.Width(); | 1371 | int offset = -rect.Width(); |
1434 | - int pos = __max(0, scrollPos + offset); | 1372 | + int pos = max(0, scrollPos + offset); |
1435 | SetScrollPos32(SB_HORZ, pos); | 1373 | SetScrollPos32(SB_HORZ, pos); |
1436 | rect.left = GetFixedColumnWidth(); | 1374 | rect.left = GetFixedColumnWidth(); |
1437 | InvalidateRect(rect); | 1375 | InvalidateRect(rect); |
@@ -1528,7 +1466,7 @@ void CGridCtrl::OnVScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | @@ -1528,7 +1466,7 @@ void CGridCtrl::OnVScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | ||
1528 | } | 1466 | } |
1529 | 1467 | ||
1530 | int yScroll = GetRowHeight( iRowToUse); | 1468 | int yScroll = GetRowHeight( iRowToUse); |
1531 | - SetScrollPos32(SB_VERT, __max(0, scrollPos - yScroll)); | 1469 | + SetScrollPos32(SB_VERT, max(0, scrollPos - yScroll)); |
1532 | rect.top = GetFixedRowHeight(); | 1470 | rect.top = GetFixedRowHeight(); |
1533 | //ScrollWindow(0, yScroll, rect); | 1471 | //ScrollWindow(0, yScroll, rect); |
1534 | //rect.bottom = rect.top + yScroll; | 1472 | //rect.bottom = rect.top + yScroll; |
@@ -1552,7 +1490,7 @@ void CGridCtrl::OnVScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | @@ -1552,7 +1490,7 @@ void CGridCtrl::OnVScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar* | ||
1552 | { | 1490 | { |
1553 | rect.top = GetFixedRowHeight(); | 1491 | rect.top = GetFixedRowHeight(); |
1554 | int offset = -rect.Height(); | 1492 | int offset = -rect.Height(); |
1555 | - int pos = __max(0, scrollPos + offset); | 1493 | + int pos = max(0, scrollPos + offset); |
1556 | SetScrollPos32(SB_VERT, pos); | 1494 | SetScrollPos32(SB_VERT, pos); |
1557 | rect.top = GetFixedRowHeight(); | 1495 | rect.top = GetFixedRowHeight(); |
1558 | InvalidateRect(rect); | 1496 | InvalidateRect(rect); |
@@ -1632,28 +1570,106 @@ void CGridCtrl::OnDraw(CDC* pDC) | @@ -1632,28 +1570,106 @@ void CGridCtrl::OnDraw(CDC* pDC) | ||
1632 | if (GetVirtualMode()) | 1570 | if (GetVirtualMode()) |
1633 | SendCacheHintToParent(VisCellRange); | 1571 | SendCacheHintToParent(VisCellRange); |
1634 | 1572 | ||
1635 | - // draw top-left cells 0..m_nFixedRows-1, 0..m_nFixedCols-1 | ||
1636 | - rect.bottom = -1; | ||
1637 | - for (row = 0; row < m_nFixedRows; row++) | 1573 | + CPen pen; |
1574 | + pen.CreatePen(PS_SOLID, 0, m_crGridLineColour); | ||
1575 | + pDC->SelectObject(&pen); | ||
1576 | + | ||
1577 | + // draw vertical lines (drawn at ends of cells) | ||
1578 | + if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_VERT) | ||
1579 | + { | ||
1580 | + int x = nFixedColWidth; | ||
1581 | + for (col = minVisibleCol; col <= maxVisibleCol; col++) | ||
1582 | + { | ||
1583 | + if (GetColumnWidth(col) <= 0) continue; | ||
1584 | + | ||
1585 | + x += GetColumnWidth(col); | ||
1586 | + pDC->MoveTo(x-1, nFixedRowHeight); | ||
1587 | + pDC->LineTo(x-1, VisRect.bottom); | ||
1588 | + } | ||
1589 | + } | ||
1590 | + | ||
1591 | + // draw horizontal lines (drawn at bottom of each cell) | ||
1592 | + if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_HORZ) | ||
1593 | + { | ||
1594 | + int y = nFixedRowHeight; | ||
1595 | + for (row = minVisibleRow; row <= maxVisibleRow; row++) | ||
1596 | + { | ||
1597 | + if (GetRowHeight(row) <= 0) continue; | ||
1598 | + | ||
1599 | + y += GetRowHeight(row); | ||
1600 | + pDC->MoveTo(nFixedColWidth, y-1); | ||
1601 | + pDC->LineTo(VisRect.right, y-1); | ||
1602 | + } | ||
1603 | + } | ||
1604 | + | ||
1605 | + pDC->SelectStockObject(NULL_PEN); | ||
1606 | + | ||
1607 | + // draw rest of non-fixed cells | ||
1608 | + rect.bottom = nFixedRowHeight-1; | ||
1609 | + for (row = minVisibleRow; row <= maxVisibleRow; row++) | ||
1638 | { | 1610 | { |
1639 | if (GetRowHeight(row) <= 0) continue; | 1611 | if (GetRowHeight(row) <= 0) continue; |
1640 | 1612 | ||
1641 | rect.top = rect.bottom+1; | 1613 | rect.top = rect.bottom+1; |
1642 | rect.bottom = rect.top + GetRowHeight(row)-1; | 1614 | rect.bottom = rect.top + GetRowHeight(row)-1; |
1643 | - rect.right = -1; | ||
1644 | 1615 | ||
1645 | - for (col = 0; col < m_nFixedCols; col++) | 1616 | + // rect.bottom = bottom pixel of previous row |
1617 | + if (rect.top > clipRect.bottom) | ||
1618 | + break; // Gone past cliprect | ||
1619 | + if (rect.bottom < clipRect.top) | ||
1620 | + continue; // Reached cliprect yet? | ||
1621 | + | ||
1622 | + rect.right = nFixedColWidth-1; | ||
1623 | + for (col = minVisibleCol; col <= maxVisibleCol; col++) | ||
1646 | { | 1624 | { |
1647 | if (GetColumnWidth(col) <= 0) continue; | 1625 | if (GetColumnWidth(col) <= 0) continue; |
1648 | 1626 | ||
1649 | rect.left = rect.right+1; | 1627 | rect.left = rect.right+1; |
1650 | rect.right = rect.left + GetColumnWidth(col)-1; | 1628 | rect.right = rect.left + GetColumnWidth(col)-1; |
1651 | 1629 | ||
1630 | + if (rect.left > clipRect.right) | ||
1631 | + break; // gone past cliprect | ||
1632 | + if (rect.right < clipRect.left) | ||
1633 | + continue; // Reached cliprect yet? | ||
1634 | + | ||
1652 | pCell = GetCell(row, col); | 1635 | pCell = GetCell(row, col); |
1636 | + | ||
1637 | + // TRACE(_T("Cell %d,%d type: %s\n"), row, col, pCell->GetRuntimeClass()->m_lpszClassName); | ||
1653 | if (pCell) | 1638 | if (pCell) |
1654 | { | 1639 | { |
1655 | - pCell->SetCoords(row,col); | ||
1656 | - pCell->Draw(pDC, row, col, rect, FALSE); | 1640 | + //Used for merge cells |
1641 | + //by Huang Wei | ||
1642 | + | ||
1643 | + if(!pCell->IsMerged()) | ||
1644 | + { | ||
1645 | + if(!pCell->IsMergeWithOthers()) | ||
1646 | + { | ||
1647 | + pCell->SetCoords(row,col); | ||
1648 | + pCell->Draw(pDC, row, col, rect, FALSE); | ||
1649 | + } | ||
1650 | + else | ||
1651 | + { | ||
1652 | + CGridCellBase* pMergedCell=GetCell(pCell->GetMergeCellID()); | ||
1653 | + CRect mergerect=rect; | ||
1654 | + if(GetCellRangeRect(pMergedCell->m_MergeRange,&mergerect)) | ||
1655 | + { | ||
1656 | + mergerect.DeflateRect(0,0,1,1); | ||
1657 | + pMergedCell->SetCoords(pCell->GetMergeCellID().row,pCell->GetMergeCellID().col); | ||
1658 | + pMergedCell->Draw(pDC, pCell->GetMergeCellID().row,pCell->GetMergeCellID().col, mergerect, TRUE); | ||
1659 | + } | ||
1660 | + } | ||
1661 | + } | ||
1662 | + else | ||
1663 | + { | ||
1664 | + CRect mergerect=rect; | ||
1665 | + | ||
1666 | + if(GetCellRangeRect(pCell->m_MergeRange,&mergerect)) | ||
1667 | + { | ||
1668 | + mergerect.DeflateRect(0,0,1,1); | ||
1669 | + pCell->SetCoords(row,col); | ||
1670 | + pCell->Draw(pDC, row, col, mergerect, TRUE); | ||
1671 | + } | ||
1672 | + } | ||
1657 | } | 1673 | } |
1658 | } | 1674 | } |
1659 | } | 1675 | } |
@@ -1687,10 +1703,46 @@ void CGridCtrl::OnDraw(CDC* pDC) | @@ -1687,10 +1703,46 @@ void CGridCtrl::OnDraw(CDC* pDC) | ||
1687 | continue; // Reached cliprect yet? | 1703 | continue; // Reached cliprect yet? |
1688 | 1704 | ||
1689 | pCell = GetCell(row, col); | 1705 | pCell = GetCell(row, col); |
1706 | + // if (pCell) | ||
1707 | + //{ | ||
1708 | + // pCell->SetCoords(row,col); | ||
1709 | + // pCell->Draw(pDC, row, col, rect, TRUE); | ||
1710 | + //} | ||
1690 | if (pCell) | 1711 | if (pCell) |
1691 | { | 1712 | { |
1692 | - pCell->SetCoords(row,col); | ||
1693 | - pCell->Draw(pDC, row, col, rect, FALSE); | 1713 | + //Used for merge cells |
1714 | + //by Huang Wei | ||
1715 | + | ||
1716 | + if(!pCell->IsMerged()) | ||
1717 | + { | ||
1718 | + if(!pCell->IsMergeWithOthers()) | ||
1719 | + { | ||
1720 | + pCell->SetCoords(row,col); | ||
1721 | + pCell->Draw(pDC, row, col, rect, FALSE); | ||
1722 | + } | ||
1723 | + else | ||
1724 | + { | ||
1725 | + CGridCellBase* pMergedCell=GetCell(pCell->GetMergeCellID()); | ||
1726 | + CRect mergerect=rect; | ||
1727 | + if(GetCellRangeRect(pMergedCell->m_MergeRange,&mergerect)) | ||
1728 | + { | ||
1729 | + mergerect.DeflateRect(0,0,1,1); | ||
1730 | + pMergedCell->SetCoords(pCell->GetMergeCellID().row,pCell->GetMergeCellID().col); | ||
1731 | + pMergedCell->Draw(pDC, pCell->GetMergeCellID().row,pCell->GetMergeCellID().col, mergerect, TRUE); | ||
1732 | + } | ||
1733 | + } | ||
1734 | + } | ||
1735 | + else | ||
1736 | + { | ||
1737 | + CRect mergerect=rect; | ||
1738 | + | ||
1739 | + if(GetCellRangeRect(pCell->m_MergeRange,&mergerect)) | ||
1740 | + { | ||
1741 | + mergerect.DeflateRect(0,0,1,1); | ||
1742 | + pCell->SetCoords(row,col); | ||
1743 | + pCell->Draw(pDC, row, col, mergerect, TRUE); | ||
1744 | + } | ||
1745 | + } | ||
1694 | } | 1746 | } |
1695 | } | 1747 | } |
1696 | } | 1748 | } |
@@ -1724,44 +1776,70 @@ void CGridCtrl::OnDraw(CDC* pDC) | @@ -1724,44 +1776,70 @@ void CGridCtrl::OnDraw(CDC* pDC) | ||
1724 | continue; // Reached cliprect yet? | 1776 | continue; // Reached cliprect yet? |
1725 | 1777 | ||
1726 | pCell = GetCell(row, col); | 1778 | pCell = GetCell(row, col); |
1779 | + // if (pCell) | ||
1780 | + //{ | ||
1781 | + // pCell->SetCoords(row,col); | ||
1782 | + // pCell->Draw(pDC, row, col, rect, TRUE); | ||
1783 | + //} | ||
1727 | if (pCell) | 1784 | if (pCell) |
1728 | { | 1785 | { |
1729 | - pCell->SetCoords(row,col); | ||
1730 | - pCell->Draw(pDC, row, col, rect, FALSE); | 1786 | + //Used for merge cells |
1787 | + //by Huang Wei | ||
1788 | + | ||
1789 | + if(!pCell->IsMerged()) | ||
1790 | + { | ||
1791 | + if(!pCell->IsMergeWithOthers()) | ||
1792 | + { | ||
1793 | + pCell->SetCoords(row,col); | ||
1794 | + pCell->Draw(pDC, row, col, rect, FALSE); | ||
1795 | + } | ||
1796 | + else | ||
1797 | + { | ||
1798 | + CGridCellBase* pMergedCell=GetCell(pCell->GetMergeCellID()); | ||
1799 | + CRect mergerect=rect; | ||
1800 | + if(GetCellRangeRect(pMergedCell->m_MergeRange,&mergerect)) | ||
1801 | + { | ||
1802 | + mergerect.DeflateRect(0,0,1,1); | ||
1803 | + pMergedCell->SetCoords(pCell->GetMergeCellID().row,pCell->GetMergeCellID().col); | ||
1804 | + pMergedCell->Draw(pDC, pCell->GetMergeCellID().row,pCell->GetMergeCellID().col, mergerect, TRUE); | ||
1805 | + } | ||
1806 | + } | ||
1807 | + } | ||
1808 | + else | ||
1809 | + { | ||
1810 | + CRect mergerect=rect; | ||
1811 | + | ||
1812 | + if(GetCellRangeRect(pCell->m_MergeRange,&mergerect)) | ||
1813 | + { | ||
1814 | + mergerect.DeflateRect(0,0,1,1); | ||
1815 | + pCell->SetCoords(row,col); | ||
1816 | + pCell->Draw(pDC, row, col, mergerect, TRUE); | ||
1817 | + } | ||
1818 | + } | ||
1731 | } | 1819 | } |
1732 | } | 1820 | } |
1733 | } | 1821 | } |
1734 | 1822 | ||
1735 | - // draw rest of non-fixed cells | ||
1736 | - rect.bottom = nFixedRowHeight-1; | ||
1737 | - for (row = minVisibleRow; row <= maxVisibleRow; row++) | 1823 | + |
1824 | +/* | ||
1825 | + // draw top-left cells 0..m_nFixedRows-1, 0..m_nFixedCols-1 | ||
1826 | + rect.bottom = -1; | ||
1827 | + for (row = 0; row < m_nFixedRows; row++) | ||
1738 | { | 1828 | { |
1739 | if (GetRowHeight(row) <= 0) continue; | 1829 | if (GetRowHeight(row) <= 0) continue; |
1740 | 1830 | ||
1741 | rect.top = rect.bottom+1; | 1831 | rect.top = rect.bottom+1; |
1742 | rect.bottom = rect.top + GetRowHeight(row)-1; | 1832 | rect.bottom = rect.top + GetRowHeight(row)-1; |
1833 | + rect.right = -1; | ||
1743 | 1834 | ||
1744 | - // rect.bottom = bottom pixel of previous row | ||
1745 | - if (rect.top > clipRect.bottom) | ||
1746 | - break; // Gone past cliprect | ||
1747 | - if (rect.bottom < clipRect.top) | ||
1748 | - continue; // Reached cliprect yet? | ||
1749 | - | ||
1750 | - rect.right = nFixedColWidth-1; | ||
1751 | - for (col = minVisibleCol; col <= maxVisibleCol; col++) | 1835 | + for (col = 0; col < m_nFixedCols; col++) |
1752 | { | 1836 | { |
1753 | if (GetColumnWidth(col) <= 0) continue; | 1837 | if (GetColumnWidth(col) <= 0) continue; |
1754 | 1838 | ||
1755 | rect.left = rect.right+1; | 1839 | rect.left = rect.right+1; |
1756 | rect.right = rect.left + GetColumnWidth(col)-1; | 1840 | rect.right = rect.left + GetColumnWidth(col)-1; |
1757 | 1841 | ||
1758 | - if (rect.left > clipRect.right) | ||
1759 | - break; // gone past cliprect | ||
1760 | - if (rect.right < clipRect.left) | ||
1761 | - continue; // Reached cliprect yet? | ||
1762 | - | ||
1763 | pCell = GetCell(row, col); | 1842 | pCell = GetCell(row, col); |
1764 | - // TRACE(_T("Cell %d,%d type: %s\n"), row, col, pCell->GetRuntimeClass()->m_lpszClassName); | ||
1765 | if (pCell) | 1843 | if (pCell) |
1766 | { | 1844 | { |
1767 | pCell->SetCoords(row,col); | 1845 | pCell->SetCoords(row,col); |
@@ -1769,41 +1847,70 @@ void CGridCtrl::OnDraw(CDC* pDC) | @@ -1769,41 +1847,70 @@ void CGridCtrl::OnDraw(CDC* pDC) | ||
1769 | } | 1847 | } |
1770 | } | 1848 | } |
1771 | } | 1849 | } |
1850 | +*/ | ||
1772 | 1851 | ||
1773 | 1852 | ||
1774 | - CPen pen; | ||
1775 | - pen.CreatePen(PS_SOLID, 0, m_crGridLineColour); | ||
1776 | - pDC->SelectObject(&pen); | ||
1777 | - | ||
1778 | - // draw vertical lines (drawn at ends of cells) | ||
1779 | - if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_VERT) | ||
1780 | - { | ||
1781 | - int x = nFixedColWidth; | ||
1782 | - for (col = minVisibleCol; col <= maxVisibleCol; col++) | ||
1783 | - { | ||
1784 | - if (GetColumnWidth(col) <= 0) continue; | 1853 | + // draw top-left cells 0..m_nFixedRows-1, 0..m_nFixedCols-1 |
1854 | + rect.bottom = -1; | ||
1855 | + for (row = 0; row < m_nFixedRows; row++) | ||
1856 | + { | ||
1857 | + if (GetRowHeight(row) <= 0) continue; | ||
1785 | 1858 | ||
1786 | - x += GetColumnWidth(col); | ||
1787 | - pDC->MoveTo(x-1, nFixedRowHeight); | ||
1788 | - pDC->LineTo(x-1, VisRect.bottom); | ||
1789 | - } | ||
1790 | - } | 1859 | + rect.top = rect.bottom+1; |
1860 | + rect.bottom = rect.top + GetRowHeight(row)-1; | ||
1861 | + rect.right = -1; | ||
1791 | 1862 | ||
1792 | - // draw horizontal lines (drawn at bottom of each cell) | ||
1793 | - if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_HORZ) | ||
1794 | - { | ||
1795 | - int y = nFixedRowHeight; | ||
1796 | - for (row = minVisibleRow; row <= maxVisibleRow; row++) | ||
1797 | - { | ||
1798 | - if (GetRowHeight(row) <= 0) continue; | 1863 | + for (col = 0; col < m_nFixedCols; col++) |
1864 | + { | ||
1865 | + if (GetColumnWidth(col) <= 0) continue; | ||
1866 | + | ||
1867 | + rect.left = rect.right+1; | ||
1868 | + rect.right = rect.left + GetColumnWidth(col)-1; | ||
1869 | + | ||
1870 | + pCell = GetCell(row, col); | ||
1871 | + // if (pCell) | ||
1872 | + //{ | ||
1873 | + //pCell->SetCoords(row,col); | ||
1874 | + //pCell->Draw(pDC, row, col, rect, FALSE); | ||
1875 | + //} | ||
1876 | + if (pCell) | ||
1877 | + { | ||
1878 | + //Used for merge cells by Huang Wei | ||
1879 | + //bugfix by Luther Bruck | ||
1799 | 1880 | ||
1800 | - y += GetRowHeight(row); | ||
1801 | - pDC->MoveTo(nFixedColWidth, y-1); | ||
1802 | - pDC->LineTo(VisRect.right, y-1); | ||
1803 | - } | ||
1804 | - } | 1881 | + if(!pCell->IsMerged()) |
1882 | + { | ||
1883 | + if(!pCell->IsMergeWithOthers()) | ||
1884 | + { | ||
1885 | + pCell->SetCoords(row,col); | ||
1886 | + pCell->Draw(pDC, row, col, rect, FALSE); | ||
1887 | + } | ||
1888 | + else | ||
1889 | + { | ||
1890 | + CGridCellBase* pMergedCell=GetCell(pCell->GetMergeCellID()); | ||
1891 | + CRect mergerect=rect; | ||
1892 | + if(GetCellRangeRect(pMergedCell->m_MergeRange,&mergerect)) | ||
1893 | + { | ||
1894 | + mergerect.DeflateRect(0,0,1,1); | ||
1895 | + pMergedCell->SetCoords(pCell->GetMergeCellID().row,pCell->GetMergeCellID().col); | ||
1896 | + pMergedCell->Draw(pDC, pCell->GetMergeCellID().row,pCell->GetMergeCellID().col, mergerect, TRUE); | ||
1897 | + } | ||
1898 | + } | ||
1899 | + } | ||
1900 | + else | ||
1901 | + { | ||
1902 | + CRect mergerect=rect; | ||
1805 | 1903 | ||
1806 | - pDC->SelectStockObject(NULL_PEN); | 1904 | + if(GetCellRangeRect(pCell->m_MergeRange,&mergerect)) |
1905 | + { | ||
1906 | + mergerect.DeflateRect(0,0,1,1); | ||
1907 | + pCell->SetCoords(row,col); | ||
1908 | + pCell->Draw(pDC, row, col, mergerect, TRUE); | ||
1909 | + } | ||
1910 | + } | ||
1911 | + } | ||
1912 | + } | ||
1913 | + } | ||
1807 | 1914 | ||
1808 | // Let parent know it can discard it's data if it needs to. | 1915 | // Let parent know it can discard it's data if it needs to. |
1809 | if (GetVirtualMode()) | 1916 | if (GetVirtualMode()) |
@@ -2047,24 +2154,18 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | @@ -2047,24 +2154,18 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | ||
2047 | pDC = GetDC(); | 2154 | pDC = GetDC(); |
2048 | 2155 | ||
2049 | // Only redraw visible cells | 2156 | // Only redraw visible cells |
2050 | - CCellRange VisCellRange, FixedVisCellRange; | 2157 | + CCellRange VisCellRange; |
2051 | if (IsWindow(GetSafeHwnd())) | 2158 | if (IsWindow(GetSafeHwnd())) |
2052 | - | ||
2053 | - { | ||
2054 | VisCellRange = GetVisibleNonFixedCellRange(); | 2159 | VisCellRange = GetVisibleNonFixedCellRange(); |
2055 | - FixedVisCellRange = GetVisibleFixedCellRange(); | ||
2056 | - } | ||
2057 | 2160 | ||
2058 | // EFW - Bug fix - Don't allow selection of fixed rows | 2161 | // EFW - Bug fix - Don't allow selection of fixed rows |
2059 | - int Left= (m_AllowSelectRowInFixedCol ? 0 : GetFixedColumnCount()); | ||
2060 | - | ||
2061 | if(nMinRow >= 0 && nMinRow < GetFixedRowCount()) | 2162 | if(nMinRow >= 0 && nMinRow < GetFixedRowCount()) |
2062 | nMinRow = GetFixedRowCount(); | 2163 | nMinRow = GetFixedRowCount(); |
2063 | if(nMaxRow >= 0 && nMaxRow < GetFixedRowCount()) | 2164 | if(nMaxRow >= 0 && nMaxRow < GetFixedRowCount()) |
2064 | nMaxRow = GetFixedRowCount(); | 2165 | nMaxRow = GetFixedRowCount(); |
2065 | - if(nMinCol >= 0 && nMinCol < Left) | 2166 | + if(nMinCol >= 0 && nMinCol < GetFixedColumnCount()) |
2066 | nMinCol = GetFixedColumnCount(); | 2167 | nMinCol = GetFixedColumnCount(); |
2067 | - if(nMaxCol >= 0 && nMaxCol < Left) | 2168 | + if(nMaxCol >= 0 && nMaxCol < GetFixedColumnCount()) |
2068 | nMaxCol = GetFixedColumnCount(); | 2169 | nMaxCol = GetFixedColumnCount(); |
2069 | 2170 | ||
2070 | // If we are selecting cells, then first clear out the list of currently selected cells, then | 2171 | // If we are selecting cells, then first clear out the list of currently selected cells, then |
@@ -2091,7 +2192,7 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | @@ -2091,7 +2192,7 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | ||
2091 | nMinCol <= cell.col && cell.col <= nMaxCol) | 2192 | nMinCol <= cell.col && cell.col <= nMaxCol) |
2092 | continue; | 2193 | continue; |
2093 | 2194 | ||
2094 | - if ( (VisCellRange.IsValid() && VisCellRange.InRange( cell )) || FixedVisCellRange.InRange( cell ) ) | 2195 | + if ( VisCellRange.IsValid() && VisCellRange.InRange( cell ) ) |
2095 | { | 2196 | { |
2096 | if (bForceRepaint && pDC) // Redraw NOW | 2197 | if (bForceRepaint && pDC) // Redraw NOW |
2097 | RedrawCell(cell.row, cell.col, pDC); | 2198 | RedrawCell(cell.row, cell.col, pDC); |
@@ -2127,7 +2228,7 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | @@ -2127,7 +2228,7 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | ||
2127 | // Set state as Selected. This will add the cell to m_SelectedCellMap | 2228 | // Set state as Selected. This will add the cell to m_SelectedCellMap |
2128 | SetItemState(cell.row, cell.col, nState | GVIS_SELECTED); | 2229 | SetItemState(cell.row, cell.col, nState | GVIS_SELECTED); |
2129 | 2230 | ||
2130 | - if (( VisCellRange.IsValid() && VisCellRange.InRange( cell )) || FixedVisCellRange.InRange( cell ) ) | 2231 | + if ( VisCellRange.IsValid() && VisCellRange.InRange( cell ) ) |
2131 | { | 2232 | { |
2132 | // Redraw (immediately or at leisure) | 2233 | // Redraw (immediately or at leisure) |
2133 | if (bForceRepaint && pDC) | 2234 | if (bForceRepaint && pDC) |
@@ -2159,7 +2260,7 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | @@ -2159,7 +2260,7 @@ void CGridCtrl::SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMax | ||
2159 | else | 2260 | else |
2160 | SetItemState(row, col, GetItemState(row, col) & ~GVIS_SELECTED); | 2261 | SetItemState(row, col, GetItemState(row, col) & ~GVIS_SELECTED); |
2161 | 2262 | ||
2162 | - if ( (VisCellRange.IsValid() && VisCellRange.InRange(row, col)) || FixedVisCellRange.InRange(row, col) ) | 2263 | + if ( VisCellRange.IsValid() && VisCellRange.InRange(row, col) ) |
2163 | { | 2264 | { |
2164 | // Redraw (immediately or at leisure) | 2265 | // Redraw (immediately or at leisure) |
2165 | if (bForceRepaint && pDC) | 2266 | if (bForceRepaint && pDC) |
@@ -2221,15 +2322,15 @@ void CGridCtrl::SelectRows(CCellID currentCell, | @@ -2221,15 +2322,15 @@ void CGridCtrl::SelectRows(CCellID currentCell, | ||
2221 | return; | 2322 | return; |
2222 | if (!IsValid(currentCell)) | 2323 | if (!IsValid(currentCell)) |
2223 | return; | 2324 | return; |
2224 | - int Left = ( m_AllowSelectRowInFixedCol ? 0 : GetFixedColumnCount()); | 2325 | + |
2225 | if (GetSingleRowSelection()) | 2326 | if (GetSingleRowSelection()) |
2226 | - SetSelectedRange(currentCell.row, Left , | 2327 | + SetSelectedRange(currentCell.row, GetFixedColumnCount(), |
2227 | currentCell.row, GetColumnCount()-1, | 2328 | currentCell.row, GetColumnCount()-1, |
2228 | bForceRedraw, bSelectCells); | 2329 | bForceRedraw, bSelectCells); |
2229 | else | 2330 | else |
2230 | SetSelectedRange(min(m_SelectionStartCell.row, currentCell.row), | 2331 | SetSelectedRange(min(m_SelectionStartCell.row, currentCell.row), |
2231 | - Left, | ||
2232 | - __max(m_SelectionStartCell.row, currentCell.row), | 2332 | + GetFixedColumnCount(), |
2333 | + max(m_SelectionStartCell.row, currentCell.row), | ||
2233 | GetColumnCount()-1, | 2334 | GetColumnCount()-1, |
2234 | bForceRedraw, bSelectCells); | 2335 | bForceRedraw, bSelectCells); |
2235 | } | 2336 | } |
@@ -2254,8 +2355,8 @@ void CGridCtrl::SelectCells(CCellID currentCell, | @@ -2254,8 +2355,8 @@ void CGridCtrl::SelectCells(CCellID currentCell, | ||
2254 | 2355 | ||
2255 | SetSelectedRange(min(m_SelectionStartCell.row, row), | 2356 | SetSelectedRange(min(m_SelectionStartCell.row, row), |
2256 | min(m_SelectionStartCell.col, col), | 2357 | min(m_SelectionStartCell.col, col), |
2257 | - __max(m_SelectionStartCell.row, row), | ||
2258 | - __max(m_SelectionStartCell.col, col), | 2358 | + max(m_SelectionStartCell.row, row), |
2359 | + max(m_SelectionStartCell.col, col), | ||
2259 | bForceRedraw, bSelectCells); | 2360 | bForceRedraw, bSelectCells); |
2260 | } | 2361 | } |
2261 | 2362 | ||
@@ -2388,9 +2489,8 @@ COleDataSource* CGridCtrl::CopyTextFromGrid() | @@ -2388,9 +2489,8 @@ COleDataSource* CGridCtrl::CopyTextFromGrid() | ||
2388 | if (col != Selection.GetMaxCol()) | 2489 | if (col != Selection.GetMaxCol()) |
2389 | str += _T("\t"); | 2490 | str += _T("\t"); |
2390 | } | 2491 | } |
2391 | - | ||
2392 | if (row != Selection.GetMaxRow()) | 2492 | if (row != Selection.GetMaxRow()) |
2393 | - str += _T("\r\n"); | 2493 | + str += _T("\n"); |
2394 | 2494 | ||
2395 | sf.Write(T2A(str.GetBuffer(1)), str.GetLength()); | 2495 | sf.Write(T2A(str.GetBuffer(1)), str.GetLength()); |
2396 | str.ReleaseBuffer(); | 2496 | str.ReleaseBuffer(); |
@@ -2427,20 +2527,20 @@ BOOL CGridCtrl::PasteTextToGrid(CCellID cell, COleDataObject* pDataObject, | @@ -2427,20 +2527,20 @@ BOOL CGridCtrl::PasteTextToGrid(CCellID cell, COleDataObject* pDataObject, | ||
2427 | 2527 | ||
2428 | // Get the text from the COleDataObject | 2528 | // Get the text from the COleDataObject |
2429 | HGLOBAL hmem = pDataObject->GetGlobalData(CF_TEXT); | 2529 | HGLOBAL hmem = pDataObject->GetGlobalData(CF_TEXT); |
2430 | - CMemFile sf((BYTE*) ::GlobalLock(hmem), (UINT)::GlobalSize(hmem)); | 2530 | + CMemFile sf((BYTE*) ::GlobalLock(hmem), ::GlobalSize(hmem)); |
2431 | 2531 | ||
2432 | // CF_TEXT is ANSI text, so we need to allocate a char* buffer | 2532 | // CF_TEXT is ANSI text, so we need to allocate a char* buffer |
2433 | // to hold this. | 2533 | // to hold this. |
2434 | - LPSTR szBuffer = new char[::GlobalSize(hmem)]; // FIX: Use LPSTR char here | 2534 | + LPSTR szBuffer = new char[::GlobalSize(hmem)]; |
2435 | if (!szBuffer) | 2535 | if (!szBuffer) |
2436 | return FALSE; | 2536 | return FALSE; |
2437 | 2537 | ||
2438 | - sf.Read(szBuffer, (UINT)::GlobalSize(hmem)); | 2538 | + sf.Read(szBuffer, ::GlobalSize(hmem)); |
2439 | ::GlobalUnlock(hmem); | 2539 | ::GlobalUnlock(hmem); |
2440 | 2540 | ||
2441 | // Now store in generic TCHAR form so we no longer have to deal with | 2541 | // Now store in generic TCHAR form so we no longer have to deal with |
2442 | // ANSI/UNICODE problems | 2542 | // ANSI/UNICODE problems |
2443 | - CString strText(szBuffer); | 2543 | + CString strText = (LPWSTR)szBuffer; |
2444 | delete szBuffer; | 2544 | delete szBuffer; |
2445 | 2545 | ||
2446 | // Parse text data and set in cells... | 2546 | // Parse text data and set in cells... |
@@ -2534,12 +2634,10 @@ BOOL CGridCtrl::PasteTextToGrid(CCellID cell, COleDataObject* pDataObject, | @@ -2534,12 +2634,10 @@ BOOL CGridCtrl::PasteTextToGrid(CCellID cell, COleDataObject* pDataObject, | ||
2534 | // Start drag n drop | 2634 | // Start drag n drop |
2535 | void CGridCtrl::OnBeginDrag() | 2635 | void CGridCtrl::OnBeginDrag() |
2536 | { | 2636 | { |
2537 | - COleDataSource* pSource = NULL; | ||
2538 | - if (!m_bAllowDragAndDrop && m_CurCol==-1) | 2637 | + if (!m_bAllowDragAndDrop) |
2539 | return; | 2638 | return; |
2540 | 2639 | ||
2541 | - if (m_CurCol>=0) pSource = new COleDataSource(); | ||
2542 | - if (!pSource && m_bAllowDragAndDrop) pSource = CopyTextFromGrid(); | 2640 | + COleDataSource* pSource = CopyTextFromGrid(); |
2543 | if (pSource) | 2641 | if (pSource) |
2544 | { | 2642 | { |
2545 | SendMessageToParent(GetSelectedCellRange().GetTopLeft().row, | 2643 | SendMessageToParent(GetSelectedCellRange().GetTopLeft().row, |
@@ -2556,7 +2654,6 @@ void CGridCtrl::OnBeginDrag() | @@ -2556,7 +2654,6 @@ void CGridCtrl::OnBeginDrag() | ||
2556 | 2654 | ||
2557 | if (pSource) | 2655 | if (pSource) |
2558 | delete pSource; // Did not pass source to clipboard, so must delete | 2656 | delete pSource; // Did not pass source to clipboard, so must delete |
2559 | - | ||
2560 | } | 2657 | } |
2561 | } | 2658 | } |
2562 | 2659 | ||
@@ -2564,41 +2661,23 @@ void CGridCtrl::OnBeginDrag() | @@ -2564,41 +2661,23 @@ void CGridCtrl::OnBeginDrag() | ||
2564 | DROPEFFECT CGridCtrl::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, | 2661 | DROPEFFECT CGridCtrl::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, |
2565 | CPoint point) | 2662 | CPoint point) |
2566 | { | 2663 | { |
2567 | - // Find which cell we are over and drop-highlight it | ||
2568 | - CCellID cell = GetCellFromPt(point, FALSE); | ||
2569 | - bool Valid; | ||
2570 | // Any text data available for us? | 2664 | // Any text data available for us? |
2571 | - if(m_CurCol==-1) | ||
2572 | - { | ||
2573 | - if(m_bDragRowMode) | ||
2574 | - { | ||
2575 | - Valid = cell.col>=GetFixedColumnCount() && cell.row>=GetFixedRowCount(); | ||
2576 | - } | ||
2577 | - else | ||
2578 | - { | ||
2579 | if (!m_bAllowDragAndDrop || !IsEditable() || !pDataObject->IsDataAvailable(CF_TEXT)) | 2665 | if (!m_bAllowDragAndDrop || !IsEditable() || !pDataObject->IsDataAvailable(CF_TEXT)) |
2580 | return DROPEFFECT_NONE; | 2666 | return DROPEFFECT_NONE; |
2581 | - Valid = IsValid(cell)!=0; | ||
2582 | - } | ||
2583 | - } | ||
2584 | - else | ||
2585 | - { | ||
2586 | - Valid = cell.col>=GetFixedColumnCount() && cell.row<GetFixedRowCount() ; | ||
2587 | - } | ||
2588 | 2667 | ||
2668 | + // Find which cell we are over and drop-highlight it | ||
2669 | + CCellID cell = GetCellFromPt(point, FALSE); | ||
2589 | 2670 | ||
2590 | // If not valid, set the previously drop-highlighted cell as no longer drop-highlighted | 2671 | // If not valid, set the previously drop-highlighted cell as no longer drop-highlighted |
2591 | - if (!Valid) | 2672 | + if (!IsValid(cell)) |
2592 | { | 2673 | { |
2593 | OnDragLeave(); | 2674 | OnDragLeave(); |
2594 | m_LastDragOverCell = CCellID(-1,-1); | 2675 | m_LastDragOverCell = CCellID(-1,-1); |
2595 | return DROPEFFECT_NONE; | 2676 | return DROPEFFECT_NONE; |
2596 | } | 2677 | } |
2597 | - if(m_CurCol==-1) | ||
2598 | - { | ||
2599 | - if (!m_bDragRowMode && !IsCellEditable(cell)) | 2678 | + |
2679 | + if (!IsCellEditable(cell)) | ||
2600 | return DROPEFFECT_NONE; | 2680 | return DROPEFFECT_NONE; |
2601 | - } | ||
2602 | 2681 | ||
2603 | // Have we moved over a different cell than last time? | 2682 | // Have we moved over a different cell than last time? |
2604 | if (cell != m_LastDragOverCell) | 2683 | if (cell != m_LastDragOverCell) |
@@ -2636,28 +2715,18 @@ DROPEFFECT CGridCtrl::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, | @@ -2636,28 +2715,18 @@ DROPEFFECT CGridCtrl::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, | ||
2636 | CPoint point) | 2715 | CPoint point) |
2637 | { | 2716 | { |
2638 | // Any text data available for us? | 2717 | // Any text data available for us? |
2639 | - m_LastDragOverCell = GetCellFromPt(point, m_CurCol>=0); | ||
2640 | - bool Valid; | ||
2641 | - if(m_CurCol==-1) | ||
2642 | - { | ||
2643 | if (!m_bAllowDragAndDrop || !pDataObject->IsDataAvailable(CF_TEXT)) | 2718 | if (!m_bAllowDragAndDrop || !pDataObject->IsDataAvailable(CF_TEXT)) |
2644 | return DROPEFFECT_NONE; | 2719 | return DROPEFFECT_NONE; |
2645 | 2720 | ||
2646 | // Find which cell we are over and drop-highlight it | 2721 | // Find which cell we are over and drop-highlight it |
2722 | + m_LastDragOverCell = GetCellFromPt(point, FALSE); | ||
2647 | if (!IsValid(m_LastDragOverCell)) | 2723 | if (!IsValid(m_LastDragOverCell)) |
2648 | return DROPEFFECT_NONE; | 2724 | return DROPEFFECT_NONE; |
2649 | 2725 | ||
2650 | if (!IsCellEditable(m_LastDragOverCell)) | 2726 | if (!IsCellEditable(m_LastDragOverCell)) |
2651 | return DROPEFFECT_NONE; | 2727 | return DROPEFFECT_NONE; |
2652 | - Valid = IsValid(m_LastDragOverCell)!=0; | ||
2653 | 2728 | ||
2654 | - } | ||
2655 | - else | ||
2656 | - { | ||
2657 | - Valid = m_LastDragOverCell.row>=0 && m_LastDragOverCell.row<GetFixedRowCount() && m_LastDragOverCell.col>=GetFixedColumnCount(); | ||
2658 | - } | ||
2659 | - | ||
2660 | - if (Valid) | 2729 | + if (IsValid(m_LastDragOverCell)) |
2661 | { | 2730 | { |
2662 | UINT nState = GetItemState(m_LastDragOverCell.row, m_LastDragOverCell.col); | 2731 | UINT nState = GetItemState(m_LastDragOverCell.row, m_LastDragOverCell.col); |
2663 | SetItemState(m_LastDragOverCell.row, m_LastDragOverCell.col, | 2732 | SetItemState(m_LastDragOverCell.row, m_LastDragOverCell.col, |
@@ -2690,39 +2759,14 @@ BOOL CGridCtrl::OnDrop(COleDataObject* pDataObject, DROPEFFECT /*dropEffect*/, | @@ -2690,39 +2759,14 @@ BOOL CGridCtrl::OnDrop(COleDataObject* pDataObject, DROPEFFECT /*dropEffect*/, | ||
2690 | CPoint /* point */) | 2759 | CPoint /* point */) |
2691 | { | 2760 | { |
2692 | m_MouseMode = MOUSE_NOTHING; | 2761 | m_MouseMode = MOUSE_NOTHING; |
2693 | - if(m_CurCol ==-1) | ||
2694 | - { | ||
2695 | - if (!m_bAllowDragAndDrop || (!IsCellEditable(m_LastDragOverCell) && !m_bDragRowMode)) | 2762 | + |
2763 | + if (!m_bAllowDragAndDrop || !IsCellEditable(m_LastDragOverCell)) | ||
2696 | return FALSE; | 2764 | return FALSE; |
2697 | - } | ||
2698 | 2765 | ||
2699 | OnDragLeave(); | 2766 | OnDragLeave(); |
2700 | - if (m_CurCol>=0) | ||
2701 | - { | ||
2702 | - if(m_LastDragOverCell.col == m_CurCol || m_LastDragOverCell.row >= GetFixedRowCount()) | ||
2703 | - return FALSE; | ||
2704 | - else | ||
2705 | - { | ||
2706 | - int New = m_arColOrder[m_CurCol]; | ||
2707 | - m_arColOrder.erase(m_arColOrder.begin()+m_CurCol); | ||
2708 | - m_arColOrder.insert(m_arColOrder.begin()+m_LastDragOverCell.col, New); | ||
2709 | - m_CurCol=-1; | ||
2710 | - Invalidate(); | ||
2711 | - return TRUE; | ||
2712 | - } | ||
2713 | - } | ||
2714 | - else | ||
2715 | - { | ||
2716 | - if(m_bDragRowMode) | ||
2717 | - { | ||
2718 | - Reorder(m_CurRow,m_LastDragOverCell.row); | ||
2719 | - Invalidate(); | ||
2720 | - return TRUE; | ||
2721 | - } | ||
2722 | - else | 2767 | + |
2723 | return PasteTextToGrid(m_LastDragOverCell, pDataObject, FALSE); | 2768 | return PasteTextToGrid(m_LastDragOverCell, pDataObject, FALSE); |
2724 | } | 2769 | } |
2725 | -} | ||
2726 | #endif | 2770 | #endif |
2727 | 2771 | ||
2728 | #ifndef GRIDCONTROL_NO_CLIPBOARD | 2772 | #ifndef GRIDCONTROL_NO_CLIPBOARD |
@@ -2845,7 +2889,10 @@ BOOL CGridCtrl::MouseOverRowResizeArea(CPoint& point) | @@ -2845,7 +2889,10 @@ BOOL CGridCtrl::MouseOverRowResizeArea(CPoint& point) | ||
2845 | if (!GetCellOrigin(idCurrentCell, &start)) | 2889 | if (!GetCellOrigin(idCurrentCell, &start)) |
2846 | return FALSE; | 2890 | return FALSE; |
2847 | 2891 | ||
2848 | - int endy = start.y + GetRowHeight(idCurrentCell.row); | 2892 | + //int endy = start.y + GetRowHeight(idCurrentCell.row); |
2893 | + //Merge the selected cells | ||
2894 | + //by Huang Wei | ||
2895 | + int endy = start.y + GetMergeCellHeight(idCurrentCell); | ||
2849 | 2896 | ||
2850 | if ((point.y - start.y < m_nResizeCaptureRange && idCurrentCell.row != 0) || | 2897 | if ((point.y - start.y < m_nResizeCaptureRange && idCurrentCell.row != 0) || |
2851 | endy - point.y < m_nResizeCaptureRange) | 2898 | endy - point.y < m_nResizeCaptureRange) |
@@ -2867,7 +2914,10 @@ BOOL CGridCtrl::MouseOverColumnResizeArea(CPoint& point) | @@ -2867,7 +2914,10 @@ BOOL CGridCtrl::MouseOverColumnResizeArea(CPoint& point) | ||
2867 | if (!GetCellOrigin(idCurrentCell, &start)) | 2914 | if (!GetCellOrigin(idCurrentCell, &start)) |
2868 | return FALSE; | 2915 | return FALSE; |
2869 | 2916 | ||
2870 | - int endx = start.x + GetColumnWidth(idCurrentCell.col); | 2917 | + //int endx = start.x + GetColumnWidth(idCurrentCell.col); |
2918 | + //Merge the selected cells | ||
2919 | + //by Huang Wei | ||
2920 | + int endx = start.x + GetMergeCellWidth(idCurrentCell); | ||
2871 | 2921 | ||
2872 | if ((point.x - start.x < m_nResizeCaptureRange && idCurrentCell.col != 0) || | 2922 | if ((point.x - start.x < m_nResizeCaptureRange && idCurrentCell.col != 0) || |
2873 | endx - point.x < m_nResizeCaptureRange) | 2923 | endx - point.x < m_nResizeCaptureRange) |
@@ -2905,7 +2955,6 @@ CCellID CGridCtrl::GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck /*=TRUE | @@ -2905,7 +2955,6 @@ CCellID CGridCtrl::GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck /*=TRUE | ||
2905 | break; | 2955 | break; |
2906 | col++; | 2956 | col++; |
2907 | } | 2957 | } |
2908 | - | ||
2909 | cellID.col = col; | 2958 | cellID.col = col; |
2910 | } | 2959 | } |
2911 | else // in non-fixed col | 2960 | else // in non-fixed col |
@@ -2960,6 +3009,7 @@ CCellID CGridCtrl::GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck /*=TRUE | @@ -2960,6 +3009,7 @@ CCellID CGridCtrl::GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck /*=TRUE | ||
2960 | else | 3009 | else |
2961 | cellID.row = row; | 3010 | cellID.row = row; |
2962 | } | 3011 | } |
3012 | + cellID=GetMergeCellID(cellID); | ||
2963 | return cellID; | 3013 | return cellID; |
2964 | } | 3014 | } |
2965 | 3015 | ||
@@ -2990,15 +3040,10 @@ CCellID CGridCtrl::GetTopleftNonFixedCell(BOOL bForceRecalculation /*=FALSE*/) | @@ -2990,15 +3040,10 @@ CCellID CGridCtrl::GetTopleftNonFixedCell(BOOL bForceRecalculation /*=FALSE*/) | ||
2990 | return m_idTopLeftCell; | 3040 | return m_idTopLeftCell; |
2991 | } | 3041 | } |
2992 | 3042 | ||
2993 | - | ||
2994 | - | ||
2995 | - | ||
2996 | - | ||
2997 | // This gets even partially visible cells | 3043 | // This gets even partially visible cells |
2998 | CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, | 3044 | CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, |
2999 | BOOL bForceRecalculation /*=FALSE*/) | 3045 | BOOL bForceRecalculation /*=FALSE*/) |
3000 | { | 3046 | { |
3001 | - int i; | ||
3002 | CRect rect; | 3047 | CRect rect; |
3003 | GetClientRect(rect); | 3048 | GetClientRect(rect); |
3004 | 3049 | ||
@@ -3006,6 +3051,7 @@ CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, | @@ -3006,6 +3051,7 @@ CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, | ||
3006 | 3051 | ||
3007 | // calc bottom | 3052 | // calc bottom |
3008 | int bottom = GetFixedRowHeight(); | 3053 | int bottom = GetFixedRowHeight(); |
3054 | + int i = 0; | ||
3009 | for (i = idTopLeft.row; i < GetRowCount(); i++) | 3055 | for (i = idTopLeft.row; i < GetRowCount(); i++) |
3010 | { | 3056 | { |
3011 | bottom += GetRowHeight(i); | 3057 | bottom += GetRowHeight(i); |
@@ -3039,54 +3085,6 @@ CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, | @@ -3039,54 +3085,6 @@ CCellRange CGridCtrl::GetVisibleNonFixedCellRange(LPRECT pRect /*=NULL*/, | ||
3039 | return CCellRange(idTopLeft.row, idTopLeft.col, maxVisibleRow, maxVisibleCol); | 3085 | return CCellRange(idTopLeft.row, idTopLeft.col, maxVisibleRow, maxVisibleCol); |
3040 | } | 3086 | } |
3041 | 3087 | ||
3042 | - | ||
3043 | -CCellRange CGridCtrl::GetVisibleFixedCellRange(LPRECT pRect /*=NULL*/, | ||
3044 | - BOOL bForceRecalculation /*=FALSE*/) | ||
3045 | -{ | ||
3046 | - int i; | ||
3047 | - CRect rect; | ||
3048 | - GetClientRect(rect); | ||
3049 | - | ||
3050 | - CCellID idTopLeft = GetTopleftNonFixedCell(bForceRecalculation); | ||
3051 | - | ||
3052 | - // calc bottom | ||
3053 | - int bottom = GetFixedRowHeight(); | ||
3054 | - for (i = idTopLeft.row; i < GetRowCount(); i++) | ||
3055 | - { | ||
3056 | - bottom += GetRowHeight(i); | ||
3057 | - if (bottom >= rect.bottom) | ||
3058 | - { | ||
3059 | - bottom = rect.bottom; | ||
3060 | - break; | ||
3061 | - } | ||
3062 | - } | ||
3063 | - int maxVisibleRow = min(i, GetRowCount() - 1); | ||
3064 | - | ||
3065 | - // calc right | ||
3066 | - int right = 0; | ||
3067 | - for (i = 0; i < GetFixedColumnCount(); i++) | ||
3068 | - { | ||
3069 | - right += GetColumnWidth(i); | ||
3070 | - if (right >= rect.right) | ||
3071 | - { | ||
3072 | - right = rect.right; | ||
3073 | - break; | ||
3074 | - } | ||
3075 | - } | ||
3076 | - int maxVisibleCol = min(i, GetColumnCount() - 1); | ||
3077 | - if (pRect) | ||
3078 | - { | ||
3079 | - pRect->left = pRect->top = 0; | ||
3080 | - pRect->right = right; | ||
3081 | - pRect->bottom = bottom; | ||
3082 | - } | ||
3083 | - | ||
3084 | - return CCellRange(idTopLeft.row, 0, maxVisibleRow, maxVisibleCol); | ||
3085 | -} | ||
3086 | - | ||
3087 | - | ||
3088 | - | ||
3089 | - | ||
3090 | // used by ResetScrollBars() - This gets only fully visible cells | 3088 | // used by ResetScrollBars() - This gets only fully visible cells |
3091 | CCellRange CGridCtrl::GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation /*=FALSE*/) | 3089 | CCellRange CGridCtrl::GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation /*=FALSE*/) |
3092 | { | 3090 | { |
@@ -3096,8 +3094,8 @@ CCellRange CGridCtrl::GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation | @@ -3096,8 +3094,8 @@ CCellRange CGridCtrl::GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation | ||
3096 | CCellID idTopLeft = GetTopleftNonFixedCell(bForceRecalculation); | 3094 | CCellID idTopLeft = GetTopleftNonFixedCell(bForceRecalculation); |
3097 | 3095 | ||
3098 | // calc bottom | 3096 | // calc bottom |
3099 | - int i; | ||
3100 | int bottom = GetFixedRowHeight(); | 3097 | int bottom = GetFixedRowHeight(); |
3098 | + int i = 0; | ||
3101 | for (i = idTopLeft.row; i < GetRowCount(); i++) | 3099 | for (i = idTopLeft.row; i < GetRowCount(); i++) |
3102 | { | 3100 | { |
3103 | bottom += GetRowHeight(i); | 3101 | bottom += GetRowHeight(i); |
@@ -3138,8 +3136,8 @@ CCellRange CGridCtrl::GetSelectedCellRange() const | @@ -3138,8 +3136,8 @@ CCellRange CGridCtrl::GetSelectedCellRange() const | ||
3138 | 3136 | ||
3139 | Selection.SetMinRow( min(Selection.GetMinRow(), cell.row) ); | 3137 | Selection.SetMinRow( min(Selection.GetMinRow(), cell.row) ); |
3140 | Selection.SetMinCol( min(Selection.GetMinCol(), cell.col) ); | 3138 | Selection.SetMinCol( min(Selection.GetMinCol(), cell.col) ); |
3141 | - Selection.SetMaxRow( __max(Selection.GetMaxRow(), cell.row) ); | ||
3142 | - Selection.SetMaxCol( __max(Selection.GetMaxCol(), cell.col) ); | 3139 | + Selection.SetMaxRow( max(Selection.GetMaxRow(), cell.row) ); |
3140 | + Selection.SetMaxCol( max(Selection.GetMaxCol(), cell.col) ); | ||
3143 | } | 3141 | } |
3144 | 3142 | ||
3145 | return Selection; | 3143 | return Selection; |
@@ -3341,6 +3339,7 @@ void CGridCtrl::ResetScrollBars() | @@ -3341,6 +3339,7 @@ void CGridCtrl::ResetScrollBars() | ||
3341 | // Row/Column position functions | 3339 | // Row/Column position functions |
3342 | 3340 | ||
3343 | // returns the top left point of the cell. Returns FALSE if cell not visible. | 3341 | // returns the top left point of the cell. Returns FALSE if cell not visible. |
3342 | +// consider cell's merge | ||
3344 | BOOL CGridCtrl::GetCellOrigin(int nRow, int nCol, LPPOINT p) | 3343 | BOOL CGridCtrl::GetCellOrigin(int nRow, int nCol, LPPOINT p) |
3345 | { | 3344 | { |
3346 | int i; | 3345 | int i; |
@@ -3352,6 +3351,72 @@ BOOL CGridCtrl::GetCellOrigin(int nRow, int nCol, LPPOINT p) | @@ -3352,6 +3351,72 @@ BOOL CGridCtrl::GetCellOrigin(int nRow, int nCol, LPPOINT p) | ||
3352 | if (nCol >= m_nFixedCols || nRow >= m_nFixedRows) | 3351 | if (nCol >= m_nFixedCols || nRow >= m_nFixedRows) |
3353 | idTopLeft = GetTopleftNonFixedCell(); | 3352 | idTopLeft = GetTopleftNonFixedCell(); |
3354 | 3353 | ||
3354 | + //Merge the selected cells | ||
3355 | + //by Huang Wei | ||
3356 | + | ||
3357 | + //if ((nRow >= m_nFixedRows && nRow < idTopLeft.row) || | ||
3358 | + // (nCol>= m_nFixedCols && nCol < idTopLeft.col)) | ||
3359 | + // return FALSE; | ||
3360 | + | ||
3361 | + p->x = 0; | ||
3362 | + if (nCol < m_nFixedCols) // is a fixed column | ||
3363 | + for (i = 0; i < nCol; i++) | ||
3364 | + p->x += GetColumnWidth(i); | ||
3365 | + else | ||
3366 | + { // is a scrollable data column | ||
3367 | + for (i = 0; i < m_nFixedCols; i++) | ||
3368 | + p->x += GetColumnWidth(i); | ||
3369 | + //Merge the selected cells | ||
3370 | + //by Huang Wei | ||
3371 | + if(nCol>idTopLeft.col) | ||
3372 | + { | ||
3373 | + for (i = idTopLeft.col; i < nCol; i++) | ||
3374 | + p->x += GetColumnWidth(i); | ||
3375 | + } | ||
3376 | + else | ||
3377 | + { | ||
3378 | + for (i = nCol; i <idTopLeft.col ; i++) | ||
3379 | + p->x -= GetColumnWidth(i); | ||
3380 | + } | ||
3381 | + } | ||
3382 | + | ||
3383 | + p->y = 0; | ||
3384 | + if (nRow < m_nFixedRows) // is a fixed row | ||
3385 | + for (i = 0; i < nRow; i++) | ||
3386 | + p->y += GetRowHeight(i); | ||
3387 | + else | ||
3388 | + { // is a scrollable data row | ||
3389 | + for (i = 0; i < m_nFixedRows; i++) | ||
3390 | + p->y += GetRowHeight(i); | ||
3391 | + //Merge the selected cells | ||
3392 | + //by Huang Wei | ||
3393 | + if(nRow>idTopLeft.row) | ||
3394 | + { | ||
3395 | + for (i = idTopLeft.row; i < nRow; i++) | ||
3396 | + p->y += GetRowHeight(i); | ||
3397 | + } | ||
3398 | + else | ||
3399 | + { | ||
3400 | + for (i = nRow; i <idTopLeft.row; i++) | ||
3401 | + p->y -= GetRowHeight(i); | ||
3402 | + } | ||
3403 | + } | ||
3404 | + | ||
3405 | + return TRUE; | ||
3406 | +} | ||
3407 | +// returns the top left point of the cell. Returns FALSE if cell not visible. | ||
3408 | +// don't consider cell's merge | ||
3409 | +BOOL CGridCtrl::GetCellOriginNoMerge(int nRow, int nCol, LPPOINT p) | ||
3410 | +{ | ||
3411 | + int i; | ||
3412 | + | ||
3413 | + if (!IsValid(nRow, nCol)) | ||
3414 | + return FALSE; | ||
3415 | + | ||
3416 | + CCellID idTopLeft; | ||
3417 | + if (nCol >= m_nFixedCols || nRow >= m_nFixedRows) | ||
3418 | + idTopLeft = GetTopleftNonFixedCell(); | ||
3419 | + | ||
3355 | if ((nRow >= m_nFixedRows && nRow < idTopLeft.row) || | 3420 | if ((nRow >= m_nFixedRows && nRow < idTopLeft.row) || |
3356 | (nCol>= m_nFixedCols && nCol < idTopLeft.col)) | 3421 | (nCol>= m_nFixedCols && nCol < idTopLeft.col)) |
3357 | return FALSE; | 3422 | return FALSE; |
@@ -3383,10 +3448,16 @@ BOOL CGridCtrl::GetCellOrigin(int nRow, int nCol, LPPOINT p) | @@ -3383,10 +3448,16 @@ BOOL CGridCtrl::GetCellOrigin(int nRow, int nCol, LPPOINT p) | ||
3383 | return TRUE; | 3448 | return TRUE; |
3384 | } | 3449 | } |
3385 | 3450 | ||
3451 | + | ||
3452 | + | ||
3386 | BOOL CGridCtrl::GetCellOrigin(const CCellID& cell, LPPOINT p) | 3453 | BOOL CGridCtrl::GetCellOrigin(const CCellID& cell, LPPOINT p) |
3387 | { | 3454 | { |
3388 | return GetCellOrigin(cell.row, cell.col, p); | 3455 | return GetCellOrigin(cell.row, cell.col, p); |
3389 | } | 3456 | } |
3457 | +BOOL CGridCtrl::GetCellOriginNoMerge(const CCellID& cell, LPPOINT p) | ||
3458 | +{ | ||
3459 | + return GetCellOriginNoMerge(cell.row, cell.col, p); | ||
3460 | +} | ||
3390 | 3461 | ||
3391 | // Returns the bounding box of the cell | 3462 | // Returns the bounding box of the cell |
3392 | BOOL CGridCtrl::GetCellRect(const CCellID& cell, LPRECT pRect) | 3463 | BOOL CGridCtrl::GetCellRect(const CCellID& cell, LPRECT pRect) |
@@ -3400,11 +3471,21 @@ BOOL CGridCtrl::GetCellRect(int nRow, int nCol, LPRECT pRect) | @@ -3400,11 +3471,21 @@ BOOL CGridCtrl::GetCellRect(int nRow, int nCol, LPRECT pRect) | ||
3400 | if (!GetCellOrigin(nRow, nCol, &CellOrigin)) | 3471 | if (!GetCellOrigin(nRow, nCol, &CellOrigin)) |
3401 | return FALSE; | 3472 | return FALSE; |
3402 | 3473 | ||
3403 | - pRect->left = CellOrigin.x; | ||
3404 | - pRect->top = CellOrigin.y; | ||
3405 | - pRect->right = CellOrigin.x + GetColumnWidth(nCol)-1; | ||
3406 | - pRect->bottom = CellOrigin.y + GetRowHeight(nRow)-1; | ||
3407 | - | 3474 | + //Merge the selected cells |
3475 | + //by Huang Wei | ||
3476 | + CGridCellBase *pCell = (CGridCellBase*) GetCell(nRow,nCol); | ||
3477 | + | ||
3478 | + if(!pCell->IsMerged()) | ||
3479 | + { | ||
3480 | + pRect->left = CellOrigin.x; | ||
3481 | + pRect->top = CellOrigin.y; | ||
3482 | + pRect->right = CellOrigin.x + GetColumnWidth(nCol)-1; | ||
3483 | + pRect->bottom = CellOrigin.y + GetRowHeight(nRow)-1; | ||
3484 | + } | ||
3485 | + else | ||
3486 | + { | ||
3487 | + GetCellRangeRect(pCell->m_MergeRange,pRect); | ||
3488 | + } | ||
3408 | //TRACE("Row %d, col %d: L %d, T %d, W %d, H %d: %d,%d - %d,%d\n", | 3489 | //TRACE("Row %d, col %d: L %d, T %d, W %d, H %d: %d,%d - %d,%d\n", |
3409 | // nRow,nCol, CellOrigin.x, CellOrigin.y, GetColumnWidth(nCol), GetRowHeight(nRow), | 3490 | // nRow,nCol, CellOrigin.x, CellOrigin.y, GetColumnWidth(nCol), GetRowHeight(nRow), |
3410 | // pRect->left, pRect->top, pRect->right, pRect->bottom); | 3491 | // pRect->left, pRect->top, pRect->right, pRect->bottom); |
@@ -3686,7 +3767,6 @@ BOOL CGridCtrl::SetRowCount(int nRows) | @@ -3686,7 +3767,6 @@ BOOL CGridCtrl::SetRowCount(int nRows) | ||
3686 | for (int row = startRow; row < nRows; row++) | 3767 | for (int row = startRow; row < nRows; row++) |
3687 | m_arRowHeights[row] = m_cellDefault.GetHeight(); | 3768 | m_arRowHeights[row] = m_cellDefault.GetHeight(); |
3688 | } | 3769 | } |
3689 | - ResetVirtualOrder(); | ||
3690 | } | 3770 | } |
3691 | else | 3771 | else |
3692 | { | 3772 | { |
@@ -3774,17 +3854,16 @@ BOOL CGridCtrl::SetColumnCount(int nCols) | @@ -3774,17 +3854,16 @@ BOOL CGridCtrl::SetColumnCount(int nCols) | ||
3774 | // and set the default column width | 3854 | // and set the default column width |
3775 | if (addedCols > 0) | 3855 | if (addedCols > 0) |
3776 | { | 3856 | { |
3777 | - int row, col; | ||
3778 | - | ||
3779 | // initialized column widths | 3857 | // initialized column widths |
3780 | int startCol = nCols - addedCols; | 3858 | int startCol = nCols - addedCols; |
3859 | + int col = 0; | ||
3781 | for (col = startCol; col < nCols; col++) | 3860 | for (col = startCol; col < nCols; col++) |
3782 | m_arColWidths[col] = m_cellFixedColDef.GetWidth(); | 3861 | m_arColWidths[col] = m_cellFixedColDef.GetWidth(); |
3783 | 3862 | ||
3784 | // initialise column data | 3863 | // initialise column data |
3785 | if (!GetVirtualMode()) | 3864 | if (!GetVirtualMode()) |
3786 | { | 3865 | { |
3787 | - for (row = 0; row < m_nRows; row++) | 3866 | + for (int row = 0; row < m_nRows; row++) |
3788 | for (col = startCol; col < nCols; col++) | 3867 | for (col = startCol; col < nCols; col++) |
3789 | { | 3868 | { |
3790 | GRID_ROW* pRow = m_RowData[row]; | 3869 | GRID_ROW* pRow = m_RowData[row]; |
@@ -3803,12 +3882,6 @@ BOOL CGridCtrl::SetColumnCount(int nCols) | @@ -3803,12 +3882,6 @@ BOOL CGridCtrl::SetColumnCount(int nCols) | ||
3803 | } | 3882 | } |
3804 | END_CATCH | 3883 | END_CATCH |
3805 | 3884 | ||
3806 | - m_arColOrder.resize(nCols); // Reset Column Order | ||
3807 | - for (int i = 0; i < nCols; i++) | ||
3808 | - { | ||
3809 | - m_arColOrder[i] = i; | ||
3810 | - } | ||
3811 | - | ||
3812 | m_nCols = nCols; | 3885 | m_nCols = nCols; |
3813 | 3886 | ||
3814 | SetModified(); | 3887 | SetModified(); |
@@ -3823,7 +3896,6 @@ int CGridCtrl::InsertColumn(LPCTSTR strHeading, | @@ -3823,7 +3896,6 @@ int CGridCtrl::InsertColumn(LPCTSTR strHeading, | ||
3823 | UINT nFormat /* = DT_CENTER|DT_VCENTER|DT_SINGLELINE */, | 3896 | UINT nFormat /* = DT_CENTER|DT_VCENTER|DT_SINGLELINE */, |
3824 | int nColumn /* = -1 */) | 3897 | int nColumn /* = -1 */) |
3825 | { | 3898 | { |
3826 | - ASSERT(!m_AllowReorderColumn); // function not implemented in case of m_AllowReorderColumn option | ||
3827 | if (nColumn >= 0 && nColumn < m_nFixedCols) | 3899 | if (nColumn >= 0 && nColumn < m_nFixedCols) |
3828 | { | 3900 | { |
3829 | 3901 | ||
@@ -3886,18 +3958,11 @@ int CGridCtrl::InsertColumn(LPCTSTR strHeading, | @@ -3886,18 +3958,11 @@ int CGridCtrl::InsertColumn(LPCTSTR strHeading, | ||
3886 | CATCH (CMemoryException, e) | 3958 | CATCH (CMemoryException, e) |
3887 | { | 3959 | { |
3888 | e->ReportError(); | 3960 | e->ReportError(); |
3889 | - return -1; | 3961 | + return FALSE; |
3890 | } | 3962 | } |
3891 | END_CATCH | 3963 | END_CATCH |
3892 | 3964 | ||
3893 | m_nCols++; | 3965 | m_nCols++; |
3894 | - | ||
3895 | - // Column Order | ||
3896 | - m_arColOrder.resize(m_nCols); | ||
3897 | - for (int i = 0; i < m_nCols; i++) | ||
3898 | - { | ||
3899 | - m_arColOrder[i] = i; | ||
3900 | - } | ||
3901 | 3966 | ||
3902 | // Initialise column data | 3967 | // Initialise column data |
3903 | SetItemText(0, nColumn, strHeading); | 3968 | SetItemText(0, nColumn, strHeading); |
@@ -3949,19 +4014,12 @@ int CGridCtrl::InsertRow(LPCTSTR strHeading, int nRow /* = -1 */) | @@ -3949,19 +4014,12 @@ int CGridCtrl::InsertRow(LPCTSTR strHeading, int nRow /* = -1 */) | ||
3949 | m_arRowHeights.Add(0); | 4014 | m_arRowHeights.Add(0); |
3950 | if (!GetVirtualMode()) | 4015 | if (!GetVirtualMode()) |
3951 | m_RowData.Add(new GRID_ROW); | 4016 | m_RowData.Add(new GRID_ROW); |
3952 | - else | ||
3953 | - m_arRowOrder.push_back(m_nRows); | ||
3954 | - | ||
3955 | } | 4017 | } |
3956 | else | 4018 | else |
3957 | { | 4019 | { |
3958 | m_arRowHeights.InsertAt(nRow, (UINT)0); | 4020 | m_arRowHeights.InsertAt(nRow, (UINT)0); |
3959 | if (!GetVirtualMode()) | 4021 | if (!GetVirtualMode()) |
3960 | m_RowData.InsertAt(nRow, new GRID_ROW); | 4022 | m_RowData.InsertAt(nRow, new GRID_ROW); |
3961 | - else | ||
3962 | - { | ||
3963 | - ResetVirtualOrder(); | ||
3964 | - } | ||
3965 | } | 4023 | } |
3966 | 4024 | ||
3967 | if (!GetVirtualMode()) | 4025 | if (!GetVirtualMode()) |
@@ -3970,7 +4028,7 @@ int CGridCtrl::InsertRow(LPCTSTR strHeading, int nRow /* = -1 */) | @@ -3970,7 +4028,7 @@ int CGridCtrl::InsertRow(LPCTSTR strHeading, int nRow /* = -1 */) | ||
3970 | CATCH (CMemoryException, e) | 4028 | CATCH (CMemoryException, e) |
3971 | { | 4029 | { |
3972 | e->ReportError(); | 4030 | e->ReportError(); |
3973 | - return -1; | 4031 | + return FALSE; |
3974 | } | 4032 | } |
3975 | END_CATCH | 4033 | END_CATCH |
3976 | 4034 | ||
@@ -4126,20 +4184,6 @@ BOOL CGridCtrl::DeleteColumn(int nColumn) | @@ -4126,20 +4184,6 @@ BOOL CGridCtrl::DeleteColumn(int nColumn) | ||
4126 | return TRUE; | 4184 | return TRUE; |
4127 | } | 4185 | } |
4128 | 4186 | ||
4129 | - | ||
4130 | -void CGridCtrl::AddSubVirtualRow(int Num, int Nb) | ||
4131 | -{ | ||
4132 | - ASSERT(Nb == -1 || Nb ==1); // only these vlaues are implemented now | ||
4133 | - if(!GetVirtualMode()) return; | ||
4134 | - for(int ind = 0; ind<m_nRows ; ind++) | ||
4135 | - if(m_arRowOrder[ind]>Num) m_arRowOrder[ind]+=Nb; | ||
4136 | - if(Nb>0) | ||
4137 | - m_arRowOrder.insert(m_arRowOrder.begin()+Num,Num); | ||
4138 | - else | ||
4139 | - m_arRowOrder.erase(m_arRowOrder.begin()+Num); | ||
4140 | -} | ||
4141 | - | ||
4142 | - | ||
4143 | BOOL CGridCtrl::DeleteRow(int nRow) | 4187 | BOOL CGridCtrl::DeleteRow(int nRow) |
4144 | { | 4188 | { |
4145 | if (nRow < 0 || nRow >= GetRowCount()) | 4189 | if (nRow < 0 || nRow >= GetRowCount()) |
@@ -4159,8 +4203,6 @@ BOOL CGridCtrl::DeleteRow(int nRow) | @@ -4159,8 +4203,6 @@ BOOL CGridCtrl::DeleteRow(int nRow) | ||
4159 | delete pRow; | 4203 | delete pRow; |
4160 | m_RowData.RemoveAt(nRow); | 4204 | m_RowData.RemoveAt(nRow); |
4161 | } | 4205 | } |
4162 | - else | ||
4163 | - AddSubVirtualRow(nRow,-1); | ||
4164 | 4206 | ||
4165 | m_arRowHeights.RemoveAt(nRow); | 4207 | m_arRowHeights.RemoveAt(nRow); |
4166 | 4208 | ||
@@ -4184,26 +4226,14 @@ BOOL CGridCtrl::DeleteRow(int nRow) | @@ -4184,26 +4226,14 @@ BOOL CGridCtrl::DeleteRow(int nRow) | ||
4184 | BOOL CGridCtrl::DeleteNonFixedRows() | 4226 | BOOL CGridCtrl::DeleteNonFixedRows() |
4185 | { | 4227 | { |
4186 | ResetSelectedRange(); | 4228 | ResetSelectedRange(); |
4229 | + | ||
4187 | int nFixed = GetFixedRowCount(); | 4230 | int nFixed = GetFixedRowCount(); |
4188 | int nCount = GetRowCount(); | 4231 | int nCount = GetRowCount(); |
4189 | - if (GetVirtualMode()) | ||
4190 | - { | ||
4191 | - if(nCount != nFixed) | ||
4192 | - { | ||
4193 | - SetRowCount(nFixed); | ||
4194 | - m_arRowOrder.resize(nFixed); | ||
4195 | - m_arRowHeights.SetSize(nFixed); | ||
4196 | - m_idCurrentCell.row = m_idCurrentCell.col = -1; | ||
4197 | - ResetScrollBars(); | ||
4198 | - SetModified(); | ||
4199 | - } | ||
4200 | - } | ||
4201 | - else | ||
4202 | - { | 4232 | + |
4203 | // Delete all data rows | 4233 | // Delete all data rows |
4204 | for (int nRow = nCount; nRow >= nFixed; nRow--) | 4234 | for (int nRow = nCount; nRow >= nFixed; nRow--) |
4205 | DeleteRow(nRow); | 4235 | DeleteRow(nRow); |
4206 | - } | 4236 | + |
4207 | return TRUE; | 4237 | return TRUE; |
4208 | } | 4238 | } |
4209 | 4239 | ||
@@ -4230,9 +4260,6 @@ BOOL CGridCtrl::DeleteAllItems() | @@ -4230,9 +4260,6 @@ BOOL CGridCtrl::DeleteAllItems() | ||
4230 | // Remove all rows | 4260 | // Remove all rows |
4231 | m_RowData.RemoveAll(); | 4261 | m_RowData.RemoveAll(); |
4232 | } | 4262 | } |
4233 | - else | ||
4234 | - m_arRowOrder.clear(); | ||
4235 | - | ||
4236 | 4263 | ||
4237 | m_idCurrentCell.row = m_idCurrentCell.col = -1; | 4264 | m_idCurrentCell.row = m_idCurrentCell.col = -1; |
4238 | m_nRows = m_nFixedRows = m_nCols = m_nFixedCols = 0; | 4265 | m_nRows = m_nFixedRows = m_nCols = m_nFixedCols = 0; |
@@ -4380,6 +4407,10 @@ CCellID CGridCtrl::GetNextItem(CCellID& cell, int nFlags) const | @@ -4380,6 +4407,10 @@ CCellID CGridCtrl::GetNextItem(CCellID& cell, int nFlags) const | ||
4380 | // Sorts on a given column using the cell text | 4407 | // Sorts on a given column using the cell text |
4381 | BOOL CGridCtrl::SortTextItems(int nCol, BOOL bAscending, LPARAM data /* = 0 */) | 4408 | BOOL CGridCtrl::SortTextItems(int nCol, BOOL bAscending, LPARAM data /* = 0 */) |
4382 | { | 4409 | { |
4410 | + SetSortColumn(nCol); | ||
4411 | + SetSortAscending(bAscending); | ||
4412 | + ResetSelectedRange(); | ||
4413 | + SetFocusCell(-1, - 1); | ||
4383 | return CGridCtrl::SortItems(pfnCellTextCompare, nCol, bAscending, data); | 4414 | return CGridCtrl::SortItems(pfnCellTextCompare, nCol, bAscending, data); |
4384 | } | 4415 | } |
4385 | 4416 | ||
@@ -4444,13 +4475,7 @@ int CALLBACK CGridCtrl::pfnCellNumericCompare(LPARAM lParam1, LPARAM lParam2, LP | @@ -4444,13 +4475,7 @@ int CALLBACK CGridCtrl::pfnCellNumericCompare(LPARAM lParam1, LPARAM lParam2, LP | ||
4444 | return 1; | 4475 | return 1; |
4445 | } | 4476 | } |
4446 | 4477 | ||
4447 | - | ||
4448 | -CGridCtrl * CGridCtrl::m_This; | ||
4449 | // private recursive sort implementation | 4478 | // private recursive sort implementation |
4450 | -bool CGridCtrl::NotVirtualCompare(int c1, int c2) | ||
4451 | -{ | ||
4452 | - return ! CGridCtrl::m_This->m_pfnVirtualCompare(c1, c2); | ||
4453 | -} | ||
4454 | BOOL CGridCtrl::SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data, | 4479 | BOOL CGridCtrl::SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data, |
4455 | int low, int high) | 4480 | int low, int high) |
4456 | { | 4481 | { |
@@ -4465,17 +4490,6 @@ BOOL CGridCtrl::SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LP | @@ -4465,17 +4490,6 @@ BOOL CGridCtrl::SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LP | ||
4465 | 4490 | ||
4466 | if (hi <= lo) | 4491 | if (hi <= lo) |
4467 | return FALSE; | 4492 | return FALSE; |
4468 | - | ||
4469 | - if (GetVirtualMode()) | ||
4470 | - { | ||
4471 | - ASSERT(m_pfnVirtualCompare); | ||
4472 | - m_CurCol = m_arColOrder[nCol]; | ||
4473 | - m_This = this; | ||
4474 | - std::stable_sort(m_arRowOrder.begin() + m_nFixedRows, m_arRowOrder.end(), | ||
4475 | - bAscending ? m_pfnVirtualCompare : NotVirtualCompare); | ||
4476 | - return TRUE; | ||
4477 | - } | ||
4478 | - | ||
4479 | 4493 | ||
4480 | //LPARAM midItem = GetItemData((lo + hi)/2, nCol); | 4494 | //LPARAM midItem = GetItemData((lo + hi)/2, nCol); |
4481 | LPARAM pMidCell = (LPARAM) GetCell((lo + hi)/2, nCol); | 4495 | LPARAM pMidCell = (LPARAM) GetCell((lo + hi)/2, nCol); |
@@ -4907,7 +4921,7 @@ int CGridCtrl::GetColumnWidth(int nCol) const | @@ -4907,7 +4921,7 @@ int CGridCtrl::GetColumnWidth(int nCol) const | ||
4907 | if (nCol < 0 || nCol >= m_nCols) | 4921 | if (nCol < 0 || nCol >= m_nCols) |
4908 | return -1; | 4922 | return -1; |
4909 | 4923 | ||
4910 | - return m_arColWidths[m_arColOrder[nCol]]; | 4924 | + return m_arColWidths[nCol]; |
4911 | } | 4925 | } |
4912 | 4926 | ||
4913 | BOOL CGridCtrl::SetRowHeight(int nRow, int height) | 4927 | BOOL CGridCtrl::SetRowHeight(int nRow, int height) |
@@ -4928,7 +4942,7 @@ BOOL CGridCtrl::SetColumnWidth(int nCol, int width) | @@ -4928,7 +4942,7 @@ BOOL CGridCtrl::SetColumnWidth(int nCol, int width) | ||
4928 | if (nCol < 0 || nCol >= m_nCols || width < 0) | 4942 | if (nCol < 0 || nCol >= m_nCols || width < 0) |
4929 | return FALSE; | 4943 | return FALSE; |
4930 | 4944 | ||
4931 | - m_arColWidths[m_arColOrder[nCol]] = width; | 4945 | + m_arColWidths[nCol] = width; |
4932 | ResetScrollBars(); | 4946 | ResetScrollBars(); |
4933 | 4947 | ||
4934 | return TRUE; | 4948 | return TRUE; |
@@ -5143,13 +5157,13 @@ void CGridCtrl::ExpandColumnsToFit(BOOL bExpandFixed /*=TRUE*/) | @@ -5143,13 +5157,13 @@ void CGridCtrl::ExpandColumnsToFit(BOOL bExpandFixed /*=TRUE*/) | ||
5143 | 5157 | ||
5144 | EnableScrollBars(SB_HORZ, FALSE); | 5158 | EnableScrollBars(SB_HORZ, FALSE); |
5145 | 5159 | ||
5146 | - int col; | ||
5147 | CRect rect; | 5160 | CRect rect; |
5148 | GetClientRect(rect); | 5161 | GetClientRect(rect); |
5149 | 5162 | ||
5150 | int nFirstColumn = (bExpandFixed)? 0 : GetFixedColumnCount(); | 5163 | int nFirstColumn = (bExpandFixed)? 0 : GetFixedColumnCount(); |
5151 | 5164 | ||
5152 | int nNumColumnsAffected = 0; | 5165 | int nNumColumnsAffected = 0; |
5166 | + int col = 0; | ||
5153 | for (col = nFirstColumn; col < GetColumnCount(); col++) | 5167 | for (col = nFirstColumn; col < GetColumnCount(); col++) |
5154 | { | 5168 | { |
5155 | if (m_arColWidths[col] > 0) | 5169 | if (m_arColWidths[col] > 0) |
@@ -5243,13 +5257,13 @@ void CGridCtrl::ExpandRowsToFit(BOOL bExpandFixed /*=TRUE*/) | @@ -5243,13 +5257,13 @@ void CGridCtrl::ExpandRowsToFit(BOOL bExpandFixed /*=TRUE*/) | ||
5243 | 5257 | ||
5244 | EnableScrollBars(SB_VERT, FALSE); | 5258 | EnableScrollBars(SB_VERT, FALSE); |
5245 | 5259 | ||
5246 | - int row; | ||
5247 | CRect rect; | 5260 | CRect rect; |
5248 | GetClientRect(rect); | 5261 | GetClientRect(rect); |
5249 | 5262 | ||
5250 | int nFirstRow = (bExpandFixed)? 0 : GetFixedRowCount(); | 5263 | int nFirstRow = (bExpandFixed)? 0 : GetFixedRowCount(); |
5251 | 5264 | ||
5252 | int nNumRowsAffected = 0; | 5265 | int nNumRowsAffected = 0; |
5266 | + int row = 0; | ||
5253 | for (row = nFirstRow; row < GetRowCount(); row++) | 5267 | for (row = nFirstRow; row < GetRowCount(); row++) |
5254 | { | 5268 | { |
5255 | if (m_arRowHeights[row] > 0) | 5269 | if (m_arRowHeights[row] > 0) |
@@ -5318,10 +5332,10 @@ void CGridCtrl::SetVirtualMode(BOOL bVirtual) | @@ -5318,10 +5332,10 @@ void CGridCtrl::SetVirtualMode(BOOL bVirtual) | ||
5318 | if (m_bVirtualMode) | 5332 | if (m_bVirtualMode) |
5319 | { | 5333 | { |
5320 | SetEditable(FALSE); | 5334 | SetEditable(FALSE); |
5335 | + SetHeaderSort(FALSE); | ||
5321 | SetAutoSizeStyle(GVS_HEADER); | 5336 | SetAutoSizeStyle(GVS_HEADER); |
5322 | SetFixedColumnSelection(FALSE); | 5337 | SetFixedColumnSelection(FALSE); |
5323 | SetFixedRowSelection(FALSE); | 5338 | SetFixedRowSelection(FALSE); |
5324 | - ResetVirtualOrder(); | ||
5325 | } | 5339 | } |
5326 | } | 5340 | } |
5327 | 5341 | ||
@@ -5426,7 +5440,7 @@ void CGridCtrl::EnsureVisible(int nRow, int nCol) | @@ -5426,7 +5440,7 @@ void CGridCtrl::EnsureVisible(int nRow, int nCol) | ||
5426 | } | 5440 | } |
5427 | */ | 5441 | */ |
5428 | 5442 | ||
5429 | - // We are going to send some scroll messages, which will steal the focus | 5443 | + // We are gonna send some scroll messages, which will steal the focus |
5430 | // from it's rightful owner. Squirrel it away ourselves so we can give | 5444 | // from it's rightful owner. Squirrel it away ourselves so we can give |
5431 | // it back. (Damir) | 5445 | // it back. (Damir) |
5432 | CWnd* pFocusWnd = GetFocus(); | 5446 | CWnd* pFocusWnd = GetFocus(); |
@@ -5489,35 +5503,34 @@ void CGridCtrl::EnsureVisible(int nRow, int nCol) | @@ -5489,35 +5503,34 @@ void CGridCtrl::EnsureVisible(int nRow, int nCol) | ||
5489 | 5503 | ||
5490 | GetClientRect(rectWindow); | 5504 | GetClientRect(rectWindow); |
5491 | 5505 | ||
5492 | - // The previous fix was fixed properly by Martin Richter | 5506 | + // The previous fix was fixed properly by Martin Richter <martin.richter@grutzeck.de> |
5493 | while (rectCell.right > rectWindow.right | 5507 | while (rectCell.right > rectWindow.right |
5494 | - && rectCell.left > GetFixedColumnWidth() | ||
5495 | - && IsVisibleHScroll() // Junlin Xu: added to prevent infinite loop | ||
5496 | - ) | 5508 | + && rectCell.left > GetFixedColumnWidth()) |
5497 | { | 5509 | { |
5498 | SendMessage(WM_HSCROLL, SB_LINERIGHT, 0); | 5510 | SendMessage(WM_HSCROLL, SB_LINERIGHT, 0); |
5499 | if (!GetCellRect(nRow, nCol, rectCell)) | 5511 | if (!GetCellRect(nRow, nCol, rectCell)) |
5500 | { | 5512 | { |
5501 | - pFocusWnd->SetFocus(); | 5513 | + if (pFocusWnd && ::IsWindow(pFocusWnd->GetSafeHwnd())) |
5514 | + pFocusWnd->SetFocus(); | ||
5502 | return; | 5515 | return; |
5503 | } | 5516 | } |
5504 | } | 5517 | } |
5505 | 5518 | ||
5506 | while (rectCell.bottom > rectWindow.bottom | 5519 | while (rectCell.bottom > rectWindow.bottom |
5507 | - && rectCell.top > GetFixedRowHeight() | ||
5508 | - && IsVisibleVScroll() // Junlin Xu: added to prevent infinite loop | ||
5509 | - ) | 5520 | + && rectCell.top > GetFixedRowHeight()) |
5510 | { | 5521 | { |
5511 | SendMessage(WM_VSCROLL, SB_LINEDOWN, 0); | 5522 | SendMessage(WM_VSCROLL, SB_LINEDOWN, 0); |
5512 | if (!GetCellRect(nRow, nCol, rectCell)) | 5523 | if (!GetCellRect(nRow, nCol, rectCell)) |
5513 | { | 5524 | { |
5514 | - pFocusWnd->SetFocus(); | 5525 | + if (pFocusWnd && ::IsWindow(pFocusWnd->GetSafeHwnd())) |
5526 | + pFocusWnd->SetFocus(); | ||
5515 | return; | 5527 | return; |
5516 | } | 5528 | } |
5517 | } | 5529 | } |
5518 | 5530 | ||
5519 | // restore focus to whoever owned it | 5531 | // restore focus to whoever owned it |
5520 | - pFocusWnd->SetFocus(); | 5532 | + if (pFocusWnd && ::IsWindow(pFocusWnd->GetSafeHwnd())) |
5533 | + pFocusWnd->SetFocus(); | ||
5521 | } | 5534 | } |
5522 | 5535 | ||
5523 | BOOL CGridCtrl::IsCellEditable(CCellID &cell) const | 5536 | BOOL CGridCtrl::IsCellEditable(CCellID &cell) const |
@@ -5798,7 +5811,7 @@ void CGridCtrl::OnMouseMove(UINT /*nFlags*/, CPoint point) | @@ -5798,7 +5811,7 @@ void CGridCtrl::OnMouseMove(UINT /*nFlags*/, CPoint point) | ||
5798 | && pCell->GetTipTextRect( &TextRect) | 5811 | && pCell->GetTipTextRect( &TextRect) |
5799 | && GetCellRect(idCurrentCell.row, idCurrentCell.col, CellRect) ) | 5812 | && GetCellRect(idCurrentCell.row, idCurrentCell.col, CellRect) ) |
5800 | { | 5813 | { |
5801 | -// TRACE0("Showing TitleTip\n"); | 5814 | + TRACE0("Showing TitleTip\n"); |
5802 | m_TitleTip.Show(TextRect, pCell->GetTipText(), 0, CellRect, | 5815 | m_TitleTip.Show(TextRect, pCell->GetTipText(), 0, CellRect, |
5803 | pCell->GetFont(), GetTitleTipTextClr(), GetTitleTipBackClr()); | 5816 | pCell->GetFont(), GetTitleTipTextClr(), GetTitleTipBackClr()); |
5804 | } | 5817 | } |
@@ -6033,13 +6046,12 @@ void CGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) | @@ -6033,13 +6046,12 @@ void CGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) | ||
6033 | // CWnd::OnLButtonDown(nFlags, point); | 6046 | // CWnd::OnLButtonDown(nFlags, point); |
6034 | 6047 | ||
6035 | SetFocus(); | 6048 | SetFocus(); |
6036 | - m_CurCol = -1; | 6049 | + |
6037 | m_bLMouseButtonDown = TRUE; | 6050 | m_bLMouseButtonDown = TRUE; |
6038 | m_LeftClickDownPoint = point; | 6051 | m_LeftClickDownPoint = point; |
6039 | m_LeftClickDownCell = GetCellFromPt(point); | 6052 | m_LeftClickDownCell = GetCellFromPt(point); |
6040 | if (!IsValid(m_LeftClickDownCell)) | 6053 | if (!IsValid(m_LeftClickDownCell)) |
6041 | return; | 6054 | return; |
6042 | - m_CurRow = m_LeftClickDownCell.row; | ||
6043 | 6055 | ||
6044 | // If the SHIFT key is not down, then the start of the selection area should be the | 6056 | // If the SHIFT key is not down, then the start of the selection area should be the |
6045 | // cell just clicked. Otherwise, keep the previous selection-start-cell so the user | 6057 | // cell just clicked. Otherwise, keep the previous selection-start-cell so the user |
@@ -6085,8 +6097,6 @@ void CGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) | @@ -6085,8 +6097,6 @@ void CGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) | ||
6085 | // (If the user moves the mouse, then dragging occurs) | 6097 | // (If the user moves the mouse, then dragging occurs) |
6086 | else if (IsCellSelected(m_LeftClickDownCell)) | 6098 | else if (IsCellSelected(m_LeftClickDownCell)) |
6087 | { | 6099 | { |
6088 | - SetFocusCell(m_LeftClickDownCell.row, m_LeftClickDownCell.col); | ||
6089 | - | ||
6090 | // If control is pressed then unselect the cell or row (depending on the list mode) | 6100 | // If control is pressed then unselect the cell or row (depending on the list mode) |
6091 | if (nFlags & MK_CONTROL) | 6101 | if (nFlags & MK_CONTROL) |
6092 | { | 6102 | { |
@@ -6355,16 +6365,7 @@ void CGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) | @@ -6355,16 +6365,7 @@ void CGridCtrl::OnLButtonDown(UINT nFlags, CPoint point) | ||
6355 | } | 6365 | } |
6356 | 6366 | ||
6357 | if (m_LeftClickDownCell.row < GetFixedRowCount()) | 6367 | if (m_LeftClickDownCell.row < GetFixedRowCount()) |
6358 | - { | ||
6359 | OnFixedRowClick(m_LeftClickDownCell); | 6368 | OnFixedRowClick(m_LeftClickDownCell); |
6360 | - if(m_AllowReorderColumn && m_LeftClickDownCell.col >= GetFixedColumnCount()) | ||
6361 | - { | ||
6362 | - ResetSelectedRange(); // TODO : This is not the better solution, as we do not see why clicking in column header should reset selection | ||
6363 | - //but the state of selection is instable after drag (at least until someone debugs it), so better clear it allways. | ||
6364 | - m_MouseMode = MOUSE_PREPARE_DRAG; | ||
6365 | - m_CurCol = m_LeftClickDownCell.col; | ||
6366 | - } | ||
6367 | - } | ||
6368 | else if (m_LeftClickDownCell.col < GetFixedColumnCount()) | 6369 | else if (m_LeftClickDownCell.col < GetFixedColumnCount()) |
6369 | OnFixedColumnClick(m_LeftClickDownCell); | 6370 | OnFixedColumnClick(m_LeftClickDownCell); |
6370 | else | 6371 | else |
@@ -6436,12 +6437,18 @@ void CGridCtrl::OnLButtonUp(UINT nFlags, CPoint point) | @@ -6436,12 +6437,18 @@ void CGridCtrl::OnLButtonUp(UINT nFlags, CPoint point) | ||
6436 | if (m_LeftClickDownPoint != point && (point.x != 0 || point.y != 0)) // 0 pt fix by email1@bierling.net | 6437 | if (m_LeftClickDownPoint != point && (point.x != 0 || point.y != 0)) // 0 pt fix by email1@bierling.net |
6437 | { | 6438 | { |
6438 | CPoint start; | 6439 | CPoint start; |
6440 | + //Used for merge cells | ||
6441 | + //by Huang Wei | ||
6442 | + m_LeftClickDownCell=GetMergeCellID(m_LeftClickDownCell); | ||
6439 | if (!GetCellOrigin(m_LeftClickDownCell, &start)) | 6443 | if (!GetCellOrigin(m_LeftClickDownCell, &start)) |
6440 | return; | 6444 | return; |
6441 | 6445 | ||
6442 | - int nColumnWidth = __max(point.x - start.x, m_bAllowColHide? 0 : 1); | 6446 | + int nColumnWidth = max(point.x - start.x, m_bAllowColHide? 0 : 1); |
6447 | + //Used for merge cells | ||
6448 | + //by Huang Wei | ||
6449 | + int mergewidth=GetMergeCellWidth(m_LeftClickDownCell)-GetColumnWidth(m_LeftClickDownCell.col); | ||
6450 | + SetColumnWidth(m_LeftClickDownCell.col, nColumnWidth-mergewidth); | ||
6443 | 6451 | ||
6444 | - SetColumnWidth(m_LeftClickDownCell.col, nColumnWidth); | ||
6445 | ResetScrollBars(); | 6452 | ResetScrollBars(); |
6446 | Invalidate(); | 6453 | Invalidate(); |
6447 | } | 6454 | } |
@@ -6462,12 +6469,18 @@ void CGridCtrl::OnLButtonUp(UINT nFlags, CPoint point) | @@ -6462,12 +6469,18 @@ void CGridCtrl::OnLButtonUp(UINT nFlags, CPoint point) | ||
6462 | if (m_LeftClickDownPoint != point && (point.x != 0 || point.y != 0)) // 0 pt fix by email1@bierling.net | 6469 | if (m_LeftClickDownPoint != point && (point.x != 0 || point.y != 0)) // 0 pt fix by email1@bierling.net |
6463 | { | 6470 | { |
6464 | CPoint start; | 6471 | CPoint start; |
6472 | + //Used for merge cells | ||
6473 | + //by Huang Wei | ||
6474 | + m_LeftClickDownCell=GetMergeCellID(m_LeftClickDownCell); | ||
6465 | if (!GetCellOrigin(m_LeftClickDownCell, &start)) | 6475 | if (!GetCellOrigin(m_LeftClickDownCell, &start)) |
6466 | return; | 6476 | return; |
6467 | 6477 | ||
6468 | - int nRowHeight = __max(point.y - start.y, m_bAllowRowHide? 0 : 1); | 6478 | + int nRowHeight = max(point.y - start.y, m_bAllowRowHide? 0 : 1); |
6479 | + //Used for merge cells | ||
6480 | + //by Huang Wei | ||
6481 | + int mergeheight=GetMergeCellHeight(m_LeftClickDownCell)-GetRowHeight(m_LeftClickDownCell.row); | ||
6469 | 6482 | ||
6470 | - SetRowHeight(m_LeftClickDownCell.row, nRowHeight); | 6483 | + SetRowHeight(m_LeftClickDownCell.row, nRowHeight-mergeheight); |
6471 | ResetScrollBars(); | 6484 | ResetScrollBars(); |
6472 | Invalidate(); | 6485 | Invalidate(); |
6473 | } | 6486 | } |
@@ -6509,7 +6522,6 @@ void CGridCtrl::OnRButtonDown(UINT nFlags, CPoint point) | @@ -6509,7 +6522,6 @@ void CGridCtrl::OnRButtonDown(UINT nFlags, CPoint point) | ||
6509 | #endif | 6522 | #endif |
6510 | } | 6523 | } |
6511 | 6524 | ||
6512 | -#include "resource.h" | ||
6513 | // EFW - Added to forward right click to parent so that a context | 6525 | // EFW - Added to forward right click to parent so that a context |
6514 | // menu can be shown without deriving a new grid class. | 6526 | // menu can be shown without deriving a new grid class. |
6515 | void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point) | 6527 | void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point) |
@@ -6529,8 +6541,8 @@ void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point) | @@ -6529,8 +6541,8 @@ void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point) | ||
6529 | else | 6541 | else |
6530 | { | 6542 | { |
6531 | SetFocusCell(-1,-1); | 6543 | SetFocusCell(-1,-1); |
6532 | - SetFocusCell(__max(FocusCell.row, m_nFixedRows), | ||
6533 | - __max(FocusCell.col, m_nFixedCols)); | 6544 | + SetFocusCell(max(FocusCell.row, m_nFixedRows), |
6545 | + max(FocusCell.col, m_nFixedCols)); | ||
6534 | 6546 | ||
6535 | // tell the cell about it | 6547 | // tell the cell about it |
6536 | CGridCellBase* pCell = GetCell(FocusCell.row, FocusCell.col); | 6548 | CGridCellBase* pCell = GetCell(FocusCell.row, FocusCell.col); |
@@ -6539,13 +6551,6 @@ void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point) | @@ -6539,13 +6551,6 @@ void CGridCtrl::OnRButtonUp(UINT nFlags, CPoint point) | ||
6539 | 6551 | ||
6540 | SendMessageToParent(FocusCell.row, FocusCell.col, NM_RCLICK); | 6552 | SendMessageToParent(FocusCell.row, FocusCell.col, NM_RCLICK); |
6541 | } | 6553 | } |
6542 | - | ||
6543 | - //右键菜单 | ||
6544 | - CMenu menu; | ||
6545 | - menu.LoadMenu(IDR_MENU1); | ||
6546 | - CMenu *pPopup = menu.GetSubMenu(0); | ||
6547 | - GetCursorPos(&point);//获取当前光标的位置,以便使得菜单可以跟随光标 | ||
6548 | - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, GetParent());//在指定位置显示弹出菜单 | ||
6549 | } | 6554 | } |
6550 | #endif | 6555 | #endif |
6551 | 6556 | ||
@@ -6676,7 +6681,7 @@ void CGridCtrl::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) | @@ -6676,7 +6681,7 @@ void CGridCtrl::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) | ||
6676 | 6681 | ||
6677 | // Create the printer font | 6682 | // Create the printer font |
6678 | int nFontSize = -10; | 6683 | int nFontSize = -10; |
6679 | - CString strFontName = _T("Arial"); | 6684 | + CString strFontName = L"Arial"; |
6680 | m_PrinterFont.CreateFont(nFontSize, 0,0,0, FW_NORMAL, 0,0,0, DEFAULT_CHARSET, | 6685 | m_PrinterFont.CreateFont(nFontSize, 0,0,0, FW_NORMAL, 0,0,0, DEFAULT_CHARSET, |
6681 | OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, | 6686 | OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, |
6682 | DEFAULT_PITCH | FF_DONTCARE, strFontName); | 6687 | DEFAULT_PITCH | FF_DONTCARE, strFontName); |
@@ -6894,6 +6899,25 @@ void CGridCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo) | @@ -6894,6 +6899,25 @@ void CGridCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo) | ||
6894 | BOOL bFirstPrintedRow = TRUE; | 6899 | BOOL bFirstPrintedRow = TRUE; |
6895 | CRect rect; | 6900 | CRect rect; |
6896 | rect.bottom = -1; | 6901 | rect.bottom = -1; |
6902 | + | ||
6903 | + //Used for merge cells | ||
6904 | + //by Huang Wei | ||
6905 | + int Row=m_nCurrPrintRow; | ||
6906 | + CRect range; | ||
6907 | + range.bottom = -1; | ||
6908 | + while (Row < GetRowCount()) | ||
6909 | + { | ||
6910 | + range.top = range.bottom+1; | ||
6911 | + range.bottom = range.top + GetRowHeight(Row) - 1; | ||
6912 | + | ||
6913 | + if (range.bottom > m_nPageHeight) | ||
6914 | + { | ||
6915 | + range.bottom=range.top; | ||
6916 | + break; | ||
6917 | + } | ||
6918 | + Row++; | ||
6919 | + } | ||
6920 | + | ||
6897 | while (m_nCurrPrintRow < GetRowCount()) | 6921 | while (m_nCurrPrintRow < GetRowCount()) |
6898 | { | 6922 | { |
6899 | rect.top = rect.bottom+1; | 6923 | rect.top = rect.bottom+1; |
@@ -6916,34 +6940,60 @@ void CGridCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo) | @@ -6916,34 +6940,60 @@ void CGridCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo) | ||
6916 | 6940 | ||
6917 | CGridCellBase* pCell = GetCell(m_nCurrPrintRow, col); | 6941 | CGridCellBase* pCell = GetCell(m_nCurrPrintRow, col); |
6918 | if (pCell) | 6942 | if (pCell) |
6919 | - pCell->PrintCell(pDC, m_nCurrPrintRow, col, rect); | 6943 | + { |
6944 | + //Used for merge cells | ||
6945 | + //by Huang Wei | ||
6946 | + int row=m_nCurrPrintRow; | ||
6947 | + if(!pCell->IsMerged()) | ||
6948 | + { | ||
6949 | + if(!pCell->IsMergeWithOthers()) | ||
6950 | + { | ||
6951 | + pCell->PrintCell(pDC, row, col, rect); | ||
6952 | + } | ||
6953 | + } | ||
6954 | + else | ||
6955 | + { | ||
6956 | + CRect mergerect=rect; | ||
6957 | + if(GetCellRangeRect(pCell->m_MergeRange,&mergerect)) | ||
6958 | + { | ||
6959 | + //mergerect.DeflateRect(0,0,1,1); | ||
6960 | + mergerect.OffsetRect(rect.TopLeft()-mergerect.TopLeft()); | ||
6961 | + pCell->PrintCell(pDC, row, col, mergerect); | ||
6962 | + } | ||
6963 | + } | ||
6964 | + } | ||
6920 | 6965 | ||
6921 | - if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_HORZ) | ||
6922 | - { | ||
6923 | - int Overlap = (col == 0)? 0:1; | ||
6924 | - pDC->MoveTo(rect.left-Overlap, rect.bottom); | ||
6925 | - pDC->LineTo(rect.right, rect.bottom); | ||
6926 | - if (m_nCurrPrintRow == 0) { | ||
6927 | - pDC->MoveTo(rect.left-Overlap, rect.top); | ||
6928 | - pDC->LineTo(rect.right, rect.top); | ||
6929 | - } | ||
6930 | - } | ||
6931 | - if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_VERT) | ||
6932 | - { | ||
6933 | - int Overlap = (bFirstPrintedRow)? 0:1; | ||
6934 | - pDC->MoveTo(rect.right, rect.top-Overlap); | ||
6935 | - pDC->LineTo(rect.right, rect.bottom); | ||
6936 | - if (col == 0) { | ||
6937 | - pDC->MoveTo(rect.left, rect.top-Overlap); | ||
6938 | - pDC->LineTo(rect.left, rect.bottom); | ||
6939 | - } | ||
6940 | - } | 6966 | + //if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_HORZ) |
6967 | + //{ | ||
6968 | + // int Overlap = (col == 0)? 0:1; | ||
6969 | + // pDC->MoveTo(rect.left-Overlap, rect.bottom); | ||
6970 | + // pDC->LineTo(rect.right, rect.bottom); | ||
6971 | + // if (m_nCurrPrintRow == 0) { | ||
6972 | + // pDC->MoveTo(rect.left-Overlap, rect.top); | ||
6973 | + // pDC->LineTo(rect.right, rect.top); | ||
6974 | + // } | ||
6975 | + //} | ||
6976 | + //if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_VERT) | ||
6977 | + //{ | ||
6978 | + // int Overlap = (bFirstPrintedRow)? 0:1; | ||
6979 | + // pDC->MoveTo(rect.right, rect.top-Overlap); | ||
6980 | + // pDC->LineTo(rect.right, rect.bottom); | ||
6981 | + // if (col == 0) { | ||
6982 | + // pDC->MoveTo(rect.left, rect.top-Overlap); | ||
6983 | + // pDC->LineTo(rect.left, rect.bottom); | ||
6984 | + // } | ||
6985 | + //} | ||
6941 | 6986 | ||
6942 | } | 6987 | } |
6943 | m_nCurrPrintRow++; | 6988 | m_nCurrPrintRow++; |
6944 | bFirstPrintedRow = FALSE; | 6989 | bFirstPrintedRow = FALSE; |
6945 | } | 6990 | } |
6946 | 6991 | ||
6992 | + //Used for merge cells | ||
6993 | + //by Huang Wei | ||
6994 | + CRect white_rect(CPoint(0,0),m_LogicalPageSize); | ||
6995 | + white_rect.top=range.bottom+1; | ||
6996 | + pDC->FillSolidRect(white_rect,RGB(255,255,255)); | ||
6947 | 6997 | ||
6948 | // Footer | 6998 | // Footer |
6949 | pInfo->m_rectDraw.bottom = m_nFooterHeight * m_CharSize.cy; | 6999 | pInfo->m_rectDraw.bottom = m_nFooterHeight * m_CharSize.cy; |
@@ -6973,37 +7023,58 @@ void CGridCtrl::PrintFixedRowCells(int nStartColumn, int nStopColumn, int& row, | @@ -6973,37 +7023,58 @@ void CGridCtrl::PrintFixedRowCells(int nStartColumn, int nStopColumn, int& row, | ||
6973 | 7023 | ||
6974 | CGridCellBase* pCell = GetCell(row, col); | 7024 | CGridCellBase* pCell = GetCell(row, col); |
6975 | if (pCell) | 7025 | if (pCell) |
6976 | - pCell->PrintCell(pDC, row, col, rect); | 7026 | + { |
7027 | + //Used for merge cells | ||
7028 | + //by Huang Wei | ||
7029 | + int row=m_nCurrPrintRow; | ||
7030 | + if(!pCell->IsMerged()) | ||
7031 | + { | ||
7032 | + if(!pCell->IsMergeWithOthers()) | ||
7033 | + { | ||
7034 | + pCell->PrintCell(pDC, row, col, rect); | ||
7035 | + } | ||
7036 | + } | ||
7037 | + else | ||
7038 | + { | ||
7039 | + CRect mergerect=rect; | ||
7040 | + if(GetCellRangeRect(pCell->m_MergeRange,&mergerect)) | ||
7041 | + { | ||
7042 | + //mergerect.DeflateRect(0,0,1,1); | ||
7043 | + mergerect.OffsetRect(rect.TopLeft()-mergerect.TopLeft()); | ||
7044 | + pCell->PrintCell(pDC, row, col, mergerect); | ||
7045 | + } | ||
7046 | + } | ||
7047 | + } | ||
6977 | 7048 | ||
6978 | - if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_HORZ) | ||
6979 | - { | ||
6980 | - int Overlap = (col == 0)? 0:1; | ||
6981 | - | ||
6982 | - pDC->MoveTo(rect.left-Overlap, rect.bottom); | ||
6983 | - pDC->LineTo(rect.right, rect.bottom); | ||
6984 | - | ||
6985 | - if (row == 0) | ||
6986 | - { | ||
6987 | - pDC->MoveTo(rect.left-Overlap, rect.top); | ||
6988 | - pDC->LineTo(rect.right, rect.top); | ||
6989 | - } | ||
6990 | - } | ||
6991 | - | ||
6992 | - if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_VERT) | ||
6993 | - { | ||
6994 | - int Overlap = (row == 0)? 0:1; | ||
6995 | - | ||
6996 | - pDC->MoveTo(rect.right, rect.top-Overlap); | ||
6997 | - pDC->LineTo(rect.right, rect.bottom); | ||
6998 | - | ||
6999 | - if( bFirst) | ||
7000 | - { | ||
7001 | - pDC->MoveTo(rect.left-1, rect.top-Overlap); | ||
7002 | - pDC->LineTo(rect.left-1, rect.bottom); | ||
7003 | - bFirst = FALSE; | ||
7004 | - } | ||
7005 | - | ||
7006 | - } | 7049 | + //if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_HORZ) |
7050 | + //{ | ||
7051 | + // int Overlap = (col == 0)? 0:1; | ||
7052 | + // | ||
7053 | + // pDC->MoveTo(rect.left-Overlap, rect.bottom); | ||
7054 | + // pDC->LineTo(rect.right, rect.bottom); | ||
7055 | + // | ||
7056 | + // if (row == 0) | ||
7057 | + // { | ||
7058 | + // pDC->MoveTo(rect.left-Overlap, rect.top); | ||
7059 | + // pDC->LineTo(rect.right, rect.top); | ||
7060 | + // } | ||
7061 | + //} | ||
7062 | + | ||
7063 | + //if (m_nGridLines == GVL_BOTH || m_nGridLines == GVL_VERT) | ||
7064 | + //{ | ||
7065 | + // int Overlap = (row == 0)? 0:1; | ||
7066 | + | ||
7067 | + // pDC->MoveTo(rect.right, rect.top-Overlap); | ||
7068 | + // pDC->LineTo(rect.right, rect.bottom); | ||
7069 | + // | ||
7070 | + // if( bFirst) | ||
7071 | + // { | ||
7072 | + // pDC->MoveTo(rect.left-1, rect.top-Overlap); | ||
7073 | + // pDC->LineTo(rect.left-1, rect.bottom); | ||
7074 | + // bFirst = FALSE; | ||
7075 | + // } | ||
7076 | + | ||
7077 | + // } | ||
7007 | 7078 | ||
7008 | } // end of column cells loop | 7079 | } // end of column cells loop |
7009 | 7080 | ||
@@ -7297,7 +7368,7 @@ BOOL CGridCtrl::Load(LPCTSTR filename, TCHAR chSeparator/*=_T(',')*/) | @@ -7297,7 +7368,7 @@ BOOL CGridCtrl::Load(LPCTSTR filename, TCHAR chSeparator/*=_T(',')*/) | ||
7297 | } | 7368 | } |
7298 | 7369 | ||
7299 | // Read in rest of data | 7370 | // Read in rest of data |
7300 | - int nItem = 1; | 7371 | + int nItem = 0; |
7301 | while (File.ReadString(buffer, 1024)) | 7372 | while (File.ReadString(buffer, 1024)) |
7302 | { | 7373 | { |
7303 | // Get first token | 7374 | // Get first token |
@@ -7567,24 +7638,116 @@ CString CGridCtrl::GetItemText(int nRow, int nCol) const | @@ -7567,24 +7638,116 @@ CString CGridCtrl::GetItemText(int nRow, int nCol) const | ||
7567 | 7638 | ||
7568 | return pCell->GetText(); | 7639 | return pCell->GetText(); |
7569 | } | 7640 | } |
7570 | - | ||
7571 | -void CGridCtrl::ResetVirtualOrder() | 7641 | +//Merge the selected cells |
7642 | +//by Huang Wei | ||
7643 | +CCellID CGridCtrl::GetMergeCellID(CCellID cell) | ||
7644 | +{ | ||
7645 | + CGridCellBase *pCell = (CGridCellBase*) GetCell(cell); | ||
7646 | + if(pCell && pCell->IsMergeWithOthers()) | ||
7647 | + return pCell->GetMergeCellID(); | ||
7648 | + return cell; | ||
7649 | +} | ||
7650 | +//Merge the selected cells | ||
7651 | +//by Huang Wei | ||
7652 | +CGridCellBase* CGridCtrl::GetCell(CCellID cell) | ||
7572 | { | 7653 | { |
7573 | - m_arRowOrder.resize(m_nRows); | ||
7574 | - for (int i = 0; i < m_nRows; i++) | 7654 | + return GetCell(cell.row,cell.col); |
7655 | +} | ||
7656 | +//Merge the selected cells | ||
7657 | +//by Huang Wei | ||
7658 | +void CGridCtrl::MergeSelectedCells() | ||
7659 | +{ | ||
7660 | + CCellRange range=GetSelectedCellRange(); | ||
7661 | + if(range.GetColSpan()<=1 && range.GetRowSpan()<=1) | ||
7662 | + return; | ||
7663 | + MergeCells(range.GetMinRow(), range.GetMinCol(), range.GetMaxRow(), range.GetMaxCol()); | ||
7664 | +} | ||
7665 | +//Merge the selected cells | ||
7666 | +//by Huang Wei | ||
7667 | +void CGridCtrl::MergeCells(int nStartRow, int nStartCol, int nEndRow, int nEndCol) | ||
7668 | +{ | ||
7669 | + for(int row=nStartRow;row<=nEndRow;row++) | ||
7575 | { | 7670 | { |
7576 | - m_arRowOrder[i] = i; | 7671 | + for(int col=nStartCol;col<=nEndCol;col++) |
7672 | + { | ||
7673 | + CGridCellBase *pCell = (CGridCellBase*) GetCell(row,col); | ||
7674 | + pCell->Show(false); | ||
7675 | + if(row==nStartRow && col==nStartCol) | ||
7676 | + { | ||
7677 | + CCellRange range(nStartRow, nStartCol, nEndRow, nEndCol); | ||
7678 | + pCell->SetMergeRange(range); | ||
7679 | + } | ||
7680 | + else | ||
7681 | + { | ||
7682 | + CCellID cell(nStartRow,nStartCol); | ||
7683 | + pCell->SetMergeCellID(cell); | ||
7684 | + } | ||
7685 | + | ||
7686 | + } | ||
7577 | } | 7687 | } |
7688 | + Invalidate(); | ||
7578 | } | 7689 | } |
7579 | - | ||
7580 | - | ||
7581 | -void CGridCtrl::Reorder(int From, int To) | 7690 | +//Merge the selected cells |
7691 | +//by Huang Wei | ||
7692 | +void CGridCtrl::UnMergeSelectedCells() | ||
7582 | { | 7693 | { |
7583 | - // Set line From just after Line To | ||
7584 | - ASSERT(From>= GetFixedRowCount() && To>=GetFixedRowCount()-1 && From<m_nRows && To<m_nRows); | ||
7585 | - int Value = m_arRowOrder[From]; | ||
7586 | - m_arRowOrder.erase(m_arRowOrder.begin()+From); | ||
7587 | - int Offset = (From>=To ? 1:0); | ||
7588 | - m_arRowOrder.insert(m_arRowOrder.begin()+To+Offset, Value); | 7694 | + CCellRange range=GetSelectedCellRange(); |
7695 | + UnMergeCells(range.GetMinRow(), range.GetMinCol(), range.GetMaxRow(), range.GetMaxCol()); | ||
7696 | +} | ||
7697 | +//Merge the selected cells | ||
7698 | +//by Huang Wei | ||
7699 | +void CGridCtrl::UnMergeCells(int nStartRow, int nStartCol, int nEndRow, int nEndCol) | ||
7700 | +{ | ||
7701 | + for(int row=nStartRow;row<=nEndRow;row++) | ||
7702 | + { | ||
7703 | + for(int col=nStartCol;col<=nEndCol;col++) | ||
7704 | + { | ||
7705 | + CGridCellBase *pCell = (CGridCellBase*) GetCell(row,col); | ||
7706 | + if(pCell->IsMerged()) | ||
7707 | + { | ||
7708 | + for(int mergerow=pCell->GetMergeRange().GetMaxRow();mergerow>=pCell->GetMergeRange().GetMinRow();mergerow--) | ||
7709 | + for(int mergecol=pCell->GetMergeRange().GetMaxCol();mergecol>=pCell->GetMergeRange().GetMinCol();mergecol--) | ||
7710 | + { | ||
7711 | + if(pCell->GetMergeRange().GetMaxRow()==-1 || pCell->GetMergeRange().GetMaxCol()==-1) | ||
7712 | + break; | ||
7713 | + CGridCellBase *pMergedCell = (CGridCellBase*) GetCell(mergerow,mergecol); | ||
7714 | + pMergedCell->UnMerge(); | ||
7715 | + } | ||
7589 | 7716 | ||
7717 | + } | ||
7718 | + else | ||
7719 | + pCell->UnMerge(); | ||
7720 | + } | ||
7721 | + } | ||
7722 | + Invalidate(); | ||
7723 | +} | ||
7724 | +//Merge the selected cells | ||
7725 | +//by Huang Wei | ||
7726 | +int CGridCtrl::GetMergeCellWidth(CCellID cell) | ||
7727 | +{ | ||
7728 | + CCellID mergecell =GetMergeCellID(cell); | ||
7729 | + CGridCellBase *pCell = (CGridCellBase*) GetCell(mergecell); | ||
7730 | + if(!pCell->IsMerged()) | ||
7731 | + return GetColumnWidth(cell.col); | ||
7732 | + int width=0; | ||
7733 | + for(int mergecol=pCell->GetMergeRange().GetMaxCol();mergecol>=pCell->GetMergeRange().GetMinCol();mergecol--) | ||
7734 | + { | ||
7735 | + width+=GetColumnWidth(mergecol); | ||
7736 | + } | ||
7737 | + return width; | ||
7738 | +} | ||
7739 | +//Merge the selected cells | ||
7740 | +//by Huang Wei | ||
7741 | +int CGridCtrl::GetMergeCellHeight(CCellID cell) | ||
7742 | +{ | ||
7743 | + CCellID mergecell =GetMergeCellID(cell); | ||
7744 | + CGridCellBase *pCell = (CGridCellBase*) GetCell(mergecell); | ||
7745 | + if(!pCell->IsMerged()) | ||
7746 | + return GetRowHeight(cell.row); | ||
7747 | + int height=0; | ||
7748 | + for(int mergerow=pCell->GetMergeRange().GetMaxRow();mergerow>=pCell->GetMergeRange().GetMinRow();mergerow--) | ||
7749 | + { | ||
7750 | + height+=GetRowHeight(mergerow); | ||
7751 | + } | ||
7752 | + return height; | ||
7590 | } | 7753 | } |
central_clearing_system/ETradeClient/mfc_ui/GridCtrl.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | // | 3 | // |
4 | // MFC Grid Control - main header | 4 | // MFC Grid Control - main header |
5 | // | 5 | // |
6 | -// Written by Chris Maunder <chris@codeproject.com> | ||
7 | -// Copyright (c) 1998-2005. All Rights Reserved. | 6 | +// Written by Chris Maunder <cmaunder@mail.com> |
7 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
8 | // | 8 | // |
9 | // This code may be used in compiled form in any way you desire. This | 9 | // This code may be used in compiled form in any way you desire. This |
10 | // file may be redistributed unmodified by any means PROVIDING it is | 10 | // file may be redistributed unmodified by any means PROVIDING it is |
@@ -32,7 +32,6 @@ | @@ -32,7 +32,6 @@ | ||
32 | #include "CellRange.h" | 32 | #include "CellRange.h" |
33 | #include "GridCell.h" | 33 | #include "GridCell.h" |
34 | #include <afxtempl.h> | 34 | #include <afxtempl.h> |
35 | -#include <vector> | ||
36 | 35 | ||
37 | 36 | ||
38 | /////////////////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////////////////// |
@@ -181,8 +180,6 @@ class CGridCtrl; | @@ -181,8 +180,6 @@ class CGridCtrl; | ||
181 | ///////////////////////////////////////////////////////////////////////////// | 180 | ///////////////////////////////////////////////////////////////////////////// |
182 | // CGridCtrl window | 181 | // CGridCtrl window |
183 | 182 | ||
184 | -typedef bool (*PVIRTUALCOMPARE)(int, int); | ||
185 | - | ||
186 | class CGridCtrl : public CWnd | 183 | class CGridCtrl : public CWnd |
187 | { | 184 | { |
188 | DECLARE_DYNCREATE(CGridCtrl) | 185 | DECLARE_DYNCREATE(CGridCtrl) |
@@ -537,6 +534,21 @@ public: | @@ -537,6 +534,21 @@ public: | ||
537 | 534 | ||
538 | // Implementation | 535 | // Implementation |
539 | public: | 536 | public: |
537 | + //Merge the selected cells | ||
538 | + //by Huang Wei | ||
539 | + CGridCellBase* GetCell(CCellID cell); | ||
540 | + CCellID GetMergeCellID(CCellID cell); | ||
541 | + void UnMergeSelectedCells(); | ||
542 | + void MergeSelectedCells(); | ||
543 | + void UnMergeCells(int nStartRow, int nStartCol, int nEndRow, int nEndCol); | ||
544 | + void MergeCells(int nStartRow, int nStartCol, int nEndRow, int nEndCol); | ||
545 | + int GetMergeCellWidth(CCellID cell); | ||
546 | + int GetMergeCellHeight(CCellID cell); | ||
547 | + BOOL GetCellOriginNoMerge(int nRow, int nCol, LPPOINT p); | ||
548 | + BOOL GetCellOriginNoMerge(const CCellID& cell, LPPOINT p); | ||
549 | + | ||
550 | + | ||
551 | + | ||
540 | virtual ~CGridCtrl(); | 552 | virtual ~CGridCtrl(); |
541 | 553 | ||
542 | protected: | 554 | protected: |
@@ -566,7 +578,6 @@ protected: | @@ -566,7 +578,6 @@ protected: | ||
566 | CCellID GetTopleftNonFixedCell(BOOL bForceRecalculation = FALSE); | 578 | CCellID GetTopleftNonFixedCell(BOOL bForceRecalculation = FALSE); |
567 | CCellRange GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation = FALSE); | 579 | CCellRange GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation = FALSE); |
568 | CCellRange GetVisibleNonFixedCellRange(LPRECT pRect = NULL, BOOL bForceRecalculation = FALSE); | 580 | CCellRange GetVisibleNonFixedCellRange(LPRECT pRect = NULL, BOOL bForceRecalculation = FALSE); |
569 | - CCellRange GetVisibleFixedCellRange(LPRECT pRect = NULL, BOOL bForceRecalculation = FALSE); | ||
570 | 581 | ||
571 | BOOL IsVisibleVScroll() { return ( (m_nBarState & GVL_VERT) > 0); } | 582 | BOOL IsVisibleVScroll() { return ( (m_nBarState & GVL_VERT) > 0); } |
572 | BOOL IsVisibleHScroll() { return ( (m_nBarState & GVL_HORZ) > 0); } | 583 | BOOL IsVisibleHScroll() { return ( (m_nBarState & GVL_HORZ) > 0); } |
@@ -681,7 +692,7 @@ protected: | @@ -681,7 +692,7 @@ protected: | ||
681 | CPoint m_LeftClickDownPoint, m_LastMousePoint; | 692 | CPoint m_LeftClickDownPoint, m_LastMousePoint; |
682 | CCellID m_LeftClickDownCell, m_SelectionStartCell; | 693 | CCellID m_LeftClickDownCell, m_SelectionStartCell; |
683 | CCellID m_idCurrentCell, m_idTopLeftCell; | 694 | CCellID m_idCurrentCell, m_idTopLeftCell; |
684 | - INT_PTR m_nTimerID; | 695 | + int m_nTimerID; |
685 | int m_nTimerInterval; | 696 | int m_nTimerInterval; |
686 | int m_nResizeCaptureRange; | 697 | int m_nResizeCaptureRange; |
687 | BOOL m_bAllowRowResize, m_bAllowColumnResize; | 698 | BOOL m_bAllowRowResize, m_bAllowColumnResize; |
@@ -787,34 +798,6 @@ protected: | @@ -787,34 +798,6 @@ protected: | ||
787 | MOUSE_PREPARE_DRAG, MOUSE_DRAGGING | 798 | MOUSE_PREPARE_DRAG, MOUSE_DRAGGING |
788 | #endif | 799 | #endif |
789 | }; | 800 | }; |
790 | -// for sort in virtual mode, and column order, save and load layer | ||
791 | -public: | ||
792 | - typedef std::vector<int> intlist; | ||
793 | - void Reorder(int From, int To); | ||
794 | - void SetVirtualCompare(PVIRTUALCOMPARE VirtualCompare) { m_pfnVirtualCompare = VirtualCompare;} | ||
795 | - int m_CurCol; | ||
796 | - void AllowReorderColumn(bool b=true) { m_AllowReorderColumn = b;} | ||
797 | - void EnableDragRowMode(bool b=true) { m_bDragRowMode = b; if(b) EnableDragAndDrop(); } // to change row order | ||
798 | - int GetLayer(int** pLayer); // gives back the number of ints of the area (do not forget to delete *pLayer) | ||
799 | - void SetLayer(int* pLayer); // coming from a previous GetLayer (ignored if not same number of column, or the same revision number) | ||
800 | - void ForceQuitFocusOnTab(bool b=true) { m_QuitFocusOnTab = b;} // use only if GetParent() is a CDialog | ||
801 | - void AllowSelectRowInFixedCol(bool b=true) { m_AllowSelectRowInFixedCol = b;} // | ||
802 | -// allow acces? | ||
803 | - intlist m_arRowOrder, m_arColOrder; | ||
804 | - static CGridCtrl* m_This; | ||
805 | -protected: | ||
806 | - virtual void AddSubVirtualRow(int Num, int Nb); | ||
807 | - bool m_bDragRowMode; | ||
808 | - int m_CurRow; | ||
809 | -private: | ||
810 | - void ResetVirtualOrder(); | ||
811 | - PVIRTUALCOMPARE m_pfnVirtualCompare; | ||
812 | - static bool NotVirtualCompare(int c1, int c2); | ||
813 | - bool m_InDestructor; | ||
814 | - bool m_AllowReorderColumn; | ||
815 | - bool m_QuitFocusOnTab; | ||
816 | - bool m_AllowSelectRowInFixedCol; | ||
817 | - | ||
818 | }; | 801 | }; |
819 | 802 | ||
820 | // Returns the default cell implementation for the given grid region | 803 | // Returns the default cell implementation for the given grid region |
@@ -853,18 +836,12 @@ inline CGridCellBase* CGridCtrl::GetCell(int nRow, int nCol) const | @@ -853,18 +836,12 @@ inline CGridCellBase* CGridCtrl::GetCell(int nRow, int nCol) const | ||
853 | if (nRow < GetFixedRowCount()) gvdi.item.nState |= (GVIS_FIXED | GVIS_FIXEDROW); | 836 | if (nRow < GetFixedRowCount()) gvdi.item.nState |= (GVIS_FIXED | GVIS_FIXEDROW); |
854 | if (nCol < GetFixedColumnCount()) gvdi.item.nState |= (GVIS_FIXED | GVIS_FIXEDCOL); | 837 | if (nCol < GetFixedColumnCount()) gvdi.item.nState |= (GVIS_FIXED | GVIS_FIXEDCOL); |
855 | if (GetFocusCell() == CCellID(nRow, nCol)) gvdi.item.nState |= GVIS_FOCUSED; | 838 | if (GetFocusCell() == CCellID(nRow, nCol)) gvdi.item.nState |= GVIS_FOCUSED; |
856 | - if(!m_InDestructor) | ||
857 | - { | ||
858 | - gvdi.item.row = m_arRowOrder[nRow]; | ||
859 | - gvdi.item.col = m_arColOrder[nCol]; | ||
860 | - | ||
861 | - if (m_pfnCallback) | ||
862 | - m_pfnCallback(&gvdi, m_lParam); | ||
863 | - else | ||
864 | - SendDisplayRequestToParent(&gvdi); | ||
865 | - gvdi.item.row = nRow; | ||
866 | - gvdi.item.col = nCol; | ||
867 | - } | 839 | + |
840 | + if (m_pfnCallback) | ||
841 | + m_pfnCallback(&gvdi, m_lParam); | ||
842 | + else | ||
843 | + SendDisplayRequestToParent(&gvdi); | ||
844 | + | ||
868 | static CGridCell cell; | 845 | static CGridCell cell; |
869 | cell.SetState(gvdi.item.nState); | 846 | cell.SetState(gvdi.item.nState); |
870 | cell.SetFormat(gvdi.item.nFormat); | 847 | cell.SetFormat(gvdi.item.nFormat); |
@@ -882,7 +859,7 @@ inline CGridCellBase* CGridCtrl::GetCell(int nRow, int nCol) const | @@ -882,7 +859,7 @@ inline CGridCellBase* CGridCtrl::GetCell(int nRow, int nCol) const | ||
882 | 859 | ||
883 | GRID_ROW* pRow = m_RowData[nRow]; | 860 | GRID_ROW* pRow = m_RowData[nRow]; |
884 | if (!pRow) return NULL; | 861 | if (!pRow) return NULL; |
885 | - return pRow->GetAt(m_arColOrder[nCol]); | 862 | + return pRow->GetAt(nCol); |
886 | } | 863 | } |
887 | 864 | ||
888 | inline BOOL CGridCtrl::SetCell(int nRow, int nCol, CGridCellBase* pCell) | 865 | inline BOOL CGridCtrl::SetCell(int nRow, int nCol, CGridCellBase* pCell) |
central_clearing_system/ETradeClient/mfc_ui/GridDropTarget.cpp
@@ -6,8 +6,8 @@ | @@ -6,8 +6,8 @@ | ||
6 | // is handle the drag and drop windows messages and pass them | 6 | // is handle the drag and drop windows messages and pass them |
7 | // directly onto the grid control. | 7 | // directly onto the grid control. |
8 | // | 8 | // |
9 | -// Written by Chris Maunder <chris@codeproject.com> | ||
10 | -// Copyright (c) 1998-2005. All Rights Reserved. | 9 | +// Written by Chris Maunder <cmaunder@mail.com> |
10 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
11 | // | 11 | // |
12 | // This code may be used in compiled form in any way you desire. This | 12 | // This code may be used in compiled form in any way you desire. This |
13 | // file may be redistributed unmodified by any means PROVIDING it is | 13 | // file may be redistributed unmodified by any means PROVIDING it is |
central_clearing_system/ETradeClient/mfc_ui/GridDropTarget.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | // | 3 | // |
4 | // MFC Grid Control - Drag/Drop target implementation | 4 | // MFC Grid Control - Drag/Drop target implementation |
5 | // | 5 | // |
6 | -// Written by Chris Maunder <chris@codeproject.com> | ||
7 | -// Copyright (c) 1998-2005. All Rights Reserved. | 6 | +// Written by Chris Maunder <cmaunder@mail.com> |
7 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
8 | // | 8 | // |
9 | // This code may be used in compiled form in any way you desire. This | 9 | // This code may be used in compiled form in any way you desire. This |
10 | // file may be redistributed unmodified by any means PROVIDING it is | 10 | // file may be redistributed unmodified by any means PROVIDING it is |
central_clearing_system/ETradeClient/mfc_ui/InPlaceEdit.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | // | 3 | // |
4 | // MFC Grid Control - inplace editing class | 4 | // MFC Grid Control - inplace editing class |
5 | // | 5 | // |
6 | -// Written by Chris Maunder <chris@codeproject.com> | ||
7 | -// Copyright (c) 1998-2005. All Rights Reserved. | 6 | +// Written by Chris Maunder <cmaunder@mail.com> |
7 | +// Copyright (c) 1998-2002. All Rights Reserved. | ||
8 | // | 8 | // |
9 | // This code may be used in compiled form in any way you desire. This | 9 | // This code may be used in compiled form in any way you desire. This |
10 | // file may be redistributed unmodified by any means PROVIDING it is | 10 | // file may be redistributed unmodified by any means PROVIDING it is |
central_clearing_system/ETradeClient/mfc_ui/MemDC.h
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | // | 8 | // |
9 | 9 | ||
10 | ////////////////////////////////////////////////// | 10 | ////////////////////////////////////////////////// |
11 | -// CGridMemDC - memory DC | 11 | +// CMemDC - memory DC |
12 | // | 12 | // |
13 | // Author: Keith Rule | 13 | // Author: Keith Rule |
14 | // Email: keithr@europa.com | 14 | // Email: keithr@europa.com |
@@ -92,7 +92,7 @@ public: | @@ -92,7 +92,7 @@ public: | ||
92 | 92 | ||
93 | private: | 93 | private: |
94 | CBitmap m_bitmap; // Offscreen bitmap | 94 | CBitmap m_bitmap; // Offscreen bitmap |
95 | - CBitmap* m_pOldBitmap; // bitmap originally found in CGridMemDC | 95 | + CBitmap* m_pOldBitmap; // bitmap originally found in CMemDC |
96 | CDC* m_pDC; // Saves CDC passed in constructor | 96 | CDC* m_pDC; // Saves CDC passed in constructor |
97 | CRect m_rect; // Rectangle of drawing area. | 97 | CRect m_rect; // Rectangle of drawing area. |
98 | BOOL m_bMemDC; // TRUE if CDC really is a Memory DC. | 98 | BOOL m_bMemDC; // TRUE if CDC really is a Memory DC. |
central_clearing_system/ETradeClient/mfc_ui/TitleTip.h
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | // | 3 | // |
4 | // MFC Grid Control - cell titletips | 4 | // MFC Grid Control - cell titletips |
5 | // | 5 | // |
6 | -// Written by Chris Maunder <chris@codeproject.com> | ||
7 | -// Copyright (c) 1998-2005. All Rights Reserved. | 6 | +// Written by Chris Maunder <cmaunder@mail.com> |
7 | +// Copyright (c) 1998-2001. All Rights Reserved. | ||
8 | // | 8 | // |
9 | // This code may be used in compiled form in any way you desire. This | 9 | // This code may be used in compiled form in any way you desire. This |
10 | // file may be redistributed unmodified by any means PROVIDING it is | 10 | // file may be redistributed unmodified by any means PROVIDING it is |
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.cpp
0 → 100644
1 | +// D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.cpp : 实现文件 | ||
2 | +// | ||
3 | + | ||
4 | +#include "stdafx.h" | ||
5 | +#include "ETradeClient.h" | ||
6 | +#include "D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.h" | ||
7 | +#include "afxdialogex.h" | ||
8 | + | ||
9 | + | ||
10 | +// PayDlg 对话框 | ||
11 | + | ||
12 | +IMPLEMENT_DYNAMIC(PayDlg, CDialogEx) | ||
13 | + | ||
14 | +PayDlg::PayDlg(CWnd* pParent /*=NULL*/) | ||
15 | + : CDialogEx(PayDlg::IDD, pParent) | ||
16 | +{ | ||
17 | + | ||
18 | +} | ||
19 | + | ||
20 | +PayDlg::~PayDlg() | ||
21 | +{ | ||
22 | +} | ||
23 | + | ||
24 | +void PayDlg::DoDataExchange(CDataExchange* pDX) | ||
25 | +{ | ||
26 | + CDialogEx::DoDataExchange(pDX); | ||
27 | + DDX_Control(pDX, IDC_PAY_STATIC_TOTAL_MONEY, total_money_static_); | ||
28 | + DDX_Control(pDX, IDC_PAY_STATIC_REAL_MONEY, real_money_static_); | ||
29 | + DDX_Control(pDX, IDC_PAY_STATIC_PASSWORD, password_static_); | ||
30 | + DDX_Control(pDX, IDC_PAY_EDIT_PASSWORD, password_edit_); | ||
31 | + DDX_Control(pDX, IDC_PAY_BUTTON_PAY, pay_button_); | ||
32 | + DDX_Control(pDX, IDC_PAY_BUTTON_CLOSE, close_button_); | ||
33 | + DDX_Control(pDX, IDC_PAY_BUTTON_PASSWORD, password_button_); | ||
34 | +} | ||
35 | + | ||
36 | + | ||
37 | +BEGIN_MESSAGE_MAP(PayDlg, CDialogEx) | ||
38 | + ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose) | ||
39 | +END_MESSAGE_MAP() | ||
40 | + | ||
41 | + | ||
42 | +// PayDlg 消息处理程序 | ||
43 | + | ||
44 | + | ||
45 | +BOOL PayDlg::OnInitDialog() | ||
46 | +{ | ||
47 | + CDialogEx::OnInitDialog(); | ||
48 | + | ||
49 | + SetCtrlPos(); | ||
50 | + | ||
51 | + return TRUE; // return TRUE unless you set the focus to a control | ||
52 | + // 异常: OCX 属性页应返回 FALSE | ||
53 | +} | ||
54 | + | ||
55 | +void PayDlg::SetCtrlPos() | ||
56 | +{ | ||
57 | + const int StaticWidth = 80, StaticHeigth = 35; | ||
58 | + const int EditWidth = 140, EditHeigth = 35; | ||
59 | + const int EditWidthShort = 70, StaticWidthShort = 70; | ||
60 | + const int ButtonWidth = 120, ButtonHeight = 40; | ||
61 | + | ||
62 | + CRect ctrl_rect; | ||
63 | + ctrl_rect.top = 30 + 10; | ||
64 | + ctrl_rect.bottom = ctrl_rect.top + StaticHeigth; | ||
65 | + ctrl_rect.left = 30; | ||
66 | + ctrl_rect.right = ctrl_rect.left + StaticWidth; | ||
67 | + total_money_static_.MoveWindow(&ctrl_rect); | ||
68 | + | ||
69 | + ctrl_rect.left = ctrl_rect.right; | ||
70 | + ctrl_rect.right += StaticWidth; | ||
71 | + real_money_static_.MoveWindow(&ctrl_rect); | ||
72 | + | ||
73 | + ctrl_rect.top = ctrl_rect.bottom + 30; | ||
74 | + ctrl_rect.bottom = ctrl_rect.top + StaticHeigth; | ||
75 | + ctrl_rect.left = 30; | ||
76 | + ctrl_rect.right = ctrl_rect.left + StaticWidth; | ||
77 | + password_static_.MoveWindow(ctrl_rect); | ||
78 | + | ||
79 | + ctrl_rect.left = ctrl_rect.right; | ||
80 | + ctrl_rect.right += EditWidth; | ||
81 | + password_edit_.MoveWindow(&ctrl_rect); | ||
82 | + | ||
83 | + ctrl_rect.left = ctrl_rect.right + 10; | ||
84 | + ctrl_rect.right += ButtonWidth; | ||
85 | + password_button_.MoveWindow(&ctrl_rect); | ||
86 | + | ||
87 | + CRect dlg_rect; | ||
88 | + GetClientRect(&dlg_rect); | ||
89 | + ctrl_rect.bottom = dlg_rect.bottom; | ||
90 | + ctrl_rect.top = ctrl_rect.bottom - ButtonHeight; | ||
91 | + ctrl_rect.right = dlg_rect.right - 100; | ||
92 | + ctrl_rect.left = ctrl_rect.right - ButtonWidth; | ||
93 | + close_button_.MoveWindow(&ctrl_rect); | ||
94 | + | ||
95 | + ctrl_rect.right = ctrl_rect.left - 100; | ||
96 | + ctrl_rect.left = ctrl_rect.right - ButtonWidth; | ||
97 | + pay_button_.MoveWindow(ctrl_rect); | ||
98 | + | ||
99 | + CRect rect; | ||
100 | + password_edit_.GetClientRect(&rect); | ||
101 | + OffsetRect(&rect, 0, 10); | ||
102 | + password_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect); | ||
103 | + | ||
104 | + password_edit_.EnableWindow(FALSE); | ||
105 | +} | ||
106 | + | ||
107 | +void PayDlg::OnBnClickedPayButtonClose() | ||
108 | +{ | ||
109 | + CDialogEx::OnCancel(); | ||
110 | +} |
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.h
0 → 100644
1 | +#pragma once | ||
2 | +#include "afxwin.h" | ||
3 | + | ||
4 | + | ||
5 | +// PayDlg 对话框 | ||
6 | + | ||
7 | +class PayDlg : public CDialogEx | ||
8 | +{ | ||
9 | + DECLARE_DYNAMIC(PayDlg) | ||
10 | + | ||
11 | +public: | ||
12 | + PayDlg(CWnd* pParent = NULL); // 标准构造函数 | ||
13 | + virtual ~PayDlg(); | ||
14 | + | ||
15 | +// 对话框数据 | ||
16 | + enum { IDD = IDD_DIALOG_PAY }; | ||
17 | + | ||
18 | +protected: | ||
19 | + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 | ||
20 | + | ||
21 | + DECLARE_MESSAGE_MAP() | ||
22 | +public: | ||
23 | + virtual BOOL OnInitDialog(); | ||
24 | + CStatic total_money_static_; | ||
25 | + CStatic real_money_static_; | ||
26 | + CStatic password_static_; | ||
27 | + CEdit password_edit_; | ||
28 | + CButton pay_button_; | ||
29 | + CButton close_button_; | ||
30 | + | ||
31 | + void SetCtrlPos(); | ||
32 | + afx_msg void OnBnClickedPayButtonClose(); | ||
33 | + CButton password_button_; | ||
34 | +}; |
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.cpp
@@ -12,6 +12,8 @@ | @@ -12,6 +12,8 @@ | ||
12 | #include "etradeclient/browser/session.h" | 12 | #include "etradeclient/browser/session.h" |
13 | #include "ETradeClient/utility/string_converter.h" | 13 | #include "ETradeClient/utility/string_converter.h" |
14 | #include "ETradeClient/utility/win_msg_define.h" | 14 | #include "ETradeClient/utility/win_msg_define.h" |
15 | +#include <vector> | ||
16 | +#include "pay_dlg.h" | ||
15 | 17 | ||
16 | 18 | ||
17 | // PlaceOrderDlg 对话框 | 19 | // PlaceOrderDlg 对话框 |
@@ -23,15 +25,6 @@ PlaceOrderDlg::PlaceOrderDlg(CWnd* pParent /*=NULL*/) | @@ -23,15 +25,6 @@ PlaceOrderDlg::PlaceOrderDlg(CWnd* pParent /*=NULL*/) | ||
23 | { | 25 | { |
24 | line_pen_.CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); | 26 | line_pen_.CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); |
25 | edit_brush_.CreateSolidBrush(RGB(245, 247, 250)); | 27 | edit_brush_.CreateSolidBrush(RGB(245, 247, 250)); |
26 | - /*error_count_ = 6; | ||
27 | - card_num_ = ErrorCode; | ||
28 | - card_name_ = ErrorCode; | ||
29 | - comm_num_ = ErrorCode; | ||
30 | - comm_name_ = ErrorCode; | ||
31 | - unit_ = ErrorCode; | ||
32 | - heavy_ = ErrorCode; | ||
33 | - price_ = ErrorCode; | ||
34 | - count_ = ErrorCode;*/ | ||
35 | } | 28 | } |
36 | 29 | ||
37 | PlaceOrderDlg::~PlaceOrderDlg() | 30 | PlaceOrderDlg::~PlaceOrderDlg() |
@@ -61,6 +54,10 @@ void PlaceOrderDlg::DoDataExchange(CDataExchange* pDX) | @@ -61,6 +54,10 @@ void PlaceOrderDlg::DoDataExchange(CDataExchange* pDX) | ||
61 | DDX_Control(pDX, IDC_STATIC_HEJI, total_money_static_); | 54 | DDX_Control(pDX, IDC_STATIC_HEJI, total_money_static_); |
62 | DDX_Control(pDX, IDC_STATIC_TOTAL_MONEY, total_real_money_static_); | 55 | DDX_Control(pDX, IDC_STATIC_TOTAL_MONEY, total_real_money_static_); |
63 | DDX_Control(pDX, IDC_STATIC_ERROR, error_static_); | 56 | DDX_Control(pDX, IDC_STATIC_ERROR, error_static_); |
57 | + DDX_Control(pDX, IDC_STATIC_BUYER, buyer_static_); | ||
58 | + DDX_Control(pDX, IDC_EDIT_BUYER_CARD, buyer_card_edit_); | ||
59 | + DDX_Control(pDX, IDC_EDIT_BUYER_NAME, buyer_name_edit_); | ||
60 | + DDX_Control(pDX, IDC_BUTTON_SWIP_CARD, swip_card_button_); | ||
64 | } | 61 | } |
65 | 62 | ||
66 | 63 | ||
@@ -135,8 +132,32 @@ void PlaceOrderDlg::SetCtrlPos() | @@ -135,8 +132,32 @@ void PlaceOrderDlg::SetCtrlPos() | ||
135 | ctrl_rect.bottom = ctrl_rect.top + StaticHeigth; | 132 | ctrl_rect.bottom = ctrl_rect.top + StaticHeigth; |
136 | ctrl_rect.left = 30; | 133 | ctrl_rect.left = 30; |
137 | ctrl_rect.right = ctrl_rect.left + StaticWidth; | 134 | ctrl_rect.right = ctrl_rect.left + StaticWidth; |
135 | + buyer_static_.MoveWindow(ctrl_rect); | ||
136 | + | ||
137 | + ctrl_rect.top -= 10; | ||
138 | + ctrl_rect.left = ctrl_rect.right; | ||
139 | + ctrl_rect.right += EditWidth; | ||
140 | + buyer_card_edit_.MoveWindow(&ctrl_rect); | ||
141 | + | ||
142 | + line_point_[3].x = ctrl_rect.right + 3; | ||
143 | + line_point_[3].y = ctrl_rect.bottom - EditHeigth / 2 - 3; | ||
144 | + | ||
145 | + ctrl_rect.left = ctrl_rect.right + 30; | ||
146 | + ctrl_rect.right = ctrl_rect.left + EditWidth; | ||
147 | + buyer_name_edit_.MoveWindow(&ctrl_rect); | ||
148 | + | ||
149 | + const int ButtonWidth = 120, ButtonHeight = 40; | ||
150 | + ctrl_rect.left = ctrl_rect.right + 30; | ||
151 | + ctrl_rect.right = ctrl_rect.left + ButtonWidth; | ||
152 | + swip_card_button_.MoveWindow(&ctrl_rect); | ||
153 | + | ||
154 | + | ||
155 | + ctrl_rect.top = ctrl_rect.bottom + 30; | ||
156 | + ctrl_rect.bottom = ctrl_rect.top + StaticHeigth; | ||
157 | + ctrl_rect.left = 30; | ||
158 | + ctrl_rect.right = ctrl_rect.left + StaticWidth; | ||
138 | owner_static_.MoveWindow(ctrl_rect); | 159 | owner_static_.MoveWindow(ctrl_rect); |
139 | - ctrl_rect.top = 30; | 160 | + ctrl_rect.top -= 10; |
140 | 161 | ||
141 | ctrl_rect.left = ctrl_rect.right; | 162 | ctrl_rect.left = ctrl_rect.right; |
142 | ctrl_rect.right += EditWidth; | 163 | ctrl_rect.right += EditWidth; |
@@ -230,7 +251,7 @@ void PlaceOrderDlg::SetCtrlPos() | @@ -230,7 +251,7 @@ void PlaceOrderDlg::SetCtrlPos() | ||
230 | 251 | ||
231 | ctrl_rect.top = ctrl_rect.bottom + 5; | 252 | ctrl_rect.top = ctrl_rect.bottom + 5; |
232 | ctrl_rect.bottom = dlg_rect.bottom; | 253 | ctrl_rect.bottom = dlg_rect.bottom; |
233 | - ctrl_rect.right = dlg_rect.right - TotalMoneyStaticWidth - 10; | 254 | + ctrl_rect.right = dlg_rect.right - TotalMoneyStaticWidth - 100 - ButtonWidth; |
234 | ctrl_rect.left = ctrl_rect.right - TotalMoneyStaticWidth; | 255 | ctrl_rect.left = ctrl_rect.right - TotalMoneyStaticWidth; |
235 | total_money_static_.MoveWindow(&ctrl_rect); | 256 | total_money_static_.MoveWindow(&ctrl_rect); |
236 | 257 | ||
@@ -238,9 +259,6 @@ void PlaceOrderDlg::SetCtrlPos() | @@ -238,9 +259,6 @@ void PlaceOrderDlg::SetCtrlPos() | ||
238 | ctrl_rect.right = dlg_rect.right; | 259 | ctrl_rect.right = dlg_rect.right; |
239 | total_real_money_static_.MoveWindow(&ctrl_rect); | 260 | total_real_money_static_.MoveWindow(&ctrl_rect); |
240 | 261 | ||
241 | - const int ButtonWidth = 120, ButtonHeight = 40; | ||
242 | - ctrl_rect.top = 10; | ||
243 | - ctrl_rect.bottom = ctrl_rect.top + ButtonHeight; | ||
244 | ctrl_rect.right = dlg_rect.right - 10; | 262 | ctrl_rect.right = dlg_rect.right - 10; |
245 | ctrl_rect.left = ctrl_rect.right - ButtonWidth; | 263 | ctrl_rect.left = ctrl_rect.right - ButtonWidth; |
246 | pay_button_.MoveWindow(&ctrl_rect); | 264 | pay_button_.MoveWindow(&ctrl_rect); |
@@ -280,6 +298,17 @@ void PlaceOrderDlg::SetCtrlPos() | @@ -280,6 +298,17 @@ void PlaceOrderDlg::SetCtrlPos() | ||
280 | count_edit_.GetClientRect(&rect); | 298 | count_edit_.GetClientRect(&rect); |
281 | OffsetRect(&rect, 0, 10); | 299 | OffsetRect(&rect, 0, 10); |
282 | count_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect); | 300 | count_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect); |
301 | + | ||
302 | + buyer_card_edit_.GetClientRect(&rect); | ||
303 | + OffsetRect(&rect, 0, 10); | ||
304 | + buyer_card_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect); | ||
305 | + | ||
306 | + buyer_name_edit_.GetClientRect(&rect); | ||
307 | + OffsetRect(&rect, 0, 10); | ||
308 | + buyer_name_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect); | ||
309 | + | ||
310 | + buyer_card_edit_.EnableWindow(FALSE); | ||
311 | + buyer_name_edit_.EnableWindow(FALSE); | ||
283 | } | 312 | } |
284 | 313 | ||
285 | void PlaceOrderDlg::OnPaint() | 314 | void PlaceOrderDlg::OnPaint() |
@@ -293,6 +322,9 @@ void PlaceOrderDlg::OnPaint() | @@ -293,6 +322,9 @@ void PlaceOrderDlg::OnPaint() | ||
293 | dc.MoveTo(line_point_[1]); | 322 | dc.MoveTo(line_point_[1]); |
294 | dc.LineTo(line_point_[1].x + 24, line_point_[1].y); | 323 | dc.LineTo(line_point_[1].x + 24, line_point_[1].y); |
295 | 324 | ||
325 | + dc.MoveTo(line_point_[3]); | ||
326 | + dc.LineTo(line_point_[3].x + 24, line_point_[3].y); | ||
327 | + | ||
296 | dc.SelectObject(old_pen); | 328 | dc.SelectObject(old_pen); |
297 | 329 | ||
298 | CDialogEx::OnPaint(); | 330 | CDialogEx::OnPaint(); |
@@ -317,7 +349,8 @@ HBRUSH PlaceOrderDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) | @@ -317,7 +349,8 @@ HBRUSH PlaceOrderDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) | ||
317 | 349 | ||
318 | void PlaceOrderDlg::OnBnClickedButtonPay() | 350 | void PlaceOrderDlg::OnBnClickedButtonPay() |
319 | { | 351 | { |
320 | - SetErrorMsg(CString(L"anniuanniu")); | 352 | + PayDlg pay_dlg; |
353 | + pay_dlg.DoModal(); | ||
321 | } | 354 | } |
322 | 355 | ||
323 | void PlaceOrderDlg::InitList() | 356 | void PlaceOrderDlg::InitList() |
@@ -346,12 +379,12 @@ void PlaceOrderDlg::InitList() | @@ -346,12 +379,12 @@ void PlaceOrderDlg::InitList() | ||
346 | 379 | ||
347 | product_list_.SetEditable(FALSE); | 380 | product_list_.SetEditable(FALSE); |
348 | 381 | ||
382 | + product_list_.SetFixedRowCount(1); | ||
383 | + product_list_.SetFixedColumnCount(2); | ||
349 | 384 | ||
350 | product_list_.SetListMode(TRUE); | 385 | product_list_.SetListMode(TRUE); |
351 | - product_list_.SetSingleRowSelection(TRUE); | ||
352 | - | ||
353 | - product_list_.SetFixedColumnCount(1); | ||
354 | - product_list_.SetFixedColumnCount(2); | 386 | + product_list_.SetSingleColSelection(TRUE); |
387 | + product_list_.SetSingleRowSelection(FALSE); | ||
355 | 388 | ||
356 | product_list_.SetRowResize(FALSE); | 389 | product_list_.SetRowResize(FALSE); |
357 | product_list_.SetColumnResize(FALSE); | 390 | product_list_.SetColumnResize(FALSE); |
@@ -377,7 +410,12 @@ void PlaceOrderDlg::OnAcceleratorTab() | @@ -377,7 +410,12 @@ void PlaceOrderDlg::OnAcceleratorTab() | ||
377 | } | 410 | } |
378 | void PlaceOrderDlg::OnAcceleratorEnter() | 411 | void PlaceOrderDlg::OnAcceleratorEnter() |
379 | { | 412 | { |
380 | - OnEditKillFocus(GetFocus()->GetDlgCtrlID(), NULL); | 413 | + OnEditKillFocus(IDC_EDIT_CARD, NULL); |
414 | + OnEditKillFocus(IDC_EDIT_COMM_NUM, NULL); | ||
415 | + OnEditKillFocus(IDC_EDIT_UNIT, NULL); | ||
416 | + OnEditKillFocus(IDC_EDIT_HEAVY, NULL); | ||
417 | + OnEditKillFocus(IDC_EDIT_PRICE, NULL); | ||
418 | + OnEditKillFocus(IDC_EDIT_COUNT, NULL); | ||
381 | 419 | ||
382 | do | 420 | do |
383 | { | 421 | { |
@@ -423,8 +461,22 @@ void PlaceOrderDlg::OnAcceleratorEnter() | @@ -423,8 +461,22 @@ void PlaceOrderDlg::OnAcceleratorEnter() | ||
423 | product_list_.SetItemFormat(row_index, index, DT_CENTER | DT_VCENTER | DT_SINGLELINE); | 461 | product_list_.SetItemFormat(row_index, index, DT_CENTER | DT_VCENTER | DT_SINGLELINE); |
424 | } | 462 | } |
425 | 463 | ||
426 | - product_list_. | ||
427 | - | 464 | + EmptyCtrl(); |
465 | + SortList(); | ||
466 | + | ||
467 | + CString subtotal; | ||
468 | + double total_price = 0; | ||
469 | + int list_count = product_list_.GetRowCount(); | ||
470 | + for (int index = 1; index <= count; ++index) | ||
471 | + { | ||
472 | + subtotal = product_list_.GetItemText(index, 7); | ||
473 | + total_price += _ttof(subtotal); | ||
474 | + } | ||
475 | + | ||
476 | + CString total_price_s; | ||
477 | + total_price_s.Format(L"%.2f", total_price); | ||
478 | + total_real_money_static_.SetWindowText(total_price_s); | ||
479 | + | ||
428 | } while (0); | 480 | } while (0); |
429 | 481 | ||
430 | UpdateWindow(); | 482 | UpdateWindow(); |
@@ -530,6 +582,12 @@ LRESULT PlaceOrderDlg::OnEditKillFocus(WPARAM wParam, LPARAM lParam) | @@ -530,6 +582,12 @@ LRESULT PlaceOrderDlg::OnEditKillFocus(WPARAM wParam, LPARAM lParam) | ||
530 | break; | 582 | break; |
531 | } | 583 | } |
532 | case IDC_EDIT_HEAVY: | 584 | case IDC_EDIT_HEAVY: |
585 | + { | ||
586 | + if (!heavy_edit_.IsWindowEnabled()) | ||
587 | + { | ||
588 | + break; | ||
589 | + } | ||
590 | + } | ||
533 | case IDC_EDIT_PRICE: | 591 | case IDC_EDIT_PRICE: |
534 | case IDC_EDIT_COUNT: | 592 | case IDC_EDIT_COUNT: |
535 | { | 593 | { |
@@ -690,3 +748,75 @@ void PlaceOrderDlg::OnSetFocus(CWnd* pOldWnd) | @@ -690,3 +748,75 @@ void PlaceOrderDlg::OnSetFocus(CWnd* pOldWnd) | ||
690 | // TODO: 在此处添加消息处理程序代码 | 748 | // TODO: 在此处添加消息处理程序代码 |
691 | } | 749 | } |
692 | 750 | ||
751 | +void PlaceOrderDlg::SortList() | ||
752 | +{ | ||
753 | + product_list_.SortItems(0, TRUE); | ||
754 | + | ||
755 | + | ||
756 | + int row_count = product_list_.GetRowCount(); | ||
757 | + CString card_num, old_card_num; | ||
758 | + | ||
759 | + struct CombineRange | ||
760 | + { | ||
761 | + int start_row; | ||
762 | + int end_row; | ||
763 | + struct CombineRange() | ||
764 | + { | ||
765 | + start_row = 0; | ||
766 | + end_row = 0; | ||
767 | + } | ||
768 | + | ||
769 | + struct CombineRange(int start, int end) | ||
770 | + { | ||
771 | + start_row = start; | ||
772 | + end_row = end; | ||
773 | + }; | ||
774 | + }; | ||
775 | + | ||
776 | + std::vector<CombineRange> combine_list; | ||
777 | + int start_row = 0, end_row = 0; | ||
778 | + for (int index = 1; index <= row_count; ++index) | ||
779 | + { | ||
780 | + card_num = product_list_.GetItemText(index, 0); | ||
781 | + if (card_num.Compare(old_card_num) == 0) | ||
782 | + { | ||
783 | + end_row++; | ||
784 | + } | ||
785 | + else | ||
786 | + { | ||
787 | + if (start_row != end_row) | ||
788 | + { | ||
789 | + combine_list.push_back(CombineRange(start_row, end_row)); | ||
790 | + } | ||
791 | + old_card_num = card_num; | ||
792 | + start_row = index; | ||
793 | + end_row = start_row; | ||
794 | + } | ||
795 | + } | ||
796 | + | ||
797 | + int combine_count = combine_list.size(); | ||
798 | + for (int index = 0; index < combine_count; ++index) | ||
799 | + { | ||
800 | + product_list_.MergeCells(combine_list[index].start_row, 0, combine_list[index].end_row, 0); | ||
801 | + product_list_.MergeCells(combine_list[index].start_row, 1, combine_list[index].end_row, 1); | ||
802 | + } | ||
803 | + | ||
804 | + product_list_.Invalidate(TRUE); | ||
805 | +} | ||
806 | + | ||
807 | +void PlaceOrderDlg::EmptyCtrl() | ||
808 | +{ | ||
809 | + card_edit_.SetWindowText(L"8888"); | ||
810 | + name_edit_.SetWindowText(L""); | ||
811 | + comm_num_edit_.SetWindowText(L""); | ||
812 | + comm_name_edit_.SetWindowText(L""); | ||
813 | + unit_edit_.SetWindowText(L"");; | ||
814 | + real_unit_static.SetWindowText(L"斤"); | ||
815 | + heavy_edit_.SetWindowText(L""); | ||
816 | + heavy_edit_.EnableWindow(FALSE); | ||
817 | + price_edit_.SetWindowText(L""); | ||
818 | + count_edit_.SetWindowText(L""); | ||
819 | + | ||
820 | + card_edit_.SetFocus(); | ||
821 | + card_edit_.SetSel(4, 4); | ||
822 | +} | ||
693 | \ No newline at end of file | 823 | \ No newline at end of file |
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.h
@@ -59,7 +59,7 @@ public: | @@ -59,7 +59,7 @@ public: | ||
59 | CGridCtrl product_list_; | 59 | CGridCtrl product_list_; |
60 | 60 | ||
61 | CPen line_pen_; | 61 | CPen line_pen_; |
62 | - CPoint line_point_[2]; | 62 | + CPoint line_point_[3]; |
63 | 63 | ||
64 | CBrush edit_brush_; | 64 | CBrush edit_brush_; |
65 | public: | 65 | public: |
@@ -89,20 +89,11 @@ public: | @@ -89,20 +89,11 @@ public: | ||
89 | afx_msg void OnAcceleratorUp(); | 89 | afx_msg void OnAcceleratorUp(); |
90 | afx_msg void OnSetFocus(CWnd* pOldWnd); | 90 | afx_msg void OnSetFocus(CWnd* pOldWnd); |
91 | 91 | ||
92 | - //bool CheckCardData(CString card_data); | ||
93 | - //bool CheckCommData(CString comm_data); | ||
94 | - //bool CheckUnitData(CString unit_data); | ||
95 | - //bool CheckPriceData(CString price_data); | ||
96 | - //bool CheckCountData(CString count_data); | ||
97 | - | ||
98 | - //CString card_num_; | ||
99 | - //CString card_name_; | ||
100 | - //CString comm_num_; | ||
101 | - //CString comm_name_; | ||
102 | - //CString unit_; | ||
103 | - //CString heavy_; | ||
104 | - //CString price_; | ||
105 | - //CString count_; | ||
106 | - //int error_count_; | ||
107 | - //const CString ErrorCode = L"-9000"; | 92 | + void SortList(); |
93 | + | ||
94 | + void EmptyCtrl(); | ||
95 | + CStatic buyer_static_; | ||
96 | + CEditBox buyer_card_edit_; | ||
97 | + CEditBox buyer_name_edit_; | ||
98 | + CButton swip_card_button_; | ||
108 | }; | 99 | }; |
central_clearing_system/Resource.h
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | #define IDD_DIALOG_PLACE_ORDER 327 | 15 | #define IDD_DIALOG_PLACE_ORDER 327 |
16 | #define IDR_MENU1 329 | 16 | #define IDR_MENU1 329 |
17 | #define IDR_ACCELERATOR_ORDER 330 | 17 | #define IDR_ACCELERATOR_ORDER 330 |
18 | +#define IDD_DIALOG_PAY 331 | ||
18 | #define IDC_USERNAME 1000 | 19 | #define IDC_USERNAME 1000 |
19 | #define IDC_PWD 1001 | 20 | #define IDC_PWD 1001 |
20 | #define IDC_ACCOUNT_EDIT 1002 | 21 | #define IDC_ACCOUNT_EDIT 1002 |
@@ -36,6 +37,8 @@ | @@ -36,6 +37,8 @@ | ||
36 | #define IDC_BUTTON1 1019 | 37 | #define IDC_BUTTON1 1019 |
37 | #define IDC_BUTTON_ERROR_ICO 1019 | 38 | #define IDC_BUTTON_ERROR_ICO 1019 |
38 | #define IDC_BUTTON_PAY 1019 | 39 | #define IDC_BUTTON_PAY 1019 |
40 | +#define IDC_PAY_BUTTON_PASSWORD 1019 | ||
41 | +#define IDC_BUTTON_SWIP_CARD 1022 | ||
39 | #define IDC_GRID_PRODUCT 1024 | 42 | #define IDC_GRID_PRODUCT 1024 |
40 | #define IDC_EDIT_CARD 1025 | 43 | #define IDC_EDIT_CARD 1025 |
41 | #define IDC_EDIT_NAME 1026 | 44 | #define IDC_EDIT_NAME 1026 |
@@ -55,6 +58,16 @@ | @@ -55,6 +58,16 @@ | ||
55 | #define IDC_STATIC_HEJI 1042 | 58 | #define IDC_STATIC_HEJI 1042 |
56 | #define IDC_STATIC_TOTAL_MONEY 1043 | 59 | #define IDC_STATIC_TOTAL_MONEY 1043 |
57 | #define IDC_STATIC_ERROR 1046 | 60 | #define IDC_STATIC_ERROR 1046 |
61 | +#define IDC_PAY_STATIC_TOTAL_MONEY 1047 | ||
62 | +#define IDC_PAY_STATIC_MONEY 1048 | ||
63 | +#define IDC_STATIC_BUYER 1049 | ||
64 | +#define IDC_PAY_STATIC_PASSWORD 1049 | ||
65 | +#define IDC_EDIT_BUYER_NAME 1050 | ||
66 | +#define IDC_PAY_EDIT_PASSWORD 1050 | ||
67 | +#define IDC_EDIT_BUYER_CARD 1051 | ||
68 | +#define IDC_PAY_BUTTON_CLOSE 1051 | ||
69 | +#define IDC_PAY_BUTTON_PAY 1052 | ||
70 | +#define IDC_PAY_STATIC_REAL_MONEY 1053 | ||
58 | #define ID_PAY_FEE 10001 | 71 | #define ID_PAY_FEE 10001 |
59 | #define ID_ORDER 10002 | 72 | #define ID_ORDER 10002 |
60 | #define ID_STATEMENT_MANAGE 10003 | 73 | #define ID_STATEMENT_MANAGE 10003 |
@@ -73,16 +86,15 @@ | @@ -73,16 +86,15 @@ | ||
73 | #define ID_ACCELERATOR_TAB 32851 | 86 | #define ID_ACCELERATOR_TAB 32851 |
74 | #define ID_ACCELERATOR_ENTER 32852 | 87 | #define ID_ACCELERATOR_ENTER 32852 |
75 | #define ID_ACCELERATOR_UP 32854 | 88 | #define ID_ACCELERATOR_UP 32854 |
76 | -#define ID_ACCELERATOR_LEFT 32855 | ||
77 | #define ID_ACCELERATOR_DOWN 32855 | 89 | #define ID_ACCELERATOR_DOWN 32855 |
78 | 90 | ||
79 | // Next default values for new objects | 91 | // Next default values for new objects |
80 | // | 92 | // |
81 | #ifdef APSTUDIO_INVOKED | 93 | #ifdef APSTUDIO_INVOKED |
82 | #ifndef APSTUDIO_READONLY_SYMBOLS | 94 | #ifndef APSTUDIO_READONLY_SYMBOLS |
83 | -#define _APS_NEXT_RESOURCE_VALUE 331 | 95 | +#define _APS_NEXT_RESOURCE_VALUE 332 |
84 | #define _APS_NEXT_COMMAND_VALUE 32857 | 96 | #define _APS_NEXT_COMMAND_VALUE 32857 |
85 | -#define _APS_NEXT_CONTROL_VALUE 1047 | 97 | +#define _APS_NEXT_CONTROL_VALUE 1054 |
86 | #define _APS_NEXT_SYMED_VALUE 311 | 98 | #define _APS_NEXT_SYMED_VALUE 311 |
87 | #endif | 99 | #endif |
88 | #endif | 100 | #endif |