source: trunk/design/ui/source/wui-widgets-spin_boxes.ads@ 5733

Last change on this file since 5733 was 5733, checked in by vadim.godunko, 3 years ago

Add control over invalid values.

  • Property svn:keywords set to Author Date Revision
File size: 7.1 KB
Line 
1------------------------------------------------------------------------------
2-- --
3-- Matreshka Project --
4-- --
5-- Web Framework --
6-- --
7-- Runtime Library Component --
8-- --
9------------------------------------------------------------------------------
10-- --
11-- Copyright © 2016-2017, Vadim Godunko <vgodunko@gmail.com> --
12-- All rights reserved. --
13-- --
14-- Redistribution and use in source and binary forms, with or without --
15-- modification, are permitted provided that the following conditions --
16-- are met: --
17-- --
18-- * Redistributions of source code must retain the above copyright --
19-- notice, this list of conditions and the following disclaimer. --
20-- --
21-- * Redistributions in binary form must reproduce the above copyright --
22-- notice, this list of conditions and the following disclaimer in the --
23-- documentation and/or other materials provided with the distribution. --
24-- --
25-- * Neither the name of the Vadim Godunko, IE nor the names of its --
26-- contributors may be used to endorse or promote products derived from --
27-- this software without specific prior written permission. --
28-- --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
40-- --
41------------------------------------------------------------------------------
42-- $Revision: 5733 $ $Date: 2017-01-28 11:53:14 +0000 (Sat, 28 Jan 2017) $
43------------------------------------------------------------------------------
44with WebAPI.HTML.Input_Elements;
45
46with Core.Slots_0;
47private with Core.Slots_0.Generic_Slots;
48private with Core.Slots_0.Emitters;
49
50package WUI.Widgets.Spin_Boxes is
51
52 type Abstract_Spin_Box is
53 abstract new WUI.Widgets.Abstract_Widget with private;
54
55 not overriding function Editing_Finished_Signal
56 (Self : in out Abstract_Spin_Box)
57 return not null access Core.Slots_0.Signal'Class;
58
59 not overriding procedure Set_Disabled
60 (Self : in out Abstract_Spin_Box;
61 Disabled : Boolean);
62 -- Available as slot.
63
64 not overriding procedure Set_Enabled
65 (Self : in out Abstract_Spin_Box;
66 Enabled : Boolean);
67 -- Available as slot.
68
69 not overriding procedure Step_Down
70 (Self : in out Abstract_Spin_Box) is abstract;
71 -- Available as slot.
72
73 not overriding procedure Step_Up
74 (Self : in out Abstract_Spin_Box) is abstract;
75 -- Available as slot.
76
77 -----------
78 -- Slots --
79 -----------
80
81 function Set_Disabled_Slot
82 (Self : in out Abstract_Spin_Box'Class)
83 return WUI.Boolean_Slots.Slot'Class;
84
85 function Set_Enabled_Slot
86 (Self : in out Abstract_Spin_Box'Class)
87 return WUI.Boolean_Slots.Slot'Class;
88
89 function Step_Down_Slot
90 (Self : in out Abstract_Spin_Box'Class)
91 return Core.Slots_0.Slot'Class;
92
93 function Step_Up_Slot
94 (Self : in out Abstract_Spin_Box'Class)
95 return Core.Slots_0.Slot'Class;
96
97 not overriding procedure Input_Event
98 (Self : in out Abstract_Spin_Box) is abstract;
99
100 not overriding procedure Change_Event
101 (Self : in out Abstract_Spin_Box) is abstract;
102
103 package Constructors is
104
105 procedure Initialize
106 (Self : in out Abstract_Spin_Box'Class;
107 Element :
108 not null WebAPI.HTML.Input_Elements.HTML_Input_Element_Access);
109
110 end Constructors;
111
112private
113
114 type Change_Dispatcher
115 (Owner : not null access Abstract_Spin_Box'Class) is
116 limited new WebAPI.DOM.Event_Listeners.Event_Listener with null record;
117
118 overriding procedure Handle_Event
119 (Self : not null access Change_Dispatcher;
120 Event : access WebAPI.DOM.Events.Event'Class);
121
122 type Input_Dispatcher
123 (Owner : not null access Abstract_Spin_Box'Class) is
124 limited new WebAPI.DOM.Event_Listeners.Event_Listener with null record;
125
126 overriding procedure Handle_Event
127 (Self : not null access Input_Dispatcher;
128 Event : access WebAPI.DOM.Events.Event'Class);
129
130 type Abstract_Spin_Box is
131 abstract new WUI.Widgets.Abstract_Widget with
132 record
133 Change : aliased
134 Change_Dispatcher (Abstract_Spin_Box'Unchecked_Access);
135 Input : aliased
136 Input_Dispatcher (Abstract_Spin_Box'Unchecked_Access);
137 Editing_Finished : aliased
138 Core.Slots_0.Emitters.Emitter (Abstract_Spin_Box'Unchecked_Access);
139 end record;
140
141 -----------
142 -- Slots --
143 -----------
144
145 package Set_Disabled_Slots is
146 new WUI.Boolean_Slots.Generic_Slots (Abstract_Spin_Box, Set_Disabled);
147
148 function Set_Disabled_Slot
149 (Self : in out Abstract_Spin_Box'Class)
150 return WUI.Boolean_Slots.Slot'Class
151 renames Set_Disabled_Slots.To_Slot;
152
153 package Set_Enabled_Slots is
154 new WUI.Boolean_Slots.Generic_Slots (Abstract_Spin_Box, Set_Enabled);
155
156 function Set_Enabled_Slot
157 (Self : in out Abstract_Spin_Box'Class)
158 return WUI.Boolean_Slots.Slot'Class
159 renames Set_Enabled_Slots.To_Slot;
160
161 package Step_Down_Slots is
162 new Core.Slots_0.Generic_Slots (Abstract_Spin_Box, Step_Down);
163
164 function Step_Down_Slot
165 (Self : in out Abstract_Spin_Box'Class) return Core.Slots_0.Slot'Class
166 renames Step_Down_Slots.To_Slot;
167
168 package Step_Up_Slots is
169 new Core.Slots_0.Generic_Slots (Abstract_Spin_Box, Step_Up);
170
171 function Step_Up_Slot
172 (Self : in out Abstract_Spin_Box'Class) return Core.Slots_0.Slot'Class
173 renames Step_Down_Slots.To_Slot;
174
175end WUI.Widgets.Spin_Boxes;
Note: See TracBrowser for help on using the repository browser.