2021-12-08 17:52:15 +03:00
|
|
|
//
|
|
|
|
// Widget type header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
|
|
|
// Type for creating all subclasses of Fl_Widget
|
|
|
|
// This should have the widget pointer in it, but it is still in the
|
|
|
|
// Fl_Type base class.
|
|
|
|
//
|
2023-03-18 19:33:27 +03:00
|
|
|
// Copyright 1998-2023 by Bill Spitzak and others.
|
2021-12-08 17:52:15 +03:00
|
|
|
//
|
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
|
|
|
// https://www.fltk.org/COPYING.php
|
|
|
|
//
|
|
|
|
// Please see the following page on how to report bugs and issues:
|
|
|
|
//
|
|
|
|
// https://www.fltk.org/bugs.php
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _FLUID_FL_WINDOW_TYPE_H
|
|
|
|
#define _FLUID_FL_WINDOW_TYPE_H
|
|
|
|
|
2023-07-19 18:44:44 +03:00
|
|
|
#include "Fl_Group_Type.h"
|
2021-12-08 17:52:15 +03:00
|
|
|
|
|
|
|
class Fl_Widget_Class_Type;
|
|
|
|
|
|
|
|
extern Fl_Menu_Item window_type_menu[];
|
|
|
|
extern Fl_Widget_Class_Type *current_widget_class;
|
2023-07-19 18:44:44 +03:00
|
|
|
|
2021-12-08 17:52:15 +03:00
|
|
|
void toggle_overlays(Fl_Widget *,void *);
|
2023-03-18 19:33:27 +03:00
|
|
|
void toggle_guides(Fl_Widget *,void *);
|
2023-07-12 00:13:46 +03:00
|
|
|
void toggle_restricted(Fl_Widget *,void *);
|
2021-12-08 17:52:15 +03:00
|
|
|
void show_project_cb(Fl_Widget *, void *);
|
|
|
|
void show_grid_cb(Fl_Widget *, void *);
|
|
|
|
void show_settings_cb(Fl_Widget *, void *);
|
|
|
|
|
2023-03-18 19:33:27 +03:00
|
|
|
enum {
|
|
|
|
FD_LEFT = 1, // user drags the left side of the selection box
|
|
|
|
FD_RIGHT = 2,
|
|
|
|
FD_BOTTOM = 4,
|
|
|
|
FD_TOP = 8,
|
|
|
|
FD_DRAG = 16, // user drags the entire selection
|
|
|
|
FD_BOX = 32 // user creates a new selection box
|
|
|
|
};
|
|
|
|
|
2023-07-19 18:44:44 +03:00
|
|
|
class Fl_Window_Type : public Fl_Group_Type
|
|
|
|
{
|
|
|
|
typedef Fl_Group_Type super;
|
2021-12-08 17:52:15 +03:00
|
|
|
protected:
|
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Menu_Item* subtypes() FL_OVERRIDE {return window_type_menu;}
|
2021-12-08 17:52:15 +03:00
|
|
|
|
|
|
|
friend class Overlay_Window;
|
|
|
|
int mx,my; // mouse position during dragging
|
|
|
|
int x1,y1; // initial position of selection box
|
|
|
|
int bx,by,br,bt; // bounding box of selection before snapping
|
|
|
|
int sx,sy,sr,st; // bounding box of selection after snapping to guides
|
|
|
|
int dx,dy;
|
|
|
|
int drag; // which parts of bbox are being moved
|
|
|
|
int numselected; // number of children selected
|
2023-07-12 00:13:46 +03:00
|
|
|
void draw_out_of_bounds(Fl_Widget_Type *group, int x, int y, int w, int h);
|
|
|
|
void draw_out_of_bounds();
|
|
|
|
void draw_overlaps();
|
2021-12-08 17:52:15 +03:00
|
|
|
void draw_overlay();
|
|
|
|
void newdx();
|
|
|
|
void newposition(Fl_Widget_Type *,int &x,int &y,int &w,int &h);
|
|
|
|
int handle(int);
|
2022-12-30 21:14:36 +03:00
|
|
|
void setlabel(const char *) FL_OVERRIDE;
|
2023-01-26 17:23:43 +03:00
|
|
|
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
|
|
|
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Widget_Type *_make() FL_OVERRIDE {return 0;} // we don't call this
|
|
|
|
Fl_Widget *widget(int,int,int,int) FL_OVERRIDE {return 0;}
|
2021-12-08 17:52:15 +03:00
|
|
|
int recalc; // set by fix_overlay()
|
2023-11-02 01:34:47 +03:00
|
|
|
void moveallchildren(int key=0);
|
2023-07-17 21:40:55 +03:00
|
|
|
ID id() const FL_OVERRIDE { return ID_Window; }
|
2023-07-19 21:41:58 +03:00
|
|
|
bool is_a(ID inID) const FL_OVERRIDE { return (inID==ID_Window) ? true : super::is_a(inID); }
|
2023-07-11 15:27:02 +03:00
|
|
|
void open_();
|
2021-12-08 17:52:15 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2022-11-24 13:39:20 +03:00
|
|
|
Fl_Window_Type() :
|
|
|
|
mx(0), my(0),
|
|
|
|
x1(0), y1(0),
|
|
|
|
bx(0), by(0), br(0), bt(0),
|
|
|
|
sx(0), sy(0), sr(0), st(0),
|
|
|
|
dx(0), dy(0),
|
|
|
|
drag(0),
|
|
|
|
numselected(0),
|
|
|
|
recalc(0),
|
|
|
|
modal(0), non_modal(0),
|
2023-07-17 19:31:58 +03:00
|
|
|
xclass(NULL),
|
2022-11-24 13:39:20 +03:00
|
|
|
sr_min_w(0), sr_min_h(0), sr_max_w(0), sr_max_h(0)
|
|
|
|
{ }
|
2021-12-08 17:52:15 +03:00
|
|
|
uchar modal, non_modal;
|
2023-07-17 19:31:58 +03:00
|
|
|
const char *xclass; // junk string, used for shortcut
|
2021-12-08 17:52:15 +03:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
|
|
|
const char *type_name() FL_OVERRIDE {return "Fl_Window";}
|
|
|
|
const char *alt_type_name() FL_OVERRIDE {return "fltk::Window";}
|
2021-12-08 17:52:15 +03:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
void open() FL_OVERRIDE;
|
2023-07-17 21:20:54 +03:00
|
|
|
void ideal_size(int &w, int &h) FL_OVERRIDE;
|
2021-12-08 17:52:15 +03:00
|
|
|
|
|
|
|
void fix_overlay(); // Update the bounding box, etc
|
|
|
|
uchar *read_image(int &ww, int &hh); // Read an image of the window
|
|
|
|
|
2023-01-26 17:23:43 +03:00
|
|
|
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
|
|
|
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
2022-12-30 21:14:36 +03:00
|
|
|
int read_fdesign(const char*, const char*) FL_OVERRIDE;
|
2021-12-08 17:52:15 +03:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
|
|
|
void move_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
|
|
|
void remove_child(Fl_Type*) FL_OVERRIDE;
|
2021-12-08 17:52:15 +03:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
int is_parent() const FL_OVERRIDE {return 1;}
|
2021-12-08 17:52:15 +03:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Widget *enter_live_mode(int top=0) FL_OVERRIDE;
|
|
|
|
void leave_live_mode() FL_OVERRIDE;
|
|
|
|
void copy_properties() FL_OVERRIDE;
|
2021-12-08 17:52:15 +03:00
|
|
|
|
|
|
|
int sr_min_w, sr_min_h, sr_max_w, sr_max_h;
|
|
|
|
|
|
|
|
static int popupx, popupy;
|
|
|
|
};
|
|
|
|
|
2023-07-19 18:44:44 +03:00
|
|
|
class Fl_Widget_Class_Type : private Fl_Window_Type
|
|
|
|
{
|
|
|
|
typedef Fl_Window_Type super;
|
2021-12-13 00:55:20 +03:00
|
|
|
protected:
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Menu_Item* subtypes() FL_OVERRIDE {return 0;}
|
2021-12-13 00:55:20 +03:00
|
|
|
|
2021-12-08 17:52:15 +03:00
|
|
|
public:
|
|
|
|
Fl_Widget_Class_Type() {
|
|
|
|
write_public_state = 0;
|
|
|
|
wc_relative = 0;
|
|
|
|
}
|
|
|
|
// state variables for output:
|
|
|
|
char write_public_state; // true when public: has been printed
|
2022-11-06 16:40:18 +03:00
|
|
|
char wc_relative; // if 1, reposition all children, if 2, reposition and resize
|
2021-12-08 17:52:15 +03:00
|
|
|
|
2023-01-26 17:23:43 +03:00
|
|
|
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
|
|
|
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
2022-12-30 21:14:36 +03:00
|
|
|
|
2023-01-26 17:23:43 +03:00
|
|
|
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
|
|
|
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
|
|
|
const char *type_name() FL_OVERRIDE {return "widget_class";}
|
2023-07-17 21:40:55 +03:00
|
|
|
ID id() const FL_OVERRIDE { return ID_Widget_Class; }
|
2023-07-19 21:41:58 +03:00
|
|
|
bool is_a(ID inID) const FL_OVERRIDE { return (inID==ID_Widget_Class) ? true : super::is_a(inID); }
|
2022-12-30 21:14:36 +03:00
|
|
|
int is_parent() const FL_OVERRIDE {return 1;}
|
|
|
|
int is_code_block() const FL_OVERRIDE {return 1;}
|
|
|
|
int is_decl_block() const FL_OVERRIDE {return 1;}
|
|
|
|
int is_class() const FL_OVERRIDE {return 1;}
|
2021-12-08 17:52:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _FLUID_FL_WINDOW_TYPE_H
|