notepad_window.h

Go to the documentation of this file.
00001 #ifndef __NOTEPAD_WINDOW_H__
00002 #define __NOTEPAD_WINDOw_H__
00003 
00004 /**
00005  * File Name  : notepad_window.h
00006  *
00007  * Description: notepad window class
00008  */
00009 
00010 /*
00011  * This file is part of notepad.
00012  *
00013  * notepad is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * notepad is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2010 IREX Technologies B.V.
00029  * All rights reserved.
00030  */
00031  
00032 #include <glib.h>
00033 #include <gtk/gtk.h>
00034 #include "notepad_gtk_source.h"
00035 #include "notepad_doc.h"
00036 #include "notepad_pages.h"
00037 #include <liberscribble/scb.h>
00038 
00039 namespace notepad 
00040 {
00041     class CNotepadWindow
00042     {
00043         private:
00044             GtkWidget*      main_window;
00045             typedef gtk::GtkEventSource<CNotepadWindow> EventSource;
00046             EventSource     source;
00047             CNotepadDoc     notepad_doc;
00048             CNotepadPages   notepad_pages;
00049             GCtx            gctx;
00050             GdkImage*       current_image;
00051             gboolean        erscribble_mode;
00052             int             erscribble_status;
00053             int             erase_status;
00054             int             current_page;
00055             gboolean        invert_pageturn;
00056             gboolean        skip_expose_events;
00057             guint           doublepagefliptimout;
00058             guint           pageflipto;
00059 
00060         public:
00061             CNotepadWindow();
00062             ~CNotepadWindow();
00063             bool init(bool create, const gchar* filename);
00064             GtkWidget* getWindow();
00065             void show(bool show);
00066             void quit();
00067             void scribble(CNPoint& pos, int status);
00068             void erase(CNPoint& pos, int status);
00069             void pageflip_or_create();
00070             void pageflip_back();
00071             void pageflip_forward();
00072             void goto_relative_page(gint delta);
00073             void goto_page();
00074             void goto_page(gint pageno);
00075             void insert_page();
00076             void clear_current_page();
00077             void delete_current_page();
00078             void delete_current_page_impl();
00079             void update_page_counter();
00080             void update(bool full = true);
00081             void set_scribble_mode(gboolean scribble_mode); // write = TRUE /erase = FALSE
00082             gboolean get_scribble_mode(); 
00083             gboolean save(bool update_last_read = false);
00084             gboolean rename();
00085             gchar*   getLabel(); // caller takes ownership of result
00086             void     set_rotation(np_rotation nrotation);
00087             void     set_pageturn_inverted(gboolean is_inverted);
00088             const gchar* getFilename(); // caller not owner of result
00089 
00090         private:
00091             CNotepadWindow(const CNotepadWindow&);              // no copy 
00092             CNotepadWindow& operator=(const CNotepadWindow&);   // no assignment
00093 
00094             void draw_page_margin();
00095             void draw_image_to_window();
00096 
00097             // callbacks of dialogs
00098             static void on_jump_to_page_dialog_response(GtkDialog* dialog, gint page, gpointer data);
00099             static void on_failure_dialog_response(GtkDialog* dialog, gint response, gpointer data);
00100             static void on_sureclear_dialog_response(GtkDialog* dialog, gint response, gpointer data);
00101             static void on_suredelete_dialog_response(GtkDialog* dialog, gint response, gpointer data);
00102             static void on_rename_dialog_response(GtkDialog* dialog, gint response, gpointer data);
00103 
00104         private:   
00105             // Gtk event handlers
00106             void connect_event_handlers(GtkWidget* widget);
00107             void disconnect_event_handlers(GtkWidget* widget);
00108             void on_expose(GdkEvent *event);
00109             void on_visibility_notify(GdkEvent *event);
00110             void on_configure(GdkEvent *event);
00111             void on_button_press(GdkEvent *event);
00112             void on_button_release(GdkEvent *event);
00113             void on_motion_notify(GdkEvent *event);
00114             void on_key_press(GdkEvent *event);
00115             void on_key_release(GdkEvent *event);
00116             void on_delete(GdkEvent *event);
00117     };
00118 
00119 }
00120 
00121 #endif // __NOTEPAD_WINDOW_H__
Generated by  doxygen 1.6.2-20100208