init
This commit is contained in:
21
jj_vision/interface/commands/add_field_command.e
Normal file
21
jj_vision/interface/commands/add_field_command.e
Normal file
@@ -0,0 +1,21 @@
|
||||
note
|
||||
description: "[
|
||||
{COMMAND} to add a field to a {SCHEMA}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/add_field_command.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
ADD_FIELD_COMMAND
|
||||
|
||||
inherit
|
||||
EDIT_COMMAND
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
153
jj_vision/interface/commands/change_fields_command.e
Normal file
153
jj_vision/interface/commands/change_fields_command.e
Normal file
@@ -0,0 +1,153 @@
|
||||
note
|
||||
description: "[
|
||||
Used by {EDIT_TOOL} to add or remove a {FIELD} in a {SCHEMA}.
|
||||
Note: this is not to be confused with {EDIT_COMMAND} which is used
|
||||
to change the "data" in a record or to change the positioning of a
|
||||
{FIELD}; this changes the {SCHEMA} itself.
|
||||
]"
|
||||
date: "6 Oct 07"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/change_fields_command.e $"
|
||||
date: "$Date: 2013-04-25 18:11:22 -0400 (Thu, 25 Apr 2013) $"
|
||||
revision: "$Revision: 14 $"
|
||||
|
||||
class
|
||||
CHANGE_FIELDS_COMMAND
|
||||
|
||||
inherit
|
||||
|
||||
JJ_COMMAND
|
||||
redefine
|
||||
text,
|
||||
affected_objects,
|
||||
execute,
|
||||
undo,
|
||||
is_executable,
|
||||
is_undoable
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_schema: like schema; a_field: like field)
|
||||
-- Create an instance
|
||||
do
|
||||
default_create
|
||||
schema := a_schema
|
||||
field := a_field
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
text: STRING
|
||||
-- Name of this command
|
||||
do
|
||||
Result := "Change schema"
|
||||
end
|
||||
|
||||
schema: SCHEMA
|
||||
-- The SCHEMA being changed
|
||||
|
||||
field: FIELD
|
||||
-- FIELD which identifies the "item" to be changed
|
||||
|
||||
affected_objects: LINKED_SET [ANY]
|
||||
-- Set of objects changable by this command
|
||||
do
|
||||
Result := Precursor {JJ_COMMAND}
|
||||
Result.extend (schema)
|
||||
Result.extend (field)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_schema (a_schema: like schema)
|
||||
-- Change `schema'
|
||||
require
|
||||
schema_exists: a_schema /= Void
|
||||
do
|
||||
schema := a_schema
|
||||
ensure
|
||||
schema_assigned: schema = a_schema
|
||||
end
|
||||
|
||||
set_field (a_field: FIELD)
|
||||
-- Change `field'
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
do
|
||||
field := a_field
|
||||
ensure
|
||||
field_assigned: field = a_field
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute
|
||||
-- Perform the command
|
||||
do
|
||||
Precursor {JJ_COMMAND}
|
||||
schema.time_modified.set_now_utc_fine
|
||||
if is_delete_command then
|
||||
schema.start
|
||||
schema.prune (field)
|
||||
else
|
||||
schema.extend (field)
|
||||
end
|
||||
end
|
||||
|
||||
undo
|
||||
-- Undo the command
|
||||
do
|
||||
Precursor {JJ_COMMAND}
|
||||
schema.time_modified.set_now_utc_fine
|
||||
if is_delete_command then
|
||||
schema.extend (field)
|
||||
else
|
||||
schema.start
|
||||
schema.prune (field)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_executable: BOOLEAN
|
||||
-- Can the command be executed?
|
||||
do
|
||||
Result := Precursor {JJ_COMMAND} and then
|
||||
(schema /= Void and field /= Void) and then
|
||||
(is_delete_command implies schema.has (field))
|
||||
end
|
||||
|
||||
is_undoable: BOOLEAN
|
||||
-- Can the command be undone?
|
||||
do
|
||||
Result := PRECURSOR {JJ_COMMAND} and then
|
||||
(schema /= Void and then field /= Void) and then
|
||||
(is_delete_command implies not schema.has (field))
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_delete_action
|
||||
-- Make this command delete `field' from `schema' when `execute' is called.
|
||||
do
|
||||
is_delete_command := True
|
||||
end
|
||||
|
||||
set_add_action
|
||||
-- Make this command add `field' to `schema' when `execute' is called.
|
||||
do
|
||||
is_delete_command := False
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
is_delete_command: BOOLEAN
|
||||
-- Is this command to be used to delete `field' from `schema'?
|
||||
|
||||
end
|
217
jj_vision/interface/commands/command_manager.e
Normal file
217
jj_vision/interface/commands/command_manager.e
Normal file
@@ -0,0 +1,217 @@
|
||||
note
|
||||
description: "[
|
||||
Objects used by {JJ_APPLICATION} to allow commands to be
|
||||
undone and redone.
|
||||
]"
|
||||
date: "2 Oct 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/command_manager.e $"
|
||||
date: "$Date: 2012-07-01 01:30:44 -0400 (Sun, 01 Jul 2012) $"
|
||||
revision: "$Revision: 12 $"
|
||||
|
||||
class
|
||||
COMMAND_MANAGER
|
||||
|
||||
inherit
|
||||
|
||||
SHARED
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
LINKED_LIST [JJ_COMMAND]
|
||||
export
|
||||
{LINKED_LIST}
|
||||
all
|
||||
-- {NONE}
|
||||
-- all
|
||||
-- {LINKED_LIST}
|
||||
-- start,
|
||||
-- forth,
|
||||
-- first_element,
|
||||
-- last_element,
|
||||
-- count,
|
||||
-- object_comparison,
|
||||
-- cursor,
|
||||
-- go_to,
|
||||
-- index
|
||||
{ANY}
|
||||
wipe_out,
|
||||
prunable,
|
||||
-- item,
|
||||
is_empty,
|
||||
-- readable,
|
||||
-- off,
|
||||
has,
|
||||
is_equal
|
||||
-- standard_is_equal,
|
||||
-- copy,
|
||||
-- same_type
|
||||
redefine
|
||||
default_create,
|
||||
wipe_out
|
||||
end
|
||||
|
||||
create
|
||||
default_create, make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
make
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
marked_index: INTEGER
|
||||
-- Mark the command at current `last_executed_index'
|
||||
|
||||
last_executed_index: INTEGER
|
||||
-- Index of last executed (and next undoable) command.
|
||||
|
||||
command: JJ_COMMAND
|
||||
-- Last inserted command.
|
||||
require
|
||||
not_empty: not is_empty
|
||||
do
|
||||
Result := i_th (last_executed_index)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
add_command (a_command: JJ_COMMAND)
|
||||
-- Remove any commands which have been undone (they will not be
|
||||
-- executable after `a_command' is added), then add `a command'
|
||||
-- to the list and execute it.
|
||||
require
|
||||
not_has_command: not has (a_command)
|
||||
do
|
||||
from go_i_th (last_executed_index + 1)
|
||||
until after or else is_empty
|
||||
loop
|
||||
remove
|
||||
end
|
||||
extend (a_command)
|
||||
execute
|
||||
check
|
||||
last_executed_index = index_of (a_command, 1)
|
||||
end
|
||||
ensure
|
||||
command_added: has (a_command)
|
||||
command_executed: last_executed_index = count
|
||||
end
|
||||
|
||||
set_mark
|
||||
-- Save a reference to the currently undoable command.
|
||||
-- Useful for marking the command state at which a
|
||||
-- system was saved.
|
||||
do
|
||||
marked_index := last_executed_index
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_undoable: BOOLEAN
|
||||
-- Can a command be undone?
|
||||
do
|
||||
Result := last_executed_index > 0
|
||||
end
|
||||
|
||||
is_executable: BOOLEAN
|
||||
-- Is there a command which can be executed?
|
||||
-- That is, was one previousely undone or added?
|
||||
do
|
||||
Result := last_executed_index + 1 <= count
|
||||
end
|
||||
|
||||
is_at_marked_state: BOOLEAN
|
||||
-- Is the cursor at item which was marked_index.
|
||||
-- Useful for marking and checking if / when a system was saved.
|
||||
do
|
||||
Result := last_executed_index = marked_index
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
wipe_out
|
||||
-- Remove all commands from Current, erasing history.
|
||||
do
|
||||
Precursor
|
||||
last_executed_index := 0
|
||||
marked_index := 0
|
||||
end
|
||||
|
||||
execute
|
||||
-- Execute the command at `last_executed_index'.
|
||||
require
|
||||
can_execute_a_command: is_executable
|
||||
local
|
||||
v: VIEW
|
||||
c: JJ_COMMAND
|
||||
do
|
||||
last_executed_index := last_executed_index + 1
|
||||
c := i_th (last_executed_index)
|
||||
c.execute
|
||||
-- Persistence_manager.extend_objects (c.affected_objects)
|
||||
-- Get a view so the views with the objects changed
|
||||
-- by executing the command can be updated.
|
||||
v := main_windows.first
|
||||
-- v.notify_views_with_set (c.affected_objects)
|
||||
v.draw_views_with_set (c.affected_objects)
|
||||
-- Call `set_widget_states' to update the undo, redo, and save, etc. buttons.
|
||||
main_windows.do_all (agent {JJ_MAIN_WINDOW}.set_widget_states)
|
||||
ensure
|
||||
last_executed_index_incremented: last_executed_index = old last_executed_index + 1
|
||||
end
|
||||
|
||||
undo
|
||||
-- Reverse execute the last command.
|
||||
require
|
||||
can_undo_a_command: is_undoable
|
||||
local
|
||||
v: VIEW
|
||||
c: JJ_COMMAND
|
||||
do
|
||||
-- Get the command at the current index and undo it.
|
||||
c := i_th (last_executed_index)
|
||||
c.undo
|
||||
last_executed_index := last_executed_index - 1
|
||||
-- persistence_manager.extend_objects (c.affected_objects)
|
||||
-- Need to get a view so the views with the objects changed
|
||||
-- by undoing the command can be updated.
|
||||
v := main_windows.first
|
||||
-- v.notify_views_with_set (c.affected_objects)
|
||||
v.draw_views_with_set (c.affected_objects)
|
||||
-- Call `set_widget_states' to update the undo, redo, and save, etc. buttons.
|
||||
main_windows.do_all (agent {JJ_MAIN_WINDOW}.set_widget_states)
|
||||
ensure
|
||||
last_executed_index_decremented: last_executed_index = old last_executed_index - 1
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (Handles to "global" application objects)
|
||||
|
||||
-- Persistence_manager: PERSISTENCE_MANAGER is
|
||||
-- -- Handle (for convinience) to the JJ_APPLICATION's `persistence_manager'.
|
||||
-- local
|
||||
-- app: JJ_APPLICATION
|
||||
-- once
|
||||
-- app ?= (create {EV_ENVIRONMENT}).application
|
||||
-- check
|
||||
-- app /= Void
|
||||
-- -- Because this class if for use by a JJ_APPLICATION
|
||||
-- end
|
||||
-- Result := app.persistence_manager
|
||||
-- ensure
|
||||
-- result_exists: Result /= Void
|
||||
-- end
|
||||
|
||||
end
|
||||
|
149
jj_vision/interface/commands/edit_command.e
Normal file
149
jj_vision/interface/commands/edit_command.e
Normal file
@@ -0,0 +1,149 @@
|
||||
note
|
||||
description: "[
|
||||
Command used to change a field of an {EDITABLE}.
|
||||
]"
|
||||
date: "27 Jan 05"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/edit_command.e $"
|
||||
date: "$Date: 2013-04-25 18:11:22 -0400 (Thu, 25 Apr 2013) $"
|
||||
revision: "$Revision: 14 $"
|
||||
|
||||
class
|
||||
EDIT_COMMAND
|
||||
|
||||
inherit
|
||||
|
||||
JJ_COMMAND
|
||||
redefine
|
||||
text,
|
||||
affected_objects,
|
||||
execute,
|
||||
undo,
|
||||
is_executable,
|
||||
is_undoable
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_record: like record; a_field: like field; a_value: like value)
|
||||
-- Initialize Current
|
||||
do
|
||||
default_create
|
||||
record := a_record
|
||||
field := a_field
|
||||
value := a_value
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
text: STRING
|
||||
-- Name of this command
|
||||
do
|
||||
Result := "Edit record"
|
||||
end
|
||||
|
||||
record: EDITABLE
|
||||
-- Object to be changed.
|
||||
|
||||
field: FIELD
|
||||
-- FIELD which identifies the "item" to be changed
|
||||
|
||||
value: ANY
|
||||
-- New value
|
||||
|
||||
affected_objects: LINKED_SET [ANY]
|
||||
-- Set of objects changable by this command
|
||||
do
|
||||
create Result.make
|
||||
Result.extend (record)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_record (a_record: like record)
|
||||
-- Change `record'
|
||||
require
|
||||
record_exists: a_record /= Void
|
||||
do
|
||||
record := a_record
|
||||
ensure
|
||||
record_assigned: record = a_record
|
||||
end
|
||||
|
||||
set_field (a_field: FIELD)
|
||||
-- Change `field'
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
do
|
||||
field := a_field
|
||||
ensure
|
||||
field_assigned: field = a_field
|
||||
end
|
||||
|
||||
set_value (a_value: ANY)
|
||||
-- Change `value'.
|
||||
require
|
||||
value_exists: a_value /= Void
|
||||
do
|
||||
value := a_value
|
||||
ensure
|
||||
value_assigned: value = a_value
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute
|
||||
-- Perform the command
|
||||
do
|
||||
if record.has_value (field.label) then
|
||||
old_field := field
|
||||
old_value := record.value (field.label)
|
||||
end
|
||||
record.extend_value (value, field.label)
|
||||
Precursor {JJ_COMMAND}
|
||||
end
|
||||
|
||||
undo
|
||||
-- Undo the command
|
||||
do
|
||||
if attached old_field as of then
|
||||
record.extend_value (of, field.label)
|
||||
else
|
||||
record.remove_value (field.label)
|
||||
end
|
||||
Precursor {JJ_COMMAND}
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_executable: BOOLEAN
|
||||
-- Can the command be executed?
|
||||
do
|
||||
Result := Precursor {JJ_COMMAND} and then
|
||||
record /= Void and field /= Void and value /= Void
|
||||
end
|
||||
|
||||
is_undoable: BOOLEAN
|
||||
-- Can the command be undone?
|
||||
do
|
||||
Result := Precursor {JJ_COMMAND} and then
|
||||
(record /= Void and (old_field /= Void implies old_value /= Void)) and
|
||||
record.has_value (field.label)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
old_value: detachable ANY
|
||||
-- Hold on to the old value in case of `undo'
|
||||
|
||||
old_field: detachable FIELD
|
||||
-- Hold the old field. If Void we know that the record previously
|
||||
-- did not have a field for the one just added by `execute', so
|
||||
-- `undo' will remove `field'.
|
||||
|
||||
end
|
126
jj_vision/interface/commands/edit_schema_command.e
Normal file
126
jj_vision/interface/commands/edit_schema_command.e
Normal file
@@ -0,0 +1,126 @@
|
||||
note
|
||||
description: "[
|
||||
Used by {EDIT_TOOL} to change a {FIELD} in a {SCHEMA}.
|
||||
Note: this is not to be confused with {EDIT_COMMAND} which is used
|
||||
to change the "data" in a record or to change the positioning of a
|
||||
{FIELD}; this changes the {SCHEMA} itself.
|
||||
]"
|
||||
date: "16 Mar 06"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/edit_schema_command.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
EDIT_SCHEMA_COMMAND
|
||||
|
||||
inherit
|
||||
|
||||
EDIT_COMMAND
|
||||
redefine
|
||||
make,
|
||||
text,
|
||||
affected_objects,
|
||||
execute,
|
||||
undo,
|
||||
is_executable,
|
||||
is_undoable
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_record: like record; a_field: like field; a_value: like value)
|
||||
-- Initialize Current
|
||||
do
|
||||
Precursor (a_record, a_field, a_value)
|
||||
create schema
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
text: STRING
|
||||
-- Name of this command
|
||||
do
|
||||
Result := "Edit schema"
|
||||
end
|
||||
|
||||
schema: SCHEMA
|
||||
-- The SCHEMA being changed
|
||||
|
||||
affected_objects: LINKED_SET [ANY]
|
||||
-- Set of objects changable by this command
|
||||
do
|
||||
Result := Precursor {EDIT_COMMAND}
|
||||
Result.extend (schema)
|
||||
Result.extend (field)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_schema (a_schema: like schema)
|
||||
-- Change `schema'
|
||||
require
|
||||
schema_exists: a_schema /= Void
|
||||
do
|
||||
schema := a_schema
|
||||
ensure
|
||||
schema_assigned: schema = a_schema
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute
|
||||
-- Perform the command
|
||||
do
|
||||
schema.time_modified.set_now_utc_fine
|
||||
Precursor {EDIT_COMMAND}
|
||||
end
|
||||
|
||||
undo
|
||||
-- Undo the command
|
||||
do
|
||||
schema.time_modified.set_now_utc_fine
|
||||
Precursor {EDIT_COMMAND}
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_executable: BOOLEAN
|
||||
-- Can the command be executed?
|
||||
do
|
||||
Result := Precursor {EDIT_COMMAND} and then
|
||||
(schema /= Void and field /= Void)
|
||||
end
|
||||
|
||||
is_undoable: BOOLEAN
|
||||
-- Can the command be undone?
|
||||
do
|
||||
Result := PRECURSOR {EDIT_COMMAND} and then
|
||||
(schema /= Void and field /= Void)
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_delete_action
|
||||
-- Make this command delete `field' from `schema' when `execute' is called.
|
||||
do
|
||||
is_delete_command := True
|
||||
end
|
||||
|
||||
set_add_action
|
||||
-- Make this command add `field' to `schema' when `execute' is called.
|
||||
do
|
||||
is_delete_command := False
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
is_delete_command: BOOLEAN
|
||||
-- Is this command to be used to delete `field' from `schema'?
|
||||
|
||||
end
|
102
jj_vision/interface/commands/jj_command.e
Normal file
102
jj_vision/interface/commands/jj_command.e
Normal file
@@ -0,0 +1,102 @@
|
||||
note
|
||||
description: "[
|
||||
Root class for commands, allowing undo and redo, and to
|
||||
facilitate history functions.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/commands/jj_command.e $"
|
||||
date: "$Date: 2014-06-15 09:17:19 -0400 (Sun, 15 Jun 2014) $"
|
||||
revision: "$Revision: 18 $"
|
||||
|
||||
class
|
||||
JJ_COMMAND
|
||||
|
||||
inherit
|
||||
|
||||
ANY
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Set up the command
|
||||
do
|
||||
create explanation.make
|
||||
create affected_objects_imp.make
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
text: STRING
|
||||
-- Texual representation of what the command does.
|
||||
do
|
||||
Result := "do nothing"
|
||||
end
|
||||
|
||||
explanation: LINKED_LIST [STRING]
|
||||
-- List of reasons why a command was not executed or undone
|
||||
-- Can be queried after a call to `is_executable' or `is_undoable'
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute
|
||||
-- Execute the action represented by the command.
|
||||
require
|
||||
executable: is_executable
|
||||
do
|
||||
was_executed := True
|
||||
end
|
||||
|
||||
undo
|
||||
-- Reverse the action performed in `execute'.
|
||||
require
|
||||
undoable: is_undoable
|
||||
do
|
||||
was_executed := False
|
||||
end
|
||||
|
||||
affected_objects: LINKED_SET [ANY]
|
||||
-- List of object whose views must be updated
|
||||
do
|
||||
Result := affected_objects_imp
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_executable: BOOLEAN
|
||||
-- Can the command be executed?
|
||||
do
|
||||
explanation.wipe_out
|
||||
Result := not was_executed
|
||||
if not Result then
|
||||
explanation.extend ("Command already executed")
|
||||
end
|
||||
end
|
||||
|
||||
is_undoable: BOOLEAN
|
||||
-- Can the command be undone?
|
||||
do
|
||||
explanation.wipe_out
|
||||
Result := was_executed
|
||||
if not Result then
|
||||
explanation.extend ("Command not yet executed")
|
||||
end
|
||||
end
|
||||
|
||||
was_executed: BOOLEAN
|
||||
-- Has the command been executed?
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
affected_objects_imp: like affected_objects
|
||||
-- List of objects affected by Current
|
||||
|
||||
end
|
||||
|
44
jj_vision/interface/controls/comparable_control.e
Normal file
44
jj_vision/interface/controls/comparable_control.e
Normal file
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "[
|
||||
A {CONTROL} which allows the editting of a {COMPARABLE}.
|
||||
]"
|
||||
date: "24 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2009, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/comparable_control.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
deferred class
|
||||
COMPARABLE_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
CONTROL
|
||||
redefine
|
||||
value,
|
||||
default_field
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: COMPARABLE
|
||||
-- A new object represented by the display.
|
||||
-- Define to convert the display into the
|
||||
-- desired type.
|
||||
do
|
||||
check attached {COMPARABLE} Precursor as c then
|
||||
Result := c
|
||||
end
|
||||
end
|
||||
|
||||
feature {FIELD_EDITOR_VIEW} -- Implementation
|
||||
|
||||
default_field: COMPARABLE_FIELD
|
||||
-- Create a field to be used if Current was `default_create'd.
|
||||
-- The anchor for `field'.
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
455
jj_vision/interface/controls/control.e
Normal file
455
jj_vision/interface/controls/control.e
Normal file
@@ -0,0 +1,455 @@
|
||||
note
|
||||
description: "[
|
||||
Used with {EDITOR} classes to make EV_WIDGETs for displaying and
|
||||
editting an object. It is composed of an EV_TEXT_FIELD, `display'
|
||||
and an optional EV_LABEL, `label' which can be positioned to the
|
||||
top, left, right, or bottom of the `display'.
|
||||
|
||||
A {CONTROL} can be created normally with `default_create' or using
|
||||
`create_from_field'. Feature `create_from_field' is used to allow
|
||||
creation of controls from a {SCHEMA} (a list of {FIELD}) for placement
|
||||
in an {DIALOG_EDITOR_VIEW} (a form maker). Features from `field' can
|
||||
then be used to determine placement, size, etc for the {CONTROL}.
|
||||
|
||||
The object to be editted is placed into the control with feature
|
||||
`set_data' and is stored in `data' from ANY. The current `value'
|
||||
of the object can be obtained if `is_display_valid'. Feature
|
||||
`is_display_valid' is True when the string displayed in the `text'
|
||||
field of `display' can be converted into an object of the correct
|
||||
type. This convertion is ultimately done by feature `string_to_type'
|
||||
from class FIELD through `field'.
|
||||
]"
|
||||
instructions: "[
|
||||
To allow the editting of objects of types other than STRING, redefine
|
||||
`default_field', or create an heir of {FIELD}, redefine `type'.
|
||||
|
||||
Feature `draw' takes care of checking the `values' type and putting
|
||||
into `display' the appropriate string if the type of the `value'
|
||||
does not conform to the control, or if there is no data, etc. If
|
||||
the data is good then `draw_display' is called to show the actual
|
||||
data. Therefore, do not redefine `draw'; redefine `draw_data'.
|
||||
]"
|
||||
date: "5 Mar 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2009, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/control.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
deferred class
|
||||
CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
EV_STOCK_COLORS
|
||||
rename
|
||||
implementation as colors_implementation
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
-- Current must be an EV_WIDGET of some sort in order to be placed into
|
||||
-- and EV_CONTAINER. That's the whole point; do not delete EV_FIXED
|
||||
-- without adding some other widget.
|
||||
EV_FIXED
|
||||
redefine
|
||||
set_data,
|
||||
initialize,
|
||||
create_interface_objects,
|
||||
destroy,
|
||||
is_destroyed,
|
||||
is_in_default_state
|
||||
-- enable_sensitive,
|
||||
-- disable_sensitive,
|
||||
-- is_sensitive
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {EV_FIXED}
|
||||
create valid_change_actions
|
||||
create select_actions
|
||||
create label
|
||||
create display
|
||||
field := Default_field
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the control
|
||||
do
|
||||
Precursor {EV_FIXED}
|
||||
label.set_minimum_width (1)
|
||||
label.set_minimum_height (1)
|
||||
display.set_minimum_height (20)
|
||||
display.set_minimum_width (50)
|
||||
extend (label)
|
||||
extend (display)
|
||||
-- descendents must create the `display'
|
||||
-- and set_actions for display.
|
||||
label_position := Label_top
|
||||
label.set_pebble_function (agent get_field)
|
||||
-- label.set_drag_and_drop_mode
|
||||
set_actions
|
||||
field.control_list.extend (Current)
|
||||
end
|
||||
|
||||
make_from_field (a_field: like field)
|
||||
-- Create a control using the values in `a_field'.
|
||||
do
|
||||
default_create
|
||||
field := a_field
|
||||
field.control_list.extend (Current)
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the controls of Current.
|
||||
do
|
||||
display.change_actions.extend (agent on_display_changed)
|
||||
label.pointer_button_press_actions.extend (agent on_control_selected)
|
||||
display.pointer_button_press_actions.extend (agent on_control_selected)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: ANY
|
||||
-- A new object created from the `text' in `display'.
|
||||
-- Normally only redefine to change the result type by using an
|
||||
-- assignment attempt on Precursor. This is to to preserve
|
||||
-- the "definition" post-condition.
|
||||
require
|
||||
display_is_valid: is_display_valid
|
||||
do
|
||||
Result := field.string_to_type (display.text)
|
||||
ensure
|
||||
valid_result: Result /= Void
|
||||
definition: equal (Result, field.string_to_type (display.text))
|
||||
end
|
||||
|
||||
field: like Default_field
|
||||
-- Dictates appearanced of current Control
|
||||
-- Redefine `Default_field' to change the type.
|
||||
|
||||
valid_change_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be called when this control changes to a valid value.
|
||||
|
||||
select_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be called when this control is selected
|
||||
|
||||
feature -- Element change
|
||||
|
||||
frozen set_data (a_data: ANY)
|
||||
-- Pass in any type of object and display the string representation
|
||||
-- of it by calling `refresh'.
|
||||
-- The argument can be Void as it will be checked on `refresh' and
|
||||
-- the control will so indicate.
|
||||
do
|
||||
Precursor {EV_FIXED} (a_data)
|
||||
refresh
|
||||
end
|
||||
|
||||
set_label_top
|
||||
-- Make the 'label' appear to the top of the `display'
|
||||
do
|
||||
label_position := Label_top
|
||||
ensure
|
||||
label_position_correct: label_position = Label_top
|
||||
end
|
||||
|
||||
set_label_bottom
|
||||
-- Make the 'label' appear to the bottom of the `display'
|
||||
do
|
||||
label_position := Label_bottom
|
||||
ensure
|
||||
label_position_correct: label_position = Label_bottom
|
||||
end
|
||||
|
||||
set_label_left
|
||||
-- Make the `label' appear to the left of the `display'.
|
||||
do
|
||||
label_position := Label_left
|
||||
ensure
|
||||
label_position_correct: label_position = Label_left
|
||||
end
|
||||
|
||||
set_label_right
|
||||
-- Make the 'label' appear to the right of the `display'
|
||||
do
|
||||
label_position := Label_right
|
||||
ensure
|
||||
label_position_correct: label_position = Label_right
|
||||
end
|
||||
|
||||
set_label_none
|
||||
-- Make the 'label' not appear at all. Make a labelless control.
|
||||
do
|
||||
label_position := Label_none
|
||||
ensure
|
||||
label_position_correct: label_position = Label_none
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
destroy
|
||||
-- Remove Current from the `control_list' in `field' when
|
||||
-- the underlying graphical object is destroyed.
|
||||
do
|
||||
Precursor {EV_FIXED}
|
||||
field.control_list.prune (Current)
|
||||
ensure then
|
||||
control_not_in_list: not field.control_list.has (Current)
|
||||
end
|
||||
|
||||
build
|
||||
-- Position and size the `label' and `display' based on
|
||||
-- values in `field'.
|
||||
local
|
||||
fh: INTEGER
|
||||
f: EV_FONT
|
||||
s_size: TUPLE [INTEGER, INTEGER]
|
||||
do
|
||||
label.set_text (field.label)
|
||||
set_item_height (label, (label.font.height).max (label.minimum_height))
|
||||
set_item_width (label, (label.font.string_width (label.text)).max (label.minimum_width))
|
||||
-- set_item_height (display, field.height.item.max (display.minimum_height))
|
||||
set_item_width (display, field.width.item.max (display.minimum_width))
|
||||
-- Set the height of the font in `display'.
|
||||
fh := field.height.item
|
||||
f := display.font.twin
|
||||
f.set_height (fh.max (1)) -- `max' to meet precondition h > 0
|
||||
display.set_font (f)
|
||||
-- Use any string because all I need is the height a string
|
||||
-- would be if it were displayed in that font. I can't use
|
||||
-- display.text because when the control is first built there
|
||||
-- may not be any text in it.
|
||||
s_size := f.string_size ("This is a STRING.")
|
||||
check attached {INTEGER_REF} s_size.item (2) as dh then
|
||||
-- because result of `string_size' is a TUPLE [INTEGER, INTEGER]
|
||||
set_item_height (display, dh.item.max (display.minimum_height))
|
||||
end
|
||||
-- Place the label in the correct possition.
|
||||
inspect
|
||||
label_position
|
||||
when Label_left then
|
||||
set_item_position (label, 0, 0)
|
||||
set_item_position (display, label.x_position + label.width, 0)
|
||||
set_minimum_width (label.width + display.width)
|
||||
set_minimum_height ((display.height).max (label.height))
|
||||
when Label_top then
|
||||
set_item_position (label, 0, 0)
|
||||
set_item_position (display, 0, label.font.height)
|
||||
set_minimum_width ((display.width).max (label.width))
|
||||
set_minimum_height (display.height + label.height)
|
||||
when Label_right then
|
||||
set_item_position (label, field.width.item.max (display.minimum_width), 0)
|
||||
set_item_position (display, 0, 0)
|
||||
set_minimum_width (label.width + display.width)
|
||||
set_minimum_height ((display.height).max (label.height))
|
||||
when Label_bottom then
|
||||
set_item_position (label, 0, field.height.item.max (display.minimum_height))
|
||||
set_item_position (display, 0, 0)
|
||||
set_minimum_width ((display.width).max (label.width))
|
||||
set_minimum_height (display.height + label.height)
|
||||
when Label_none then
|
||||
set_item_height (label, label.minimum_height)
|
||||
set_item_width (label, label.minimum_width)
|
||||
set_item_position (label, 0, 0)
|
||||
set_minimum_width (display.width)
|
||||
set_minimum_height (display.height)
|
||||
else
|
||||
check
|
||||
should_not_happen: False
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
frozen refresh
|
||||
-- Displays the string representation of `data'.
|
||||
-- Normally do not redefine; redefine `load_display' instead.
|
||||
do
|
||||
display.change_actions.block
|
||||
-- change_actions.block
|
||||
if field.is_calculated then
|
||||
-- display.disable_sensitive
|
||||
else
|
||||
display.enable_sensitive
|
||||
end
|
||||
if field.is_calculated then
|
||||
display.set_text ("{CONTROL}.refresh -- fix me")
|
||||
-- display.set_text (field.function_result_as_string)
|
||||
elseif attached data as d then
|
||||
display.set_text (field.type_to_string (d))
|
||||
else
|
||||
display.set_text ("Void")
|
||||
end
|
||||
build_colors
|
||||
-- change_actions.resume
|
||||
display.change_actions.resume
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
is_display_valid: BOOLEAN
|
||||
-- Is the representation in `display' valid for
|
||||
-- object of `Type' based on `field'?
|
||||
-- Default is True because assumes `Type' is an ANY.
|
||||
do
|
||||
Result := not equal (display.text, Void_representation) and then
|
||||
field.is_valid_data (display.text)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_in_default_state: BOOLEAN = True
|
||||
-- redefined to make it get past the Eiffel Vision2
|
||||
-- post condition of `default create'.
|
||||
|
||||
is_destroyed: BOOLEAN
|
||||
-- Is current usable as a widget?
|
||||
do
|
||||
Result := Precursor {EV_FIXED} and not field.control_list.has (Current)
|
||||
end
|
||||
|
||||
-- is_sensitive: BOOLEAN is
|
||||
-- -- Is the object sensitive to user input?
|
||||
-- do
|
||||
-- Result := display.is_sensitive
|
||||
-- end
|
||||
--
|
||||
--feature -- Status setting
|
||||
--
|
||||
-- enable_sensitive is
|
||||
-- -- Make the `display' sensitive to user input.
|
||||
-- do
|
||||
-- display.enable_sensitive
|
||||
-- end
|
||||
--
|
||||
-- disable_sensitive is
|
||||
-- -- Make the `display' unresponsive to user input.
|
||||
-- do
|
||||
-- display.disable_sensitive
|
||||
-- end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
load_display (a_value: STRING)
|
||||
-- Put `a_value' into `display'.
|
||||
-- This feature should be called when redefining.
|
||||
-- require
|
||||
-- value_exists: a_value /= Void
|
||||
do
|
||||
display.set_text (a_value.out)
|
||||
end
|
||||
|
||||
build_colors
|
||||
-- Change display to red if the `text' in `display'
|
||||
-- (not necessarilly the same `data' that is in
|
||||
-- Current) is not valid.
|
||||
do
|
||||
if is_display_valid then
|
||||
display.set_foreground_color (Black)
|
||||
else
|
||||
display.set_foreground_color (Red)
|
||||
end
|
||||
end
|
||||
|
||||
get_field: like field
|
||||
-- Getter function for `field' so can use `set_pebble_function'.
|
||||
-- `set_pebble_function' cannot take an attribute such as
|
||||
-- `field' as a parameter; it must be a function.
|
||||
do
|
||||
Result := field
|
||||
end
|
||||
|
||||
refresh_dependent_controls
|
||||
-- Refresh all other controls which are dependent on
|
||||
-- this one. Called when display changes.
|
||||
local
|
||||
c_list: LINKED_LIST [CONTROL]
|
||||
c: CONTROL
|
||||
do
|
||||
c_list := field.controls_dependent
|
||||
from c_list.start
|
||||
until c_list.exhausted
|
||||
loop
|
||||
c := c_list.item
|
||||
if c /= Current then
|
||||
c.refresh
|
||||
end
|
||||
c_list.forth
|
||||
end
|
||||
end
|
||||
|
||||
on_display_changed
|
||||
-- Update because something was done in the control
|
||||
do
|
||||
build_colors
|
||||
refresh_dependent_controls
|
||||
if is_display_valid then
|
||||
valid_change_actions.call ([Current])
|
||||
end
|
||||
end
|
||||
|
||||
on_control_selected (a_x, a_y, button: INTEGER;
|
||||
a_x_tilt, a_y_tilt, a_pressure: DOUBLE;
|
||||
a_screen_x, a_screen_y: INTEGER)
|
||||
-- Execute the agents in `select_actions'
|
||||
-- The parameters are ignored but are needed to match the
|
||||
-- signature of the `pointer_button_press_actions' of `display'.
|
||||
-- EV_ACTION_SEQUENCE [TUPLE [x, y, button: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER]]
|
||||
do
|
||||
select_actions.call ([Current])
|
||||
end
|
||||
|
||||
feature {FIELD_EDITOR_VIEW} -- Implementation
|
||||
|
||||
label: EV_LABEL
|
||||
-- Displays the name (`key') if `is_label_shown'
|
||||
|
||||
display: EV_TEXT_FIELD
|
||||
-- Displays the `value'.
|
||||
|
||||
label_position: INTEGER
|
||||
-- Where is the label displayed? (top,
|
||||
-- bottom, left, or right of the `display'.
|
||||
|
||||
Label_top, Label_bottom, Label_left, Label_right, Label_none: INTEGER = unique
|
||||
-- Position of `label' in relation to display
|
||||
|
||||
default_field: FIELD
|
||||
-- Create a field to be used if Current was `default_create'd.
|
||||
-- The anchor for `field'.
|
||||
deferred
|
||||
end
|
||||
|
||||
Void_representation: STRING_32
|
||||
-- A string with the value "Void".
|
||||
once
|
||||
create Result.make_from_string ("Void")
|
||||
ensure
|
||||
definition: equal (Result, ("Void").as_string_32)
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
field_exists: field /= Void
|
||||
label_exists: label /= Void
|
||||
display_exists: display /= Void
|
||||
select_actions_exists: select_actions /= Void
|
||||
valid_change_actions_exists: valid_change_actions /= Void
|
||||
|
||||
in_control_list_if_not_destroyed: not is_destroyed implies field.control_list.has (Current)
|
||||
not_in_control_list_if_destroyed: is_destroyed implies not field.control_list.has (Current)
|
||||
|
||||
is_sensitive_definition: is_sensitive implies display.is_sensitive
|
||||
|
||||
end
|
102
jj_vision/interface/controls/integer_control.e
Normal file
102
jj_vision/interface/controls/integer_control.e
Normal file
@@ -0,0 +1,102 @@
|
||||
note
|
||||
description: "[
|
||||
A {CONTROL} for changing integers
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/integer_control.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
INTEGER_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
SPIN_CONTROL
|
||||
redefine
|
||||
initialize,
|
||||
value,
|
||||
set_actions,
|
||||
increment,
|
||||
decrement
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_from_field
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Set up the object
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
delta := 1
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the `display'.
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: INTEGER_REF
|
||||
-- A new object represented by the string in the display.
|
||||
-- Redefine to convert the displayed string into the
|
||||
-- desired type.
|
||||
do
|
||||
check attached {INTEGER_REF} Precursor {SPIN_CONTROL} as c then
|
||||
Result := c
|
||||
end
|
||||
end
|
||||
|
||||
delta: INTEGER
|
||||
-- The amount to change `value' when one of the buttons is pressed.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_delta (a_delta: INTEGER)
|
||||
-- Change `delta'
|
||||
require
|
||||
positive_delta: a_delta > 0
|
||||
do
|
||||
delta := a_delta
|
||||
ensure
|
||||
delta_assigned: delta = a_delta
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
increment
|
||||
-- Increase the `value' by amount `step'.
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
set_data (value.item + delta)
|
||||
on_display_changed
|
||||
end
|
||||
|
||||
decrement
|
||||
-- Decrease the `value' by amount `step'.
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
set_data (value.item - delta)
|
||||
on_display_changed
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
default_field: INTEGER_FIELD
|
||||
-- Dictates appearanced of current Control
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
positive_delta: delta > 0
|
||||
|
||||
end
|
212
jj_vision/interface/controls/spin_control.e
Normal file
212
jj_vision/interface/controls/spin_control.e
Normal file
@@ -0,0 +1,212 @@
|
||||
note
|
||||
description: "[
|
||||
A {CONTROL} that adds an `increment_button' and a `decrement_button'
|
||||
which the user can press to increase or decrease the `value'.
|
||||
Feature `increment' and `decrement' must be redefined to change
|
||||
`value', but call the Precursors to make the buttons repeat.
|
||||
]"
|
||||
date: "23 Aug 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/spin_control.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
deferred class
|
||||
SPIN_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
COMPARABLE_CONTROL
|
||||
redefine
|
||||
initialize,
|
||||
create_interface_objects,
|
||||
set_actions,
|
||||
build
|
||||
-- enable_sensitive,
|
||||
-- disable_sensitive,
|
||||
-- is_sensitive
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Set up the control
|
||||
do
|
||||
extend (increment_button)
|
||||
extend (decrement_button)
|
||||
show_buttons
|
||||
Precursor {COMPARABLE_CONTROL}
|
||||
end
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {COMPARABLE_CONTROL}
|
||||
create timeout
|
||||
create increment_button
|
||||
create decrement_button
|
||||
timeout.set_interval (500) -- one-half a second?
|
||||
increment_button.set_text ("+")
|
||||
decrement_button.set_text ("-")
|
||||
increment_button.set_minimum_width (10)
|
||||
decrement_button.set_minimum_width (10)
|
||||
increment_button.set_minimum_height (1)
|
||||
decrement_button.set_minimum_height (1)
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the buttons.
|
||||
do
|
||||
Precursor {COMPARABLE_CONTROL}
|
||||
-- To make the spin function work `increment' and `decrement' actions are
|
||||
-- added, not to the buttons, but to a timer which will be started and killed
|
||||
-- when the appropriate button is pressed and released.
|
||||
-- `Force_extend' was used to bypass the signature for the agents.
|
||||
increment_button.pointer_button_press_actions.force_extend (agent start_timeout (agent increment))
|
||||
increment_button.pointer_button_release_actions.force_extend (agent kill_timeout)
|
||||
decrement_button.pointer_button_press_actions.force_extend (agent start_timeout (agent decrement))
|
||||
decrement_button.pointer_button_release_actions.force_extend (agent kill_timeout)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_buttons_hidden: BOOLEAN
|
||||
-- Are the `increment_button' and the `decrement_button'
|
||||
-- hidden from view?
|
||||
|
||||
-- is_sensitive: BOOLEAN is
|
||||
-- -- Can the control react to input?
|
||||
-- do
|
||||
-- Result := Precursor {COMPARABLE_CONTROL} and then
|
||||
-- increment_button.is_sensitive and
|
||||
-- decrement_button.is_sensitive
|
||||
-- end
|
||||
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
hide_buttons
|
||||
-- Make the `increment_button' and the `decrement_button'
|
||||
-- not appear in the control.
|
||||
do
|
||||
increment_button.hide
|
||||
decrement_button.hide
|
||||
end
|
||||
|
||||
show_buttons
|
||||
-- Make the `increment_button' and the `decrement_button'
|
||||
-- appear in the control.
|
||||
do
|
||||
increment_button.show
|
||||
decrement_button.show
|
||||
end
|
||||
|
||||
-- enable_sensitive is
|
||||
-- -- Make the `display' sensitive to user input.
|
||||
-- do
|
||||
-- -- Redefined to take care of the added buttons
|
||||
-- Precursor {COMPARABLE_CONTROL}
|
||||
-- increment_button.enable_sensitive
|
||||
-- decrement_button.enable_sensitive
|
||||
-- end
|
||||
--
|
||||
-- disable_sensitive is
|
||||
-- -- Make the `display' unresponsive to user input.
|
||||
-- do
|
||||
-- -- Redefined to take care of the added buttons
|
||||
-- Precursor {COMPARABLE_CONTROL}
|
||||
-- increment_button.disable_sensitive
|
||||
-- decrement_button.disable_sensitive
|
||||
-- end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
increment
|
||||
-- Intended to be redefined to increase the magnitude of `value'.
|
||||
-- Default function only sets the `timeout' to a shorter repeat interval.
|
||||
do
|
||||
timeout.set_interval (100)
|
||||
end
|
||||
|
||||
decrement
|
||||
-- Intended to be redefined to decrease the magnitude of `value'.
|
||||
-- Default function only sets the `timeout' to a shorter repeat interval.
|
||||
do
|
||||
timeout.set_interval (100)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
build
|
||||
-- Position the widgets
|
||||
local
|
||||
x, y: INTEGER
|
||||
h: INTEGER
|
||||
do
|
||||
Precursor {COMPARABLE_CONTROL}
|
||||
-- set the size of the buttons
|
||||
h := display.height // 2
|
||||
x := display.x_position + display.width
|
||||
y := display.y_position + (display.y_position // 2)
|
||||
if label_position = Label_right then
|
||||
x := x + label.x_position + label.width
|
||||
end
|
||||
set_item_position (increment_button, x, display.y_position)
|
||||
set_item_height (increment_button, h.max (increment_button.minimum_height))
|
||||
set_item_width (increment_button, h.max (increment_button.minimum_width))
|
||||
set_item_height (decrement_button, h.max (decrement_button.minimum_height))
|
||||
set_item_width (decrement_button, h.max (decrement_button.minimum_width))
|
||||
y := increment_button.y_position + increment_button.height
|
||||
set_item_position (decrement_button, x, y)
|
||||
set_minimum_width (minimum_width + increment_button.width)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
start_timeout (a_procedure: PROCEDURE)
|
||||
-- Calls `a_procedure' once and then sets up `timeout' to
|
||||
-- execute `a_procedure' repeatedly.
|
||||
require
|
||||
procedure_exists: a_procedure /= Void
|
||||
do
|
||||
a_procedure.call ([])
|
||||
timeout.set_interval (1000)
|
||||
timeout.actions.extend (a_procedure)
|
||||
end
|
||||
|
||||
kill_timeout
|
||||
-- Remove actions from the `timeout' so it does not
|
||||
-- continue to repeat even when the button is released.
|
||||
do
|
||||
timeout.actions.wipe_out
|
||||
timeout.reset_count
|
||||
end
|
||||
|
||||
increment_button: EV_BUTTON
|
||||
-- Press to increase the `value'
|
||||
|
||||
decrement_button: EV_BUTTON
|
||||
-- Press to decrease the `value'
|
||||
|
||||
timeout: EV_TIMEOUT
|
||||
-- Used when a button is held down.
|
||||
|
||||
invariant
|
||||
|
||||
-- ensure sure buttons are created
|
||||
increment_button_exists: increment_button /= Void
|
||||
decrement_button_exists: decrement_button /= Void
|
||||
timeout_exists: timeout /= Void
|
||||
|
||||
-- ensure buttons are part of current
|
||||
increment_button_in_current: has (increment_button)
|
||||
decrement_button_in_current: has (decrement_button)
|
||||
|
||||
is_sensitive_definition: is_sensitive implies increment_button.is_sensitive and
|
||||
decrement_button.is_sensitive
|
||||
|
||||
end
|
52
jj_vision/interface/controls/string_control.e
Normal file
52
jj_vision/interface/controls/string_control.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "[
|
||||
A {CONTROL} in which to edit strings
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/string_control.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
STRING_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
-- NOTE: do not inherit from other widgets such as EV_TEXT_FIELD. This
|
||||
-- causes too many clashes with EV_FIXED coming from CONTROL.
|
||||
-- I have gone up that path too many times. DO NOT DO IT AGAIN!
|
||||
|
||||
COMPARABLE_CONTROL
|
||||
redefine
|
||||
value
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_from_field
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: STRING_32
|
||||
-- A new object represented by the string in the display.
|
||||
-- Redefine to convert the displayed string into the
|
||||
-- desired type.
|
||||
do
|
||||
check attached {STRING_32} Precursor as c then
|
||||
Result := c
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
default_field: STRING_FIELD
|
||||
-- Dictates appearanced of current Control
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
end
|
48
jj_vision/interface/controls/string_field_schema.e
Normal file
48
jj_vision/interface/controls/string_field_schema.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
A {SCHEMA} that describes placement of a {INTEGER_FIELD}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/string_field_schema.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
STRING_FIELD_SCHEMA
|
||||
|
||||
inherit
|
||||
|
||||
FIELD_SCHEMA
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
create {LINKED_LIST}
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialize
|
||||
|
||||
default_create
|
||||
-- Create an instance
|
||||
do
|
||||
Precursor {FIELD_SCHEMA}
|
||||
extend (length_field)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
length_field: INTEGER_FIELD
|
||||
-- Create a field to store the `number_of_characters' of a FIELD
|
||||
once
|
||||
create Result
|
||||
Result.set_label ("Length")
|
||||
Result.set_x (30)
|
||||
Result.set_y (0)
|
||||
Result.set_width (50)
|
||||
end
|
||||
|
||||
end
|
111
jj_vision/interface/controls/ymd_time_control.e
Normal file
111
jj_vision/interface/controls/ymd_time_control.e
Normal file
@@ -0,0 +1,111 @@
|
||||
note
|
||||
description: "[
|
||||
Used with {EDITOR} classes to make EV_WIDGETs for displaying and
|
||||
editting data which is a {YMD_TIME}
|
||||
]"
|
||||
date: "7 Mar 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/controls/ymd_time_control.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
|
||||
class
|
||||
YMD_TIME_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
YMD_CONSTANTS
|
||||
undefine
|
||||
default_create,
|
||||
is_equal,
|
||||
copy
|
||||
end
|
||||
|
||||
SPIN_CONTROL
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
value,
|
||||
increment,
|
||||
decrement
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_from_field
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
set_delta (One_day)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the control
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
end
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: YMD_TIME
|
||||
-- A new object represented by the string in the display.
|
||||
-- Redefine to convert the displayed string into the
|
||||
-- desired type.
|
||||
do
|
||||
check attached {YMD_TIME} Precursor {SPIN_CONTROL} as c then
|
||||
Result := c
|
||||
end
|
||||
end
|
||||
|
||||
delta: YMD_DURATION
|
||||
-- The amount to change `value' when one of the buttons is pressed.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_delta (a_delta: like delta)
|
||||
-- Change `delta'
|
||||
require
|
||||
positive_delta: not a_delta.is_negative
|
||||
do
|
||||
delta := a_delta.twin
|
||||
ensure
|
||||
delta_assigned: equal (delta, a_delta)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
increment
|
||||
-- Increase the `value' by amount `step'.
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
set_data (value + delta)
|
||||
on_display_changed
|
||||
end
|
||||
|
||||
decrement
|
||||
-- Decrease the `value' by amount `step'.
|
||||
do
|
||||
Precursor {SPIN_CONTROL}
|
||||
set_data (value - delta)
|
||||
on_display_changed
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
default_field: YMD_TIME_FIELD
|
||||
-- Dictates appearanced of current Control
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
end
|
49
jj_vision/interface/fields/comparable_field.e
Normal file
49
jj_vision/interface/fields/comparable_field.e
Normal file
@@ -0,0 +1,49 @@
|
||||
note
|
||||
description: "[
|
||||
A {FIELD} used to create a control to edit a COMPARABLE.
|
||||
]"
|
||||
date: "24 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/comparable_field.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
|
||||
deferred class
|
||||
COMPARABLE_FIELD
|
||||
|
||||
inherit
|
||||
|
||||
FIELD
|
||||
redefine
|
||||
default_create,
|
||||
as_widget,
|
||||
Type
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
Precursor {FIELD}
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: COMPARABLE_CONTROL
|
||||
-- Each descendent class must create the appropriate control.
|
||||
-- Redefined to change the type.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature --
|
||||
|
||||
Type: COMPARABLE
|
||||
-- Anchor for `value'
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
483
jj_vision/interface/fields/field.e
Normal file
483
jj_vision/interface/fields/field.e
Normal file
@@ -0,0 +1,483 @@
|
||||
note
|
||||
description: "[
|
||||
Used with {EDITOR} classes.
|
||||
Object that describes how to create a {CONTROL}.
|
||||
]"
|
||||
date: "7 Mar 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/field.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
|
||||
deferred class
|
||||
FIELD
|
||||
|
||||
inherit
|
||||
|
||||
FIELD_CONSTANTS
|
||||
undefine
|
||||
default_create,
|
||||
is_equal
|
||||
end
|
||||
|
||||
EDITABLE
|
||||
redefine
|
||||
default_create,
|
||||
schema,
|
||||
is_schema_available,
|
||||
schema_imp,
|
||||
set_schema,
|
||||
remove_schema
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Initialize the object.
|
||||
do
|
||||
Precursor {EDITABLE}
|
||||
-- schema_imp := Field_schema
|
||||
-- Add the "data". The data is the lables and positions.
|
||||
set_label (Default_label_field_name)
|
||||
set_x (Default_x)
|
||||
set_y (Default_y)
|
||||
set_width (Default_width)
|
||||
set_height (Default_height)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
schema: FIELD_SCHEMA
|
||||
-- The schema used to display and edit a FIELD.
|
||||
once
|
||||
create Result
|
||||
Result.extend_mandatory (Label_field)
|
||||
Result.extend_mandatory (X_field)
|
||||
Result.extend_mandatory (Y_field)
|
||||
Result.extend_mandatory (Width_field)
|
||||
Result.extend_mandatory (Height_field)
|
||||
-- Result.set_up
|
||||
end
|
||||
|
||||
Type: ANY
|
||||
-- Anchor.
|
||||
deferred
|
||||
end
|
||||
|
||||
label: STRING_32
|
||||
-- Identifier of this field.
|
||||
do
|
||||
check attached {STRING_32} value (Default_label_field_name) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
x: INTEGER_REF
|
||||
-- x-position of field in a dialog
|
||||
do
|
||||
check attached {INTEGER_REF} value (Default_x_field_name) as i then
|
||||
Result := i
|
||||
end
|
||||
end
|
||||
|
||||
y: INTEGER_REF
|
||||
-- y-position of field in a dialog
|
||||
do
|
||||
check attached {INTEGER_REF} value (Default_y_field_name) as i then
|
||||
Result := i
|
||||
end
|
||||
end
|
||||
|
||||
width: INTEGER_REF
|
||||
-- Width of this field. Used to create a control
|
||||
-- that is `width' pixels wide.
|
||||
do
|
||||
check attached {INTEGER_REF} value (Default_width_field_name) as i then
|
||||
Result := i
|
||||
end
|
||||
end
|
||||
|
||||
height: INTEGER_REF
|
||||
-- Height of this field. Used to create a control
|
||||
-- that is `height' pixels tall.
|
||||
do
|
||||
check attached {INTEGER_REF} value (Default_height_field_name) as i then
|
||||
Result := i
|
||||
end
|
||||
end
|
||||
|
||||
-- format: STRING is
|
||||
-- -- Used to set how the data is displayed.
|
||||
-- do
|
||||
-- Result ?= value_by_field (format_field)
|
||||
-- ensure
|
||||
-- valid_result: Result /= Void
|
||||
-- end
|
||||
--
|
||||
-- posible_formats: LINKED_SET [STRING]
|
||||
-- -- Set of posible formats which can be used in `format'.
|
||||
--
|
||||
-- function: STRING_32
|
||||
-- -- Function to be assigned to any widget created from
|
||||
-- -- this field.
|
||||
-- do
|
||||
-- Result ?= value_by_field (schema.formula_field)
|
||||
-- ensure
|
||||
-- valid_result: Result /= Void
|
||||
-- end
|
||||
|
||||
-- function_result_as_string: STRING_32
|
||||
-- -- The result of executing the `function' converted to
|
||||
-- -- a string.
|
||||
-- local
|
||||
---- p: FUNCTION_PARSER
|
||||
-- r: ANY
|
||||
-- t: like Type
|
||||
-- do
|
||||
-- if function = Void then
|
||||
-- Result := "Value is calculated, but no formula entered."
|
||||
-- else
|
||||
---- p.parse_string (function)
|
||||
---- r := parser.last_value
|
||||
-- if r.same_type (Type) then
|
||||
-- t ?= r
|
||||
-- check
|
||||
-- should_not_happen: t /= Void
|
||||
-- -- Because `r.same_type' insures `r' conforms to `t'.
|
||||
-- end
|
||||
-- Result := type_to_string (t)
|
||||
-- else
|
||||
-- -- there was a parse error.
|
||||
-- Result ?= r
|
||||
-- check
|
||||
-- should_not_happen: Result /= Void
|
||||
-- -- Because parser should return an error string
|
||||
-- -- if it failed to get a good result.
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- function_result_as_type: like type
|
||||
-- -- The result of executing the `function'.
|
||||
-- require
|
||||
-- has_function: function /= Void
|
||||
-- function_works: is_valid_function (function)
|
||||
-- local
|
||||
---- p: FUNCTION_PARSER
|
||||
-- do
|
||||
---- p.parse_string (function)
|
||||
---- Result := p.last_value
|
||||
-- end
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_label (a_string: STRING_32)
|
||||
-- Change the `name'.
|
||||
require
|
||||
string_exists: a_string /= Void
|
||||
do
|
||||
extend_value (a_string, Default_label_field_name)
|
||||
ensure
|
||||
id_was_set: equal (label, a_string)
|
||||
end
|
||||
|
||||
set_x (a_x: INTEGER)
|
||||
do
|
||||
extend_value (a_x, Default_x_field_name)
|
||||
ensure
|
||||
x_was_set: x.item = a_x
|
||||
end
|
||||
|
||||
set_y (a_y: INTEGER)
|
||||
do
|
||||
extend_value (a_y, Default_y_field_name)
|
||||
ensure
|
||||
y_was_set: y.item = a_y
|
||||
end
|
||||
|
||||
set_width (a_width: INTEGER)
|
||||
-- Change `width'
|
||||
require
|
||||
valid_width: a_width > 0
|
||||
do
|
||||
extend_value (a_width, Default_width_field_name)
|
||||
ensure
|
||||
width_was_set: width.item = a_width
|
||||
end
|
||||
|
||||
set_height (a_height: INTEGER)
|
||||
-- Change `height'
|
||||
require
|
||||
valid_height: a_height > 0
|
||||
do
|
||||
extend_value (a_height, Default_height_field_name)
|
||||
ensure
|
||||
height_was_set: height.item = a_height
|
||||
end
|
||||
|
||||
-- set_format (a_format: STRING) is
|
||||
-- -- Change `format'
|
||||
-- require
|
||||
-- schema_exists: schema /= Void
|
||||
-- valid_format: posible_formats.has (a_format)
|
||||
-- do
|
||||
-- extend_with_field (a_format, format_field)
|
||||
-- extend (a_format, "format")
|
||||
-- ensure
|
||||
-- format_was_set: format = a_format
|
||||
-- end
|
||||
|
||||
-- set_function (a_string: STRING) is
|
||||
-- -- Change the `formula'
|
||||
-- require
|
||||
-- schema_exists: schema /= Void
|
||||
-- string_exists: a_string /= Void
|
||||
-- do
|
||||
-- extend_with_field (a_string, schema.formula_field)
|
||||
-- ensure
|
||||
-- formula_was_set: equal (formula, a_string)
|
||||
-- end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_calculated: BOOLEAN
|
||||
-- Should the value (produced by any control) use the result
|
||||
-- of executing (parsing) the `formula'? (Oposite is to use
|
||||
-- what ever data is set into the control.)
|
||||
-- fix -- Set by `use_formula' or `use_data'.
|
||||
do
|
||||
-- Result := formula.count >= 1
|
||||
end
|
||||
|
||||
is_schema_available: BOOLEAN
|
||||
-- Does Current have a schema?
|
||||
-- Redefined to always be True to follow the redefinition of `schema'.
|
||||
do
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
use_function
|
||||
-- Set `is_calculated' to True
|
||||
do
|
||||
-- is_calculated := True
|
||||
end
|
||||
|
||||
use_data
|
||||
-- Set `is_calculated' to False
|
||||
do
|
||||
-- is_calculated := False
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
-- parser: PARSER is
|
||||
-- -- Parser for evaluating the `formula'
|
||||
-- once
|
||||
-- create Result
|
||||
-- end
|
||||
|
||||
is_valid_data (a_value: ANY): BOOLEAN
|
||||
-- Is `a_value' valid data for this field?
|
||||
-- Must redefine `parsed' if redefine this feature.
|
||||
do
|
||||
Result := a_value /= Void and then a_value.conforms_to (Type)
|
||||
end
|
||||
|
||||
is_valid_function (a_function: STRING_32): BOOLEAN
|
||||
-- Can `a_function' be parsed, returning a result
|
||||
-- of the correct `type'?
|
||||
local
|
||||
-- p: FUNCTION_PARSER
|
||||
do
|
||||
-- p.parse_string (a_function)
|
||||
-- Result := p.last_value.same_type (type)
|
||||
end
|
||||
|
||||
string_to_type (a_string: STRING_32): like Type
|
||||
-- Convert `a_string' to an object of `Type'
|
||||
-- Default is to simply return `a_string' since
|
||||
-- it conforms to ANY if it exists.
|
||||
require
|
||||
valid_string: is_valid_data (a_string)
|
||||
do
|
||||
Result := a_string
|
||||
end
|
||||
|
||||
type_to_string (a_value: ANY): STRING_32
|
||||
-- The string representation of `a_value'.
|
||||
-- The default is to call feature `out' on `a_value' or to
|
||||
-- return the string "Void" or "Non-conforming data".
|
||||
do
|
||||
if a_value = Void then
|
||||
Result := "Void"
|
||||
elseif a_value /= Void and then not a_value.conforms_to (Type) then
|
||||
Result := "Non-conforming data"
|
||||
else
|
||||
Result := a_value.out
|
||||
end
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
controls_from: LINKED_LIST [CONTROL]
|
||||
-- All the controls whose positioning is dictated by
|
||||
-- this field (i.e. created from this field)
|
||||
local
|
||||
c_list: LINKED_LIST [CONTROL]
|
||||
c: CONTROL
|
||||
do
|
||||
create Result.make
|
||||
c_list := control_list
|
||||
from c_list.start
|
||||
until c_list.exhausted
|
||||
loop
|
||||
c := c_list.item
|
||||
if c.field = Current then -- or c.field.formula.has_field (Current) then
|
||||
-- make a formula class and put parser in it.
|
||||
Result.extend (c)
|
||||
end
|
||||
c_list.forth
|
||||
end
|
||||
end
|
||||
|
||||
controls_dependent: LINKED_LIST [CONTROL]
|
||||
-- All the controls in `controls_from' plus any controls
|
||||
-- whose `formula' contains a reference to Current.
|
||||
local
|
||||
c_list: LINKED_LIST [CONTROL]
|
||||
c: CONTROL
|
||||
do
|
||||
create Result.make
|
||||
c_list := control_list
|
||||
from c_list.start
|
||||
until c_list.exhausted
|
||||
loop
|
||||
c := c_list.item
|
||||
if c.field = Current then -- or c.field.formula.has_field (Current) then
|
||||
-- make a formula class and put parser in it.
|
||||
Result.extend (c)
|
||||
end
|
||||
c_list.forth
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: CONTROL
|
||||
-- Each descendent class must create the appropriate control and
|
||||
-- put the control into `control_list'.
|
||||
deferred
|
||||
ensure
|
||||
result_has_field: Result.field = Current
|
||||
result_added_to_list: control_list.has (Result)
|
||||
end
|
||||
|
||||
feature {CONTROL} -- Implementation
|
||||
|
||||
control_list: LINKED_LIST [CONTROL]
|
||||
-- Keeps track of all the controls so one control can update
|
||||
-- others and used to make formulas work.
|
||||
-- NOTE: This can be a once feature here as these are only valid
|
||||
-- for the current execution.
|
||||
-- The creation procedures for CONTROL should add the created
|
||||
-- widget to the list; `destroy' from CONTROL should remove it.
|
||||
-- Declared as once function so the list (of EV_WIDGETs) does
|
||||
-- not get stored. That could get messy.
|
||||
once
|
||||
create Result.make
|
||||
end
|
||||
|
||||
schema_imp: FIELD_SCHEMA
|
||||
-- Implementation and/or anchor for `schema'. Set by `set_schema' and
|
||||
-- removed by `remove_schema.
|
||||
-- NOTE: The FIELDs in a SCHEMA will determine the keys to be
|
||||
-- used in `data_table' and will be used to build the controls
|
||||
-- for obtaining the values asscociated with the keys.
|
||||
|
||||
feature {NONE} -- Implementation (fields used by `field_schema')
|
||||
|
||||
Label_field: STRING_FIELD
|
||||
-- Create a field to store the `label' of a FIELD
|
||||
once
|
||||
create Result
|
||||
-- Result.extend (Default_name, Default_label_field_name)
|
||||
Result.set_label (Default_label_field_name)
|
||||
Result.set_x (0)
|
||||
Result.set_y (0)
|
||||
Result.set_width (Default_width)
|
||||
Result.set_height (Default_height)
|
||||
end
|
||||
|
||||
X_field: INTEGER_FIELD
|
||||
-- Create a field to store the `x' value of a FIELD
|
||||
once
|
||||
create Result
|
||||
-- Result.extend (Default_x_field_name, Default_x_field_name)
|
||||
Result.set_label (Default_x_field_name)
|
||||
Result.set_x (0)
|
||||
Result.set_y (50)
|
||||
Result.set_width (Default_width)
|
||||
Result.set_height (Default_height)
|
||||
end
|
||||
|
||||
Y_field: INTEGER_FIELD
|
||||
-- Create a field to store the `y' value of a FIELD
|
||||
once
|
||||
create Result
|
||||
Result.set_label (Default_y_field_name)
|
||||
Result.set_x (0)
|
||||
Result.set_y (100)
|
||||
Result.set_width (Default_width)
|
||||
Result.set_height (Default_height)
|
||||
end
|
||||
|
||||
Width_field: INTEGER_FIELD
|
||||
-- Create a field to store the `width' of a FIELD
|
||||
once
|
||||
create Result
|
||||
Result.set_label (Default_width_field_name)
|
||||
Result.set_x (0)
|
||||
Result.set_y (150)
|
||||
Result.set_width (Default_width)
|
||||
Result.set_height (Default_height)
|
||||
end
|
||||
|
||||
Height_field: INTEGER_FIELD
|
||||
-- Create a field to store the `height' of a FIELD
|
||||
once
|
||||
create Result
|
||||
Result.set_label (Default_height_field_name)
|
||||
Result.set_x (0)
|
||||
Result.set_y (200)
|
||||
Result.set_width (Default_width)
|
||||
Result.set_height (Default_height)
|
||||
end
|
||||
|
||||
feature {NONE} -- Inaplicable
|
||||
|
||||
set_schema (a_schema: like schema_imp)
|
||||
-- Change `schema' indirectly by changing `schema_imp'.
|
||||
do
|
||||
check
|
||||
should_not_be_called: False
|
||||
-- Because `schema' was redefined to a constant
|
||||
end
|
||||
end
|
||||
|
||||
remove_schema
|
||||
-- Make `schema' imp Void
|
||||
do
|
||||
check
|
||||
should_not_be_called: False
|
||||
-- Because `schema' was redefined to a constant
|
||||
end
|
||||
end
|
||||
|
||||
end
|
32
jj_vision/interface/fields/field_constants.e
Normal file
32
jj_vision/interface/fields/field_constants.e
Normal file
@@ -0,0 +1,32 @@
|
||||
note
|
||||
description: "[
|
||||
Constants for use by classes dealing with class {FIELD} (i.e {FIELD}
|
||||
and {SCHEMA} and any descendants.
|
||||
]"
|
||||
date: "28 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/field_constants.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
|
||||
class
|
||||
FIELD_CONSTANTS
|
||||
|
||||
feature -- Access
|
||||
|
||||
Default_label_field_name: STRING = "label"
|
||||
Default_x_field_name: STRING = "x"
|
||||
Default_y_field_name: STRING = "y"
|
||||
Default_height_field_name: STRING = "height"
|
||||
Default_width_field_name: STRING = "width"
|
||||
|
||||
Default_name: STRING = "name: "
|
||||
Default_x: INTEGER = 0
|
||||
Default_y: INTEGER = 0
|
||||
Default_height: INTEGER = 30
|
||||
Default_width: INTEGER = 150
|
||||
|
||||
end
|
33
jj_vision/interface/fields/field_ref.e
Normal file
33
jj_vision/interface/fields/field_ref.e
Normal file
@@ -0,0 +1,33 @@
|
||||
note
|
||||
description: "[
|
||||
A reference to a {FIELD} for use by once feature
|
||||
`user_identifier_field' from {SCHEMA}
|
||||
]"
|
||||
date: "7 Oct 07"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/field_ref.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
FIELD_REF
|
||||
|
||||
create
|
||||
set_field
|
||||
|
||||
feature -- Access
|
||||
|
||||
field: FIELD
|
||||
-- Item held by current
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_field (a_field: FIELD)
|
||||
-- Change the `field'.
|
||||
do
|
||||
field := a_field
|
||||
end
|
||||
|
||||
end
|
24
jj_vision/interface/fields/field_schema.e
Normal file
24
jj_vision/interface/fields/field_schema.e
Normal file
@@ -0,0 +1,24 @@
|
||||
note
|
||||
description: "[
|
||||
A {SCHEMA} for a {FIELD}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/field_schema.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
FIELD_SCHEMA
|
||||
|
||||
inherit
|
||||
|
||||
SCHEMA
|
||||
|
||||
create
|
||||
default_create
|
||||
create {LINKED_LIST}
|
||||
make
|
||||
|
||||
end
|
42
jj_vision/interface/fields/formula_field.e
Normal file
42
jj_vision/interface/fields/formula_field.e
Normal file
@@ -0,0 +1,42 @@
|
||||
note
|
||||
description: "[
|
||||
A {FIELD} in which to edit formulas
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/formula_field.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class FORMULA_FIELD
|
||||
-- creates an edit box.
|
||||
|
||||
inherit
|
||||
|
||||
STRING_FIELD
|
||||
redefine
|
||||
is_valid_data
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_valid_data (a_data: ANY): BOOLEAN
|
||||
-- Is the value in `a_data' a valid representation
|
||||
-- for the `Type' of the data.
|
||||
local
|
||||
-- scan: SCANNER
|
||||
-- s: STRING
|
||||
do
|
||||
---- create scan
|
||||
-- s ?= a_data
|
||||
-- if s /= Void then
|
||||
---- scan.scan_string (s)
|
||||
-- end
|
||||
---- Result := Precursor {STRING_FIELD} (a_data) and then not scan.scanning_error
|
||||
end
|
||||
|
||||
end
|
74
jj_vision/interface/fields/integer_field.e
Normal file
74
jj_vision/interface/fields/integer_field.e
Normal file
@@ -0,0 +1,74 @@
|
||||
note
|
||||
description: "[
|
||||
A {FIELD} used to create a {INTEGER_CONTROL} and position that control.
|
||||
]"
|
||||
date: "24 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/integer_field.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
INTEGER_FIELD
|
||||
|
||||
inherit
|
||||
|
||||
COMPARABLE_FIELD
|
||||
redefine
|
||||
default_create,
|
||||
is_valid_data,
|
||||
string_to_type
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Create an instance
|
||||
do
|
||||
Precursor {COMPARABLE_FIELD}
|
||||
end
|
||||
|
||||
feature -- Querry
|
||||
|
||||
Type: INTEGER_REF
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
string_to_type (a_string: STRING_32): like type
|
||||
-- Convert `a_string' to an object of `Type'.
|
||||
do
|
||||
create Result
|
||||
Result.set_item (a_string.to_integer)
|
||||
end
|
||||
|
||||
is_valid_data (a_value: ANY): BOOLEAN
|
||||
-- Is the value in the display a valid representation
|
||||
-- for the type of the data.
|
||||
do
|
||||
Result := Precursor {COMPARABLE_FIELD} (a_value)
|
||||
if not Result then
|
||||
-- It may be that `a_value' is a STRING representation
|
||||
-- of an integer, so check the string and convert it.
|
||||
if attached {STRING} a_value as s then
|
||||
Result := s.is_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: INTEGER_CONTROL
|
||||
-- Create the appropriate type of control
|
||||
do
|
||||
create Result.make_from_field (Current)
|
||||
end
|
||||
|
||||
end
|
444
jj_vision/interface/fields/schema.e
Normal file
444
jj_vision/interface/fields/schema.e
Normal file
@@ -0,0 +1,444 @@
|
||||
note
|
||||
description: "[
|
||||
A list of {FIELD} where each {FIELD} describes the placement
|
||||
of a {CONTROL} withing an {EDITOR}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/schema.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
SCHEMA
|
||||
|
||||
inherit
|
||||
|
||||
LINKED_LIST [FIELD]
|
||||
rename
|
||||
item as field
|
||||
redefine
|
||||
default_create,
|
||||
make,
|
||||
copy,
|
||||
is_equal,
|
||||
-- Redefine the following in order to set the time the schema was
|
||||
-- changed so the dialog editor can use it to determine if it needs
|
||||
-- to redraw the view.
|
||||
extend,
|
||||
put_front,
|
||||
put_left,
|
||||
put_right,
|
||||
merge_left,
|
||||
merge_right,
|
||||
-- Need to redefine the following in order to preserve the invariant
|
||||
-- dealing with the keys (key fields must reside in current). If a
|
||||
-- field is removed from Current it can no longer be used as a key.
|
||||
-- Other features are defined in terms of this, so these four should
|
||||
-- take care of all features from LINKED_LIST.
|
||||
remove,
|
||||
replace,
|
||||
remove_right,
|
||||
wipe_out
|
||||
select
|
||||
make
|
||||
end
|
||||
|
||||
LINKED_LIST [FIELD] -- inherited identically as above except for `make'
|
||||
rename
|
||||
make as list_make,
|
||||
item as field
|
||||
redefine
|
||||
default_create,
|
||||
-- make,
|
||||
copy,
|
||||
is_equal,
|
||||
-- Redefine the following in order to set the time the schema was
|
||||
-- changed so the dialog editor can use it to determine if it needs
|
||||
-- to redraw the view.
|
||||
extend,
|
||||
put_front,
|
||||
put_left,
|
||||
put_right,
|
||||
merge_left,
|
||||
merge_right,
|
||||
-- Need to redefine the following in order to preserve the invariant
|
||||
-- dealing with the keys (key fields must reside in current). If a
|
||||
-- field is removed from Current it can no longer be used as a key.
|
||||
-- Other features are defined in terms of this, so these four should
|
||||
-- take care of all features from LINKED_LIST.
|
||||
remove,
|
||||
replace,
|
||||
remove_right,
|
||||
wipe_out
|
||||
end
|
||||
|
||||
EDITABLE
|
||||
redefine
|
||||
default_create,
|
||||
copy,
|
||||
is_equal
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
create {LINKED_LIST}
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Create an instance
|
||||
-- Redefined because `new_chain' from LINKED_LIST uses `make'.
|
||||
do
|
||||
list_make
|
||||
Precursor {EDITABLE}
|
||||
create keys_imp.make
|
||||
create mandatory_fields.make
|
||||
create time_modified.set_now_utc_fine
|
||||
extend_mandatory (Name_field)
|
||||
end
|
||||
|
||||
make
|
||||
-- Called by `new_chain' from LINKED_LIST
|
||||
do
|
||||
Precursor {LINKED_LIST}
|
||||
default_create
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
identifying_field: FIELD
|
||||
-- The field used to get a string which will identify an object.
|
||||
do
|
||||
Result := identifying_field_ref.field
|
||||
end
|
||||
|
||||
keys: LINKED_SET [STRING]
|
||||
-- The keys to use in comparison of EDITABLEs using Current.
|
||||
-- NOTE: Even though FIELDs are used in `keys_imp', ultimately the label
|
||||
-- of the FIELD will be used to access data in an EDITABLE, hence the result type.
|
||||
do
|
||||
create Result.make
|
||||
from keys_imp.start
|
||||
until keys_imp.exhausted
|
||||
loop
|
||||
Result.extend (keys_imp.item.label)
|
||||
keys_imp.forth
|
||||
end
|
||||
end
|
||||
|
||||
key_fields: LINKED_SET [FIELD]
|
||||
-- The fields which are used as keys
|
||||
do
|
||||
create Result.make
|
||||
from keys_imp.start
|
||||
until keys_imp.exhausted
|
||||
loop
|
||||
Result.extend (keys_imp.item)
|
||||
keys_imp.forth
|
||||
end
|
||||
end
|
||||
|
||||
Name_field: STRING_FIELD
|
||||
-- The FIELD used to access the "name" of the object.
|
||||
once
|
||||
create Result
|
||||
Result.set_label ("Name: ")
|
||||
end
|
||||
|
||||
time_modified: YMDHMS_TIME
|
||||
-- Time at which a modification was made (such as adding
|
||||
-- or removing a field).
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_identifying_field (a_field: STRING_FIELD)
|
||||
-- Change the `user_identifying_field'
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
do
|
||||
identifying_field_ref.set_field (a_field)
|
||||
ensure
|
||||
field_was_assigned: identifying_field = a_field
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
put_front (a_field: like field)
|
||||
-- Add `a_field' to beginning.
|
||||
-- Do not move cursor.
|
||||
-- Reset `time_modified'.
|
||||
do
|
||||
Precursor {LINKED_LIST} (a_field)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
extend (a_field: like field)
|
||||
-- Add `a_field' to the end.
|
||||
-- Do not move cursor.
|
||||
-- Reset `time_modified'.
|
||||
do
|
||||
Precursor {LINKED_LIST} (a_field)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
extend_mandatory (a_field: like field)
|
||||
-- Add `a_field' to Current and make it a manditory field.
|
||||
-- Reset `time_modified'.
|
||||
require
|
||||
is_extendible: extendible
|
||||
do
|
||||
check
|
||||
field_exists: a_field /= Void
|
||||
end
|
||||
mandatory_fields.extend (a_field)
|
||||
extend (a_field)
|
||||
ensure
|
||||
has_field: has (a_field)
|
||||
has_as_mandatory: has_mandatory (a_field)
|
||||
end
|
||||
|
||||
put_left (a_field: like field)
|
||||
-- Add `a_field' to the left of cursor position.
|
||||
-- Do not move cursor.
|
||||
-- Reset `time_modified'.
|
||||
do
|
||||
Precursor {LINKED_LIST} (a_field)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
put_right (a_field: like field)
|
||||
-- Add `a_field' to the left of cursor position.
|
||||
-- Do not move cursor.
|
||||
-- Reset `time_modified'.
|
||||
do
|
||||
Precursor {LINKED_LIST} (a_field)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
merge_left (a_other: like Current)
|
||||
-- Merge `a_other' into current structure before cursor
|
||||
-- position. Do not move cursor. Empty `other'.
|
||||
-- Reset `time_modified'.
|
||||
do
|
||||
Precursor {LINKED_LIST} (a_other)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
merge_right (a_other: like Current)
|
||||
-- Merge `a_other' into current structure after cursor
|
||||
-- position. Do not move cursor. Empty `other'.
|
||||
-- Reset `time_modified'.
|
||||
do
|
||||
Precursor {LINKED_LIST} (a_other)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
remove
|
||||
-- Remove current item.
|
||||
-- Move cursor to right neighbor
|
||||
-- (or `after' if no right neighbor).
|
||||
-- Reset `time_modified'.
|
||||
-- Also, redefined to preserve invariant.
|
||||
do
|
||||
if attached {COMPARABLE_FIELD} field as cf then
|
||||
keys_imp.prune (cf)
|
||||
else
|
||||
-- Do not have to worry about it, because if `v' is not
|
||||
-- a COMPARABLE_FIELD it would never be in `keys' anyway.
|
||||
end
|
||||
Precursor {LINKED_LIST}
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
replace (v: like field)
|
||||
-- Replace current item by `v'.
|
||||
-- Reset `time_modified'.
|
||||
-- Also, redefined to preserve invariant.
|
||||
do
|
||||
if attached {COMPARABLE_FIELD} v as cf then
|
||||
keys_imp.prune (cf)
|
||||
else
|
||||
-- Do not have to worry about it, because if `v' is not
|
||||
-- a COMPARABLE_FIELD it would never be in `keys' anyway.
|
||||
end
|
||||
Precursor {LINKED_LIST} (v)
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
remove_right
|
||||
-- Remove item to the right of cursor position.
|
||||
-- Do not move cursor.
|
||||
-- Reset `time_modified'.
|
||||
-- Also, redefined to preserve invariant.
|
||||
do
|
||||
if attached {COMPARABLE_FIELD} i_th (index + 1) as cf then
|
||||
keys_imp.prune (cf)
|
||||
else
|
||||
-- Do not have to worry about it, because if `v' is not
|
||||
-- a COMPARABLE_FIELD it would never be in `keys' anyway.
|
||||
end
|
||||
Precursor {LINKED_LIST}
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
wipe_out
|
||||
-- Remove all items.
|
||||
-- Reset `time_modified'.
|
||||
-- Also, redefined to preserve invariant.
|
||||
do
|
||||
keys_imp.wipe_out
|
||||
Precursor {LINKED_LIST}
|
||||
time_modified.set_now_utc_fine
|
||||
end
|
||||
|
||||
add_key_field (a_field: COMPARABLE_FIELD)
|
||||
-- Add `a_field' to use in comparisons
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
has_field: has (a_field)
|
||||
do
|
||||
keys_imp.extend (a_field)
|
||||
ensure
|
||||
has_key: keys_imp.has (a_field)
|
||||
end
|
||||
|
||||
prune_key_field (a_field: COMPARABLE_FIELD)
|
||||
-- Remove `a_field' so it no longer is used in comparisons
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
do
|
||||
keys_imp.prune (a_field)
|
||||
ensure
|
||||
removed: not keys_imp.has (a_field)
|
||||
end
|
||||
|
||||
promote_key_field (a_field: COMPARABLE_FIELD)
|
||||
-- Move `a_field' toward the beginning of `keys' by one, so it
|
||||
-- will be a "more important" key.
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
has_as_key: key_fields.has (a_field)
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
if keys_imp.count > 1 then
|
||||
i := keys_imp.index_of (a_field, 1)
|
||||
if i > 1 then
|
||||
go_i_th (i - 1)
|
||||
swap (i)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
field_was_promoted:
|
||||
end
|
||||
|
||||
demote_key_field (a_field: COMPARABLE_FIELD)
|
||||
-- Move `a_field' toward the end of `keys' by one, so it
|
||||
-- will be a "less important" key.
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
has_as_key: key_fields.has (a_field)
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
if keys_imp.count > 1 then
|
||||
i := keys_imp.index_of (a_field, 1)
|
||||
if i < count then
|
||||
go_i_th (i + 1)
|
||||
swap (i)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
field_was_demoted:
|
||||
end
|
||||
|
||||
set_key_primary (a_field: COMPARABLE_FIELD)
|
||||
-- Move `a_field' toward the end of `keys' by one, so it
|
||||
-- will be a "less important" key.
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
has_as_key: key_fields.has (a_field)
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
if keys_imp.count > 1 then
|
||||
i := keys_imp.index_of (a_field, 1)
|
||||
if i /= 1 then
|
||||
go_i_th (1)
|
||||
swap (i)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
field_is_primary: key_fields.index_of (a_field, 1) = 1
|
||||
end
|
||||
|
||||
feature -- Querry
|
||||
|
||||
has_mandatory (a_field: like field): BOOLEAN
|
||||
-- Is `a_field' required to always be in this schema?
|
||||
-- (I.e. can it never be deleted?)
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
do
|
||||
Result := mandatory_fields.has (a_field)
|
||||
ensure
|
||||
definition: Result = mandatory_fields.has (a_field)
|
||||
end
|
||||
|
||||
feature -- Duplication
|
||||
|
||||
copy (other: like Current)
|
||||
-- Update current object using fields of object attached
|
||||
-- to `other', so as to yield equal objects.
|
||||
-- Redefined to merge the copy operations from both ancestors.
|
||||
-- NOTE: Feature `infix "<"' from VIEWABLE only checks the `id'
|
||||
-- and assumes if the `id' (and hence the `time_stamp' from both
|
||||
-- objects are equal the object must have been copied and is
|
||||
-- therefore equal.
|
||||
do
|
||||
Precursor {LINKED_LIST} (other)
|
||||
Precursor {EDITABLE} (other)
|
||||
end
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
is_equal (other: like Current): BOOLEAN
|
||||
-- Is Current equal to `other'?
|
||||
do
|
||||
-- Precursor {VIEWABLE} uses feature `infix "<"' to do the
|
||||
-- comparison, and there is no less than feature in LINKED_LIST,
|
||||
-- therefore this feature makes the BIG assumption that if
|
||||
-- the `id' and `time_stamp' (from VIEWABLE) of both objects
|
||||
-- are the same then it must have been a copy. There is no other
|
||||
-- way to make the `time_stamps' equal.
|
||||
Result := Precursor {EDITABLE} (other)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
keys_imp: LINKED_SET [COMPARABLE_FIELD]
|
||||
-- Set of fields whose associated values can be used to compare
|
||||
-- one EDITABLE to another in feature `infix "<"' from EDITABLE.
|
||||
-- The order implies the more significant fields.
|
||||
|
||||
mandatory_fields: LINKED_SET [FIELD]
|
||||
-- Set of fields which can not be deleted from Current.
|
||||
|
||||
identifying_field_ref: FIELD_REF
|
||||
-- The field to be used as `identifying_field' as set by the user
|
||||
-- in place of the default field.
|
||||
once
|
||||
create Result.set_field (Name_field)
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
keys_imp_exists: keys_imp /= Void
|
||||
manditory_fields_exists: mandatory_fields /= Void
|
||||
keys_reside_in_current: key_fields.for_all (agent has)
|
||||
mandatory_fields_reside_in_current: mandatory_fields.for_all (agent has)
|
||||
|
||||
end
|
48
jj_vision/interface/fields/string_field.e
Normal file
48
jj_vision/interface/fields/string_field.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
A {FIELD} describing the placement of a {STRING_CONTROL}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/string_field.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class STRING_FIELD
|
||||
-- creates an edit box.
|
||||
|
||||
inherit
|
||||
|
||||
COMPARABLE_FIELD
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
feature -- Access
|
||||
|
||||
feature -- Querry
|
||||
|
||||
type: STRING_32
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
once
|
||||
create Result.make_from_string ("")
|
||||
end
|
||||
|
||||
as_type (a_string: STRING_32): like type
|
||||
-- Convert `a_string' to an object of `Type'.
|
||||
do
|
||||
Result := a_string
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: STRING_CONTROL
|
||||
do
|
||||
create Result.make_from_field (Current)
|
||||
end
|
||||
|
||||
end
|
82
jj_vision/interface/fields/ymd_time_field.e
Normal file
82
jj_vision/interface/fields/ymd_time_field.e
Normal file
@@ -0,0 +1,82 @@
|
||||
note
|
||||
description: "[
|
||||
A {FIELD} decribing the placement of a {YMD_TIME_CONTROL}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/fields/ymd_time_field.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
YMD_TIME_FIELD
|
||||
|
||||
inherit
|
||||
|
||||
COMPARABLE_FIELD
|
||||
redefine
|
||||
is_valid_data,
|
||||
string_to_type,
|
||||
type_to_string
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Access
|
||||
|
||||
Type: YMD_TIME
|
||||
-- Implementation (and anchor) of `value'.
|
||||
-- Redefined to change type.
|
||||
once
|
||||
create Result.set_now
|
||||
end
|
||||
|
||||
is_valid_data (a_value: ANY): BOOLEAN
|
||||
-- Is the value in `a_value' a valid representation
|
||||
-- for the `Type' of the data.
|
||||
local
|
||||
f: YMD_TIME_FORMATTER
|
||||
do
|
||||
Result := Precursor {COMPARABLE_FIELD} (a_value)
|
||||
if not Result then
|
||||
-- It may be that `a_value' is a STRING representation
|
||||
-- of a date, so check the string and convert it.
|
||||
create f
|
||||
if attached {STRING} a_value as s then
|
||||
Result := f.is_valid (s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
string_to_type (a_string: STRING_32): like Type
|
||||
-- Convert `a_string' to a YMD_TIME
|
||||
local
|
||||
f: YMD_TIME_FORMATTER
|
||||
do
|
||||
create f
|
||||
Result := f.to_ymd_time (a_string)
|
||||
end
|
||||
|
||||
type_to_string (a_value: ANY): STRING_32
|
||||
-- The string representation of `a_value'.
|
||||
local
|
||||
f: YMD_TIME_FORMATTER
|
||||
do
|
||||
if attached {YMD_TIME} a_value as t then
|
||||
create f
|
||||
Result := f.to_string (t)
|
||||
else
|
||||
Result := Precursor {COMPARABLE_FIELD} (a_value)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Transformation
|
||||
|
||||
as_widget: YMD_TIME_CONTROL
|
||||
do
|
||||
create Result.make_from_field (Current)
|
||||
end
|
||||
|
||||
end
|
148
jj_vision/interface/system/about_dialog.e
Normal file
148
jj_vision/interface/system/about_dialog.e
Normal file
@@ -0,0 +1,148 @@
|
||||
note
|
||||
description : "About dialog box"
|
||||
author : "Generated by the New Vision2 Application Wizard."
|
||||
date : "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision : "1.0.0"
|
||||
|
||||
class
|
||||
ABOUT_DIALOG
|
||||
|
||||
inherit
|
||||
|
||||
-- EV_DIALOG
|
||||
EV_TITLED_WINDOW
|
||||
-- Used EV_TITLED_WINDOW so the dialog can be declared as
|
||||
-- "once" and non-modal. The close actions for DIALOGs
|
||||
-- were too restrictive or not exported.
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {EV_TITLED_WINDOW}
|
||||
create pixmap
|
||||
create message_label
|
||||
create ok_button.make_with_text ("OK")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Populate the dialog box.
|
||||
local
|
||||
main_horizontal_box: EV_HORIZONTAL_BOX
|
||||
left_vertical_box: EV_VERTICAL_BOX
|
||||
right_vertical_box: EV_VERTICAL_BOX
|
||||
horizontal_separator: EV_HORIZONTAL_SEPARATOR
|
||||
buttons_box: EV_HORIZONTAL_BOX
|
||||
ev_cell: EV_CELL
|
||||
do
|
||||
Precursor
|
||||
|
||||
--| Add the pixmap to the dialog box.
|
||||
--|
|
||||
--| We do not use `{EV_STOCK_PIXMAPS}.Information_pixmap'
|
||||
--| directly because a given pixmap can only have one
|
||||
--| parent. `Information_pixmap' may have alredy been put
|
||||
--| into another container.
|
||||
pixmap.copy ((create {EV_STOCK_PIXMAPS}).Information_pixmap)
|
||||
pixmap.set_minimum_size (pixmap.width, pixmap.height)
|
||||
|
||||
create message_label
|
||||
message_label.align_text_left
|
||||
|
||||
create horizontal_separator
|
||||
|
||||
ok_button.set_minimum_size (75, 24)
|
||||
ok_button.select_actions.extend (agent destroy)
|
||||
|
||||
create buttons_box
|
||||
buttons_box.extend (create {EV_CELL}) -- Fill in empty space on left
|
||||
buttons_box.extend (ok_button)
|
||||
buttons_box.disable_item_expand (ok_button)
|
||||
|
||||
create left_vertical_box
|
||||
left_vertical_box.set_border_width (7)
|
||||
left_vertical_box.extend (pixmap)
|
||||
left_vertical_box.disable_item_expand (pixmap)
|
||||
left_vertical_box.extend (create {EV_CELL})
|
||||
|
||||
create right_vertical_box
|
||||
right_vertical_box.set_padding (7)
|
||||
right_vertical_box.extend (message_label)
|
||||
right_vertical_box.extend (horizontal_separator)
|
||||
right_vertical_box.disable_item_expand (horizontal_separator)
|
||||
right_vertical_box.extend (buttons_box)
|
||||
right_vertical_box.disable_item_expand (buttons_box)
|
||||
|
||||
create main_horizontal_box
|
||||
main_horizontal_box.set_border_width (7)
|
||||
create ev_cell
|
||||
ev_cell.set_minimum_width (21)
|
||||
main_horizontal_box.extend (ev_cell)
|
||||
main_horizontal_box.disable_item_expand (ev_cell)
|
||||
main_horizontal_box.extend (left_vertical_box)
|
||||
main_horizontal_box.disable_item_expand (left_vertical_box)
|
||||
create ev_cell
|
||||
ev_cell.set_minimum_width (28)
|
||||
main_horizontal_box.extend (ev_cell)
|
||||
main_horizontal_box.disable_item_expand (ev_cell)
|
||||
main_horizontal_box.extend (right_vertical_box)
|
||||
extend (main_horizontal_box)
|
||||
|
||||
-- set_default_push_button (ok_button)
|
||||
-- set_default_cancel_button (ok_button)
|
||||
|
||||
set_title (Default_title)
|
||||
set_message (Default_message)
|
||||
set_size (400, 150)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
message: STRING
|
||||
-- Message displayed in the dialog box.
|
||||
do
|
||||
Result := message_label.text
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_message (a_message: STRING)
|
||||
do
|
||||
message_label.set_text (a_message)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
message_label: EV_LABEL
|
||||
-- Label situated on the top of the dialog,
|
||||
-- contains the message.
|
||||
|
||||
pixmap: EV_PIXMAP
|
||||
-- Pixmap display on the left of the dialog.
|
||||
|
||||
ok_button: EV_BUTTON
|
||||
-- "OK" button.
|
||||
|
||||
feature {NONE} -- Implementation / Constants
|
||||
|
||||
Default_title: STRING = "Standard Interface Cluster"
|
||||
-- Default title for the dialog window.
|
||||
|
||||
Default_message: STRING =
|
||||
"%N%N%
|
||||
%Written by%N%N%
|
||||
%Johnson J. Johnson%N%N%N%
|
||||
%with ISE Eiffel 6.68 (free version) with Eiffel Vision."
|
||||
|
||||
|
||||
end
|
283
jj_vision/interface/system/editable.e
Normal file
283
jj_vision/interface/system/editable.e
Normal file
@@ -0,0 +1,283 @@
|
||||
note
|
||||
description: "[
|
||||
Used with EDITOR classes.
|
||||
Object which can be edited in a dialog box, an {EDITOR} using
|
||||
a format stored in a `schema'.
|
||||
]"
|
||||
date: "7 Mar 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/system/editable.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
EDITABLE
|
||||
|
||||
inherit
|
||||
|
||||
TIME_STAMPABLE
|
||||
redefine
|
||||
default_create
|
||||
-- infix "<"
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
do
|
||||
Precursor {TIME_STAMPABLE}
|
||||
create data_table.make (5)
|
||||
schema_imp := Default_schema
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
value (a_key: STRING): detachable ANY
|
||||
-- The value associated with `key' or Void if none.
|
||||
require
|
||||
key_exists: a_key /= Void
|
||||
do
|
||||
Result := data_table.item (a_key)
|
||||
end
|
||||
|
||||
schema: SCHEMA
|
||||
-- Used to construct a dialog in which to edit the values
|
||||
-- which are then stored in `data_table'.
|
||||
require
|
||||
schema_available: is_schema_available
|
||||
do
|
||||
check attached schema_imp as s then
|
||||
Result := s
|
||||
end
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
display_name: STRING_32
|
||||
-- Used as an "out" value for display in TOOLs and other widgets.
|
||||
do
|
||||
if attached {STRING_32} value (schema.identifying_field.label) as s then
|
||||
Result := s
|
||||
else
|
||||
Result := Current.id
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target_label_field (a_field: STRING_FIELD)
|
||||
-- Change the field used to display an identifier in the tools, etc.
|
||||
-- This is really in the `schema' of the editable.
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
local
|
||||
w: JJ_MAIN_WINDOW
|
||||
do
|
||||
schema.set_identifying_field (a_field)
|
||||
-- Because `target_label_field' is posibly used by all views, when it changes
|
||||
-- all views must be updated because there is no way for the view to know
|
||||
-- if it contains `target_label_field'. Originally `target_label_field'
|
||||
-- was added to the views using `add_object' (see VIEW), but using a FIELD
|
||||
-- implies some EDITABLEs in the system. I wanted the "Standard Interface"
|
||||
-- cluster to stand alone and not need the "Dynamic Editor" cluster to which
|
||||
-- this class belongs.
|
||||
check attached {JJ_APPLICATION} (create {EV_ENVIRONMENT}).application as a then
|
||||
-- because only JJ_APPLICATIONS should use this. really ???
|
||||
-- Get hold of any VIEW; `first_window' will work.
|
||||
w := a.first_window
|
||||
w.draw_all_views
|
||||
end
|
||||
end
|
||||
|
||||
set_schema (a_schema: like schema)
|
||||
-- Change `schema' indirectly by changing `schema_imp'.
|
||||
require
|
||||
schema_exists: a_schema /= Void
|
||||
do
|
||||
schema_imp := a_schema
|
||||
ensure
|
||||
schema_was_set: schema = a_schema
|
||||
end
|
||||
|
||||
remove_schema
|
||||
-- Make `schema_imp' Void
|
||||
do
|
||||
schema_imp := Void
|
||||
ensure
|
||||
schema_imp_void: schema = Void
|
||||
end
|
||||
|
||||
extend_value (a_value: ANY; a_key: STRING)
|
||||
-- Add `a_value' to the `data_table' and associate it with `a_key'
|
||||
-- and accessable through feature `value'.
|
||||
-- NOTE: `a_value' can be Void.
|
||||
require
|
||||
key_exists: a_key /= Void
|
||||
value_exists: a_value /= Void -- temp
|
||||
do
|
||||
data_table.force (a_value, a_key)
|
||||
ensure
|
||||
has_value: a_value /= Void implies data_table.has_item (a_value)
|
||||
has_key: data_table.has (a_key)
|
||||
end
|
||||
|
||||
remove_value (a_key: STRING)
|
||||
-- Remove the value associated with `a_key' and `a_key'.
|
||||
require
|
||||
key_exists: a_key /= Void
|
||||
do
|
||||
data_table.remove (a_key)
|
||||
ensure
|
||||
not_has_value: not data_table.has (a_key)
|
||||
not_has_key: not data_table.has (a_key)
|
||||
end
|
||||
|
||||
-- extend_with_field (a_value: ANY; a_field: FIELD) is
|
||||
-- -- Change the value of the data as index using the `name' from `a_field'.
|
||||
-- -- NOTE: `a_value' can be Void.
|
||||
-- require
|
||||
-- field_exists: a_field /= Void
|
||||
-- schema_has_field: schema.has (a_field)
|
||||
-- do
|
||||
-- extend (a_value, a_field.label)
|
||||
-- ensure
|
||||
-- has_value: a_value /= Void implies data_table.has_item (a_value)
|
||||
-- has_key: data_table.has (a_field.label)
|
||||
-- end
|
||||
|
||||
-- change (a_control: VALUE_KEY_PAIR) is
|
||||
-- -- Change the `value' in Current to the value stored in `a_control'
|
||||
-- -- NOTE: `a_control' contains a `key' / `value' pair.
|
||||
-- do
|
||||
-- data_table.force (a_control.value, a_control.key)
|
||||
-- end
|
||||
|
||||
remove_unreachable_data
|
||||
-- Remove any data from this EDITABLE that cannot be
|
||||
-- accessed using the keys in `a_key_set' or the
|
||||
-- `keys' in `template'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_schema_available: BOOLEAN
|
||||
-- Does Current have a schema?
|
||||
do
|
||||
Result := schema_imp /= Void
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
has_schema (a_schema: SCHEMA): BOOLEAN
|
||||
-- Does `schema' equal `a_schema'?
|
||||
require
|
||||
schema_exists: a_schema /= Void
|
||||
do
|
||||
Result := schema = a_schema
|
||||
end
|
||||
|
||||
has_value (a_key: STRING): BOOLEAN
|
||||
-- Is there a value associated with `a_key'?
|
||||
require
|
||||
key_exists: a_key /= Void
|
||||
do
|
||||
data_table.search (a_key)
|
||||
Result := data_table.found
|
||||
end
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
is_less alias "<" (a_other: like Current): BOOLEAN
|
||||
-- Is Current less than `a_other'?
|
||||
-- This uses the `keys' from `schema' first and then the `id'.
|
||||
do
|
||||
if not (Current = a_other) then
|
||||
if schema = Void and a_other.schema = Void then
|
||||
Result := Current < a_other
|
||||
elseif schema /= Void and a_other.schema = Void then
|
||||
Result := True
|
||||
elseif schema = Void and a_other.schema /= Void then
|
||||
Result := False
|
||||
elseif schema /= Void and a_other.schema /= Void then
|
||||
Result := compare_key_values (a_other)
|
||||
end
|
||||
end
|
||||
ensure then
|
||||
zero_schemas: (schema = Void and a_other.schema = Void) implies Result = (Current < a_other)
|
||||
one_schema_current: (schema /= Void and a_other.schema = Void) implies Result
|
||||
one_schema_other: (schema = Void and a_other.schema /= Void) implies not Result
|
||||
same_schema_both: (schema /= Void and a_other.schema /= Void) implies Result = compare_key_values (a_other)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
compare_key_values (a_other: like Current): BOOLEAN
|
||||
-- Is Current less than `a_other' when comparing keys?
|
||||
-- Feature to decompose `infix "<"'.
|
||||
require
|
||||
other_exists: a_other /= Void
|
||||
schema_exists: schema /= Void
|
||||
other_schema_exists: a_other.schema /= Void
|
||||
local
|
||||
keys: LINKED_SET [STRING]
|
||||
k: STRING
|
||||
done: BOOLEAN
|
||||
do
|
||||
keys := schema.keys
|
||||
if schema /= a_other.schema then
|
||||
keys.intersect (a_other.schema.keys)
|
||||
end
|
||||
from keys.start
|
||||
until done or else keys.exhausted
|
||||
loop
|
||||
k := keys.item
|
||||
-- Now compare the values. If both are Void (can happen) or reference
|
||||
-- the same object (unlikely or imposible) then just continue to
|
||||
-- the next key. If they are not equal then do comparison.
|
||||
if attached {COMPARABLE} value (k) as c and
|
||||
attached {COMPARABLE} a_other.value (k) as other_c then
|
||||
Result := c < other_c
|
||||
done := True
|
||||
end
|
||||
keys.forth
|
||||
end
|
||||
-- At this point we have either made a determination using the
|
||||
-- values at the keys, in which case `done' will be true, or we
|
||||
-- have exhausted the keys without making a determination. In
|
||||
-- the second case compare the `id' features; this should be
|
||||
-- true if Current was created before `a_other'. (Feature `id'
|
||||
-- incorporates a `time_stamp'.)
|
||||
if not done then
|
||||
Result := Current.id < a_other.id
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE}-- Implementation
|
||||
|
||||
schema_imp: detachable like schema
|
||||
-- Implementation of `schema'. Set by `set_schema' and
|
||||
-- removed by `remove_schema.
|
||||
-- NOTE: The FIELDs in a SCHEMA will determine the keys to be
|
||||
-- used in `data_table' and will be used to build the controls
|
||||
-- for obtaining the values asscociated with the keys.
|
||||
|
||||
data_table: HASH_TABLE [ANY, STRING]
|
||||
-- The actual data is stored here.
|
||||
|
||||
Default_schema: SCHEMA
|
||||
-- Schema available to all EDITABLEs
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
-- data_table_exists: data_table /= Void
|
||||
|
||||
end
|
223
jj_vision/interface/system/jj_application.e
Normal file
223
jj_vision/interface/system/jj_application.e
Normal file
@@ -0,0 +1,223 @@
|
||||
note
|
||||
description: "[
|
||||
Root class for an application built using the "jj_vision" classes
|
||||
]"
|
||||
date: "19 Jul 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
JJ_APPLICATION
|
||||
|
||||
inherit
|
||||
|
||||
SHARED
|
||||
export
|
||||
{NONE}
|
||||
all
|
||||
-- {ANY}
|
||||
-- persistence_manager
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
EV_APPLICATION
|
||||
redefine
|
||||
create_interface_objects,
|
||||
destroy
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_and_launch
|
||||
-- Initialize and launch application
|
||||
local
|
||||
-- l_app: EV_APPLICATION
|
||||
do
|
||||
-- -- The use of `l_app' instead of inheritance is the style
|
||||
-- -- used by the wizard in version 23.09.
|
||||
-- create l_app
|
||||
-- prepare
|
||||
-- -- The next instruction launches GUI message processing.
|
||||
-- -- It should be the last instruction of a creation procedure
|
||||
-- -- that initializes GUI objects. Any other processing should
|
||||
-- -- be done either by agents associated with GUI elements
|
||||
-- -- or in a separate processor.
|
||||
-- l_app.launch
|
||||
-- -- No code should appear here,
|
||||
-- -- otherwise GUI message processing will be stuck in SCOOP mode.
|
||||
print ("JJ_APPLICATION.make_and_launch %N")
|
||||
default_create
|
||||
prepare
|
||||
launch
|
||||
print ("%T end JJ_APPLICATION.make_and_launch %N")
|
||||
end
|
||||
|
||||
create_interface_objects
|
||||
-- Set up the attribute
|
||||
do
|
||||
Precursor {EV_APPLICATION}
|
||||
create target
|
||||
end
|
||||
|
||||
prepare
|
||||
-- Prepare the application by either loading it from a previous
|
||||
-- execution or create a new one if an old one doesn't exist.
|
||||
local
|
||||
w: like first_window
|
||||
do
|
||||
print ("JJ_APPLICATION.prepare %N")
|
||||
-- initialize_directories
|
||||
-- rebuild_application
|
||||
if not is_application_loaded then
|
||||
print (" JJ_APPLICATION.prepare begin if statement %N")
|
||||
create w.make (target)
|
||||
print (" JJ_APPLICATION.prepare after create w %N")
|
||||
w.show
|
||||
print (" JJ_APPLICATION.prepare after w.show %N")
|
||||
end
|
||||
print ("%T end JJ_APPLICATION.prepare %N")
|
||||
end
|
||||
|
||||
destroy
|
||||
-- Save the state of all main_windows and end the application.
|
||||
do
|
||||
-- save_system_state
|
||||
Precursor {EV_APPLICATION}
|
||||
end
|
||||
|
||||
initialize_directories
|
||||
-- Set up the datastores for the system info.
|
||||
local
|
||||
d: DIRECTORY
|
||||
do
|
||||
create d.make (Default_data_path.name)
|
||||
if not d.exists then
|
||||
d.create_dir
|
||||
end
|
||||
create d.make (Default_settings_path.name)
|
||||
if not d.exists then
|
||||
d.create_dir
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
target: ANY
|
||||
-- The top/main object handled by this application
|
||||
|
||||
frozen first_window: like window_anchor
|
||||
-- Anchor to describe the type of the windows in the program.
|
||||
require
|
||||
has_at_least_one_window: has_windows
|
||||
do
|
||||
check attached {like window_anchor} main_windows.first as w then
|
||||
Result := w
|
||||
end
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
-- command_manager: COMMAND_MANAGER is
|
||||
-- -- Manages the COMMAND's called by the application to allow undo/redo capabilities.
|
||||
-- once
|
||||
-- create Result
|
||||
-- end
|
||||
|
||||
application_state: APPLICATION_STATE
|
||||
-- The state of the application.
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_windows: BOOLEAN
|
||||
-- Does at least one window exist in the application?
|
||||
do
|
||||
Result := not main_windows.is_empty
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
rebuild_application
|
||||
-- Rebuild the windows as they were on the last application exit.
|
||||
local
|
||||
f: RAW_FILE
|
||||
a: ANY
|
||||
do
|
||||
-- Attempt to read the `application_state' from the disk in order
|
||||
-- to begin this execution where the last one left off.
|
||||
create f.make (merged_file_name (Default_settings_path.name.as_string_8, "Application_State"))
|
||||
if f.exists and then f.is_readable then
|
||||
f.open_read
|
||||
if f.is_readable then
|
||||
if attached {like application_state} f.retrieved as app_state then
|
||||
-- Force a call to `widget' causing the creation of new windows.
|
||||
a := app_state.view
|
||||
is_application_loaded := True
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
save_system_state
|
||||
-- Save the state of the system for restoration on next execution.
|
||||
local
|
||||
dn: STRING_32
|
||||
fn: STRING
|
||||
d: DIRECTORY
|
||||
f: RAW_FILE
|
||||
do
|
||||
dn := Default_settings_path.name
|
||||
create d.make (dn)
|
||||
if not d.exists then
|
||||
d.recursive_create_dir
|
||||
end
|
||||
fn := merged_file_name (Default_settings_path.name.as_string_8, "Application_State")
|
||||
-- fn := "Application_state"
|
||||
create f.make (fn)
|
||||
if f.exists then
|
||||
f.wipe_out
|
||||
-- else
|
||||
-- f.create_read_write
|
||||
end
|
||||
f.create_read_write
|
||||
f.general_store (application_state)
|
||||
f.close
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
is_application_loaded: BOOLEAN
|
||||
-- Was the last application state retrieved from a persistent file and
|
||||
-- now ready to be used to initialize the application?
|
||||
-- Set by `load_application_state'.
|
||||
|
||||
Default_application_state_name: STRING = "Application State"
|
||||
-- To be used as file name of file containing the `state'.
|
||||
|
||||
feature {NONE} -- Implementation (anchors)
|
||||
|
||||
window_anchor: JJ_MAIN_WINDOW
|
||||
-- Anchor for the type of `first_window'
|
||||
-- Not to be called; just used to anchor types.
|
||||
-- Declared as a feature to avoid adding an attribute.
|
||||
require else
|
||||
not_callable: False
|
||||
do
|
||||
check
|
||||
do_not_call: False then
|
||||
-- Because give no info; simply used as anchor.
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
918
jj_vision/interface/system/jj_main_window.e
Normal file
918
jj_vision/interface/system/jj_main_window.e
Normal file
@@ -0,0 +1,918 @@
|
||||
note
|
||||
description: "[
|
||||
This can be used as base class for the main window(s) of a program,
|
||||
allowing the program to have multiple main windows, with a standard
|
||||
set of buttons and actions such as undo/redo, open, save, etc.
|
||||
|
||||
|
||||
To enable undo/redo create a descendant of {JJ_COMMAND} and add it to the
|
||||
`command_mangaer' with `add_command'.
|
||||
]"
|
||||
date: "18 Jul 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2015, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/system/jj_main_window.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
JJ_MAIN_WINDOW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
draw,
|
||||
state,
|
||||
-- set_split_manager,
|
||||
add_actions
|
||||
end
|
||||
|
||||
EV_TITLED_WINDOW
|
||||
rename
|
||||
object_id as ise_object_id,
|
||||
item as ev_item,
|
||||
is_empty as ev_is_empty
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
PIXEL_BUFFERS
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
create split_manager
|
||||
-- Create the "File" menu
|
||||
create file_menu
|
||||
create file_new_target_item
|
||||
create file_save_item
|
||||
create file_open_item
|
||||
create file_exit_item
|
||||
-- Create the "Edit" menu
|
||||
create edit_menu
|
||||
create edit_undo_item
|
||||
create edit_redo_item
|
||||
-- Create the "Tools" menu
|
||||
create tool_menu
|
||||
create tool_preferences_item
|
||||
-- Create the "Window" menu
|
||||
create window_menu
|
||||
create window_new_item
|
||||
create window_maximize_all_item
|
||||
create window_minimize_all_item
|
||||
create window_raise_all_item
|
||||
-- Create the "Help" menu
|
||||
create help_menu
|
||||
create help_about_item
|
||||
-- Create the `jj_menu_bar'
|
||||
create jj_menu_bar
|
||||
-- Create the main_window box and tool bar
|
||||
create jj_tool_bar
|
||||
create jj_tool_bar_box
|
||||
create jj_tool_bar
|
||||
create new_target_button
|
||||
create open_button
|
||||
create save_button
|
||||
create undo_button
|
||||
create redo_button
|
||||
create new_window_button
|
||||
create minimize_all_button
|
||||
create raise_all_button
|
||||
create help_button
|
||||
-- -- Create the status bar.
|
||||
-- create jj_status_bar
|
||||
-- create jj_status_label
|
||||
-- Create the dialogs
|
||||
create preferences_dialog
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TITLED_WINDOW}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window.
|
||||
-- local
|
||||
-- sys: like system
|
||||
do
|
||||
-- create split_manager
|
||||
Precursor {EV_TITLED_WINDOW}
|
||||
Precursor {VIEW}
|
||||
main_windows.extend (Current)
|
||||
-- Create and add the menu bar.
|
||||
build_standard_menu_bar
|
||||
show_menu
|
||||
-- Create and add the toolbar.
|
||||
build_main_window_tool_bar
|
||||
-- upper_bar.extend (create {EV_HORIZONTAL_SEPARATOR})
|
||||
upper_bar.extend (jj_tool_bar_box)
|
||||
upper_bar.disable_item_expand (jj_tool_bar_box)
|
||||
upper_bar.extend (create {EV_HORIZONTAL_SEPARATOR})
|
||||
-- Create and add the status bar.
|
||||
-- build_standard_status_bar
|
||||
-- lower_bar.extend (jj_status_bar)
|
||||
-- Set up window attributes
|
||||
-- set_system (sys) -- commented out for dynamic editor
|
||||
-- set_target (system)
|
||||
set_size (Window_width, Window_height)
|
||||
-- set_actions
|
||||
-- set_widget_states
|
||||
set_preferences_dialog (Default_preferences_dialog)
|
||||
-- Set up the "split-managed" cell, bar, and menu.
|
||||
extend (split_manager.cell)
|
||||
jj_tool_bar_box.extend (split_manager.bar)
|
||||
window_menu.extend (split_manager.menu)
|
||||
-- Finish the window
|
||||
set_title (Window_title)
|
||||
-- draw
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add actions to the widgets
|
||||
do
|
||||
-- add actions to window
|
||||
close_request_actions.extend (agent on_close_window)
|
||||
-- add actions to File menu items
|
||||
-- file_new_target_item.select_actions.extend (agent on_make_new_target)
|
||||
file_open_item.select_actions.extend (agent on_file_open)
|
||||
file_save_item.select_actions.extend (agent on_file_save)
|
||||
file_exit_item.select_actions.extend (agent on_exit)
|
||||
-- add actions to the Tool menu items
|
||||
tool_preferences_item.select_actions.extend (agent on_show_preferences_dialog)
|
||||
-- add actions to Window menu items
|
||||
-- window_new_item.select_actions.extend (agent on_make_new_window)
|
||||
window_maximize_all_item.select_actions.extend (agent on_maximize_all)
|
||||
window_minimize_all_item.select_actions.extend (agent on_minimize_all)
|
||||
window_raise_all_item.select_actions.extend (agent on_raise_all)
|
||||
-- window_preferences_item.select_actions.extend (agent on_show_preferences_window)
|
||||
-- add actions to Help menu items
|
||||
help_about_item.select_actions.extend (agent on_about)
|
||||
-- add actions to buttons
|
||||
new_target_button.set_pebble_function (agent on_get_target)
|
||||
new_target_button.select_actions.extend (agent on_make_new_target)
|
||||
new_target_button.drop_actions.extend (agent on_drop_target)
|
||||
-- open_button.select_actions.extend (agent on_file_open)
|
||||
-- save_button.select_actions.extend (agent on_file_save)
|
||||
undo_button.select_actions.extend (agent command_manager.undo)
|
||||
redo_button.select_actions.extend (agent command_manager.execute)
|
||||
new_window_button.drop_actions.extend (agent on_drop_in_new_window)
|
||||
-- new_window_button.select_actions.extend (agent on_make_new_window)
|
||||
minimize_all_button.select_actions.extend (agent on_minimize_all)
|
||||
raise_all_button.select_actions.extend (agent on_raise_all)
|
||||
-- preferences_button.select_actions.extend (agent on_show_preferences_window)
|
||||
end
|
||||
|
||||
build_standard_menu_bar
|
||||
-- Create and populate `jj_menu_bar'.
|
||||
do
|
||||
-- Add attributes to menu items
|
||||
file_menu.set_text ("File")
|
||||
file_new_target_item.set_text ("New target")
|
||||
file_save_item.set_text ("Save")
|
||||
file_open_item.set_text ("Open")
|
||||
file_exit_item.set_text ("Exit")
|
||||
edit_menu.set_text ("Edit")
|
||||
edit_undo_item.set_text ("Undo")
|
||||
edit_redo_item.set_text ("Redo")
|
||||
tool_menu.set_text ("Tool")
|
||||
tool_preferences_item.set_text ("Preferences")
|
||||
window_menu.set_text ("Window")
|
||||
window_new_item.set_text ("New")
|
||||
window_maximize_all_item.set_text ("Maximize all")
|
||||
window_minimize_all_item.set_text ("Minimize all")
|
||||
window_raise_all_item.set_text ("Raise all")
|
||||
help_menu.set_text ("Help")
|
||||
help_about_item.set_text ("About")
|
||||
-- Register and fill the "File" menu
|
||||
file_menu.extend (file_new_target_item)
|
||||
file_menu.extend (file_open_item)
|
||||
file_menu.extend (file_save_item)
|
||||
file_menu.extend (create {EV_MENU_SEPARATOR})
|
||||
file_menu.extend (file_exit_item)
|
||||
-- Register and fill the "Edit" menu
|
||||
edit_menu.extend (edit_undo_item)
|
||||
edit_menu.extend (edit_redo_item)
|
||||
-- Register and fill the "Tools" menu
|
||||
tool_menu.extend (tool_preferences_item)
|
||||
-- Register and fill the "Window" menu
|
||||
window_menu.extend (window_new_item)
|
||||
window_menu.extend (window_maximize_all_item)
|
||||
window_menu.extend (window_minimize_all_item)
|
||||
window_menu.extend (window_raise_all_item)
|
||||
-- Register and fill the "Help" menu
|
||||
help_menu.extend (help_about_item)
|
||||
-- Fill the `jj_menu_bar'
|
||||
jj_menu_bar.extend (file_menu)
|
||||
jj_menu_bar.extend (edit_menu)
|
||||
jj_menu_bar.extend (tool_menu)
|
||||
jj_menu_bar.extend (window_menu)
|
||||
jj_menu_bar.extend (help_menu)
|
||||
ensure
|
||||
menu_bar_created:
|
||||
jj_menu_bar /= Void and then
|
||||
not jj_menu_bar.is_empty
|
||||
end
|
||||
|
||||
build_main_window_tool_bar
|
||||
-- Create and populate the standard toolbar.
|
||||
local
|
||||
lab: EV_LABEL
|
||||
do
|
||||
-- Add attributes to buttons
|
||||
new_target_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_object_symbol_buffer))
|
||||
new_target_button.set_tooltip ("New target")
|
||||
open_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_open_file_color_buffer))
|
||||
open_button.set_tooltip ("Open")
|
||||
save_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_save_color_buffer))
|
||||
save_button.set_tooltip ("Save")
|
||||
undo_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_undo_color_buffer))
|
||||
undo_button.set_tooltip ("Undo")
|
||||
redo_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_redo_color_buffer))
|
||||
redo_button.set_tooltip ("Redo")
|
||||
new_window_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_new_development_tool_color_buffer))
|
||||
new_window_button.set_tooltip ("New window")
|
||||
minimize_all_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_minimize_all_color_buffer))
|
||||
minimize_all_button.set_tooltip ("Minimize all")
|
||||
raise_all_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_restore_all_color_buffer))
|
||||
raise_all_button.set_tooltip ("Raise all")
|
||||
help_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_help_tool_color_buffer))
|
||||
help_button.set_tooltip ("Help")
|
||||
-- Add the buttons to the toolbar
|
||||
jj_tool_bar.extend (new_target_button)
|
||||
jj_tool_bar.extend (open_button)
|
||||
jj_tool_bar.extend (save_button)
|
||||
jj_tool_bar.extend (create {EV_TOOL_BAR_SEPARATOR})
|
||||
jj_tool_bar.extend (undo_button)
|
||||
jj_tool_bar.extend (redo_button)
|
||||
jj_tool_bar.extend (create {EV_TOOL_BAR_SEPARATOR})
|
||||
jj_tool_bar.extend (new_window_button)
|
||||
jj_tool_bar.extend (minimize_all_button)
|
||||
jj_tool_bar.extend (raise_all_button)
|
||||
jj_tool_bar.extend (create {EV_TOOL_BAR_SEPARATOR})
|
||||
jj_tool_bar.extend (help_button)
|
||||
jj_tool_bar.extend (create {EV_TOOL_BAR_SEPARATOR})
|
||||
-- Add the tool bar to the box
|
||||
jj_tool_bar_box.extend (jj_tool_bar)
|
||||
jj_tool_bar_box.disable_item_expand (jj_tool_bar)
|
||||
-- Add some space after the `help_button'
|
||||
create lab.make_with_text (" ")
|
||||
jj_tool_bar_box.extend (lab)
|
||||
jj_tool_bar_box.disable_item_expand (lab)
|
||||
ensure
|
||||
toolbar_created: jj_tool_bar /= Void and then not jj_tool_bar.is_empty
|
||||
end
|
||||
|
||||
-- build_standard_status_bar
|
||||
-- -- Create and populate the status bar at bottom of window.
|
||||
-- do
|
||||
-- jj_status_bar.set_border_width (2)
|
||||
-- jj_status_label.align_text_left
|
||||
-- jj_status_bar.extend (jj_status_label)
|
||||
-- ensure
|
||||
-- status_bar_created:
|
||||
-- jj_status_bar /= Void and then
|
||||
-- jj_status_label /= Void
|
||||
-- end
|
||||
|
||||
feature -- Access
|
||||
|
||||
state: MAIN_WINDOW_STATE
|
||||
-- Used to `persist' the state of the widget.
|
||||
-- Redefined as attribute so it gets stored with the object.
|
||||
-- Call `make_state' to create a new state from Current.
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_cancelled: BOOLEAN_REF
|
||||
-- Was an action (in a dialog) cancelled?
|
||||
-- A once function so any JJ_MAIN_WINDOW can recognize it.
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
cancel
|
||||
-- A cancel button in one of the dialogs was pressed.
|
||||
-- Sets `is_cancelled' to True.
|
||||
-- Should be reset to False after it is checked.
|
||||
do
|
||||
is_cancelled.set_item (True)
|
||||
end
|
||||
|
||||
uncancel
|
||||
-- Resets is_cancelled to False
|
||||
do
|
||||
is_cancelled.set_item (False)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
-- restore_with_state (a_state: MAIN_WINDOW_STATE) is
|
||||
-- -- Set up window parameters as read from a file with name `a_file_name'.
|
||||
-- -- `A_file_name' should include the full path and name of the file.
|
||||
-- require
|
||||
-- state_exists: a_state /= Void
|
||||
-- local
|
||||
-- t: like target
|
||||
-- do
|
||||
-- t ?= a_state.target
|
||||
-- if t /= Void then
|
||||
-- set_target (t)
|
||||
-- end
|
||||
-- set_position (a_state.x, a_state.y)
|
||||
-- if a_state.is_maximized then
|
||||
-- maximize
|
||||
-- elseif a_state.is_minimized then
|
||||
-- minimize
|
||||
-- else
|
||||
-- restore
|
||||
-- end
|
||||
-- set_size (a_state.width, a_state.height)
|
||||
-- split_manager.restore_with_state (a_state.split_manager_state)
|
||||
-- end
|
||||
|
||||
show_menu
|
||||
-- Show the menu bar
|
||||
do
|
||||
set_menu_bar (jj_menu_bar)
|
||||
end
|
||||
|
||||
hide_menu
|
||||
-- Hide the menu bar
|
||||
do
|
||||
remove_menu_bar
|
||||
end
|
||||
|
||||
show_button_text
|
||||
-- Show text on all the buttons
|
||||
do
|
||||
-- view_manager.show_button_text
|
||||
-- interface_table.show_button_text
|
||||
end
|
||||
|
||||
hide_button_text
|
||||
-- Show text on all the buttons
|
||||
do
|
||||
-- view_manager.hide_button_text
|
||||
-- interface_table.hide_button_text
|
||||
end
|
||||
|
||||
set_preferences_dialog (a_window: EV_TITLED_WINDOW)
|
||||
-- Make `a_window' available to Current so `a_window' can be shown
|
||||
-- when the `preferences_button' or `preferences_item' is selected.
|
||||
require
|
||||
window_exists: a_window /= Void
|
||||
do
|
||||
preferences_dialog := a_window
|
||||
ensure
|
||||
window_registered: preferences_dialog = a_window
|
||||
end
|
||||
|
||||
-- set_status_text (a_text: STRING_8)
|
||||
-- -- Change the text in the status bar.
|
||||
-- do
|
||||
-- jj_status_label.set_text (a_text)
|
||||
-- end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Update the whole window.
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
-- This simply puts the `display_name' (from EDITABLE) or `generating_type' of
|
||||
-- the `target' into the title bar of the window.
|
||||
s := application.generating_type + ": "
|
||||
if not is_view_empty then
|
||||
if attached {EDITABLE} target as e then
|
||||
s := s + e.display_name.to_string_8
|
||||
else
|
||||
s := s + target.generating_type.name
|
||||
end
|
||||
else
|
||||
s := s + "Empty"
|
||||
end
|
||||
set_title (s)
|
||||
set_widget_states
|
||||
end
|
||||
|
||||
frozen ask_to_save
|
||||
-- Show the `ask_to_save_dialog'
|
||||
do
|
||||
-- check attached {JJ_APPLICATION} (create {EV_ENVIRONMENT}).application as a then
|
||||
-- -- because only {JJ_APPLICATION} should use this. really ???
|
||||
-- w := a.first_window
|
||||
-- ask_to_save_dialog.show_modal_to_window (a.first_window)
|
||||
-- end
|
||||
ask_to_save_dialog.show_modal_to_window (Current)
|
||||
end
|
||||
|
||||
show_save_dialog
|
||||
-- Show the `file_save_dialog'.
|
||||
-- Also, passed as an agent in `ask_to_save_dialog'.
|
||||
do
|
||||
file_save_dialog.show_modal_to_window (main_windows.first)
|
||||
end
|
||||
|
||||
validate_file_name_and_save
|
||||
-- Get a file name and write `save_object' to disk.
|
||||
require
|
||||
-- save_object_exists: save_object.item /= Void
|
||||
local
|
||||
s: STRING
|
||||
f: RAW_FILE
|
||||
do
|
||||
s := file_save_dialog.file_title
|
||||
if is_valid_file_name (s) then
|
||||
create f.make_open_write (s)
|
||||
f.general_store (target)
|
||||
else
|
||||
file_save_dialog.show_modal_to_window (main_windows.first)
|
||||
end
|
||||
end
|
||||
|
||||
validate_file_name_and_open
|
||||
-- Get a file name and read a object into `save_object'
|
||||
require
|
||||
-- save_object_exists: save_object.item /= Void
|
||||
local
|
||||
s: STRING
|
||||
f: RAW_FILE
|
||||
do
|
||||
s := file_open_dialog.file_name
|
||||
if is_valid_file_name (s) then
|
||||
create f.make_open_read (s)
|
||||
if attached f.retrieved as a then
|
||||
if attached {like target_imp} a as t then
|
||||
set_target (t)
|
||||
end
|
||||
end
|
||||
-- if attached {like target_imp} f.retrieved as t then
|
||||
---- set_save_object (a)
|
||||
-- target_imp := t
|
||||
-- end
|
||||
else
|
||||
file_open_dialog.show_modal_to_window (main_windows.first)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Actions
|
||||
|
||||
on_show_preferences_dialog
|
||||
-- React to a press of the preferences button or menu by
|
||||
-- showing the `preferences_dialog'.
|
||||
require
|
||||
preferences_dialog_exists: preferences_dialog /= Void
|
||||
do
|
||||
preferences_dialog.show
|
||||
if preferences_dialog.is_minimized then
|
||||
preferences_dialog.restore
|
||||
end
|
||||
preferences_dialog.raise
|
||||
end
|
||||
|
||||
on_file_open
|
||||
-- React to a request to read a system from disk.
|
||||
do
|
||||
validate_file_name_and_open
|
||||
set_widget_states
|
||||
end
|
||||
|
||||
on_file_save
|
||||
-- React to a request to save the system to disk.
|
||||
local
|
||||
w: JJ_MAIN_WINDOW
|
||||
-- ff: STANDARD_INTERFACE_FILE_FACILITIES
|
||||
do
|
||||
-- create ff
|
||||
-- ff.set_persistent (system)
|
||||
-- ff.validate_file_name_and_save
|
||||
-- set_save_object (target)
|
||||
validate_file_name_and_save
|
||||
-- if system.is_okay then
|
||||
-- Change the title of all JJ_MAIN_WINDOWs targeted
|
||||
-- to `target'
|
||||
from main_windows.start
|
||||
until main_windows.exhausted
|
||||
loop
|
||||
w := main_windows.item
|
||||
if w.target = target then
|
||||
w.draw
|
||||
end
|
||||
main_windows.forth
|
||||
end
|
||||
-- else
|
||||
-- -- save operation failed. Write failure?
|
||||
-- end
|
||||
-- set_widget_states
|
||||
end
|
||||
|
||||
on_get_target: like target
|
||||
-- Needed to be able to `set_pebble_function' for buttons so the
|
||||
-- button can pick the current `target' as a pebble during a pick.
|
||||
do
|
||||
Result := target
|
||||
end
|
||||
|
||||
on_make_new_target
|
||||
-- Create a new target after querying user to save
|
||||
-- current target if necessary.
|
||||
local
|
||||
t: like target
|
||||
do
|
||||
create t
|
||||
set_target (t)
|
||||
-- draw
|
||||
end
|
||||
|
||||
on_about
|
||||
-- Display the About dialog.
|
||||
do
|
||||
about_dialog.show
|
||||
end
|
||||
|
||||
on_maximize_all
|
||||
-- Maximize all the main windows
|
||||
do
|
||||
main_windows.do_all (agent {JJ_MAIN_WINDOW}.maximize)
|
||||
end
|
||||
|
||||
on_minimize_all
|
||||
-- Minimize all the main windows
|
||||
do
|
||||
main_windows.do_all (agent {JJ_MAIN_WINDOW}.minimize)
|
||||
end
|
||||
|
||||
on_raise_all
|
||||
-- Raise all the main windows
|
||||
do
|
||||
main_windows.do_all (agent {JJ_MAIN_WINDOW}.restore)
|
||||
end
|
||||
|
||||
on_drop_in_new_window (a_target: like target)
|
||||
-- React to `a_target' drop on the new_window button.
|
||||
require
|
||||
target_exists: a_target /= Void
|
||||
local
|
||||
w: like Current
|
||||
do
|
||||
create w.make (a_target)
|
||||
w.show
|
||||
end
|
||||
|
||||
on_drop_target (a_target: like target)
|
||||
-- React to drop of `a_target' (on a button?) by changing
|
||||
-- the `target' and setting up views.
|
||||
require
|
||||
target_exists: a_target /= Void
|
||||
do
|
||||
-- system.uncancel
|
||||
-- system.ask_to_save
|
||||
-- if not system.is_cancelled.item then
|
||||
-- set_system (a_system)
|
||||
-- end
|
||||
end
|
||||
|
||||
-- on_make_new_window
|
||||
-- Create a new JJ_MAIN_WINDOW (like Current) and
|
||||
-- target it to the same `system'.
|
||||
-- local
|
||||
-- w: like Current
|
||||
-- do
|
||||
-- create w.make (target)
|
||||
-- w.show
|
||||
-- end
|
||||
|
||||
on_exit
|
||||
-- End the execution, insuring to save unsaved targets.
|
||||
local
|
||||
w: JJ_MAIN_WINDOW
|
||||
do
|
||||
from main_windows.start
|
||||
until main_windows.exhausted or else is_cancelled.item
|
||||
loop
|
||||
w := main_windows.item
|
||||
if not is_view_empty then
|
||||
-- set_save_object (w.target)
|
||||
ask_to_save
|
||||
end
|
||||
main_windows.forth
|
||||
end
|
||||
if not is_cancelled.item then
|
||||
end_application
|
||||
end
|
||||
end
|
||||
|
||||
feature {JJ_MAIN_WINDOW, APPLICATION_STATE} -- Implementation (support routines)
|
||||
|
||||
on_close_window
|
||||
-- A request to close the window has occured.
|
||||
-- If this is the only window displaying `system' then give user
|
||||
-- chance to save the `system' before closing window.
|
||||
-- Remove the `a_window' from `main_windows' list and destroy it.
|
||||
-- If it is the last window then end the application.
|
||||
do
|
||||
uncancel
|
||||
check attached {JJ_APPLICATION} (create {EV_ENVIRONMENT}).application as jj_app then
|
||||
-- Because {JJ_MAIN_WINDOW} (this class) is for use in a {JJ_APPLICATION}.
|
||||
-- if jj_app.persistence_manager.is_pending then
|
||||
ask_to_save
|
||||
-- end
|
||||
if not is_cancelled.item then
|
||||
if main_windows.count = 1 then
|
||||
-- About to close the last window and therefore end the application,
|
||||
-- so save it's state before destroying this last window.
|
||||
end_application
|
||||
else
|
||||
main_windows.start
|
||||
main_windows.prune (Current)
|
||||
destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {COMMAND_MANAGER} -- Implementation
|
||||
|
||||
set_widget_states
|
||||
-- Update the state of the buttons and menu items
|
||||
do
|
||||
-- Item always enabled
|
||||
-- file_menu.enable_sensitive
|
||||
-- file_new_system_item.enable_sensitive
|
||||
-- file_open_item.enable_sensitive
|
||||
-- file_exit_item.enable_sensitive
|
||||
-- help_menu.enable_sensitive
|
||||
-- help_about_item.enable_sensitive
|
||||
-- new_window_button.enable_sensitive
|
||||
-- new_system_button.enable_sensitive
|
||||
-- open_button.enable_sensitive
|
||||
-- help_button.enable_sensitive
|
||||
-- Items conditionally enabled
|
||||
if is_view_empty then
|
||||
file_save_item.disable_sensitive
|
||||
save_button.disable_sensitive
|
||||
elseif command_manager.is_at_marked_state then
|
||||
file_save_item.disable_sensitive
|
||||
save_button.disable_sensitive
|
||||
else
|
||||
file_save_item.enable_sensitive
|
||||
save_button.enable_sensitive
|
||||
end
|
||||
|
||||
if command_manager.is_undoable then
|
||||
edit_undo_item.enable_sensitive
|
||||
undo_button.enable_sensitive
|
||||
else
|
||||
edit_undo_item.disable_sensitive
|
||||
undo_button.disable_sensitive
|
||||
end
|
||||
if command_manager.is_executable then
|
||||
edit_redo_item.enable_sensitive
|
||||
redo_button.enable_sensitive
|
||||
else
|
||||
edit_redo_item.disable_sensitive
|
||||
redo_button.disable_sensitive
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (support routines)
|
||||
|
||||
is_target_in_other_window: BOOLEAN
|
||||
-- Is `target' also contained in some other JJ_MAIN_WINDOW?
|
||||
-- Used to determine if it must be saved when Current is closed.
|
||||
do
|
||||
if target /= Void then
|
||||
from main_windows.start
|
||||
until main_windows.exhausted or else Result
|
||||
loop
|
||||
Result := main_windows.item /= Current and then main_windows.item.target = target
|
||||
main_windows.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end_application
|
||||
-- Close down the application
|
||||
do
|
||||
if attached (create {EV_ENVIRONMENT}).application as a then
|
||||
a.destroy
|
||||
end
|
||||
end
|
||||
|
||||
preferences_dialog: EV_TITLED_WINDOW
|
||||
-- The window, if any, displayed when the `preferences_button' or
|
||||
-- `preferences_item' is selected.
|
||||
-- Can be used as a dialog for setting up the views.
|
||||
|
||||
Default_preferences_dialog: PREFERENCES_WINDOW
|
||||
-- For setting window parameters
|
||||
once
|
||||
-- create Result.make (target)
|
||||
create Result
|
||||
Result.close_request_actions.extend (agent Result.hide)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (dialogs)
|
||||
|
||||
about_dialog: ABOUT_DIALOG
|
||||
-- Show minimal information about the program.
|
||||
once
|
||||
create Result
|
||||
-- Hide when something else is clicked so it can be non-modal
|
||||
-- and so the user does not have to hit the "okay" button or
|
||||
-- explicitely close the dialog.
|
||||
Result.close_request_actions.extend (agent Result.hide)
|
||||
Result.focus_out_actions.extend (agent Result.hide)
|
||||
end
|
||||
|
||||
File_open_dialog: EV_FILE_OPEN_DIALOG
|
||||
-- Standard
|
||||
once
|
||||
create Result
|
||||
-- Result.filters.extend (["*.*", "All files"])
|
||||
Result.open_actions.extend (agent validate_file_name_and_open)
|
||||
Result.cancel_actions.extend (agent cancel)
|
||||
end
|
||||
|
||||
Ask_to_save_dialog: EV_QUESTION_DIALOG
|
||||
-- Asks the user if he wants to save the system.
|
||||
local
|
||||
dc: EV_DIALOG_CONSTANTS
|
||||
do
|
||||
create dc
|
||||
create Result
|
||||
-- Result.set_text ("System is not saved!%N%N Save?")
|
||||
-- Result.button (dc.Ev_yes).select_actions.extend (agent show_save_dialog)
|
||||
Result.set_text ("Some objects have changed! Commit changes?")
|
||||
Result.button (dc.ev_yes).select_actions.extend (agent commit_changes)
|
||||
Result.button (dc.Ev_cancel).select_actions.extend (agent cancel)
|
||||
end
|
||||
|
||||
commit_changes
|
||||
-- Save any changed objects.
|
||||
do
|
||||
check attached {JJ_APPLICATION} (create {EV_ENVIRONMENT}).application as jj_app then
|
||||
-- Because this is used by JJ_APPLICATIONs
|
||||
-- jj_app.persistence_manager.commit
|
||||
end
|
||||
end
|
||||
|
||||
File_save_dialog: EV_FILE_SAVE_DIALOG
|
||||
-- Standard
|
||||
once
|
||||
create Result
|
||||
-- Result.filters.extend (["*.*", "All files"])
|
||||
Result.save_actions.extend (agent validate_file_name_and_save)
|
||||
Result.cancel_actions.extend (agent cancel)
|
||||
end
|
||||
|
||||
feature {NONE} -- Menus
|
||||
|
||||
jj_menu_bar: EV_MENU_BAR
|
||||
-- Standard menu bar for this window.
|
||||
|
||||
file_menu: EV_MENU
|
||||
-- "File" menu for this window (contains New, Open, Close, Exit...)
|
||||
|
||||
file_new_target_item: EV_MENU_ITEM
|
||||
-- "File/New system"
|
||||
|
||||
file_open_item: EV_MENU_ITEM
|
||||
-- "File/Open"
|
||||
|
||||
file_save_item: EV_MENU_ITEM
|
||||
-- "File/Save"
|
||||
|
||||
file_exit_item: EV_MENU_ITEM
|
||||
-- "File/Exit"
|
||||
|
||||
edit_menu: EV_MENU
|
||||
-- "Edit" menu (contains Undo, Redo, Cut, Copy, etc...)
|
||||
|
||||
edit_undo_item: EV_MENU_ITEM
|
||||
-- "Edit/Undo"
|
||||
|
||||
edit_redo_item: EV_MENU_ITEM
|
||||
-- "Edit/Redo"
|
||||
|
||||
tool_menu: EV_MENU
|
||||
-- "Tools" menu (contains Preferences, etc...)
|
||||
|
||||
tool_preferences_item: EV_MENU_ITEM
|
||||
-- "Tools/Preferences"
|
||||
|
||||
window_menu: EV_MENU
|
||||
-- "Window" menu for this window (contains Minimize all, Raise all, etc...)
|
||||
|
||||
window_new_item: EV_MENU_ITEM
|
||||
-- "Window/New"
|
||||
|
||||
window_maximize_all_item: EV_MENU_ITEM
|
||||
-- "Window/Maximize all"
|
||||
|
||||
window_minimize_all_item: EV_MENU_ITEM
|
||||
-- "Window/Minimize all"
|
||||
|
||||
window_raise_all_item: EV_MENU_ITEM
|
||||
-- "Window/Raise all"
|
||||
|
||||
help_menu: EV_MENU
|
||||
-- "Help" menu for this window (contains About...)
|
||||
|
||||
help_about_item: EV_MENU_ITEM
|
||||
-- "Help/About"
|
||||
|
||||
feature {NONE} -- Toolbars and buttons
|
||||
|
||||
jj_tool_bar_box: EV_HORIZONTAL_BOX
|
||||
-- Holder for `jj_tool_bar'. Other items can
|
||||
-- be added here to make a custom bar or to `upper_bar'
|
||||
-- to place another tool_bar below this one.
|
||||
|
||||
jj_tool_bar: EV_TOOL_BAR
|
||||
-- Standard toolbar for this window
|
||||
|
||||
new_window_button: EV_TOOL_BAR_BUTTON
|
||||
-- Create a new system
|
||||
|
||||
new_target_button: EV_TOOL_BAR_BUTTON
|
||||
-- Create a new system for this window
|
||||
|
||||
open_button: EV_TOOL_BAR_BUTTON
|
||||
-- Opens an existing system
|
||||
|
||||
save_button: EV_TOOL_BAR_BUTTON
|
||||
-- To save the system
|
||||
|
||||
minimize_all_button: EV_TOOL_BAR_BUTTON
|
||||
-- To minimize all the JJ_MAIN_WINDOWs
|
||||
|
||||
raise_all_button: EV_TOOL_BAR_BUTTON
|
||||
-- To restore all the JJ_MAIN_WINDOWs
|
||||
|
||||
help_button: EV_TOOL_BAR_BUTTON
|
||||
-- Opens help engine
|
||||
|
||||
undo_button: EV_TOOL_BAR_BUTTON
|
||||
-- To undo the last command
|
||||
|
||||
redo_button: EV_TOOL_BAR_BUTTON
|
||||
-- To redo the last undone command
|
||||
|
||||
feature {NONE} -- Status bar
|
||||
|
||||
-- jj_status_bar: EV_STATUS_BAR
|
||||
-- -- Standard status bar for this window
|
||||
|
||||
-- jj_status_label: EV_LABEL
|
||||
-- -- Label situated in the `jj_status_bar'.
|
||||
-- -- Note: Call `set_status_text' to change the text
|
||||
-- -- displayed in the status bar.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
split_manager: SPLIT_MANAGER
|
||||
-- Controls placement of sub-windows
|
||||
|
||||
feature {NONE} -- Implementation / Constants
|
||||
|
||||
Window_title: STRING = "JJ_MAIN_WINDOW"
|
||||
-- Title of the window.
|
||||
|
||||
Window_width: INTEGER = 800
|
||||
-- Initial width for this window.
|
||||
|
||||
Window_height: INTEGER = 600
|
||||
-- Initial height for this window.
|
||||
|
||||
invariant
|
||||
|
||||
-- system_exists: system /= Void
|
||||
|
||||
end
|
||||
|
36
jj_vision/interface/system/jj_system.e
Normal file
36
jj_vision/interface/system/jj_system.e
Normal file
@@ -0,0 +1,36 @@
|
||||
note
|
||||
description: "[
|
||||
Root object for use with {JJ_MAIN_WINDOW} which can be placed
|
||||
into any number of these windows using the {VIEW} model.
|
||||
]"
|
||||
date: "21 Apr 06"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/system/jj_system.e $"
|
||||
date: "$Date: 2012-05-31 14:05:35 -0400 (Thu, 31 May 2012) $"
|
||||
revision: "$Revision: 10 $"
|
||||
|
||||
|
||||
class
|
||||
JJ_SYSTEM
|
||||
|
||||
inherit
|
||||
|
||||
SHARED
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize_interface
|
||||
-- Set up the interface items into the `interface_table'.
|
||||
do
|
||||
-- interface_table.add_item_with_tuple (<<"{SYSTEM} - System not saved text", "System not saved", "The system has not been saved since last change.", "Changes have been made, but the system has not been save.", "icon_red_cross.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{SYSTEM} - Not in system text", "Not in system", "The displayed interface names are not used by the program.", "The displayed interface names are not used by the program.", "icon_exec_quit_color.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{SYSTEM} - Not allowed pixmap", "Not allowed", "Operation not allowed", "The operation you are attempting is not allowed.", "icon_delete_color.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{SYSTEM} - Empty", "Empty", "Empty view or object", "The view or object is empty.", "icon_class_symbol_gray.ico">>)
|
||||
end
|
||||
|
||||
end
|
63
jj_vision/interface/system/preferences_window.e
Normal file
63
jj_vision/interface/system/preferences_window.e
Normal file
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} dialog for setting user preverences
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/system/preferences_window.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
|
||||
class
|
||||
PREFERENCES_WINDOW
|
||||
|
||||
inherit
|
||||
|
||||
-- SPLIT_VIEW
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
EV_TITLED_WINDOW
|
||||
rename
|
||||
object_id as ise_object_id
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TITLED_WINDOW}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the window
|
||||
do
|
||||
Precursor {EV_TITLED_WINDOW}
|
||||
Precursor {VIEW}
|
||||
set_title ("System Preferences")
|
||||
-- split_manager.extend (create {WINDOW_PREFERENCES_VIEW})
|
||||
extend (create {WINDOW_PREFERENCES_VIEW})
|
||||
end
|
||||
|
||||
end
|
42
jj_vision/interface/system/shared.e
Normal file
42
jj_vision/interface/system/shared.e
Normal file
@@ -0,0 +1,42 @@
|
||||
note
|
||||
description: "[
|
||||
Global objects for use in the "jj_vision" cluster
|
||||
]"
|
||||
date: "10 May 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/system/shared.e $"
|
||||
date: "$Date: 2015-10-15 13:03:35 -0700 (Thu, 15 Oct 2015) $"
|
||||
revision: "$Revision: 21 $"
|
||||
|
||||
class
|
||||
SHARED
|
||||
|
||||
inherit
|
||||
|
||||
ANY
|
||||
|
||||
JJ_FILE_FACILITIES
|
||||
|
||||
feature -- Access, restricted to descendants
|
||||
|
||||
main_windows: LINKED_LIST [JJ_MAIN_WINDOW]
|
||||
-- List of all open JJ_MAIN_WINDOWs
|
||||
once
|
||||
create Result.make
|
||||
end
|
||||
|
||||
command_manager: COMMAND_MANAGER
|
||||
-- Used to undo/redo commands for this system
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
minimum_pixmap_size: INTEGER = 8
|
||||
maximum_pixmap_size: INTEGER = 64
|
||||
|
||||
end
|
||||
|
1342
jj_vision/interface/system/split_manager.e
Normal file
1342
jj_vision/interface/system/split_manager.e
Normal file
File diff suppressed because it is too large
Load Diff
425
jj_vision/interface/tools/edit_tool.e
Normal file
425
jj_vision/interface/tools/edit_tool.e
Normal file
@@ -0,0 +1,425 @@
|
||||
note
|
||||
description: "[
|
||||
A {TOOL} used to hold views for editting an {EDITABLE}
|
||||
]"
|
||||
date: "23 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/tools/edit_tool.e $"
|
||||
date: "$Date: 2013-04-25 18:11:22 -0400 (Thu, 25 Apr 2013) $"
|
||||
revision: "$Revision: 14 $"
|
||||
|
||||
class
|
||||
EDIT_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
TOOL
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_actions,
|
||||
target_imp,
|
||||
set_target
|
||||
-- history_dropdown,
|
||||
-- new_history_item
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {TOOL}
|
||||
create list_editor_view
|
||||
create dialog_editor_view
|
||||
create field_editor_view
|
||||
-- Create the new buttons before Precursor {TOOL} so `initialize'
|
||||
-- can call `set_actions' without a Void reference.
|
||||
create edit_schema_toggle_button
|
||||
create schema_label
|
||||
create new_field_button
|
||||
create delete_field_button
|
||||
create align_fields_button
|
||||
edit_schema_toggle_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_shell_color_buffer))
|
||||
edit_schema_toggle_button.set_tooltip ("EDIT_TOOL.edit_schema_toggle_button")
|
||||
new_field_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_shell_color_buffer))
|
||||
new_field_button.set_tooltip ("EDIT_TOOL.new_field_button")
|
||||
delete_field_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_shell_color_buffer))
|
||||
delete_field_button.set_tooltip ("EDIT_TOOL.delete_field_button")
|
||||
align_fields_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_shell_color_buffer))
|
||||
align_fields_button.set_tooltip ("EDIT_TOOL.align_fields_button")
|
||||
-- Align_fields menu
|
||||
create align_fields_menu
|
||||
create align_on_edit_box_check_item
|
||||
create align_fields_left_item
|
||||
create align_fields_right_item
|
||||
create align_fields_top_item
|
||||
create align_fields_bottom_item
|
||||
create align_fields_horizontal_center_item
|
||||
create align_fields_vertical_center_item
|
||||
-- New field menu
|
||||
create new_field_menu
|
||||
create new_string_field_item
|
||||
create new_integer_field_item
|
||||
create new_date_field_item
|
||||
-- Use default schema at first
|
||||
create schema
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the window
|
||||
-- Create the views in the window using agents.
|
||||
local
|
||||
vs: EV_VERTICAL_SEPARATOR
|
||||
do
|
||||
build_align_fields_menu
|
||||
build_new_field_menu
|
||||
-- Create the tool and its views
|
||||
Precursor {TOOL}
|
||||
-- Add `schema_label' to the `title_bar'.
|
||||
check
|
||||
title_bar_has_target_label: title_bar.has (target_label)
|
||||
-- because Precursor {TOOL} should have put it there.
|
||||
end
|
||||
title_bar.start
|
||||
title_bar.search (tool_name_label)
|
||||
create vs
|
||||
title_bar.put_right (schema_label)
|
||||
title_bar.disable_item_expand (schema_label)
|
||||
title_bar.put_right (vs)
|
||||
title_bar.disable_item_expand (vs)
|
||||
-- Add the buttons to the `tool_bar' (from TOOL)
|
||||
tool_bar.extend (edit_schema_toggle_button)
|
||||
-- Create the views
|
||||
split_manager.set_horizontal
|
||||
split_manager.extend_siblings (field_editor_view, dialog_editor_view)
|
||||
split_manager.set_vertical
|
||||
split_manager.extend_siblings (split_manager.last_view, list_editor_view)
|
||||
-- Set up the views in this tool.
|
||||
split_manager.enable_mode_changes
|
||||
split_manager.set_split_mode
|
||||
split_manager.disable_view (field_editor_view)
|
||||
end
|
||||
|
||||
-- initialize_interface
|
||||
-- -- Add interface items for this class to the `interface_table'.
|
||||
-- do
|
||||
-- Precursor {TOOL}
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL}", "EDIT_TOOL", "This is an EDIT_TOOL.", "This tool is used to create schemas.", "icon_tool_color.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL}.edit_schema_toggle_button", "Toggles schema build mode", "Click this button to tobble between schema building and normal view", "This tool is used to create schemas.", "icon_tool_color.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL}.new_field_button", "Create a new field", "Open a drop-down menu for adding fields.", "This button opens a drop-down menu for creating new fields.", "icon_exe_up_to_date.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL}.delete_field_button", "Delete field", "Delete the selected fields", "This button deletes the selected fields from the schema.", "icon_exec_quit_color.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL}.align_fields_button", "Align fields", "Align the selected fields.", "This button pulls down a menu for aligning fields in various methods.", "icon_format_clickable_color.ico">>)
|
||||
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL} - new_string_field", "Create a STRING field", "Create a STRING field", "Creates a new field of type STRING.", "icon_display_labels_color.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL} - new_integer_field", "Create an INTEGER field", "Create an INTEGER field", "Creates a new field of type INTEGER.", "icon_once_symbol.ico">>)
|
||||
-- interface_table.add_item_with_tuple (<<"{EDIT_TOOL} - new_date_field", "Create a DATE field", "Create a DATE field", "Creates a new field of type DATE.", "icon_new_editor_color.ico">>)
|
||||
-- end
|
||||
|
||||
build_align_fields_menu
|
||||
-- Build the `align_fields_menu'.
|
||||
do
|
||||
-- put items into the menu
|
||||
align_fields_menu.extend (align_on_edit_box_check_item)
|
||||
align_fields_menu.extend (align_fields_left_item)
|
||||
align_fields_menu.extend (align_fields_right_item)
|
||||
align_fields_menu.extend (align_fields_top_item)
|
||||
align_fields_menu.extend (align_fields_bottom_item)
|
||||
align_fields_menu.extend (align_fields_horizontal_center_item)
|
||||
align_fields_menu.extend (align_fields_vertical_center_item)
|
||||
end
|
||||
|
||||
build_new_field_menu
|
||||
-- Build the `new_field_menu'
|
||||
do
|
||||
-- Put the items into the menu
|
||||
new_field_menu.extend (new_string_field_item)
|
||||
new_field_menu.extend (new_integer_field_item)
|
||||
new_field_menu.extend (new_date_field_item)
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add actions to the widgets
|
||||
do
|
||||
Precursor {TOOL}
|
||||
-- Set actions for buttons and menus
|
||||
edit_schema_toggle_button.select_actions.extend (agent on_edit_schema_toggle_button_pressed)
|
||||
new_field_button.select_actions.extend (agent on_new_field_button_pressed)
|
||||
new_string_field_item.select_actions.extend (agent on_create_new_string_field)
|
||||
new_date_field_item.select_actions.extend (agent on_create_new_date_field)
|
||||
new_integer_field_item.select_actions.extend (agent on_create_new_integer_field)
|
||||
delete_field_button.select_actions.extend (agent on_delete_field)
|
||||
-- Set actions for views
|
||||
dialog_editor_view.control_select_actions.extend (agent on_control_selected)
|
||||
-- Reminder: Though the `target_label' is part of TOOL, the ability to
|
||||
-- change the "field" displayed in the label is only changable from
|
||||
-- a system using this [EDIT_TOOL] class.
|
||||
tool_name_label.drop_actions.extend (agent on_set_target_label_field)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
selected_control: detachable CONTROL
|
||||
-- The control last selected by the user in "schema-edit" mode.
|
||||
|
||||
list_editor_view: LIST_EDITOR_VIEW
|
||||
-- View in list format for editting the schema.
|
||||
|
||||
dialog_editor_view: DIALOG_EDITOR_VIEW
|
||||
-- View for editting a record.
|
||||
|
||||
field_editor_view: FIELD_EDITOR_VIEW
|
||||
-- View for editting specific fields from the record's schema.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_target: like target)
|
||||
-- Change `target' and pass it on to the views.
|
||||
do
|
||||
-- Must handle a FIELD differently.
|
||||
if attached {FIELD} a_target as f then
|
||||
if is_edit_schema_mode then
|
||||
field_editor_view.set_record (f)
|
||||
end
|
||||
else
|
||||
Precursor {TOOL} (a_target)
|
||||
list_editor_view.set_record (a_target)
|
||||
dialog_editor_view.set_record (a_target)
|
||||
dialog_editor_view.set_schema (get_schema)
|
||||
draw
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_edit_schema_mode: BOOLEAN
|
||||
-- Is the tool in a mode to allow changes to the schema?
|
||||
|
||||
feature {NONE} -- Implementation (actions)
|
||||
|
||||
on_edit_schema_toggle_button_pressed
|
||||
-- React to a press of the edit_schema_toggle_button' by
|
||||
-- toggling between "schema-edit" mode and "normal" mode.
|
||||
do
|
||||
if edit_schema_toggle_button.is_selected then
|
||||
-- Add the `field_editor_view'.
|
||||
split_manager.enable_view (field_editor_view)
|
||||
split_manager.set_split_mode
|
||||
split_manager.disable_mode_changes
|
||||
dialog_editor_view.control_select_actions.resume
|
||||
-- Add the buttons
|
||||
tool_bar.extend (new_field_button)
|
||||
tool_bar.extend (delete_field_button)
|
||||
tool_bar.extend (align_fields_button)
|
||||
is_edit_schema_mode := True
|
||||
else
|
||||
-- Remove the `field_editor_view'.
|
||||
split_manager.enable_mode_changes
|
||||
split_manager.disable_view (field_editor_view)
|
||||
dialog_editor_view.control_select_actions.block
|
||||
-- Remove the buttons
|
||||
tool_bar.start
|
||||
tool_bar.prune (new_field_button)
|
||||
tool_bar.start
|
||||
tool_bar.prune (delete_field_button)
|
||||
tool_bar.start
|
||||
tool_bar.prune (align_fields_button)
|
||||
is_edit_schema_mode := False
|
||||
end
|
||||
end
|
||||
|
||||
on_control_selected (a_control: CONTROL)
|
||||
-- A control has been selected in "schema-edit" mode.
|
||||
-- Added as agent to `dialog_editor_view.control_selected_actions' in
|
||||
-- feature `on_edit_schema_toggle_button_pressed'.
|
||||
require
|
||||
control_exists: a_control /= Void
|
||||
do
|
||||
selected_control := a_control
|
||||
field_editor_view.set_record (a_control.field)
|
||||
field_editor_view.set_schema (a_control.field.schema)
|
||||
syncronize_buttons
|
||||
ensure
|
||||
control_was_selected: selected_control = a_control
|
||||
field_was_set: field_editor_view.record = a_control.field
|
||||
end
|
||||
|
||||
on_new_field_button_pressed
|
||||
-- React to a press of the `new_field_button'.
|
||||
do
|
||||
new_field_menu.show
|
||||
end
|
||||
|
||||
on_create_new_string_field
|
||||
-- React to a menu item or button used to create a new string field.
|
||||
local
|
||||
f: STRING_FIELD
|
||||
c: CHANGE_FIELDS_COMMAND
|
||||
do
|
||||
create f
|
||||
create c.make (schema, f)
|
||||
command_manager.add_command (c)
|
||||
end
|
||||
|
||||
on_create_new_date_field
|
||||
-- React to a menu item or button used to create a new date field.
|
||||
local
|
||||
f: YMD_TIME_FIELD
|
||||
c: CHANGE_FIELDS_COMMAND
|
||||
do
|
||||
create f
|
||||
create c.make (schema, f)
|
||||
command_manager.add_command (c)
|
||||
end
|
||||
|
||||
on_create_new_integer_field
|
||||
-- React to a menu item or button used to create a new integer field.
|
||||
local
|
||||
f: INTEGER_FIELD
|
||||
c: CHANGE_FIELDS_COMMAND
|
||||
do
|
||||
create f
|
||||
create c.make (schema, f)
|
||||
command_manager.add_command (c)
|
||||
end
|
||||
|
||||
on_delete_field
|
||||
-- Remove the selected field from the schema.
|
||||
require
|
||||
is_deletable: not target.schema.has_mandatory (field_editor_view.record)
|
||||
local
|
||||
f: FIELD
|
||||
c: CHANGE_FIELDS_COMMAND
|
||||
do
|
||||
if not field_editor_view.is_view_empty then
|
||||
f := field_editor_view.record
|
||||
create c.make (schema, f)
|
||||
c.set_delete_action
|
||||
command_manager.add_command (c)
|
||||
end
|
||||
end
|
||||
|
||||
on_set_target_label_field (a_field: STRING_FIELD)
|
||||
-- Change the "global" field to be used to determine what part of
|
||||
-- an EDITABLE (based on `a_field') to display in the drop-downs
|
||||
-- and lists, etc. (See `set_target_label_field' from EDITABLE.)
|
||||
require
|
||||
field_exists: a_field /= Void
|
||||
local
|
||||
e: EDITABLE
|
||||
do
|
||||
-- Because `target_label_field' is a once feature just need to
|
||||
-- make sure it is called; to do that I need an EDITABLE.
|
||||
create e
|
||||
e.set_target_label_field (a_field)
|
||||
end
|
||||
|
||||
|
||||
feature {FIELD_EDITOR_VIEW} -- Implementation
|
||||
|
||||
get_schema: SCHEMA
|
||||
-- Obtain a schema from the `record'
|
||||
require
|
||||
target_exists: target /= Void
|
||||
do
|
||||
if target.schema /= schema then
|
||||
Result := target.schema
|
||||
schema := Result
|
||||
else
|
||||
Result := schema
|
||||
end
|
||||
ensure
|
||||
result_exists: result /= Void
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
target_imp: detachable EDITABLE
|
||||
-- Detachable implementation of `target' for void-safety
|
||||
|
||||
schema: SCHEMA
|
||||
-- The last schema used and passed to the views.
|
||||
|
||||
syncronize_buttons
|
||||
-- Make sure the buttons are in the correct state.
|
||||
local
|
||||
f: FIELD
|
||||
do
|
||||
f := field_editor_view.record
|
||||
if schema.has_mandatory (f) then
|
||||
delete_field_button.disable_sensitive
|
||||
else
|
||||
delete_field_button.enable_sensitive
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (buttons)
|
||||
|
||||
edit_schema_toggle_button: EV_TOGGLE_BUTTON --EV_TOOL_BAR_TOGGLE_BUTTON
|
||||
-- Toggles between normal mode and a mode allowing
|
||||
-- editting of the `schema' from `record'.
|
||||
|
||||
schema_label: EV_LABEL
|
||||
-- Shows the `id' or name of the schema currently in use.
|
||||
|
||||
align_fields_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Aligns a group of fields
|
||||
|
||||
delete_field_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Deletes the selected field(s) from the `schema' of `record'
|
||||
|
||||
new_field_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Pulls down a menu for creating a new field
|
||||
|
||||
new_field_menu: EV_MENU
|
||||
-- Pull down menu for selecting the type of field
|
||||
-- activated by the `new_field_button'.
|
||||
|
||||
new_string_field_item: EV_MENU_ITEM
|
||||
-- Used to create a new STRING_FIELD
|
||||
|
||||
new_integer_field_item: EV_MENU_ITEM
|
||||
-- Used to create a new INTEGER_FIELD
|
||||
|
||||
new_date_field_item: EV_MENU_ITEM
|
||||
-- Used to create a new YMD_TIME_FIELD
|
||||
|
||||
align_fields_menu: EV_MENU
|
||||
-- Pull down menu for selecting the field alignment method,
|
||||
-- activated by the `align_field_button'.
|
||||
|
||||
align_on_edit_box_check_item: EV_CHECK_MENU_ITEM
|
||||
-- Select to make allignments key off the edit boxes of the
|
||||
-- selected controls as opposed to the labels.
|
||||
|
||||
align_fields_left_item: EV_MENU_ITEM
|
||||
-- Align the left sides of the selected controls
|
||||
|
||||
align_fields_right_item: EV_MENU_ITEM
|
||||
-- Align the right sides of the selected controls
|
||||
|
||||
align_fields_top_item: EV_MENU_ITEM
|
||||
-- Align the tops of the selected controls
|
||||
|
||||
align_fields_bottom_item: EV_MENU_ITEM
|
||||
-- Align the bottoms of the selected controls
|
||||
|
||||
align_fields_horizontal_center_item: EV_MENU_ITEM
|
||||
-- Align the horizontal centers of the selected controls
|
||||
|
||||
align_fields_vertical_center_item: EV_MENU_ITEM
|
||||
-- Align the vertical centers of the selected controls
|
||||
|
||||
invariant
|
||||
|
||||
has_schema_if_has_record: target_imp /= Void implies schema /= Void
|
||||
has_correct_schema: target_imp /= Void implies target.has_schema (schema)
|
||||
|
||||
end
|
80
jj_vision/interface/tools/text_tool.e
Normal file
80
jj_vision/interface/tools/text_tool.e
Normal file
@@ -0,0 +1,80 @@
|
||||
note
|
||||
description: "[
|
||||
A {TOOL} that holds a {TEXT_VIEW} in which to edit a long string
|
||||
]"
|
||||
date: "4 Jan 08"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/tools/text_tool.e $"
|
||||
date: "$Date: 2013-06-16 13:26:06 -0700 (Sun, 16 Jun 2013) $"
|
||||
revision: "$Revision: 15 $"
|
||||
|
||||
class
|
||||
TEXT_TOOL
|
||||
|
||||
inherit
|
||||
|
||||
TOOL
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
build_tool_bars,
|
||||
add_actions
|
||||
-- view
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {TOOL}
|
||||
create clear_button
|
||||
create view
|
||||
clear_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_shell_color_buffer))
|
||||
clear_button.set_tooltip ("{EDIT_TOOL}.clear_button")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window
|
||||
do
|
||||
Precursor {TOOL}
|
||||
split_manager.extend (view)
|
||||
end
|
||||
|
||||
build_tool_bars
|
||||
-- Create the two toolbars.
|
||||
do
|
||||
Precursor {TOOL}
|
||||
tool_bar.extend (clear_button)
|
||||
-- tool_bar.extend (create {EV_TOOL_BAR_SEPARATOR})
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Adds agents to the buttons and menues.
|
||||
do
|
||||
Precursor {TOOL}
|
||||
clear_button.pointer_button_press_actions.force_extend (agent clear)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
clear
|
||||
-- delete all text
|
||||
do
|
||||
view.remove_text
|
||||
end
|
||||
|
||||
clear_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Button to move to previous record
|
||||
|
||||
view: TEXT_VIEW
|
||||
-- Text area for displaying ships info, etc.
|
||||
|
||||
end
|
750
jj_vision/interface/tools/tool.e
Normal file
750
jj_vision/interface/tools/tool.e
Normal file
@@ -0,0 +1,750 @@
|
||||
note
|
||||
description: "[
|
||||
Base class for all the tool windows. Has history list for
|
||||
stepping forward and backward through the `viewable_items'
|
||||
which have been displayed in the tool.
|
||||
|
||||
The {TOOL} is a EV_FRAME containing an EV_VERTICAL_BOX called
|
||||
`main_container'. Into `main_container' is placed an EV_HORIZONTAL_BOX
|
||||
serving as a toolbar called `title_bar'. (An EV_HORIZONTAL_BOX was
|
||||
used instead of a EV_TOOL_BAR in order to add widgets other than
|
||||
EV_TOOLBAR_BUTTONS to the toolbar, giving the desired look.) The
|
||||
`title_bar' is built by adding text, buttons, spaces, other bars, etc
|
||||
to it. Below the `title_bar' is added the `cell' from `split_manager'
|
||||
which contains any {VIEW}s in the tool.
|
||||
|
||||
TNL = `tool_name_label' -- contains the `name' of the tool
|
||||
HTB = `history_tool_bar` -- contains the forth and back buttons
|
||||
TL = `target_label' -- shows the name of the object in the tool
|
||||
TB = `tool_bar' -- clients add buttons here
|
||||
UT = `user_text' -- an EV_LABEL allowed to expand (see `set_user_text')
|
||||
RTB = `resize_tool_bar' -- contains the minimize/miximize and close buttons
|
||||
FB = `forth_button' -- To go back in the history
|
||||
BB = `back_button' -- to go forward in the history
|
||||
xB = `maximize_button' or `restore_button'
|
||||
X = `close_button'
|
||||
`bar' = split_manager.bar -- any buttons produced by `split_manager' are here
|
||||
|
||||
|------------------------------ title bar -----------------------------------|
|
||||
| | TNL | |--- HTB ---| | TL | |-- TB --| | `bar' | | UT | |--- RTB ---|
|
||||
| | |BB| |FB| | | ... | | ... | | |xB| |X| |
|
||||
|----------------------------------------------------------------------------|
|
||||
| |
|
||||
| |
|
||||
| split_manager.cell |
|
||||
| |
|
||||
| |
|
||||
|----------------------------------------------------------------------------|
|
||||
|
||||
The `bar' and `cell', both from `split_manager', will be empty because no
|
||||
{VIEW}s have been added to the `split_manager'. Descendants should follow this
|
||||
pattern as described in class {SPLIT_MANAGER}, redefining `initialize'.
|
||||
|
||||
feature initialize is
|
||||
-- Set up the window.
|
||||
-- Redefine to add the views to the window.
|
||||
do
|
||||
Precursor {TOOL}
|
||||
split_manager.extend (view_one)
|
||||
split_manager.extend (view_two)
|
||||
end
|
||||
|
||||
Feature `initialize' above assumes two features, `view_one' and `view_two',
|
||||
to be defined to return a descendant of {VIEW} and some effected EV_WIDGET.
|
||||
]"
|
||||
date: "30 Sep 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/tools/tool.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
TOOL
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_actions,
|
||||
set_target,
|
||||
draw,
|
||||
state
|
||||
end
|
||||
|
||||
EV_FRAME
|
||||
rename
|
||||
object_id as ise_object_id
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
PIXEL_BUFFERS
|
||||
undefine
|
||||
default_create,
|
||||
copy
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_FRAME}
|
||||
-- create history
|
||||
create history_dropdown
|
||||
create main_container
|
||||
-- Create the action sequences
|
||||
create maximize_actions
|
||||
create close_actions
|
||||
create restore_actions
|
||||
-- Create the buttons
|
||||
create title_bar
|
||||
create tool_bar
|
||||
create history_tool_bar
|
||||
-- create user_text
|
||||
create resize_tool_bar
|
||||
create tool_name_label
|
||||
create target_label
|
||||
-- create history_combo -- see "fix me" comment before `update_history_combo' feature
|
||||
create split_manager
|
||||
-- Create buttons
|
||||
create back_button
|
||||
create forth_button
|
||||
create maximize_button
|
||||
create restore_button
|
||||
create close_button
|
||||
size_button := maximize_button
|
||||
-- Set button attributes
|
||||
back_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_back_color_buffer))
|
||||
back_button.set_tooltip ("Back")
|
||||
forth_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_forth_color_buffer))
|
||||
forth_button.set_tooltip ("Forth")
|
||||
maximize_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_maximize_color_buffer))
|
||||
maximize_button.set_tooltip ("Maximize")
|
||||
restore_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_restore_color_buffer))
|
||||
restore_button.set_tooltip ("Restore")
|
||||
close_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_close_color_buffer))
|
||||
close_button.set_tooltip ("Close")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Build the interface for this window
|
||||
-- Must create `view' before calling this.
|
||||
local
|
||||
hs: EV_HORIZONTAL_SEPARATOR
|
||||
do
|
||||
Precursor {EV_FRAME}
|
||||
Precursor {VIEW}
|
||||
-- tools.extend (Current)
|
||||
-- Prevent the tool from holding more than one target, so
|
||||
-- the history functions will work.
|
||||
history_dropdown.set_parent_tool (Current)
|
||||
target_label.set_minimum_width (Target_label_width)
|
||||
-- view_manager.set_single_mode
|
||||
-- split_manager.disable_mode_changes
|
||||
-- Create the toolbar
|
||||
build_tool_bars
|
||||
build_title_bar
|
||||
-- To get the tool bar look I used small 16x16 pixel icons.
|
||||
-- The `title_bar' is an EV_HORIZONTAL_BOX which contains several
|
||||
-- widets. These are a EV_LABLE, an EV_TOOL_BAR, another label
|
||||
-- (which is allowed to expand), and finally another EV_TOOL_BAR
|
||||
-- containing the `minimize_button' or the `restore_button' (depending
|
||||
-- on `is_maximized') and the `close_button'.
|
||||
main_container.extend (title_bar)
|
||||
main_container.disable_item_expand (title_bar)
|
||||
create hs
|
||||
main_container.extend (hs)
|
||||
main_container.disable_item_expand (hs)
|
||||
main_container.extend (split_manager.cell)
|
||||
extend (main_container)
|
||||
set_minimum_height (100)
|
||||
-- set_view (Default_view)
|
||||
-- set_button_states
|
||||
-- No, do not call `add_actions'; it is already called
|
||||
-- from {VIEW}.`initialize' throught {SPLIT_VIEW}
|
||||
-- add_actions
|
||||
end
|
||||
|
||||
build_title_bar
|
||||
-- Create the small title bar at top of tool
|
||||
local
|
||||
lab: EV_LABEL
|
||||
do
|
||||
-- Add the name of tool to the title bar
|
||||
tool_name_label.set_text (generating_type.name)
|
||||
title_bar.extend (tool_name_label)
|
||||
title_bar.disable_item_expand (tool_name_label)
|
||||
-- Add the forth and back buttons (in `history_tool_bar')
|
||||
title_bar.extend (history_tool_bar)
|
||||
title_bar.disable_item_expand (history_tool_bar)
|
||||
-- Add a title to the tool
|
||||
-- title_bar.extend (target_label)
|
||||
-- title_bar.disable_item_expand (target_label)
|
||||
-- Add a history list combo box
|
||||
-- history_combo.disable_edit
|
||||
-- title_bar.extend (history_combo) -- see "fix me" comment before `update_history_combo' feature
|
||||
-- If use EV_COMBO_BOX the title bar must be bigger to
|
||||
-- allow for `minimum_height' of the box.
|
||||
-- Add the tool bar (to be used in descendants
|
||||
title_bar.extend (tool_bar)
|
||||
title_bar.disable_item_expand (tool_bar)
|
||||
-- Put in a spacer to move the mode buttons to right
|
||||
create lab.make_with_text (" ")
|
||||
title_bar.extend (lab)
|
||||
title_bar.disable_item_expand (lab)
|
||||
-- Add the `bar' from `view_manager' here
|
||||
title_bar.extend (split_manager.bar)
|
||||
-- title_bar.disable_item_expand (split_manager.bar)
|
||||
-- Add the maximize/minimize and hide buttons (in `resize_tool_bar')
|
||||
title_bar.extend (resize_tool_bar)
|
||||
title_bar.disable_item_expand (resize_tool_bar)
|
||||
end
|
||||
|
||||
build_tool_bars
|
||||
-- Create the tool bar.
|
||||
local
|
||||
vs: EV_VERTICAL_SEPARATOR
|
||||
do
|
||||
history_tool_bar.extend (back_button)
|
||||
history_tool_bar.extend (forth_button)
|
||||
history_tool_bar.extend (target_label)
|
||||
-- create vs
|
||||
-- history_tool_bar.extend (vs)
|
||||
-- history_tool_bar.disable_item_expand (vs)
|
||||
resize_tool_bar.extend (size_button)
|
||||
resize_tool_bar.extend (close_button)
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add functionality to the buttons.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
target_label.set_pebble_function (agent on_get_target)
|
||||
-- Add actions to the buttons.
|
||||
maximize_button.select_actions.extend (agent on_maximize)
|
||||
restore_button.select_actions.extend (agent on_restore)
|
||||
close_button.select_actions.extend (agent on_close)
|
||||
back_button.select_actions.extend (agent on_back)
|
||||
forth_button.select_actions.extend (agent on_forth)
|
||||
-- Add actions to `history'
|
||||
history_dropdown.select_actions.extend (agent on_history_item_selected)
|
||||
target_label.pointer_button_press_actions.extend (agent on_target_label_selected)
|
||||
-- target_label.drop_actions.extend (agent on_field_dropped_on_target_label)
|
||||
-- see "fix me" comment before `update_history_combo' feature
|
||||
-- history_combo.select_actions.extend (agent on_history_selected)
|
||||
-- Add actions to update any views contained in this tool
|
||||
-- No. Don't do this as the tool may contain views which only want to handle a part of the viewable.
|
||||
-- Passing the wrong kind breaks the contract. Make each descendent descide what to pass to its children views.
|
||||
-- viewable_added_action_sequence.extend (agent on_viewable_added)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
tool_bar: EV_HORIZONTAL_BOX --EV_TOOL_BAR
|
||||
-- Available for adding new buttons in descendants.
|
||||
|
||||
state: TOOL_STATE
|
||||
-- Snapshot of the current settings of Current
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_target: like target)
|
||||
-- Change the value of `target' and add it to the `object_set' (the set
|
||||
-- of objects contained in this view. The old target is removed from
|
||||
-- the set.
|
||||
do
|
||||
Precursor {VIEW} (a_target)
|
||||
update_history
|
||||
-- if target_imp /= a_target then
|
||||
-- Precursor {VIEW} (a_target)
|
||||
---- add_object (a_target.target_label_field)
|
||||
---- tool_label.set_accept_cursor (a_viewable.accept_cursor)
|
||||
---- tool_label.set_deny_cursor (a_viewable.deny_cursor)
|
||||
-- update_history
|
||||
-- draw
|
||||
-- end
|
||||
end
|
||||
|
||||
-- set_user_text (a_string: STRING)
|
||||
-- -- Change the `user_text'
|
||||
-- do
|
||||
-- user_text.set_text (a_string)
|
||||
-- end
|
||||
|
||||
feature {SPLIT_MANAGER, HISTORY_DROPDOWN} -- Access
|
||||
|
||||
tool_name_label: EV_LABEL
|
||||
-- String in top left of toolbar to display the name of the tool.
|
||||
|
||||
target_label: EV_LABEL
|
||||
-- String in the bar to display the name of the `target'.
|
||||
|
||||
maximize_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed when the tool is maximized.
|
||||
|
||||
close_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed when the tool is closed.
|
||||
|
||||
restore_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed when the tool is restored.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
-- set_user_text (a_text: STRING_8)
|
||||
-- -- Change the `user_text' that is displayed in the title bar.
|
||||
-- do
|
||||
-- user_text.set_text (a_text)
|
||||
-- end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_maximized: BOOLEAN
|
||||
-- Is the tool in a maximized state?
|
||||
|
||||
is_resizable: BOOLEAN
|
||||
-- Is the tool resizable? (E.g. is the `resize_tool_bar' visible?)
|
||||
do
|
||||
Result := resize_tool_bar.is_displayed
|
||||
end
|
||||
|
||||
-- is_destroyed: BOOLEAN
|
||||
-- -- Is `Current' no longer usable?
|
||||
-- do
|
||||
-- Result := not tools.has (Current) and Precursor {EV_FRAME}
|
||||
-- end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
enable_resize
|
||||
-- Allow the `resize_tool_bar' to show.
|
||||
do
|
||||
resize_tool_bar.show
|
||||
end
|
||||
|
||||
disable_resize
|
||||
-- Hide the `resize_tool_bar'.
|
||||
do
|
||||
resize_tool_bar.hide
|
||||
end
|
||||
|
||||
enable_history
|
||||
-- Make the `history_tool_bar' visible
|
||||
do
|
||||
history_tool_bar.show
|
||||
-- target_label.show
|
||||
end
|
||||
|
||||
disable_history
|
||||
-- Make the `history_tool_bar' NOT visible
|
||||
do
|
||||
history_tool_bar.hide
|
||||
-- target_label.hide
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Builds the string shown at top of the tool in `viewable_label'
|
||||
-- using the id of the object.
|
||||
local
|
||||
n: STRING
|
||||
s: STRING
|
||||
f: EV_FONT
|
||||
i: INTEGER
|
||||
w: INTEGER -- for testing
|
||||
do
|
||||
if is_view_empty then
|
||||
n := "Empty"
|
||||
else
|
||||
if attached {EDITABLE} target as e then
|
||||
n := e.display_name
|
||||
else
|
||||
n := target.generating_type
|
||||
end
|
||||
end
|
||||
f := target_label.font
|
||||
create s.make (0)
|
||||
from i := 1
|
||||
until i > n.count or else f.string_width (s) >= Target_label_width
|
||||
loop
|
||||
w := f.string_width (s)
|
||||
s.append_character (n.item (i))
|
||||
i := i + 1
|
||||
end
|
||||
if f.string_width (s) > Target_label_width then
|
||||
s.remove_tail (1)
|
||||
end
|
||||
target_label.set_text (s)
|
||||
target_label.set_tooltip (n)
|
||||
set_button_states
|
||||
end
|
||||
|
||||
feature {NONE} -- Actions
|
||||
|
||||
-- on_field_dropped_on_target_label (a_field: STRING_FIELD) is
|
||||
-- -- React to a drop of `a_field' onto the `target_label'.
|
||||
-- require
|
||||
-- field_exists: a_field /= Void
|
||||
-- do
|
||||
-- target.set_target_label_field (a_field)
|
||||
-- draw_views (target.target_label_field)
|
||||
-- end
|
||||
|
||||
on_target_label_selected (a_x, a_y, a_button: INTEGER;
|
||||
a_x_tilt, a_y_tilt, a_pressure: DOUBLE;
|
||||
a_screen_x, a_screen_y: INTEGER)
|
||||
--
|
||||
do
|
||||
if a_button = 1 then
|
||||
history_dropdown.show
|
||||
end
|
||||
end
|
||||
|
||||
on_history_item_selected
|
||||
-- React to an item selection from the `history_dropdown'.
|
||||
do
|
||||
set_target (selected_history_item_target)
|
||||
end
|
||||
|
||||
on_get_target: like target
|
||||
-- Used as agent for `target_label.get_pebble_function' because
|
||||
-- an attribute cannot be used as an agent
|
||||
do
|
||||
Result := target
|
||||
end
|
||||
|
||||
-- see "fix me" comment before `update_history_combo' feature
|
||||
-- on_history_selected is
|
||||
-- -- Handle an item select in the history combo box
|
||||
-- require
|
||||
-- history_exists: history /= Void
|
||||
-- local
|
||||
-- cli: CLUSTER_LIST_ITEM
|
||||
-- do
|
||||
-- cli ?= history_combo.selected_item
|
||||
-- check
|
||||
-- cli_not_void: cli /= Void -- because only CLUSTER_LIST_ITEMS should be in list
|
||||
-- end
|
||||
-- set_cluster (cli.cluster)
|
||||
-- end
|
||||
|
||||
on_back
|
||||
-- Handle a go back request (from button or menu).
|
||||
require
|
||||
history_exists: history_dropdown /= Void
|
||||
history_can_go_back: not history_dropdown.is_off and then not history_dropdown.is_before
|
||||
local
|
||||
v: HISTORY_ITEM
|
||||
do
|
||||
history_dropdown.back
|
||||
v := history_dropdown.item
|
||||
check attached {like target} v.target as t then
|
||||
set_target (t)
|
||||
end
|
||||
set_button_states
|
||||
end
|
||||
|
||||
on_forth
|
||||
-- Handle a go forth request (from button or menu).
|
||||
require
|
||||
history_exists: history_dropdown /= Void
|
||||
history_can_go_forth: not history_dropdown.is_off and then not history_dropdown.is_after
|
||||
local
|
||||
v: HISTORY_ITEM
|
||||
do
|
||||
history_dropdown.forth
|
||||
v := history_dropdown.item
|
||||
check attached {like target} v.target as t then
|
||||
set_target (t)
|
||||
end
|
||||
set_button_states
|
||||
end
|
||||
|
||||
on_maximize
|
||||
-- React to a request (button or menu) to "maximize" by performing
|
||||
-- the actions in `maximize_actions'.
|
||||
require
|
||||
resizing_allowed: is_resizable
|
||||
do
|
||||
maximize_actions.call ([])
|
||||
end
|
||||
|
||||
on_restore
|
||||
-- React to a request (button or menu) to "maximize" by performing
|
||||
-- the actions in `maximize_actions'.
|
||||
require
|
||||
resizing_allowed: is_resizable
|
||||
do
|
||||
restore_actions.call ([])
|
||||
end
|
||||
|
||||
on_close
|
||||
-- React to a close request by executing the `close_actions'.
|
||||
require
|
||||
resizing_allowed: is_resizable
|
||||
do
|
||||
close_actions.call ([])
|
||||
end
|
||||
|
||||
feature {SPLIT_MANAGER, TOOL_STATE} -- Actions
|
||||
|
||||
maximize
|
||||
-- Put window in maximized state
|
||||
require
|
||||
resizing_allowed: is_resizable
|
||||
do
|
||||
is_maximized := True
|
||||
if not (size_button = restore_button) then
|
||||
resize_tool_bar.go_i_th (resize_tool_bar.index_of (size_button, 1))
|
||||
resize_tool_bar.replace (restore_button)
|
||||
size_button := restore_button
|
||||
end
|
||||
close_button.disable_sensitive
|
||||
end
|
||||
|
||||
restore
|
||||
-- Put window back in default state
|
||||
require
|
||||
-- resizing_allowed: is_resizable
|
||||
do
|
||||
is_maximized := False
|
||||
if not (size_button = maximize_button) then
|
||||
resize_tool_bar.go_i_th (resize_tool_bar.index_of (size_button, 1))
|
||||
resize_tool_bar.replace (maximize_button)
|
||||
size_button := maximize_button
|
||||
end
|
||||
close_button.enable_sensitive
|
||||
end
|
||||
|
||||
close_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button containing an "X" icon
|
||||
|
||||
maximize_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button which parent can access intended
|
||||
-- to be used to maximize the tool.
|
||||
|
||||
restore_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button which parent can access intended
|
||||
-- to be used to normalize (restore) the tool.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
update_history
|
||||
-- Update the history list.
|
||||
require
|
||||
target_exists: target /= Void
|
||||
local
|
||||
found: BOOLEAN
|
||||
v: HISTORY_ITEM
|
||||
oldest_v: HISTORY_ITEM
|
||||
do
|
||||
-- if not history.has (viewable) then -- not needed if history is a SET
|
||||
-- does history have viewable? Must do a search because list items
|
||||
from history_dropdown.start
|
||||
until found or else history_dropdown.is_exhausted
|
||||
loop
|
||||
v := history_dropdown.item
|
||||
if v.is_simular (new_history_item) then
|
||||
found := True
|
||||
else
|
||||
history_dropdown.forth
|
||||
end
|
||||
end
|
||||
if found then
|
||||
-- leave list as is but change time stamp of found item
|
||||
v := history_dropdown.item
|
||||
v.reset_time_stamp
|
||||
else
|
||||
-- not found so must add a new one
|
||||
v := new_history_item
|
||||
history_dropdown.extend (v)
|
||||
if history_dropdown.count > maximum_history_items then
|
||||
-- find oldest item in list and remove it
|
||||
oldest_v := history_dropdown.first
|
||||
from history_dropdown.start
|
||||
until history_dropdown.is_exhausted
|
||||
loop
|
||||
v := history_dropdown.item
|
||||
if v.time_stamp < oldest_v.time_stamp then
|
||||
oldest_v := history_dropdown.item
|
||||
end
|
||||
history_dropdown.forth
|
||||
end
|
||||
history_dropdown.start
|
||||
history_dropdown.prune (oldest_v)
|
||||
end
|
||||
history_dropdown.start
|
||||
history_dropdown.search (v)
|
||||
-- Display a string describing the target
|
||||
target_label.set_text (v.target.generating_type.name + " " + v.time_stamp.as_string)
|
||||
check
|
||||
not_off: not history_dropdown.is_off -- because just inserted it
|
||||
end
|
||||
end
|
||||
-- update_history_combo -- see "fix me" comment before `update_history_combo' feature
|
||||
-- set_button_states
|
||||
-- end
|
||||
ensure
|
||||
proper_histroy_count: history_dropdown.count <= maximum_history_items
|
||||
end
|
||||
|
||||
-- Fix me!!!
|
||||
-- `update_history_combo' is a problem.
|
||||
-- Line "history_combo.wipe_out" causes a system crash, perhaps the screen
|
||||
-- objects are not getting destroyed? Tried destroying each item in combo
|
||||
-- but that did not help.
|
||||
-- Also, can't seem to set the text; get an infinate loop?
|
||||
-- Besides, the combo box is too tall; it make the TOOL's toolbar and buttons
|
||||
-- too big, so commenting it out.
|
||||
-- update_history_combo is
|
||||
-- -- Put the history items into the `history_combo' box
|
||||
-- local
|
||||
-- cli: CLUSTER_LIST_ITEM
|
||||
-- pos: CURSOR
|
||||
-- c: CLUSTER
|
||||
-- do
|
||||
-- history_combo.wipe_out
|
||||
-- pos := history.cursor
|
||||
-- c := history.item.cluster
|
||||
-- from history.start
|
||||
-- until history.exhausted
|
||||
-- loop
|
||||
-- if history.item.cluster /= c then
|
||||
-- create cli.make (history.item.cluster)
|
||||
-- history_combo.extend (cli)
|
||||
-- end
|
||||
-- history.forth
|
||||
-- end
|
||||
-- history.go_to (pos)
|
||||
-- history_combo.enable_edit -- so set_text will work
|
||||
-- history_combo.set_text (history.item.cluster.id)
|
||||
-- history_combo.disable_edit
|
||||
-- end
|
||||
|
||||
set_button_states
|
||||
-- Set the states of the back and forth buttons.
|
||||
do
|
||||
if history_dropdown.is_empty or history_dropdown.is_first or history_dropdown.is_before then
|
||||
back_button.disable_sensitive
|
||||
else
|
||||
back_button.enable_sensitive
|
||||
end
|
||||
if history_dropdown.is_empty or history_dropdown.is_last or history_dropdown.is_after then
|
||||
forth_button.disable_sensitive
|
||||
else
|
||||
forth_button.enable_sensitive
|
||||
end
|
||||
if history_dropdown.is_empty then
|
||||
target_label.disable_sensitive
|
||||
else
|
||||
target_label.enable_sensitive
|
||||
end
|
||||
end
|
||||
|
||||
main_container: EV_VERTICAL_BOX
|
||||
-- Holds the other widgets in the TOOL.
|
||||
|
||||
title_bar: EV_HORIZONTAL_BOX
|
||||
-- Holds the name of tool, `history_tool_bar', and `resize_tool_bar'.
|
||||
|
||||
history_tool_bar: EV_HORIZONTAL_BOX --EV_TOOL_BAR
|
||||
-- The toolbar with the forth, back and posibly history buttons.
|
||||
|
||||
-- user_text: EV_LABEL
|
||||
-- -- Text settable by `set_user_text'
|
||||
|
||||
resize_tool_bar: EV_TOOL_BAR
|
||||
-- Tool bar to hold resize and close buttons
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
forth_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Button containing go back icon
|
||||
|
||||
back_button: EV_BUTTON --EV_TOOL_BAR_BUTTON
|
||||
-- Button containing go forth icon
|
||||
|
||||
size_button: EV_TOOL_BAR_BUTTON
|
||||
-- Button containing maximize or restore icon
|
||||
|
||||
-- history_combo: EV_COMBO_BOX -- see "fix me" comment before `update_history_combo' feature
|
||||
-- To pull down a history list
|
||||
|
||||
maximum_history_items: INTEGER = 5
|
||||
-- Number of items to keep in history list
|
||||
|
||||
feature {HISTORY_DROPDOWN} -- Implementation
|
||||
|
||||
history_dropdown: HISTORY_DROPDOWN
|
||||
-- A dropdown-like box containing the clusters previously targetted
|
||||
-- in this tool from which selections can be made to retarget the tool.
|
||||
|
||||
new_history_item: HISTORY_ITEM
|
||||
-- Helper routine called by `update_history' when it needs to
|
||||
-- create a new time-stamped viewable for placement in the `history'.
|
||||
-- Made a seperate routine because descendents may want to store
|
||||
-- other types of items in the history list.
|
||||
do
|
||||
create Result.make (target)
|
||||
end
|
||||
|
||||
selected_history_item_target: like target
|
||||
-- The item from the `history_dropdown' typecast to `target'
|
||||
do
|
||||
check attached {HISTORY_ITEM} history_dropdown.selected_item as hi then
|
||||
check attached {like target} hi.target as t then
|
||||
Result := t
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Result_exists: Result /= Void
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
split_manager: SPLIT_MANAGER
|
||||
-- Controls placement of sub-windows
|
||||
|
||||
|
||||
--feature {TOOL} -- Implementation
|
||||
|
||||
-- tools: LINKED_SET [TOOL]
|
||||
-- -- Keeps track of all the TOOLs in the system
|
||||
-- once
|
||||
-- create Result.make
|
||||
-- end
|
||||
|
||||
feature {NONE} -- Constants
|
||||
|
||||
Target_label_width: INTEGER = 100
|
||||
-- Sets the size of the `target_label' in pixels.
|
||||
|
||||
invariant
|
||||
|
||||
close_button_exists: close_button /= Void
|
||||
restore_button_exists: restore_button /= Void
|
||||
maximize_button_exists: maximize_button /= Void
|
||||
|
||||
-- label_clickable_when: history.is_empty implies not object_label.is_sensitive
|
||||
|
||||
end
|
203
jj_vision/interface/views/color_fader.e
Normal file
203
jj_vision/interface/views/color_fader.e
Normal file
@@ -0,0 +1,203 @@
|
||||
note
|
||||
description: "[
|
||||
Helper class for manipulating an {EV_COLOR}. Specifically, it
|
||||
gives a range of colors starting from `color' and fading toward
|
||||
a darker or lighter color.
|
||||
Black is at the "dark" end of the scale and a dark_grey (first
|
||||
passing through a lighter color) is at the other end.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
revision: "$Revision: 33 $"
|
||||
|
||||
class
|
||||
COLOR_FADER
|
||||
|
||||
inherit
|
||||
|
||||
ANY
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make_with_color,
|
||||
make_with_color_and_count
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Initialize with `color' rgb = [0.5, 0.5, 0.5] (a mid-tone grey)
|
||||
-- and five steps.
|
||||
do
|
||||
create color.make_with_rgb (0.5, 0.5, 0.5)
|
||||
count := 10
|
||||
end
|
||||
|
||||
make_with_color (a_color: EV_COLOR)
|
||||
-- Initialize with `a_color' and five steps
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
do
|
||||
create color.make_with_rgb (a_color.red, a_color.green, a_color.blue)
|
||||
count := 10
|
||||
end
|
||||
|
||||
make_with_color_and_count (a_color: EV_COLOR; a_count: INTEGER)
|
||||
-- Set `color' and `count'
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
count_large_enough: a_count >= 0
|
||||
do
|
||||
create color.make_with_rgb (a_color.red, a_color.green, a_color.blue)
|
||||
count := a_count
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
color: EV_COLOR
|
||||
-- The original color on which results are based
|
||||
|
||||
count: INTEGER
|
||||
-- The number of steps (or max distance) to go from the original color to full dark
|
||||
|
||||
distance: INTEGER
|
||||
-- The current place in the range of colors
|
||||
-- (Higher numbers are further away from `color'; a `step'
|
||||
-- of zero gives the original color.)
|
||||
|
||||
i_th_darker (a_distance: INTEGER): EV_COLOR
|
||||
-- The color a `a_distance' away from `color' toward the black
|
||||
require
|
||||
distance_large_enough: a_distance >= 0
|
||||
distance_small_enough: a_distance <= count
|
||||
local
|
||||
r, g, b: REAL_32
|
||||
r_dist, g_dist, b_dist: REAL_32
|
||||
r_step, g_step, b_step: REAL_32
|
||||
do
|
||||
r_dist := Darkest - color.red
|
||||
g_dist := Darkest - color.green
|
||||
b_dist := Darkest - color.blue
|
||||
r_step := r_dist / count
|
||||
g_step := g_dist / count
|
||||
b_step := b_dist / count
|
||||
r := color.red + r_step * a_distance
|
||||
g := color.green + g_step * a_distance
|
||||
b := color.blue + b_step * a_distance
|
||||
create Result.make_with_rgb (r, g, b)
|
||||
end
|
||||
|
||||
darker: EV_COLOR
|
||||
-- The color a `distance' away from `color' toward the `Darkest'
|
||||
do
|
||||
Result := i_th_darker (distance)
|
||||
end
|
||||
|
||||
i_th_lighter (a_distance: INTEGER): EV_COLOR
|
||||
-- The color a `a_distance' away from `color' toward the `Grey'
|
||||
require
|
||||
distance_large_enough: a_distance >= 0
|
||||
distance_small_enough: a_distance <= count
|
||||
local
|
||||
r, g, b: REAL_32
|
||||
r_dist, g_dist, b_dist: REAL_32
|
||||
r_step, g_step, b_step: REAL_32
|
||||
do
|
||||
r_dist := Grey - color.red
|
||||
g_dist := Grey - color.green
|
||||
b_dist := Grey - color.blue
|
||||
r_step := r_dist / count
|
||||
g_step := g_dist / count
|
||||
b_step := b_dist / count
|
||||
r := color.red + r_step * a_distance
|
||||
g := color.green + g_step * a_distance
|
||||
b := color.blue + b_step * a_distance
|
||||
create Result.make_with_rgb (r, g, b)
|
||||
end
|
||||
|
||||
lighter: EV_COLOR
|
||||
-- The color a `distance' away from `color' toward the lighter end
|
||||
do
|
||||
Result := i_th_lighter (distance)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_color (a_color: EV_COLOR)
|
||||
-- Make `color' have the same rgb values as `a_color' (copies the values)
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
do
|
||||
color.set_rgb (a_color.red, a_color.green, a_color.blue)
|
||||
end
|
||||
|
||||
set_count (a_count: INTEGER)
|
||||
-- Change the `count'
|
||||
require
|
||||
count_big_enough: a_count >= 0
|
||||
do
|
||||
count := a_count
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
forth
|
||||
-- Increment the `step' up to a maximum of `count'
|
||||
require
|
||||
not_after: not is_after
|
||||
do
|
||||
distance := distance + 1
|
||||
end
|
||||
|
||||
back
|
||||
-- Decrement the `step' downn to a minimum of zero
|
||||
require
|
||||
not_before: not is_before
|
||||
do
|
||||
distance := distance - 1
|
||||
end
|
||||
|
||||
finish
|
||||
-- Move the the last position
|
||||
do
|
||||
distance := count
|
||||
end
|
||||
|
||||
start
|
||||
-- Move to the first position
|
||||
do
|
||||
distance := 1
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_before: BOOLEAN
|
||||
-- Is the `step' before the range?
|
||||
do
|
||||
Result := distance = 0
|
||||
end
|
||||
|
||||
is_after: BOOLEAN
|
||||
-- Is the `step' greater than `count'
|
||||
do
|
||||
Result := distance > count
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
Lightest: REAL_32 = 0.8
|
||||
-- The lightest value to which Current will fade
|
||||
|
||||
Darkest: REAL_32 = 0.2
|
||||
-- The darkest value to which Current will fade
|
||||
|
||||
Grey: REAL_32 = 0.6
|
||||
-- A medium value toward which Current can fade
|
||||
|
||||
invariant
|
||||
|
||||
color_exists: color /= Void
|
||||
count_large_enough: count >= 0
|
||||
|
||||
end
|
61
jj_vision/interface/views/default_view.e
Normal file
61
jj_vision/interface/views/default_view.e
Normal file
@@ -0,0 +1,61 @@
|
||||
note
|
||||
description: "[
|
||||
Used by {VIEW_MANAGER} as a place holder when it has
|
||||
no other views.
|
||||
]"
|
||||
date: "29 Aug 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/default_view.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
DEFAULT_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
EV_LABEL
|
||||
rename
|
||||
object_id as ise_object_id
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_LABEL}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the view
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_LABEL}
|
||||
set_text ("Default view")
|
||||
end
|
||||
|
||||
end
|
443
jj_vision/interface/views/dialog_editor_view.e
Normal file
443
jj_vision/interface/views/dialog_editor_view.e
Normal file
@@ -0,0 +1,443 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} for displaying an {EDITABLE} using it's `schema'
|
||||
]"
|
||||
date: "30 Mar 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/dialog_editor_view.e $"
|
||||
date: "$Date: 2012-05-31 14:05:35 -0400 (Thu, 31 May 2012) $"
|
||||
revision: "$Revision: 10 $"
|
||||
|
||||
class
|
||||
DIALOG_EDITOR_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_STOCK_COLORS
|
||||
rename
|
||||
implementation as colors_implementation
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
is_equal,
|
||||
copy
|
||||
end
|
||||
|
||||
VIEW
|
||||
rename
|
||||
target_imp as record_imp,
|
||||
target as record,
|
||||
set_target as set_record
|
||||
undefine
|
||||
-- default_create,
|
||||
copy,
|
||||
is_equal
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
record_imp,
|
||||
set_record,
|
||||
draw
|
||||
end
|
||||
|
||||
-- EV_CELL
|
||||
EV_FRAME
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
-- data, -- to make it inaplicable
|
||||
-- set_data -- to make it inaplicable
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_FRAME}
|
||||
create changed_controls.make
|
||||
create controls.make
|
||||
create save_actions
|
||||
create control_select_actions
|
||||
create scrollable_area
|
||||
create time_drawn.from_seconds (0)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Create an editor view.
|
||||
do
|
||||
Precursor {EV_FRAME}
|
||||
Precursor {VIEW}
|
||||
extend (scrollable_area)
|
||||
set_save_on_change
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets
|
||||
do
|
||||
scrollable_area.item.drop_actions.extend (agent on_drop_editable)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
scrollable_area: EDITOR_SCROLL_AREA
|
||||
|
||||
schema: SCHEMA
|
||||
-- Current schema in use by the editor.
|
||||
require
|
||||
has_schema: has_schema
|
||||
do
|
||||
check attached schema_imp as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
save_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed after the record is saved.
|
||||
|
||||
control_select_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed when a control is clicked.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_record (a_record: like record)
|
||||
-- Change `record' to `a_record'
|
||||
-- Reload the data into the controls
|
||||
do
|
||||
Precursor {VIEW} (a_record)
|
||||
draw
|
||||
end
|
||||
|
||||
set_schema (a_schema: like schema)
|
||||
-- Change `schema' to `a_schema'.
|
||||
-- Uses the pattern described in feature `set_target' from VIEW to
|
||||
-- add `a_schema' to the `object_set' (the set of objects contained
|
||||
-- in this view) and removes the old schema (if it had one) from
|
||||
-- the `object_set'.
|
||||
-- Also, removes old/add new fields contained in `a_schema'.
|
||||
do
|
||||
-- Save the old `record'
|
||||
if attached schema_imp as s and then s /= a_schema then
|
||||
-- target_set.prune (s)
|
||||
schema_imp := a_schema
|
||||
-- target_set.extend (s)
|
||||
draw
|
||||
end
|
||||
ensure
|
||||
schema_assigned: schema = a_schema
|
||||
-- contains_schema: target_set.has (a_schema)
|
||||
-- old_schema_removed: (old schema /= Void) and (old schema /= schema) implies not target_set.has (old schema)
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Rebuild and show the view.
|
||||
do
|
||||
if has_schema then
|
||||
if is_rebuild_needed then
|
||||
build_controls
|
||||
end
|
||||
if record /= Void then
|
||||
fill_controls
|
||||
if attached schema as s and then record.has_schema (s) then
|
||||
enable_controls
|
||||
else
|
||||
disable_controls
|
||||
end
|
||||
else
|
||||
disable_controls
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
disable
|
||||
-- Make the controls unresponsive to input.
|
||||
do
|
||||
is_user_disabled := True
|
||||
end
|
||||
|
||||
enable
|
||||
-- Make the controls responsive to input.
|
||||
do
|
||||
is_user_disabled := False
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_user_disabled: BOOLEAN
|
||||
-- Has the user requested the controls to be disabled?
|
||||
|
||||
is_save_on_change: BOOLEAN
|
||||
-- Are changes made in the controls automatically
|
||||
-- saved to `record'? In other words, is `record'
|
||||
-- updated anytime a change is made, or must it
|
||||
-- be done manually with a call to `save_record'?
|
||||
|
||||
has_schema: BOOLEAN
|
||||
-- Is a `schema' assigned to Current?
|
||||
do
|
||||
Result := attached schema_imp
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_save_on_change
|
||||
-- Make automatic updates to `record' whenever
|
||||
-- a change is made in any control.
|
||||
do
|
||||
is_save_on_change := True
|
||||
end
|
||||
|
||||
set_save_on_request
|
||||
-- Require `save_record' to be called in order to
|
||||
-- accept any changes make in any control.
|
||||
do
|
||||
is_save_on_change := False
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
disable_controls
|
||||
-- Disable all controls.
|
||||
local
|
||||
c: CONTROL
|
||||
do
|
||||
from controls.start
|
||||
until controls.exhausted
|
||||
loop
|
||||
c := controls.item
|
||||
c.disable_sensitive
|
||||
check attached c.parent as p then
|
||||
p.set_foreground_color (Red)
|
||||
p.propagate_foreground_color
|
||||
end
|
||||
controls.forth
|
||||
end
|
||||
end
|
||||
|
||||
enable_controls
|
||||
-- Enable all controls.
|
||||
local
|
||||
c: CONTROL
|
||||
do
|
||||
from controls.start
|
||||
until controls.exhausted
|
||||
loop
|
||||
c := controls.item
|
||||
c.enable_sensitive
|
||||
check attached c.parent as p then
|
||||
p.set_foreground_color (Black)
|
||||
p.propagate_foreground_color
|
||||
end
|
||||
controls.forth
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
build_controls
|
||||
-- Create controls for each FIELD in `schema'.
|
||||
require
|
||||
schema_exists: schema /= Void
|
||||
local
|
||||
f: FIELD
|
||||
c: CONTROL
|
||||
do
|
||||
check attached {EDITOR_FIXED} scrollable_area.item as ef then
|
||||
-- Because `scrollable_area' is an {EDITOR_SCROLL_AREA}
|
||||
-- which *should* hold an {EDITOR_FIXED}.
|
||||
ef.wipe_out
|
||||
controls.wipe_out
|
||||
if attached schema as s then
|
||||
from s.start
|
||||
until s.exhausted
|
||||
loop
|
||||
f := s.field
|
||||
c := f.as_widget
|
||||
-- add actions to each control as it is created
|
||||
c.valid_change_actions.extend (agent on_control_changed (c))
|
||||
c.select_actions.extend (agent on_control_selected (c))
|
||||
-- c.display.pointer_button_press_actions.force_extend (agent on_control_selected (c))
|
||||
-- c.label.pointer_button_press_actions.force_extend (agent on_control_selected (c))
|
||||
-- put the control into the fixed
|
||||
ef.extend (c)
|
||||
-- place the control in the correct spot
|
||||
scrollable_area.position_control (c)
|
||||
-- keep track of the control
|
||||
controls.extend (c)
|
||||
if is_user_disabled then
|
||||
disable_controls
|
||||
end
|
||||
s.forth
|
||||
end
|
||||
if not is_user_disabled then
|
||||
enable_controls
|
||||
end
|
||||
end
|
||||
end
|
||||
check attached schema as s then
|
||||
time_drawn := s.time_modified.twin
|
||||
end
|
||||
end
|
||||
|
||||
save_record
|
||||
-- Get the data from each control and put it into the
|
||||
-- the record if the data is valid.
|
||||
require
|
||||
record_exitsts: record /= Void
|
||||
local
|
||||
dat: ANY -- for testing
|
||||
con: CONTROL -- control
|
||||
c: EDIT_COMMAND
|
||||
do
|
||||
from changed_controls.start
|
||||
until changed_controls.off
|
||||
loop
|
||||
con := changed_controls.item
|
||||
if con.is_display_valid and then not con.field.is_calculated then
|
||||
dat := con.value
|
||||
c := new_edit_command (record, con.field, con.value)
|
||||
-- Disable drawing to keep this control from being updated
|
||||
-- when the EDIT_COMMAND is executed.
|
||||
disable_drawing
|
||||
command_manager.add_command (c)
|
||||
enable_drawing
|
||||
end
|
||||
changed_controls.forth
|
||||
end
|
||||
save_actions.call ([])
|
||||
changed_controls.wipe_out
|
||||
end
|
||||
|
||||
new_edit_command (a_record: like record; a_field: FIELD; a_value: ANY): EDIT_COMMAND
|
||||
-- Used by `save_record' to get an EDIT_COMMAND
|
||||
require
|
||||
record_exists: record /= Void
|
||||
do
|
||||
create Result.make (a_record, a_field, a_value)
|
||||
end
|
||||
|
||||
fill_controls
|
||||
-- Put the data from the record into the corresponding control
|
||||
require
|
||||
record_exists: record /= Void
|
||||
local
|
||||
key: STRING
|
||||
con: CONTROL
|
||||
do
|
||||
from
|
||||
controls.start
|
||||
until
|
||||
controls.exhausted
|
||||
loop
|
||||
key := controls.item.field.label
|
||||
con := controls.item
|
||||
if attached record.value (key) as dat then
|
||||
con.set_data (dat)
|
||||
end
|
||||
con.refresh
|
||||
controls.forth
|
||||
end
|
||||
end
|
||||
|
||||
feature {CONTROL} -- implementation
|
||||
|
||||
on_drop_editable (a_editable: EDITABLE)
|
||||
-- React to drop of `a_editable' on Current except if
|
||||
-- it is a FIELD. (FIELDs are handled by FIELD_EDITOR_VIEW.)
|
||||
-- Fix me !!! This makes the interface inconsistent by allowing a drop
|
||||
-- of a type that is really not allowed.
|
||||
require
|
||||
editable_exists: a_editable /= Void
|
||||
do
|
||||
-- The `parent_tool' (a EDIT_TOOL) takes care of the special
|
||||
-- case, when `a_editable' is a FIELD.
|
||||
if attached parent_tool as pt then
|
||||
pt.set_target (a_editable)
|
||||
end
|
||||
end
|
||||
|
||||
on_control_changed (a_control: CONTROL)
|
||||
-- A change has been made to value in `a_control'
|
||||
require
|
||||
control_exists: a_control /= Void
|
||||
do
|
||||
changed_controls.extend (a_control)
|
||||
if is_save_on_change then
|
||||
save_record
|
||||
disable_drawing
|
||||
draw_views (record)
|
||||
enable_drawing
|
||||
end
|
||||
end
|
||||
|
||||
on_control_selected (a_control: CONTROL)
|
||||
-- React to `a_control' being selected.
|
||||
require
|
||||
control_exists: a_control /= Void
|
||||
do
|
||||
control_select_actions.call ([a_control])
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
controls: LINKED_SET [CONTROL]
|
||||
-- All the controls in the pages.
|
||||
|
||||
changed_controls: LINKED_SET [CONTROL]
|
||||
-- Controls whose data has changed since last save
|
||||
|
||||
is_rebuild_needed: BOOLEAN
|
||||
-- Used internally to let `draw' know that the controls
|
||||
-- need to be rebuilt, because the schema has changed
|
||||
-- since the last call to `draw'. This prevents calling
|
||||
-- `build_controls' (and unnecessarily recreating the
|
||||
-- controls again) on every call to `draw'.
|
||||
require
|
||||
schema_exists: schema /= Void
|
||||
do
|
||||
check attached schema as s then
|
||||
Result := time_drawn < s.time_modified
|
||||
end
|
||||
end
|
||||
|
||||
time_drawn: YMDHMS_TIME
|
||||
-- The time the controls were last drawn.
|
||||
-- This is used to allow the controls for a schema to be
|
||||
-- redrawn only after the `schema' has changed, not every
|
||||
-- time a new `record' is set.
|
||||
-- Updated by `build_controls'.
|
||||
|
||||
record_imp: detachable EDITABLE
|
||||
-- Detachable implementation of `target' for void-safety
|
||||
|
||||
schema_imp: detachable like schema
|
||||
-- Detachable implementation of `schema'
|
||||
|
||||
feature {NONE} -- Inaplicable
|
||||
|
||||
-- data: ANY
|
||||
-- -- Not to be used
|
||||
--
|
||||
-- set_data (a_data: like data) is
|
||||
-- -- Not to be used
|
||||
-- do
|
||||
-- check
|
||||
-- False
|
||||
-- end
|
||||
-- end
|
||||
|
||||
end
|
191
jj_vision/interface/views/dimable.e
Normal file
191
jj_vision/interface/views/dimable.e
Normal file
@@ -0,0 +1,191 @@
|
||||
note
|
||||
description: "[
|
||||
A widget that can appear bright or dim
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
deferred class
|
||||
DIMABLE
|
||||
|
||||
inherit
|
||||
|
||||
ANY
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
default_create
|
||||
-- Set the default `dimming_level'
|
||||
do
|
||||
dimming_level := Dimmer
|
||||
previous_dimming_level := Dimmest
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
dimming_level: INTEGER_32
|
||||
-- The amount colors will be dimmed
|
||||
-- (One of `Dim', `Dimmer', or `Dimmest')
|
||||
|
||||
previous_dimming_level: INTEGER_32
|
||||
-- Used to `restore' to the prior dimming level
|
||||
|
||||
Bright: INTEGER = 0
|
||||
Normal: INTEGER_32 = 7
|
||||
Dim: INTEGER = 10
|
||||
Dimmer: INTEGER_32 = 15
|
||||
Dimmest: INTEGER_32 = 20
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_dimming_level (a_level: like dimming_level)
|
||||
-- Change the `dimming_level'
|
||||
require
|
||||
valid_level: a_level = Bright or a_level = Normal or a_level = Dim or
|
||||
a_level = Dimmer or a_level = Dimmest
|
||||
do
|
||||
-- io.put_string ("DIMABLE.set_dimming_level -- ")
|
||||
-- if attached {VITP_ITEM} Current as v then
|
||||
-- io.put_string ("on " + v.name)
|
||||
-- else
|
||||
-- io.put_string (" on? " + generating_type)
|
||||
-- end
|
||||
-- io.put_string (" from " + previous_dimming_level.out)
|
||||
-- io.put_string (" to " + dimming_level.out + "%N")
|
||||
previous_dimming_level := dimming_level
|
||||
dimming_level := a_level
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
restore_dimming_level
|
||||
-- Set the `dimming_level' to the `previous_dimming_level'
|
||||
do
|
||||
set_dimming_level (previous_dimming_level)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_bright: BOOLEAN
|
||||
-- Should the resulting colors be "bright"?
|
||||
do
|
||||
Result := dimming_level = Bright
|
||||
end
|
||||
|
||||
is_normal: BOOLEAN
|
||||
-- Should the resulting colors be "normal"?
|
||||
do
|
||||
Result := dimming_level = Normal
|
||||
end
|
||||
|
||||
is_dimmed: BOOLEAN
|
||||
-- Should the resulting colors be "dim"?
|
||||
do
|
||||
Result := dimming_level = Dim
|
||||
end
|
||||
|
||||
is_more_dimmed: BOOLEAN
|
||||
-- Should the resulting colors be "dimmer"?
|
||||
do
|
||||
Result := dimming_level = Dimmer
|
||||
end
|
||||
|
||||
is_completely_dimmed: BOOLEAN
|
||||
-- Should the resulting colors be "dimmest"?
|
||||
do
|
||||
Result := dimming_level = Dimmest
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_bright
|
||||
-- Change the color dimming level to "bright
|
||||
do
|
||||
set_dimming_level (Bright)
|
||||
end
|
||||
|
||||
set_normal
|
||||
-- Change the `dimming_level' to "normal"
|
||||
do
|
||||
set_dimming_level (normal)
|
||||
end
|
||||
|
||||
set_dimmed
|
||||
-- Change the color dimming level to "dim"
|
||||
do
|
||||
set_dimming_level (Dim)
|
||||
end
|
||||
|
||||
set_more_dimmed
|
||||
-- Change the color dimming level to `Dimmer'
|
||||
do
|
||||
set_dimming_level (Dimmer)
|
||||
end
|
||||
|
||||
set_completely_dimmed
|
||||
-- Change the color dimming level to `Dimmest'
|
||||
do
|
||||
set_dimming_level (Dimmest)
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
adjusted_color (a_color: EV_COLOR): EV_COLOR
|
||||
-- A new color from `a_color' adjusted based on the `dimming_level'
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
do
|
||||
fader.set_color (a_color)
|
||||
Result := fader.i_th_lighter (dimming_level)
|
||||
end
|
||||
|
||||
dim_color (a_color: EV_COLOR): EV_COLOR
|
||||
-- A new color based on `a_color' at a "faded" level
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
do
|
||||
fader.set_color (a_color)
|
||||
Result := fader.i_th_lighter (Dim)
|
||||
end
|
||||
|
||||
dimmer_color (a_color: EV_COLOR): EV_COLOR
|
||||
-- A new color based on `a_color' at a "faded" level
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
do
|
||||
fader.set_color (a_color)
|
||||
Result := fader.i_th_lighter (Dimmer)
|
||||
end
|
||||
|
||||
dimmest_color (a_color: EV_COLOR): EV_COLOR
|
||||
-- A new color based on `a_color' at a "faded" level
|
||||
require
|
||||
color_exists: a_color /= Void
|
||||
do
|
||||
fader.set_color (a_color)
|
||||
Result := fader.i_th_lighter (Default_step_count)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
fader: COLOR_FADER
|
||||
-- Used to calculate a new color based on some initial color and dimming level
|
||||
once
|
||||
create Result
|
||||
Result.set_count (Default_step_count)
|
||||
end
|
||||
|
||||
Default_step_count: INTEGER_32 = 20
|
||||
-- Number of variable color settings used in the `fader'
|
||||
|
||||
invariant
|
||||
|
||||
valid_dimming_level: dimming_level = Bright or
|
||||
dimming_level = Normal or
|
||||
dimming_level = Dim or
|
||||
dimming_level = Dimmer or
|
||||
dimming_level = Dimmest
|
||||
|
||||
end
|
69
jj_vision/interface/views/field_editor_view.e
Normal file
69
jj_vision/interface/views/field_editor_view.e
Normal file
@@ -0,0 +1,69 @@
|
||||
note
|
||||
description: "[
|
||||
An special {DIALOG_EDITOR_VIEW} used to edit a {FIELD}
|
||||
|
||||
A {FIELD_SCHEMA} can not be created when a {FIELD} is created,
|
||||
because, as Manu from ISE described, both {FIELD} and {SCHEMA}
|
||||
would rely on the creation of the other, and an object would
|
||||
be referenced before the created object was ever assigned to
|
||||
the `Result' in `default_create'.
|
||||
]"
|
||||
date: "27 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/field_editor_view.e $"
|
||||
date: "$Date: 2012-03-16 14:05:07 -0400 (Fri, 16 Mar 2012) $"
|
||||
revision: "$Revision: 7 $"
|
||||
|
||||
class
|
||||
FIELD_EDITOR_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
DIALOG_EDITOR_VIEW
|
||||
redefine
|
||||
record_imp,
|
||||
set_record,
|
||||
new_edit_command
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_record (a_record: like record)
|
||||
-- Change the `record'.
|
||||
do
|
||||
-- Redefined to ensure the `schema' for `a_record' is set.
|
||||
-- It may alread be here, but not always.
|
||||
-- Note that `draw' is called by Precursor.
|
||||
set_schema (a_record.schema)
|
||||
Precursor {DIALOG_EDITOR_VIEW} (a_record)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (actions)
|
||||
|
||||
parent_schema: SCHEMA
|
||||
-- The schema being editted by the `parent_tool' which
|
||||
-- must be a EDIT_TOOL.
|
||||
do
|
||||
check attached {EDIT_TOOL} parent_tool as pt then
|
||||
Result := pt.get_schema
|
||||
end
|
||||
end
|
||||
|
||||
new_edit_command (a_record: like record; a_field: FIELD; a_value: ANY): EDIT_SCHEMA_COMMAND
|
||||
-- Used by `save_record' to get the correct type of command.
|
||||
-- It is special for this type as it is a field that is
|
||||
-- changing but the command affects a SCHEMA.
|
||||
do
|
||||
create Result.make (a_record, a_field, a_value)
|
||||
Result.set_schema (parent_schema)
|
||||
end
|
||||
|
||||
record_imp: detachable FIELD
|
||||
-- Detachable implementation of `target' for void-safety
|
||||
|
||||
end
|
151
jj_vision/interface/views/filename_view.e
Normal file
151
jj_vision/interface/views/filename_view.e
Normal file
@@ -0,0 +1,151 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} used to display the names of files as filtered
|
||||
]"
|
||||
date: "26 Jan 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/filename_view.e $"
|
||||
date: "$Date: 2012-05-31 14:05:35 -0400 (Thu, 31 May 2012) $"
|
||||
revision: "$Revision: 10 $"
|
||||
|
||||
class
|
||||
FILENAME_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_VERTICAL_BOX
|
||||
rename
|
||||
object_id as ise_object_id
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
copy,
|
||||
is_equal
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_VERTICAL_BOX}
|
||||
create browse_button
|
||||
create directory_text
|
||||
create file_list
|
||||
browse_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_shell_color_buffer))
|
||||
browse_button.set_tooltip ("{FILENAME_VIEW.Browse_button")
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Create an editor view.
|
||||
do
|
||||
Precursor {EV_VERTICAL_BOX}
|
||||
Precursor {VIEW}
|
||||
extend (browse_button)
|
||||
extend (directory_text)
|
||||
extend (file_list)
|
||||
disable_item_expand (browse_button)
|
||||
disable_item_expand (directory_text)
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add actions to the widgets and view.
|
||||
do
|
||||
browse_button.select_actions.extend (agent on_browse_button_pressed)
|
||||
directory_text.change_actions.extend (agent on_directory_text_changed)
|
||||
end
|
||||
|
||||
feature {NONE} -- Actions
|
||||
|
||||
on_browse_button_pressed
|
||||
-- React to a press of the browse button
|
||||
do
|
||||
directory_dialog.show_modal_to_window (parent_window)
|
||||
end
|
||||
|
||||
on_directory_selected
|
||||
-- React to a directory selection from the `directory_dialog'.
|
||||
do
|
||||
directory_text.set_text (directory_dialog.directory)
|
||||
end
|
||||
|
||||
on_directory_text_changed
|
||||
-- React to a change of the `directory_text'.
|
||||
do
|
||||
draw
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the view
|
||||
local
|
||||
d: DIRECTORY
|
||||
lin: ARRAYED_LIST [STRING]
|
||||
s, ext: STRING
|
||||
i: EV_LIST_ITEM
|
||||
p: EV_PIXMAP
|
||||
do
|
||||
file_list.wipe_out
|
||||
create d.make_open_read (directory_text.text)
|
||||
if d.exists then
|
||||
lin := d.linear_representation
|
||||
from lin.start
|
||||
until lin.exhausted
|
||||
loop
|
||||
s := lin.item
|
||||
ext := s.twin
|
||||
ext.keep_tail (3)
|
||||
if equal (ext, "ico") or equal (ext, "png") then
|
||||
create p
|
||||
p.set_with_named_file (directory_dialog.directory + "\" + s)
|
||||
create i.make_with_text (s)
|
||||
i.set_pixmap (p)
|
||||
i.set_pebble (directory_dialog.directory + "\" + s)
|
||||
file_list.extend (i)
|
||||
end
|
||||
lin.forth
|
||||
end
|
||||
end
|
||||
d.close
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
browse_button: EV_BUTTON
|
||||
-- To open a directory dialog
|
||||
|
||||
directory_text: EV_TEXT
|
||||
-- To display the directory (or path).
|
||||
|
||||
file_list: EV_LIST
|
||||
-- To display the filenames of the files
|
||||
|
||||
directory_dialog: EV_DIRECTORY_DIALOG
|
||||
-- The standard direcory selection dialog.
|
||||
once
|
||||
create Result
|
||||
Result.set_start_directory ("d:/eiffel54/studio/bitmaps/ico")
|
||||
Result.ok_actions.extend (agent on_directory_selected)
|
||||
end
|
||||
|
||||
end
|
59
jj_vision/interface/views/fixed_view.e
Normal file
59
jj_vision/interface/views/fixed_view.e
Normal file
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "[
|
||||
An EV_FIXED which is also a {VIEW}
|
||||
]"
|
||||
date: "12 Sep 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/fixed_view.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
FIXED_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy,
|
||||
is_equal
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
EV_FIXED
|
||||
rename
|
||||
object_id as ise_object_id
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_FIXED}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Create an editor view.
|
||||
do
|
||||
Precursor {EV_FIXED}
|
||||
Precursor {VIEW}
|
||||
end
|
||||
|
||||
end
|
57
jj_vision/interface/views/horizontal_split_view.e
Normal file
57
jj_vision/interface/views/horizontal_split_view.e
Normal file
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} that is also an {EV_HORIZONTAL_SPLIT_AREA}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/horizontal_split_view.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
HORIZONTAL_SPLIT_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_HORIZONTAL_SPLIT_AREA
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
-- draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_HORIZONTAL_SPLIT_AREA}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the widget
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_HORIZONTAL_SPLIT_AREA}
|
||||
draw
|
||||
end
|
||||
|
||||
end
|
62
jj_vision/interface/views/jj_drawing_area_view.e
Normal file
62
jj_vision/interface/views/jj_drawing_area_view.e
Normal file
@@ -0,0 +1,62 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} combined with an EV_DRAWING_AREA
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/jj_drawing_area_view.e $"
|
||||
date: "$Date: 2012-11-27 20:19:38 -0500 (Tue, 27 Nov 2012) $"
|
||||
revision: "$Revision: 13 $"
|
||||
|
||||
class
|
||||
JJ_DRAWING_AREA_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_DRAWING_AREA
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
add_actions
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_DRAWING_AREA}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the widget
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_DRAWING_AREA}
|
||||
-- set_actions
|
||||
end
|
||||
|
||||
add_actions
|
||||
do
|
||||
resize_actions.force_extend (agent draw)
|
||||
expose_actions.force_extend (agent draw)
|
||||
end
|
||||
|
||||
end
|
121
jj_vision/interface/views/jj_figure_world_view.e
Normal file
121
jj_vision/interface/views/jj_figure_world_view.e
Normal file
@@ -0,0 +1,121 @@
|
||||
note
|
||||
description : "[
|
||||
This class ties together the concept of EV_FIGURE_WORLD, EV_DRAWING_AREA,
|
||||
and EV_DRAWING_AREA_PROJECTOR in a simpler interface.
|
||||
In order to fake out Eiffel Vision to allow a widget to be decreased in
|
||||
size (I call this the `set_minimum_size' problem'), the drawing
|
||||
area is contained in an EV_FIXED allowing the drawing area's size
|
||||
to follow that of the fixed, and thereby, indirectly the size of the
|
||||
parent window.
|
||||
|
||||
While this worked for the editor classes it does not seem to work here.
|
||||
I don't know why. Is the problem with `resize_fixed' or with the fact
|
||||
that, in the graphics program where it is used, I am also using the
|
||||
"jj_vision" classes. Perhaps the problem is there.???
|
||||
]"
|
||||
date: "27 Sep 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/jj_figure_world_view.e $"
|
||||
date: "$Date: 2012-05-31 14:05:35 -0400 (Thu, 31 May 2012) $"
|
||||
revision: "$Revision: 10 $"
|
||||
|
||||
class
|
||||
JJ_FIGURE_WORLD_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_FRAME
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
draw
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_FRAME}
|
||||
create fixed
|
||||
create world
|
||||
create drawing_area
|
||||
create projector.make (world, drawing_area)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the widget
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_FRAME}
|
||||
extend (drawing_area)
|
||||
set_actions
|
||||
-- draw
|
||||
end
|
||||
|
||||
set_actions
|
||||
do
|
||||
resize_actions.force_extend (agent draw)
|
||||
drawing_area.expose_actions.force_extend (agent draw)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
world: EV_FIGURE_WORLD
|
||||
-- World which Current will manipulate.
|
||||
|
||||
drawing_area: EV_DRAWING_AREA
|
||||
-- Area on which `world' will be projected.
|
||||
-- It is contained within a `fixed' area of Current.
|
||||
-- Exported to allow direct drawing on it.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_world (a_world: EV_FIGURE_WORLD)
|
||||
-- Change the `world' of figures to be displayed
|
||||
require
|
||||
world_exists: a_world /= Void
|
||||
do
|
||||
world := a_world
|
||||
projector.set_world (a_world)
|
||||
end
|
||||
|
||||
feature {NONE} -- Drawing / Refresh operations
|
||||
|
||||
draw
|
||||
-- Build the view
|
||||
do
|
||||
drawing_area.clear
|
||||
if projector /= Void then
|
||||
projector.full_project
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
projector: EV_DRAWING_AREA_PROJECTOR
|
||||
-- For projecting the world onto the drawing area.
|
||||
|
||||
fixed: EV_FIXED
|
||||
-- Container placed in the EV_FRAME to control size of `drawing_area'.
|
||||
|
||||
end
|
77
jj_vision/interface/views/jj_model_world_cell_view.e
Normal file
77
jj_vision/interface/views/jj_model_world_cell_view.e
Normal file
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description : "[
|
||||
A scrollable drawing area (i.e. an {EV_MODEL_WORLD_CELL} that
|
||||
is a {VIEW}.
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
|
||||
class
|
||||
JJ_MODEL_WORLD_CELL_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy,
|
||||
is_equal
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
draw
|
||||
end
|
||||
|
||||
EV_MODEL_WORLD_CELL
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
-- Must create `world' because not calling `make_with_world'
|
||||
create world
|
||||
Precursor {EV_MODEL_WORLD_CELL}
|
||||
Precursor {VIEW}
|
||||
is_autoscroll_enabled := true
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up by calling both precursor versions
|
||||
do
|
||||
Precursor {EV_MODEL_WORLD_CELL}
|
||||
Precursor {VIEW}
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
add_model (a_model: JJ_MODEL_WORLD_VIEW)
|
||||
-- Add `a_model' to the `world' and set
|
||||
-- the `parent' of `a_model'
|
||||
do
|
||||
world.extend (a_model)
|
||||
a_model.set_parent_view (Current)
|
||||
end
|
||||
|
||||
feature {NONE} -- Drawing / Refresh operations
|
||||
|
||||
draw
|
||||
-- Build the view
|
||||
do
|
||||
drawing_area.clear
|
||||
if projector /= Void then
|
||||
projector.full_project
|
||||
end
|
||||
end
|
||||
|
||||
end
|
100
jj_vision/interface/views/jj_model_world_view.e
Normal file
100
jj_vision/interface/views/jj_model_world_view.e
Normal file
@@ -0,0 +1,100 @@
|
||||
note
|
||||
description: "[
|
||||
An {EV_MODEL_WORLD} that is also a {VIEW}.
|
||||
It is a group of figures that allow redraws through the {VIEW}
|
||||
class interface (e.g. when the underlying object model changes,
|
||||
the views displaying that object can be redrawn.)
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
JJ_MODEL_WORLD_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
redefine
|
||||
-- default_create,
|
||||
create_interface_objects,
|
||||
draw
|
||||
end
|
||||
|
||||
EV_MODEL_WORLD
|
||||
redefine
|
||||
default_create,
|
||||
create_interface_objects
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
create {JJ_MODEL_WORLD_VIEW}
|
||||
list_make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
-- Standard creation procedure, added to align with the pattern
|
||||
-- used by `default_create' from {EV_ANY}.
|
||||
-- Remember, `make' from {VIEW} calls `default_create', which
|
||||
-- in {EV_ANY} calls both `create_interface_objects' and later
|
||||
-- `initialize'. However, `default_create' from {EV_MODEL_WORLD}
|
||||
-- does NOT call `initialize'.
|
||||
do
|
||||
-- Precursor eventually calls `create_interface_objects'
|
||||
Precursor {EV_MODEL_WORLD}
|
||||
-- now, also call `initialzie'
|
||||
initialize
|
||||
end
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'.
|
||||
-- Called by `defult_create'.
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation
|
||||
-- bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_MODEL_WORLD}
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
parent: detachable EV_CONTAINER
|
||||
-- Parent of the current view.
|
||||
-- To be effected by joining with an EV_ class.
|
||||
-- An {EV_MODEL_WORLD} as a descendent of {EV_MODEL} is to be
|
||||
-- extended into an {EV_MODEL_WORLD_CELL}, which is an {EV_CONTAINER},
|
||||
-- but there seems to be no way to determine this container.
|
||||
do
|
||||
check
|
||||
do_not_call: False then
|
||||
-- because can not return what is expected.
|
||||
end
|
||||
end
|
||||
|
||||
is_destroyed: BOOLEAN
|
||||
-- Has the view been destroyed?
|
||||
-- This will be joined with an EV_WIDGET feature.
|
||||
-- See comment for feature `parent'.
|
||||
do
|
||||
-- check
|
||||
-- do_not_call: False then
|
||||
-- -- because can not return what is expected.
|
||||
-- end
|
||||
Result := false
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
draw
|
||||
-- Redraw the window
|
||||
do
|
||||
-- world.wipe_out
|
||||
-- world.full_redraw
|
||||
Precursor {VIEW}
|
||||
end
|
||||
|
||||
end
|
210
jj_vision/interface/views/jj_scrollable_drawing_area_view.e
Normal file
210
jj_vision/interface/views/jj_scrollable_drawing_area_view.e
Normal file
@@ -0,0 +1,210 @@
|
||||
note
|
||||
description : "[
|
||||
This class ties together the concept of EV_MODEL_WORLD, EV_DRAWING_AREA,
|
||||
and EV_MODEL_DRAWING_AREA_PROJECTOR in a simpler interface. The drawing
|
||||
area is contained in an EV_FIXED within an EV_SCROLLABLE_AREA,
|
||||
allowing the
|
||||
]"
|
||||
date: "18 Jul 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/jj_scrollable_drawing_area_view.e $"
|
||||
date: "$Date: 2012-06-11 16:54:43 -0400 (Mon, 11 Jun 2012) $"
|
||||
revision: "$Revision: 11 $"
|
||||
|
||||
class
|
||||
JJ_SCROLLABLE_DRAWING_AREA_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
draw
|
||||
end
|
||||
|
||||
EV_SCROLLABLE_AREA
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_SCROLLABLE_AREA}
|
||||
create fixed
|
||||
create world
|
||||
create drawing_area
|
||||
create projector.make (world, drawing_area)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the widget
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_SCROLLABLE_AREA}
|
||||
extend (fixed)
|
||||
fixed.extend (drawing_area)
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
do
|
||||
resize_actions.force_extend (agent draw)
|
||||
resize_actions.extend (agent resize_fixed)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
world: EV_FIGURE_WORLD
|
||||
-- World which Current will manipulate.
|
||||
|
||||
drawing_area: EV_DRAWING_AREA
|
||||
-- Area on which `world' will be projected.
|
||||
-- It is contained within a `fixed' area of Current.
|
||||
-- Exported to allow direct drawing on it.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_world (a_world: EV_FIGURE_WORLD)
|
||||
-- Change the `world' of figures to be displayed
|
||||
require
|
||||
world_exists: a_world /= Void
|
||||
do
|
||||
world := a_world
|
||||
projector.set_world (a_world)
|
||||
end
|
||||
|
||||
feature {NONE} -- Drawing / Refresh operations
|
||||
|
||||
resize_fixed (a_x, a_y, a_width, a_height: INTEGER)
|
||||
-- Change the size of `drawing_area' to be at least as big as the
|
||||
-- scroll area but no bigger, by removing the old one area re-
|
||||
-- extending it into `fixed'.
|
||||
-- The parameters are there so the feature has the correct
|
||||
-- signature but are not used in the calculations.
|
||||
local
|
||||
big_x, big_y: INTEGER
|
||||
f: like fixed
|
||||
do
|
||||
-- Must check for parent because `parent_window' makes no
|
||||
-- since if Current is not contained in some container.
|
||||
if parent_window /= Void then
|
||||
-- This feature is ineficient as is because of all the
|
||||
-- re-parenting that is going on.
|
||||
-- Must `lock_update' from EV_WINDOW to prevent
|
||||
-- severe flickering on all the re-parenting.
|
||||
parent_window.lock_update
|
||||
-- Block the actions so don't get infinite loop
|
||||
resize_actions.block
|
||||
-- Create a new fixed with the correct size to
|
||||
-- replace the wrong sized one.
|
||||
create f
|
||||
-- Transfer all the `drawing_area' to the new fixed
|
||||
-- For some reason the `drawing_area' does not always have
|
||||
-- parent `fixed' as expected; hence all the checks and the
|
||||
-- statement to make the parent of `drawing_area' call `prune'.
|
||||
fixed.start
|
||||
fixed.prune (drawing_area)
|
||||
check
|
||||
not fixed.has (drawing_area)
|
||||
end
|
||||
if attached {EV_CONTAINER} drawing_area.parent as p then
|
||||
p.prune (drawing_area)
|
||||
end
|
||||
check
|
||||
drawing_area.parent = Void
|
||||
end
|
||||
f.extend (drawing_area)
|
||||
-- Put any actions in `fixed' into the new fixed `f'.
|
||||
f.conforming_pick_actions.merge_right (fixed.conforming_pick_actions)
|
||||
f.drop_actions.merge_right (fixed.drop_actions)
|
||||
f.pick_actions.merge_right (fixed.pick_actions)
|
||||
f.pick_ended_actions.merge_right (fixed.pick_ended_actions)
|
||||
f.focus_in_actions.merge_right (fixed.focus_in_actions)
|
||||
f.key_press_actions.merge_right (fixed.key_press_actions)
|
||||
f.key_press_string_actions.merge_right (fixed.key_press_string_actions)
|
||||
f.key_release_actions.merge_right (fixed.key_release_actions)
|
||||
f.pointer_button_press_actions.merge_right (fixed.pointer_button_press_actions)
|
||||
f.pointer_button_release_actions.merge_right (fixed.pointer_button_release_actions)
|
||||
f.pointer_double_press_actions.merge_right (fixed.pointer_double_press_actions)
|
||||
f.pointer_enter_actions.merge_right (fixed.pointer_enter_actions)
|
||||
f.pointer_leave_actions.merge_right (fixed.pointer_leave_actions)
|
||||
f.pointer_motion_actions.merge_right (fixed.pointer_motion_actions)
|
||||
f.resize_actions.merge_right (fixed.resize_actions)
|
||||
-- Replace `fixed' with the new fixed, `f'.
|
||||
replace (f)
|
||||
-- Make the size of `drawing_area' at least as big as Current.
|
||||
f.set_item_size (drawing_area, client_width.max (world.bounding_box.width), client_height.max (world.bounding_box.height))
|
||||
-- f.set_item_size (drawing_area, width.max (world.bounding_box.width), height.max (world.bounding_box.height))
|
||||
resize_actions.resume
|
||||
parent_window.unlock_update
|
||||
end
|
||||
-- From here down would be used if `set_item_size' from
|
||||
-- VIEWPORT worked properly. As of 26 Nov 02 ISE can not
|
||||
-- answer why I get a post-condition violation on the
|
||||
-- feature even though it passes the pre-conditions.
|
||||
-- The calls to `item.set_minimum_width (50) were there
|
||||
-- for testing and probably not needed if `set_item_size'
|
||||
-- ever works.
|
||||
---- from item.start
|
||||
---- until item.exhausted
|
||||
---- loop
|
||||
---- c := item.item
|
||||
---- big_x := (c.x_position + c.width).max (big_x)
|
||||
---- big_y := (c.y_position + c.height).max (big_y)
|
||||
---- item.forth
|
||||
---- end
|
||||
-- item.set_minimum_width (50)
|
||||
-- item.set_minimum_height (50)
|
||||
-- item.set_minimum_width (25)
|
||||
---- if big_x < client_width or big_y < client_height then
|
||||
------ if big_x < client_width then
|
||||
------ set_item_width (client_width)
|
||||
------ end
|
||||
---- if big_y < client_height then
|
||||
---- set_item_height (client_height)
|
||||
---- end
|
||||
------ set_item_size (client_width, client_height)
|
||||
---- item.set_minimum_size (client_width, client_height)
|
||||
---- else
|
||||
---- set_item_size (big_x, big_y)
|
||||
------ item.set_minimum_size (big_x, big_y)
|
||||
---- end
|
||||
end
|
||||
|
||||
draw
|
||||
-- Build the view
|
||||
do
|
||||
drawing_area.clear
|
||||
if projector /= Void then
|
||||
projector.full_project
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
projector: EV_DRAWING_AREA_PROJECTOR
|
||||
-- For projecting the world onto the drawing area.
|
||||
|
||||
fixed: EV_FIXED
|
||||
-- Container placed in the EV_FRAME to facilitate
|
||||
-- the placement of scrollbars and other widgets.
|
||||
|
||||
end
|
||||
|
388
jj_vision/interface/views/list_editor_view.e
Normal file
388
jj_vision/interface/views/list_editor_view.e
Normal file
@@ -0,0 +1,388 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} which allows the editting of an {EDITABLE} in a
|
||||
multi-column list.
|
||||
]"
|
||||
date: "24 Feb 04"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/list_editor_view.e $"
|
||||
date: "$Date: 2012-05-31 14:05:35 -0400 (Thu, 31 May 2012) $"
|
||||
revision: "$Revision: 10 $"
|
||||
|
||||
class
|
||||
LIST_EDITOR_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_STOCK_COLORS
|
||||
rename
|
||||
implementation as colors_implementation
|
||||
export
|
||||
{NONE} all
|
||||
undefine
|
||||
default_create,
|
||||
is_equal,
|
||||
copy
|
||||
end
|
||||
|
||||
EV_NOTEBOOK
|
||||
rename
|
||||
item as page,
|
||||
selected_item as selected_page,
|
||||
select_item as select_page,
|
||||
set_item_text as set_page_text
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
-- data,
|
||||
-- set_data
|
||||
end
|
||||
|
||||
VIEW
|
||||
rename
|
||||
target_imp as record_imp,
|
||||
target as record,
|
||||
set_target as set_record
|
||||
undefine
|
||||
-- default_create,
|
||||
copy,
|
||||
is_equal
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize,
|
||||
record_imp
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_NOTEBOOK}
|
||||
create changed_controls.make
|
||||
create controls.make
|
||||
create save_actions
|
||||
create control_select_actions
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Create an editor view.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_NOTEBOOK}
|
||||
set_save_on_change
|
||||
set_actions
|
||||
end
|
||||
|
||||
set_actions
|
||||
--
|
||||
do
|
||||
drop_actions.extend (agent on_drop_object)
|
||||
-- selection_actions.extend (agent on_page_selected)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
-- record: EDITABLE
|
||||
-- The object that contains the data to be editted.
|
||||
-- Data in `record' is reached via feature `value (a_key)'.
|
||||
|
||||
schema: detachable SCHEMA
|
||||
-- Describes how to build the controls which
|
||||
-- will be used to edit `record'.
|
||||
|
||||
save_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed after the record is saved.
|
||||
|
||||
control_select_actions: EV_NOTIFY_ACTION_SEQUENCE
|
||||
-- Actions to be performed when a control is clicked.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_schema (a_schema: like schema)
|
||||
-- Change `schema' to `a_schema'.
|
||||
require
|
||||
schema_exists: a_schema /= Void
|
||||
do
|
||||
if schema /= a_schema then
|
||||
schema := a_schema
|
||||
build_pages
|
||||
if record /= Void then
|
||||
fill_controls
|
||||
end
|
||||
end
|
||||
if record = Void then
|
||||
disable_controls -- at least until user loads a record
|
||||
end
|
||||
ensure
|
||||
schema_was_set: schema = a_schema
|
||||
end
|
||||
|
||||
set_target (a_record: like record)
|
||||
-- Change `record' to `a_record'
|
||||
-- Reload the data into the controls
|
||||
require
|
||||
record_exists: a_record /= Void
|
||||
do
|
||||
record_imp := a_record
|
||||
if not is_user_disabled then
|
||||
enable_controls
|
||||
end
|
||||
fill_controls
|
||||
ensure
|
||||
record_was_set: record = a_record
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
disable
|
||||
-- Make the controls unresponsive to input.
|
||||
do
|
||||
is_user_disabled := True
|
||||
end
|
||||
|
||||
enable
|
||||
-- Make the controls responsive to input.
|
||||
do
|
||||
is_user_disabled := False
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_user_disabled: BOOLEAN
|
||||
-- Has the user requested the controls to be disabled?
|
||||
|
||||
is_save_on_change: BOOLEAN
|
||||
-- Are changes made in the controls automatically
|
||||
-- saved to `record'? In other words, is `record'
|
||||
-- updated anytime a change is made, or must it
|
||||
-- be done manually with a call to `save_record'?
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_save_on_change
|
||||
-- Make automatic updates to `record' whenever
|
||||
-- a change is made in any control.
|
||||
do
|
||||
is_save_on_change := True
|
||||
end
|
||||
|
||||
set_save_on_request
|
||||
-- Require `save_record' to be called in order to
|
||||
-- accept any changes make in any control.
|
||||
do
|
||||
is_save_on_change := False
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
disable_controls
|
||||
-- Disable all controls.
|
||||
local
|
||||
c: CONTROL
|
||||
do
|
||||
from controls.start
|
||||
until controls.exhausted
|
||||
loop
|
||||
c := controls.item
|
||||
c.disable_sensitive
|
||||
check attached c.parent as p then
|
||||
p.set_foreground_color (Red)
|
||||
p.propagate_foreground_color
|
||||
end
|
||||
controls.forth
|
||||
end
|
||||
end
|
||||
|
||||
enable_controls
|
||||
-- Enable all controls.
|
||||
local
|
||||
c: CONTROL
|
||||
do
|
||||
from controls.start
|
||||
until controls.exhausted
|
||||
loop
|
||||
c := controls.item
|
||||
c.enable_sensitive
|
||||
check attached c.parent as p then
|
||||
p.set_foreground_color (Black)
|
||||
p.propagate_foreground_color
|
||||
end
|
||||
controls.forth
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation (actions)
|
||||
|
||||
on_drop_object (a_object: like record)
|
||||
-- React to `a_object' dropping on Current.
|
||||
require
|
||||
object_exists: a_object /= Void
|
||||
local
|
||||
-- p: DATABASE_EDIT_TOOL
|
||||
do
|
||||
-- p ?= parent
|
||||
-- if p /= Void then
|
||||
-- parent_tool.set_object (a_object)
|
||||
-- end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
build_pages
|
||||
-- Create a tab in the notebook for each schema_page in `schema'.
|
||||
-- local
|
||||
---- ep: EDITOR_PAGE
|
||||
---- sa: EV_SCROLLABLE_AREA
|
||||
-- sa: EDITOR_SCROLL_AREA
|
||||
-- ef: EDITOR_FIXED
|
||||
-- sp: SCHEMA_PAGE
|
||||
-- f: FIELD
|
||||
-- c: CONTROL
|
||||
do
|
||||
-- wipe_out
|
||||
-- from schema.start
|
||||
-- until schema.exhausted
|
||||
-- loop
|
||||
-- -- for each SCHEMA_PAGE in `schema', make a scroll
|
||||
-- -- area and put it in Current (an EV_NOTEBOOK). This
|
||||
-- -- will create a tabbed page for each page in the schema.
|
||||
-- create sa
|
||||
-- extend (sa)
|
||||
-- select_page (sa)
|
||||
-- sp := schema.item
|
||||
-- set_page_text (sa, sp.name)
|
||||
-- -- For each FIELD in the SCHEMA_PAGE create a CONTROL
|
||||
-- -- and put it into the 'fixed' from EDITOR_SCROLL_AREA.
|
||||
-- from sp.start
|
||||
-- until sp.exhausted
|
||||
-- loop
|
||||
-- -- create a control from the field
|
||||
-- f := sp.item
|
||||
-- c := f.as_widget
|
||||
-- -- add actions to each control as it is created
|
||||
-- c.display.change_actions.extend (agent on_control_changed (c))
|
||||
-- c.display.pointer_button_press_actions.force_extend (agent on_control_selected (c))
|
||||
-- c.label.pointer_button_press_actions.force_extend (agent on_control_selected (c))
|
||||
-- -- put the control into the fixed
|
||||
-- sa.item.extend (c)
|
||||
-- -- place the control in the correct spot
|
||||
-- sa.position_control (c)
|
||||
-- -- keep track of the control
|
||||
-- controls.extend (c)
|
||||
-- sp.forth
|
||||
-- end
|
||||
-- if is_user_disabled then
|
||||
-- disable_controls
|
||||
-- end
|
||||
-- schema.forth
|
||||
-- end
|
||||
-- if record /= Void then
|
||||
-- fill_controls
|
||||
-- end
|
||||
end
|
||||
|
||||
save_record
|
||||
-- Get the data from each control and put it into the
|
||||
-- the record if the data is valid.
|
||||
require
|
||||
record_exitsts: record /= Void
|
||||
local
|
||||
dat: ANY -- COMPARABLE -- data
|
||||
con: CONTROL -- control
|
||||
do
|
||||
from changed_controls.start
|
||||
until changed_controls.off
|
||||
loop
|
||||
con := changed_controls.item
|
||||
if con.is_display_valid and then not con.field.is_calculated then
|
||||
dat := con.value
|
||||
record.extend_value (dat, con.field.id)
|
||||
end
|
||||
changed_controls.forth
|
||||
end
|
||||
save_actions.call ([])
|
||||
changed_controls.wipe_out
|
||||
end
|
||||
|
||||
fill_controls
|
||||
-- Put the data from the record into the corresponding control
|
||||
require
|
||||
record_exists: record /= Void
|
||||
local
|
||||
key: STRING
|
||||
con: CONTROL
|
||||
do
|
||||
from
|
||||
controls.start
|
||||
until
|
||||
controls.exhausted
|
||||
loop
|
||||
key := controls.item.field.id
|
||||
con := controls.item
|
||||
if attached record.value (key) as dat then
|
||||
con.set_data (dat)
|
||||
end
|
||||
con.refresh
|
||||
controls.forth
|
||||
end
|
||||
end
|
||||
|
||||
feature {CONTROL} -- implementation
|
||||
|
||||
on_control_changed (a_control: CONTROL)
|
||||
-- A change has been made to value in `a_control'
|
||||
do
|
||||
changed_controls.extend (a_control)
|
||||
if is_save_on_change then
|
||||
save_record
|
||||
end
|
||||
end
|
||||
|
||||
on_control_selected (a_control: CONTROL)
|
||||
-- React to `a_control' being selected.
|
||||
require
|
||||
control_exists: a_control /= Void
|
||||
do
|
||||
control_select_actions.call ([a_control])
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
controls: LINKED_SET [CONTROL]
|
||||
-- All the controls in the pages.
|
||||
|
||||
changed_controls: LINKED_SET [CONTROL]
|
||||
-- Controls whose data has changed since last save
|
||||
|
||||
record_imp: detachable EDITABLE
|
||||
-- Detachable implementation of `target' for void-safety
|
||||
|
||||
feature {NONE} -- Inaplicable
|
||||
|
||||
-- data: ANY
|
||||
-- -- Not to be used
|
||||
--
|
||||
-- set_data (a_data: like data) is
|
||||
-- -- Not to be used
|
||||
-- do
|
||||
-- check
|
||||
-- False
|
||||
-- end
|
||||
-- end
|
||||
|
||||
invariant
|
||||
|
||||
invariant_clause: -- Your invariant here
|
||||
|
||||
end
|
52
jj_vision/interface/views/split_view.e
Normal file
52
jj_vision/interface/views/split_view.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} that can be split into multiple panes through calls
|
||||
to feature `split_manager'. (See {SPLIT_MANAGER} or {TOOL}
|
||||
for example.)
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
date: "5/1/19"
|
||||
|
||||
deferred class
|
||||
SPLIT_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
-- VIEW
|
||||
-- redefine
|
||||
-- create_interface_objects
|
||||
-- end
|
||||
|
||||
--feature {NONE} -- Initialization
|
||||
|
||||
-- create_interface_objects
|
||||
-- -- Create objects to be used by `Current' in `initialize'
|
||||
-- -- Implemented by descendants to create attached objects
|
||||
-- -- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
-- do
|
||||
-- create split_manager
|
||||
-- Precursor {VIEW}
|
||||
-- end
|
||||
|
||||
feature -- Access
|
||||
|
||||
split_manager: SPLIT_MANAGER
|
||||
-- Manages the placement of sub-views within current.
|
||||
attribute
|
||||
create Result
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_split_manager (a_manager: SPLIT_MANAGER)
|
||||
-- Change `split_manager'
|
||||
require
|
||||
manager_exists: a_manager /= Void
|
||||
do
|
||||
split_manager := a_manager
|
||||
ensure
|
||||
manager_assigned: split_manager = a_manager
|
||||
end
|
||||
|
||||
|
||||
end
|
63
jj_vision/interface/views/text_view.e
Normal file
63
jj_vision/interface/views/text_view.e
Normal file
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} in which to display text
|
||||
]"
|
||||
date: "4 Jan 08"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/text_view.e $"
|
||||
date: "$Date: 2012-05-31 14:05:35 -0400 (Thu, 31 May 2012) $"
|
||||
revision: "$Revision: 10 $"
|
||||
|
||||
class
|
||||
TEXT_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
EV_TEXT
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TEXT}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the widget
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_TEXT}
|
||||
set_actions
|
||||
draw
|
||||
end
|
||||
|
||||
set_actions
|
||||
do
|
||||
resize_actions.force_extend (agent draw)
|
||||
end
|
||||
|
||||
end
|
56
jj_vision/interface/views/vertical_split_view.e
Normal file
56
jj_vision/interface/views/vertical_split_view.e
Normal file
@@ -0,0 +1,56 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} that is also an {EV_VERTICAL_SPLIT_AREA}
|
||||
]"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/vertical_split_view.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
VERTICAL_SPLIT_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
VIEW
|
||||
undefine
|
||||
-- default_create,
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
EV_VERTICAL_SPLIT_AREA
|
||||
undefine
|
||||
is_in_default_state
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_VERTICAL_SPLIT_AREA}
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the widget
|
||||
do
|
||||
Precursor {VIEW}
|
||||
Precursor {EV_VERTICAL_SPLIT_AREA}
|
||||
draw
|
||||
end
|
||||
|
||||
end
|
747
jj_vision/interface/views/view.e
Normal file
747
jj_vision/interface/views/view.e
Normal file
@@ -0,0 +1,747 @@
|
||||
note
|
||||
description: "[
|
||||
Used as common ancestor to all "windows" in a system built using the
|
||||
"jj_vision" cluster. It provides a way through feature `draw_views'
|
||||
for updating all the views which contain that `target'.
|
||||
Alternatively, the view
|
||||
can force the redraw of views containing any of several objects by passing
|
||||
a set of changed objects to feature `draw_views_with_set'.
|
||||
The class should be an ancestor ancestor along with
|
||||
some effected EV_WIDGET.
|
||||
NOTE: Views which are `is_destroyed' are removed from the global `views' set
|
||||
in feature `draw_views'.
|
||||
]"
|
||||
date: "18 Jul 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/view.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
deferred class
|
||||
VIEW
|
||||
|
||||
inherit
|
||||
|
||||
DIMABLE
|
||||
undefine
|
||||
default_create
|
||||
redefine
|
||||
set_dimming_level
|
||||
end
|
||||
|
||||
SHARED
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
PIXEL_BUFFERS
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
--create
|
||||
-- make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_target: like target)
|
||||
-- Create a new view to display `a_target'
|
||||
do
|
||||
-- This assignment is required to avoid violating a
|
||||
-- precondition "not_empty" later when calling
|
||||
-- feature `create_interface_objects".
|
||||
target_imp := a_target
|
||||
-- `default_create from:
|
||||
-- 1) {EV_ANY} calls `create_interface_objects', later `initialize'
|
||||
-- 2) {EV_MODEL calls only `create_interface_objects'
|
||||
default_create
|
||||
set_target (a_target) -- calls `draw'
|
||||
-- draw
|
||||
end
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation
|
||||
-- bridge pattern.
|
||||
-- Called by `default_create' from {EV_ANY} or {EV_MODEL}
|
||||
require
|
||||
not_interface_objects_created: not is_interface_objects_created
|
||||
do
|
||||
create pixmap.make_with_pixel_buffer (Icon_new_class_color_buffer)
|
||||
is_interface_objects_created := true
|
||||
ensure
|
||||
interface_objects_created: is_interface_objects_created
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize the view and insert it into a global list of views.
|
||||
require
|
||||
view_not_initialized: not is_view_initialized
|
||||
do
|
||||
-- initialize_dimable
|
||||
dimming_level := Dim
|
||||
previous_dimming_level := Dimmer
|
||||
add_actions
|
||||
is_view_initialized := True
|
||||
ensure
|
||||
initialized: is_view_initialized
|
||||
end
|
||||
|
||||
add_actions
|
||||
-- Add any actions to Current.
|
||||
require
|
||||
not_initialized: not is_view_initialized
|
||||
do
|
||||
pointer_button_press_actions.extend (agent on_prepick_right_click)
|
||||
pick_actions.extend (agent on_picked)
|
||||
pointer_motion_actions.extend (agent on_postput_move)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_interface_objects_created: BOOLEAN
|
||||
-- Has `create_interface_objects' been called?
|
||||
|
||||
is_view_initialized: BOOLEAN
|
||||
-- Has `initialize' been called?
|
||||
|
||||
is_pick_notifiable: BOOLEAN
|
||||
-- Should Current be notified by other views (normally
|
||||
-- a view contained in Current) that some event has
|
||||
-- occurred?
|
||||
-- Feature `set_parent_view' must have been called on
|
||||
-- the child view for this to take effect.
|
||||
|
||||
has_parent_view: BOOLEAN
|
||||
-- Does Current know the view in which it resides?
|
||||
do
|
||||
Result := attached parent_view_imp
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
application: JJ_APPLICATION
|
||||
-- The application in which Current resides.
|
||||
do
|
||||
check attached {JJ_APPLICATION} (create {EV_ENVIRONMENT}).application as app then
|
||||
-- because this class is for use in a {JJ_APPLICATION}.
|
||||
Result := app
|
||||
end
|
||||
end
|
||||
|
||||
pixmap: EV_PIXMAP
|
||||
-- The pixmap associated with this view
|
||||
|
||||
-- application: JJ_APPLICATION is
|
||||
-- -- Convience feature for obtaining the current application.
|
||||
-- local
|
||||
-- app: JJ_APPLICATION
|
||||
-- once
|
||||
-- app ?= (create {EV_ENVIRONMENT}).application
|
||||
-- check
|
||||
-- jj_application_exists: app /= Void
|
||||
-- -- Because VIEWs are used in JJ_APPLICATIONs.
|
||||
-- end
|
||||
-- ensure
|
||||
-- result_exists: Result /= Void
|
||||
-- end
|
||||
|
||||
-- command_manager: COMMAND_MANAGER is
|
||||
-- -- Manages the COMMAND's called by the system to allow undo/redo capabilities.
|
||||
-- -- (This is a handle to the `command_manager' from a JJ_APPLICATION; putting it
|
||||
-- -- here instead of in SHARED allows redefinition of the `command_manager' in
|
||||
-- -- descendents of JJ_APPLICATION.
|
||||
-- once
|
||||
-- Result := application.command_manager
|
||||
-- end
|
||||
|
||||
frozen target: attached like target_imp
|
||||
-- The primary target in this view. This feature along with
|
||||
-- `set_target' allows the view to handle one target specially.
|
||||
require
|
||||
not_empty: not is_view_empty
|
||||
do
|
||||
check attached target_imp as t then
|
||||
Result := t
|
||||
end
|
||||
end
|
||||
|
||||
parent_window: JJ_MAIN_WINDOW
|
||||
-- The {JJ_MAIN_WINDOW} if any which contains this view.
|
||||
-- Must redefine to change type.
|
||||
do
|
||||
check attached {EV_CONTAINABLE} Current as c then
|
||||
Result := recursive_parent_window (c)
|
||||
end
|
||||
ensure
|
||||
valid_result: Result /= Void
|
||||
end
|
||||
|
||||
parent_tool: detachable TOOL
|
||||
-- The TOOL, if any, in which Current resides.
|
||||
local
|
||||
con: detachable EV_CONTAINER
|
||||
do
|
||||
from con := parent
|
||||
until Result /= Void or else con = Void
|
||||
loop
|
||||
if attached {TOOL} con as t then
|
||||
Result := t
|
||||
else
|
||||
con := con.parent
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parent_view: attached like parent_view_imp
|
||||
-- The view in which Current resides.
|
||||
-- Provides a way for a model view to notify a parent
|
||||
-- container of changes
|
||||
require
|
||||
has_parent_view: has_parent_view
|
||||
do
|
||||
check attached parent_view_imp as p then
|
||||
Result := p
|
||||
end
|
||||
end
|
||||
|
||||
parent: detachable EV_CONTAINER
|
||||
-- Parent of the current view.
|
||||
-- To be effected by joining with an EV_ class
|
||||
deferred
|
||||
end
|
||||
|
||||
state: VIEW_STATE
|
||||
-- A snapshot of the current look of the view
|
||||
do
|
||||
create Result.make (Current)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_target (a_target: like target)
|
||||
-- Change the value of `target' and realign the table or list
|
||||
-- of views in which `a_target' is displayed.
|
||||
do
|
||||
-- print ("VIEW.set_target: a_target = " + target.out + "%N")
|
||||
-- Remove the old association
|
||||
if attached target_imp and then target /= a_target then
|
||||
check
|
||||
has_associated_view: views_table.has (target)
|
||||
-- because `target_imp' not Void and `make'
|
||||
end
|
||||
views_table.prune (Current)
|
||||
target_imp := Void
|
||||
end
|
||||
if target_imp = Void then
|
||||
-- the expected case, except of initial creation
|
||||
-- print ("VIEW.set_target: if statement target_imp = Void %N")
|
||||
target_imp := a_target
|
||||
views_table.extend (Current)
|
||||
elseif not views_table.has_view (Current) then
|
||||
-- print ("VIEW.set_target: not views_table.has (Current) %N")
|
||||
check
|
||||
same_object: target_imp = a_target
|
||||
-- because of assignment statement in `make'
|
||||
end
|
||||
views_table.extend (Current)
|
||||
end
|
||||
draw
|
||||
ensure
|
||||
has_target: has_target (a_target)
|
||||
end
|
||||
|
||||
set_parent_view (a_view: VIEW)
|
||||
-- Set `parent_view' to `a_view', allowing Current to
|
||||
-- notify `a_view' of some event (e.g. right click).
|
||||
do
|
||||
parent_view_imp := a_view
|
||||
end
|
||||
|
||||
set_dimming_level (a_level: like dimming_level)
|
||||
-- Change the `dimming_level'
|
||||
do
|
||||
Precursor (a_level)
|
||||
-- paint
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
-- paint
|
||||
-- -- Draw the current view when some property like
|
||||
-- -- background color changes
|
||||
-- do
|
||||
-- end
|
||||
|
||||
draw
|
||||
-- Draw the current view.
|
||||
-- Default does nothing
|
||||
require
|
||||
view_is_drawable: not is_draw_disabled
|
||||
do
|
||||
end
|
||||
|
||||
draw_other_views (a_target: ANY)
|
||||
-- Draw all views that contain `a_target' except Current
|
||||
-- This also cleans any "destroyed" views from the `views' set.
|
||||
require
|
||||
target_exists: a_target /= Void
|
||||
local
|
||||
b: BOOLEAN
|
||||
do
|
||||
b := is_draw_disabled
|
||||
disable_drawing
|
||||
draw_views (a_target)
|
||||
if not b then
|
||||
enable_drawing
|
||||
end
|
||||
end
|
||||
|
||||
draw_views (a_target: ANY)
|
||||
-- Draw the views which contain `a_target'.
|
||||
local
|
||||
lin: LINEAR [VIEW]
|
||||
marks: LINKED_SET [VIEW] -- Views marked for removal.
|
||||
v: VIEW
|
||||
do
|
||||
create marks.make
|
||||
lin := views_table.linear (a_target)
|
||||
from lin.start
|
||||
until lin.after
|
||||
loop
|
||||
v := lin.item
|
||||
if v.is_destroyed then
|
||||
marks.extend (v)
|
||||
elseif not v.is_draw_disabled then
|
||||
v.draw
|
||||
end
|
||||
lin.forth
|
||||
end
|
||||
-- Clean out any views that are no longer usable.
|
||||
from marks.start
|
||||
until marks.exhausted
|
||||
loop
|
||||
views_table.prune (marks.item)
|
||||
marks.forth
|
||||
end
|
||||
end
|
||||
|
||||
draw_views_with_set (a_set: LINEAR [ANY])
|
||||
-- Draw the views which contain any of the objects in `a_set'.
|
||||
-- This also cleans any "destroyed" views from the `views' set.
|
||||
require
|
||||
set_exists: a_set /= Void
|
||||
local
|
||||
lin: LINEAR [VIEW]
|
||||
marks: LINKED_SET [VIEW] -- Views marked for removal.
|
||||
v: VIEW
|
||||
do
|
||||
create marks.make
|
||||
lin := views_table.linear_with_set (a_set)
|
||||
from lin.start
|
||||
until lin.after
|
||||
loop
|
||||
v := lin.item
|
||||
if v.is_destroyed then
|
||||
marks.extend (v)
|
||||
elseif not v.is_draw_disabled then
|
||||
v.draw
|
||||
end
|
||||
lin.forth
|
||||
end
|
||||
-- Clean out any views that are no longer usable.
|
||||
from marks.start
|
||||
until marks.exhausted
|
||||
loop
|
||||
views_table.prune (marks.item)
|
||||
marks.forth
|
||||
end
|
||||
end
|
||||
|
||||
draw_all_views
|
||||
-- Draw *all* the views in the system.
|
||||
-- Also cleans any "destroyed" views for the `views' set.
|
||||
local
|
||||
lin: LINEAR [VIEW]
|
||||
marks: LINKED_SET [VIEW] -- Views marked for removal.
|
||||
v: VIEW
|
||||
do
|
||||
create marks.make
|
||||
lin := views_table.linear_representation
|
||||
from lin.start
|
||||
until lin.after
|
||||
loop
|
||||
v := lin.item
|
||||
if v.is_destroyed then
|
||||
marks.extend (v)
|
||||
elseif not v.is_draw_disabled then
|
||||
v.draw
|
||||
end
|
||||
lin.forth
|
||||
end
|
||||
-- Clean out any views that are no longer usable.
|
||||
from marks.start
|
||||
until marks.exhausted
|
||||
loop
|
||||
views_table.prune (marks.item)
|
||||
marks.forth
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_in_default_state: BOOLEAN = true
|
||||
-- Is `Current' in its default state?
|
||||
-- The intent of this class is to be joined with an EV_WIDGET.
|
||||
-- The default state of a descendent is most likely not the same
|
||||
-- as the default state of the parent EV_WIDGET (after all, a
|
||||
-- new type widget is being defined that, by definition looks
|
||||
-- different from the parent.)
|
||||
-- This silly feature is the post-condition of `default_create'
|
||||
-- from EV_WIDGET, which required a choice--either redefine this
|
||||
-- feature in every EV_WIDGET descendant or, as chosen here, use
|
||||
-- this version (the EV_WIDGET version is irrelavent anyway) and
|
||||
-- undefine it in the inherit class of the EV_WIDGET parent.
|
||||
|
||||
is_destroyed: BOOLEAN
|
||||
-- Has the view been destroyed?
|
||||
-- This will be joined with an EV_WIDGET feature
|
||||
deferred
|
||||
end
|
||||
|
||||
is_view_empty: BOOLEAN
|
||||
-- Are there no objects in this VIEW?
|
||||
do
|
||||
Result := target_imp = Void
|
||||
end
|
||||
|
||||
is_draw_disabled: BOOLEAN
|
||||
-- Can the view be drawn using 'draw'?
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
disable_drawing
|
||||
-- Block the view from being redrawn by calling draw.
|
||||
-- Used to reduce number of calls to draw.
|
||||
do
|
||||
is_draw_disabled := True
|
||||
ensure
|
||||
drawing_not_allowed: is_draw_disabled
|
||||
end
|
||||
|
||||
enable_drawing
|
||||
-- Allow the view to be redrawn on a call to draw.
|
||||
do
|
||||
is_draw_disabled := False
|
||||
ensure
|
||||
drawing_allowed: not is_draw_disabled
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
has_target (a_target: like target): BOOLEAN
|
||||
-- Does Current contain `a_target'?
|
||||
do
|
||||
Result := target_imp = a_target
|
||||
end
|
||||
|
||||
display_name (a_object: ANY): STRING
|
||||
-- An identifying "out" value corresponding to `a_object'.
|
||||
require
|
||||
object_exists: a_object /= Void
|
||||
do
|
||||
if attached {EDITABLE} a_object as e then
|
||||
Result := e.display_name
|
||||
else
|
||||
Result := "fix me"
|
||||
print ("VIEW.display_name -- get from once table?")
|
||||
end
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
yes_cursor (a_target: ANY): EV_POINTER_STYLE
|
||||
-- Cursor for `a_target'.
|
||||
do
|
||||
create Result.make_with_pixel_buffer (Icon_new_class_color_buffer, 0, 0)
|
||||
end
|
||||
|
||||
no_cursor (a_target: ANY): EV_CURSOR
|
||||
-- Cursor for `a_target'.
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
linear (a_object: ANY): LINEAR [VIEW]
|
||||
-- List of views in which `a_object' is displayed. The
|
||||
-- resulting list could be empty.
|
||||
do
|
||||
Result := views_table.linear (a_object)
|
||||
end
|
||||
|
||||
linear_with_set (a_set: LINEAR [ANY]): LINEAR [VIEW]
|
||||
-- List of views in which any of the objects in `a_set'
|
||||
-- is displayed.
|
||||
do
|
||||
Result := views_table.linear_with_set (a_set)
|
||||
end
|
||||
|
||||
frozen post_pick_move_agent: PROCEDURE [TUPLE [a_x, a_y: INTEGER;
|
||||
a_x_tilt, a_y_tilt, a_pressure: DOUBLE;
|
||||
a_screen_x, a_screen_y: INTEGER]]
|
||||
-- Creates an agent out of `on_postput_move' which is added to
|
||||
-- the `pointer_motion_actions' of *ALL* views when a pick occurs
|
||||
-- (see `on_picked'). Holding on to this agent as a once feature
|
||||
-- allows `on_postput_move' to remove this agent from *ALL* the
|
||||
-- views after the pick has ended and the mouse is moved [in one
|
||||
-- of the views].
|
||||
once
|
||||
Result := agent on_postput_move
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
target_changed_operations
|
||||
-- This feature is called by `notify_views' to perform
|
||||
-- actions when that view's `target' was modified.
|
||||
do
|
||||
print ("{VIEW}.target_changed_operations %N")
|
||||
|
||||
end
|
||||
|
||||
pick_notified_operations (a_target: ANY)
|
||||
-- React to the pick of `a_target' from some view
|
||||
do
|
||||
print ("{VIEW}.pick_notified_operations on {" + generating_type.name + "}%N")
|
||||
|
||||
end
|
||||
|
||||
pick_ended_operations
|
||||
-- React to the end of a pick and drop operation
|
||||
do
|
||||
print ("{VIEW}.pick_ended_operations on {" + generating_type.name + "} %N")
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- Agents and support (actions)
|
||||
|
||||
frozen on_prepick_right_click (x, y, button: INTEGER;
|
||||
x_tilt, y_tilt, pressure: DOUBLE;
|
||||
screen_x, screen_y: INTEGER)
|
||||
-- Notify the parent of all views that contain `target'
|
||||
-- that a pick event occurred involving `target'.
|
||||
local
|
||||
lin: LINEAR [VIEW]
|
||||
marks: LINKED_SET [VIEW] -- Views marked for removal.
|
||||
v: VIEW
|
||||
do
|
||||
-- is_picking.set_item (true)
|
||||
create marks.make
|
||||
lin := views_table.linear (target)
|
||||
from lin.start
|
||||
until lin.after
|
||||
loop
|
||||
v := lin.item
|
||||
if v.is_destroyed then
|
||||
marks.extend (v)
|
||||
elseif v.has_parent_view then
|
||||
-- Notifiy the parent view of the pick
|
||||
v.parent_view.pick_notified_operations (target)
|
||||
-- Save the view for notification when pick ends
|
||||
pick_notified_views.extend (v.parent_view)
|
||||
end
|
||||
lin.forth
|
||||
end
|
||||
-- Clean out any views that are no longer usable.
|
||||
from marks.start
|
||||
until marks.exhausted
|
||||
loop
|
||||
views_table.prune (marks.item)
|
||||
marks.forth
|
||||
end
|
||||
end
|
||||
|
||||
frozen on_picked (a_x, a_y: INTEGER)
|
||||
-- Notify the parent of all views that contain `target'
|
||||
-- that a pick event occurred involving `target'.
|
||||
local
|
||||
lin: LINEAR [VIEW]
|
||||
marks: LINKED_SET [VIEW] -- Views marked for removal.
|
||||
v: VIEW
|
||||
do
|
||||
is_picking.set_item (true)
|
||||
-- create marks.make
|
||||
-- lin := views_table.linear (target)
|
||||
-- from lin.start
|
||||
-- until lin.after
|
||||
-- loop
|
||||
-- v := lin.item
|
||||
-- if v.is_destroyed then
|
||||
-- marks.extend (v)
|
||||
-- elseif v.has_parent_view then
|
||||
-- -- Notifiy the parent view of the pick
|
||||
-- v.parent_view.pick_notified_operations (target)
|
||||
-- -- Save the view for notification when pick ends
|
||||
-- pick_notified_views.extend (v.parent_view)
|
||||
-- end
|
||||
-- lin.forth
|
||||
-- end
|
||||
-- -- Clean out any views that are no longer usable.
|
||||
-- from marks.start
|
||||
-- until marks.exhausted
|
||||
-- loop
|
||||
-- views_table.prune (marks.item)
|
||||
-- marks.forth
|
||||
-- end
|
||||
end
|
||||
|
||||
frozen on_postput_move (a_x, a_y: INTEGER;
|
||||
a_x_tilt, a_y_tilt, a_pressure: DOUBLE;
|
||||
a_screen_x, a_screen_y: INTEGER)
|
||||
-- Feature added as agent to `pointer_motion_actions'
|
||||
-- to react after a pnp operations has ended. It calls
|
||||
-- feature `postput_operations'.
|
||||
-- Redefine `postput_operations' to clean up any operations
|
||||
-- that occurred in `do_prepick_operations'.
|
||||
-- See index clause for information on pick-and-put.
|
||||
local
|
||||
v: VIEW
|
||||
do
|
||||
print ("{VIEW}.on_postput_move on " + generating_type.name + "%N")
|
||||
-- Notify views when a transport has ended.
|
||||
if is_picking.item and then not application.transport_in_progress then
|
||||
print ("%T `is_picking and not transport_in_progress pick_notified_views.count = " + pick_notified_views.count.out + "%N")
|
||||
is_picking.set_item (false)
|
||||
-- Inform any parent views that the pick has ended
|
||||
from pick_notified_views.start
|
||||
until pick_notified_views.after
|
||||
loop
|
||||
v := pick_notified_views.item
|
||||
v.pick_ended_operations
|
||||
pick_notified_views.forth
|
||||
end
|
||||
pick_notified_views.wipe_out
|
||||
end
|
||||
end
|
||||
|
||||
notify_changed (a_target: ANY)
|
||||
-- Inform the views that have `a_target' that `a_target'
|
||||
-- has changed (i.e. call `on_target_changed' for those
|
||||
-- views).
|
||||
-- This also cleans any "destroyed" views from the `views' set.
|
||||
local
|
||||
lin: LINEAR [VIEW]
|
||||
marks: LINKED_SET [VIEW] -- Views marked for removal.
|
||||
v: VIEW
|
||||
do
|
||||
create marks.make
|
||||
lin := views_table.linear (a_target)
|
||||
from lin.start
|
||||
until lin.after
|
||||
loop
|
||||
v := lin.item
|
||||
if v.is_destroyed then
|
||||
marks.extend (v)
|
||||
elseif not v.is_draw_disabled then
|
||||
v.target_changed_operations
|
||||
end
|
||||
lin.forth
|
||||
end
|
||||
-- Clean out any views that are no longer usable.
|
||||
from marks.start
|
||||
until marks.exhausted
|
||||
loop
|
||||
views_table.prune (marks.item)
|
||||
marks.forth
|
||||
end
|
||||
end
|
||||
|
||||
frozen is_picking: BOOLEAN_REF
|
||||
-- Is a pick-and-put (PNP) operation in progress?
|
||||
-- It seems the PNP operations intercepts events system-
|
||||
-- wide, so this is a global reference.
|
||||
-- See index clause for information on pick-and-put.
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
pick_notified_views: LINKED_SET [VIEW]
|
||||
-- List of views that were notfied by `on_picked'
|
||||
once
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- Action sequences
|
||||
|
||||
pointer_button_press_actions: EV_POINTER_BUTTON_ACTION_SEQUENCE
|
||||
-- Actions to be performed when screen pointer button is pressed.
|
||||
-- Defined here as place-holder to be undefined (i.e. joined) to
|
||||
-- the version from {EV_WIDGET} or {EV_MODEL}.
|
||||
-- See index clause for information on pick-and-put.
|
||||
deferred
|
||||
end
|
||||
|
||||
pointer_motion_actions: EV_POINTER_MOTION_ACTION_SEQUENCE
|
||||
-- Actions to be performed when screen pointer moves.
|
||||
-- Defined here as place-holder to be undefined (i.e. joined) to
|
||||
-- the version from {EV_WIDGET} or {EV_MODEL}.
|
||||
-- See index clause for information on pick-and-put.
|
||||
deferred
|
||||
end
|
||||
|
||||
pick_actions: EV_PND_START_ACTION_SEQUENCE
|
||||
-- Actions to be performed when `pebble' is picked up.
|
||||
-- Defined here as place-holder to be undefined by some
|
||||
-- {EV_WIDGET} or {EV_MODEL}.
|
||||
deferred
|
||||
end
|
||||
|
||||
drop_actions: EV_PND_ACTION_SEQUENCE --EV_PND_START_ACTION_SEQUENCE
|
||||
-- Actions to be performed when a pebble is dropped here.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
recursive_parent_window (a_containable: EV_CONTAINABLE): JJ_MAIN_WINDOW
|
||||
-- The {JJ_MAIN_WINDOW} which contains this tool.
|
||||
-- This procedure was provided by Julian Rodgers from the Eiffel
|
||||
-- users group.
|
||||
do
|
||||
check attached {EV_CONTAINER} a_containable.parent as cur_parent then
|
||||
-- because parent of EV_CONTAINABLE must be an EV_CONTAINER
|
||||
if attached {JJ_MAIN_WINDOW} cur_parent as w then
|
||||
Result := w
|
||||
else
|
||||
check attached {EV_CONTAINABLE} cur_parent as con_parent then
|
||||
-- because, if `cur_parent' is not a {JJ_MAIN_WINDOW} it must be EV_CONTAINABLE
|
||||
Result := recursive_parent_window (con_parent)
|
||||
end
|
||||
end
|
||||
end
|
||||
ensure
|
||||
result_exists: Result /= Void
|
||||
end
|
||||
|
||||
feature {NONE} -- Implemetation
|
||||
|
||||
target_imp: detachable ANY
|
||||
-- Detachable implementation of `target' for void safety
|
||||
|
||||
views_table: VIEW_TARGET_TABLE
|
||||
-- Global table associating objects to views
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
parent_view_imp: detachable VIEW
|
||||
-- Detachable implementation of `parent_view'
|
||||
|
||||
invariant
|
||||
|
||||
-- not_empty: target_imp /= Void
|
||||
|
||||
end
|
290
jj_vision/interface/views/window_preferences_view.e
Normal file
290
jj_vision/interface/views/window_preferences_view.e
Normal file
@@ -0,0 +1,290 @@
|
||||
note
|
||||
description: "[
|
||||
A {VIEW} placed in a {PREFERENCES_WINDOW} for setting the
|
||||
startup and appearance attributes of a {JJ_MAIN_WINDOW}
|
||||
]"
|
||||
date: "12 Sep 03"
|
||||
author: "Jimmy J. Johnson"
|
||||
copyright: "Copyright 2012, Jimmy J. Johnson"
|
||||
license: "Eiffel Forum License v2 (see forum.txt)"
|
||||
URL: "$URL: file:///F:/eiffel_repositories/jj_vision/trunk/interface/views/window_preferences_view.e $"
|
||||
date: "$Date: 2015-10-24 07:32:40 -0700 (Sat, 24 Oct 2015) $"
|
||||
revision: "$Revision: 23 $"
|
||||
|
||||
class
|
||||
WINDOW_PREFERENCES_VIEW
|
||||
|
||||
inherit
|
||||
|
||||
SHARED
|
||||
undefine
|
||||
default_create,
|
||||
is_equal
|
||||
end
|
||||
|
||||
FIXED_VIEW
|
||||
undefine
|
||||
copy
|
||||
redefine
|
||||
create_interface_objects,
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
default_create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_interface_objects
|
||||
-- Create objects to be used by `Current' in `initialize'
|
||||
-- Implemented by descendants to create attached objects
|
||||
-- in order to adhere to void-safety due to the implementation bridge pattern.
|
||||
do
|
||||
Precursor {FIXED_VIEW}
|
||||
create apply_to_label
|
||||
create apply_to_combo_box
|
||||
create hide_menu_check_button
|
||||
create hide_button_text_check_button
|
||||
create button_size_label
|
||||
create button_size_spin_button.make_with_value_range (create
|
||||
{INTEGER_INTERVAL}.make (Minimum_pixmap_size, Maximum_pixmap_size))
|
||||
create language_combo_box
|
||||
create start_up_options_label
|
||||
create height_label
|
||||
create height_spin_button
|
||||
create width_label
|
||||
create width_spin_button
|
||||
create x_position_label
|
||||
create x_position_spin_button
|
||||
create y_position_label
|
||||
create y_position_spin_button
|
||||
create mode_label
|
||||
create mode_combo_box
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Set up the dialog
|
||||
do
|
||||
Precursor {FIXED_VIEW}
|
||||
hide_menu_check_button.align_text_left
|
||||
hide_button_text_check_button.align_text_right
|
||||
-- height_spin_button.align_text_left
|
||||
-- width_spin_button.align_text_left
|
||||
-- x_position_spin_button.align_text_left
|
||||
-- y_position_spin_button.align_text_left
|
||||
|
||||
extend (apply_to_label)
|
||||
extend (apply_to_combo_box)
|
||||
extend (hide_menu_check_button)
|
||||
extend (hide_button_text_check_button)
|
||||
extend (button_size_label)
|
||||
extend (button_size_spin_button)
|
||||
extend (language_combo_box)
|
||||
extend (start_up_options_label)
|
||||
extend (height_label)
|
||||
extend (height_spin_button)
|
||||
extend (width_label)
|
||||
extend (width_spin_button)
|
||||
extend (x_position_label)
|
||||
extend (x_position_spin_button)
|
||||
extend (y_position_label)
|
||||
extend (y_position_spin_button)
|
||||
extend (mode_label)
|
||||
extend (mode_combo_box)
|
||||
|
||||
build_widgets
|
||||
set_actions
|
||||
end
|
||||
|
||||
feature {NONE} -- Basic operations
|
||||
|
||||
build_widgets
|
||||
-- Set the apperance and location of all the controls
|
||||
local
|
||||
|
||||
do
|
||||
-- Fix so it looks up these interface items
|
||||
apply_to_label.set_text ("Apply these changes to")
|
||||
apply_to_combo_box.extend (create {EV_LIST_ITEM}.make_with_text ("All"))
|
||||
apply_to_combo_box.extend (create {EV_LIST_ITEM}.make_with_text ("New"))
|
||||
hide_menu_check_button.set_text ("Hide menu bar")
|
||||
hide_button_text_check_button.set_text ("Hide button text")
|
||||
language_combo_box.set_text ("English")
|
||||
start_up_options_label.set_text ("Start-up options")
|
||||
height_label.set_text ("Height")
|
||||
width_label.set_text ("Width")
|
||||
x_position_label.set_text ("X position")
|
||||
y_position_label.set_text ("Y position")
|
||||
mode_label.set_text ("Select mode")
|
||||
button_size_label.set_text ("Button size")
|
||||
|
||||
set_item_position (apply_to_label, Spacing, Spacing)
|
||||
set_item_position (apply_to_combo_box,
|
||||
apply_to_label.x_position + apply_to_label.width + Spacing,
|
||||
apply_to_label.y_position)
|
||||
set_item_position (hide_menu_check_button,
|
||||
Spacing,
|
||||
apply_to_combo_box.y_position + apply_to_combo_box.height + Spacing)
|
||||
set_item_position (hide_button_text_check_button,
|
||||
Spacing,
|
||||
hide_menu_check_button.y_position + hide_menu_check_button.height + Spacing)
|
||||
set_item_position (button_size_label,
|
||||
Spacing,
|
||||
hide_button_text_check_button.y_position + hide_button_text_check_button.height + Spacing)
|
||||
set_item_position (button_size_spin_button,
|
||||
button_size_label.x_position + button_size_label.width + Spacing,
|
||||
button_size_label.y_position)
|
||||
set_item_position (language_combo_box,
|
||||
Spacing,
|
||||
button_size_spin_button.y_position + button_size_spin_button.height + Spacing)
|
||||
set_item_position (start_up_options_label,
|
||||
Spacing,
|
||||
language_combo_box.y_position + language_combo_box.height + Spacing)
|
||||
set_item_position (height_label,
|
||||
Spacing + Spacing,
|
||||
start_up_options_label.y_position + start_up_options_label.height + 2)
|
||||
set_item_position (height_spin_button,
|
||||
height_label.x_position + height_label.width + Spacing,
|
||||
height_label.y_position)
|
||||
set_item_position (width_label,
|
||||
Spacing + Spacing,
|
||||
height_spin_button.y_position + height_spin_button.height + Spacing)
|
||||
set_item_position (width_spin_button,
|
||||
height_spin_button.x_position,
|
||||
width_label.y_position)
|
||||
set_item_position (x_position_label,
|
||||
height_spin_button.x_position + height_spin_button.width + Spacing + Spacing,
|
||||
height_label.y_position)
|
||||
set_item_position (x_position_spin_button,
|
||||
x_position_label.x_position + x_position_label.width + Spacing,
|
||||
x_position_label.y_position)
|
||||
set_item_position (y_position_label,
|
||||
x_position_label.x_position,
|
||||
width_label.y_position)
|
||||
set_item_position (y_position_spin_button,
|
||||
y_position_label.x_position + y_position_label.width + Spacing,
|
||||
y_position_label.y_position)
|
||||
set_item_position (mode_label,
|
||||
Spacing,
|
||||
width_label.y_position + width_label.height + Spacing + Spacing)
|
||||
set_item_position (mode_combo_box,
|
||||
mode_label.x_position + mode_label.width + Spacing,
|
||||
mode_label.y_position)
|
||||
end
|
||||
|
||||
set_actions
|
||||
-- Add agents to the controls
|
||||
do
|
||||
hide_menu_check_button.select_actions.extend (agent on_hide_menu_option_changed)
|
||||
hide_button_text_check_button.select_actions.extend (agent on_hide_button_text_check_button_changed)
|
||||
button_size_spin_button.change_actions.extend (agent on_button_size_spin_button_changed)
|
||||
end
|
||||
|
||||
feature {NONE} -- Basic operations
|
||||
|
||||
on_hide_menu_option_changed
|
||||
-- React to a change of the `hide_menu_check_button' by showing ro hiding
|
||||
-- the menu bar in all the main windows in the system
|
||||
local
|
||||
mw: JJ_MAIN_WINDOW
|
||||
do
|
||||
from main_windows.start
|
||||
until main_windows.exhausted
|
||||
loop
|
||||
mw := main_windows.item
|
||||
if not hide_menu_check_button.is_selected and then mw.menu_bar = Void then
|
||||
mw.show_menu
|
||||
else
|
||||
mw.hide_menu
|
||||
end
|
||||
main_windows.forth
|
||||
end
|
||||
end
|
||||
|
||||
on_hide_button_text_check_button_changed
|
||||
-- React to a change of the `hide_button_text_check_button' by showing or hiding
|
||||
-- text on all the buttons in the systems `main_windows'.
|
||||
local
|
||||
mw: JJ_MAIN_WINDOW
|
||||
do
|
||||
from main_windows.start
|
||||
until main_windows.exhausted
|
||||
loop
|
||||
mw := main_windows.item
|
||||
if hide_button_text_check_button.is_selected then
|
||||
mw.hide_button_text
|
||||
else
|
||||
mw.show_button_text
|
||||
end
|
||||
main_windows.forth
|
||||
end
|
||||
end
|
||||
|
||||
on_button_size_spin_button_changed (a_value: INTEGER)
|
||||
-- React to a change of the `button_size_spin_button' by changing the
|
||||
-- size of the toolbar buttons in the system's `main_window'.
|
||||
do
|
||||
io.put_string ("Fix me! WINDOW_PREFERENCES_VIEW.on_button_size_spin_button_changed %N")
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
apply_to_label: EV_LABEL
|
||||
-- Label to go with `apply_to_combo_box'
|
||||
|
||||
apply_to_combo_box: EV_COMBO_BOX
|
||||
-- Apply settings to one or all windows in system
|
||||
|
||||
hide_menu_check_button: EV_CHECK_BUTTON
|
||||
-- Check to show main menu
|
||||
|
||||
hide_button_text_check_button: EV_CHECK_BUTTON
|
||||
-- Check to display text along with the pixmaps on buttons.
|
||||
|
||||
button_size_label: EV_LABEL
|
||||
-- Label to go with `button_size_spin_button'.
|
||||
|
||||
button_size_spin_button: EV_SPIN_BUTTON
|
||||
-- Sets the size of the pixmaps (and consequently the size of the buttons).
|
||||
|
||||
language_combo_box: EV_COMBO_BOX
|
||||
-- Select the language to use
|
||||
|
||||
start_up_options_label: EV_LABEL
|
||||
-- Simply a heading saying "Start up options".
|
||||
|
||||
height_label: EV_LABEL
|
||||
-- Label to go with `height_spin_button'
|
||||
|
||||
height_spin_button: EV_SPIN_BUTTON
|
||||
-- Sets the start-up height of a MAIN_WINDOW
|
||||
|
||||
width_label: EV_LABEL
|
||||
-- Label to go with `height_spin_button'
|
||||
|
||||
width_spin_button: EV_SPIN_BUTTON
|
||||
-- Sets the start-up width of a MAIN_WINDOW
|
||||
|
||||
x_position_label: EV_LABEL
|
||||
-- Label to to with `x_position_spin_button
|
||||
|
||||
x_position_spin_button: EV_SPIN_BUTTON
|
||||
-- Sets the start-up `x_position' of a MAIN_WINDOW
|
||||
|
||||
y_position_label: EV_LABEL
|
||||
-- Label to to with `y_position_spin_button
|
||||
|
||||
y_position_spin_button: EV_SPIN_BUTTON
|
||||
-- Sets the start-up `y_position' of a MAIN_WINDOW
|
||||
|
||||
mode_label: EV_LABEL
|
||||
-- Label to go with `mode_combo_box'
|
||||
|
||||
mode_combo_box: EV_COMBO_BOX
|
||||
-- Select the start-up mode of a MAIN_WINDOW
|
||||
|
||||
feature {NONE} -- Implementation (constants)
|
||||
|
||||
Spacing: INTEGER = 10
|
||||
|
||||
end
|
Reference in New Issue
Block a user