text_controller.h

Go to the documentation of this file.
00001 /*
00002  * File Name: text_controller.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_CONTROLLER_H
00028 #define TEXT_CONTROLLER_H
00029 
00030 #include "text_tasks.h"
00031 #include "text_model.h"
00032 #include "thread.h"
00033 
00034 namespace text
00035 {
00036 
00037 class TextModel;
00038 class TextView;
00039 
00040 class TextController
00041 {
00042 public:
00043     /// @brief Constructors and destructors.
00044     TextController(TextModel *_model, TextView *_view);
00045     ~TextController();
00046 
00047 public:
00048     /// @brief Start working thread.
00049     void start();
00050 
00051     /// @brief Stop working thread.
00052     void stop();
00053 
00054     /// @brief Render specified page.
00055     void render(unsigned int id, unsigned int page_index, void *data, unsigned char* bmp);
00056 
00057     /// @brief Render a page start with start_pos.
00058     void render(unsigned int id, const Position& start_pos, void *data, unsigned char* bmp);
00059 
00060     /// @brief Paginate.
00061     void paginate(const Position& start, bool send_start_notification);
00062 
00063     /// @brief Search specified pattern in text model.
00064     /// @param search_context Search type and search criteria.
00065     void search(SearchContext* sc);
00066     
00067     /// @brief Pause pagination
00068     ///
00069     /// Called when document window is deactivated
00070     ///
00071     void pause_pagination();
00072 
00073     /// @brief Restart pagination again after it was paused
00074     ///
00075     /// Called when document windows is activated again
00076     ///    
00077     void restart_pagination();
00078 
00079 private:
00080     void on_pagination_aborted(const Position& start);
00081     void on_pagination_finished(unsigned int, unsigned int);
00082     void on_search_aborted(SearchContext* sc);
00083 
00084 private:
00085     /// @brief Text model.
00086     TextModel *model;
00087 
00088     /// @brief Text view.
00089     TextView *view;
00090 
00091     /// @brief Worker thread
00092     common::Thread thread;
00093 
00094     /// @brief Flag to indicate if pagination is busy
00095     ///
00096     /// Note, this flag will stay busy even if pagination is paused
00097     ///
00098     bool pagination_pending;
00099         
00100     /// @brief Flag to indicate if pagination was paused
00101     bool pagination_paused;
00102     
00103 
00104 };
00105 
00106 }; // namespace text
00107 
00108 #endif // TEXT_CONTROLLER_H
00109 
00110 
Generated by  doxygen 1.6.2-20100208