root/trunk/tests/DumbMainView.cxx

Revision 253, 9.6 kB (checked in by jordi, 2 years ago)

Applied Enrico Tröger's patch for full screen support. This closes ticket #33.

Line 
1// ePDFView - Dumb Test Main View.
2// Copyright (C) 2006 Emma's Software.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18#include <epdfview.h>
19#include <stdlib.h>
20#include "DumbFindView.h"
21#include "DumbPageView.h"
22#include "DumbPreferencesView.h"
23#include "DumbPrintView.h"
24#include "DumbMainView.h"
25
26using namespace ePDFView;
27
28////////////////////////////////////////////////////////////////
29// Interface Methods
30////////////////////////////////////////////////////////////////
31DumbMainView::DumbMainView (MainPter *pter):
32    IMainView (pter)
33{
34    m_CurrentPage = 0;
35    m_FindView = new DumbFindView ();
36    m_NumberOfPages = g_strdup ("of 0");
37    m_GoToPageText = g_strdup ("");
38    m_OpenFileName = g_strdup ("");
39    m_LastOpenFileFolder = NULL;
40    m_LastSaveFileFolder = NULL;
41    m_Outline = NULL;
42    m_PageView = new DumbPageView ();
43    m_Password = NULL;
44    m_SaveFileName = g_strdup ("");
45    m_SensitiveFind = TRUE;
46    m_SensitiveGoToFirstPage = TRUE;
47    m_SensitiveGoToLastPage = TRUE;
48    m_SensitiveGoToNextPage = TRUE;
49    m_SensitiveGoToPage = TRUE;
50    m_SensitiveGoToPreviousPage = TRUE;
51    m_SensitivePrint = TRUE;
52    m_SensitiveReload = TRUE;
53    m_SensitiveRotateLeft = TRUE;
54    m_SensitiveRotateRight = TRUE;
55    m_SensitiveSave = TRUE;
56    m_SensitiveZoom = TRUE;
57    m_SensitiveZoomIn = TRUE;
58    m_SensitiveZoomOut = TRUE;
59    m_SensitiveZoomFit = TRUE;
60    m_SensitiveZoomWidth = TRUE;
61    m_Shown = FALSE;
62    m_ShownError = FALSE;
63    m_ShownIndex = FALSE;
64    m_ShownStatusbar = FALSE;
65    m_ShownToolbar = FALSE;
66    m_Title = g_strdup ("");
67    m_TimesShownPassword = 0;
68    m_ZoomText = g_strdup ("");
69    m_ZoomToFit = FALSE;
70    m_ZoomToWidth = FALSE;
71}
72
73DumbMainView::~DumbMainView ()
74{
75    delete m_FindView;
76    delete m_PageView;
77    g_free (m_GoToPageText);
78    g_free (m_NumberOfPages);
79    g_free (m_LastOpenFileFolder);
80    g_free (m_LastSaveFileFolder);
81    g_free (m_OpenFileName);
82    g_free (m_Password);
83    g_free (m_SaveFileName);
84    g_free (m_Title);
85    g_free (m_ZoomText);
86}
87
88void
89DumbMainView::activeZoomFit (gboolean active)
90{
91    m_ZoomToFit = active;
92}
93
94void
95DumbMainView::activeZoomWidth (gboolean active)
96{
97    m_ZoomToWidth = active;
98}
99
100IFindView *
101DumbMainView::getFindView ()
102{
103    return m_FindView;
104}
105
106IPageView *
107DumbMainView::getPageView ()
108{
109    return m_PageView;
110}
111
112IPreferencesView *
113DumbMainView::getPreferencesView ()
114{
115    return new DumbPreferencesView ();
116}
117
118#if defined (HAVE_CUPS)
119IPrintView *
120DumbMainView::getPrintView ()
121{
122    return new DumbPrintView ();
123}
124#endif // HAVE_CUPS
125
126
127gchar *
128DumbMainView::openFileDialog (const gchar *lastFolder)
129{
130    g_free (m_LastOpenFileFolder);
131    m_LastOpenFileFolder = g_strdup (lastFolder);
132    return g_strdup (m_OpenFileName);
133}
134
135gchar *
136DumbMainView::promptPasswordDialog (void)
137{
138    m_TimesShownPassword++;
139    return g_strdup (m_Password);
140}
141
142gchar *
143DumbMainView::saveFileDialog (const gchar *lastFolder)
144{
145    g_free (m_LastSaveFileFolder);
146    m_LastSaveFileFolder = g_strdup (lastFolder);
147    return g_strdup (m_SaveFileName);
148}
149
150void
151DumbMainView::sensitiveGoToFirstPage (gboolean sensitive)
152{
153    m_SensitiveGoToFirstPage = sensitive;
154}
155
156void
157DumbMainView::sensitiveFind (gboolean sensitive)
158{
159    m_SensitiveFind = sensitive;
160}
161
162void
163DumbMainView::sensitiveGoToLastPage (gboolean sensitive)
164{
165    m_SensitiveGoToLastPage = sensitive;
166}
167
168void
169DumbMainView::sensitiveGoToNextPage (gboolean sensitive)
170{
171    m_SensitiveGoToNextPage = sensitive;
172}
173
174void
175DumbMainView::sensitiveGoToPage (gboolean sensitive)
176{
177    m_SensitiveGoToPage = sensitive;
178}
179
180void
181DumbMainView::sensitiveGoToPreviousPage (gboolean sensitive)
182{
183    m_SensitiveGoToPreviousPage = sensitive;
184}
185
186void
187DumbMainView::sensitiveOpen (gboolean sensitive)
188{
189}
190
191void
192DumbMainView::sensitivePrint (gboolean sensitive)
193{
194    m_SensitivePrint = sensitive;
195}
196
197void
198DumbMainView::sensitiveReload (gboolean sensitive)
199{
200    m_SensitiveReload = sensitive;
201}
202
203void
204DumbMainView::sensitiveRotateLeft (gboolean sensitive)
205{
206    m_SensitiveRotateLeft = sensitive;
207}
208
209void
210DumbMainView::sensitiveRotateRight (gboolean sensitive)
211{
212    m_SensitiveRotateRight = sensitive;
213}
214
215void
216DumbMainView::sensitiveSave (gboolean sensitive)
217{
218    m_SensitiveSave = sensitive;
219}
220
221void
222DumbMainView::sensitiveZoom (gboolean sensitive)
223{
224    m_SensitiveZoom = sensitive;
225}
226
227void
228DumbMainView::sensitiveZoomIn (gboolean sensitive)
229{
230    m_SensitiveZoomIn = sensitive;
231}
232
233void
234DumbMainView::sensitiveZoomOut (gboolean sensitive)
235{
236    m_SensitiveZoomOut = sensitive;
237}
238
239void
240DumbMainView::sensitiveZoomFit (gboolean sensitive)
241{
242    m_SensitiveZoomFit = sensitive;
243}
244
245void
246DumbMainView::sensitiveZoomWidth (gboolean sensitive)
247{
248    m_SensitiveZoomWidth = sensitive;
249}
250
251const gchar *
252DumbMainView::getGoToPageText ()
253{
254    return (const gchar *)m_GoToPageText;
255}
256
257const gchar *
258DumbMainView::getZoomText ()
259{
260    return m_ZoomText;
261}
262
263void
264DumbMainView::setCursor (ViewCursor cursorType)
265{
266}
267
268void
269DumbMainView::setFullScreen (gboolean fullScreen)
270{
271}
272
273void
274DumbMainView::setNumberOfPagesText (const gchar *text)
275{
276    g_free (m_NumberOfPages);
277    m_NumberOfPages = g_strdup (text);
278}
279
280void
281DumbMainView::setGoToPageText (const char *text)
282{
283    g_free (m_GoToPageText);
284    m_GoToPageText = g_strdup (text);
285    m_CurrentPage = atoi(text);
286}
287
288void
289DumbMainView::setTitle (const gchar *title)
290{
291    g_free (m_Title);
292    m_Title = g_strdup (title);
293}
294
295void
296DumbMainView::setOutline (DocumentOutline *outline)
297{
298    m_Outline = outline;
299}
300
301void
302DumbMainView::setStatusBarText (const gchar *text)
303{
304}
305
306void
307DumbMainView::setZoomText (const gchar *text)
308{
309    g_free (m_ZoomText);
310    m_ZoomText = g_strdup (text);
311}
312
313void
314DumbMainView::show (void)
315{
316    m_Shown = TRUE;
317}
318
319void
320DumbMainView::showErrorMessage (const gchar *title, const gchar *body)
321{
322    m_ShownError = TRUE;
323}
324
325void
326DumbMainView::showIndex (gboolean show)
327{
328    m_ShownIndex = show;
329}
330
331void
332DumbMainView::showStatusbar (gboolean show)
333{
334    m_ShownStatusbar = show;
335}
336
337void
338DumbMainView::showToolbar (gboolean show)
339{
340    m_ShownToolbar = show;
341}
342
343////////////////////////////////////////////////////////////////
344// Test Methods
345////////////////////////////////////////////////////////////////
346
347gint
348DumbMainView::countTimesShownPasswordPrompt ()
349{
350    return m_TimesShownPassword;
351}
352
353gint
354DumbMainView::getCurrentPage ()
355{
356    return m_CurrentPage;
357}
358
359const gchar *
360DumbMainView::getLastOpenFileFolder ()
361{
362    return m_LastOpenFileFolder;
363}
364
365const gchar *
366DumbMainView::getLastSaveFileFolder ()
367{
368    return m_LastSaveFileFolder;
369}
370
371
372DocumentOutline *
373DumbMainView::getOutline ()
374{
375    return m_Outline;
376}
377
378const gchar *
379DumbMainView::getTitle ()
380{
381    return m_Title;
382}
383
384gboolean
385DumbMainView::isSensitiveFind ()
386{
387    return m_SensitiveFind;
388}
389
390gboolean
391DumbMainView::isSensitiveGoToFirstPage ()
392{
393    return m_SensitiveGoToFirstPage;
394}
395
396gboolean
397DumbMainView::isSensitiveGoToLastPage ()
398{
399    return m_SensitiveGoToLastPage;
400}
401
402gboolean
403DumbMainView::isSensitiveGoToNextPage ()
404{
405    return m_SensitiveGoToNextPage;
406}
407
408gboolean
409DumbMainView::isSensitiveGoToPage ()
410{
411    return m_SensitiveGoToPage;
412}
413
414gboolean
415DumbMainView::isSensitiveGoToPreviousPage ()
416{
417    return m_SensitiveGoToPreviousPage;
418}
419
420gboolean
421DumbMainView::isSensitivePrint ()
422{
423    return m_SensitivePrint;
424}
425
426gboolean
427DumbMainView::isSensitiveReload ()
428{
429    return m_SensitiveReload;
430}
431
432gboolean
433DumbMainView::isSensitiveRotateLeft ()
434{
435    return m_SensitiveRotateLeft;
436}
437
438gboolean
439DumbMainView::isSensitiveRotateRight ()
440{
441    return m_SensitiveRotateRight;
442}
443
444gboolean
445DumbMainView::isSensitiveSave ()
446{
447    return m_SensitiveSave;
448}
449
450gboolean
451DumbMainView::isSensitiveZoom ()
452{
453    return m_SensitiveZoom;
454}
455
456gboolean
457DumbMainView::isSensitiveZoomIn ()
458{
459    return m_SensitiveZoomIn;
460}
461
462gboolean
463DumbMainView::isSensitiveZoomOut ()
464{
465    return m_SensitiveZoomOut;
466}
467
468gboolean
469DumbMainView::isSensitiveZoomFit ()
470{
471    return m_SensitiveZoomFit;
472}
473
474gboolean
475DumbMainView::isSensitiveZoomWidth ()
476{
477    return m_SensitiveZoomWidth;
478}
479
480gboolean
481DumbMainView::isShown ()
482{
483    return m_Shown;
484}
485
486gboolean
487DumbMainView::isShownIndex ()
488{
489    return m_ShownIndex;
490}
491
492gboolean
493DumbMainView::isShownStatusbar ()
494{
495    return m_ShownStatusbar;
496}
497
498gboolean
499DumbMainView::isShownToolbar ()
500{
501    return m_ShownToolbar;
502}
503
504gboolean
505DumbMainView::isZoomToFitActive ()
506{
507    return m_ZoomToFit;
508}
509
510gboolean
511DumbMainView::isZoomToWidthActive ()
512{
513    return m_ZoomToWidth;
514}
515
516void
517DumbMainView::setOpenFileName (const gchar *fileName)
518{
519    g_free (m_OpenFileName);
520    m_OpenFileName = g_strdup (fileName);
521}
522
523void
524DumbMainView::setPassword (const gchar *password)
525{
526    g_free (m_Password);
527    m_Password = g_strdup (password);
528    m_TimesShownPassword = 0;
529}
530
531void
532DumbMainView::setSaveFileName (const gchar *fileName)
533{
534    g_free (m_SaveFileName);
535    m_SaveFileName = g_strdup (fileName);
536}
537
538gboolean
539DumbMainView::shownError ()
540{
541    gboolean shown = m_ShownError;
542    // It's like the user clicked the "OK" button. No shown anymore, until
543    // the next error.
544    m_ShownError = FALSE;
545
546    return shown;
547}
Note: See TracBrowser for help on using the browser.