wet-winobj 0.1-mswin32

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,41 @@
1
+ require 'singleton'
2
+ require 'timeout'
3
+ require 'win32ole'
4
+
5
+ require 'dl/import'
6
+ require 'dl/struct'
7
+ require 'Win32API'
8
+
9
+ require 'soap/property'
10
+
11
+ require 'wet/constants/process.rb'
12
+ require 'wet/exceptions/CompileExceptions.rb'
13
+ require 'wet/utils/FileUtils.rb'
14
+ require 'wet/utils/TextUtils.rb'
15
+ require 'wet/utils/ArrayUtils.rb'
16
+ require 'wet/utils/CompileUtils.rb'
17
+ require 'wet/winobjects/WinUtils'
18
+ require 'wet/winobjects/WinObjects.rb'
19
+ require 'wet/winobjects/Window'
20
+ require 'wet/winobjects/AppWindow'
21
+ require 'wet/winobjects/WinButton'
22
+ require 'wet/winobjects/WinEdit'
23
+ require 'wet/winobjects/WinComboBox'
24
+ require 'wet/winobjects/WinDialog'
25
+
26
+ include Wet::WinUtils
27
+
28
+ =begin rdoc
29
+ This is the main interface to the outside
30
+ world. This module has factory methods which
31
+ masquerades the creation of object instances, yet
32
+ providing developers an object based API for handling
33
+ windows.
34
+ =end
35
+ module Wet
36
+ module Winobjects
37
+ def app_window(props)
38
+ AppWindow.find(props)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,10 @@
1
+ module Wet
2
+ module Winobjects
3
+ #Process control constants:
4
+
5
+ # Should the script be executed in a separate process ?
6
+ INPROCESS = 11
7
+ OUTOFPROCESS = 12
8
+
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ Object_timeout = 10
@@ -0,0 +1,73 @@
1
+ require 'wet/constants/wincontrolconst.rb'
2
+
3
+ BTN_CLASS = "Button"
4
+ WM_SETTEXT = 0x000C
5
+ WM_GETTEXT = 0x000D
6
+
7
+ SW_SHOWNORMAL = 1
8
+ SW_MAXIMIZE = 3
9
+ SW_MINIMIZE = 6
10
+
11
+ ## GetWindows Constants
12
+ GW_HWNDFIRST = 0
13
+ GW_HWNDLAST = 1
14
+ GW_HWNDNEXT = 2
15
+ GW_HWNDPREV = 3
16
+ GW_OWNER = 4
17
+ GW_CHILD = 5
18
+ GW_ENABLEDPOPUP = 6
19
+ GW_MAX = 6
20
+
21
+ GWL_EXSTYLE = -20
22
+ GWL_STYLE = -16
23
+
24
+
25
+ ## Window Style constants
26
+ WS_OVERLAPPED = 0x00000000
27
+ WS_POPUP = 0x80000000
28
+ WS_CHILD = 0x40000000
29
+ WS_MINIMIZE = 0x20000000
30
+ WS_VISIBLE = 0x10000000
31
+ WS_DISABLED = 0x08000000
32
+ WS_CLIPSIBLINGS = 0x04000000
33
+ WS_CLIPCHILDREN = 0x02000000
34
+ WS_MAXIMIZE = 0x01000000
35
+ WS_BORDER = 0x00800000
36
+ WS_DLGFRAME = 0x00400000
37
+ WS_VSCROLL = 0x00200000
38
+ WS_HSCROLL = 0x00100000
39
+ WS_SYSMENU = 0x00080000
40
+ WS_THICKFRAME = 0x00040000
41
+ WS_GROUP = 0x00020000
42
+ WS_TABSTOP = 0x00010000
43
+ WS_MINIMIZEBOX = 0x00020000
44
+ WS_MAXIMIZEBOX = 0x00010000
45
+
46
+ # Styles derived from other styles
47
+ WS_CAPTION = WS_BORDER | WS_DLGFRAME
48
+ WS_TILED = WS_OVERLAPPED
49
+ WS_ICONIC = WS_MINIMIZE
50
+ WS_SIZEBOX = WS_THICKFRAME
51
+ WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
52
+ WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
53
+
54
+ WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU
55
+ WS_CHILDWINDOW = WS_CHILD
56
+
57
+
58
+ #MOUSE actions
59
+ WH_MOUSE_LL = 14
60
+ WM_MOUSEMOVE = 0x200
61
+ WM_LBUTTONDOWN = 0x201
62
+ WM_LBUTTONUP = 0x202
63
+ WM_LBUTTONDBLCLK = 0x203
64
+ WM_RBUTTONDOWN = 0x204
65
+ WM_RBUTTONUP = 0x205
66
+ WM_RBUTTONDBLCLK = 0x206
67
+ WM_MBUTTONDOWN = 0x207
68
+ WM_MBUTTONUP = 0x208
69
+ WM_MBUTTONDBLCLK = 0x209
70
+ WM_MOUSEWHEEL = 0x20A
71
+
72
+
73
+
@@ -0,0 +1,60 @@
1
+ #Button Constants
2
+ BS_PUSHBUTTON = 0
3
+ BS_DEFPUSHBUTTON = 1
4
+ BS_CHECKBOX = 2
5
+ BS_AUTOCHECKBOX = 3
6
+ BS_RADIOBUTTON = 4
7
+ BS_3STATE = 5
8
+ BS_AUTO3STATE = 6
9
+ BS_GROUPBOX = 7
10
+ BS_USERBUTTON = 8
11
+ BS_AUTORADIOBUTTON = 9
12
+ BS_OWNERDRAW = 11
13
+ BS_LEFTTEXT = 32
14
+ BS_TEXT = 0
15
+ BS_ICON = 64
16
+ BS_BITMAP = 128
17
+ BS_LEFT = 256
18
+ BS_RIGHT = 512
19
+ BS_CENTER = 768
20
+ BS_TOP = 1024
21
+ BS_BOTTOM = 2048
22
+ BS_VCENTER = 3072
23
+ BS_PUSHLIKE = 4096
24
+ BS_MULTILINE = 8192
25
+ BS_NOTIFY = 16384
26
+ BS_FLAT = 32768
27
+ BS_RIGHTBUTTON = BS_LEFTTEXT
28
+
29
+ #Button states
30
+ BST_UNCHECKED = 0
31
+ BST_CHECKED = 1
32
+ BST_INDETERMINATE = 2
33
+ BST_PUSHED = 4
34
+ BST_FOCUS = 8
35
+
36
+ #Button Messages
37
+ BM_GETCHECK = 240
38
+ BM_SETCHECK = 241
39
+ BM_GETSTATE = 242
40
+ BM_SETSTATE = 243
41
+ BM_SETSTYLE = 244
42
+ BM_CLICK = 245
43
+ BM_GETIMAGE = 246
44
+ BM_SETIMAGE = 247
45
+
46
+ #Edit constants
47
+ ES_LEFT = 0
48
+ ES_CENTER = 1
49
+ ES_RIGHT = 2
50
+ ES_MULTILINE = 4
51
+ ES_UPPERCASE = 8
52
+ ES_LOWERCASE = 16
53
+ ES_PASSWORD = 32
54
+ ES_AUTOVSCROLL = 64
55
+ ES_AUTOHSCROLL = 128
56
+ ES_NOHIDESEL = 256
57
+ ES_OEMCONVERT = 1024
58
+ ES_READONLY = 2048
59
+ ES_WANTRETURN = 4096
60
+ ES_NUMBER = 8192
@@ -0,0 +1,31 @@
1
+ =begin rdoc
2
+ If ruby were a compiled language these exceptions would have
3
+ shown up at compile time. This file has all the exceptions that should
4
+ be raised when wrong invocations are made
5
+ =end
6
+ module Wet
7
+ module Exceptions
8
+ =begin rdoc
9
+ Exception to be raised when a psuedo abstract method is not implemented in a base clase
10
+ =end
11
+ class AbstractMethodError < RuntimeError
12
+ def initialize(message="")
13
+ super(message)
14
+ end
15
+ end
16
+
17
+ =begin rdoc
18
+ If the argument class is not correct raise this exception
19
+ =end
20
+ class ArgumentTypeException < RuntimeError
21
+ def initialize(exp, actual)
22
+ msg = "Invalid argument type = #{exp.to_s} class expected. #{actual.to_s} class was passed"
23
+ super(msg)
24
+ end
25
+ end
26
+
27
+
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ =begin rdoc
2
+ If ruby were a compiled language these exceptions would have
3
+ shown up at compile time. This file has all the exceptions that should
4
+ be raised when wrong invocations are made
5
+ =end
6
+ module Wet
7
+ module Exceptions
8
+ =begin rdoc
9
+ Exception to be raised when a psuedo abstract method is not implemented in a base clase
10
+ =end
11
+ class UnsupportedOperationException < RuntimeError
12
+ def initialize(message="")
13
+ super(message)
14
+ end
15
+ end
16
+
17
+
18
+
19
+ end
20
+ end
@@ -0,0 +1,52 @@
1
+ =begin license
2
+ Copyright (c) 2005, Qantom Software
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ Neither the name of Qantom Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+
12
+ (based on BSD Open Source License)
13
+ =end
14
+
15
+
16
+ =begin rdoc
17
+ General utilties that are used in various places in the package.
18
+ =end
19
+ module Wet
20
+ module Utils
21
+
22
+
23
+ class ArrayUtils
24
+ =begin rdoc
25
+ Utility method to construct a dictionary of parameters using an array
26
+ of arguments. Typically, when you need to identify objects, you will
27
+ say, Object("name:=n1"; "id:=i1" ...). The idea is that all the arguments
28
+ have to be matched to declare success. This method takes a multiple
29
+ argument list and converts into a dictionary of name value parameters.
30
+ While processing the arguments, if any of the 'value' in the name-value
31
+ pair looks like a regular expression, then the dictionary's value is a
32
+ Regex instance instead of a string
33
+ =end
34
+ def ArrayUtils.get_parameters(args)
35
+ param_hash=Hash.new()
36
+ args.each do |a|
37
+ seperated_args = a.split(Param_separator, 2)
38
+ name = seperated_args[0]
39
+ value = seperated_args[1]
40
+ #If the value looks like a regexp, then make it one!
41
+ if /^\/.*\// =~ value
42
+ value = value.gsub("/", "")
43
+ value= Regexp.new(value)
44
+ end
45
+ param_hash[name]=value
46
+ end
47
+ return param_hash
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,43 @@
1
+ =begin license
2
+ Copyright (c) 2005, Qantom Software
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ Neither the name of Qantom Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+
12
+ (based on BSD Open Source License)
13
+ =end
14
+
15
+
16
+ require 'wet/exceptions/CompileExceptions'
17
+ =begin rdoc
18
+ General utilties that are used in various places in the package.
19
+ =end
20
+ module Wet
21
+ module Utils
22
+ include Wet::Exceptions
23
+
24
+ class CompileUtils
25
+ =begin rdoc
26
+ =end
27
+ def CompileUtils.assert_argument_types(exp, actual)
28
+ compare_results = false
29
+ #For now, dont do any verification for the type
30
+ #of args. sent to this method itself.
31
+ if exp.kind_of?(Class)
32
+ compare_results = exp == actual
33
+ else
34
+ raise ArgumentTypeException.new(Class, exp)
35
+ end
36
+ if !compare_results
37
+ raise ArgumentTypeException.new(exp, actual)
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,75 @@
1
+ =begin license
2
+ Copyright (c) 2005, Qantom Software
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ Neither the name of Qantom Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+
12
+ (based on BSD Open Source License)
13
+ =end
14
+
15
+
16
+ class Dir
17
+ def Dir.mk_all_dirs(path)
18
+ dirs = []
19
+ d_exists = File.exists?(path)
20
+ dirs << File.basename(path)
21
+ while !d_exists
22
+ path = File.dirname(path)
23
+ d_exists = File.exists?(path)
24
+ if !d_exists
25
+ dirs << File.basename(path)
26
+ end
27
+ sleep 0.2
28
+ end
29
+
30
+ dirs.reverse.each do |d|
31
+ path = path + "\\" + d
32
+ if !File.exists?(path)
33
+ Dir.mkdir(path)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+
40
+ =begin rdoc
41
+ General utilties that are used in various places in the package.
42
+ =end
43
+ module WET
44
+ module Utils
45
+
46
+ class FileUtils
47
+ =begin rdoc
48
+ Convert a path into an absolute path. Also if the incoming path is in
49
+ unix style ('/' as separator), converts it to dos style. If the second
50
+ optional parameter is specified as false, then '\' is not added to the
51
+ end of the path
52
+ =end
53
+ def FileUtils.full_path(path, isDir=true)
54
+ ret_path=path
55
+ if ret_path==nil || ret_path.strip() ==""
56
+ #
57
+ else
58
+ if ret_path.index(".") == 0
59
+ ret_path = File.expand_path(".") + "/" + ret_path
60
+ end
61
+ ret_path = ret_path.gsub("/" , "\\" )
62
+ if isDir
63
+ if ret_path.slice(-1,1) != "\\"
64
+ ret_path = ret_path + "\\"
65
+ end
66
+ end
67
+ end
68
+ return ret_path
69
+ end
70
+
71
+ end
72
+
73
+
74
+ end
75
+ end
@@ -0,0 +1,63 @@
1
+ =begin license
2
+ Copyright (c) 2005, Qantom Software
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ Neither the name of Qantom Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+
12
+ (based on BSD Open Source License)
13
+ =end
14
+
15
+
16
+
17
+ =begin rdoc
18
+ General utilties that are used in various places in the package.
19
+ =end
20
+ module Wet
21
+ module Utils
22
+
23
+ class TextUtils
24
+ =begin rdoc
25
+ Compare a string with another string or regular expression. If the second
26
+ argument is a string, then an exact match search is done. If the second
27
+ argument is a regular expression, then a regex match is done.
28
+
29
+ returns true if the two arguments match, false otherwise.
30
+ =end
31
+ def TextUtils.compare_text(str_cmp, str_or_regex)
32
+ compare_results = false
33
+ if str_or_regex.class.to_s == "Regexp"
34
+ compare_results = (str_or_regex =~ str_cmp) != nil
35
+ elsif str_cmp.class.to_s == "String"
36
+ compare_results = (str_cmp == str_or_regex)
37
+ end
38
+ return compare_results
39
+ end
40
+
41
+
42
+ =begin rdoc
43
+ Return a compact representation of the string. Usually used for
44
+ making a neat representation of long strings. The first argument is
45
+ the string to be compacted. The second argument is the maximum
46
+ number of characters to use in the returned value. If the string is
47
+ greater than <size>, then only the first <size> characters are displayed
48
+ and three dots are displayed after that.
49
+ =end
50
+ def TextUtils.compact(str_comp, size=10)
51
+ return nil if str_comp == nil
52
+ str_ret=
53
+ if str_comp.length > size
54
+ str_ret=str_comp.slice(0, size)
55
+ str_ret="#{str_ret}..."
56
+ else
57
+ str_ret=str_comp
58
+ end
59
+ return str_ret
60
+ end
61
+ end
62
+ end
63
+ end