lib/sugarcube/symbol.rb in sugarcube-0.2.3 vs lib/sugarcube/symbol.rb in sugarcube-0.2.5
- old
+ new
@@ -32,10 +32,16 @@
attr_accessor :controlstates
attr_accessor :controlevents
attr_accessor :system_fonts
attr_accessor :font_sizes
attr_accessor :returnkeys
+ attr_accessor :activityindicator_styles
+ attr_accessor :tableview_styles
+ attr_accessor :statusbar_styles
+ attr_accessor :barmetrics
+ attr_accessor :barbuttomitems
+ attr_accessor :keyboardtypes
end
@devices = {
iphone: UIUserInterfaceIdiomPhone,
ipad: UIUserInterfaceIdiomPad,
@@ -135,14 +141,75 @@
yahoo: UIReturnKeyYahoo,
done: UIReturnKeyDone,
emergencycall: UIReturnKeyEmergencyCall,
}
+ @activityindicator_styles = {
+ large: UIActivityIndicatorViewStyleWhiteLarge,
+ whitelarge: UIActivityIndicatorViewStyleWhiteLarge,
+ white: UIActivityIndicatorViewStyleWhite,
+ gray: UIActivityIndicatorViewStyleGray,
+ }
+
+ @tableview_styles = {
+ plain: UITableViewStylePlain,
+ grouped: UITableViewStyleGrouped,
+ }
+
+ @statusbar_styles = {
+ default: UIStatusBarStyleDefault,
+ black: UIStatusBarStyleBlackOpaque,
+ translucent: UIStatusBarStyleBlackTranslucent,
+ }
+
+ @barmetrics = {
+ default: UIBarMetricsDefault,
+ landscape: UIBarMetricsLandscapePhone,
+ }
+
+ @barbuttomitems = {
+ done: UIBarButtonSystemItemDone,
+ cancel: UIBarButtonSystemItemCancel,
+ edit: UIBarButtonSystemItemEdit,
+ save: UIBarButtonSystemItemSave,
+ add: UIBarButtonSystemItemAdd,
+ flexiblespace: UIBarButtonSystemItemFlexibleSpace,
+ fixedspace: UIBarButtonSystemItemFixedSpace,
+ compose: UIBarButtonSystemItemCompose,
+ reply: UIBarButtonSystemItemReply,
+ action: UIBarButtonSystemItemAction,
+ organize: UIBarButtonSystemItemOrganize,
+ bookmarks: UIBarButtonSystemItemBookmarks,
+ search: UIBarButtonSystemItemSearch,
+ refresh: UIBarButtonSystemItemRefresh,
+ stop: UIBarButtonSystemItemStop,
+ camera: UIBarButtonSystemItemCamera,
+ trash: UIBarButtonSystemItemTrash,
+ play: UIBarButtonSystemItemPlay,
+ pause: UIBarButtonSystemItemPause,
+ rewind: UIBarButtonSystemItemRewind,
+ fastforward: UIBarButtonSystemItemFastForward,
+ undo: UIBarButtonSystemItemUndo,
+ redo: UIBarButtonSystemItemRedo,
+ pagecurl: UIBarButtonSystemItemPageCurl,
+ }
+
+ @keyboardtypes = {
+ default: UIKeyboardTypeDefault,
+ asciicapable: UIKeyboardTypeASCIICapable,
+ numbersandpunctuation: UIKeyboardTypeNumbersAndPunctuation,
+ url: UIKeyboardTypeURL,
+ numberpad: UIKeyboardTypeNumberPad,
+ phonepad: UIKeyboardTypePhonePad,
+ namephonepad: UIKeyboardTypeNamePhonePad,
+ emailaddress: UIKeyboardTypeEmailAddress,
+ }
+
private
def look_in(here)
return here[self] if here.has_key? self
- raise SugarNotFoundException.new(self)
+ raise SugarNotFoundException.new(self.inspect)
end
public
def uidevice
look_in(Symbol.devices)
@@ -169,41 +236,65 @@
end
def uicontrolstate
look_in(Symbol.controlstates)
end
+ alias :uistate :uicontrolstate
def uicontrolevent
look_in(Symbol.controlevents)
end
def uireturnkey
look_in(Symbol.returnkeys)
end
+ def uiactivityindicatorstyle
+ look_in(Symbol.activityindicator_styles)
+ end
+ alias :uiactivityindicatorviewstyle :uiactivityindicatorstyle
+
+ def uitablestyle
+ look_in(Symbol.tableview_styles)
+ end
+ alias :uitableviewstyle :uitablestyle
+
+ def uistatusbarstyle
+ look_in(Symbol.statusbar_styles)
+ end
+
+ def uibarmetrics
+ look_in(Symbol.barmetrics)
+ end
+
+ def uibarbuttonitem
+ look_in(Symbol.barbuttomitems)
+ end
+
+ def uikeyboardtype
+ look_in(Symbol.keyboardtypes)
+ end
+
def uifont(size=UIFont.systemFontSize)
# system fonts
- begin
+ if Symbol.system_fonts.has_key? self
font = look_in(Symbol.system_fonts)
if Symbol === size
size = Symbol.font_sizes.fetch(size).uifontsize
end
- return UIFont.send(font, size)
- rescue SugarNotFoundException
+ font = UIFont.send(font, size)
+ else
size = look_in(font_sizes).uifontsize
- return UIFont.systemFontOfSize(size)
+ font = UIFont.systemFontOfSize(size)
end
+ font
end
def uifontsize
size = look_in(Symbol.system_fonts)
if Symbol === size
return UIFont.send(Symbol.font_sizes[self])
end
return size.to_f
- end
-
- def to_teacup_stylesheet
- Teacup::Stylesheet[self]
end
end