00001 /* 00002 * Copyright (C) 2006, iRex Technologies B.V. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2, or (at your option) 00007 * any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef CONTROLLER_H_ 00020 #define CONTROLLER_H_ 00021 00022 #include "PageInfo.h" 00023 #include "PDFCore.h" 00024 #include "RenderThread.h" 00025 #include "GtkMgr.h" 00026 #include "PDFView.h" 00027 #include "RenderThread.h" 00028 #include <sys/time.h> 00029 #include <liberdm/display.h> 00030 #include "channels.h" 00031 #include "Settings.h" 00032 #include "ScribbleMgr.h" 00033 00035 // 00036 // controller serves as access pointer, from which every component can 00037 // access all the other components. 00038 // controller is initialized, maintained and destroyed by CPDFApp class 00039 // 00040 // settings contains all global parameters. 00041 // NOTICE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 00042 // When settings.zoom is larger than value calculated from page type 00043 // We should use the value without changing settings.zoom 00044 // 00045 // we should check zoom max value when 00046 // 1. issues a new request 00047 // 2. receives a message from render thread *** 00048 // 3. query a page in page list 00049 // 00051 00052 class CPDFApp; 00053 struct Controller 00054 { 00055 private: 00056 struct timeval startStamp; 00057 struct timeval now; 00058 void initTimeStamp() 00059 { 00060 gettimeofday(&startStamp, NULL); 00061 } 00062 public: 00063 CPDFApp * app; // becomes NULL when quit from app 00064 CPDFCore * core; // same as app 00065 CPDFView * view; // same as app 00066 PageList pageList; // delete only when quit from app 00067 TodoList todoList; // same as pageList 00068 GtkMgr gtkMgr; // gtk related function 00069 CSettings settings; // global settings 00070 CRenderThread thread; 00071 ThreadParam param; 00072 CChannels channels; // all channels in iLiad 00073 int updateReq; // used to control update, when it reaches to 0, update screen 00074 // it can only be increased by toolbar and pagebar 00075 CScribbleMgr scbMgr; 00076 00077 Controller() 00078 { 00079 core = NULL; view = NULL; app = NULL; 00080 param.bQuit = gFalse; 00081 param.pageList = &pageList; 00082 param.todoList = &todoList; 00083 param.ctrl = this; 00084 updateReq = 0; 00085 initTimeStamp(); 00086 } 00087 00088 int getTimeStamp() 00089 { 00090 gettimeofday(&now, NULL); 00091 return (now.tv_sec - startStamp.tv_sec); 00092 } 00093 00094 int getHighTimeStamp() 00095 { 00096 gettimeofday(&now, NULL); 00097 return (now.tv_sec - startStamp.tv_sec) * 1000000 + 00098 (now.tv_usec - startStamp.tv_usec); 00099 } 00100 00101 void validateSettings(); 00102 double calZoom(const int page); 00103 }; 00104 00105 #endif 00106