Develop and Download Open Source Software

Browse CVS Repository

Contents of /tombo/Tombo/Src/DetailsViewWndProc.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.23 - (show annotations) (download) (as text)
Sun Sep 3 12:56:34 2006 UTC (17 years, 7 months ago) by hirami
Branch: MAIN
CVS Tags: Tombo_2_0b2, Tombo_2_0b3, Tombo_2_0b1, Tombo_2_0b4, B228, B229, B226, B227, B225, B231, B230, HEAD
Changes since 1.22: +1 -2 lines
File MIME type: text/x-c++src
* In edit view, display "OK" button insted of "x" on title bar.
* Support WM5 style menubar(WM5 version).
* FIX: Input method ATOK is not work good on W-ZERO3[es].
	This fix is port from B221.

- L9N is not completed(menubar label)

1 #include <windows.h>
2 #include <tchar.h>
3 #if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)
4 #include <aygshell.h>
5 #endif
6 #include "Tombo.h"
7 #include "resource.h"
8 #include "MemoDetailsView.h"
9
10 #if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)
11 #include "PlatformLayer.h"
12 #endif
13
14 #include "Property.h"
15
16 static SUPER_WND_PROC gSuperProc;
17
18 #define KEY_ESC 0x1B
19 #define KEY_CTRL_A 1
20 #define KEY_CTRL_B 2
21 #define KEY_CTRL_C 3
22
23 #define KEY_COLON 0xBB
24 #define KEY_SEMICOLON 0xBA
25
26 void SetWndProc(SUPER_WND_PROC wp)
27 {
28 gSuperProc = wp;
29 }
30
31 /////////////////////////////////////////
32 // Window procedure for sub classing editview
33 /////////////////////////////////////////
34 SUPER_WND_PROC gDefaultProc;
35 DWORD gDelta;
36
37 LRESULT CALLBACK DetailsViewSuperProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
38 {
39 if (msg == WM_CREATE) {
40 LPCREATESTRUCT pCS = (LPCREATESTRUCT)lParam;
41 SimpleEditor *frm = (SimpleEditor*)pCS->lpCreateParams;
42 SetWindowLong(hwnd, gDelta, (LONG)frm);
43 }
44 return CallWindowProc(gDefaultProc, hwnd, msg, wParam, lParam);
45 }
46
47 #if defined(PLATFORM_SIG3)
48 INT nSelBase = -1;
49 #endif
50
51 LRESULT CALLBACK NewDetailsViewProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
52 {
53 SimpleEditor *pView = (SimpleEditor*)GetWindowLong(hwnd, gDelta);
54 if (pView == NULL) {
55 return CallWindowProc(gDefaultProc, hwnd, msg, wParam, lParam);
56 }
57
58 switch(msg) {
59 case WM_CLEAR:
60 if (pView->IsReadOnly()) return 0;
61 break;
62 case WM_CUT:
63 if (pView->IsReadOnly()) return 0;
64 break;
65 case WM_PASTE:
66 if (pView->IsReadOnly()) return 0;
67 break;
68 case WM_KEYDOWN:
69 if (pView->OnKeyDown(hwnd, wParam, lParam) == 0) return 0;
70 break;
71 case WM_CHAR:
72 pView->SetMDSearchFlg(TRUE); // clear search status flag
73
74 // if read only mode, ignore key events
75 if (pView->IsReadOnly()) {
76 if (wParam == KEY_CTRL_C) break; // Ctrl-C should not disable
77 return 0;
78 }
79 // disable Ctrl-B(BELL)
80 if (wParam == KEY_CTRL_A || wParam == KEY_CTRL_B) return 0;
81 break;
82
83 case WM_COMMAND:
84 pView->OnCommand(hwnd, wParam, lParam);
85 break;
86
87 #if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)
88 case WM_LBUTTONDOWN:
89 {
90 // clear search status
91 pView->SetMDSearchFlg(TRUE);
92
93 // Tap&hold
94 SHRGINFO rgi;
95 rgi.cbSize = sizeof(SHRGINFO);
96 rgi.hwndClient = hwnd;
97 rgi.ptDown.x = LOWORD(lParam);
98 rgi.ptDown.y = HIWORD(lParam);
99 rgi.dwFlags = SHRG_RETURNCMD;
100
101 if (SHRecognizeGesture(&rgi) == GN_CONTEXTMENU) {
102 HMENU hPopup = PLATFORM_TYPE::LoadDetailsViewPopupMenu();
103
104 int x, y;
105 UINT nFlg = TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN;
106 RECT r;
107 GetWindowRect(hwnd, &r);
108
109 x = rgi.ptDown.x;
110 if (x < (r.right - r.left) / 2) {
111 nFlg |= TPM_LEFTALIGN;
112 x++;
113 } else {
114 nFlg |= TPM_RIGHTALIGN;
115 x--;
116 }
117
118 y = rgi.ptDown.y + r.top;
119
120 if (rgi.ptDown.y + r.top < r.bottom / 2) {
121 nFlg |= TPM_TOPALIGN;
122 y++;
123 } else {
124 nFlg |= TPM_BOTTOMALIGN;
125 y--;
126 }
127
128 DWORD nID = TrackPopupMenuEx(hPopup, nFlg, x, y, hwnd, NULL);
129 DestroyMenu(hPopup);
130 if (nID != 0) {
131
132 if (nID == IDM_PASTE) {
133 CallWindowProc(gSuperProc, hwnd, msg, wParam, lParam);
134 }
135 pView->OnCommand(hwnd, MAKEWPARAM(nID, 0), 0);
136 }
137 return 0;
138 }
139 break;
140 }
141 #else
142 case WM_LBUTTONDOWN:
143 // clear search status
144 pView->SetMDSearchFlg(TRUE);
145 #if defined(PLATFORM_SIG3)
146 {
147 INT xPos, yPos;
148 xPos = (INT)LOWORD(lParam);
149 yPos = (INT)HIWORD(lParam);
150 LPARAM l = MAKELPARAM(xPos, yPos);
151 nSelBase = SendMessage(hwnd, EM_CHARFROMPOS, 0, l) & 0xFFFF;
152 }
153 #endif
154 break;
155 #endif
156 case WM_SETFOCUS:
157 {
158 if (pView) pView->OnGetFocus();
159 break;
160 }
161 }
162
163 LRESULT lResult = CallWindowProc(gSuperProc, hwnd, msg, wParam, lParam);
164 if (pView && msg != EM_GETMODIFY) {
165 pView->SetModifyStatus();
166 }
167 return lResult;
168 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26