Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa_test / FormFiller_Test / MainFrm.cpp
1 // MainFrm.cpp : implementation of the CMainFrame class\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "ReaderVC.h"\r
6 \r
7 #include "MainFrm.h"\r
8 \r
9 #ifdef _DEBUG\r
10 #define new DEBUG_NEW\r
11 #undef THIS_FILE\r
12 static char THIS_FILE[] = __FILE__;\r
13 #endif\r
14 \r
15 /////////////////////////////////////////////////////////////////////////////\r
16 // CMainFrame\r
17 \r
18 IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)\r
19 \r
20 BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)\r
21         //{{AFX_MSG_MAP(CMainFrame)\r
22                 // NOTE - the ClassWizard will add and remove mapping macros here.\r
23                 //    DO NOT EDIT what you see in these blocks of generated code !\r
24         ON_WM_CREATE()\r
25         //}}AFX_MSG_MAP\r
26 END_MESSAGE_MAP()\r
27 \r
28 static UINT indicators[] =\r
29 {\r
30         ID_SEPARATOR,           // status line indicator\r
31         ID_INDICATOR_CAPS,\r
32         ID_INDICATOR_NUM,\r
33         ID_INDICATOR_SCRL,\r
34 };\r
35 \r
36 /////////////////////////////////////////////////////////////////////////////\r
37 // CMainFrame construction/destruction\r
38 \r
39 CMainFrame::CMainFrame()\r
40 {\r
41         // TODO: add member initialization code here\r
42         \r
43 }\r
44 \r
45 CMainFrame::~CMainFrame()\r
46 {\r
47 }\r
48 \r
49 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)\r
50 {\r
51         if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)\r
52                 return -1;\r
53         \r
54         if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP\r
55                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||\r
56                 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))\r
57         {\r
58                 TRACE0("Failed to create toolbar\n");\r
59                 return -1;      // fail to create\r
60         }\r
61 \r
62         if (!m_wndStatusBar.Create(this) ||\r
63                 !m_wndStatusBar.SetIndicators(indicators,\r
64                   sizeof(indicators)/sizeof(UINT)))\r
65         {\r
66                 TRACE0("Failed to create status bar\n");\r
67                 return -1;      // fail to create\r
68         }\r
69 \r
70         // TODO: Delete these three lines if you don't want the toolbar to\r
71         //  be dockable\r
72 \r
73         m_wndToolBar.ModifyStyle(0,TBSTYLE_FLAT | CBRS_TOOLTIPS | TBSTYLE_TRANSPARENT | TBBS_CHECKBOX);\r
74         m_wndToolBar.GetToolBarCtrl().SetButtonWidth(40,40);\r
75 \r
76         CImageList ImgList,ImgList1;\r
77         CBitmap bm;\r
78         ImgList.Create(22,22,ILC_COLOR8|ILC_MASK, 16, 16);\r
79         ImgList.SetBkColor(::GetSysColor(15));\r
80         bm.LoadBitmap(IDB_BITMAP23);//OPEN\r
81         ImgList.Add(&bm,RGB(0,255,0));\r
82         bm.Detach();\r
83         bm.LoadBitmap(IDB_BITMAP35);//Print\r
84         ImgList.Add(&bm,RGB(0,255,0));\r
85         bm.Detach();\r
86         bm.LoadBitmap(IDB_BITMAP17);//first page\r
87         ImgList.Add(&bm,RGB(0,255,0));\r
88         bm.Detach();\r
89         bm.LoadBitmap(IDB_BITMAP24);//prev page\r
90         ImgList.Add(&bm,RGB(0,255,0));\r
91         bm.Detach();\r
92         bm.LoadBitmap(IDB_BITMAP22);//next page\r
93         ImgList.Add(&bm,RGB(0,255,0));\r
94         bm.Detach();\r
95         bm.LoadBitmap(IDB_BITMAP21);//last page\r
96         ImgList.Add(&bm,RGB(0,255,0));\r
97         bm.Detach();\r
98         bm.LoadBitmap(IDB_BITMAP16);//count clockwise\r
99         ImgList.Add(&bm,RGB(0,255,0));\r
100         bm.Detach();\r
101         bm.LoadBitmap(IDB_BITMAP15);//clockwise\r
102         ImgList.Add(&bm,RGB(0,255,0));\r
103         bm.Detach();\r
104         bm.LoadBitmap(IDB_BITMAP14);//zoom in\r
105         ImgList.Add(&bm,RGB(0,255,0));\r
106         bm.Detach();\r
107         bm.LoadBitmap(IDB_BITMAP26);//zoom out\r
108         ImgList.Add(&bm,RGB(0,255,0));\r
109         bm.Detach();\r
110         bm.LoadBitmap(IDB_BITMAP13);//actual size\r
111         ImgList.Add(&bm,RGB(0,255,0));\r
112         bm.Detach();\r
113         bm.LoadBitmap(IDB_BITMAP18);//fit page\r
114         ImgList.Add(&bm,RGB(0,255,0));\r
115         bm.Detach();\r
116         bm.LoadBitmap(IDB_BITMAP19);//fit width\r
117         ImgList.Add(&bm,RGB(0,255,0));\r
118         bm.Detach();\r
119         bm.LoadBitmap(IDB_BITMAP36);//search\r
120         ImgList.Add(&bm,RGB(0,255,0));\r
121         bm.Detach();\r
122         bm.LoadBitmap(IDB_BITMAP7);//Bookmark\r
123         ImgList.Add(&bm,RGB(0,255,0));\r
124         bm.Detach();\r
125         bm.LoadBitmap(IDB_BITMAP25);//snap shot\r
126         ImgList.Add(&bm,RGB(0,255,0));\r
127         bm.Detach();\r
128         bm.LoadBitmap(IDB_BITMAP2);//select text\r
129         ImgList.Add(&bm,RGB(0,255,0));\r
130         bm.Detach();\r
131         bm.LoadBitmap(IDB_BITMAP20);//hand tool\r
132         ImgList.Add(&bm,RGB(0,255,0));\r
133         bm.Detach();\r
134         bm.LoadBitmap(IDB_BITMAP12);//about\r
135         ImgList.Add(&bm,RGB(0,255,0));\r
136         bm.Detach();\r
137         m_wndToolBar.GetToolBarCtrl().SetImageList(&ImgList);\r
138         //m_wndToolBar.GetToolBarCtrl().SetHotImageList(&ImgList);\r
139         ImgList.Detach();\r
140 \r
141         ImgList1.Create(22,22,ILC_COLOR8|ILC_MASK, 16, 16);\r
142         ImgList1.SetBkColor(::GetSysColor(15));\r
143         bm.LoadBitmap(IDB_BITMAP23);//open\r
144         ImgList1.Add(&bm,RGB(0,255,0));\r
145         bm.Detach();\r
146         bm.LoadBitmap(IDB_BITMAP30);//printer\r
147         ImgList1.Add(&bm,RGB(0,255,0));\r
148         bm.Detach();\r
149         bm.LoadBitmap(IDB_BITMAP8);//first page\r
150         ImgList1.Add(&bm,RGB(0,255,0));\r
151         bm.Detach();\r
152         bm.LoadBitmap(IDB_BITMAP29);//prev page\r
153         ImgList1.Add(&bm,RGB(0,255,0));\r
154         bm.Detach();\r
155         bm.LoadBitmap(IDB_BITMAP28);//next page\r
156         ImgList1.Add(&bm,RGB(0,255,0));\r
157         bm.Detach();\r
158         bm.LoadBitmap(IDB_BITMAP27);//last page\r
159         ImgList1.Add(&bm,RGB(0,255,0));\r
160         bm.Detach();\r
161         bm.LoadBitmap(IDB_BITMAP1);//count clockwise\r
162         ImgList1.Add(&bm,RGB(0,255,0));\r
163         bm.Detach();\r
164         bm.LoadBitmap(IDB_BITMAP6);//clockwise\r
165         ImgList1.Add(&bm,RGB(0,255,0));\r
166         bm.Detach();\r
167         bm.LoadBitmap(IDB_BITMAP33);//zoom in\r
168         ImgList1.Add(&bm,RGB(0,255,0));\r
169         bm.Detach();\r
170         bm.LoadBitmap(IDB_BITMAP34);//zoom out\r
171         ImgList1.Add(&bm,RGB(0,255,0));\r
172         bm.Detach();\r
173         bm.LoadBitmap(IDB_BITMAP4);//actual size\r
174         ImgList1.Add(&bm,RGB(0,255,0));\r
175         bm.Detach();\r
176         bm.LoadBitmap(IDB_BITMAP9);//fit page\r
177         ImgList1.Add(&bm,RGB(0,255,0));\r
178         bm.Detach();\r
179         bm.LoadBitmap(IDB_BITMAP10);//fit width\r
180         ImgList1.Add(&bm,RGB(0,255,0));\r
181         bm.Detach();\r
182         bm.LoadBitmap(IDB_BITMAP31);//search\r
183         ImgList1.Add(&bm,RGB(0,255,0));\r
184         bm.Detach();\r
185         bm.LoadBitmap(IDB_BITMAP5);//bookmark\r
186         ImgList1.Add(&bm,RGB(0,255,0));\r
187         bm.Detach();\r
188         bm.LoadBitmap(IDB_BITMAP32);//snap\r
189         ImgList1.Add(&bm,RGB(0,255,0));\r
190         bm.Detach();\r
191         bm.LoadBitmap(IDB_BITMAP3);//select text\r
192         ImgList1.Add(&bm,RGB(0,255,0));\r
193         bm.Detach();\r
194         bm.LoadBitmap(IDB_BITMAP11);//hand tool\r
195         ImgList1.Add(&bm,RGB(0,255,0));\r
196         bm.Detach();\r
197         bm.LoadBitmap(IDB_BITMAP12);//about\r
198         ImgList1.Add(&bm,RGB(0,255,0));\r
199         bm.Detach();\r
200         m_wndToolBar.GetToolBarCtrl().SetDisabledImageList(&ImgList1);\r
201         ImgList1.Detach();\r
202     \r
203         m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);\r
204         EnableDocking(CBRS_ALIGN_ANY);\r
205         DockControlBar(&m_wndToolBar);\r
206 \r
207         return 0;\r
208 }\r
209 \r
210 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)\r
211 {\r
212         if( !CMDIFrameWnd::PreCreateWindow(cs) )\r
213                 return FALSE;\r
214         // TODO: Modify the Window class or styles here by modifying\r
215         //  the CREATESTRUCT cs\r
216 \r
217         return TRUE;\r
218 }\r
219 \r
220 /////////////////////////////////////////////////////////////////////////////\r
221 // CMainFrame diagnostics\r
222 \r
223 #ifdef _DEBUG\r
224 void CMainFrame::AssertValid() const\r
225 {\r
226         CMDIFrameWnd::AssertValid();\r
227 }\r
228 \r
229 void CMainFrame::Dump(CDumpContext& dc) const\r
230 {\r
231         CMDIFrameWnd::Dump(dc);\r
232 }\r
233 \r
234 #endif //_DEBUG\r
235 \r
236 /////////////////////////////////////////////////////////////////////////////\r
237 // CMainFrame message handlers\r
238 \r