Class: Symbol
- Inherits:
-
Object
- Object
- Symbol
- Defined in:
- lib/sugarcube/symbol.rb,
lib/sugarcube/defaults.rb,
lib/sugarcube/symbol/symbol_uicolor.rb
Overview
Adds some UI classes to the Symbol class. These methods are prefixed with ‘ui` to make their intent clear, and to provide a little bit of “namespacing”
# alignment
:left.uialignment => UITextAlignmentLeft
# uicolors
:black.uicolor => UIColor.blackColor
:darkturquoise.uicolor => UIColor.blackColor
# fonts
:system.uifont => UIFont.systemFontOfSize(UIFont.systemFontSize)
:label.uifont => UIFont.systemFontOfSize(UIFont.labelFontSize)
You can extend the defaults by adding entries:
Symbol.css_colors[:my_color] = 0x123456
Symbol.font_sizes[:big] = 40
:my_color.uicolor => UIColor
:big.uifont => UIFont
Class Attribute Summary collapse
-
.alignments ⇒ Object
Returns the value of attribute alignments.
-
.bordertypes ⇒ Object
Returns the value of attribute bordertypes.
-
.buttontypes ⇒ Object
Returns the value of attribute buttontypes.
-
.controlevents ⇒ Object
Returns the value of attribute controlevents.
-
.controlstates ⇒ Object
Returns the value of attribute controlstates.
-
.css_colors ⇒ Object
Returns the value of attribute css_colors.
-
.devices ⇒ Object
Returns the value of attribute devices.
-
.font_sizes ⇒ Object
Returns the value of attribute font_sizes.
-
.orientations ⇒ Object
Returns the value of attribute orientations.
-
.system_fonts ⇒ Object
Returns the value of attribute system_fonts.
-
.uicolors ⇒ Object
Returns the value of attribute uicolors.
Instance Method Summary collapse
- #get_default ⇒ Object
- #remove_default ⇒ Object
- #set_default(val) ⇒ Object
- #to_teacup_stylesheet ⇒ Object
- #uialignment ⇒ Object
- #uibordertype ⇒ Object
- #uibuttontype ⇒ Object
- #uicolor(alpha = nil) ⇒ Object
- #uicontrolevent ⇒ Object
- #uicontrolstate ⇒ Object
- #uidevice ⇒ Object
- #uifont(size = UIFont.systemFontSize) ⇒ Object
- #uifontsize ⇒ Object
- #uiorientation ⇒ Object
Class Attribute Details
.alignments ⇒ Object
Returns the value of attribute alignments.
28 29 30 |
# File 'lib/sugarcube/symbol.rb', line 28 def alignments @alignments end |
.bordertypes ⇒ Object
Returns the value of attribute bordertypes.
31 32 33 |
# File 'lib/sugarcube/symbol.rb', line 31 def bordertypes @bordertypes end |
.buttontypes ⇒ Object
Returns the value of attribute buttontypes.
30 31 32 |
# File 'lib/sugarcube/symbol.rb', line 30 def @buttontypes end |
.controlevents ⇒ Object
Returns the value of attribute controlevents.
33 34 35 |
# File 'lib/sugarcube/symbol.rb', line 33 def controlevents @controlevents end |
.controlstates ⇒ Object
Returns the value of attribute controlstates.
32 33 34 |
# File 'lib/sugarcube/symbol.rb', line 32 def controlstates @controlstates end |
.css_colors ⇒ Object
Returns the value of attribute css_colors.
4 5 6 |
# File 'lib/sugarcube/symbol/symbol_uicolor.rb', line 4 def css_colors @css_colors end |
.devices ⇒ Object
Returns the value of attribute devices.
27 28 29 |
# File 'lib/sugarcube/symbol.rb', line 27 def devices @devices end |
.font_sizes ⇒ Object
Returns the value of attribute font_sizes.
35 36 37 |
# File 'lib/sugarcube/symbol.rb', line 35 def font_sizes @font_sizes end |
.orientations ⇒ Object
Returns the value of attribute orientations.
29 30 31 |
# File 'lib/sugarcube/symbol.rb', line 29 def orientations @orientations end |
.system_fonts ⇒ Object
Returns the value of attribute system_fonts.
34 35 36 |
# File 'lib/sugarcube/symbol.rb', line 34 def system_fonts @system_fonts end |
.uicolors ⇒ Object
Returns the value of attribute uicolors.
3 4 5 |
# File 'lib/sugarcube/symbol/symbol_uicolor.rb', line 3 def uicolors @uicolors end |
Instance Method Details
#get_default ⇒ Object
3 4 5 |
# File 'lib/sugarcube/defaults.rb', line 3 def get_default NSUserDefaults.standardUserDefaults.objectForKey(self) end |
#remove_default ⇒ Object
11 12 13 |
# File 'lib/sugarcube/defaults.rb', line 11 def remove_default NSUserDefaults.standardUserDefaults.removeObjectForKey(self) end |
#set_default(val) ⇒ Object
7 8 9 |
# File 'lib/sugarcube/defaults.rb', line 7 def set_default val NSUserDefaults.standardUserDefaults.setObject(val, forKey:self) end |
#to_teacup_stylesheet ⇒ Object
186 187 188 |
# File 'lib/sugarcube/symbol.rb', line 186 def to_teacup_stylesheet Teacup::Stylesheet[self] end |
#uialignment ⇒ Object
140 141 142 |
# File 'lib/sugarcube/symbol.rb', line 140 def uialignment look_in(Symbol.alignments) end |
#uibordertype ⇒ Object
152 153 154 |
# File 'lib/sugarcube/symbol.rb', line 152 def uibordertype look_in(Symbol.bordertypes) end |
#uibuttontype ⇒ Object
148 149 150 |
# File 'lib/sugarcube/symbol.rb', line 148 def look_in(Symbol.) end |
#uicolor(alpha = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sugarcube/symbol/symbol_uicolor.rb', line 7 def uicolor(alpha=nil) begin # iOS colors color = UIColor.send(look_in(Symbol.uicolors)) if not alpha.nil? color = color.colorWithAlphaComponent(alpha.to_f) end rescue SugarNotFoundException # css colors color = look_in(Symbol.css_colors).uicolor(alpha) end color end |
#uicontrolevent ⇒ Object
160 161 162 |
# File 'lib/sugarcube/symbol.rb', line 160 def uicontrolevent look_in(Symbol.controlevents) end |
#uicontrolstate ⇒ Object
156 157 158 |
# File 'lib/sugarcube/symbol.rb', line 156 def uicontrolstate look_in(Symbol.controlstates) end |
#uidevice ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/sugarcube/symbol.rb', line 132 def uidevice look_in(Symbol.devices) if Symbol.devices[self] return Symbol.devices[self] end raise SugarNotFoundException.new(self) end |
#uifont(size = UIFont.systemFontSize) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/sugarcube/symbol.rb', line 164 def uifont(size=UIFont.systemFontSize) # system fonts begin font = look_in(Symbol.system_fonts) if Symbol === size size = Symbol.font_sizes.fetch(size).uifontsize end return UIFont.send(font, size) rescue SugarNotFoundException size = look_in(font_sizes).uifontsize return UIFont.systemFontOfSize(size) end end |
#uifontsize ⇒ Object
178 179 180 181 182 183 184 |
# File 'lib/sugarcube/symbol.rb', line 178 def uifontsize size = look_in(Symbol.system_fonts) if Symbol === size return UIFont.send(Symbol.font_sizes[self]) end return size.to_f end |
#uiorientation ⇒ Object
144 145 146 |
# File 'lib/sugarcube/symbol.rb', line 144 def uiorientation look_in(Symbol.orientations) end |