class AastraXmlApi::PhoneImageMenu
Public Instance Methods
addURI(key, uri)
click to toggle source
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.
# File lib/aastra_xml_api/phone_image_menu.rb, line 80 def addURI(key, uri) @entries += [PhoneImageMenuEntry.new(key, uri)] end
render()
click to toggle source
Create XML text output.
# 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)
click to toggle source
Sets the alignment of the image. veritcal is one of ‘top’, ‘middle’ (default), or ‘bottom’. horizontal is one of ‘left’, ‘middle’ (default), or ‘right’.
# File lib/aastra_xml_api/phone_image_menu.rb, line 60 def setAlignment(vertical=nil, horizontal=nil) @verticalAlign = vertical @horizontalAlign = horizontal end
setGDImage(gdImage)
click to toggle source
Sets the image based on an externally generated GD image. Image must be 40x144 in size and should be created using PhoneGDImage
.
# 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)
click to toggle source
Sets the image to be displayed. image must be a string of hex.
# File lib/aastra_xml_api/phone_image_menu.rb, line 53 def setImage(image) @image = image end
setSize(height, width)
click to toggle source
Sets the size of the image to be displayed which must match the actual images height and width.
# File lib/aastra_xml_api/phone_image_menu.rb, line 67 def setSize(height, width) @height = height @width = width end
setURIBase(uriBase)
click to toggle source
Sets the base URI that is prepended to the URI for a specific key.
# File lib/aastra_xml_api/phone_image_menu.rb, line 73 def setURIBase(uriBase) @uriBase = uriBase end