2007-05-22 18:53:17 +04:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2013-05-30 17:07:49 +04:00
|
|
|
* Copyright (C) 2006-2013 Sanel Zukan
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* of the License, 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-05-22 18:53:17 +04:00
|
|
|
*/
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
#ifndef __DESKTOP_ICON_H__
|
|
|
|
#define __DESKTOP_ICON_H__
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2008-09-15 15:00:23 +04:00
|
|
|
#include <FL/Fl_Widget.H>
|
|
|
|
#include <FL/Fl_Image.H>
|
2009-07-09 17:44:16 +04:00
|
|
|
#include <edelib/MenuButton.h>
|
2013-05-30 17:07:49 +04:00
|
|
|
#include <edelib/String.h>
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
DESKTOP_ICON_TYPE_NORMAL,
|
|
|
|
DESKTOP_ICON_TYPE_TRASH,
|
|
|
|
DESKTOP_ICON_TYPE_LINK,
|
|
|
|
DESKTOP_ICON_TYPE_FILE,
|
|
|
|
DESKTOP_ICON_TYPE_FOLDER
|
|
|
|
};
|
|
|
|
|
|
|
|
/* default icon sizes */
|
|
|
|
#define DESKTOP_ICON_SIZE_W 48
|
|
|
|
#define DESKTOP_ICON_SIZE_H 48
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each DesktopIcon shares IconOptions, which is content of [Icons] section
|
|
|
|
* from configuration file. With this, 'Desktop' needs only to update content so all
|
|
|
|
* icons see it.
|
|
|
|
*/
|
|
|
|
struct IconOptions {
|
|
|
|
int label_background;
|
|
|
|
int label_foreground;
|
|
|
|
int label_font;
|
|
|
|
int label_fontsize;
|
|
|
|
int label_maxwidth;
|
|
|
|
int label_transparent;
|
|
|
|
int label_visible;
|
|
|
|
bool one_click_exec;
|
|
|
|
};
|
2008-08-07 18:22:05 +04:00
|
|
|
|
2007-05-22 18:53:17 +04:00
|
|
|
class MovableIcon;
|
|
|
|
|
2007-06-20 14:58:07 +04:00
|
|
|
class DesktopIcon : public Fl_Widget {
|
2009-02-26 14:15:27 +03:00
|
|
|
private:
|
2013-05-30 17:07:49 +04:00
|
|
|
int icon_type;
|
|
|
|
int lwidth, lheight;
|
|
|
|
bool focused;
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
Fl_Image *darker_img;
|
|
|
|
IconOptions *opts;
|
|
|
|
MovableIcon *micon;
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
/* location of .desktop file and command to be executed */
|
|
|
|
EDELIB_NS_PREPEND(String) path, cmd;
|
|
|
|
EDELIB_NS_PREPEND(MenuButton) *imenu;
|
|
|
|
|
|
|
|
public:
|
|
|
|
DesktopIcon(const char *l, int W = DESKTOP_ICON_SIZE_W, int H = DESKTOP_ICON_SIZE_H);
|
|
|
|
~DesktopIcon();
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void set_icon_type(int c) { icon_type = c; }
|
|
|
|
int get_icon_type(void) { return icon_type;}
|
|
|
|
void set_image(const char *name);
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2011-11-09 18:08:11 +04:00
|
|
|
void update_label_font_and_size(void);
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void set_options(IconOptions *o) {
|
|
|
|
opts = o;
|
|
|
|
update_label_font_and_size();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Here is implemented localy focus schema avoiding messy fltk one. Focus/unfocus is handled from Desktop. */
|
|
|
|
void do_focus(void) { focused = true; }
|
|
|
|
void do_unfocus(void) { focused = false; }
|
|
|
|
bool is_focused(void) { return focused; }
|
|
|
|
|
|
|
|
void set_path(const char *p) { path = p; }
|
|
|
|
const char *get_path(void) { return path.c_str(); }
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void set_cmd(const char *c) { cmd = c; }
|
|
|
|
const char *get_cmd(void) { return cmd.c_str(); }
|
2009-02-26 14:15:27 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void fix_position(int X, int Y);
|
2009-02-26 14:15:27 +03:00
|
|
|
void drag(int x, int y, bool apply);
|
|
|
|
int drag_icon_x(void);
|
|
|
|
int drag_icon_y(void);
|
|
|
|
|
|
|
|
/*
|
2013-05-30 17:07:49 +04:00
|
|
|
* This is 'enhanced' (in some sense) redraw(). Redrawing icon will not fully redraw label nor
|
|
|
|
* focus box, which laid outside icon box. It will use damage() on given region, but called from
|
|
|
|
* parent, so parent can redraw that region on itself (since label does not laid on any box)
|
2009-02-26 14:15:27 +03:00
|
|
|
*
|
2013-05-30 17:07:49 +04:00
|
|
|
* Alternative way would be to redraw the whole parent, but it is pretty unneeded and slow.
|
2009-02-26 14:15:27 +03:00
|
|
|
*/
|
|
|
|
void fast_redraw(void);
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void draw(void);
|
|
|
|
int handle(int event);
|
2007-05-22 18:53:17 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|