2009-08-17 12:41:51 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gdrag.h
|
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2009-08-17 12:41:51 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (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, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2009-08-17 12:41:51 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
2011-12-31 03:39:20 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#ifndef __GDRAG_H
|
|
|
|
#define __GDRAG_H
|
|
|
|
|
2021-10-22 21:18:45 +02:00
|
|
|
#include "gb.form.const.h"
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
class gPicture;
|
|
|
|
class gControl;
|
|
|
|
|
|
|
|
class gDrag
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Nothing = 0,
|
|
|
|
Text = 1,
|
|
|
|
Image = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exit();
|
|
|
|
|
|
|
|
static bool isActive() { return _active; }
|
|
|
|
static bool isEnabled() { return _enabled; }
|
|
|
|
|
|
|
|
static void setIcon(gPicture *vl);
|
|
|
|
static gPicture *getIcon() { return _icon; }
|
|
|
|
static void getIconPos(int *x, int *y) { *x = _icon_x; *y = _icon_y; }
|
|
|
|
static void setIconPos(int x, int y) { _icon_x = x; _icon_y = y; }
|
|
|
|
|
2012-06-12 03:50:46 +02:00
|
|
|
static gControl *dragText(gControl *source, char *text, char *format = 0);
|
|
|
|
static gControl *dragImage(gControl *source, gPicture *image);
|
2014-10-18 20:09:07 +02:00
|
|
|
static void end();
|
2007-12-30 17:41:49 +01:00
|
|
|
static void cancel();
|
|
|
|
|
|
|
|
static gControl *getSource() { return _source; }
|
2009-01-13 01:42:55 +01:00
|
|
|
static gControl *getDestination() { return _destination; }
|
2020-01-24 08:12:01 +01:00
|
|
|
static void setDestination(gControl *dest) { _destination = dest; }
|
2007-12-30 17:41:49 +01:00
|
|
|
static int getAction() { return _action; }
|
|
|
|
|
|
|
|
static int getType();
|
|
|
|
static char *getFormat(int n = 0);
|
2012-07-15 00:44:43 +02:00
|
|
|
static char *getText(int *len, const char *format, bool fromOutside = false);
|
|
|
|
static gPicture *getImage(bool fromOutside = false);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
static int getDropX() { return _x; }
|
|
|
|
static int getDropY() { return _y; }
|
|
|
|
|
2019-06-01 04:52:25 +02:00
|
|
|
static void setDropX(int v) { _x = v; }
|
|
|
|
static void setDropY(int v) { _y = v; }
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static void show(gControl *control, int x = 0, int y = 0, int w = -1, int h = -1);
|
|
|
|
static void hide(gControl *control = NULL);
|
|
|
|
|
|
|
|
static bool checkThreshold(gControl *control, int x, int y, int sx, int sy);
|
|
|
|
|
|
|
|
// "Private"
|
|
|
|
static void setDropInfo(int type, char *format);
|
2009-01-13 01:42:55 +01:00
|
|
|
static void setDropData(int action, int x, int y, gControl *source, gControl *dest);
|
2007-12-30 17:41:49 +01:00
|
|
|
static void setDropText(char *text, int len = -1);
|
|
|
|
static void setDropImage(gPicture *image);
|
|
|
|
static void setDropImage(char *buf, int len);
|
|
|
|
|
|
|
|
static GdkDragContext *enable(GdkDragContext *context, gControl *control, guint32 time);
|
|
|
|
static GdkDragContext *disable(GdkDragContext *context);
|
|
|
|
static bool getData(const char *prefix);
|
|
|
|
|
2021-03-09 01:38:04 +01:00
|
|
|
static bool setCurrent(gControl *control);
|
|
|
|
static bool isCurrent(gControl *control) { return control == _current; }
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static volatile bool _got_data;
|
|
|
|
|
2020-01-24 08:12:01 +01:00
|
|
|
static gControl *_source;
|
|
|
|
static gControl *_destination;
|
|
|
|
static gControl *_dest;
|
2021-03-09 01:38:04 +01:00
|
|
|
static gControl *_current;
|
2020-01-24 08:12:01 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
private:
|
2012-06-12 03:50:46 +02:00
|
|
|
|
|
|
|
static gControl *drag(gControl *source, GtkTargetList *list);
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static bool _active;
|
|
|
|
static gPicture *_icon;
|
|
|
|
static int _icon_x;
|
|
|
|
static int _icon_y;
|
|
|
|
static int _action;
|
|
|
|
static int _type;
|
|
|
|
static gPicture *_picture;
|
|
|
|
static char *_text;
|
2011-12-20 16:47:14 +01:00
|
|
|
static int _text_len;
|
2007-12-30 17:41:49 +01:00
|
|
|
static char *_format;
|
|
|
|
static int _enabled;
|
|
|
|
static int _x;
|
|
|
|
static int _y;
|
|
|
|
static GdkDragContext *_context;
|
|
|
|
static guint32 _time;
|
|
|
|
static bool _local;
|
2014-10-18 20:09:07 +02:00
|
|
|
static volatile bool _end;
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|