init
This commit is contained in:
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
Reference in New Issue
Block a user