1 /* Dia -- an diagram creation/manipulation program
2  * Copyright (C) 1998 Alexander Larsson
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 #ifndef TOOL_H
19 #define TOOL_H
20 
21 #include <gdk/gdk.h>
22 
23 typedef struct _Tool Tool;
24 typedef struct _ToolState ToolState;
25 
26 typedef enum _ToolType ToolType;
27 
28 #include "display.h"
29 
30 typedef void (* ButtonPressFunc)   (Tool *, GdkEventButton *, DDisplay *ddisp);
31 typedef void (* ButtonHoldFunc)    (Tool *, GdkEventButton *, DDisplay *ddisp);
32 typedef void (* DoubleClickFunc)   (Tool *, GdkEventButton *, DDisplay *ddisp);
33 typedef void (* ButtonReleaseFunc) (Tool *, GdkEventButton *, DDisplay *ddisp);
34 typedef void (* MotionFunc)        (Tool *, GdkEventMotion *, DDisplay *ddisp);
35 
36 enum _ToolType {
37   CREATE_OBJECT_TOOL,
38   MAGNIFY_TOOL,
39   MODIFY_TOOL,
40   SCROLL_TOOL,
41   TEXTEDIT_TOOL
42 };
43 
44 struct _Tool {
45   ToolType type;
46 
47   /*  Action functions  */
48   ButtonPressFunc    button_press_func;
49   ButtonHoldFunc     button_hold_func;
50   ButtonReleaseFunc  button_release_func;
51   MotionFunc         motion_func;
52   DoubleClickFunc    double_click_func;
53 };
54 
55 struct _ToolState {
56   ToolType type;
57   gpointer extra_data;
58   gpointer user_data;
59   GtkWidget *button;
60   int invert_persistence;
61 };
62 
63 extern Tool *active_tool, *transient_tool;
64 
65 void tool_get(ToolState *state);
66 void tool_restore(const ToolState *state);
67 void tool_free(Tool *tool);
68 void tool_select(ToolType type, gpointer extra_data, gpointer user_date,
69                  GtkWidget *button, int invert_persistence);
70 void tool_select_former(void);
71 void tool_reset(void);
72 void tool_options_dialog_show(ToolType type, gpointer extra_data,
73 			      gpointer user_data,GtkWidget *button,
74                               int invert_persistence);
75 
76 #endif /* TOOL_H */
77