lustr-mxml 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ +++ 0.1.0 2007-05-23
2
+
3
+ + 1 major enhancement:
4
+ + Initial release
@@ -0,0 +1,18 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/lustr-mxml.rb
6
+ lib/lustr-mxml/version.rb
7
+ lib/lustr-mxml/_common.rb
8
+ lib/lustr-mxml/button.rb
9
+ lib/lustr-mxml/label.rb
10
+ lib/lustr-mxml/divided_box.rb
11
+ lib/lustr-mxml/list.rb
12
+ lib/lustr-mxml/field.rb
13
+ lib/lustr-mxml/text_area.rb
14
+ lib/lustr-mxml/box.rb
15
+ lib/lustr-mxml/app.rb
16
+ scripts/txt2html
17
+ setup.rb
18
+
@@ -0,0 +1,6 @@
1
+ Lustr is a Ruby DSL for GUI development. Lustr4MXML allows Lustr UIs to be
2
+ displayed via Flex/MXML.
3
+
4
+ More details on Lustr can be found at {Lustr's home page}[http://www.codecorps.org/moinmoin/index.cgi/Lustr]
5
+ or on the {RubyForge}[http://rubyforge.org/projects/lustr] site.
6
+
@@ -0,0 +1,93 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ include FileUtils
12
+ require File.join(File.dirname(__FILE__), 'lib', 'lustr-mxml', 'version')
13
+
14
+ AUTHOR = 'FIXME full name' # can also be an array of Authors
15
+ EMAIL = "FIXME email"
16
+ DESCRIPTION = "description of gem"
17
+ GEM_NAME = 'lustr-mxml' # what ppl will type to install your gem
18
+ RUBYFORGE_PROJECT = 'lustr' # The unix name for your project
19
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
21
+
22
+ NAME = "lustr-mxml"
23
+ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
24
+ VERS = Lustr4MXML::VERSION::STRING + (REV ? ".#{REV}" : "")
25
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
26
+ RDOC_OPTS = ['--quiet', '--title', 'lustr-mxml documentation',
27
+ "--opname", "index.html",
28
+ "--line-numbers",
29
+ "--main", "README",
30
+ "--inline-source"]
31
+
32
+ class Hoe
33
+ def extra_deps
34
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
35
+ end
36
+ end
37
+
38
+ # Generate all the Rake tasks
39
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
40
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
41
+ p.author = AUTHOR
42
+ p.description = DESCRIPTION
43
+ p.email = EMAIL
44
+ p.summary = DESCRIPTION
45
+ p.url = HOMEPATH
46
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
47
+ p.test_globs = ["test/**/test_*.rb"]
48
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
49
+
50
+ # == Optional
51
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
52
+ p.extra_deps = [['lustr-core', '>=0.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
53
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
54
+ end
55
+
56
+
57
+ desc 'Generate website files'
58
+ task :website_generate do
59
+ Dir['website/**/*.txt'].each do |txt|
60
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
61
+ end
62
+ end
63
+
64
+ desc 'Upload website files to rubyforge'
65
+ task :website_upload do
66
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
67
+ host = "#{config["username"]}@rubyforge.org"
68
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
69
+ # remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
+ local_dir = 'website'
71
+ sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
72
+ end
73
+
74
+ desc 'Generate and upload website files'
75
+ task :website => [:website_generate, :website_upload]
76
+
77
+ desc 'Release the website and new gem version'
78
+ task :deploy => [:check_version, :website, :release]
79
+
80
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
81
+ task :local_deploy => [:website_generate, :install_gem]
82
+
83
+ task :check_version do
84
+ unless ENV['VERSION']
85
+ puts 'Must pass a VERSION=x.y.z release version'
86
+ exit
87
+ end
88
+ unless ENV['VERSION'] == VERS
89
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
90
+ exit
91
+ end
92
+ end
93
+
@@ -0,0 +1,15 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ path=File::join(File::dirname(__FILE__), 'lustr-mxml')
15
+ Dir[path+'/*.rb'].sort.each {|f| require f}
@@ -0,0 +1,75 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+ require 'rubygems'
16
+ require 'builder'
17
+
18
+ module Lustr4MXML
19
+ class GenerationContext < Builder::XmlMarkup
20
+ def initialize(name)
21
+ super()
22
+ @name=name
23
+ @namespaces={'xmlns:mx'=>'http://www.adobe.com/2006/mxml',
24
+ 'xmlns:Lustr'=>'gadgets.*'}
25
+ @script_needed=true
26
+ end
27
+
28
+ def to_s
29
+ self.target!
30
+ end
31
+
32
+ def build_gadget_ref(gadget)
33
+ self.Lustr gadget.builder.name.to_sym, :id=>gadget.name
34
+ end
35
+
36
+ def net_attrs(raw={})
37
+ result=raw.reject {|key, value| value==nil || (value.kind_of?(String) && value.size==0)}
38
+
39
+ if @namespaces
40
+ result.merge!(@namespaces)
41
+ result.delete 'id'
42
+ end
43
+
44
+ @namespaces=nil
45
+
46
+ return result
47
+ end
48
+
49
+ def descend(widget)
50
+ if @script_needed
51
+ self.mx :Script, 'source'=>'_'+@name+'.as'
52
+ @script_needed=false
53
+ end
54
+
55
+ widget.children.each do |child|
56
+ child.generate(self)
57
+ end
58
+ end
59
+ end
60
+
61
+ class Generator < Lustr::Generator
62
+ def create_context(name)
63
+ GenerationContext.new name
64
+ end
65
+ end
66
+ end
67
+
68
+ module Lustr
69
+ class XmlBasedWidget
70
+ def action(bus_message)
71
+ return "#{bus_message}(event)" if bus_message
72
+ end
73
+ end
74
+ end
75
+
@@ -0,0 +1,38 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class AppWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ attrs=xml.net_attrs 'applicationComplete'=>action(option(:on_init)),
20
+ 'backgroundGradientColors'=>"[#ffffff, #c0c0c0]",
21
+ 'width'=>option(:width),
22
+ 'height'=>option(:height)
23
+
24
+ xml.mx :Application, attrs do
25
+ scripts=option(:scripts) || []
26
+
27
+ scripts.each do |script|
28
+ xml.mx :Script, 'source'=>script
29
+ end
30
+
31
+ xml.descend(self)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Lustr.declare(Lustr::SimpleBuilder.new(:app, Lustr4MXML::AppWidget))
38
+
@@ -0,0 +1,34 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class BoxWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ direction=(option(:direction)==:horizontal ? 'horizontal' : 'vertical')
20
+
21
+ xml.mx :Box, xml.net_attrs('id'=>option(:name), 'direction'=>direction,
22
+ 'label'=>option(:label),
23
+ 'width'=>option(:width),
24
+ 'height'=>option(:height),
25
+ 'horizontalAlign'=>option(:horizontal_align),
26
+ 'verticalAlign'=>option(:vertical_align)) do
27
+ xml.descend(self)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Lustr.declare(Lustr::SimpleBuilder.new(:box, Lustr4MXML::BoxWidget))
34
+
@@ -0,0 +1,29 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class ButtonWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ xml.mx :Button, xml.net_attrs('id'=>option(:name), 'label'=>option(:text),
20
+ 'click'=>action(option(:on_click)),
21
+ 'enabled'=>option(:enabled)) do
22
+ xml.descend(self)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ Lustr.declare(Lustr::SimpleBuilder.new(:button, Lustr4MXML::ButtonWidget))
29
+
@@ -0,0 +1,31 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class DividedBoxWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ direction=(option(:direction)==:horizontal ? 'horizontal' : 'vertical')
20
+
21
+ xml.mx :DividedBox, xml.net_attrs('id'=>option(:name), 'direction'=>direction,
22
+ 'width'=>option(:width),
23
+ 'height'=>option(:height)) do
24
+ xml.descend(self)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Lustr.declare(Lustr::SimpleBuilder.new(:divided_box, Lustr4MXML::DividedBoxWidget))
31
+
@@ -0,0 +1,31 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class FieldWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ xml.mx :TextInput, xml.net_attrs('id'=>option(:name),
20
+ 'width'=>option(:width),
21
+ 'height'=>option(:height),
22
+ 'displayAsPassword'=>option(:password),
23
+ 'change'=>action(option(:on_change))) do
24
+ xml.descend(self)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Lustr.declare(Lustr::SimpleBuilder.new(:field, Lustr4MXML::FieldWidget))
31
+
@@ -0,0 +1,36 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class LabelWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ xml.mx :Label, xml.net_attrs('id'=>option(:name), 'text'=>option(:text),
20
+ 'fontSize'=>option(:font_size),
21
+ 'fontWeight'=>fontWeight,
22
+ 'textAlign'=>option(:text_align),
23
+ 'selectable'=>true,
24
+ 'truncateToFit'=>true) do
25
+ xml.descend(self)
26
+ end
27
+ end
28
+
29
+ def fontWeight
30
+ return(option(:is_bold) ? 'bold' : 'normal')
31
+ end
32
+ end
33
+ end
34
+
35
+ Lustr.declare(Lustr::SimpleBuilder.new(:label, Lustr4MXML::LabelWidget))
36
+
@@ -0,0 +1,34 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Lustr is free software; you can redistribute it and/or modify it under the
5
+ terms of the GNU General Public License as published by the Free Software
6
+ Foundation; either version 2 of the License.
7
+
8
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
9
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ details. This file is included in the Ruby gem as License.txt.
12
+ =end
13
+
14
+ require 'lustr'
15
+
16
+ module Lustr4MXML
17
+ class ListWidget < Lustr::XmlBasedWidget
18
+ def generate(xml)
19
+ xml.mx :List, xml.net_attrs('id'=>option(:name), 'width'=>option(:width),
20
+ 'height'=>option(:height),
21
+ 'allowMultipleSelection'=>option(:allow_multiple_selection),
22
+ 'doubleClick'=>action(option(:double_click)),
23
+ 'doubleClickEnabled'=>option(:double_click_enabled),
24
+ 'change'=>action(option(:on_click)),
25
+ 'editable'=>option(:editable),
26
+ 'wordWrap'=>true) do
27
+ xml.descend(self)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Lustr.declare(Lustr::SimpleBuilder.new(:list, Lustr4MXML::ListWidget))
34
+