init
This commit is contained in:
71
jj_vision/unfinished/check_box_control.e
Normal file
71
jj_vision/unfinished/check_box_control.e
Normal file
@@ -0,0 +1,71 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
CHECK_BOX_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
CONTROL
|
||||
redefine
|
||||
value,
|
||||
field,
|
||||
default_field,
|
||||
refresh
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_from_field
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Set up the control
|
||||
do
|
||||
Precursor {CONTROL}
|
||||
prune (display)
|
||||
create check_box
|
||||
extend (check_box)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
field: CHECK_BOX_FIELD
|
||||
|
||||
value: BOOLEAN
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
refresh
|
||||
--
|
||||
do
|
||||
if is_valid (data) then
|
||||
b ?= data
|
||||
check
|
||||
go_assignment: d /= Void -- would not be valid otherwise
|
||||
end
|
||||
if b then
|
||||
enable_select
|
||||
else
|
||||
disable_select
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
check_box: EV_CHECK_BUTTON
|
||||
|
||||
default_field: CHECK_BOX_FIELD
|
||||
-- Create a field to be used if Current was `default_create'd.
|
||||
-- Assume it is a STRING.
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
|
||||
end -- class CHECK_BOX_CONTROL
|
45
jj_vision/unfinished/check_box_field.e
Normal file
45
jj_vision/unfinished/check_box_field.e
Normal file
@@ -0,0 +1,45 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
|
||||
CHECK_BOX_FIELD
|
||||
|
||||
inherit
|
||||
|
||||
FIELD
|
||||
redefine
|
||||
Type,
|
||||
is_valid
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Access
|
||||
|
||||
Type: BOOLEAN_REF
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
as_type (a_string: STRING): BOOLEAN
|
||||
-- Convert `a_string' to an object of `Type'.
|
||||
do
|
||||
Result := a_string.same_string (("True").to_upper)
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: CHECK_BOX_CONTROL
|
||||
-- Create a control from this field
|
||||
do
|
||||
create Result.make_from_field (Current)
|
||||
end
|
||||
|
||||
end -- class CHECK_BOX_FIELD
|
56
jj_vision/unfinished/jj_leaf_node_item.e
Normal file
56
jj_vision/unfinished/jj_leaf_node_item.e
Normal file
@@ -0,0 +1,56 @@
|
||||
note
|
||||
description: "[
|
||||
A JJ_NODE_ITEM which can hold only a VIEWABLE_LEAF_NODE and placeable
|
||||
into a JJ_TREE_VIEW.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
JJ_LEAF_NODE_ITEM
|
||||
|
||||
inherit
|
||||
|
||||
JJ_NODE_ITEM
|
||||
redefine
|
||||
set_actions,
|
||||
target,
|
||||
on_drop_node
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widget, but...
|
||||
-- remove the actions which will accept a drop of a node, because
|
||||
-- we cannot add a child node to the `target'.
|
||||
-- This does not prevent adding other drop actions, even a drop of
|
||||
-- a node as long as it doesn't add a child node to `target'.
|
||||
do
|
||||
Precursor {JJ_NODE_ITEM}
|
||||
-- clear the drop actions. This is safe at this time because
|
||||
-- JJ_NODE_ITEM only adds one drop action which is the one that
|
||||
-- must be removed anyway.
|
||||
drop_actions.wipe_out
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
target: NODE
|
||||
-- The node which is displayed by Current.
|
||||
|
||||
feature -- Testing for now
|
||||
|
||||
on_drop_node (a_node: NODE)
|
||||
-- Can this be done?
|
||||
do
|
||||
check
|
||||
do_not_call: False
|
||||
end
|
||||
end
|
||||
|
||||
end
|
321
jj_vision/unfinished/jj_node_item.e
Normal file
321
jj_vision/unfinished/jj_node_item.e
Normal file
@@ -0,0 +1,321 @@
|
||||
note
|
||||
description: "[
|
||||
Objects placeable into an EV_TREE, more specifically into a
|
||||
JJ_TREE_VIEW (a VIEW that holds VIEWABLE_NODEs). This is the
|
||||
screen representatin of a VIEWABLE_NODE.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "21 Apr 06"
|
||||
|
||||
class
|
||||
JJ_NODE_ITEM
|
||||
|
||||
inherit
|
||||
|
||||
-- EV_STOCK_COLORS
|
||||
-- rename
|
||||
-- implementation as colors_implementation
|
||||
-- export
|
||||
-- {NONE} all
|
||||
-- undefine
|
||||
-- default_create,
|
||||
-- copy,
|
||||
-- is_equal
|
||||
-- end
|
||||
|
||||
EV_TREE_ITEM
|
||||
redefine
|
||||
initialize,
|
||||
item,
|
||||
parent_tree, -- to get correct type
|
||||
wipe_out,
|
||||
destroy,
|
||||
is_destroyed
|
||||
end
|
||||
|
||||
VIEW
|
||||
rename
|
||||
parent as parent_from_view_not_to_be_used
|
||||
undefine
|
||||
-- default_create,
|
||||
is_equal,
|
||||
copy
|
||||
redefine
|
||||
initialize,
|
||||
target,
|
||||
set_target,
|
||||
draw,
|
||||
parent_tool,
|
||||
destroy,
|
||||
is_destroyed
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Create an instance.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TREE_ITEM}
|
||||
-- enable_pebble_positioning
|
||||
-- set_pebble_position (0, 0)
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widget
|
||||
do
|
||||
pick_actions.force_extend (agent enable_select)
|
||||
drop_actions.extend (agent on_drop_node)
|
||||
pointer_double_press_actions.force_extend (agent on_double_click)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
target: NODE
|
||||
-- The node which is displayed by Current.
|
||||
|
||||
level: INTEGER
|
||||
-- The indention level this node should occupy in the tree.
|
||||
|
||||
item: JJ_NODE_ITEM
|
||||
-- Current item.
|
||||
-- Redefined to change the type
|
||||
do
|
||||
Result ?= Precursor {EV_TREE_ITEM}
|
||||
end
|
||||
|
||||
parent_tree: JJ_TREE_VIEW
|
||||
-- Contains Current
|
||||
-- Redefined to change type.
|
||||
do
|
||||
Result ?= Precursor {EV_TREE_ITEM}
|
||||
end
|
||||
|
||||
parent_tool: JJ_TREE_TOOL
|
||||
-- The TOOL which contains this view.
|
||||
-- Can not be Void.
|
||||
do
|
||||
Result := parent_tree.parent_tool
|
||||
ensure then
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
wipe_out
|
||||
-- Clean out the view
|
||||
do
|
||||
recursive_do_all (agent clear_viewables)
|
||||
-- remove_all_viewables
|
||||
Precursor {EV_TREE_ITEM}
|
||||
end
|
||||
|
||||
clear_viewables (a_node: EV_TREE_NODE)
|
||||
--
|
||||
local
|
||||
ti: JJ_NODE_ITEM
|
||||
do
|
||||
ti ?= a_node
|
||||
if ti /= Void then
|
||||
ti.remove_all_targets
|
||||
end
|
||||
end
|
||||
|
||||
set_target (a_target: like target)
|
||||
-- Change `target'
|
||||
do
|
||||
Precursor {VIEW} (a_target)
|
||||
set_pebble (a_target)
|
||||
set_data (a_target)
|
||||
set_accept_cursor (yes_cursor (a_target))
|
||||
set_deny_cursor (no_cursor (a_target))
|
||||
-- if a_object.can_adopt then
|
||||
-- drop_actions.append (a_object.adopt_actions)
|
||||
-- end
|
||||
draw
|
||||
end
|
||||
|
||||
set_level (a_level: INTEGER)
|
||||
-- Change `level'
|
||||
do
|
||||
level := a_level
|
||||
ensure
|
||||
level_was_set: level = a_level
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
is_viewing_ancestors: BOOLEAN
|
||||
-- Are the nodes in the tree sorted by anscestors?
|
||||
|
||||
is_destroyed: BOOLEAN
|
||||
-- Is `Current' no longer usable?
|
||||
do
|
||||
Result := Precursor {VIEW} and Precursor {EV_TREE_ITEM}
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
destroy
|
||||
-- Destroy underlying native toolkit object.
|
||||
-- Render `Current' unusable.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TREE_ITEM}
|
||||
end
|
||||
|
||||
view_ancestors
|
||||
-- Make the view display ancestor nodes
|
||||
do
|
||||
is_viewing_ancestors := True
|
||||
end
|
||||
|
||||
view_descendants
|
||||
-- Make the view dispay descendant nodes
|
||||
do
|
||||
is_viewing_ancestors := False
|
||||
end
|
||||
|
||||
feature -- Querry
|
||||
|
||||
has_object_item (a_target: NODE): BOOLEAN
|
||||
-- Does Current contain an item with `target' equal to `a_target'?
|
||||
require
|
||||
target_exists: a_target /= Void
|
||||
do
|
||||
from start
|
||||
until Result or else exhausted
|
||||
loop
|
||||
Result := item.target = a_target
|
||||
forth
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Add children of `a_item.data' to the tree
|
||||
local
|
||||
n: NODE
|
||||
n_list: LINEAR [NODE]
|
||||
ti: JJ_NODE_ITEM
|
||||
pix: EV_PIXMAP
|
||||
p_view: JJ_TREE_VIEW
|
||||
p_tool: TOOL
|
||||
p_win: JJ_MAIN_WINDOW
|
||||
do
|
||||
if parent_tree /= Void then
|
||||
p_view := parent_tree
|
||||
p_tool := p_view.parent_tool
|
||||
p_win ?= p_tool.parent_window
|
||||
-- p_win ?= parent_window
|
||||
if p_view /= Void and then p_win /= Void then --p_view.is_displayed and p_win /= Void then
|
||||
-- This check seems to be needed to keep the view from being drawn
|
||||
-- even when it is not shown. Evidently draw gets called even if
|
||||
-- the TREE in which Current resides is not in any JJ_MAIN_WINDOW.
|
||||
-- (`parent_window' relies on a recursive search for Current in
|
||||
-- any descendents. If no main_window has the tree in which Current
|
||||
-- resides then `parent_window' is Void
|
||||
n ?= p_win.target
|
||||
check
|
||||
n_exists: n /= Void
|
||||
-- because the parent must be a NODE_TREE_VIEW and the
|
||||
-- `target' of it must be a NODE
|
||||
end
|
||||
if target /= Void then
|
||||
if n.descendants.has (target) then
|
||||
set_text (display_name (target))
|
||||
else
|
||||
set_text (display_name (target) + " " + interface_table.short_name ("not in system text"))
|
||||
end
|
||||
pix := (interface_table.pixmap (display_name (target))).twin
|
||||
-- FIX ME!! Changing the pixmap in order to put a not simble over it if
|
||||
-- not in system seems to be causing problems. Specificly, it violates post-
|
||||
-- condition of `set_pixmap'. Work on this later, or do my own tree.
|
||||
-- pix.set_background_color (Red)
|
||||
-- pix.set_size (100, 300)
|
||||
---- pix.fill_rectangle (pix.x_position + 5, pix.y_position, 100, 20)
|
||||
---- pix.fill_rectangle (5, 0, 100, 20)
|
||||
-- pix.set_line_width (3)
|
||||
-- pix.draw_segment (0,0, pix.width, pix.height)
|
||||
remove_pixmap
|
||||
set_pixmap (pix)
|
||||
---- pixmap.set_background_color (Red)
|
||||
---- pixmap.set_size (100, pixmap.height)
|
||||
---- pixmap.set_size (100, 100)
|
||||
---- pixmap.fill_rectangle (pixmap.x_position + 5, pixmap.y_position, 100, 20)
|
||||
---- pixmap.fill_rectangle (5, 0, 100, 20)
|
||||
---- wipe_out
|
||||
if parent_tree.is_viewing_ancestors then
|
||||
n_list := target.parents
|
||||
else
|
||||
n_list := target.children
|
||||
end
|
||||
-- clean out items which should no longer be here
|
||||
end
|
||||
from start
|
||||
until exhausted
|
||||
loop
|
||||
if not n_list.has (item.target) then
|
||||
item.wipe_out -- to remove all the views
|
||||
remove
|
||||
else
|
||||
forth
|
||||
end
|
||||
end
|
||||
-- Add new items
|
||||
from n_list.start
|
||||
until n_list.exhausted
|
||||
loop
|
||||
n := n_list.item
|
||||
-- n_list.forth
|
||||
if not has_object_item (n) then -- prevents duplicates
|
||||
ti := parent_tree.new_tree_item (n)
|
||||
extend (ti)
|
||||
ti.set_target (n)
|
||||
end
|
||||
n_list.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Actions
|
||||
|
||||
on_drop_node (a_node: NODE)
|
||||
-- React to a drop of `a_node' by adding `a_node' as child to
|
||||
-- the `target'?
|
||||
local
|
||||
c: ADD_NODE_COMMAND
|
||||
do
|
||||
create c
|
||||
c.set_parent_node (target)
|
||||
c.set_child_node (a_node)
|
||||
command_manager.add_command (c)
|
||||
end
|
||||
|
||||
on_double_click
|
||||
-- React to a mouse double click by opening a NAMER_VIEW.
|
||||
-- local
|
||||
-- nv: NAMER_VIEW
|
||||
do
|
||||
-- create nv
|
||||
-- nv.set_target (target)
|
||||
-- nv.set_position (50,50)
|
||||
end
|
||||
|
||||
feature {NONE} -- Inaplicable
|
||||
|
||||
parent_from_view_not_to_be_used: EV_CONTAINER
|
||||
-- Redefined to effect it (was deferred from VIEW); it
|
||||
-- does no good in this class as the parent of a EV_TREE_ITEM
|
||||
-- does not conform to the parent of most VIEWs which should
|
||||
-- be EV_CONTAINERs.
|
||||
do
|
||||
end
|
||||
|
||||
end
|
309
jj_vision/unfinished/jj_tree_tool.e
Normal file
309
jj_vision/unfinished/jj_tree_tool.e
Normal file
@@ -0,0 +1,309 @@
|
||||
note
|
||||
description: "[
|
||||
TOOL used to hold a JJ_TREE_VIEW for displaying a hierarchical
|
||||
structure of VIEWABLE_NODEs.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "21 Apr 06"
|
||||
|
||||
class
|
||||
JJ_TREE_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
TOOL
|
||||
redefine
|
||||
initialize,
|
||||
initialize_interface,
|
||||
set_actions,
|
||||
target,
|
||||
set_target,
|
||||
set_button_states,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Set up the window
|
||||
do
|
||||
create tree_view
|
||||
-- Create the new buttons before Precursor {TOOL} so `initialize'
|
||||
-- can call `set_actions' without a Void reference.
|
||||
create target_system_button
|
||||
create new_node_button
|
||||
create view_descendants_button
|
||||
create view_ancestors_button
|
||||
create cut_button
|
||||
-- "Register" the widgets with the `interface_table' in use by the
|
||||
-- current program (from SHARED in the "Standard Interface" cluster).
|
||||
interface_table.register_widget (target_system_button, "{JJ_TREE_TOOL} - target_system")
|
||||
interface_table.register_widget (new_node_button, "{JJ_TREE_TOOL} - new_node")
|
||||
interface_table.register_widget (view_descendants_button, "{JJ_TREE_TOOL} - view_descendants")
|
||||
interface_table.register_widget (view_ancestors_button, "{JJ_TREE_TOOL} - view_ancestors")
|
||||
interface_table.register_widget (cut_button, "{JJ_TREE_TOOL} - cut")
|
||||
interface_table.register_widget (Current, generating_type)
|
||||
-- Create the tool and its views
|
||||
Precursor {TOOL}
|
||||
-- Add the buttons to the `tool_bar' (from TOOL)
|
||||
tool_bar.extend (target_system_button)
|
||||
tool_bar.extend (new_node_button)
|
||||
tool_bar.extend (view_descendants_button)
|
||||
tool_bar.extend (view_ancestors_button)
|
||||
tool_bar.extend (cut_button)
|
||||
-- Set up the views in this tool.
|
||||
-- view_manager.enable_mode_changes
|
||||
split_manager.extend (tree_view)
|
||||
set_actions_for_views
|
||||
end
|
||||
|
||||
initialize_interface
|
||||
-- Create INTERFACE_ITEMs which could be used by Current.
|
||||
-- Called by `initialize'.
|
||||
do
|
||||
-- Only add an interface item for Current if its `interface_name' has
|
||||
-- not already been added; the other items are specific for this tool
|
||||
-- and most likely will not be redefine, so no need to check inclusion
|
||||
-- of these in the `interface_table'.
|
||||
-- In redefinitions of this feature call this at the end of the redefinition
|
||||
-- so an item for the `interface_name' can be added to the `interface_table'.
|
||||
if not interface_table.has_key (generating_type) then
|
||||
interface_table.add_item_with_tuple (<< generating_type, "JJ_TREE_TOOL", "Node tree tool", "Used to view relationships between nodes.", "icon_format_feature_descendants_color.ico">>)
|
||||
end
|
||||
interface_table.add_item_with_tuple (<<"{JJ_TREE_TOOL} - target_system", "Target System", "Make System be the target", "Set the target of this tool to the applications system.", "icon_object_symbol.ico">>)
|
||||
interface_table.add_item_with_tuple (<<"{JJ_TREE_TOOL} - new_node", "New Node", "Create a new node", "Create a new node.", "icon_cluster_symbol_color.ico">>)
|
||||
interface_table.add_item_with_tuple (<<"{JJ_TREE_TOOL} - view_descendants", "Descendents", "View descendants", "Show the descendent relationships of targeted object.", "icon_format_descendants_color.ico">>)
|
||||
interface_table.add_item_with_tuple (<<"{JJ_TREE_TOOL} - view_ancestors", "Ancestors", "View Ancestors", "Show the ancestor relationships of targeted object.", "icon_format_ancestors_color.ico">>)
|
||||
interface_table.add_item_with_tuple (<<"{JJ_TREE_TOOL} - cut", "Cut relationship", "Cut the link to the selected node", "Cut this link to the selected node.", "icon_cut_color.ico">>)
|
||||
-- Call Precursor after current is set up. Specifically after the interface
|
||||
-- item for Current's `interface_name' is added. (see above)
|
||||
Precursor {TOOL}
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets
|
||||
do
|
||||
Precursor {TOOL}
|
||||
target_system_button.select_actions.extend (agent on_target_system_button_pressed)
|
||||
new_node_button.select_actions.extend (agent on_new_node_button_pressed (agent new_node))
|
||||
view_descendants_button.select_actions.extend (agent on_view_descendants_button_pressed)
|
||||
view_ancestors_button.select_actions.extend (agent on_view_ancestors_button_pressed)
|
||||
cut_button.select_actions.extend (agent on_cut_button_pressed)
|
||||
end
|
||||
|
||||
set_actions_for_views
|
||||
-- Add actions to the views. This can only be done after the views are
|
||||
-- created. Because `set_actions' is called in the precursor to `initialize'
|
||||
-- this feature had to be added in order to access the "views" after they
|
||||
-- are created in `initialize' with the calls to `register_view_function'
|
||||
-- from `view_manager'.
|
||||
do
|
||||
tree_view.select_actions.extend (agent set_button_states)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
target: NODE
|
||||
-- The object handled by this tool.
|
||||
|
||||
tree_view: JJ_TREE_VIEW
|
||||
-- The VIEW which actually does the displaying of
|
||||
-- the nodes in a tree.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_target: like target)
|
||||
-- Change the `target' of the tool.
|
||||
-- Redefined to propegate `a_target' to the `tree_view'.
|
||||
do
|
||||
Precursor {TOOL} (a_target)
|
||||
tree_view.set_target (a_target)
|
||||
draw
|
||||
set_button_states
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Builds the string shown at top of the tool in `viewable_label'
|
||||
-- using the id of the object.
|
||||
local
|
||||
s: STRING
|
||||
n: NODE
|
||||
pw_test: ANY
|
||||
do
|
||||
Precursor {TOOL}
|
||||
-- Reminder: `target_label' is built in Precursor {TOOL}; it fills in
|
||||
-- the `display_name' if the TOOL's target is an EDITALBE, else it uses
|
||||
-- the generating type of the target.
|
||||
-- So, this redefined version simply addes the "not in system text"
|
||||
-- to the display name if necessary.
|
||||
s := target_label.tooltip
|
||||
pw_test := parent_window.target
|
||||
n ?= parent_window.target
|
||||
check
|
||||
n /= Void
|
||||
end
|
||||
if n /= Void and then not n.descendants.has (target) then
|
||||
s := s + " " + interface_table.short_name ("not in system text")
|
||||
end
|
||||
target_label.set_tooltip (s)
|
||||
set_button_states
|
||||
end
|
||||
|
||||
set_button_states
|
||||
-- Set the states of the buttons.
|
||||
local
|
||||
n: NODE
|
||||
do
|
||||
Precursor {TOOL}
|
||||
check
|
||||
tree_view_exists: tree_view /= Void
|
||||
end
|
||||
if tree_view.target = Void then
|
||||
new_node_button.disable_sensitive
|
||||
cut_button.disable_sensitive
|
||||
view_descendants_button.disable_sensitive
|
||||
view_ancestors_button.disable_sensitive
|
||||
else
|
||||
view_descendants_button.enable_sensitive
|
||||
view_ancestors_button.enable_sensitive
|
||||
n := tree_view.selected_target
|
||||
if n.can_adopt then
|
||||
new_node_button.enable_sensitive
|
||||
else
|
||||
new_node_button.disable_sensitive
|
||||
end
|
||||
if n /= target then
|
||||
cut_button.enable_sensitive
|
||||
else
|
||||
cut_button.disable_sensitive
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (actions)
|
||||
|
||||
on_target_system_button_pressed
|
||||
-- React to a press of the `target_system_button' by retargetting
|
||||
-- the view to the application's `target' and view descendents mode.
|
||||
local
|
||||
app: JJ_APPLICATION
|
||||
vn: NODE
|
||||
do
|
||||
app ?= (create {EV_ENVIRONMENT}).application
|
||||
check
|
||||
app_exists: app /= Void
|
||||
-- Because this class is only used by JJJ_APPLICATIONs
|
||||
end
|
||||
vn ?= app.target
|
||||
if vn /= Void then
|
||||
set_target (vn)
|
||||
end
|
||||
if tree_view.selected_item /= Void then
|
||||
tree_view.selected_item.disable_select
|
||||
end
|
||||
set_button_states
|
||||
end
|
||||
|
||||
on_new_node_button_pressed (a_function: FUNCTION [NODE])
|
||||
-- React to a press of the `new_node_button' by creating a
|
||||
-- new node using `a_function' and make the new node a child
|
||||
-- under the currently selected node.
|
||||
local
|
||||
c: ADD_NODE_COMMAND
|
||||
ti: EV_TREE_NODE
|
||||
new_n, n: NODE
|
||||
do
|
||||
new_n := a_function.item ([])
|
||||
create c
|
||||
n := tree_view.selected_target
|
||||
c.set_parent_node (n)
|
||||
c.set_child_node (new_n)
|
||||
command_manager.add_command (c)
|
||||
-- restore the selected object after a draw
|
||||
ti := tree_view.retrieve_item_recursively_by_data (n, False)
|
||||
if ti /= Void then
|
||||
ti.enable_select
|
||||
end
|
||||
end
|
||||
|
||||
new_node: EDITABLE_NODE
|
||||
-- Creation feature for a new node, used in `on_new_node_button_pressed'.
|
||||
do
|
||||
create Result
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
on_view_ancestors_button_pressed
|
||||
-- React to a press of the `view_ancestors_button' by changing
|
||||
-- the `view' to ancestors mode.
|
||||
do
|
||||
tree_view.set_view_ancestors
|
||||
end
|
||||
|
||||
on_view_descendants_button_pressed
|
||||
-- React to a press of the `view_descendants_button' by changing
|
||||
-- the `view' to descendants mode.
|
||||
do
|
||||
tree_view.set_view_descendants
|
||||
end
|
||||
|
||||
on_cut_button_pressed
|
||||
-- React to a press of the `cut_button' by removing the current node
|
||||
-- from its parent. (Does not necessarily delete from the system, but
|
||||
-- the node could be deleted if this is its only location in the tree.)
|
||||
require
|
||||
not_viewing_ancestors: not tree_view.is_viewing_ancestors
|
||||
cannot_cut_target_from_its_parent: tree_view.selected_target /= target
|
||||
local
|
||||
nti: JJ_NODE_ITEM
|
||||
nti_parent: JJ_NODE_ITEM
|
||||
parent_n: NODE
|
||||
n: NODE
|
||||
c: CUT_NODE_COMMAND
|
||||
do
|
||||
n := tree_view.selected_target
|
||||
nti := tree_view.selected_item
|
||||
nti_parent ?= nti.parent
|
||||
if nti_parent = Void then
|
||||
parent_n := target
|
||||
check
|
||||
parent_n.children.has (n)
|
||||
-- because otherwise we have the wrong parent
|
||||
end
|
||||
else
|
||||
parent_n := nti_parent.target
|
||||
end
|
||||
create c
|
||||
c.set_parent_node (parent_n)
|
||||
c.set_child_node (n)
|
||||
command_manager.add_command (c)
|
||||
-- Set the selected item to the `target' because we just deleted
|
||||
-- the selected item.
|
||||
draw_views (target)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (Buttons)
|
||||
|
||||
target_system_button: EV_TOOL_BAR_BUTTON
|
||||
-- To restore the application's `system' as the target of the view.
|
||||
|
||||
new_node_button: EV_TOOL_BAR_BUTTON
|
||||
-- To create a new DATABASE_RECORD.
|
||||
|
||||
view_descendants_button: EV_TOOL_BAR_BUTTON
|
||||
-- To make the tree show descendants (recursively) of the `target'.
|
||||
|
||||
view_ancestors_button: EV_TOOL_BAR_BUTTON
|
||||
-- To make the tree show descendants (recursively) of the `target'.
|
||||
|
||||
cut_button: EV_TOOL_BAR_BUTTON
|
||||
-- To cut the link between a parent node and the currently selected node
|
||||
|
||||
end
|
||||
|
236
jj_vision/unfinished/jj_tree_view.e
Normal file
236
jj_vision/unfinished/jj_tree_view.e
Normal file
@@ -0,0 +1,236 @@
|
||||
note
|
||||
description: "[
|
||||
Hierachical screen representation of VIEWABLE_NODEs.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "21 Apr 06"
|
||||
|
||||
class
|
||||
JJ_TREE_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_TREE
|
||||
redefine
|
||||
initialize,
|
||||
item,
|
||||
selected_item,
|
||||
destroy,
|
||||
is_destroyed
|
||||
end
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy,
|
||||
is_equal
|
||||
redefine
|
||||
initialize,
|
||||
target,
|
||||
set_target,
|
||||
draw,
|
||||
parent_tool,
|
||||
destroy,
|
||||
is_destroyed
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Set up the object
|
||||
do
|
||||
create item_list.make
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TREE}
|
||||
-- The tree is really just a root node, therefore there is only
|
||||
-- one `target' in this VIEW, and the sub-nodes are themselves VIEWs
|
||||
-- containing its own object.
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets.
|
||||
do
|
||||
drop_actions.extend (agent on_drop_target)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
target: NODE
|
||||
-- The object this view will display.
|
||||
|
||||
selected_item: JJ_NODE_ITEM
|
||||
-- Currently selected item at any level within tree hierarchy.
|
||||
do
|
||||
Result ?= Precursor {EV_TREE}
|
||||
end
|
||||
|
||||
selected_target: like target
|
||||
-- The object (data) in the `selected_item'
|
||||
require
|
||||
target_exists: target /= Void
|
||||
do
|
||||
if selected_item /= Void then
|
||||
Result := selected_item.target
|
||||
else
|
||||
Result := target
|
||||
end
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
no_item_selected_result: selected_item = Void implies Result = target
|
||||
end
|
||||
|
||||
item: JJ_NODE_ITEM
|
||||
-- Current item (node) in the tree.
|
||||
do
|
||||
Result ?= Precursor {EV_TREE}
|
||||
end
|
||||
|
||||
parent_tool: JJ_TREE_TOOL
|
||||
-- The JJ_TREE_TOOL which contains this view.
|
||||
-- Can not be Void.
|
||||
do
|
||||
Result ?= Precursor {VIEW}
|
||||
ensure then
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_target: like target)
|
||||
-- Change the value of `target'.
|
||||
do
|
||||
Precursor {VIEW} (a_target)
|
||||
draw
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_viewing_ancestors: BOOLEAN
|
||||
-- Are the clusters in the tree sorted by anscestors?
|
||||
|
||||
is_destroyed: BOOLEAN
|
||||
-- Is `Current' no longer usable?
|
||||
do
|
||||
Result := Precursor {VIEW} and Precursor {EV_TREE}
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_view_descendants
|
||||
-- Change to an descendants view
|
||||
do
|
||||
is_viewing_ancestors := False
|
||||
if not is_draw_disabled then
|
||||
draw
|
||||
end
|
||||
end
|
||||
|
||||
set_view_ancestors
|
||||
-- Change to an anscestors view
|
||||
do
|
||||
is_viewing_ancestors := True
|
||||
if not is_draw_disabled then
|
||||
draw
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
destroy
|
||||
-- Destroy underlying native toolkit object.
|
||||
-- Render `Current' unusable.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TREE}
|
||||
end
|
||||
|
||||
draw
|
||||
-- Build the view
|
||||
local
|
||||
t: like target
|
||||
tn: EV_TREE_NODE
|
||||
n_list: BILINEAR [NODE]
|
||||
do
|
||||
-- Get the selected object
|
||||
t := selected_target
|
||||
-- Clean out the tree
|
||||
from start
|
||||
until exhausted
|
||||
loop
|
||||
remove
|
||||
end
|
||||
-- Rebuild the tree recursively
|
||||
if target /= Void then
|
||||
if is_viewing_ancestors then
|
||||
n_list := target.parents
|
||||
else
|
||||
n_list := target.children
|
||||
end
|
||||
from n_list.start
|
||||
until n_list.exhausted
|
||||
loop
|
||||
-- Pass the type to `next_tree_item' to get the correct
|
||||
-- type of tree_item.
|
||||
root_item := new_tree_item (n_list.item)
|
||||
extend (root_item)
|
||||
-- But must also call `set_target' on that tree_item
|
||||
-- to force a draw (recursively).
|
||||
root_item.set_target (n_list.item)
|
||||
-- expand_clusters
|
||||
if root_item.is_expandable then
|
||||
root_item.expand
|
||||
end
|
||||
n_list.forth
|
||||
end
|
||||
end
|
||||
if t /= Void then
|
||||
tn := retrieve_item_recursively_by_data (t, False)
|
||||
if tn /= Void then
|
||||
tn.enable_select
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (actions)
|
||||
|
||||
on_drop_target (a_target: like target)
|
||||
-- React to a drop of `a_target'.
|
||||
require
|
||||
target_exists: a_target /= Void
|
||||
do
|
||||
parent_tool.set_target (a_target)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
root_item: JJ_NODE_ITEM
|
||||
-- Top-most item in the tree.
|
||||
-- Reminder: this is a EV_WIDGET which holds the data; not the data.
|
||||
|
||||
item_list: LINKED_LIST [JJ_NODE_ITEM]
|
||||
-- List of items which are in the view
|
||||
-- Reminder: these items are EV_WIDGETs which holds the data; not the data.
|
||||
|
||||
feature {JJ_NODE_ITEM} -- Implementation
|
||||
|
||||
new_tree_item (a_node: NODE): JJ_NODE_ITEM
|
||||
-- Create a new JJ_NODE_ITEM.
|
||||
-- `target' to `a_node'.
|
||||
require
|
||||
node_exists: a_node /= Void
|
||||
do
|
||||
if a_node.can_adopt then
|
||||
Result := create {JJ_NODE_ITEM}
|
||||
else
|
||||
Result := create {JJ_LEAF_NODE_ITEM}
|
||||
end
|
||||
Result.set_target (a_node)
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
end
|
56
jj_vision/unfinished/label_control.e
Normal file
56
jj_vision/unfinished/label_control.e
Normal file
@@ -0,0 +1,56 @@
|
||||
class LABEL_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
CONTROL
|
||||
rename
|
||||
make as control_make
|
||||
redefine
|
||||
set_height, set_width
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_parent: WEL_COMPOSITE_WINDOW)
|
||||
do
|
||||
control_make (a_parent)
|
||||
create static.make (Current, "New_Text", 0, 0, width, height, -1)
|
||||
end
|
||||
|
||||
set_height (a_height: INTEGER)
|
||||
do
|
||||
resize (width, a_height)
|
||||
static.set_height (height)
|
||||
end
|
||||
|
||||
set_width (a_width: INTEGER)
|
||||
do
|
||||
resize (a_width, height)
|
||||
static.set_width (width)
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_data (a_string: STRING)
|
||||
do
|
||||
static.set_text (a_string)
|
||||
end
|
||||
|
||||
data: STRING
|
||||
do
|
||||
Result := static.text
|
||||
end
|
||||
|
||||
is_data_valid: BOOLEAN
|
||||
do
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
static: WEL_STATIC
|
||||
|
||||
end -- class LABEL_CONTROL
|
269
jj_vision/unfinished/left_aligned_scrollable_area.e
Normal file
269
jj_vision/unfinished/left_aligned_scrollable_area.e
Normal file
@@ -0,0 +1,269 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that represent a scrollable area in which the contents are always aligned with the top left while
|
||||
smaller than client area.
|
||||
|
||||
When using this control, you must be careful of the following things:
|
||||
|
||||
An action sequence is connected to the idle_actions of the application from time to time. As it is removed,
|
||||
it is the final agent contained, so if you must add to the idle actions, you should not add at the last position.
|
||||
|
||||
An agent is connected to the `resize_actions' of the widget inserted. If you clear this action sequence, `Current'
|
||||
will not update as the widget size changes. Removing the widget via `remove_item' removes the final agent from
|
||||
`resize_actions'.
|
||||
|
||||
None of the inherited features for addition and removal of widget does not work correctly. Use `add_item'
|
||||
and `remove_item' only.
|
||||
]"
|
||||
author: "Julian Rogers"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
LEFT_ALIGNED_SCROLLABLE_AREA
|
||||
|
||||
inherit
|
||||
EV_VERTICAL_BOX
|
||||
redefine
|
||||
initialize,
|
||||
is_in_default_state
|
||||
end
|
||||
|
||||
feature {NONE} -- Creation
|
||||
|
||||
initialize
|
||||
-- Initialize `Current'.
|
||||
local
|
||||
h_box: EV_HORIZONTAL_BOX
|
||||
do
|
||||
create cell
|
||||
create viewport
|
||||
create vertical_scroll_bar
|
||||
vertical_scroll_bar.change_actions.extend (agent scroll_vertically)
|
||||
create horizontal_scroll_bar
|
||||
horizontal_scroll_bar.change_actions.extend (agent scroll_horizontally)
|
||||
horizontal_scroll_bar.hide
|
||||
vertical_scroll_bar.hide
|
||||
create horizontal_box
|
||||
extend (horizontal_box)
|
||||
create main_fixed
|
||||
viewport.extend (main_fixed)
|
||||
create h_box
|
||||
extend (h_box)
|
||||
h_box.extend (horizontal_scroll_bar)
|
||||
cell.set_minimum_size (vertical_scroll_bar.minimum_width, horizontal_scroll_bar.minimum_height)
|
||||
h_box.extend (cell)
|
||||
h_box.disable_item_expand (cell)
|
||||
cell.hide
|
||||
|
||||
disable_item_expand (h_box)
|
||||
horizontal_box.extend (viewport)
|
||||
horizontal_box.extend (vertical_scroll_bar)
|
||||
horizontal_box.disable_item_expand (vertical_scroll_bar)
|
||||
|
||||
resize_actions.extend (agent resized)
|
||||
|
||||
is_initialized := True
|
||||
end
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
add_item (an_item: EV_WIDGET)
|
||||
-- Add `an_item' to `Current'.
|
||||
require
|
||||
an_item_not_void: an_item /= Void
|
||||
do
|
||||
main_fixed.extend (an_item)
|
||||
main_fixed.set_item_position (an_item, 0, 0)
|
||||
the_item := an_item
|
||||
the_item.resize_actions.extend (agent item_resized)
|
||||
resized (0, 0, 0, 0)
|
||||
ensure
|
||||
item_set: the_item = an_item
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
the_item: EV_WIDGET
|
||||
-- Item currently contained.
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
remove_item
|
||||
-- Remove item from `Current'
|
||||
do
|
||||
if the_item /= Void then
|
||||
main_fixed.wipe_out
|
||||
the_item := Void
|
||||
the_item.resize_actions.go_i_th (the_item.resize_actions.count)
|
||||
the_item.resize_actions.remove
|
||||
end
|
||||
ensure
|
||||
no_item_contained: the_item = Void
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
item_resized (an_x, a_y, a_width, a_height: INTEGER)
|
||||
-- `the_item' has been resized, respond by updating `Current'.
|
||||
do
|
||||
resized (0, 0, width, height)
|
||||
end
|
||||
|
||||
resized (an_x, a_y, a_width, a_height: INTEGER)
|
||||
-- `Current' has been resized. Determine if the scroll bars must be updated, and if necessary
|
||||
-- connect an idle action that executes `update_scroll_bars' if their visible status has changed.
|
||||
-- The visible status of the scroll bars must not be updated via `show' or `hide' during execution of
|
||||
-- this feature as it is called from within the resize. Resizing a Vision2 interface during a resize
|
||||
-- event is dangerous in this situation. Hence we must connect `update_scroll_bars' to perform the update
|
||||
-- when the resizing is completed from the idle actions.
|
||||
do
|
||||
clear_visibility_flags
|
||||
if the_item /= Void then
|
||||
if viewport.width < the_item.width then
|
||||
if not horizontal_scroll_bar.is_show_requested then
|
||||
show_horizontal := True
|
||||
end
|
||||
horizontal_scroll_bar.value_range.adapt (create {INTEGER_INTERVAL}.make (0, the_item.width - viewport.width))
|
||||
horizontal_scroll_bar.set_leap (viewport.width.max (1))
|
||||
elseif horizontal_scroll_bar.is_show_requested then
|
||||
hide_horizontal := True
|
||||
end
|
||||
if viewport.height < the_item.height then
|
||||
if not vertical_scroll_bar.is_show_requested then
|
||||
show_vertical := True
|
||||
end
|
||||
|
||||
vertical_scroll_bar.value_range.adapt (create {INTEGER_INTERVAL}.make (0, the_item.height - viewport.height))
|
||||
vertical_scroll_bar.set_leap (viewport.height.max (1))
|
||||
elseif vertical_scroll_bar.is_show_requested then
|
||||
hide_vertical := True
|
||||
end
|
||||
|
||||
-- Ensure that as `Current' is enlarged, if the scroll positions are non zero, the
|
||||
-- item tends towards the zero position.
|
||||
if viewport.y_offset > 0 and the_item.height - viewport.y_offset < viewport.height then
|
||||
viewport.set_y_offset ((the_item.height - viewport.height).max (0))
|
||||
end
|
||||
if viewport.x_offset > 0 and the_item.width - viewport.x_offset < viewport.width then
|
||||
viewport.set_x_offset ((the_item.width - viewport.width).max (0))
|
||||
end
|
||||
if show_horizontal or hide_horizontal or show_vertical or hide_vertical and not idle_actions_connected then
|
||||
idle_actions_connected := True
|
||||
application.idle_actions.extend (agent update_scroll_bars)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
update_scroll_bars
|
||||
-- Actually perform hiding and showing of scroll bars deferred from `resized'.
|
||||
-- Note that we must recompute the scroll bar values, as the widgets may have been resized since we
|
||||
-- originally flagged that there must be a change of visibility.
|
||||
do
|
||||
if show_vertical then
|
||||
vertical_scroll_bar.show
|
||||
end
|
||||
if hide_vertical then
|
||||
vertical_scroll_bar.hide
|
||||
end
|
||||
if show_horizontal then
|
||||
horizontal_scroll_bar.show
|
||||
end
|
||||
if hide_horizontal then
|
||||
horizontal_scroll_bar.hide
|
||||
end
|
||||
|
||||
if horizontal_scroll_bar.is_show_requested and vertical_scroll_bar.is_show_requested then
|
||||
cell.show
|
||||
else
|
||||
cell.hide
|
||||
end
|
||||
|
||||
if show_vertical or show_horizontal or hide_horizontal or hide_vertical then
|
||||
if vertical_scroll_bar.is_show_requested then
|
||||
vertical_scroll_bar.value_range.adapt (create {INTEGER_INTERVAL}.make (0, the_item.height - viewport.height))
|
||||
vertical_scroll_bar.set_leap (viewport.height.max (1))
|
||||
end
|
||||
|
||||
if horizontal_scroll_bar.is_show_requested then
|
||||
horizontal_scroll_bar.value_range.adapt (create {INTEGER_INTERVAL}.make (0, the_item.width - viewport.width))
|
||||
horizontal_scroll_bar.set_leap (viewport.width.max (1))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Ensure that as `Current' is enlarged, if the scroll positions are non zero, the
|
||||
-- item tends towards the zero position.
|
||||
if viewport.y_offset > 0 and the_item.height - viewport.y_offset < viewport.height then
|
||||
viewport.set_y_offset ((the_item.height - viewport.height).max (0))
|
||||
end
|
||||
if viewport.x_offset > 0 and the_item.width - viewport.x_offset < viewport.width then
|
||||
viewport.set_x_offset ((the_item.width - viewport.width).max (0))
|
||||
end
|
||||
|
||||
|
||||
-- Remove the idle action as leaving it hogs the CPU.
|
||||
application.idle_actions.go_i_th (application.idle_actions.count)
|
||||
application.idle_actions.remove
|
||||
idle_actions_connected := False
|
||||
end
|
||||
|
||||
show_vertical, hide_vertical, show_horizontal, hide_horizontal, show_cell, hide_cell: BOOLEAN
|
||||
-- Flags to determine if the visible state of widgets must be updated.
|
||||
|
||||
clear_visibility_flags
|
||||
-- Clear visibility flags to False.
|
||||
do
|
||||
show_vertical := False
|
||||
show_horizontal := False
|
||||
hide_horizontal := False
|
||||
hide_vertical := False
|
||||
end
|
||||
|
||||
|
||||
scroll_vertically (new_value: INTEGER)
|
||||
-- Respond to a scrolling of `vertical_scroll_bar'.
|
||||
do
|
||||
viewport.set_y_offset (new_value)
|
||||
end
|
||||
|
||||
scroll_horizontally (new_value: INTEGER)
|
||||
-- Respond to a scrolling of `horizontal_scroll_bar'.
|
||||
do
|
||||
viewport.set_x_offset (new_value)
|
||||
end
|
||||
|
||||
is_in_default_state: BOOLEAN = True
|
||||
-- Is `Current' in its default state.
|
||||
|
||||
idle_actions_connected: BOOLEAN
|
||||
-- Is the idle event for showing scroll bars already connected?
|
||||
|
||||
vertical_scroll_bar: EV_VERTICAL_SCROLL_BAR
|
||||
-- Vertical scroll bar comprising `Current'.
|
||||
|
||||
horizontal_scroll_bar: EV_HORIZONTAL_SCROLL_BAR
|
||||
-- Horizontal scroll bar comprising `Current'.
|
||||
|
||||
horizontal_box: EV_HORIZONTAL_BOX
|
||||
-- Horizontal box comprising `Current'.
|
||||
|
||||
viewport: EV_VIEWPORT
|
||||
-- Viewport comprising `Current'.
|
||||
|
||||
main_fixed: EV_FIXED
|
||||
-- The Fixed required in `Current'.
|
||||
|
||||
cell: EV_CELL
|
||||
-- A cell placed betwen the corners of the scroll bars.
|
||||
|
||||
application: EV_APPLICATION
|
||||
-- Once access to EV_APPLICATION.
|
||||
once
|
||||
--((create {EV_ENVIRONMENT}).application).idle_actions.extend (agent update_scroll_bars)
|
||||
Result := ((create {EV_ENVIRONMENT}).application)
|
||||
end
|
||||
|
||||
end -- class LEFT_ALIGNED_SCROLLABLE_AREA
|
144
jj_vision/unfinished/ymd_duration_control.e
Normal file
144
jj_vision/unfinished/ymd_duration_control.e
Normal file
@@ -0,0 +1,144 @@
|
||||
class YMD_DURATION_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WEL_SS_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
WEL_EN_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
YMD_DURATION_PARSER
|
||||
rename
|
||||
make as parser_make
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
CONTROL
|
||||
redefine
|
||||
make,
|
||||
on_control_command,
|
||||
set_height,
|
||||
set_width
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_parent: WEL_COMPOSITE_WINDOW)
|
||||
local
|
||||
button_size: INTEGER
|
||||
do
|
||||
parser_make
|
||||
Precursor (a_parent)
|
||||
create static.make (Current, "", 0, 0, 50, 20, -1)
|
||||
create up_button.make (Current, "+", 40, 0, 10, 10, -1)
|
||||
create down_button.make (Current, "-", 40, 10, 10, 10, -1)
|
||||
end
|
||||
|
||||
set_height (a_height: INTEGER)
|
||||
local
|
||||
but_size: INTEGER
|
||||
do
|
||||
Precursor (a_height)
|
||||
but_size := height // 2
|
||||
static.set_height (height)
|
||||
static.set_width (width - but_size-1)
|
||||
up_button.set_x (static.width+1)
|
||||
down_button.set_y (static.width+1)
|
||||
up_button.set_height (but_size)
|
||||
up_button.set_width (but_size)
|
||||
down_button.set_height (but_size)
|
||||
down_button.set_width (but_size)
|
||||
end
|
||||
|
||||
set_width (a_width: INTEGER)
|
||||
local
|
||||
but_size: INTEGER
|
||||
do
|
||||
Precursor (a_width)
|
||||
but_size := height // 2
|
||||
static.set_width (width - but_size-1)
|
||||
up_button.set_x (static.width+1)
|
||||
down_button.set_x (static.width+1)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Messages
|
||||
|
||||
on_control_command (control: WEL_CONTROL)
|
||||
local
|
||||
temp: WEL_CONTROL_WINDOW
|
||||
do
|
||||
temp ?= parent
|
||||
if control = up_button then
|
||||
increment
|
||||
temp.notify (Current, En_change)
|
||||
elseif control = down_button then
|
||||
decrement
|
||||
temp.notify (Current, En_change)
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
data: YMD_DURATION
|
||||
-- data: YMD_DURATION is
|
||||
-- do
|
||||
-- Result := date
|
||||
-- end
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_data (a_duration: YMD_DURATION)
|
||||
do
|
||||
data := a_duration
|
||||
static.set_text (to_string (data))
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_data_valid: BOOLEAN
|
||||
do
|
||||
Result := True
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
static: WEL_STATIC
|
||||
|
||||
up_button: WEL_PUSH_BUTTON
|
||||
|
||||
down_button: WEL_PUSH_BUTTON
|
||||
|
||||
increment
|
||||
local
|
||||
one_day: YMD_DURATION
|
||||
do
|
||||
create one_day.make
|
||||
one_day.set (0,0,1)
|
||||
data.add (one_day)
|
||||
static.set_text (to_string (data))
|
||||
end
|
||||
|
||||
decrement
|
||||
local
|
||||
one_day: YMD_DURATION
|
||||
do
|
||||
create one_day.make
|
||||
one_day.set (0,0,1)
|
||||
data.sub (one_day)
|
||||
static.set_text (to_string(data))
|
||||
end
|
||||
|
||||
|
||||
end
|
109
jj_vision/unfinished/ymd_interval_control.e
Normal file
109
jj_vision/unfinished/ymd_interval_control.e
Normal file
@@ -0,0 +1,109 @@
|
||||
class YMD_INTERVAL_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WEL_EN_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
JJJ_CONTROL
|
||||
redefine
|
||||
make,
|
||||
notify,
|
||||
set_height,
|
||||
set_width
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_parent: WEL_COMPOSITE_WINDOW)
|
||||
do
|
||||
Precursor (a_parent)
|
||||
create start_date_edit.make (Current)
|
||||
create finish_date_edit.make (Current)
|
||||
create duration_edit.make (Current)
|
||||
create data.make
|
||||
start_date_edit.set_x (5)
|
||||
start_date_edit.set_y (5)
|
||||
finish_date_edit.set_x (5)
|
||||
finish_date_edit.set_y (start_date_edit.y + start_date_edit.height + 5)
|
||||
duration_edit.set_x (5)
|
||||
duration_edit.set_y (finish_date_edit.y + finish_date_edit.height + 5)
|
||||
end
|
||||
|
||||
set_height (a_height: INTEGER)
|
||||
do
|
||||
Precursor (a_height)
|
||||
finish_date_edit.set_y (start_date_edit.y + start_date_edit.height + 5)
|
||||
end
|
||||
|
||||
set_width (a_width: INTEGER)
|
||||
do
|
||||
Precursor (a_width)
|
||||
start_date_edit.set_width (width-10)
|
||||
finish_date_edit.set_width (width-10)
|
||||
duration_edit.set_width (width-10)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
data: YMD_INTERVAL
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_data (a_interval: like data)
|
||||
do
|
||||
data := a_interval
|
||||
start_date_edit.set_data (data.start)
|
||||
finish_date_edit.set_data (data.finish)
|
||||
duration_edit.set_data (data.duration)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_data_valid: BOOLEAN
|
||||
do
|
||||
-- if is_valid_date_string (text) then
|
||||
-- set_date_string (text)
|
||||
Result := True
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Messages
|
||||
|
||||
notify (a_control: WEL_CONTROL; a_notify_code: INTEGER)
|
||||
local
|
||||
p: WEL_COMPOSITE_WINDOW
|
||||
do
|
||||
if a_notify_code = En_change then
|
||||
if a_control = start_date_edit or a_control = finish_date_edit then
|
||||
data.set_start_finish (start_date_edit.data, finish_date_edit.data)
|
||||
elseif a_control = duration_edit then
|
||||
if not duration_edit.data.is_negative then
|
||||
data.set_start_duration (start_date_edit.data, duration_edit.data)
|
||||
end
|
||||
else
|
||||
end
|
||||
set_data (data)
|
||||
end
|
||||
p ?= parent
|
||||
if p /= Void then
|
||||
p.notify (Current, En_change)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
start_date_edit: JJJ_EDIT_DATE
|
||||
|
||||
finish_date_edit: JJJ_EDIT_DATE
|
||||
|
||||
duration_edit: JJJ_EDIT_YMD_DURATION
|
||||
|
||||
|
||||
end -- class YMD_INTERVAL_CONTROL
|
42
jj_vision/unfinished/ymd_interval_field.e
Normal file
42
jj_vision/unfinished/ymd_interval_field.e
Normal file
@@ -0,0 +1,42 @@
|
||||
class YMD_INTERVAL_FIELD
|
||||
-- creates an edit box.
|
||||
|
||||
inherit
|
||||
|
||||
FIELD
|
||||
redefine
|
||||
make
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
Precursor
|
||||
set_height (150)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
data: YMD_INTERVAL
|
||||
once
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_control (a_parent: WEL_COMPOSITE_WINDOW): JJJ_EDIT_YMD_INTERVAL
|
||||
do
|
||||
create Result.make (a_parent)
|
||||
Result.set_x (x)
|
||||
Result.set_y (y)
|
||||
Result.set_width (width)
|
||||
Result.set_height (height)
|
||||
Result.set_data (data)
|
||||
end
|
||||
|
||||
end -- class DMY_INTERVAL_FIELD
|
205
jj_vision/unfinished/ymdhms_duration_control.e
Normal file
205
jj_vision/unfinished/ymdhms_duration_control.e
Normal file
@@ -0,0 +1,205 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
YMDHMS_DURATION_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
EV_KEY_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
YMDHMS_DURATION_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
CONTROL
|
||||
redefine
|
||||
initialize,
|
||||
value_imp,
|
||||
is_value_valid,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor {CONTROL}
|
||||
create parser.make
|
||||
create static
|
||||
create up_button
|
||||
create down_button
|
||||
extend (static)
|
||||
extend (up_button)
|
||||
extend (down_button)
|
||||
position_widgets
|
||||
set_actions
|
||||
end
|
||||
|
||||
position_widgets
|
||||
-- Set the size and location of each widget in `Current'
|
||||
do
|
||||
static.set_minimum_width (150)
|
||||
up_button.set_text ("+")
|
||||
down_button.set_text ("-")
|
||||
up_button.set_minimum_size (static.height // 2, static.height // 2)
|
||||
down_button.set_minimum_size (static.height // 2, static.height // 2)
|
||||
-- set_item_size (up_button, up_button.width, static.height // 2)
|
||||
-- set_item_size (down_button, down_button.width, static.height // 2)
|
||||
set_item_position (up_button, static.width, 0)
|
||||
set_item_position (down_button, static.width, static.height // 2)
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets
|
||||
do
|
||||
up_button.select_actions.extend (agent increment_value)
|
||||
down_button.select_actions.extend (agent decrement_value)
|
||||
static.key_press_actions.extend (agent on_key_press)
|
||||
end
|
||||
|
||||
-- set_height (a_height: INTEGER) is
|
||||
-- local
|
||||
-- but_size: INTEGER
|
||||
-- do
|
||||
-- Precursor (a_height)
|
||||
-- but_size := height // 2
|
||||
-- static.set_height (height)
|
||||
-- static.set_width (width - but_size-1)
|
||||
-- up_button.set_x (static.width+1)
|
||||
-- down_button.set_y (static.width+1)
|
||||
-- up_button.set_height (but_size)
|
||||
-- up_button.set_width (but_size)
|
||||
-- down_button.set_height (but_size)
|
||||
-- down_button.set_width (but_size)
|
||||
-- end
|
||||
--
|
||||
-- set_width (a_width: INTEGER) is
|
||||
-- local
|
||||
-- but_size: INTEGER
|
||||
-- do
|
||||
-- Precursor (a_width)
|
||||
-- but_size := height // 2
|
||||
-- static.set_width (width - but_size-1)
|
||||
-- up_button.set_x (static.width+1)
|
||||
-- down_button.set_x (static.width+1)
|
||||
-- end
|
||||
|
||||
feature -- Access
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_value_valid: BOOLEAN
|
||||
do
|
||||
-- FIX ME !!!
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Update the screen representation (ie `static'). This feature
|
||||
-- is not called directly from Current; it is called by
|
||||
-- JJJ_CONTROL.`set_value'.
|
||||
do
|
||||
static.set_text (parser.to_string (value_imp))
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
increment_value
|
||||
-- Increase the value by one unit. Unit is based
|
||||
-- on position of caret within the edit box.
|
||||
do
|
||||
change_value (1)
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
decrement_value
|
||||
-- Decrease the value by one unit. Unit is based
|
||||
-- on position of caret within the edit box.
|
||||
do
|
||||
change_value (-1)
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
change_value (sign: INTEGER)
|
||||
-- Change the value by + or - one unit based on `sign'
|
||||
require
|
||||
valid_sign: sign = 1 or sign = -1
|
||||
local
|
||||
pos: INTEGER
|
||||
do
|
||||
pos := static.caret_position
|
||||
if parser.is_index_in_year_string (value_imp, pos) then
|
||||
value_imp.add (One_year * sign)
|
||||
elseif parser.is_index_in_month_string (value_imp, pos) then
|
||||
value_imp.add (One_month * sign)
|
||||
elseif parser.is_index_in_day_string (value_imp, pos) then
|
||||
value_imp.add (One_day * sign)
|
||||
elseif parser.is_index_in_hour_string (value_imp, pos) then
|
||||
value_imp.add (One_hour * sign)
|
||||
elseif parser.is_index_in_minute_string (value_imp, pos) then
|
||||
value_imp.add (One_minute * sign)
|
||||
elseif parser.is_index_in_second_string (value_imp, pos) then
|
||||
value_imp.add (One_second * sign)
|
||||
else
|
||||
end
|
||||
draw
|
||||
static.set_caret_position (pos)
|
||||
end
|
||||
|
||||
on_key_press (a_key: EV_KEY)
|
||||
-- Process a key pressed in static
|
||||
do
|
||||
if a_key.code = Key_up then
|
||||
increment_value
|
||||
static.set_caret_position ((static.caret_position - 1).max (0))
|
||||
-- to move the caret back after the key press
|
||||
-- otherwise it move forward one position.
|
||||
elseif a_key.code = Key_down then
|
||||
decrement_value
|
||||
static.set_caret_position ((static.caret_position + 1).max (0))
|
||||
-- to move the caret back after the key press
|
||||
-- otherwise it move forward one position.
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
value_imp: YMDHMS_DURATION
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
|
||||
static: EV_TEXT_FIELD
|
||||
|
||||
up_button: EV_BUTTON
|
||||
|
||||
down_button: EV_BUTTON
|
||||
|
||||
parser: YMD_TIME_PARSER
|
||||
-- parser: YMDHMS_DURATION_PARSER
|
||||
-- For converting `value' to and from strings
|
||||
|
||||
end -- class YMDHMS_DURATION_CONTROL
|
164
jj_vision/unfinished/ymdhms_interval_control.e
Normal file
164
jj_vision/unfinished/ymdhms_interval_control.e
Normal file
@@ -0,0 +1,164 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
YMDHMS_INTERVAL_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
CONTROL
|
||||
redefine
|
||||
initialize,
|
||||
value_imp,
|
||||
is_value_valid,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
local
|
||||
lab: EV_LABEL
|
||||
do
|
||||
Precursor {JJJ_CONTROL}
|
||||
create start_date_edit
|
||||
create finish_date_edit
|
||||
create duration_edit
|
||||
|
||||
extend (start_date_edit)
|
||||
extend (finish_date_edit)
|
||||
extend (duration_edit)
|
||||
|
||||
create lab.make_with_text ("Start")
|
||||
extend (lab)
|
||||
set_item_position (lab, 0, 0)
|
||||
-- set_item_width (lab, 20)
|
||||
create lab.make_with_text ("Finish")
|
||||
extend (lab)
|
||||
set_item_position (lab, 0, 30)
|
||||
create lab.make_with_text ("Duration")
|
||||
extend (lab)
|
||||
set_item_position (lab, 0, 60)
|
||||
-- set_item_width (lab, 20)
|
||||
set_item_position (start_date_edit, lab.width + 5, 0)
|
||||
set_item_position (finish_date_edit, lab.width +5, 30)
|
||||
set_item_position (duration_edit, lab.width + 5, 60)
|
||||
-- set_item_width (start_date_edit, 150)
|
||||
-- set_item_width (finish_date_edit, 150)
|
||||
-- set_item_width (duration_edit, 150)
|
||||
|
||||
-- !! duration_edit.make (Current)
|
||||
-- !! value.make
|
||||
|
||||
-- start_date_edit.set_x (5)
|
||||
-- start_date_edit.set_y (5)
|
||||
-- finish_date_edit.set_x (5)
|
||||
-- finish_date_edit.set_y (start_date_edit.y + start_date_edit.height + 5)
|
||||
-- duration_edit.set_x (5)
|
||||
-- duration_edit.set_y (finish_date_edit.y + finish_date_edit.height + 5)
|
||||
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets in `Current'
|
||||
do
|
||||
start_date_edit.change_actions.extend (agent on_start_changed)
|
||||
finish_date_edit.change_actions.extend (agent on_finish_changed)
|
||||
duration_edit.change_actions.extend (agent on_duration_changed)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_value_valid: BOOLEAN
|
||||
do
|
||||
-- if is_valid_date_string (text) then
|
||||
-- set_date_string (text)
|
||||
Result := True
|
||||
-- end
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Update the screen representation of Current by simply loading
|
||||
-- the various pieces of `value_imp' into the proper controls.
|
||||
-- This feature is called from JJJ_CONTROL.`set_value'.
|
||||
do
|
||||
start_date_edit.set_value (value_imp.start)
|
||||
finish_date_edit.set_value (value_imp.finish)
|
||||
duration_edit.set_value (value_imp.duration)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
on_start_changed
|
||||
-- Start has changed so update `Current'
|
||||
local
|
||||
s, f: YMDHMS_TIME
|
||||
do
|
||||
s := start_date_edit.value
|
||||
f := finish_date_edit.value
|
||||
if f < s then
|
||||
f := s
|
||||
end
|
||||
value_imp.set_start_finish (s, f)
|
||||
draw
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
on_finish_changed
|
||||
-- Finished has changed so update `Current'
|
||||
local
|
||||
s, f: YMDHMS_TIME
|
||||
do
|
||||
s := start_date_edit.value
|
||||
f := finish_date_edit.value
|
||||
if f < s then
|
||||
s := f
|
||||
end
|
||||
value_imp.set_start_finish (s, f)
|
||||
draw
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
on_duration_changed
|
||||
-- `Duration_edit' has changed so update `Current'
|
||||
local
|
||||
s: YMDHMS_TIME
|
||||
d: YMDHMS_DURATION
|
||||
do
|
||||
s := start_date_edit.value
|
||||
d := duration_edit.value
|
||||
if d.is_negative then
|
||||
value_imp.set_start_finish (s, s)
|
||||
else
|
||||
value_imp.set_start_duration (s, d)
|
||||
end
|
||||
draw
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
value_imp: YMDHMS_INTERVAL
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
|
||||
start_date_edit: YMDHMS_TIME_CONTROL
|
||||
|
||||
finish_date_edit: YMDHMS_TIME_CONTROL
|
||||
|
||||
duration_edit: YMDHMS_DURATION_CONTROL
|
||||
|
||||
end
|
44
jj_vision/unfinished/ymdhms_interval_field.e
Normal file
44
jj_vision/unfinished/ymdhms_interval_field.e
Normal file
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
YMDHMS_INTERVAL_FIELD
|
||||
|
||||
inherit
|
||||
|
||||
FIELD
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
default_create
|
||||
do
|
||||
Precursor {FIELD}
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
data: YMDHMS_INTERVAL
|
||||
once
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: YMDHMS_INTERVAL_CONTROL
|
||||
do
|
||||
create Result
|
||||
-- Result.set_data (data)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
237
jj_vision/unfinished/ymdhms_time_control.e
Normal file
237
jj_vision/unfinished/ymdhms_time_control.e
Normal file
@@ -0,0 +1,237 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
YMDHMS_TIME_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
EV_KEY_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
YMDHMS_DURATION_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
CONTROL
|
||||
redefine
|
||||
initialize,
|
||||
value_imp,
|
||||
is_value_valid,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor {CONTROL}
|
||||
create parser.make
|
||||
create static
|
||||
create up_button
|
||||
create down_button
|
||||
create calendar_button
|
||||
extend (static)
|
||||
extend (up_button)
|
||||
extend (down_button)
|
||||
extend (calendar_button)
|
||||
position_widgets
|
||||
set_actions
|
||||
end
|
||||
|
||||
position_widgets
|
||||
-- Set the size and location of each widget in `Current'
|
||||
do
|
||||
static.set_minimum_width (150)
|
||||
up_button.set_text ("+")
|
||||
down_button.set_text ("-")
|
||||
up_button.set_minimum_size (static.height // 2, static.height // 2)
|
||||
down_button.set_minimum_size (static.height // 2, static.height // 2)
|
||||
calendar_button.set_minimum_size (static.height, static.height)
|
||||
-- set_item_size (up_button, up_button.width, static.height // 2)
|
||||
-- set_item_size (down_button, down_button.width, static.height // 2)
|
||||
set_item_position (up_button, static.width, 0)
|
||||
set_item_position (down_button, static.width, static.height // 2)
|
||||
set_item_position (calendar_button, static.width + up_button.width, 0)
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets
|
||||
do
|
||||
up_button.select_actions.extend (agent increment_data)
|
||||
down_button.select_actions.extend (agent decrement_data)
|
||||
calendar_button.select_actions.extend (agent open_calendar_dialog)
|
||||
static.key_press_actions.extend (agent on_key_press)
|
||||
end
|
||||
|
||||
|
||||
-- set_minimum_height (a_height: INTEGER) is
|
||||
-- local
|
||||
-- but_size: INTEGER
|
||||
-- do
|
||||
-- Precursor {JJJ_CONTROL} (a_height)
|
||||
-- but_size := minimum_height // 2
|
||||
-- set_item_height (static, minimum_height)
|
||||
-- set_item_height (up_button, but_size)
|
||||
-- set_item_height (down_button, but_size)
|
||||
-- set_item_y_position (up_button, 0)
|
||||
-- set_item_y_position (down_button, but_size)
|
||||
-- end
|
||||
|
||||
-- set_minimum_width (a_width: INTEGER) is
|
||||
-- local
|
||||
-- but_size: INTEGER
|
||||
-- do
|
||||
-- Precursor {JJJ_CONTROL} (a_width)
|
||||
-- but_size := up_button.width
|
||||
-- set_item_width (static, minimum_width - but_size - 1)
|
||||
-- set_item_x_position (up_button, minimum_width - but_size)
|
||||
-- set_item_x_position (down_button, minimum_width - but_size)
|
||||
-- end
|
||||
|
||||
feature -- Access
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_value_valid: BOOLEAN
|
||||
do
|
||||
-- FIX ME !!!
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Update the screen representation (ie `static'). This feature
|
||||
-- is not called directly from Current; it is called by
|
||||
-- JJJ_CONTROL.`set_value'.
|
||||
do
|
||||
static.set_text (parser.to_string (value_imp))
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
increment_data
|
||||
-- Increase the data by one unit. Unit is based
|
||||
-- on position of caret within the edit box.
|
||||
do
|
||||
change_data (1)
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
decrement_data
|
||||
-- Decrease the data by one unit. Unit is based
|
||||
-- on position of caret within the edit box.
|
||||
do
|
||||
change_data (-1)
|
||||
change_actions.call ([])
|
||||
end
|
||||
|
||||
change_data (sign: INTEGER)
|
||||
-- Change the data by + or - one unit based on `sign'
|
||||
-- Update `value_imp'.
|
||||
require
|
||||
valid_sign: sign = 1 or sign = -1
|
||||
local
|
||||
pos: INTEGER
|
||||
h: INTEGER
|
||||
do
|
||||
pos := static.caret_position
|
||||
if parser.is_index_in_year_string (value_imp, pos) then
|
||||
value_imp.add_duration (One_year * sign)
|
||||
elseif parser.is_index_in_month_string (value_imp, pos) then
|
||||
value_imp.add_duration (One_month * sign)
|
||||
elseif parser.is_index_in_day_string (value_imp, pos) then
|
||||
value_imp.add_duration (One_day * sign)
|
||||
elseif parser.is_index_in_hour_string (value_imp, pos) then
|
||||
value_imp.add_duration (One_hour * sign)
|
||||
elseif parser.is_index_in_minute_string (value_imp, pos) then
|
||||
value_imp.add_duration (One_minute * sign)
|
||||
elseif parser.is_index_in_second_string (value_imp, pos) then
|
||||
value_imp.add_duration (One_second * sign)
|
||||
elseif parser.is_index_in_am_pm_string (value_imp, pos) then
|
||||
h := value_imp.hour
|
||||
h := h + 12
|
||||
if h >= 24 then
|
||||
h := h - 24
|
||||
end
|
||||
value_imp.set_hour (h)
|
||||
else
|
||||
end
|
||||
draw
|
||||
static.set_caret_position (pos)
|
||||
end
|
||||
|
||||
on_key_press (a_key: EV_KEY)
|
||||
-- Process a key pressed in static
|
||||
do
|
||||
if a_key.code = Key_up then
|
||||
increment_data
|
||||
static.set_caret_position ((static.caret_position - 1).max (0))
|
||||
-- to move the caret back after the key press
|
||||
-- otherwise it move forward one position.
|
||||
elseif a_key.code = Key_down then
|
||||
decrement_data
|
||||
static.set_caret_position ((static.caret_position + 1).max (0))
|
||||
-- to move the caret back after the key press
|
||||
-- otherwise it move forward one position.
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
open_calendar_dialog
|
||||
-- Open a caladar for selecting a date.
|
||||
do
|
||||
calendar_tool.set_date (value)
|
||||
calendar_tool.show
|
||||
calendar_tool.raise
|
||||
-- calendar_tool.enable_capture
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
value_imp: YMDHMS_TIME
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
|
||||
static: EV_TEXT_FIELD
|
||||
|
||||
up_button: EV_BUTTON
|
||||
|
||||
down_button: EV_BUTTON
|
||||
|
||||
calendar_button: EV_BUTTON
|
||||
-- Opens a calendar for selecting a date.
|
||||
|
||||
calendar_tool: EV_COLOR_DIALOG
|
||||
-- temp fix just to do something; empliment a calendar dialog
|
||||
-- Used to select a date
|
||||
once
|
||||
create Result
|
||||
Result.disable_user_resize
|
||||
end
|
||||
|
||||
parser: YMD_TIME_PARSER
|
||||
-- parser: YMDHMS_PARSER
|
||||
-- For converting dates to and from strings
|
||||
|
||||
end
|
44
jj_vision/unfinished/ymdhms_time_field.e
Normal file
44
jj_vision/unfinished/ymdhms_time_field.e
Normal file
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
YMDHMS_TIME_FIELD
|
||||
|
||||
inherit
|
||||
|
||||
FIELD
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
default_create
|
||||
do
|
||||
Precursor {FIELD}
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
data: YMDHMS_INTERVAL
|
||||
once
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: YMDHMS_TIME_CONTROL
|
||||
do
|
||||
create Result
|
||||
-- Result.set_data (data)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
Reference in New Issue
Block a user