UpDownButton.st
changeset 340 c02e5db9b6f5
parent 338 d779aad63356
child 577 fe0313b081bc
equal deleted inserted replaced
339:1614b7fe9867 340:c02e5db9b6f5
     1 SimpleView subclass:#UpDownButton
     1 SimpleView subclass:#UpDownButton
     2 	instanceVariableNames:'upButton downButton'
     2 	instanceVariableNames:'orientation upButton downButton'
     3 	classVariableNames:''
     3 	classVariableNames:''
     4 	poolDictionaries:''
     4 	poolDictionaries:''
     5 	category:'Views-Interactors'
     5 	category:'Views-Interactors'
     6 !
     6 !
     7 
     7 
    27 
    27 
    28      top := StandardSystemView new.
    28      top := StandardSystemView new.
    29      top extent:(300 @ 200).
    29      top extent:(300 @ 200).
    30 
    30 
    31      ud := UpDownButton in:top.
    31      ud := UpDownButton in:top.
       
    32      ud origin:(10 @ 10).
       
    33 
       
    34      ud upAction:[Transcript showCR:'up'].
       
    35      ud downAction:[Transcript showCR:'down'].
       
    36      top open.
       
    37                                                                 [exEnd]
       
    38 
       
    39                                                                 [exBegin]
       
    40      |top ud|
       
    41 
       
    42      top := StandardSystemView new.
       
    43      top extent:(300 @ 200).
       
    44 
       
    45      ud := UpDownButton in:top.
       
    46      ud orientation:#horizontal.
    32      ud origin:(10 @ 10).
    47      ud origin:(10 @ 10).
    33 
    48 
    34      ud upAction:[Transcript showCR:'up'].
    49      ud upAction:[Transcript showCR:'up'].
    35      ud downAction:[Transcript showCR:'down'].
    50      ud downAction:[Transcript showCR:'down'].
    36      top open.
    51      top open.
    73 
    88 
    74     "Created: 1.4.1997 / 11:53:39 / cg"
    89     "Created: 1.4.1997 / 11:53:39 / cg"
    75     "Modified: 1.4.1997 / 11:54:17 / cg"
    90     "Modified: 1.4.1997 / 11:54:17 / cg"
    76 !
    91 !
    77 
    92 
       
    93 leftButtonForm
       
    94     "return the left-buttons image"
       
    95 
       
    96     <resource: #style (#upDownButtonLeftForm #upDownButtonLeftFormFile)>
       
    97 
       
    98     |fileName form|
       
    99 
       
   100     form := StyleSheet at:'upDownButtonLeftForm' default:nil.
       
   101     form isNil ifTrue:[
       
   102         fileName := StyleSheet at:'upDownButtonLeftFormFile' default:'ComboLtB_win.xbm'.
       
   103         form := Image fromFile:fileName.
       
   104     ].
       
   105     form isNil ifTrue:[
       
   106         form  := Form width:7 height:16 
       
   107                       fromArray:#[
       
   108                                   2r00000000
       
   109                                   2r00000000
       
   110                                   2r00000100
       
   111                                   2r00001100
       
   112                                   2r00011100
       
   113                                   2r00111100
       
   114                                   2r01111100
       
   115                                   2r11111100
       
   116                                   2r11111100
       
   117                                   2r01111100
       
   118                                   2r00111100
       
   119                                   2r00011100
       
   120                                   2r00001100
       
   121                                   2r00000100
       
   122                                   2r00000000
       
   123                                   2r00000000
       
   124                                  ]
       
   125                       on:Display.
       
   126     ].
       
   127     form notNil ifTrue:[
       
   128         ^ form on:Display
       
   129     ].
       
   130     ^ nil
       
   131 
       
   132     "Created: 1.4.1997 / 12:39:18 / cg"
       
   133     "Modified: 1.4.1997 / 12:45:58 / cg"
       
   134 !
       
   135 
       
   136 rightButtonForm
       
   137     "return the left-buttons image"
       
   138 
       
   139     <resource: #style (#upDownButtonRightForm #upDownButtonRightFormFile)>
       
   140 
       
   141     |fileName form|
       
   142 
       
   143     form := StyleSheet at:'upDownButtonRightForm' default:nil.
       
   144     form isNil ifTrue:[
       
   145         fileName := StyleSheet at:'upDownButtonRightFormFile' default:'ComboRtB_win.xbm'.
       
   146         form := Image fromFile:fileName.
       
   147     ].
       
   148     form isNil ifTrue:[
       
   149         form  := Form width:7 height:16 
       
   150                       fromArray:#[
       
   151                                   2r00000000
       
   152                                   2r00000000
       
   153                                   2r01000000
       
   154                                   2r01100000
       
   155                                   2r01110000
       
   156                                   2r01111000
       
   157                                   2r01111100
       
   158                                   2r01111110
       
   159                                   2r01111110
       
   160                                   2r01111100
       
   161                                   2r01111000
       
   162                                   2r01110000
       
   163                                   2r01100000
       
   164                                   2r01000000
       
   165                                   2r00000000
       
   166                                   2r00000000
       
   167                                  ]
       
   168                       on:Display.
       
   169     ].
       
   170     form notNil ifTrue:[
       
   171         ^ form on:Display
       
   172     ].
       
   173     ^ nil
       
   174 
       
   175     "Modified: 1.4.1997 / 11:54:17 / cg"
       
   176     "Created: 1.4.1997 / 12:39:34 / cg"
       
   177 !
       
   178 
    78 upButtonForm
   179 upButtonForm
    79     "return the up-buttons image"
   180     "return the up-buttons image"
    80 
   181 
    81     <resource: #style (#upDownButtonUpForm #upDownButtonUpFormFile)>
   182     <resource: #style (#upDownButtonUpForm #upDownButtonUpFormFile)>
    82 
   183 
   136 
   237 
   137     "Created: 1.4.1997 / 11:55:52 / cg"
   238     "Created: 1.4.1997 / 11:55:52 / cg"
   138     "Modified: 1.4.1997 / 11:56:02 / cg"
   239     "Modified: 1.4.1997 / 11:56:02 / cg"
   139 ! !
   240 ! !
   140 
   241 
       
   242 !UpDownButton methodsFor:'accessing-look'!
       
   243 
       
   244 orientation
       
   245     ^ orientation
       
   246 
       
   247     "Created: 1.4.1997 / 12:42:01 / cg"
       
   248 !
       
   249 
       
   250 orientation:aSymbol
       
   251     orientation := aSymbol.
       
   252     self initializeButtonDimensions
       
   253 
       
   254     "Created: 1.4.1997 / 12:42:17 / cg"
       
   255     "Modified: 1.4.1997 / 12:42:29 / cg"
       
   256 ! !
       
   257 
   141 !UpDownButton methodsFor:'initialization'!
   258 !UpDownButton methodsFor:'initialization'!
   142 
   259 
   143 initialize
   260 initialize
       
   261     orientation := #vertical.
       
   262 
   144     super initialize.
   263     super initialize.
   145     self initializeButtons
   264     self initializeButtons
   146 
   265 
   147     "Created: 1.4.1997 / 11:58:07 / cg"
   266     "Created: 1.4.1997 / 11:58:07 / cg"
       
   267     "Modified: 1.4.1997 / 12:47:58 / cg"
       
   268 !
       
   269 
       
   270 initializeButtonDimensions
       
   271     orientation == #vertical ifTrue:[
       
   272         upButton label:(self class upButtonForm).
       
   273         downButton label:(self class downButtonForm).
       
   274 
       
   275         upButton origin:0@0.
       
   276         downButton origin:(0 @ upButton preferredExtent y).
       
   277 
       
   278         self preferredExtent:(upButton preferredExtent x
       
   279                               @
       
   280                               (upButton preferredExtent y 
       
   281                               +
       
   282                               downButton preferredExtent y)).
       
   283     ] ifFalse:[
       
   284         upButton label:(self class rightButtonForm).
       
   285         downButton label:(self class leftButtonForm).
       
   286 
       
   287         downButton origin:0@0.
       
   288         upButton origin:(downButton preferredExtent x @ 0).
       
   289 
       
   290         self preferredExtent:((upButton preferredExtent x
       
   291                               +
       
   292                               downButton preferredExtent x)
       
   293                               @
       
   294                               upButton preferredExtent y).
       
   295     ].
       
   296 
       
   297     "Modified: 1.4.1997 / 12:47:38 / cg"
   148 !
   298 !
   149 
   299 
   150 initializeButtons
   300 initializeButtons
   151     upButton := ArrowButton upIn:self.
   301     upButton := ArrowButton upIn:self.
   152     upButton label:(self class upButtonForm).
       
   153     upButton origin:0@0.
       
   154     upButton action:[self countUp].
   302     upButton action:[self countUp].
   155     upButton autoRepeat:true.
   303     upButton autoRepeat:true.
   156 
   304 
   157     downButton := ArrowButton downIn:self.
   305     downButton := ArrowButton downIn:self.
   158     downButton label:(self class downButtonForm).
       
   159     downButton origin:(0 @ upButton preferredExtent y).
       
   160     downButton action:[self countDown].
   306     downButton action:[self countDown].
   161     downButton autoRepeat:true.
   307     downButton autoRepeat:true.
   162 
   308 
   163     self preferredExtent:(upButton preferredExtent x
   309     self initializeButtonDimensions
   164                           @
   310 
   165                           (upButton preferredExtent y 
   311     "Modified: 1.4.1997 / 12:42:58 / cg"
   166                           +
       
   167                           downButton preferredExtent y)).
       
   168 
       
   169     "Created: 1.4.1997 / 11:58:11 / cg"
       
   170     "Modified: 1.4.1997 / 11:58:43 / cg"
       
   171 ! !
   312 ! !
   172 
   313 
   173 !UpDownButton class methodsFor:'documentation'!
   314 !UpDownButton class methodsFor:'documentation'!
   174 
   315 
   175 version
   316 version
   176     ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.1 1997-04-01 10:03:05 cg Exp $'
   317     ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.2 1997-04-01 10:48:24 cg Exp $'
   177 ! !
   318 ! !