~ubuntu-branches/ubuntu/quantal/glom/quantal

« back to all changes in this revision

Viewing changes to glom/utility_widgets/canvas/canvas_item_movable.h

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-01-11 17:12:01 UTC
  • mfrom: (1.1.39 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111171201-0ov9zh1fxfueshxc
Tags: 1.8.5-0ubuntu1
* New upstream release (LP: #256701), fixes LP bugs: 
  + Clear the text in property dialogs for text items (LP: #309147)
  + Don't crash when showing and then hiding the grid (LP: #303453)
  + Temporarily remember the sort order so it is the same when navigating 
    away and back (LP: #303422)
  + Use the list's sort order for the top-level records in the report 
    (LP: #303425)
  + Users/Groups: Disable drag-and-drop for the treeview, because it is
    useless and confusing (LP: #299573)
  + Import: Sort the fields list alphabetically (LP: #306593)
  + delete primary key make unusuable the database (LP: #299549)
  + Spanish translate incomplete (LP: #299556)
  + import date format error (LP: #299591)
  + can't delete data from table list view (LP: #299853)
  + Field definition: default value not saved (LP: #299896)
  + reports crashing (LP: #300054)
  + Year error with date fields (LP: #300057)
  + list view: 2 records added instead of 1 (LP: #300819)
* debian/control: Refreshed dependencies for libglom-dev.
* debian/control: Updated build-deps to match configure checks. goocavnasmm
  build-dep bumped to version without .la files.
* debian/rules: Don't delete the directory containing the templates.
* debian/control, debian/rules, debian/glom-doc.*: Split out
  arch-independent manual and examples into separate package glom-doc, which
  is now recommended by glom (glom will still work if they're not available)
* debian/copyright: Rewritten to new machine-readable format. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Glom
 
2
 *
 
3
 * Copyright (C) 2007 Murray Cumming
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License as
 
7
 * published by the Free Software Foundation; either version 2 of the
 
8
 * License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public
 
16
 * License along with this program; if not, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#ifndef GLOM_UTILITY_WIDGETS_CANVAS_ITEM_MOVABLE_H
 
22
#define GLOM_UTILITY_WIDGETS_CANVAS_ITEM_MOVABLE_H
 
23
 
 
24
#include "canvas_item_movable.h"
 
25
#include "canvas_group_grid.h"
 
26
#include <goocanvasmm/item.h>
 
27
#include <gdkmm/cursor.h>
 
28
 
 
29
namespace Glom
 
30
{
 
31
 
 
32
class CanvasItemMovable : virtual public Glib::ObjectBase
 
33
{
 
34
protected:
 
35
  CanvasItemMovable();
 
36
  virtual ~CanvasItemMovable();
 
37
 
 
38
public:
 
39
 
 
40
  /* Get the position of the item.
 
41
   * For some items, this is an arbitrary part of the item, 
 
42
   * such as the top-left of a rectangle,
 
43
   * or the first point in a line.
 
44
   */
 
45
  virtual void get_xy(double& x, double& y) const = 0;
 
46
 
 
47
  /** Move the item.
 
48
   * This should be the same arbitrary part of the item that is used by get_xy().
 
49
   * All other parts of the item will move by the same offset.
 
50
   */
 
51
  virtual void set_xy(double x, double y) = 0;
 
52
 
 
53
  /* 
 
54
   */
 
55
  virtual void get_width_height(double& width, double& height) const = 0;
 
56
 
 
57
  /** 
 
58
   */
 
59
  virtual void set_width_height(double width, double height) = 0;
 
60
 
 
61
  void set_drag_cursor(Gdk::CursorType cursor);
 
62
  void set_drag_cursor(const Gdk::Cursor& cursor);
 
63
 
 
64
  typedef sigc::signal<void> type_signal_moved;
 
65
 
 
66
  /// This signal is emitted when the canvas item is moved by the user.
 
67
  type_signal_moved signal_moved();
 
68
 
 
69
  /** void on_show_context(guint button, guint32 activate_time);
 
70
   */
 
71
  typedef sigc::signal<void, guint, guint32> type_signal_show_context;
 
72
  type_signal_show_context signal_show_context();
 
73
 
 
74
  /** Provide information about a grid or rules, 
 
75
   * to which the item should snap when moving:
 
76
   *
 
77
   * @param grid: This must exist for as long as the canvas item.
 
78
   */
 
79
  virtual void set_grid(const Glib::RefPtr<const CanvasGroupGrid>& grid);
 
80
 
 
81
  /** Restrict drag movement (via dragging) to the x axis or the y axis,
 
82
   * or prevent all drag movement.
 
83
   */
 
84
  void set_movement_allowed(bool vertical = true, bool horizontal = true);
 
85
 
 
86
  ///A convenience function, to avoid repeating a large if/else block.
 
87
  static Glib::RefPtr<CanvasItemMovable> cast_to_movable(const Glib::RefPtr<Goocanvas::Item>& item);
 
88
  static Glib::RefPtr<const CanvasItemMovable> cast_const_to_movable(const Glib::RefPtr<const Goocanvas::Item>& item);
 
89
 
 
90
  static Glib::RefPtr<Goocanvas::Item> cast_to_item(const Glib::RefPtr<CanvasItemMovable>& item);
 
91
  static Glib::RefPtr<const Goocanvas::Item> cast_const_to_item(const Glib::RefPtr<const CanvasItemMovable>& item);
 
92
 
 
93
protected:
 
94
 
 
95
  virtual Goocanvas::Canvas* get_parent_canvas_widget() = 0;
 
96
 
 
97
  virtual void snap_position(double& x, double& y) const;
 
98
 
 
99
  void set_cursor(const Gdk::Cursor& cursor);
 
100
  void unset_cursor();
 
101
  
 
102
public:
 
103
  //These should really be protected, but the compiler doesn't allow it:
 
104
  bool on_button_press_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventButton* event);
 
105
  bool on_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventMotion* event);
 
106
  bool on_button_release_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventButton* event);
 
107
  bool on_enter_notify_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventCrossing* event);
 
108
  bool on_leave_notify_event(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventCrossing* event);
 
109
 
 
110
protected:
 
111
  bool m_dragging;
 
112
  bool m_dragging_vertical_only, m_dragging_horizontal_only; //Set by using Ctrl while dragging.
 
113
  double m_drag_start_cursor_x, m_drag_start_cursor_y;
 
114
  double m_drag_start_position_x, m_drag_start_position_y;
 
115
  Gdk::Cursor m_drag_cursor;
 
116
 
 
117
  Glib::RefPtr<const CanvasGroupGrid> m_grid;
 
118
 
 
119
  bool m_allow_vertical_movement, m_allow_horizontal_movement;
 
120
 
 
121
  type_signal_moved m_signal_moved;
 
122
  type_signal_show_context m_signal_show_context;
 
123
};
 
124
 
 
125
} //namespace Glom
 
126
 
 
127
#endif //GLOM_UTILITY_WIDGETS_CANVAS_ITEM_MOVABLE_H
 
128