Develop and Download Open Source Software

Browse CVS Repository

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

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


Revision 1.6 - (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.5: +21 -0 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 <commctrl.h>
3 #include <tchar.h>
4 #if defined(PLATFORM_BE500)
5 #include <CSO.h>
6 #endif
7
8 #include "Tombo.h"
9 #include "Message.h"
10 #include "resource.h"
11
12 #include "PlatformLayer.h"
13 #include "Property.h"
14
15 ///////////////////////////////////////////////////
16 // ctor & dtor
17 ///////////////////////////////////////////////////
18
19 PlatformLayer::PlatformLayer() : hMainWnd(NULL)
20 {
21 }
22
23 PlatformLayer::~PlatformLayer()
24 {
25 }
26
27 BOOL PlatformLayer::Init(HWND h)
28 {
29 hMainWnd = h;
30 return TRUE;
31 }
32
33 ///////////////////////////////////////////////////
34 ///////////////////////////////////////////////////
35 // helper functions
36 ///////////////////////////////////////////////////
37 ///////////////////////////////////////////////////
38
39 void SetAppIcon(HINSTANCE hInst, HWND hWnd)
40 {
41 #if defined(PLATFORM_WIN32)
42 // set app icon
43 HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TOMBO));
44 SendMessage(hWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);
45 #endif
46 #if defined(PLATFORM_HPC)
47 HICON hIcon = (HICON)LoadImage(hInst,
48 MAKEINTRESOURCE(IDI_TOMBO),
49 IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
50 SendMessage(hWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
51 #endif
52 }
53
54 ///////////////////////////////////////////////////
55 // menu helper
56 ///////////////////////////////////////////////////
57
58 void AddMenuItemByMsgRes(HMENU hMenu, MenuMsgRes *pRes)
59 {
60 int i = 0;
61 while(1) {
62 if (pRes[i].iPos == -1) break;
63
64 if (pRes[i].iMenuID == -1) {
65 InsertMenu(hMenu, pRes[i].iPos, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
66 } else if (pRes[i].pSubMenu != NULL) {
67 HMENU hSubMenu = CreatePopupMenu();
68 AddMenuItemByMsgRes(hSubMenu, pRes[i].pSubMenu);
69
70 InsertMenu(hMenu, pRes[i].iPos, MF_BYPOSITION | MF_STRING | MF_POPUP | pRes[i].iExtOpt, (UINT)hSubMenu, g_mMsgRes.GetMsg(pRes[i].iMsgID));
71 } else {
72 InsertMenu(hMenu, pRes[i].iPos, MF_BYPOSITION | MF_STRING | pRes[i].iExtOpt, pRes[i].iMenuID, g_mMsgRes.GetMsg(pRes[i].iMsgID));
73 }
74
75 i++;
76 }
77 }
78
79 void OverrideMenuTitle(HMENU hMenu, MenuMsgRes *pRes, int nNumRes)
80 {
81 for (int i = 0; i < nNumRes; i++) {
82 if (pRes[i].iMenuID == -1) {
83 InsertMenu(hMenu, pRes[i].iPos, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
84 } else {
85 InsertMenu(hMenu, pRes[i].iPos, MF_BYPOSITION | MF_STRING | pRes[i].iExtOpt, pRes[i].iMenuID, g_mMsgRes.GetMsg(pRes[i].iMsgID));
86 }
87 }
88 }
89
90 ///////////////////////////////////////////////////
91 //
92 ///////////////////////////////////////////////////
93 #if defined(PLATFORM_HPC) || defined(PLATFORM_WIN32) || defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)
94
95 static MenuMsgRes aContextMenu[] = {
96 { 0, IDM_CUT, 0, MSG_ID_MENUITEM_MAIN_CUT },
97 { 1, IDM_COPY, 0, MSG_ID_MENUITEM_MAIN_COPY },
98 { 2, IDM_PASTE, 0, MSG_ID_MENUITEM_MAIN_PASTE },
99 { 3, -1, 0, 0 },
100
101 { 4, IDM_ENCRYPT, 0, MSG_ID_MENUITEM_MAIN_ENCRYPT },
102 { 5, IDM_DECRYPT, 0, MSG_ID_MENUITEM_MAIN_DECRYPT },
103 { 6, -1, 0, 0 },
104 { 7, IDM_SEARCH, 0, MSG_ID_MENUITEM_MAIN_FIND },
105 { 8, -1, 0, 0 },
106 { 9, IDM_NEWFOLDER, 0, MSG_ID_MENUITEM_MAIN_NEWFOLDER },
107 { 10, -1, 0, 0 },
108 { 11, IDM_DELETEITEM, 0, MSG_ID_MENUITEM_MAIN_DELETE },
109 { 12, IDM_RENAME, 0, MSG_ID_MENUITEM_MAIN_RENAME },
110 { 13, -1, 0, 0 },
111 { 14, IDM_TRACELINK, 0, MSG_ID_MENUITEM_CTX_TRACELINK},
112 };
113
114 static MenuMsgRes aDirectoryContextMenu[] = {
115 { 4, IDM_ASSOC, 0, MSG_ID_MENUITEM_EXPLORER },
116 { 5, -1, 0, 0 },
117 };
118
119 HMENU PlatformLayer::LoadContextMenu(DWORD nFlg)
120 {
121 HMENU hMenu = CreatePopupMenu();
122 OverrideMenuTitle(hMenu, aContextMenu, sizeof(aContextMenu)/sizeof(MenuMsgRes));
123 if (nFlg & CTXMENU_DIR) {
124 OverrideMenuTitle(hMenu, aDirectoryContextMenu, sizeof(aDirectoryContextMenu)/sizeof(MenuMsgRes));
125 } else if ((nFlg & CTXMENU_FILE) && (nFlg & CTXMENU_ENABLEEXTAPP)) {
126 DWORD nPos = 4;
127 if (nFlg & CTXMENU_USEASSOC) {
128 MenuMsgRes aAssocMenu[] = {
129 { nPos, IDM_ASSOC, 0, MSG_ID_MENUITEM_ASSOCIATION },
130 };
131 OverrideMenuTitle(hMenu, aAssocMenu, sizeof(aAssocMenu)/sizeof(MenuMsgRes));
132 nPos++;
133 }
134 if (g_Property.GetExtApp1() && _tcslen(g_Property.GetExtApp1()) > 0) {
135 MenuMsgRes aExtMenu1[] = {
136 { nPos, IDM_EXTAPP1, 0, MSG_ID_DLG_EXTAPP_LBL_APP1 },
137 };
138 OverrideMenuTitle(hMenu, aExtMenu1, sizeof(aExtMenu1)/sizeof(MenuMsgRes));
139 nPos++;
140 }
141 if (g_Property.GetExtApp2() && _tcslen(g_Property.GetExtApp2()) > 0) {
142 MenuMsgRes aExtMenu2[] = {
143 { nPos, IDM_EXTAPP2, 0, MSG_ID_DLG_EXTAPP_LBL_APP2 },
144 };
145 OverrideMenuTitle(hMenu, aExtMenu2, sizeof(aExtMenu2)/sizeof(MenuMsgRes));
146 nPos++;
147 }
148 if (nPos > 4) {
149 MenuMsgRes aSep[] = {
150 { nPos, -1, 0, 0 },
151 };
152 OverrideMenuTitle(hMenu, aSep, sizeof(aSep)/sizeof(MenuMsgRes));
153 }
154 }
155 return hMenu;
156 }
157
158 #endif

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