gimp/app/tools/gimptexttool.h

130 lines
4.2 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
2010-02-18 04:39:33 +08:00
* GimpTextTool
* Copyright (C) 2002-2010 Sven Neumann <sven@gimp.org>
* Daniel Eddeland <danedde@svn.gnome.org>
* Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-25 06:05:25 +08:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1997-11-25 06:05:25 +08:00
*/
#ifndef __GIMP_TEXT_TOOL_H__
#define __GIMP_TEXT_TOOL_H__
Made GimpToolOptions a GimpContext subclass and objectified all tool 2003-02-05 Michael Natterer <mitch@gimp.org> Made GimpToolOptions a GimpContext subclass and objectified all tool options types. * app/core/core-types.h: replaced GimpToolOptionsNewFunc by GimpToolOptionsGUIFunc. * libgimpproxy/gimpproxytypes.h: regenerated. * app/core/gimppaintinfo.[ch]: added "GType paint_options_type". * app/core/gimptoolinfo.[ch]: added "GType tool_options_type", removed tool_info->context since GimpToolOptions are a GimpContext now. Added "gboolean use_context" as a temp_hack. * libgimptool/gimptooltypes.h: added the tool_options_type to the tool registering callback. * app/tools/tool_options.[ch]: is a real GimpContext subclass now. * app/paint/paint-types.h * app/paint/paint.c: added the paint_options_type to the paint registering stuff. * app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions subclass now. * app/paint/Makefile.am * app/paint/gimpairbrushoptions.[ch] * app/paint/gimpcloneoptions.[ch] * app/paint/gimpconvolveoptions.[ch] * app/paint/gimpdodgeburnoptions.[ch] * app/paint/gimperaseroptions.[ch] * app/paint/gimpsmudgeoptions.[ch]: new files holding GimpPaintOptions subclasses. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: removed paint options stuff, lots of related changed & cleanups. * tools/pdbgen/pdb/paint_tools.pdb: changed accordingly. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/Makefile.am * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpcropoptions.[ch] * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimptextoptions.[ch] * app/tools/gimpvectoroptions.[ch]: new files holding the various tool options classes. * app/tools/selection_options.[ch] * app/tools/transform_options.[ch]: made them objects. * app/tools/paint_options.[ch]: contains only the paint_options GUI and reset stuff. * app/tools/tools-types.h: removed SelectionOptions typedef for now. * app/tools/[all tools]: removed the tool options stuff except some GUI constructors. Tons of related changes. * app/tools/tool_manager.[ch]: changed tool registration / restore / switching accordingly. * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 22:39:40 +08:00
#include "gimpdrawtool.h"
1997-11-25 06:05:25 +08:00
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#define GIMP_TYPE_TEXT_TOOL (gimp_text_tool_get_type ())
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) 2001-07-24 Michael Natterer <mitch@gimp.org> Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) * configure.in: require glib/gtk+ >= 1.3.7, commented out the gtkxmhtml stuff. From now on, you will need glib, pango, atk and gtk+ HEAD from CVS to hack or use GIMP HEAD. Beware, it crashes randomly :) * app/core/Makefile.am * app/core/gimpmarshal.list: new file plus rules to generate gimpmarshal.[ch] from it. * app/core/* * app/tools/* * app/widgets/* * libgimpwidgets/*: started to use the glib object system. All core/ objects are still gtk objects however. All signals are created using g_signal_new(). There are many gtk+ artefacts left. Finally, we will _not_ use the gtk_signal_foo() wrappers and friends any more. * app/colormaps.c * app/devices.[ch] * app/disp_callbacks.c * app/errorconsole.c * app/file-save.[ch] * app/interface.c * app/module_db.c * app/nav_window.c * app/ops_buttons.c * app/scroll.c * app/user_install.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/brushes-commands.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.[ch] * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimp/gimpui.c * libgimpbase/gimpenv.c: tons and tons of changes like "const gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete and currently disables), lots of s/gtk_signal/g_signal/, removal/replacement of deprecated stuff, s/GtkSignalFunc/GCallback/ and lots of small changes and fixes while I was on it, zillions of warnings left... * modules/Makefile.am: disabled the water color selector temporarily (XInput issues). * plug-ins/Makefile.am * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl: simply excluded all plug-ins which did not build (including Script-Fu). They are trivial to fix.
2001-07-25 05:27:11 +08:00
#define GIMP_TEXT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TEXT_TOOL, GimpTextTool))
#define GIMP_IS_TEXT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TEXT_TOOL))
#define GIMP_TEXT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TEXT_TOOL, GimpTextToolClass))
#define GIMP_IS_TEXT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TEXT_TOOL))
#define GIMP_TEXT_TOOL_GET_OPTIONS(t) (GIMP_TEXT_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpTextTool GimpTextTool;
typedef struct _GimpTextToolClass GimpTextToolClass;
struct _GimpTextTool
{
GimpDrawTool parent_instance;
GimpText *proxy;
GList *pending;
guint idle_id;
gboolean moving;
GimpTextBuffer *buffer;
GimpText *text;
GimpTextLayer *layer;
GimpImage *image;
GtkWidget *confirm_dialog;
GimpUIManager *ui_manager;
gboolean handle_rectangle_change_complete;
gboolean text_box_fixed;
GimpTextLayout *layout;
app: fix text tool drawing for good this time (hopefully) Earlier I claimed that drawing would work now because we make sure that buffer and layout are always in sync. This was nonsense. In fact, we constantly ran into the sutiation where the buffer was modified, and we were drawing with the previous layout. It's unclear why this didn't cause drawing artifacts, but it did cause e.g. the cursor temporarily jumping to the next position while editing in the middle of text (especially visible at line ends). Several underlying problems existed: first, we now modify the buffer from outside the text tool (from GimpTextStyleEditor) where we can't pause the tool; second, proxy changes are handled asymetrically (property changes are queued and processed all together in an idle function) so we can't pause/resume drawing across the entire operation because it has many beginnings and only one end. Therefore: - add gimp_text_tool_block_drawing()/unblock_drawing(), where block() can be called as many times as needed, and a single unblock() enables drawing again. block() also clears the layout, because it served its purpose (it was just used to pause drawing, and we know the buffer will change, so kill it). - connect to GtkTextBuffer::begin-user-action and call block() from the callback, so we undraw stuff and kill the cached layout before any buffer change happens. - call unblock() at the end of gimp_text_tool_apply() because then the text and the buffer are in sync again, the tool is undrawn and we can safely create the layout again to draw our stuff. - also call block()/unblock() from some other places, like when a new text layer is created. - get rid of *all* calls to draw_tool_pause()/resume() around buffer modifications, they are not needed any longer. - add calls to begin/end_user_action() where they were missing.
2010-03-05 06:47:23 +08:00
gboolean drawing_blocked;
GimpToolWidget *widget;
GimpToolWidget *grab_widget;
/* text editor state: */
GtkWidget *style_overlay;
GtkWidget *style_editor;
gboolean selecting;
GtkTextIter select_start_iter;
gboolean select_words;
gboolean select_lines;
GtkIMContext *im_context;
gboolean needs_im_reset;
gboolean preedit_active;
gchar *preedit_string;
gint preedit_cursor;
GtkTextMark *preedit_start;
GtkTextMark *preedit_end;
gboolean overwrite_mode;
gint x_pos;
GtkWidget *offscreen_window;
GtkWidget *proxy_text_view;
GtkWidget *editor_dialog;
};
struct _GimpTextToolClass
{
GimpDrawToolClass parent_class;
};
void gimp_text_tool_register (GimpToolRegisterCallback callback,
gpointer data);
GType gimp_text_tool_get_type (void) G_GNUC_CONST;
gboolean gimp_text_tool_set_layer (GimpTextTool *text_tool,
GimpLayer *layer);
gboolean gimp_text_tool_get_has_text_selection (GimpTextTool *text_tool);
void gimp_text_tool_delete_selection (GimpTextTool *text_tool);
void gimp_text_tool_cut_clipboard (GimpTextTool *text_tool);
void gimp_text_tool_copy_clipboard (GimpTextTool *text_tool);
void gimp_text_tool_paste_clipboard (GimpTextTool *text_tool);
void gimp_text_tool_create_vectors (GimpTextTool *text_tool);
void gimp_text_tool_create_vectors_warped (GimpTextTool *text_tool);
/* only for the text editor */
void gimp_text_tool_clear_layout (GimpTextTool *text_tool);
gboolean gimp_text_tool_ensure_layout (GimpTextTool *text_tool);
gboolean gimp_text_tool_apply (GimpTextTool *text_tool,
gboolean push_undo);
#endif /* __GIMP_TEXT_TOOL_H__ */