00001 /* 00002 * File Name: text_tasks.h 00003 */ 00004 00005 /* 00006 * This file is part of uds-plugin-plaintext. 00007 * 00008 * uds-plugin-plaintext is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * uds-plugin-plaintext is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 /** 00023 * Copyright (C) 2008 iRex Technologies B.V. 00024 * All rights reserved. 00025 */ 00026 00027 #ifndef TEXT_TASKS_H 00028 #define TEXT_TASKS_H 00029 00030 #include "thread.h" 00031 #include "signal_slot.h" 00032 #include "text_base_types.h" 00033 00034 using namespace std; 00035 using namespace common; 00036 00037 namespace text 00038 { 00039 00040 class TextView; 00041 class TextModel; 00042 00043 /// @brief This is the first task for text plugin. It is executed by worker 00044 /// thread once text view is initialized. 00045 class InitializationTask : public common::Task 00046 { 00047 public: 00048 /// @brief Constructors and destructors 00049 InitializationTask(TextView *view); 00050 virtual ~InitializationTask(); 00051 00052 public: 00053 virtual void execute(); 00054 00055 private: 00056 TextView *text_view; 00057 }; 00058 00059 /// @brief This is the last task for text plugin. It is executed by worker 00060 /// thread once text view is deinitialized. 00061 class DeinitializationTask : public common::Task 00062 { 00063 public: 00064 /// @brief Constructors and destructors 00065 DeinitializationTask(TextView *view); 00066 virtual ~DeinitializationTask(); 00067 00068 public: 00069 virtual void execute(); 00070 00071 private: 00072 TextView *text_view; 00073 }; 00074 00075 /// @brief Pagination task definition for text plugin. The pagination task is 00076 /// responsible for calculating start position and end position for a 00077 /// specified page, and calculating total pages. 00078 class PaginationTask : public common::Task 00079 { 00080 public: 00081 /// @brief Constructors and destructors 00082 PaginationTask(TextView *view, const Position& _start, bool _is_child); 00083 virtual ~PaginationTask(); 00084 00085 public: 00086 /// @brief Abort signal. 00087 utils::Signal<const Position&> abort_signal; 00088 00089 public: 00090 virtual void execute(); 00091 00092 private: 00093 TextView *text_view; 00094 Position start_pos; 00095 bool is_child; 00096 }; 00097 00098 00099 /// @brief Pagination abort tasks 00100 /// 00101 /// A dummy task to abort the current pagination 00102 /// 00103 class PaginationAbortTask : public common::Task 00104 { 00105 public: 00106 /// @brief Constructors and destructors 00107 PaginationAbortTask(TextView *view); 00108 virtual ~PaginationAbortTask(); 00109 00110 public: 00111 virtual void execute(); 00112 00113 private: 00114 TextView *text_view; 00115 }; 00116 00117 /// @brief Render task definition for text plugin. The render task is 00118 /// responsible for rendering a specified page. 00119 class RenderTask : public common::Task 00120 { 00121 public: 00122 /// @brief Constructors and destructors 00123 RenderTask(unsigned int _id, 00124 TextView *_view, 00125 const Position& _pos, 00126 void *_user_data, 00127 unsigned char *_bmp); 00128 virtual ~RenderTask(); 00129 00130 public: 00131 virtual void execute(); 00132 00133 private: 00134 unsigned int id; 00135 TextView *text_view; 00136 Position start_pos; 00137 void *user_data; 00138 unsigned char *bmp; 00139 }; 00140 00141 /// @brief Search task definition for text plugin. The search task is 00142 /// responsible for find the previous/next/all occurrence of specified 00143 /// pattern. 00144 class SearchTask : public common::Task 00145 { 00146 public: 00147 /// @brief Constructors and destructors 00148 SearchTask(TextModel *_model, SearchContext* _sc); 00149 virtual ~SearchTask(); 00150 00151 public: 00152 utils::Signal<SearchContext*> abort_signal; 00153 00154 public: 00155 virtual void execute(); 00156 00157 private: 00158 TextModel *text_model; 00159 SearchContext *sc; 00160 }; 00161 00162 }; // namespace text 00163 00164 #endif // TEXT_TASKS_H 00165