00001
00008 #ifndef INCL_PALEDIT
00009 #define INCL_PALEDIT 1
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "objbrowse.h"
00030 #include "rect.h"
00031 #include <vector>
00032
00033 class Flex_file_info;
00034 class U7object;
00035
00036
00037
00038
00039 class Palette_edit: public Object_browser
00040 {
00041 Flex_file_info *flex_info;
00042 guchar *image;
00043 int width, height;
00044 GtkWidget *draw;
00045 GdkGC *drawgc;
00046 std::vector<GdkRgbCmap*> palettes;
00047 int cur_pal;
00048 GtkColorSelectionDialog *colorsel;
00049 GtkWidget *sbar;
00050 GtkWidget *pspin;
00051 GtkAdjustment *palnum_adj;
00052 guint sbar_sel;
00053 Rectangle selected_box;
00054 GtkWidget *insert_btn, *remove_btn, *up_btn, *down_btn;
00055
00056 virtual void show(int x, int y, int w, int h);
00057 virtual void show()
00058 { Palette_edit::show(0, 0,
00059 draw->allocation.width, draw->allocation.height);}
00060 void select(int new_sel);
00061 virtual void load();
00062 virtual void render();
00063
00064 static int color_closed(GtkWidget *widget, GdkEvent *event,
00065 gpointer data);
00066 static void color_cancel(GtkWidget *widget, gpointer data);
00067 static void color_okay(GtkWidget *widget, gpointer data);
00068 void double_clicked();
00069 GtkWidget *create_controls();
00070 void enable_controls();
00071
00072 void setup();
00073 void new_palette();
00074 void update_flex(int pnum);
00075 public:
00076 Palette_edit(Flex_file_info *flinfo);
00077 ~Palette_edit();
00078 void show_palette(int palnum);
00079
00080 void unselect(bool need_render = true);
00081 void move_palette(bool up);
00082 void add_palette();
00083 void remove_palette();
00084
00085 static gint configure(GtkWidget *widget, GdkEventConfigure *event,
00086 gpointer data);
00087
00088 static gint expose(GtkWidget *widget, GdkEventExpose *event,
00089 gpointer data);
00090
00091 static gint mouse_press(GtkWidget *widget, GdkEventButton *event,
00092 gpointer data);
00093
00094 static void drag_data_get(GtkWidget *widget, GdkDragContext *context,
00095 GtkSelectionData *data, guint info, guint time, gpointer data);
00096
00097 static gint selection_clear(GtkWidget *widget,
00098 GdkEventSelection *event, gpointer data);
00099 static gint drag_begin(GtkWidget *widget, GdkDragContext *context,
00100 gpointer data);
00101 static void palnum_changed(GtkAdjustment *adj, gpointer data);
00102 static void export_palette(char *fname, gpointer user_data);
00103 static void import_palette(char *fname, gpointer user_data);
00104 };
00105
00106 #endif