home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / imagemap / imap_command.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-25  |  3.5 KB  |  111 lines

  1. /*
  2.  * This is a plug-in for the GIMP.
  3.  *
  4.  * Generates clickable image maps.
  5.  *
  6.  * Copyright (C) 1998-1999 Maurits Rijk  lpeek.mrijk@consunet.nl
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21.  *
  22.  */
  23.  
  24. #ifndef _IMAP_COMMAND_H
  25. #define _IMAP_COMMAND_H
  26.  
  27. #include "imap_object.h"
  28.  
  29. #define DEFAULT_UNDO_LEVELS 10
  30.  
  31. typedef struct CommandClass_t CommandClass_t;
  32. typedef struct Command_t Command_t;
  33. typedef struct CommandList_t CommandList_t;
  34.  
  35. typedef enum {CMD_APPEND, CMD_DESTRUCT, CMD_IGNORE} CmdExecuteValue_t;
  36.  
  37. #define COMMAND_PROTO(class) \
  38. static void class##_destruct(Command_t *command); \
  39. static CmdExecuteValue_t class##_execute(Command_t *command); \
  40. static void class##_undo(Command_t *command); \
  41. static void class##_redo(Command_t *command)
  42.  
  43. struct CommandClass_t {
  44.    void (*destruct)(Command_t*);
  45.    CmdExecuteValue_t (*execute)(Command_t*);
  46.    void (*undo)(Command_t*);
  47.    void (*redo)(Command_t*);
  48. };
  49.  
  50. struct Command_t {
  51.    CommandClass_t      *class;
  52.    CommandList_t       *sub_commands;
  53.    const gchar           *name;
  54.    gboolean         locked;
  55. };
  56.  
  57.  
  58. typedef Command_t* (*CommandFactory_t)(void);
  59.  
  60. typedef void (*CommandListCallbackFunc_t)(Command_t*, gpointer);
  61.  
  62. typedef struct {
  63.    CommandListCallbackFunc_t func;
  64.    gpointer data;
  65. } CommandListCB_t;
  66.  
  67. typedef struct {
  68.    GList *list;
  69. } CommandListCallback_t;
  70.  
  71. struct CommandList_t {
  72.    CommandList_t *parent;
  73.    gint undo_levels;
  74.    GList *list;
  75.    GList *undo;            /* Pointer to current undo command */
  76.    GList *redo;            /* Pointer to current redo command */
  77.    CommandListCallback_t update_cb;
  78. };
  79.  
  80. CommandList_t *command_list_new(gint undo_levels);
  81. void command_list_destruct(CommandList_t *list);
  82. void command_list_set_undo_level(gint level);
  83. void command_list_add(Command_t *command);
  84. void command_list_remove_all(void);
  85. void command_list_undo(CommandList_t *list);
  86. void command_list_undo_all(CommandList_t *list);
  87. void command_list_redo(CommandList_t *list);
  88. void command_list_redo_all(CommandList_t *list);
  89. void command_list_add_update_cb(CommandListCallbackFunc_t func, gpointer data);
  90. Command_t *command_list_get_redo_command(void);
  91.  
  92. Command_t *command_new(void (*func)(void));
  93. Command_t *command_init(Command_t *command, const gchar *name, 
  94.             CommandClass_t *class);
  95. void command_execute(Command_t *command);
  96. void command_undo(Command_t *command);
  97. void command_redo(Command_t *command);
  98. void command_set_name(Command_t *command, const gchar *name);
  99. void command_add_subcommand(Command_t *command, Command_t *sub_command);
  100.  
  101. void last_command_undo(void);
  102. void last_command_redo(void);
  103.  
  104. void subcommand_list_add(CommandList_t *list, Command_t *command);
  105. Command_t *subcommand_start(const gchar *name);
  106. void subcommand_end(void);
  107.  
  108. #define command_lock(command) ((command)->locked = TRUE)
  109.  
  110. #endif /* _IMAP_COMMAND_H */
  111.