paledit.h

Go to the documentation of this file.
00001 
00008 #ifndef INCL_PALEDIT
00009 #define INCL_PALEDIT  1
00010 
00011 /*
00012 Copyright (C) 2000 The Exult Team
00013 
00014 This program is free software; you can redistribute it and/or
00015 modify it under the terms of the GNU General Public License
00016 as published by the Free Software Foundation; either version 2
00017 of the License, or (at your option) any later version.
00018 
00019 This program is distributed in the hope that it will be useful,
00020 but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License
00025 along with this program; if not, write to the Free Software
00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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  *  Show a palette.
00038  */
00039 class Palette_edit: public Object_browser
00040   {
00041   Flex_file_info *flex_info;  // Where file data is stored.
00042   guchar *image;      // Holds data to render.
00043   int width, height;    // Dimensions of image.
00044   GtkWidget *draw;    // GTK draw area to display them in.
00045   GdkGC *drawgc;      // For drawing in 'draw'.
00046   std::vector<GdkRgbCmap*> palettes;  // The palettes to display.
00047   int cur_pal;      // Index of current palette.
00048   GtkColorSelectionDialog *colorsel;// Open color selector.
00049   GtkWidget *sbar;    // Status bar.
00050   GtkWidget *pspin;   // Spin button for palette #.
00051   GtkAdjustment *palnum_adj;  // For palette #.
00052   guint sbar_sel;     // Status bar context for selection.
00053   Rectangle selected_box;   // Location of selected color.
00054   GtkWidget *insert_btn, *remove_btn, *up_btn, *down_btn;
00055           // Blit onto screen.
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); // Show new selection.
00061   virtual void load();    // Load from file data.
00062   virtual void render();    // Draw list.
00063           // Handle color-selector buttons.
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();    // Handle double-click on a color.
00069   GtkWidget *create_controls(); // Controls at bottom of browser.
00070   void enable_controls();   // Enable/disable controls after sel.
00071           //   has changed.
00072   void setup();     // Setup box.
00073   void new_palette();   // Create new palette.
00074   void update_flex(int pnum); // Update flex_info data.
00075 public:
00076   Palette_edit(Flex_file_info *flinfo);
00077   ~Palette_edit();
00078   void show_palette(int palnum);  // Show desired palette.
00079           // Turn off selection.
00080   void unselect(bool need_render = true);
00081   void move_palette(bool up);
00082   void add_palette();
00083   void remove_palette();
00084           // Configure when created/resized.
00085   static gint configure(GtkWidget *widget, GdkEventConfigure *event,
00086               gpointer data);
00087           // Blit to screen.
00088   static gint expose(GtkWidget *widget, GdkEventExpose *event,
00089               gpointer data);
00090           // Handle mouse press.
00091   static gint mouse_press(GtkWidget *widget, GdkEventButton *event,
00092               gpointer data);
00093           // Give dragged palette.
00094   static void drag_data_get(GtkWidget *widget, GdkDragContext *context,
00095     GtkSelectionData *data, guint info, guint time, gpointer data);
00096           // Someone else selected.
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

Generated on Mon Jul 9 14:42:48 2007 for ExultEngine by  doxygen 1.5.1