RadioButton.st
changeset 1384 e4acb2c5b10b
parent 1087 171cdcfe0274
child 1391 33fef737601f
equal deleted inserted replaced
1383:b6541bec0b4f 1384:e4acb2c5b10b
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 Toggle subclass:#RadioButton
    13 Toggle subclass:#RadioButton
    14 	instanceVariableNames:''
    14 	instanceVariableNames:'buttonStyle buttonOnLevel buttonOffLevel'
    15 	classVariableNames:''
    15 	classVariableNames:'DefaultButtonStyle DefaultActiveLevel DefaultPassiveLevel'
    16 	poolDictionaries:''
    16 	poolDictionaries:''
    17 	category:'Views-Interactors'
    17 	category:'Views-Interactors'
    18 !
    18 !
    19 
    19 
    20 !RadioButton class methodsFor:'documentation'!
    20 !RadioButton class methodsFor:'documentation'!
   139 
   139 
   140                                                                         [exEnd]
   140                                                                         [exEnd]
   141 "
   141 "
   142 ! !
   142 ! !
   143 
   143 
       
   144 !RadioButton class methodsFor:'defaults'!
       
   145 
       
   146 motifCheckBotForm
       
   147     ^ Form 
       
   148         width:15 
       
   149         height:15 
       
   150         fromArray:#[2r00000000 2r00000000
       
   151                     2r00000000 2r00000000
       
   152                     2r00000000 2r00000000
       
   153                     2r00000000 2r00000000
       
   154                     2r00000000 2r00000000
       
   155                     2r00000000 2r00000000
       
   156                     2r00000000 2r00000000
       
   157                     2r00000000 2r00001110
       
   158                     2r01110000 2r00011100
       
   159                     2r00111000 2r00111000
       
   160                     2r00011100 2r01110000
       
   161                     2r00001110 2r11100000
       
   162                     2r00000111 2r11000000
       
   163                     2r00000011 2r10000000
       
   164                     2r00000001 2r00000000
       
   165                    ]
       
   166 
       
   167     "Created: / 3.11.1997 / 12:06:45 / cg"
       
   168     "Modified: / 3.11.1997 / 12:10:50 / cg"
       
   169 !
       
   170 
       
   171 motifCheckTopForm
       
   172     ^ Form 
       
   173         width:15 
       
   174         height:15 
       
   175         fromArray:#[2r00000001 2r00000000
       
   176                     2r00000011 2r10000000
       
   177                     2r00000111 2r11000000
       
   178                     2r00001110 2r11100000
       
   179                     2r00011100 2r01110000
       
   180                     2r00111000 2r00111000
       
   181                     2r01110000 2r00011100
       
   182                     2r11100000 2r00000000
       
   183                     2r00000000 2r00000000
       
   184                     2r00000000 2r00000000
       
   185                     2r00000000 2r00000000
       
   186                     2r00000000 2r00000000
       
   187                     2r00000000 2r00000000
       
   188                     2r00000000 2r00000000
       
   189                     2r00000000 2r00000000
       
   190                    ]
       
   191 
       
   192     "Created: / 3.11.1997 / 12:06:45 / cg"
       
   193     "Modified: / 3.11.1997 / 12:11:03 / cg"
       
   194 !
       
   195 
       
   196 round3DCheckBotForm
       
   197     ^ Form 
       
   198         width:15 
       
   199         height:15 
       
   200         fromArray:#[2r00000000 2r00000000
       
   201                     2r00000000 2r00000000
       
   202                     2r00000000 2r00000000
       
   203                     2r00000000 2r00000000
       
   204                     2r00000000 2r00000000
       
   205                     2r00000000 2r00001100
       
   206                     2r00000000 2r00000110
       
   207                     2r00000000 2r00000110
       
   208                     2r00000000 2r00000110
       
   209                     2r00000000 2r00001100
       
   210                     2r00000000 2r00001100
       
   211                     2r00110000 2r00011000
       
   212                     2r00111100 2r01111000
       
   213                     2r00001111 2r11100000
       
   214                     2r00000011 2r10000000
       
   215                    ]
       
   216 
       
   217     "Modified: / 3.11.1997 / 13:32:17 / cg"
       
   218     "Created: / 3.11.1997 / 14:29:37 / cg"
       
   219 !
       
   220 
       
   221 round3DCheckTopForm
       
   222     ^ Form 
       
   223         width:15 
       
   224         height:15 
       
   225         fromArray:#[2r00000011 2r10000000
       
   226                     2r00001111 2r11100000
       
   227                     2r00111100 2r01111000
       
   228                     2r00110000 2r00011000
       
   229                     2r01100000 2r00001100
       
   230                     2r01100000 2r00001100
       
   231                     2r11000000 2r00000000
       
   232                     2r11000000 2r00000000
       
   233                     2r11000000 2r00000000
       
   234                     2r01100000 2r00000000
       
   235                     2r01100000 2r00000000
       
   236                     2r00000000 2r00000000
       
   237                     2r00000000 2r00000000
       
   238                     2r00000000 2r00000000
       
   239                     2r00000000 2r00000000
       
   240                    ]
       
   241 
       
   242     "Modified: / 3.11.1997 / 13:31:49 / cg"
       
   243     "Created: / 3.11.1997 / 14:29:45 / cg"
       
   244 !
       
   245 
       
   246 roundOffForm
       
   247     ^ Form 
       
   248         width:15 
       
   249         height:15 
       
   250         fromArray:#[2r00000011 2r10000000
       
   251                     2r00001111 2r11100000
       
   252                     2r00111100 2r01111000
       
   253                     2r00110000 2r00011000
       
   254                     2r01100000 2r00001100
       
   255                     2r01100000 2r00001100
       
   256                     2r11000000 2r00000110
       
   257                     2r11000000 2r00000110
       
   258                     2r11000000 2r00000110
       
   259                     2r01100000 2r00001100
       
   260                     2r01100000 2r00001100
       
   261                     2r00110000 2r00011000
       
   262                     2r00111100 2r01111000
       
   263                     2r00001111 2r11100000
       
   264                     2r00000011 2r10000000
       
   265                    ]
       
   266 
       
   267     "Created: / 3.11.1997 / 12:41:13 / cg"
       
   268     "Modified: / 3.11.1997 / 13:25:03 / cg"
       
   269 !
       
   270 
       
   271 roundOnForm
       
   272     ^ Form 
       
   273         width:15 
       
   274         height:15 
       
   275         fromArray:#[2r00000000 2r00000000
       
   276                     2r00000000 2r00000000
       
   277                     2r00000000 2r00000000
       
   278                     2r00000000 2r00000000
       
   279                     2r00000011 2r10000000
       
   280                     2r00000111 2r11000000
       
   281                     2r00001111 2r11100000
       
   282                     2r00001111 2r11100000
       
   283                     2r00001111 2r11100000
       
   284                     2r00000111 2r11000000
       
   285                     2r00000011 2r10000000
       
   286                     2r00000000 2r00000000
       
   287                     2r00000000 2r00000000
       
   288                     2r00000000 2r00000000
       
   289                     2r00000000 2r00000000
       
   290                    ]
       
   291 
       
   292     "Created: / 3.11.1997 / 12:41:17 / cg"
       
   293     "Modified: / 3.11.1997 / 14:10:59 / cg"
       
   294 !
       
   295 
       
   296 updateStyleCache
       
   297     |l|
       
   298 
       
   299     DefaultButtonStyle := StyleSheet at:'radioButton.style'.
       
   300     l := -1.
       
   301     DefaultButtonStyle == #round2D ifTrue:[l := 0].
       
   302     DefaultActiveLevel := StyleSheet at:'radioButton.activeLevel' default:l.
       
   303     DefaultButtonStyle == #motif ifTrue:[l := 1].
       
   304     DefaultPassiveLevel := StyleSheet at:'radioButton.passivelLevel' default:l.
       
   305 
       
   306     "
       
   307      self updateStyleCache
       
   308     "
       
   309 
       
   310     "Modified: / 3.11.1997 / 14:20:21 / cg"
       
   311 ! !
       
   312 
       
   313 !RadioButton methodsFor:'drawing'!
       
   314 
       
   315 drawToggleImage
       
   316     "drawing of the radio image is done here."
       
   317 
       
   318     |x y clrTop clrBot img1 img2 img imgOn threeD lvl|
       
   319 
       
   320     buttonStyle isNil ifTrue:[
       
   321         ^ super drawToggleImage
       
   322     ].
       
   323 
       
   324     threeD := true.
       
   325     buttonStyle == #motif ifTrue:[
       
   326         img1 := self class motifCheckTopForm onDevice:device.
       
   327         img2 := self class motifCheckBotForm onDevice:device.
       
   328     ] ifFalse:[
       
   329         buttonStyle == #round3D ifTrue:[
       
   330             img1 := self class round3DCheckTopForm onDevice:device.
       
   331             img2 := self class round3DCheckBotForm onDevice:device.
       
   332             buttonOnLevel == buttonOffLevel ifTrue:[
       
   333                 controller pressed ifTrue:[
       
   334                     imgOn := self class roundOnForm onDevice:device.
       
   335                 ]
       
   336             ].
       
   337         ] ifFalse:[
       
   338             img1 := self class roundOffForm onDevice:device.
       
   339             controller pressed ifTrue:[
       
   340                 imgOn := self class roundOnForm onDevice:device.
       
   341             ].
       
   342             threeD := false.
       
   343         ]
       
   344     ].
       
   345 
       
   346     x := hSpace + margin.
       
   347     y := (height - img1 height) // 2.
       
   348 
       
   349     threeD ifFalse:[
       
   350         self paint:fgColor.
       
   351         self displayForm:img1 x:x y:y.
       
   352         controller pressed ifTrue:[
       
   353             self paint:activeFgColor.
       
   354             self displayForm:imgOn x:x y:y
       
   355         ]
       
   356     ] ifTrue:[
       
   357         controller pressed ifTrue:[
       
   358             lvl := buttonOnLevel
       
   359         ] ifFalse:[
       
   360             lvl := buttonOffLevel.
       
   361         ].
       
   362         lvl < 0 ifTrue:[
       
   363             clrTop := shadowColor.
       
   364             clrBot := lightColor.
       
   365         ] ifFalse:[
       
   366             clrTop := lightColor.
       
   367             clrBot := shadowColor.
       
   368         ].
       
   369         self paint:clrTop.
       
   370         self displayForm:img1 x:x y:y.
       
   371         self paint:clrBot.
       
   372         self displayForm:img2 x:x y:y.
       
   373 
       
   374         controller pressed ifTrue:[
       
   375             imgOn notNil ifTrue:[
       
   376                 self paint:fgColor.
       
   377                 self displayForm:imgOn x:x y:y
       
   378             ]
       
   379         ]
       
   380     ]
       
   381 
       
   382     "Created: / 3.11.1997 / 12:16:30 / cg"
       
   383     "Modified: / 3.11.1997 / 14:46:41 / cg"
       
   384 ! !
       
   385 
   144 !RadioButton methodsFor:'initialization'!
   386 !RadioButton methodsFor:'initialization'!
   145 
   387 
   146 defaultControllerClass
   388 defaultControllerClass
   147     ^ RadioButtonController
   389     ^ RadioButtonController
       
   390 !
       
   391 
       
   392 initStyle
       
   393     buttonStyle := DefaultButtonStyle.
       
   394     super initStyle.
       
   395 
       
   396     buttonStyle isNil ifTrue:[
       
   397         showLamp := styleSheet at:'radioButton.showLamp' default:showLamp.
       
   398         ^ self
       
   399     ].
       
   400 
       
   401     showLamp := true.
       
   402     buttonOnLevel := DefaultActiveLevel.
       
   403     buttonOffLevel := DefaultPassiveLevel.
       
   404 
       
   405     onLevel := offLevel := 0.
       
   406     self level:0.
       
   407 
       
   408     (buttonStyle == #motif 
       
   409     or:[buttonStyle == #round3D]) ifTrue:[
       
   410         activeBgColor := bgColor. 
       
   411         activeFgColor := fgColor.
       
   412     ] ifFalse:[
       
   413         buttonStyle == #round2D ifTrue:[
       
   414             activeFgColor := fgColor.
       
   415             activeBgColor := bgColor.
       
   416         ]
       
   417     ]
       
   418 
       
   419     "Modified: / 3.11.1997 / 14:38:11 / cg"
       
   420 ! !
       
   421 
       
   422 !RadioButton methodsFor:'private'!
       
   423 
       
   424 lampImageHeight
       
   425     ^ 15
       
   426 
       
   427     "Created: / 3.11.1997 / 14:27:27 / cg"
       
   428 !
       
   429 
       
   430 lampImageWidth
       
   431     ^ 15
       
   432 
       
   433     "Created: / 3.11.1997 / 14:27:23 / cg"
       
   434 ! !
       
   435 
       
   436 !RadioButton methodsFor:'queries'!
       
   437 
       
   438 is3D
       
   439     buttonStyle == #round2D ifTrue:[^ false.].
       
   440     ^ super is3D
       
   441 
       
   442     "Created: / 3.11.1997 / 14:39:36 / cg"
   148 ! !
   443 ! !
   149 
   444 
   150 !RadioButton class methodsFor:'documentation'!
   445 !RadioButton class methodsFor:'documentation'!
   151 
   446 
   152 version
   447 version
   153     ^ '$Header: /cvs/stx/stx/libwidg/RadioButton.st,v 1.14 1997-03-01 12:53:37 cg Exp $'
   448     ^ '$Header: /cvs/stx/stx/libwidg/RadioButton.st,v 1.15 1997-11-03 15:24:30 cg Exp $'
   154 ! !
   449 ! !