main_window.h

Go to the documentation of this file.
00001 /*
00002  * File Name: main_window.h
00003  */
00004 
00005 /*
00006  * This file is part of liberscribble.
00007  *
00008  * liberscribble 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  * liberscribble 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 MAIN_WINDOW_H_
00028 #define MAIN_WINDOW_H_
00029 
00030 #include <string>
00031 #include <gtk/gtk.h>
00032 
00033 #include "gtk_widget.h"
00034 #include "gtk_source.h"
00035 
00036 #include "scribble_manager.h"
00037 
00038 
00039 namespace test
00040 {
00041 
00042 /// The main window
00043 class MainWindow
00044 {
00045 public:
00046     MainWindow();
00047     ~MainWindow();
00048 
00049     /// @brief Retrieve Gtk widget directly. It serves as parent widget for all 
00050     /// sub views.
00051     inline GtkWidget *get_window() { return main_window; }
00052 
00053     /// Show window or hide the main window.
00054     void show(bool show = true);
00055 
00056 private:
00057 
00058     void create();
00059     void destroy();
00060 
00061     // update the drawing content
00062     void update();
00063 
00064     // goto the previous page
00065     void goto_prev_page();
00066 
00067     // goto the next page
00068     void goto_next_page();
00069 
00070     void connect_event_handlers(GtkWidget *widget);
00071 
00072     /// Gtk events handler.
00073     gboolean on_expose(GtkWidget *widget, GdkEvent *event);
00074     gboolean on_configure(GtkWidget *widget, GdkEvent *event);
00075     gboolean on_button_press(GtkWidget *widget, GdkEvent *event);
00076     gboolean on_button_release(GtkWidget *widget, GdkEvent *event);
00077     gboolean on_motion_notify(GtkWidget *widget, GdkEvent *event);
00078     gboolean on_key_press(GtkWidget *widget, GdkEvent *event);
00079     gboolean on_key_release(GtkWidget *widget, GdkEvent *event);
00080     gboolean on_delete(GtkWidget *widget, GdkEvent *event);
00081 
00082     // draw scribble
00083     void draw_scribble_page();
00084 
00085     // scribble
00086     // status: 0, begin; 1, move; 2, end
00087     void scribble(const ScbPoint &pos, int status);
00088 
00089     // erase
00090     // status: 0, begin; 1, move; 2, end
00091     void erase(const ScbPoint &pos, int status);
00092 
00093     // insert a document record into database
00094     void add_document_to_db();
00095 
00096 private:
00097     GtkWidget *main_window;     ///< The GTK window.
00098     typedef gtk::GtkEventSource<MainWindow> EventSource;
00099     EventSource source;         ///< The event source.
00100 
00101     // scribble manager
00102     ScribbleMgr erscribble_mgr;
00103 
00104     // scribble GC
00105     ScribbleGC  erscribble_gc;
00106 
00107     // current page id
00108     ScbPageId   cur_page_id;
00109 
00110     // current page number
00111     int         page_number;
00112 
00113     // scribble status
00114     int         erscribble_status;
00115 
00116     // erase status
00117     int         erase_status;
00118 
00119     // scribble mode
00120     bool        erscribble_mode;
00121 
00122     // target path
00123     std::string target_doc_path;
00124 };
00125 
00126 }; //namespace test
00127 
00128 #endif
Generated by  doxygen 1.6.2-20100208