shapedraw.h

Go to the documentation of this file.
00001 
00007 #ifndef INCL_SHAPEDRAW
00008 #define INCL_SHAPEDRAW  1
00009 
00010 /*
00011 Copyright (C) 2001  The Exult Team
00012 
00013 This program is free software; you can redistribute it and/or
00014 modify it under the terms of the GNU General Public License
00015 as published by the Free Software Foundation; either version 2
00016 of the License, or (at your option) any later version.
00017 
00018 This program 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, write to the Free Software
00025 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00026 */
00027 
00028 #include <gtk/gtk.h>
00029 #include <gdk/gdktypes.h>
00030 
00031 class Vga_file;
00032 class Shape_frame;
00033 class Image_buffer8;
00034 
00035 typedef void (*Drop_callback)(int filenum,
00036         int shapenum, int framenum, void *udata);
00037 
00038 /*
00039  *  This class can draw shapes from a .vga file.
00040  */
00041 class Shape_draw
00042   {
00043 protected:
00044   Vga_file *ifile;    // Where the shapes come from.
00045   GtkWidget *draw;    // GTK draw area to display them in.
00046   GdkGC *drawgc;      // For drawing in 'draw'.
00047   Image_buffer8 *iwin;    // What we render into.
00048   GdkRgbCmap *palette;    // For gdk_draw_indexed_image().
00049   Drop_callback drop_callback;  // Called when a shape is dropped here.
00050   void *drop_user_data;
00051   bool dragging;      // Dragging from here.
00052 public:
00053   Shape_draw(Vga_file *i, unsigned char *palbuf, GtkWidget *drw);
00054   virtual ~Shape_draw();
00055           // Blit onto screen.
00056   void show(GdkDrawable *drawable, int x, int y, int w, int h);
00057   void show(int x, int y, int w, int h)
00058     { show(draw->window, x, y, w, h); }
00059   void show()
00060     { show(0, 0, draw->allocation.width, draw->allocation.height);}
00061   guint32 get_color(int i)
00062     { return palette->colors[i]; }
00063   void draw_shape(Shape_frame *shape, int x, int y);
00064   void draw_shape(int shapenum, int framenum, int x, int y);
00065   void draw_shape_outline(int shapenum, int framenum, 
00066           int x, int y, unsigned char color);
00067   void draw_shape_centered(int shapenum, int framenum);
00068   virtual void render();    // Update what gets shown.
00069   void set_background_color(guint32 c);
00070       
00071   void configure();   // Configure when created/resized.
00072           // Handler for drop.
00073   static void drag_data_received(GtkWidget *widget, 
00074     GdkDragContext *context, gint x, gint y, 
00075     GtkSelectionData *selection_data, guint info, guint time,
00076     gpointer udata);
00077   void enable_drop(Drop_callback callback, void *udata);
00078   void set_drag_icon(GdkDragContext *context, Shape_frame *shape);
00079           // Start/end dragging from here.
00080   void start_drag(char *target, int id, GdkEvent *event);
00081   void mouse_up()
00082     { dragging = false; }
00083   };
00084 
00085 #endif

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