1 | /* ***** BEGIN LICENSE BLOCK ***** |
---|
2 | * Version: CDDL 1.0/LGPL 2.1 |
---|
3 | * |
---|
4 | * The contents of this file are subject to the COMMON DEVELOPMENT AND |
---|
5 | * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use |
---|
6 | * this file except in compliance with the License. You may obtain a copy of |
---|
7 | * the License at http://www.sun.com/cddl/ |
---|
8 | * |
---|
9 | * Software distributed under the License is distributed on an "AS IS" basis, |
---|
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
---|
11 | * for the specific language governing rights and limitations under the |
---|
12 | * License. |
---|
13 | * |
---|
14 | * The Initial Developer of the Original Code is |
---|
15 | * Eugene Romanenko, netlabs.org. |
---|
16 | * Portions created by the Initial Developer are Copyright (C) 2006 |
---|
17 | * the Initial Developer. All Rights Reserved. |
---|
18 | * |
---|
19 | * Contributor(s): |
---|
20 | * |
---|
21 | * Alternatively, the contents of this file may be used under the terms of |
---|
22 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
---|
23 | * in which case the provisions of the LGPL are applicable instead of those |
---|
24 | * above. If you wish to allow use of your version of this file only under the |
---|
25 | * terms of the LGPL, and not to allow others to use your version of this file |
---|
26 | * under the terms of the CDDL, indicate your decision by deleting the |
---|
27 | * provisions above and replace them with the notice and other provisions |
---|
28 | * required by the LGPL. If you do not delete the provisions above, a recipient |
---|
29 | * may use your version of this file under the terms of any one of the CDDL |
---|
30 | * or the LGPL. |
---|
31 | * |
---|
32 | * ***** END LICENSE BLOCK ***** */ |
---|
33 | |
---|
34 | |
---|
35 | #define INCL_WIN |
---|
36 | #define INCL_DOS |
---|
37 | #define INCL_SPL |
---|
38 | #define INCL_SPLDOSPRINT |
---|
39 | #define INCL_DEV |
---|
40 | #include <os2.h> |
---|
41 | |
---|
42 | #include <string> |
---|
43 | #include <stdio.h> |
---|
44 | #include <process.h> |
---|
45 | |
---|
46 | #include <ludoc.xh> |
---|
47 | |
---|
48 | #include "Lucide.h" |
---|
49 | #include "pluginman.h" |
---|
50 | #include "pluginViewDlg.h" |
---|
51 | #include "fontsInfoDlg.h" |
---|
52 | #include "docInfoDlg.h" |
---|
53 | #include "findDlg.h" |
---|
54 | #include "printDlg.h" |
---|
55 | #include "progressDlg.h" |
---|
56 | #include "settingsDlg.h" |
---|
57 | #include "docViewer.h" |
---|
58 | #include "indexWindow.h" |
---|
59 | #include "lusettings.h" |
---|
60 | #include "luutils.h" |
---|
61 | #include "tb_spl.h" |
---|
62 | #include "Lucide_res.h" |
---|
63 | #include "messages.h" |
---|
64 | |
---|
65 | |
---|
66 | #define ID_SPLITTER 1 |
---|
67 | |
---|
68 | const char *appName = "Lucide"; |
---|
69 | const char *appVersion = VERSION; |
---|
70 | const char *fwp = "FrameWindowPos"; |
---|
71 | const char *lvd = "LastViewedDir"; |
---|
72 | const char *splpos = "SplitterPos"; |
---|
73 | const char *showind = "ShowIndex"; |
---|
74 | |
---|
75 | HWND createToolbar( HWND hwnd ); |
---|
76 | void AboutBox( HWND hWndFrame ); |
---|
77 | void initPipeMon( HWND hWndFrame ); |
---|
78 | void unInitPipeMon(); |
---|
79 | |
---|
80 | HAB hab = NULLHANDLE; |
---|
81 | HWND hWndFrame = NULLHANDLE; |
---|
82 | HWND hWndMenu = NULLHANDLE; |
---|
83 | HWND hToolBar = NULLHANDLE; |
---|
84 | HWND hVertSplitter = NULLHANDLE; |
---|
85 | HWND hFrameSysmenu = NULLHANDLE; |
---|
86 | HWND hFrameTitlebar = NULLHANDLE; |
---|
87 | HWND hFrameMinMax = NULLHANDLE; |
---|
88 | |
---|
89 | Environment *ev = somGetGlobalEnvironment(); |
---|
90 | LuDocument *doc = NULL; |
---|
91 | PluginManager *pluginMan = NULL; |
---|
92 | DocumentViewer *docViewer = NULL; |
---|
93 | IndexWindow *indexWin = NULL; |
---|
94 | FindDlg *findDlg = NULL; |
---|
95 | LuSettings *settings = NULL; |
---|
96 | char *title = NULL; |
---|
97 | |
---|
98 | |
---|
99 | bool Lucide::dontSwitchPage = false; |
---|
100 | SHORT Lucide::splitterPos = 100; |
---|
101 | bool Lucide::showIndex = true; |
---|
102 | bool Lucide::isMaxview = false; |
---|
103 | bool Lucide::isFullscreen = false; |
---|
104 | LuWindowPos Lucide::winPos = {0}; |
---|
105 | char Lucide::docFullName[ CCHMAXPATH ] = ""; |
---|
106 | char Lucide::docFileName[ CCHMAXPATHCOMP ] = ""; |
---|
107 | // static data for asynch loading document |
---|
108 | ProgressDlg *Lucide::loadProgressDlg = NULL; |
---|
109 | bool Lucide::docLoaded = false;; |
---|
110 | char *Lucide::loadError = NULL; |
---|
111 | void *Lucide::thumbnailData = NULL; |
---|
112 | int Lucide::thumbnailDataLen = 0; |
---|
113 | |
---|
114 | |
---|
115 | HMODULE _hmod = NULLHANDLE; |
---|
116 | |
---|
117 | unsigned APIENTRY LibMain( unsigned hmod, unsigned termination ) |
---|
118 | { |
---|
119 | if ( termination ) { |
---|
120 | /* DLL is detaching from process */ |
---|
121 | } else { |
---|
122 | /* DLL is attaching to process */ |
---|
123 | _hmod = hmod; |
---|
124 | } |
---|
125 | return( 1 ); |
---|
126 | } |
---|
127 | |
---|
128 | |
---|
129 | PFNWP pOldSplProc; |
---|
130 | |
---|
131 | void Lucide::enableCopy( bool enable ) |
---|
132 | { |
---|
133 | WinEnableMenuItem( hWndMenu, CM_COPY, enable ); |
---|
134 | } |
---|
135 | |
---|
136 | void Lucide::setOfPages( long pages ) |
---|
137 | { |
---|
138 | char *pgfrm = newstrdupL( TB_PAGENUM ); |
---|
139 | char pgnum[ 32 ]; |
---|
140 | snprintf( pgnum, sizeof( pgnum ), pgfrm, pages ); |
---|
141 | delete pgfrm; |
---|
142 | WinSetDlgItemText( hToolBar, TBID_OFPAGES, pgnum ); |
---|
143 | WinSendDlgItemMsg( hToolBar, TBID_PAGENUM, SPBM_SETLIMITS, |
---|
144 | MPFROMLONG( pages ), MPFROMLONG( 1 ) ); |
---|
145 | } |
---|
146 | |
---|
147 | void Lucide::checkNavigationMenus() |
---|
148 | { |
---|
149 | WinEnableMenuItem( hWndMenu, CM_GOTOPAGE, TRUE ); |
---|
150 | BOOL enfirst = ( docViewer->getCurrentPage() != 0 ); |
---|
151 | BOOL enlast = ( docViewer->getCurrentPage() != ( doc->getPageCount( ev ) - 1 ) ); |
---|
152 | WinEnableMenuItem( hWndMenu, CM_FIRSTPAGE, enfirst ); |
---|
153 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FIRSTPAGE), (MPARAM)enfirst ); |
---|
154 | WinEnableMenuItem( hWndMenu, CM_PREVPAGE, enfirst ); |
---|
155 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_PREVPAGE), (MPARAM)enfirst ); |
---|
156 | WinEnableMenuItem( hWndMenu, CM_NEXTPAGE, enlast ); |
---|
157 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_NEXTPAGE), (MPARAM)enlast ); |
---|
158 | WinEnableMenuItem( hWndMenu, CM_LASTPAGE, enlast ); |
---|
159 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_LASTPAGE), (MPARAM)enlast ); |
---|
160 | |
---|
161 | bool tmp = dontSwitchPage; |
---|
162 | dontSwitchPage = true; |
---|
163 | WinSendDlgItemMsg( hToolBar, TBID_PAGENUM, SPBM_SETCURRENTVALUE, |
---|
164 | MPFROMLONG( docViewer->getCurrentPage() + 1 ), MPVOID ); |
---|
165 | dontSwitchPage = tmp; |
---|
166 | indexWin->goToPage( NULL, docViewer->getCurrentPage() ); |
---|
167 | } |
---|
168 | |
---|
169 | void Lucide::enableZoomMenus() |
---|
170 | { |
---|
171 | BOOL scalable = doc->isScalable( ev ); |
---|
172 | WinEnableMenuItem( hWndMenu, CM_FITWINDOW, scalable ); |
---|
173 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FITWINDOW), (MPARAM)scalable ); |
---|
174 | WinEnableMenuItem( hWndMenu, CM_ACTSIZE, scalable ); |
---|
175 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_ACTSIZE), (MPARAM)scalable ); |
---|
176 | WinEnableMenuItem( hWndMenu, CM_FITWIDTH, scalable ); |
---|
177 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FITWIDTH), (MPARAM)scalable ); |
---|
178 | WinEnableMenuItem( hWndMenu, CM_ZOOM_IN_OUT, scalable ); |
---|
179 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_ZOOM_IN_OUT), (MPARAM)scalable ); |
---|
180 | WinEnableControl( hToolBar, TBID_ZOOM, scalable ); |
---|
181 | BOOL rotable = doc->isRotable( ev ); |
---|
182 | WinEnableMenuItem( hWndMenu, CM_ROTATE90CW, rotable ); |
---|
183 | WinEnableMenuItem( hWndMenu, CM_ROTATE90CCW, rotable ); |
---|
184 | } |
---|
185 | |
---|
186 | |
---|
187 | void Lucide::setZoomChecks( SHORT cmd, SHORT cbind, double zoom ) |
---|
188 | { |
---|
189 | if ( cmd != -1 ) |
---|
190 | { |
---|
191 | WinCheckMenuItem( hWndMenu, cmd, TRUE ); |
---|
192 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT( cmd ), (MPARAM)TRUE ); |
---|
193 | } |
---|
194 | |
---|
195 | if ( cbind != -1 ) |
---|
196 | { |
---|
197 | char buf[ 255 ] = ""; |
---|
198 | WinSendDlgItemMsg( hToolBar, TBID_ZOOM, LM_QUERYITEMTEXT, |
---|
199 | MPFROM2SHORT( cbind, sizeof( buf ) ), MPFROMP( buf ) ); |
---|
200 | WinSetDlgItemText( hToolBar, TBID_ZOOM, buf ); |
---|
201 | } |
---|
202 | |
---|
203 | if ( zoom != 0 ) |
---|
204 | { |
---|
205 | std::string z = str( zoom * 100.0 ) + "%"; |
---|
206 | WinSetDlgItemText( hToolBar, TBID_ZOOM, z.c_str() ); |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | void Lucide::checkZoomMenus() |
---|
211 | { |
---|
212 | double zoom = docViewer->getZoom(); |
---|
213 | |
---|
214 | WinCheckMenuItem( hWndMenu, CM_FITWINDOW, FALSE ); |
---|
215 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT(CM_FITWINDOW), (MPARAM)FALSE ); |
---|
216 | WinCheckMenuItem( hWndMenu, CM_ACTSIZE, FALSE ); |
---|
217 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT(CM_ACTSIZE), (MPARAM)FALSE ); |
---|
218 | WinCheckMenuItem( hWndMenu, CM_FITWIDTH, FALSE ); |
---|
219 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT(CM_FITWIDTH), (MPARAM)FALSE ); |
---|
220 | |
---|
221 | if ( zoom == -2 ) { |
---|
222 | setZoomChecks( CM_FITWINDOW, 1, 0 ); |
---|
223 | } else if ( zoom == -1 ) { |
---|
224 | setZoomChecks( CM_FITWIDTH, 2, 0 ); |
---|
225 | } else if ( zoom == 1 ) { |
---|
226 | setZoomChecks( CM_ACTSIZE, 0, 0 ); |
---|
227 | } else { |
---|
228 | setZoomChecks( -1, -1, zoom ); |
---|
229 | } |
---|
230 | } |
---|
231 | |
---|
232 | void Lucide::checkMenus() |
---|
233 | { |
---|
234 | // pre-set "Actual size" |
---|
235 | setZoomChecks( CM_ACTSIZE, 0, 0 ); |
---|
236 | |
---|
237 | if ( doc == NULL ) |
---|
238 | { |
---|
239 | // "single page" mode by default |
---|
240 | WinCheckMenuItem( hWndMenu, CM_SINGLEPAGE, TRUE ); |
---|
241 | |
---|
242 | WinEnableMenuItem( hWndMenu, CM_SAVEAS, FALSE ); |
---|
243 | WinEnableMenuItem( hWndMenu, CM_PRINT, FALSE ); |
---|
244 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_PRINT), (MPARAM)FALSE ); |
---|
245 | WinEnableMenuItem( hWndMenu, CM_DOCINFO, FALSE ); |
---|
246 | WinEnableMenuItem( hWndMenu, CM_FONTSINFO, FALSE ); |
---|
247 | |
---|
248 | WinEnableMenuItem( hWndMenu, CM_COPY, FALSE ); |
---|
249 | WinEnableMenuItem( hWndMenu, CM_SELECTALL, FALSE ); |
---|
250 | WinEnableMenuItem( hWndMenu, CM_FIND, FALSE ); |
---|
251 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FIND), (MPARAM)FALSE ); |
---|
252 | WinEnableMenuItem( hWndMenu, CM_FINDAGAIN, FALSE ); |
---|
253 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FINDAGAIN), (MPARAM)FALSE ); |
---|
254 | |
---|
255 | WinEnableMenuItem( hWndMenu, CM_FIRSTPAGE, FALSE ); |
---|
256 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FIRSTPAGE), (MPARAM)FALSE ); |
---|
257 | WinEnableMenuItem( hWndMenu, CM_PREVPAGE, FALSE ); |
---|
258 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_PREVPAGE), (MPARAM)FALSE ); |
---|
259 | WinEnableMenuItem( hWndMenu, CM_NEXTPAGE, FALSE ); |
---|
260 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_NEXTPAGE), (MPARAM)FALSE ); |
---|
261 | WinEnableMenuItem( hWndMenu, CM_LASTPAGE, FALSE ); |
---|
262 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_LASTPAGE), (MPARAM)FALSE ); |
---|
263 | WinEnableMenuItem( hWndMenu, CM_GOTOPAGE, FALSE ); |
---|
264 | |
---|
265 | WinEnableMenuItem( hWndMenu, CM_FITWINDOW, FALSE ); |
---|
266 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FITWINDOW), (MPARAM)FALSE ); |
---|
267 | WinEnableMenuItem( hWndMenu, CM_ACTSIZE, FALSE ); |
---|
268 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_ACTSIZE), (MPARAM)FALSE ); |
---|
269 | WinEnableMenuItem( hWndMenu, CM_FITWIDTH, FALSE ); |
---|
270 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FITWIDTH), (MPARAM)FALSE ); |
---|
271 | WinEnableMenuItem( hWndMenu, CM_ZOOM_IN_OUT, FALSE ); |
---|
272 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_ZOOM_IN_OUT), (MPARAM)FALSE ); |
---|
273 | WinEnableControl( hToolBar, TBID_ZOOM, FALSE ); |
---|
274 | |
---|
275 | WinEnableMenuItem( hWndMenu, CM_ROTATE90CW, FALSE ); |
---|
276 | WinEnableMenuItem( hWndMenu, CM_ROTATE90CCW, FALSE ); |
---|
277 | WinEnableMenuItem( hWndMenu, CM_SINGLEPAGE, FALSE ); |
---|
278 | WinEnableMenuItem( hWndMenu, CM_CONTINUOUS, FALSE ); |
---|
279 | |
---|
280 | setOfPages( 0 ); |
---|
281 | return; |
---|
282 | } |
---|
283 | |
---|
284 | |
---|
285 | checkNavigationMenus(); |
---|
286 | enableZoomMenus(); |
---|
287 | checkZoomMenus(); |
---|
288 | |
---|
289 | WinEnableMenuItem( hWndMenu, CM_PRINT, TRUE ); |
---|
290 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_PRINT), (MPARAM)TRUE ); |
---|
291 | WinEnableMenuItem( hWndMenu, CM_SAVEAS, doc->isSaveable( ev ) ); |
---|
292 | setOfPages( doc->getPageCount( ev ) ); |
---|
293 | WinEnableMenuItem( hWndMenu, CM_FONTSINFO, doc->isHaveFontInfo( ev ) ); |
---|
294 | WinEnableMenuItem( hWndMenu, CM_DOCINFO, TRUE ); |
---|
295 | |
---|
296 | BOOL haveText = doc->isHaveText( ev ); |
---|
297 | WinEnableMenuItem( hWndMenu, CM_FIND, haveText ); |
---|
298 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FIND), (MPARAM)haveText ); |
---|
299 | WinEnableMenuItem( hWndMenu, CM_SELECTALL, haveText ); |
---|
300 | |
---|
301 | WinEnableMenuItem( hWndMenu, CM_SINGLEPAGE, TRUE ); |
---|
302 | WinEnableMenuItem( hWndMenu, CM_CONTINUOUS, TRUE ); |
---|
303 | } |
---|
304 | |
---|
305 | void Lucide::goToPage( long page ) |
---|
306 | { |
---|
307 | if ( docViewer != NULL ) { |
---|
308 | docViewer->goToPage( page ); |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | void Lucide::setZoom( double zoom ) |
---|
313 | { |
---|
314 | if ( docViewer != NULL ) { |
---|
315 | docViewer->setZoom( zoom ); |
---|
316 | checkZoomMenus(); |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | void Lucide::setDocument( LuDocument *_doc ) |
---|
321 | { |
---|
322 | docViewer->setDocument( _doc ); |
---|
323 | indexWin->setDocument( _doc ); |
---|
324 | checkMenus(); |
---|
325 | } |
---|
326 | |
---|
327 | void Lucide::setPageLayout( PgLayout layout ) |
---|
328 | { |
---|
329 | if ( layout == SinglePage ) { |
---|
330 | WinCheckMenuItem( hWndMenu, CM_SINGLEPAGE, TRUE ); |
---|
331 | WinCheckMenuItem( hWndMenu, CM_CONTINUOUS, FALSE ); |
---|
332 | } |
---|
333 | else { |
---|
334 | WinCheckMenuItem( hWndMenu, CM_SINGLEPAGE, FALSE ); |
---|
335 | WinCheckMenuItem( hWndMenu, CM_CONTINUOUS, TRUE ); |
---|
336 | } |
---|
337 | |
---|
338 | docViewer->setPageLayout( layout ); |
---|
339 | } |
---|
340 | |
---|
341 | |
---|
342 | void Lucide::closeDocument() |
---|
343 | { |
---|
344 | docViewer->close(); |
---|
345 | delete doc; |
---|
346 | doc = NULL; |
---|
347 | WinSetWindowText( hWndFrame, title ); |
---|
348 | |
---|
349 | if ( thumbnailData != NULL ) { |
---|
350 | writeThumbnail( docFullName ); |
---|
351 | delete thumbnailData; |
---|
352 | thumbnailData = NULL; |
---|
353 | thumbnailDataLen = 0; |
---|
354 | } |
---|
355 | } |
---|
356 | |
---|
357 | void Lucide::loadthread( void *p ) |
---|
358 | { |
---|
359 | HAB thab = WinInitialize( 0 ); |
---|
360 | HMQ thmq = WinCreateMsgQueue( thab, 0 ); |
---|
361 | |
---|
362 | docLoaded = doc->loadFile( ev, docFullName, NULL, &loadError ); |
---|
363 | if ( docLoaded ) { |
---|
364 | if ( doc->isCreateFileThumbnail( ev ) && isThumbNeeded( docFullName ) ) { |
---|
365 | loadProgressDlg->setText( getLocalizedString( MSGS_CREATING_THUMBNAIL ).c_str() ); |
---|
366 | createThumbnail( doc ); |
---|
367 | } |
---|
368 | } |
---|
369 | loadProgressDlg->hide(); |
---|
370 | |
---|
371 | WinDestroyMsgQueue( thmq ); |
---|
372 | WinTerminate( thab ); |
---|
373 | _endthread(); |
---|
374 | } |
---|
375 | |
---|
376 | void Lucide::loadDocument( const char *fn ) |
---|
377 | { |
---|
378 | char *msg = newstrdupL( MSGS_NO_SUIT_PLUG ); |
---|
379 | |
---|
380 | // find extension |
---|
381 | char *ext = strrchr( fn, '.' ); |
---|
382 | if ( ext == NULL ) { |
---|
383 | WinMessageBox( HWND_DESKTOP, hWndFrame, msg, |
---|
384 | NULL, 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE ); |
---|
385 | } |
---|
386 | else |
---|
387 | { |
---|
388 | // test if extension supported and then close previous opened document |
---|
389 | if ( pluginMan->createDocumentForExt( ext + 1, true ) == NULL ) |
---|
390 | { |
---|
391 | WinMessageBox( HWND_DESKTOP, hWndFrame, msg, |
---|
392 | NULL, 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE ); |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | closeDocument(); |
---|
397 | |
---|
398 | doc = pluginMan->createDocumentForExt( ext + 1, false ); |
---|
399 | if ( doc == NULL ) { |
---|
400 | WinMessageBox( HWND_DESKTOP, hWndFrame, msg, |
---|
401 | NULL, 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE ); |
---|
402 | } |
---|
403 | else |
---|
404 | { |
---|
405 | strcpy( docFullName, fn ); |
---|
406 | docLoaded = false;; |
---|
407 | loadError = NULL; |
---|
408 | |
---|
409 | // Load document asynchronously |
---|
410 | loadProgressDlg = new ProgressDlg( hWndFrame ); |
---|
411 | char *ldmsg = newstrdupL( MSGS_LOADING_DOCUMENT ); |
---|
412 | loadProgressDlg->setText( ldmsg ); |
---|
413 | delete ldmsg; |
---|
414 | loadProgressDlg->show( loadthread, NULL ); // doc will be loaded |
---|
415 | delete loadProgressDlg; |
---|
416 | |
---|
417 | if ( docLoaded ) |
---|
418 | { |
---|
419 | char *t = new char[ 2048 ]; |
---|
420 | char _fn[ _MAX_FNAME ]; |
---|
421 | char _ex[ _MAX_EXT ]; |
---|
422 | _splitpath( fn, NULL, NULL, _fn, _ex ); |
---|
423 | strcpy( docFileName, _fn ); |
---|
424 | strcat( docFileName, _ex ); |
---|
425 | snprintf( t, 2048, "%s - %s", docFileName, title ); |
---|
426 | WinSetWindowText( hWndFrame, t ); |
---|
427 | delete t; |
---|
428 | setDocument( doc ); |
---|
429 | } |
---|
430 | else |
---|
431 | { |
---|
432 | if ( loadError == NULL ) |
---|
433 | { |
---|
434 | char *m = newstrdupL( MSGS_FILE_LOAD_ERROR ); |
---|
435 | WinMessageBox( HWND_DESKTOP, hWndFrame, m, |
---|
436 | NULL, 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE ); |
---|
437 | delete m; |
---|
438 | } |
---|
439 | else |
---|
440 | { |
---|
441 | WinMessageBox( HWND_DESKTOP, hWndFrame, loadError, |
---|
442 | NULL, 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE ); |
---|
443 | SOMFree( loadError ); |
---|
444 | } |
---|
445 | |
---|
446 | delete doc; |
---|
447 | doc = NULL; |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | } |
---|
452 | |
---|
453 | } |
---|
454 | delete msg; |
---|
455 | } |
---|
456 | |
---|
457 | void Lucide::openDocument() |
---|
458 | { |
---|
459 | char dirbuf[ CCHMAXPATH ]; |
---|
460 | PFILEDLG fd = new FILEDLG; |
---|
461 | memset( fd, 0, sizeof( FILEDLG ) ); |
---|
462 | fd->cbSize = sizeof( FILEDLG ); |
---|
463 | fd->fl = FDS_CENTER | FDS_OPEN_DIALOG; |
---|
464 | PrfQueryProfileString( HINI_USERPROFILE, appName, lvd, "", |
---|
465 | dirbuf, sizeof( dirbuf ) ); |
---|
466 | snprintf( fd->szFullFile, sizeof( fd->szFullFile ), |
---|
467 | "%s%s", dirbuf, pluginMan->getExtsMask().c_str() ); |
---|
468 | WinFileDlg( HWND_DESKTOP, hWndFrame, fd ); |
---|
469 | if ( fd->lReturn == DID_OK ) |
---|
470 | { |
---|
471 | char drv[ _MAX_DRIVE ] = ""; |
---|
472 | char dir[ _MAX_PATH ] = ""; |
---|
473 | char buf[ _MAX_PATH ] = ""; |
---|
474 | _splitpath( fd->szFullFile, drv, dir, NULL, NULL ); |
---|
475 | _makepath( buf, drv, dir, NULL, NULL ); |
---|
476 | PrfWriteProfileString( HINI_USERPROFILE, appName, lvd, buf ); |
---|
477 | |
---|
478 | loadDocument( fd->szFullFile ); |
---|
479 | } |
---|
480 | delete fd; |
---|
481 | } |
---|
482 | |
---|
483 | void Lucide::saveDocumentAs() |
---|
484 | { |
---|
485 | char dirbuf[ CCHMAXPATH ]; |
---|
486 | PFILEDLG fd = new FILEDLG; |
---|
487 | memset( fd, 0, sizeof( FILEDLG ) ); |
---|
488 | fd->cbSize = sizeof( FILEDLG ); |
---|
489 | fd->fl = FDS_CENTER | FDS_SAVEAS_DIALOG; |
---|
490 | PrfQueryProfileString( HINI_USERPROFILE, appName, lvd, "", |
---|
491 | dirbuf, sizeof( dirbuf ) ); |
---|
492 | char fil[ _MAX_FNAME ] = ""; |
---|
493 | char ext[ _MAX_EXT ] = ""; |
---|
494 | _splitpath( docFullName, NULL, NULL, fil, ext ); |
---|
495 | snprintf( fd->szFullFile, sizeof( fd->szFullFile ), |
---|
496 | "%s%s%s", dirbuf, fil, ext ); |
---|
497 | WinFileDlg( HWND_DESKTOP, hWndFrame, fd ); |
---|
498 | if ( fd->lReturn == DID_OK ) |
---|
499 | { |
---|
500 | bool doSave = true; |
---|
501 | if ( access( fd->szFullFile, F_OK ) == 0 ) |
---|
502 | { |
---|
503 | char *t = newstrdupL( MSGS_WARNING ); |
---|
504 | char *m = newstrdupL( MSGS_OVERWRITE_FILE ); |
---|
505 | ULONG response = WinMessageBox( HWND_DESKTOP, hWndFrame, m, t, |
---|
506 | 0, MB_YESNO | MB_WARNING | MB_MOVEABLE ); |
---|
507 | delete m; |
---|
508 | delete t; |
---|
509 | |
---|
510 | doSave = ( response == MBID_YES ); |
---|
511 | } |
---|
512 | if ( doSave ) |
---|
513 | { |
---|
514 | if ( !doc->saveAs( ev, fd->szFullFile ) ) |
---|
515 | { |
---|
516 | char *m = newstrdupL( MSGS_FILE_SAVE_ERROR ); |
---|
517 | WinMessageBox( HWND_DESKTOP, hWndFrame, m, NULL, |
---|
518 | 0, MB_OK | MB_ERROR | MB_MOVEABLE ); |
---|
519 | delete m; |
---|
520 | } |
---|
521 | } |
---|
522 | } |
---|
523 | delete fd; |
---|
524 | } |
---|
525 | |
---|
526 | void Lucide::checkNavpane() |
---|
527 | { |
---|
528 | if ( Lucide::showIndex ) { |
---|
529 | WinCheckMenuItem( hWndMenu, CM_NAVPANE, TRUE ); |
---|
530 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT( CM_NAVPANE ), (MPARAM)TRUE ); |
---|
531 | } |
---|
532 | else { |
---|
533 | WinCheckMenuItem( hWndMenu, CM_NAVPANE, FALSE ); |
---|
534 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT( CM_NAVPANE ), (MPARAM)FALSE ); |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | |
---|
539 | void Lucide::toggleMaxview() |
---|
540 | { |
---|
541 | ULONG ulFrameStyle = WinQueryWindowULong( hWndFrame, QWL_STYLE ); |
---|
542 | |
---|
543 | if ( isMaxview ) |
---|
544 | { |
---|
545 | WinSetParent( hFrameSysmenu, hWndFrame, FALSE ); |
---|
546 | WinSetParent( hFrameTitlebar, hWndFrame, FALSE ); |
---|
547 | WinSetParent( hFrameMinMax, hWndFrame, FALSE ); |
---|
548 | ulFrameStyle |= FS_SIZEBORDER; |
---|
549 | } |
---|
550 | else |
---|
551 | { |
---|
552 | WinQueryWindowPos( hWndFrame, &winPos.Swp ); |
---|
553 | winPos.XRestore = WinQueryWindowUShort( hWndFrame, QWS_XRESTORE ); |
---|
554 | winPos.YRestore = WinQueryWindowUShort( hWndFrame, QWS_YRESTORE ); |
---|
555 | winPos.CXRestore = WinQueryWindowUShort( hWndFrame, QWS_CXRESTORE ); |
---|
556 | winPos.CYRestore = WinQueryWindowUShort( hWndFrame, QWS_CYRESTORE ); |
---|
557 | winPos.XMinimize = WinQueryWindowUShort( hWndFrame, QWS_XMINIMIZE ); |
---|
558 | winPos.YMinimize = WinQueryWindowUShort( hWndFrame, QWS_YMINIMIZE ); |
---|
559 | |
---|
560 | WinSetParent( hFrameSysmenu, HWND_OBJECT, FALSE ); |
---|
561 | WinSetParent( hFrameTitlebar, HWND_OBJECT, FALSE ); |
---|
562 | WinSetParent( hFrameMinMax, HWND_OBJECT, FALSE ); |
---|
563 | ulFrameStyle &= ~FS_SIZEBORDER; |
---|
564 | } |
---|
565 | |
---|
566 | WinSetWindowULong( hWndFrame, QWL_STYLE, ulFrameStyle ); |
---|
567 | WinSendMsg( hWndFrame, WM_UPDATEFRAME, |
---|
568 | MPFROMLONG( FCF_TITLEBAR | FCF_SIZEBORDER | FCF_SYSMENU | FCF_MINMAX ), |
---|
569 | MPVOID ); |
---|
570 | |
---|
571 | if ( isMaxview ) |
---|
572 | { |
---|
573 | WinSetWindowUShort( hWndFrame, QWS_XRESTORE, winPos.XRestore ); |
---|
574 | WinSetWindowUShort( hWndFrame, QWS_YRESTORE, winPos.YRestore ); |
---|
575 | WinSetWindowUShort( hWndFrame, QWS_CXRESTORE, winPos.CXRestore ); |
---|
576 | WinSetWindowUShort( hWndFrame, QWS_CYRESTORE, winPos.CYRestore ); |
---|
577 | WinSetWindowUShort( hWndFrame, QWS_XMINIMIZE, winPos.XMinimize ); |
---|
578 | WinSetWindowUShort( hWndFrame, QWS_YMINIMIZE, winPos.YMinimize ); |
---|
579 | ULONG swpopt = SWP_MOVE | SWP_SIZE | SWP_SHOW; |
---|
580 | WinSetWindowPos( hWndFrame, NULLHANDLE, |
---|
581 | winPos.Swp.x, winPos.Swp.y, winPos.Swp.cx, winPos.Swp.cy, |
---|
582 | swpopt ); |
---|
583 | } |
---|
584 | else |
---|
585 | { |
---|
586 | WinSetWindowPos( hWndFrame, HWND_TOP, 0, 0, |
---|
587 | WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ), |
---|
588 | WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ), |
---|
589 | SWP_SIZE | SWP_MOVE | SWP_ZORDER ); |
---|
590 | } |
---|
591 | |
---|
592 | isMaxview = !isMaxview; |
---|
593 | } |
---|
594 | |
---|
595 | |
---|
596 | void Lucide::toggleFullscreen() |
---|
597 | { |
---|
598 | if ( isFullscreen ) |
---|
599 | { |
---|
600 | docViewer->setFullscreen( false ); |
---|
601 | WinSetParent( docViewer->getFrameHWND(), hWndFrame, TRUE ); |
---|
602 | WinSendMsg( hVertSplitter, SBM_SETWINDOWS, |
---|
603 | MPFROMHWND( indexWin->getHWND() ), |
---|
604 | MPFROMHWND( docViewer->getFrameHWND() ) ); |
---|
605 | } |
---|
606 | else |
---|
607 | { |
---|
608 | docViewer->setFullscreen( true ); |
---|
609 | WinSendMsg( hVertSplitter, SBM_SETWINDOWS, |
---|
610 | MPFROMHWND( indexWin->getHWND() ), |
---|
611 | MPFROMHWND( NULLHANDLE ) ); |
---|
612 | WinSetParent( docViewer->getFrameHWND(), HWND_DESKTOP, FALSE ); |
---|
613 | WinSetWindowPos( docViewer->getFrameHWND(), HWND_TOP, 0, 0, |
---|
614 | WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ), |
---|
615 | WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ), |
---|
616 | SWP_SIZE | SWP_MOVE | SWP_ZORDER ); |
---|
617 | } |
---|
618 | |
---|
619 | isFullscreen = !isFullscreen; |
---|
620 | } |
---|
621 | |
---|
622 | void Lucide::focusDocview() |
---|
623 | { |
---|
624 | WinSetFocus( HWND_DESKTOP, docViewer->getViewHWND() ); |
---|
625 | } |
---|
626 | |
---|
627 | void Lucide::toggleZoom() |
---|
628 | { |
---|
629 | if ( ( doc != NULL ) && doc->isScalable( ev ) ) |
---|
630 | { |
---|
631 | bool isZoom = !docViewer->isZoomMode(); |
---|
632 | |
---|
633 | WinCheckMenuItem( hWndMenu, CM_ZOOM_IN_OUT, isZoom ); |
---|
634 | WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT( CM_ZOOM_IN_OUT ), (MPARAM)isZoom ); |
---|
635 | docViewer->setZoomMode( isZoom ); |
---|
636 | } |
---|
637 | } |
---|
638 | |
---|
639 | void Lucide::cmdMinimize() |
---|
640 | { |
---|
641 | if ( isFullscreen ) { |
---|
642 | toggleFullscreen(); |
---|
643 | } |
---|
644 | WinSetWindowPos( hWndFrame, HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE ); |
---|
645 | } |
---|
646 | |
---|
647 | void Lucide::cmdSwitchToFullscreen() |
---|
648 | { |
---|
649 | if ( !isFullscreen ) |
---|
650 | { |
---|
651 | SWP pos = {0}; |
---|
652 | WinQueryWindowPos( hWndFrame, &pos ); |
---|
653 | |
---|
654 | if ( pos.fl & SWP_MINIMIZE ) { |
---|
655 | WinSetWindowPos( hWndFrame, HWND_TOP, 0, 0, 0, 0, |
---|
656 | SWP_SHOW | SWP_ACTIVATE | SWP_RESTORE | SWP_ZORDER ); |
---|
657 | } |
---|
658 | toggleFullscreen(); |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | static MRESULT EXPENTRY splProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) |
---|
663 | { |
---|
664 | switch ( msg ) |
---|
665 | { |
---|
666 | case WM_CONTROL: |
---|
667 | { |
---|
668 | if ( ( SHORT1FROMMP( mp1 ) == ID_SPLITTER ) && |
---|
669 | ( SHORT2FROMMP( mp1 ) == SBN_POSITIONCHANGED ) ) |
---|
670 | { |
---|
671 | SHORT pos = SHORT1FROMMP( mp2 ); |
---|
672 | if ( pos > 0 ) { |
---|
673 | Lucide::splitterPos = pos; |
---|
674 | Lucide::showIndex = true; |
---|
675 | } |
---|
676 | else { |
---|
677 | Lucide::showIndex = false; |
---|
678 | } |
---|
679 | Lucide::checkNavpane(); |
---|
680 | } |
---|
681 | } |
---|
682 | break; |
---|
683 | |
---|
684 | case WM_COMMAND: |
---|
685 | { |
---|
686 | switch ( SHORT1FROMMP(mp1) ) |
---|
687 | { |
---|
688 | case CM_OPEN: |
---|
689 | Lucide::openDocument(); |
---|
690 | return (MRESULT)FALSE; |
---|
691 | |
---|
692 | case CM_SAVEAS: |
---|
693 | Lucide::saveDocumentAs(); |
---|
694 | return (MRESULT)FALSE; |
---|
695 | |
---|
696 | case CM_PRINT: |
---|
697 | { |
---|
698 | PrintDlg *d = new PrintDlg( hWndFrame, doc, docViewer->getCurrentPage() + 1 ); |
---|
699 | if ( d->showDialog() == DID_OK ) { |
---|
700 | // print |
---|
701 | PrintSetup *p = new PrintSetup; |
---|
702 | memset( p, 0, sizeof( PrintSetup ) ); |
---|
703 | d->getPrintSetup( p ); |
---|
704 | printDocument( hWndFrame, doc, Lucide::docFileName, p ); |
---|
705 | delete p; |
---|
706 | } |
---|
707 | delete d; |
---|
708 | return (MRESULT)FALSE; |
---|
709 | } |
---|
710 | |
---|
711 | case CM_EXIT: |
---|
712 | WinPostMsg( hWndFrame, WM_CLOSE, NULL, NULL ); |
---|
713 | return (MRESULT)FALSE; |
---|
714 | |
---|
715 | case CM_DOCINFO: |
---|
716 | { |
---|
717 | LuDocumentInfo *dinfo = doc->getDocumentInfo( ev ); |
---|
718 | DocInfoDlg *d = new DocInfoDlg( hWndFrame, dinfo ); |
---|
719 | d->doDialog(); |
---|
720 | LuDocument::freeDocumentInfo( ev, dinfo ); |
---|
721 | return (MRESULT)FALSE; |
---|
722 | } |
---|
723 | |
---|
724 | case CM_FONTSINFO: |
---|
725 | { |
---|
726 | FontsInfoDlg *d = new FontsInfoDlg( hWndFrame, doc ); |
---|
727 | d->doDialog(); |
---|
728 | return (MRESULT)FALSE; |
---|
729 | } |
---|
730 | |
---|
731 | case CM_PLUGINSLIST: |
---|
732 | { |
---|
733 | PluginViewDlg *d = new PluginViewDlg( hWndFrame, |
---|
734 | pluginMan->getPluginsList() ); |
---|
735 | d->doDialog(); |
---|
736 | return (MRESULT)FALSE; |
---|
737 | } |
---|
738 | |
---|
739 | case CM_COPY: |
---|
740 | docViewer->copyToClipbrd(); |
---|
741 | return (MRESULT)FALSE; |
---|
742 | |
---|
743 | case CM_SELECTALL: |
---|
744 | docViewer->selectAll(); |
---|
745 | return (MRESULT)FALSE; |
---|
746 | |
---|
747 | case CM_FIND: |
---|
748 | if ( findDlg->showDialog() == DID_OK ) { |
---|
749 | if ( strlen( findDlg->getSearchString() ) > 0 ) |
---|
750 | { |
---|
751 | docViewer->searchDocument( findDlg->getSearchString(), |
---|
752 | findDlg->isCaseSensitive(), false ); |
---|
753 | |
---|
754 | WinEnableMenuItem( hWndMenu, CM_FINDAGAIN, TRUE ); |
---|
755 | WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_FINDAGAIN), (MPARAM)TRUE ); |
---|
756 | } |
---|
757 | } |
---|
758 | return (MRESULT)FALSE; |
---|
759 | |
---|
760 | case CM_FINDAGAIN: |
---|
761 | docViewer->searchDocument( findDlg->getSearchString(), |
---|
762 | findDlg->isCaseSensitive(), true ); |
---|
763 | return (MRESULT)FALSE; |
---|
764 | |
---|
765 | case CM_SETTINGS: |
---|
766 | { |
---|
767 | SettingsDlg *d = new SettingsDlg( hWndFrame, settings ); |
---|
768 | d->doDialog(); |
---|
769 | return (MRESULT)FALSE; |
---|
770 | } |
---|
771 | |
---|
772 | case CM_FIRSTPAGE: |
---|
773 | Lucide::goToPage( 0 ); |
---|
774 | return (MRESULT)FALSE; |
---|
775 | |
---|
776 | case CM_NEXTPAGE: |
---|
777 | Lucide::goToPage( docViewer->getCurrentPage() + 1 ); |
---|
778 | return (MRESULT)FALSE; |
---|
779 | |
---|
780 | case CM_PREVPAGE: |
---|
781 | Lucide::goToPage( docViewer->getCurrentPage() - 1 ); |
---|
782 | return (MRESULT)FALSE; |
---|
783 | |
---|
784 | case CM_LASTPAGE: |
---|
785 | Lucide::goToPage( doc->getPageCount( ev ) - 1 ); |
---|
786 | return (MRESULT)FALSE; |
---|
787 | |
---|
788 | case CM_GOTOPAGE: |
---|
789 | { |
---|
790 | GotoDlg *d = new GotoDlg( hWndFrame, doc->getPageCount( ev ), |
---|
791 | docViewer->getCurrentPage() + 1 ); |
---|
792 | if ( d->showDialog() == DID_OK ) { |
---|
793 | long pg = d->getPage(); |
---|
794 | if ( pg > 0 ) { |
---|
795 | Lucide::goToPage( pg - 1 ); |
---|
796 | } |
---|
797 | } |
---|
798 | delete d; |
---|
799 | return (MRESULT)FALSE; |
---|
800 | } |
---|
801 | |
---|
802 | case CM_FITWINDOW: |
---|
803 | Lucide::setZoom( -2 ); |
---|
804 | return (MRESULT)FALSE; |
---|
805 | |
---|
806 | case CM_ACTSIZE: |
---|
807 | Lucide::setZoom( 1 ); |
---|
808 | return (MRESULT)FALSE; |
---|
809 | |
---|
810 | case CM_FITWIDTH: |
---|
811 | Lucide::setZoom( -1 ); |
---|
812 | return (MRESULT)FALSE; |
---|
813 | |
---|
814 | case CM_ZOOM_IN_OUT: |
---|
815 | Lucide::toggleZoom(); |
---|
816 | return (MRESULT)FALSE; |
---|
817 | |
---|
818 | case CM_SINGLEPAGE: |
---|
819 | Lucide::setPageLayout( SinglePage ); |
---|
820 | return (MRESULT)FALSE; |
---|
821 | |
---|
822 | case CM_CONTINUOUS: |
---|
823 | Lucide::setPageLayout( Continuous ); |
---|
824 | return (MRESULT)FALSE; |
---|
825 | |
---|
826 | case CM_ROTATE90CW: |
---|
827 | docViewer->setRotation( docViewer->getRotation() + 90 ); |
---|
828 | return (MRESULT)FALSE; |
---|
829 | |
---|
830 | case CM_ROTATE90CCW: |
---|
831 | docViewer->setRotation( docViewer->getRotation() - 90 ); |
---|
832 | return (MRESULT)FALSE; |
---|
833 | |
---|
834 | case CM_NAVPANE: |
---|
835 | { |
---|
836 | Lucide::showIndex = !Lucide::showIndex; |
---|
837 | Lucide::checkNavpane(); |
---|
838 | WinSendMsg( hVertSplitter, SBM_SETSPLITTERPOS, |
---|
839 | MPFROMSHORT( Lucide::showIndex ? Lucide::splitterPos : 0 ), MPVOID ); |
---|
840 | } |
---|
841 | return (MRESULT)FALSE; |
---|
842 | |
---|
843 | case CM_MAXVIEW: |
---|
844 | Lucide::toggleMaxview(); |
---|
845 | return (MRESULT)FALSE; |
---|
846 | |
---|
847 | case CM_FULLSCREEN: |
---|
848 | Lucide::toggleFullscreen(); |
---|
849 | return (MRESULT)FALSE; |
---|
850 | |
---|
851 | case CM_PRODINFO: |
---|
852 | AboutBox( hWndFrame ); |
---|
853 | return (MRESULT)FALSE; |
---|
854 | |
---|
855 | case CM_MINIMIZE: |
---|
856 | Lucide::cmdMinimize(); |
---|
857 | return (MRESULT)FALSE; |
---|
858 | |
---|
859 | case CM_TOFULLSCREEN: |
---|
860 | Lucide::cmdSwitchToFullscreen(); |
---|
861 | return (MRESULT)FALSE; |
---|
862 | } |
---|
863 | } |
---|
864 | break; |
---|
865 | } |
---|
866 | return pOldSplProc( hwnd, msg, mp1, mp2 ); |
---|
867 | } |
---|
868 | |
---|
869 | |
---|
870 | char deffont[] = "9.WarpSans"; |
---|
871 | int deffontlen = sizeof( deffont ); |
---|
872 | |
---|
873 | extern "C" APIRET APIENTRY LucideMain( int argc, char *argv[] ) |
---|
874 | { |
---|
875 | HMQ hmq; |
---|
876 | QMSG qmsg; |
---|
877 | hab = WinInitialize( 0 ); |
---|
878 | hmq = WinCreateMsgQueue( hab, 0 ); |
---|
879 | |
---|
880 | loadLang(); |
---|
881 | |
---|
882 | settings = new LuSettings; |
---|
883 | settings->load(); |
---|
884 | |
---|
885 | pluginMan = new PluginManager; |
---|
886 | |
---|
887 | InitPMSplitterClass( hab ); |
---|
888 | InitPMToolbarClass( hab ); |
---|
889 | |
---|
890 | ULONG ulFrameFlags = FCF_TITLEBAR | FCF_SIZEBORDER | FCF_SYSMENU | |
---|
891 | FCF_MINMAX | FCF_TASKLIST | FCF_NOBYTEALIGN | FCF_ICON; |
---|
892 | title = newstrdupL( MSGS_MAIN_WIN_TITLE ); |
---|
893 | hWndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ulFrameFlags, NULL, title, |
---|
894 | WS_SYNCPAINT|WS_VISIBLE, _hmod, IDI_MAIN_ICON, NULL ); |
---|
895 | hFrameSysmenu = WinWindowFromID( hWndFrame, FID_SYSMENU ); |
---|
896 | hFrameTitlebar = WinWindowFromID( hWndFrame, FID_TITLEBAR ); |
---|
897 | hFrameMinMax = WinWindowFromID( hWndFrame, FID_MINMAX ); |
---|
898 | WinSetAccelTable( hab, WinLoadAccelTable( hab, _hmod, IDA_MAINACCEL ), hWndFrame ); |
---|
899 | hWndMenu = WinLoadMenu( hWndFrame, _hmod, IDM_MAINMENU ); |
---|
900 | localizeMenu( hWndMenu ); |
---|
901 | WinSetWindowUShort( hWndMenu, QWS_ID, FID_MENU ); |
---|
902 | |
---|
903 | // Vertical splitter and his windows - Index and Document view |
---|
904 | hVertSplitter = WinCreateWindow( hWndFrame, WC_ER_SPLITTER, "", |
---|
905 | WS_VISIBLE | SBS_VSPLIT, |
---|
906 | 0, 0, 0, 0, hWndFrame, HWND_TOP, |
---|
907 | ID_SPLITTER, NULL, NULL ); |
---|
908 | |
---|
909 | indexWin = new IndexWindow( hWndFrame ); |
---|
910 | |
---|
911 | DocumentViewer::registerClass(); |
---|
912 | |
---|
913 | docViewer = new DocumentViewer( hWndFrame ); |
---|
914 | |
---|
915 | WinSendMsg( hVertSplitter, SBM_SETWINDOWS, |
---|
916 | MPFROMHWND( indexWin->getHWND() ), MPFROMHWND( docViewer->getFrameHWND() ) ); |
---|
917 | Lucide::splitterPos = PrfQueryProfileInt( HINI_USERPROFILE, appName, splpos, Lucide::splitterPos ); |
---|
918 | Lucide::showIndex = PrfQueryProfileInt( HINI_USERPROFILE, appName, showind, Lucide::showIndex ); |
---|
919 | WinSendMsg( hVertSplitter, SBM_SETSPLITTERPOS, |
---|
920 | MPFROMSHORT( Lucide::showIndex ? Lucide::splitterPos : 0 ), MPVOID ); |
---|
921 | |
---|
922 | // Horizontal splitter and its windows - Toolbar and Vertical splitter |
---|
923 | // Horizontal splitter is client window |
---|
924 | HWND hHorizSplitter = WinCreateWindow( hWndFrame, WC_ER_SPLITTER, "", |
---|
925 | WS_VISIBLE | SBS_HSPLIT | SBS_SECONDFIXED, |
---|
926 | 0, 0, 0, 0, hWndFrame, HWND_TOP, |
---|
927 | FID_CLIENT, NULL, NULL ); |
---|
928 | pOldSplProc = WinSubclassWindow( hHorizSplitter, splProc ); |
---|
929 | |
---|
930 | hToolBar = createToolbar( hWndFrame ); |
---|
931 | |
---|
932 | WinSendMsg( hHorizSplitter, SBM_SETWINDOWS, |
---|
933 | MPFROMHWND( hVertSplitter ), MPFROMHWND( hToolBar ) ); |
---|
934 | // ãáâ ®¢šâì 䚪ášà®¢ ë© à §¬¥à €«ï âã«¡ à |
---|
935 | WinSendMsg( hHorizSplitter, SBM_SETFIXEDSIZE, |
---|
936 | MPFROMSHORT( DEFAULT_PICTSIZE + TOOLBAR_HEIGHT_ADD ), MPVOID ); |
---|
937 | |
---|
938 | findDlg = new FindDlg( hWndFrame ); |
---|
939 | Lucide::checkMenus(); |
---|
940 | Lucide::setPageLayout( settings->layout ); |
---|
941 | Lucide::setZoom( settings->zoom ); |
---|
942 | |
---|
943 | // ®ª § âì ®ª® ¯à®£à ¬¬ë |
---|
944 | if ( !PMRestoreWindowPos( NULL, appName, fwp, hWndFrame, |
---|
945 | TRUE, TRUE, FALSE, FALSE, FALSE ) ) { |
---|
946 | WinSetWindowPos( hWndFrame, HWND_TOP, 100, 100, 630, 400, |
---|
947 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ACTIVATE ); |
---|
948 | } |
---|
949 | |
---|
950 | Lucide::focusDocview(); |
---|
951 | |
---|
952 | if ( argc > 1 ) { |
---|
953 | Lucide::loadDocument( argv[1] ); |
---|
954 | } |
---|
955 | |
---|
956 | Lucide::checkNavpane(); |
---|
957 | initPipeMon( hWndFrame ); |
---|
958 | |
---|
959 | // Messsage loop |
---|
960 | while ( WinGetMsg( hab, &qmsg, 0, 0, 0 ) ) { |
---|
961 | WinDispatchMsg( hab, &qmsg ); |
---|
962 | } |
---|
963 | |
---|
964 | if ( WinIsWindow( hab, hWndFrame ) ) |
---|
965 | { |
---|
966 | char valbuf[ 3 ] = ""; |
---|
967 | PrfWriteProfileString( HINI_USERPROFILE, appName, splpos, |
---|
968 | itoa( Lucide::splitterPos, valbuf, 10 ) ); |
---|
969 | PrfWriteProfileString( HINI_USERPROFILE, appName, showind, |
---|
970 | itoa( Lucide::showIndex, valbuf, 10 ) ); |
---|
971 | PMStoreWindowPos( NULL, appName, fwp, hWndFrame ); |
---|
972 | } |
---|
973 | |
---|
974 | WinDestroyWindow( hWndFrame ); |
---|
975 | |
---|
976 | Lucide::closeDocument(); |
---|
977 | delete docViewer; |
---|
978 | delete indexWin; |
---|
979 | |
---|
980 | // must be freed _after_ document |
---|
981 | delete pluginMan; |
---|
982 | |
---|
983 | delete findDlg; |
---|
984 | delete title; |
---|
985 | delete settings; |
---|
986 | unInitPipeMon(); |
---|
987 | |
---|
988 | WinDestroyMsgQueue( hmq ); |
---|
989 | WinTerminate( hab ); |
---|
990 | return 0; |
---|
991 | } |
---|
992 | |
---|