summaryrefslogtreecommitdiff
path: root/fluid/nodes/Button_Node.h
blob: 53944d6ea203d881b2b06acacce9179f79da44b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//
// Button Node header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2025 by Bill Spitzak and others.
//
// 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_NODES_BUTTON_NODE_H
#define FLUID_NODES_BUTTON_NODE_H

#include "nodes/Widget_Node.h"

/**
 \brief A handler for the simple push button and a base class for all other buttons.
 */
class Button_Node : public Widget_Node
{
public:
  typedef Widget_Node super;
  static Button_Node prototype;
private:
  Fl_Menu_Item *subtypes() override;
public:
  void ideal_size(int &w, int &h) override;
  const char *type_name() override { return "Fl_Button"; }
  const char *alt_type_name() override { return "fltk::Button"; }
  Fl_Widget *widget(int x, int y, int w, int h) override;
  Widget_Node *_make() override { return new Button_Node(); }
  int is_button() const override { return 1; }
  Type type() const override { return FLD_NODE_TYPE_Button; }
  bool is_a(Type inType) const override { return (inType==FLD_NODE_TYPE_Button) ? true : super::is_a(inType); }
  void write_properties(fld::io::Project_Writer &f) override;
  void read_property(fld::io::Project_Reader &f, const char *) override;
  void copy_properties() override;
};

// ---- Return Button ----

/**
 \brief The Return Button is simply a Button with the return key as a hotkey.
 */
class Return_Button_Node : public Button_Node
{
public:
  typedef Button_Node super;
  static Return_Button_Node prototype;
public:
  void ideal_size(int &w, int &h) override;
  const char *type_name() override { return "Fl_Return_Button"; }
  const char *alt_type_name() override { return "fltk::ReturnButton"; }
  Fl_Widget *widget(int x, int y, int w, int h) override;
  Widget_Node *_make() override { return new Return_Button_Node(); }
  Type type() const override { return FLD_NODE_TYPE_Return_Button; }
  bool is_a(Type inType) const override { return (inType==FLD_NODE_TYPE_Return_Button) ? true : super::is_a(inType); }
};

// ---- Repeat Button ----

/**
 \brief Handler for Fl_Repeat_Button.
 \note Even though Fl_Repeat_Button is somewhat limited compared to Fl_Button,
 and some settings may not make much sense, it is still derived from it,
 so the wrapper should be as well.
 */
class Repeat_Button_Node : public Button_Node
{
public:
  typedef Button_Node super;
  static Repeat_Button_Node prototype;
public:
  const char *type_name() override { return "Fl_Repeat_Button"; }
  const char *alt_type_name() override { return "fltk::RepeatButton"; }
  Fl_Widget *widget(int x, int y, int w, int h) override;
  Widget_Node *_make() override { return new Repeat_Button_Node(); }
  Type type() const override { return FLD_NODE_TYPE_Repeat_Button; }
  bool is_a(Type inType) const override { return (inType==FLD_NODE_TYPE_Repeat_Button) ? true : super::is_a(inType); }
};

// ---- Light Button ----

/**
 \brief A handler for a toggle button with an indicator light.
 */
class Light_Button_Node : public Button_Node
{
public:
  typedef Button_Node super;
  static Light_Button_Node prototype;
public:
  void ideal_size(int &w, int &h) override;
  const char *type_name() override { return "Fl_Light_Button"; }
  const char *alt_type_name() override { return "fltk::LightButton"; }
  Fl_Widget *widget(int x, int y, int w, int h) override;
  Widget_Node *_make() override { return new Light_Button_Node(); }
  Type type() const override { return FLD_NODE_TYPE_Light_Button; }
  bool is_a(Type inType) const override { return (inType==FLD_NODE_TYPE_Light_Button) ? true : super::is_a(inType); }
};

// ---- Check Button ----

/**
 \brief Manage buttons with a check mark on its left.
 */
class Check_Button_Node : public Button_Node
{
public:
  typedef Button_Node super;
  static Check_Button_Node prototype;
public:
  void ideal_size(int &w, int &h) override;
  const char *type_name() override { return "Fl_Check_Button"; }
  const char *alt_type_name() override { return "fltk::CheckButton"; }
  Fl_Widget *widget(int x, int y, int w, int h) override;
  Widget_Node *_make() override { return new Check_Button_Node(); }
  Type type() const override { return FLD_NODE_TYPE_Check_Button; }
  bool is_a(Type inType) const override { return (inType==FLD_NODE_TYPE_Check_Button) ? true : super::is_a(inType); }
};

// ---- Round Button ----

/**
 \brief Manage buttons with a round indicator on its left.
 */
class Round_Button_Node : public Button_Node
{
public:
  typedef Button_Node super;
  static Round_Button_Node prototype;
public:
  void ideal_size(int &w, int &h) override;
  const char *type_name() override { return "Fl_Round_Button"; }
  const char *alt_type_name() override { return "fltk::RadioButton"; }
  Fl_Widget *widget(int x, int y, int w, int h) override;
  Widget_Node *_make() override { return new Round_Button_Node(); }
  Type type() const override { return FLD_NODE_TYPE_Round_Button; }
  bool is_a(Type inType) const override { return (inType==FLD_NODE_TYPE_Round_Button) ? true : super::is_a(inType); }
};


#endif // FLUID_NODES_BUTTON_NODE_H