redcar 0.6.1 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +26 -0
- data/README.md +17 -31
- data/Rakefile +1 -1
- data/bin/redcar +1 -1
- data/lib/redcar.rb +8 -4
- data/lib/redcar/installer.rb +2 -1
- data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
- data/plugins/application/features/step_definitions/tree_steps.rb +1 -1
- data/plugins/application/features/support/env.rb +38 -17
- data/plugins/application/lib/application.rb +4 -0
- data/plugins/application/lib/application/command.rb +8 -2
- data/plugins/application/lib/application/command/executor.rb +37 -8
- data/plugins/application/lib/application/command/history.rb +3 -3
- data/plugins/application/lib/application/menu.rb +4 -0
- data/plugins/application/lib/application/menu/item.rb +9 -1
- data/plugins/application/lib/application/tab.rb +11 -0
- data/plugins/application/spec/application/command/executor_spec.rb +3 -3
- data/plugins/application/spec/application/command_spec.rb +24 -0
- data/plugins/application/spec/spec_helper.rb +1 -0
- data/plugins/application_swt/lib/application_swt.rb +27 -24
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -33
- data/plugins/application_swt/lib/application_swt/dialogs/input_dialog.rb +46 -0
- data/plugins/application_swt/lib/application_swt/dialogs/text_and_file_dialog.rb +118 -0
- data/plugins/application_swt/lib/application_swt/icon.rb +37 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +8 -3
- data/plugins/application_swt/lib/application_swt/tab.rb +6 -3
- data/plugins/application_swt/lib/application_swt/treebook.rb +29 -31
- data/plugins/application_swt/lib/swt/graphics_utils.rb +170 -0
- data/plugins/application_swt/lib/swt/vtab_folder.rb +125 -0
- data/plugins/application_swt/lib/swt/vtab_item.rb +69 -0
- data/plugins/application_swt/lib/swt/vtab_label.rb +84 -0
- data/plugins/auto_indenter/lib/auto_indenter.rb +4 -2
- data/plugins/core/lib/core/controller.rb +18 -0
- data/plugins/declarations/lib/declarations.rb +1 -1
- data/plugins/document_search/lib/document_search.rb +8 -6
- data/plugins/document_search/lib/document_search/replace.rb +51 -31
- data/plugins/document_search/lib/document_search/search_and_replace.rb +12 -11
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +33 -17
- data/plugins/edit_view/lib/edit_view.rb +100 -21
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +34 -11
- data/plugins/edit_view/lib/edit_view/actions/deletion.rb +10 -0
- data/plugins/edit_view/lib/edit_view/command.rb +5 -1
- data/plugins/edit_view/lib/edit_view/document.rb +8 -3
- data/plugins/edit_view/lib/edit_view/document/command.rb +15 -1
- data/plugins/edit_view/lib/edit_view/document/controller.rb +9 -0
- data/plugins/edit_view/lib/edit_view/document/history.rb +41 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +1 -11
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +150 -4
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +1 -1
- data/plugins/edit_view_swt/vendor/java-mateview.rb +1 -1
- data/plugins/find-in-project/lib/find_in_project.rb +7 -5
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +2 -2
- data/plugins/line_tools/features/step_definitions/line_tools_steps.rb +0 -1
- data/plugins/line_tools/lib/line_tools.rb +7 -9
- data/plugins/macros/features/block_selection_in_macros.feature +48 -0
- data/plugins/macros/features/predictive_macros.feature +79 -0
- data/plugins/macros/features/record_and_run_macro.feature +87 -0
- data/plugins/macros/features/step_definitions/macro_steps.rb +66 -0
- data/plugins/macros/features/step_definitions/prediction_steps.rb +8 -0
- data/plugins/macros/features/support/env.rb +2 -0
- data/plugins/macros/lib/macros.rb +167 -0
- data/plugins/macros/lib/macros/action_sequence.rb +30 -0
- data/plugins/macros/lib/macros/commands.rb +108 -0
- data/plugins/macros/lib/macros/macro.rb +37 -0
- data/plugins/macros/lib/macros/manager_controller.rb +67 -0
- data/plugins/macros/lib/macros/predictive/document_controller.rb +69 -0
- data/plugins/macros/lib/macros/predictive/sequence_finder.rb +112 -0
- data/plugins/macros/plugin.rb +9 -0
- data/plugins/macros/spec/macros/predictive/sequence_finder_spec.rb +142 -0
- data/plugins/macros/spec/spec_helper.rb +6 -0
- data/plugins/macros/views/macro_manager.html.erb +86 -0
- data/plugins/outline_view/lib/outline_view.rb +1 -1
- data/plugins/project/lib/project/commands.rb +2 -2
- data/plugins/redcar/redcar.rb +37 -46
- data/plugins/repl/lib/repl.rb +4 -4
- data/plugins/runnables/features/command_tree.feature +1 -1
- data/plugins/runnables/features/parameter_input.feature +42 -0
- data/plugins/runnables/features/step_definitions/runnable_steps.rb +6 -0
- data/plugins/runnables/features/support/env.rb +28 -8
- data/plugins/runnables/lib/runnables.rb +35 -206
- data/plugins/runnables/lib/runnables/commands.rb +65 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable.rb +62 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +59 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +32 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +41 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +61 -0
- data/plugins/scm/lib/scm.rb +78 -45
- data/plugins/scm/lib/scm/commands.rb +18 -4
- data/plugins/scm/lib/scm/model.rb +54 -41
- data/plugins/scm_svn/LICENSE +48 -0
- data/plugins/scm_svn/features/add_and_commit.feature +18 -0
- data/plugins/scm_svn/features/checkout.feature +5 -0
- data/plugins/scm_svn/features/edit_and_index.feature +12 -0
- data/plugins/scm_svn/features/ignore_files.feature +14 -0
- data/plugins/scm_svn/features/merge.feature +34 -0
- data/plugins/scm_svn/features/resolve_conflict.feature +23 -0
- data/plugins/scm_svn/features/revert_and_delete.feature +21 -0
- data/plugins/scm_svn/features/step_definitions/branch_and_merge_steps.rb +27 -0
- data/plugins/scm_svn/features/step_definitions/checkout_steps.rb +25 -0
- data/plugins/scm_svn/features/step_definitions/edit_and_index_steps.rb +50 -0
- data/plugins/scm_svn/features/step_definitions/scm_svn_steps.rb +57 -0
- data/plugins/scm_svn/features/support/env.rb +74 -0
- data/plugins/scm_svn/features/switch_branches.feature +53 -0
- data/plugins/scm_svn/features/update.feature +16 -0
- data/plugins/scm_svn/lib/scm_svn.rb +423 -9
- data/plugins/scm_svn/lib/scm_svn/change.rb +116 -0
- data/plugins/swt/lib/swt.rb +0 -15
- data/plugins/swt/lib/swt/cucumber_patches.rb +2 -37
- data/plugins/swt/lib/swt/cucumber_runner.rb +1 -0
- data/plugins/swt/lib/swt/full_swt.rb +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Clojure.tmbundle/Syntaxes/Clojure.tmLanguage +14 -2
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +1 -1
- data/plugins/todo_list/views/default.css +50 -0
- data/plugins/todo_list/views/index.html.erb +5 -16
- data/plugins/todo_list/views/redcar_small_icon.png +0 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +14 -33
- data/plugins/view_shortcuts/views/default.css +31 -0
- data/plugins/view_shortcuts/views/index.html.erb +26 -16
- data/plugins/view_shortcuts/views/redcar_small_icon.png +0 -0
- data/{plugins/runnables → share}/icons/cog.png +0 -0
- data/share/icons/folder-gear-emblem.png +0 -0
- data/share/icons/folder-gear.png +0 -0
- data/share/icons/folder-open-small-gears.png +0 -0
- metadata +59 -5
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class ApplicationSWT
|
4
|
+
module Icon
|
5
|
+
def self.swt_image(icon)
|
6
|
+
case icon
|
7
|
+
when :directory
|
8
|
+
dir_image
|
9
|
+
when :file
|
10
|
+
file_image
|
11
|
+
when Symbol
|
12
|
+
image(File.expand_path(File.join(Redcar::ICONS_DIRECTORY, icon.to_s + ".png")))
|
13
|
+
when String
|
14
|
+
image(icon)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.image(path)
|
19
|
+
cached_images[path] ||= Swt::Graphics::Image.new(ApplicationSWT.display, path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.cached_images
|
23
|
+
@cached_images ||= {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.dir_image
|
27
|
+
path = File.join(Redcar.root, %w(plugins application icons darwin-folder.png))
|
28
|
+
image(path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.file_image
|
32
|
+
path = File.join(Redcar.root, %w(plugins application icons darwin-file.png))
|
33
|
+
image(path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -60,12 +60,10 @@ module Redcar
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def add_entries_to_menu(menu, menu_model)
|
63
|
-
|
64
63
|
menu_model.each do |entry|
|
65
64
|
if entry.is_a?(Redcar::Menu::LazyMenu)
|
66
65
|
menu_header = Swt::Widgets::MenuItem.new(menu, Swt::SWT::CASCADE)
|
67
66
|
menu_header.text = entry.text
|
68
|
-
#new_menu = Swt::Widgets::Menu.new(@window.shell, Swt::SWT::DROP_DOWN)
|
69
67
|
new_menu = Swt::Widgets::Menu.new(menu)
|
70
68
|
menu_header.menu = new_menu
|
71
69
|
menu_header.add_arm_listener do
|
@@ -75,10 +73,17 @@ module Redcar
|
|
75
73
|
elsif entry.is_a?(Redcar::Menu)
|
76
74
|
menu_header = Swt::Widgets::MenuItem.new(menu, Swt::SWT::CASCADE)
|
77
75
|
menu_header.text = entry.text
|
78
|
-
#new_menu = Swt::Widgets::Menu.new(@window.shell, Swt::SWT::DROP_DOWN)
|
79
76
|
new_menu = Swt::Widgets::Menu.new(menu)
|
80
77
|
menu_header.menu = new_menu
|
78
|
+
menu_header.enabled = (entry.length > 0)
|
81
79
|
add_entries_to_menu(new_menu, entry)
|
80
|
+
menu_header.add_arm_listener do
|
81
|
+
entry.entries.zip(new_menu.get_items) do |sub_entry, swt_item|
|
82
|
+
if sub_entry.lazy_text?
|
83
|
+
swt_item.text = sub_entry.text
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
82
87
|
elsif entry.is_a?(Redcar::Menu::Item::Separator)
|
83
88
|
item = Swt::Widgets::MenuItem.new(menu, Swt::SWT::SEPARATOR)
|
84
89
|
elsif entry.is_a?(Redcar::Menu::Item)
|
@@ -19,8 +19,11 @@ module Redcar
|
|
19
19
|
@item.dispose
|
20
20
|
end
|
21
21
|
@item = Swt::Custom::CTabItem.new(notebook.tab_folder, Swt::SWT::CLOSE, position)
|
22
|
-
@icon
|
23
|
-
|
22
|
+
set_icon(@model.icon)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_icon(icon)
|
26
|
+
@item.image = @icon = ApplicationSWT::Icon.swt_image(icon)
|
24
27
|
end
|
25
28
|
|
26
29
|
def create_tab_widget
|
@@ -66,6 +69,7 @@ module Redcar
|
|
66
69
|
@model.add_listener(:focus, &method(:focus))
|
67
70
|
@model.add_listener(:close, &method(:close))
|
68
71
|
@model.add_listener(:moved, &method(:move_tab_widget_to_position))
|
72
|
+
@model.add_listener(:changed_icon, &method(:set_icon))
|
69
73
|
end
|
70
74
|
|
71
75
|
def focus
|
@@ -74,7 +78,6 @@ module Redcar
|
|
74
78
|
|
75
79
|
def close
|
76
80
|
@item.dispose
|
77
|
-
@icon.dispose
|
78
81
|
end
|
79
82
|
end
|
80
83
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
+
require 'swt/vtab_folder'
|
2
|
+
require 'swt/vtab_item'
|
3
|
+
|
1
4
|
module Redcar
|
2
5
|
class ApplicationSWT
|
3
6
|
class Treebook
|
4
|
-
|
7
|
+
attr_reader :tab_folder
|
8
|
+
|
5
9
|
def initialize(window, model)
|
6
10
|
@window, @model = window, model
|
7
11
|
add_listeners
|
8
12
|
create_tree_view
|
9
13
|
end
|
10
|
-
|
14
|
+
|
11
15
|
def add_listeners
|
12
16
|
@model.add_listener(:tree_added, &method(:tree_added))
|
13
17
|
@model.add_listener(:tree_removed, &method(:tree_removed))
|
@@ -15,46 +19,40 @@ module Redcar
|
|
15
19
|
end
|
16
20
|
|
17
21
|
def tree_added(tree)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@
|
23
|
-
@tree_layout.topControl = tree_view.control
|
24
|
-
@tree_composite.layout
|
22
|
+
i = Swt::Widgets::VTabItem.new(@tab_folder, Swt::SWT::NULL)
|
23
|
+
i.text = tree.tree_mirror.title
|
24
|
+
i.control = TreeViewSWT.new(@tab_folder, tree)
|
25
|
+
tree.controller = i.control
|
26
|
+
@tab_folder.silent_selection(i)
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
def tree_removed(tree)
|
28
30
|
tree.controller.close
|
29
|
-
@
|
31
|
+
@tab_folder.remove_item(@tab_folder.get_item(tree.tree_mirror.title))
|
30
32
|
end
|
31
|
-
|
33
|
+
|
32
34
|
def tree_focussed(tree)
|
33
|
-
|
34
|
-
@
|
35
|
-
@tree_combo.select(@tree_combo.get_items.to_a.index(tree.tree_mirror.title))
|
35
|
+
item = @tab_folder.get_item(tree.tree_mirror.title)
|
36
|
+
@tab_folder.silent_selection(item)
|
36
37
|
end
|
37
38
|
|
38
39
|
def create_tree_view
|
39
|
-
@
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
selected_tree = @model.trees.detect {|t| t.tree_mirror.title == @tree_combo.text}
|
51
|
-
@model.focus_tree(selected_tree)
|
40
|
+
@tab_folder = Swt::Widgets::VTabFolder.new(@window.tree_sash, Swt::SWT::NONE)
|
41
|
+
colors = [ Swt::Graphics::Color.new(display, 230, 240, 255),
|
42
|
+
Swt::Graphics::Color.new(display, 170, 199, 246),
|
43
|
+
Swt::Graphics::Color.new(display, 135, 178, 247) ]
|
44
|
+
percents = [60, 85]
|
45
|
+
@tab_folder.set_selection_background(colors, percents, true)
|
46
|
+
|
47
|
+
@tab_folder.add_selection_listener do |event|
|
48
|
+
tab_item = event.item
|
49
|
+
tree_view_swt = tab_item.control
|
50
|
+
@model.focus_tree(tree_view_swt.model)
|
52
51
|
end
|
53
|
-
|
54
|
-
@
|
52
|
+
|
53
|
+
@tab_folder.layout
|
55
54
|
@window.left_composite.layout
|
56
55
|
end
|
57
|
-
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
module Swt
|
2
|
+
class GraphicsUtils
|
3
|
+
import org.eclipse.swt.SWT
|
4
|
+
import org.eclipse.swt.widgets.Display
|
5
|
+
import org.eclipse.swt.graphics.FontMetrics
|
6
|
+
import org.eclipse.swt.graphics.GC
|
7
|
+
import org.eclipse.swt.graphics.Image
|
8
|
+
import org.eclipse.swt.graphics.ImageData
|
9
|
+
import org.eclipse.swt.graphics.Point
|
10
|
+
import org.eclipse.swt.graphics.Rectangle
|
11
|
+
|
12
|
+
##
|
13
|
+
# Draws text vertically (rotates plus or minus 90 degrees). Uses the current
|
14
|
+
# font, color, and background.
|
15
|
+
# <dl>
|
16
|
+
# <dt><b>Styles: </b></dt>
|
17
|
+
# <dd>UP, DOWN</dd>
|
18
|
+
# </dl>
|
19
|
+
#
|
20
|
+
# @param string the text to draw
|
21
|
+
# @param x the x coordinate of the top left corner of the drawing rectangle
|
22
|
+
# @param y the y coordinate of the top left corner of the drawing rectangle
|
23
|
+
# @param gc the GC on which to draw the text
|
24
|
+
# @param style the style (SWT.UP or SWT.DOWN)
|
25
|
+
# <p>
|
26
|
+
# Note: Only one of the style UP or DOWN may be specified.
|
27
|
+
# </p>
|
28
|
+
#
|
29
|
+
def self.draw_vertical_text(string, x, y, gc, style)
|
30
|
+
display = Display.current
|
31
|
+
|
32
|
+
fm = gc.font_metrics
|
33
|
+
pt = gc.text_extent(string)
|
34
|
+
|
35
|
+
string_image = Image.new(display, pt.x, pt.y)
|
36
|
+
string_gc = GC.new(string_image)
|
37
|
+
|
38
|
+
string_gc.foreground = gc.foreground
|
39
|
+
string_gc.background = gc.background
|
40
|
+
string_gc.font = gc.font
|
41
|
+
string_gc.draw_text(string, 0, 0)
|
42
|
+
|
43
|
+
draw_vertical_image(string_image, x, y, gc, style)
|
44
|
+
|
45
|
+
string_gc.dispose
|
46
|
+
string_image.dispose
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Draws an image vertically (rotates plus or minus 90 degrees)
|
51
|
+
# <dl>
|
52
|
+
# <dt><b>Styles: </b></dt>
|
53
|
+
# <dd>UP, DOWN</dd>
|
54
|
+
# </dl>
|
55
|
+
#
|
56
|
+
# @param image the image to draw
|
57
|
+
# @param x the x coordinate of the top left corner of the drawing rectangle
|
58
|
+
# @param y the y coordinate of the top left corner of the drawing rectangle
|
59
|
+
# @param gc the GC on which to draw the image
|
60
|
+
# @param style the style (SWT.UP or SWT.DOWN)
|
61
|
+
# <p>
|
62
|
+
# Note: Only one of the style UP or DOWN may be specified.
|
63
|
+
# </p>
|
64
|
+
#
|
65
|
+
def self.draw_vertical_image(image, x, y, gc, style)
|
66
|
+
display = Display.current
|
67
|
+
|
68
|
+
sd = image.image_data
|
69
|
+
dd = ImageData.new(sd.height, sd.width, sd.depth, sd.palette)
|
70
|
+
up = (style == SWT::UP)
|
71
|
+
|
72
|
+
# Transform all pixels
|
73
|
+
sd.width.times do |sx|
|
74
|
+
sd.height.times do |sy|
|
75
|
+
dx = up ? sy : sd.height - sy - 1
|
76
|
+
dy = up ? sd.width - sx - 1 : sx
|
77
|
+
dd.set_pixel(dx, dy, sd.get_pixel(sx, sy))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
vertical = Image.new(display, dd)
|
82
|
+
gc.draw_image(vertical, x, y)
|
83
|
+
vertical.dispose
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Creates an image containing the specified text, rotated either plus or minus
|
88
|
+
# 90 degrees.
|
89
|
+
# <dl>
|
90
|
+
# <dt><b>Styles: </b></dt>
|
91
|
+
# <dd>UP, DOWN</dd>
|
92
|
+
# </dl>
|
93
|
+
#
|
94
|
+
# @param text the text to rotate
|
95
|
+
# @param font the font to use
|
96
|
+
# @param foreground the color or pattern for the text
|
97
|
+
# @param background the background color or pattern
|
98
|
+
# @param style direction to rotate (up or down)
|
99
|
+
# @param optional options hash for padding
|
100
|
+
# @return Image
|
101
|
+
# <p>
|
102
|
+
# Note: Only one of the style UP or DOWN may be specified.
|
103
|
+
# </p>
|
104
|
+
#
|
105
|
+
def self.create_rotated_text(text, font, foreground, background, style, options = {})
|
106
|
+
options = {:padding_x => 16, :padding_y => 4}.merge(options)
|
107
|
+
|
108
|
+
display = Display.current
|
109
|
+
|
110
|
+
gc = GC.new(display)
|
111
|
+
gc.font = font
|
112
|
+
|
113
|
+
fm = gc.font_metrics
|
114
|
+
pt = gc.text_extent(text)
|
115
|
+
extent = Rectangle.new(0, 0, pt.x + options[:padding_x], pt.y + options[:padding_y])
|
116
|
+
gc.dispose
|
117
|
+
|
118
|
+
string_image = Image.new(display, extent.width, extent.height)
|
119
|
+
|
120
|
+
gc = GC.new(string_image)
|
121
|
+
|
122
|
+
gc.font = font
|
123
|
+
gc.foreground = foreground
|
124
|
+
gc.background = background
|
125
|
+
|
126
|
+
# Do customization
|
127
|
+
yield(gc, extent) if block_given?
|
128
|
+
|
129
|
+
gc.draw_text(text, options[:padding_x] / 2, options[:padding_y] / 2, true)
|
130
|
+
|
131
|
+
image = create_rotated_image(string_image, style)
|
132
|
+
gc.dispose
|
133
|
+
string_image.dispose
|
134
|
+
return image
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Creates a rotated image (plus or minus 90 degrees)
|
139
|
+
# <dl>
|
140
|
+
# <dt><b>Styles: </b></dt>
|
141
|
+
# <dd>UP, DOWN</dd>
|
142
|
+
# </dl>
|
143
|
+
#
|
144
|
+
# @param image the image to rotate
|
145
|
+
# @param style direction to rotate (up or down)
|
146
|
+
# @return Image
|
147
|
+
# <p>
|
148
|
+
# Note: Only one of the style UP or DOWN may be specified.
|
149
|
+
# </p>
|
150
|
+
#
|
151
|
+
def self.create_rotated_image(image, style)
|
152
|
+
display = Display.current
|
153
|
+
|
154
|
+
sd = image.image_data
|
155
|
+
dd = ImageData.new(sd.height, sd.width, sd.depth, sd.palette)
|
156
|
+
|
157
|
+
up = (style == SWT::UP)
|
158
|
+
|
159
|
+
sd.width.times do |sx|
|
160
|
+
sd.height.times do |sy|
|
161
|
+
dx = up ? sy : sd.height - sy - 1
|
162
|
+
dy = up ? sd.width - sx - 1 : sx
|
163
|
+
dd.set_pixel(dx, dy, sd.get_pixel(sx, sy))
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
return Image.new(display, dd)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Swt
|
2
|
+
module Widgets
|
3
|
+
class VTabFolder < Swt::Widgets::Composite
|
4
|
+
attr_accessor :tab_area, :content_area
|
5
|
+
attr_reader :selection_color_options, :font, :items
|
6
|
+
|
7
|
+
SelectionEvent = Struct.new("Event", :item, :doit)
|
8
|
+
|
9
|
+
def initialize(parent, style)
|
10
|
+
super(parent, style | Swt::SWT::BORDER)
|
11
|
+
self.layout = Swt::Layout::GridLayout.new(2, false).tap do |l|
|
12
|
+
l.horizontalSpacing = -1
|
13
|
+
l.verticalSpacing = -1
|
14
|
+
l.marginHeight = -1
|
15
|
+
l.marginWidth = -1
|
16
|
+
end
|
17
|
+
|
18
|
+
@items = []
|
19
|
+
@selection_listeners = []
|
20
|
+
@font = Swt::Widgets::Display.current.system_font
|
21
|
+
|
22
|
+
@tab_area = Swt::Widgets::Composite.new(self, Swt::SWT::NONE).tap do |t|
|
23
|
+
t.layout_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_VERTICAL | Swt::Layout::GridData::GRAB_VERTICAL)
|
24
|
+
t.layout = Swt::Layout::RowLayout.new.tap do |l|
|
25
|
+
l.type = Swt::SWT::VERTICAL
|
26
|
+
l.spacing = -1
|
27
|
+
l.wrap = false
|
28
|
+
l.marginLeft = 0
|
29
|
+
l.marginRight = 0
|
30
|
+
l.marginTop = 0
|
31
|
+
l.marginBottom = 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_selection_background(colors, percents, vertical = true)
|
37
|
+
@selection_color_options = { :colors => colors,
|
38
|
+
:percents => percents.collect { |i| i / 100.0 },
|
39
|
+
:vertical => vertical }
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_item(tab)
|
43
|
+
@items << tab
|
44
|
+
tab.draw_label(@tab_area)
|
45
|
+
tab.font = @font
|
46
|
+
tab.active = true if @items.size == 1
|
47
|
+
layout
|
48
|
+
end
|
49
|
+
|
50
|
+
def remove_item(tab)
|
51
|
+
@items.delete(tab)
|
52
|
+
tab.dispose
|
53
|
+
selection = @items.first if tab.active?
|
54
|
+
layout
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_item(selector)
|
58
|
+
return @items[selector] if selector.respond_to? :to_int
|
59
|
+
return @items.detect { |i| i.text == selector } if selector.respond_to? :to_str
|
60
|
+
raise NotImplementedError, "Getting via Point not implemented"
|
61
|
+
end
|
62
|
+
|
63
|
+
def item_count
|
64
|
+
@items.size
|
65
|
+
end
|
66
|
+
|
67
|
+
def selection
|
68
|
+
@items.detect { |x| x.active? }
|
69
|
+
end
|
70
|
+
|
71
|
+
def selection=(tab)
|
72
|
+
return if tab.nil?
|
73
|
+
evt = SelectionEvent.new.tap do |e|
|
74
|
+
e.item = tab
|
75
|
+
e.doit = true
|
76
|
+
end
|
77
|
+
@selection_listeners.each do |l|
|
78
|
+
if l.respond_to? :call
|
79
|
+
l[evt]
|
80
|
+
else
|
81
|
+
l.widgetSelected(evt)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
if evt.doit
|
85
|
+
silent_selection(tab)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def silent_selection(tab)
|
90
|
+
return if tab.nil?
|
91
|
+
selection.active = false if selection
|
92
|
+
if tab.respond_to? :to_int
|
93
|
+
@items[tab].active = true
|
94
|
+
else
|
95
|
+
tab.active = true
|
96
|
+
end
|
97
|
+
layout
|
98
|
+
@tab_area.layout
|
99
|
+
end
|
100
|
+
|
101
|
+
def selection_index
|
102
|
+
index_of(selection)
|
103
|
+
end
|
104
|
+
|
105
|
+
def index_of(tab)
|
106
|
+
@items.index(tab)
|
107
|
+
end
|
108
|
+
|
109
|
+
def show_item(tab)
|
110
|
+
selection = tab
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_selection_listener(listener = nil)
|
114
|
+
return @selection_listeners << listener if listener
|
115
|
+
raise ArgumentError, "Expected a listener or a block" unless block_given?
|
116
|
+
@selection_listeners << Proc.new
|
117
|
+
end
|
118
|
+
|
119
|
+
def font= swt_font
|
120
|
+
@font = swt_font
|
121
|
+
@items.each { |tab| tab.font = swt_font }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|