Class: AastraXmlApi::PhoneImageMenu
- Defined in:
- lib/aastra_xml_api/phone_image_menu.rb
Constant Summary
Constants inherited from Phone
AastraXmlApi::Phone::HIGHASCII
Instance Method Summary collapse
-
#addURI(key, uri) ⇒ Object
Adds a URI and key pair that is associated with the given key pressed by the user.
-
#render ⇒ Object
Create XML text output.
-
#setAlignment(vertical = nil, horizontal = nil) ⇒ Object
Sets the alignment of the image.
-
#setGDImage(gdImage) ⇒ Object
Sets the image based on an externally generated GD image.
-
#setImage(image) ⇒ Object
Sets the image to be displayed.
-
#setSize(height, width) ⇒ Object
Sets the size of the image to be displayed which must match the actual images height and width.
-
#setURIBase(uriBase) ⇒ Object
Sets the base URI that is prepended to the URI for a specific key.
Methods inherited from Phone
#addIcon, #addSoftkey, #convert_high_ascii, #escape, #getRefreshTimeout, #getRefreshURL, #initialize, #setAllowAnswer, #setBeep, #setCancelAction, #setDestroyOnExit, #setLockIn, #setRefresh, #setTimeout, #setTitle, #setTitleWrap
Constructor Details
This class inherits a constructor from AastraXmlApi::Phone
Instance Method Details
#addURI(key, uri) ⇒ Object
Adds a URI and key pair that is associated with the given key pressed by the user. The full URI is the one set by setURIBase followed by this uri.
80 81 82 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 80 def addURI(key, uri) @entries += [PhoneImageMenuEntry.new(key, uri)] end |
#render ⇒ Object
Create XML text output.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 108 def render title = escape(@title) out = "<AastraIPPhoneImageMenu" out += " destroyOnExit=\"yes\"" if @destroyOnExit == "yes" if not @cancelAction.nil? then cancelAction = escape(@cancelAction) out += " cancelAction=\"#{cancelAction}\"" end out += " Beep=\"yes\"" if @beep == "yes" out += " LockIn=\"yes\"" if @locking == "yes" out += " Timeout=\"#{@timeout}\"" if @timeout != 0 out += ">\n" out += "<Image" out += " verticalAlign=\"#{@verticalAlign}\"" if not @verticalAlign.nil? out += " horizontalAlign=\"#{@horizontalAlign}\"" if not @horizontalAlign.nil? out += " height=\"#{@height}\"" if not @height.nil? out += " width=\"#{@width}\"" if not @width.nil? out += ">#{@image}</Image>\n" out += "<URIList" out += " base=\"#{escape(@uriBase)}\"" if not @uriBase.nil? out += ">\n" @entries.each { |entry| out += entry.render } out += "</URIList>\n" @softkeys.each { |softkey| out += softkey.render } iconList = 0 @icons.each do |icon| if iconList == 0 out += "<IconList>\n" iconList = 1 end out += icon.render end out += "</IconList>\n" if iconList != 0 out += "</AastraIPPhoneImageMenu>\n" return out end |
#setAlignment(vertical = nil, horizontal = nil) ⇒ Object
Sets the alignment of the image. veritcal is one of ‘top’, ‘middle’ (default), or ‘bottom’. horizontal is one of ‘left’, ‘middle’ (default), or ‘right’.
60 61 62 63 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 60 def setAlignment(vertical=nil, horizontal=nil) @verticalAlign = vertical @horizontalAlign = horizontal end |
#setGDImage(gdImage) ⇒ Object
Sets the image based on an externally generated GD image. Image must be 40x144 in size and should be created using PhoneGDImage.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 86 def setGDImage(gdImage) img = gdImage.getGDImage byte = 0 i = 0 imageHexString = "" for x in 0..143 for y in 0..39 rgb = img.getPixel(x, y) byte += 2**(7-(i%8)) if rgb > 0 if (i%8) == 7 then byteHex ="%02x" % byte imageHexString += byteHex byte = 0 end i += 1 end end setImage(imageHexString) setSize(40,144) end |
#setImage(image) ⇒ Object
Sets the image to be displayed. image must be a string of hex.
53 54 55 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 53 def setImage(image) @image = image end |
#setSize(height, width) ⇒ Object
Sets the size of the image to be displayed which must match the actual images height and width.
67 68 69 70 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 67 def setSize(height, width) @height = height @width = width end |
#setURIBase(uriBase) ⇒ Object
Sets the base URI that is prepended to the URI for a specific key.
73 74 75 |
# File 'lib/aastra_xml_api/phone_image_menu.rb', line 73 def setURIBase(uriBase) @uriBase = uriBase end |