objbrowse.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000-2001 The Exult Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef OBJBROWSE_H
00020 #define OBJBROWSE_H
00021 
00022 #include <gtk/gtk.h>
00023 
00024 //#include <glade/glade.h>
00025 
00026 class Shape_group;
00027 class Shape_file_info;
00028 
00029 class Object_browser {
00030 private:
00031   GtkWidget *widget;
00032 protected:
00033   int selected;     // Index of user-selected entry,
00034           //   counting from the top-left entry
00035           //   currently rendered.
00036   int index0;     // Index of top-leftmost in
00037           //   displayed list.
00038   GtkWidget *vscroll;   // Vertical scrollbar.
00039   GtkWidget *hscroll;   // Horizontal scrollbar.
00040   Shape_group *group;   // Non-null to use filter.
00041   GtkWidget *popup;   // Popup menu in draw area.
00042   Shape_file_info *file_info; // Our creator (or null).
00043   GtkWidget *find_text;   // For searching.
00044   GtkWidget *loc_down, *loc_up; // 'Locate' buttons.
00045           // 'Move' buttons:
00046   GtkWidget *move_down, *move_up;
00047   int config_width, config_height;// For storing prev. dims.
00048 
00049   void set_widget(GtkWidget *w);
00050   static bool search_name(const char *nm, const char *srch);
00051 public:
00052   Object_browser(Shape_group *grp = 0, Shape_file_info *fi = 0);
00053   virtual ~Object_browser();
00054   
00055   GtkWidget *get_widget();
00056   Shape_group *get_group()
00057     { return group; }
00058   int get_selected()    // Return index of sel'd item, or -1.
00059     { return selected < 0 ? -1 : index0 + selected; }
00060   GtkWidget *get_find_text()  // Get 'find' text widget.
00061     { return find_text; }
00062   virtual void load()   // Load from file data.
00063     {  }
00064   virtual void render() = 0;
00065           // Blit onto screen.
00066   virtual void show(int x, int y, int w, int h) = 0;
00067   virtual void show() = 0;
00068   virtual int get_selected_id()
00069     { return -1; }
00070   virtual bool server_response(int id, unsigned char *data, int datalen);
00071   virtual void end_terrain_editing();
00072   virtual void set_background_color(guint32 c);
00073           // Menu items:
00074   static void on_browser_group_add(
00075           GtkMenuItem *item, gpointer udata);
00076           // Add 'Add to group...' submenu.
00077   void add_group_submenu(GtkWidget *popup);
00078   static void on_browser_file_save(GtkMenuItem *item, gpointer udata);
00079   static void on_browser_file_revert(GtkMenuItem *item, gpointer udata);
00080   virtual GtkWidget *create_popup();  // Popup menu.
00081       
00082   enum        // Create controls at bottom.
00083     {     // OR together what you want.
00084     find_controls = 1,
00085     locate_controls = 2,
00086     move_controls = 4
00087     };
00088   GtkWidget *create_controls(int controls);
00089           // Virtuals for controls.
00090   virtual void search(const char *srch, int dir)
00091     {  }
00092   virtual void locate(bool upwards)// Locate terrain on game map.
00093     {  }
00094   virtual void move(bool upwards) // Move current selected chunk.
00095     {  }
00096 };
00097 
00098           // File-selector utility:
00099           // Callback for file-selector 'ok':
00100 typedef void (*File_sel_okay_fun)(const char *, gpointer);
00101 GtkFileSelection *Create_file_selection
00102   (
00103   const char *title,
00104   File_sel_okay_fun ok_handler,
00105   gpointer user_data
00106   );
00107 
00108 #endif

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