1 /*
2  *  KCemu -- The emulator for the KC85 homecomputer series and much more.
3  *  Copyright (C) 1997-2010 Torsten Paul
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License along
16  *  with this program; if not, write to the Free Software Foundation, Inc.,
17  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ui_gtk_main_h
21 #define __ui_gtk_main_h
22 
23 #include "kc/system.h"
24 
25 #include "ui/statusl.h"
26 #include "ui/hsv2rgb.h"
27 
28 #include "ui/generic/ui_base.h"
29 
30 #include "ui/gtk/window.h"
31 
32 using namespace std;
33 
34 class MainWindow : public StatusListener, public UI_Gtk_Window {
35 private:
36     struct {
37         GtkDrawingArea *drawingarea;
38 
39         GtkMenu        *popup_menu;
40 
41         GtkMenuBar     *menubar;
42         GtkHBox        *status_hbox;
43         GtkLabel       *status_label;
44         GtkStatusbar   *status_statusbar;
45 
46         GtkAccelGroup  *accel_group;
47 
48         guint           idle_id;
49         long            status_sec;
50     } _w;
51 
52     int           _width;
53     int           _height;
54 
55     bool          _expose;
56     GdkGC         *_gc;
57     GdkVisual     *_visual;
58     GdkImage      *_image;
59     byte_t        *_dirty_old;
60     GdkColormap   *_colormap;
61     GdkColor       _col[24];
62 
63     CMD           *_cmd_ui_toggle;
64 
65     string        _accel_map_path;
66 
67 protected:
68     void init(void);
69     void init_icon(void);
70     void add_menu_accel_group(const char *base, const char *name);
71     void wire_menu_item(const char *name, const char *shortcut, const char *command);
72 
73     gulong get_col(byte_t *bitmap, int which, int idx, int width);
74     void update_1(byte_t *bitmap, byte_t *dirty, int dirty_size, int width, int height);
75     void update_2(byte_t *bitmap, byte_t *dirty, int dirty_size, int width, int height);
76     void update_3(byte_t *bitmap, byte_t *dirty, int dirty_size, int width, int height);
77     void update_1_debug(byte_t *bitmap, byte_t *dirty, int dirty_size, int width, int height);
78     void update_2_scanline(byte_t *bitmap, byte_t *dirty, int dirty_size, int width, int height);
79     void update_3_smooth(byte_t *bitmap, byte_t *dirty, int dirty_size, int width, int height);
80 
81     void attach_remote_listener(void);
82 
83     static gboolean on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
84     static gboolean on_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
85     static void on_accel_group_changed(GtkAccelGroup *accel_group, guint keyval, GdkModifierType modifier, GClosure *accel_closure, gpointer user_data);
86     static gboolean on_accel_group_changed_idle_func(gpointer data);
87     static gboolean on_property_change(GtkWidget *widget, GdkEventProperty *event, gpointer data);
88 
89 public:
90     MainWindow(const char *ui_xml_file);
91     virtual ~MainWindow(void);
92 
93     virtual GtkWidget * get_main_window(void);
94 
95     virtual void process_events(void);
96     virtual void show(int width, int height);
97     virtual bool resize(int width, int height);
98     virtual void update(UI_Base *ui, int image_width, int image_height, bool full_update);
99     virtual void allocate_color_rgb(int idx, int r, int g, int b);
100 
101     virtual gboolean get_display_effect(void);
102     virtual void set_display_effect(gboolean effect);
103 
104     virtual void set_fps(unsigned long fps);
105     virtual void status_bar_toggle(void);
106     virtual void menu_bar_toggle(void);
107 
108     virtual GdkColor * get_colormap(void);
109     /*
110      *  StatusListener
111      */
112     virtual void setStatus(const char *msg);
113 };
114 
115 #endif /* __ui_gtk_main_h */
116 
117