TriggerBox.st
changeset 4393 52cc2a73099a
child 4406 72cf3a074996
equal deleted inserted replaced
4392:9570ef5f05c3 4393:52cc2a73099a
       
     1 "
       
     2  COPYRIGHT (c) 2013 by Claus Gittinger
       
     3               All Rights Reserved
       
     4 
       
     5  This software is furnished under a license and may be used
       
     6  only in accordance with the terms of that license and with the
       
     7  inclusion of the above copyright notice.   This software may not
       
     8  be provided or otherwise made available to, or used by, any
       
     9  other person.  No title to or ownership of the software is
       
    10  hereby transferred.
       
    11 "
       
    12 "{ Package: 'stx:libwidg2' }"
       
    13 
       
    14 CheckBox subclass:#TriggerBox
       
    15 	instanceVariableNames:''
       
    16 	classVariableNames:''
       
    17 	poolDictionaries:''
       
    18 	category:'Views-Interactors'
       
    19 !
       
    20 
       
    21 !TriggerBox class methodsFor:'documentation'!
       
    22 
       
    23 copyright
       
    24 "
       
    25  COPYRIGHT (c) 2013 by Claus Gittinger
       
    26               All Rights Reserved
       
    27 
       
    28  This software is furnished under a license and may be used
       
    29  only in accordance with the terms of that license and with the
       
    30  inclusion of the above copyright notice.   This software may not
       
    31  be provided or otherwise made available to, or used by, any
       
    32  other person.  No title to or ownership of the software is
       
    33  hereby transferred.
       
    34 "
       
    35 !
       
    36 
       
    37 documentation
       
    38 "
       
    39     A TriggerBox looks similar to a CheckBox (it contains a button and a label),
       
    40     but does not show a check-icon.
       
    41     Instead, a trigger button (unlabelled) performs a momentary action when pressed.
       
    42 "
       
    43 !
       
    44 
       
    45 examples
       
    46 "
       
    47   no-op TriggerBox without a label:
       
    48                                                                         [exBegin]
       
    49      |b|
       
    50 
       
    51      b := TriggerBox new.
       
    52      b open
       
    53                                                                         [exEnd]
       
    54 
       
    55 
       
    56   no-op TriggerBox:
       
    57                                                                         [exBegin]
       
    58      |b|
       
    59 
       
    60      b := TriggerBox new.
       
    61      b label:'foo'.
       
    62      b open
       
    63                                                                         [exEnd]
       
    64 
       
    65 
       
    66   combined instance creation & label setup:
       
    67                                                                         [exBegin]
       
    68      |b|
       
    69 
       
    70      b := TriggerBox label:'foo'.
       
    71      b open
       
    72                                                                         [exEnd]
       
    73 
       
    74 
       
    75   no-op trigger, disabled:
       
    76                                                                         [exBegin]
       
    77      |b|
       
    78 
       
    79      b := TriggerBox label:'foo'.
       
    80      b disable.
       
    81      b open
       
    82                                                                         [exEnd]
       
    83 
       
    84 
       
    85   changing colors 
       
    86                                                                         [exBegin]
       
    87      |panel b|
       
    88 
       
    89      panel := VerticalPanelView new.
       
    90 
       
    91      b := TriggerBox label:'foo' in:panel.
       
    92 
       
    93      b := TriggerBox label:'bar' in:panel.
       
    94      b labelView foregroundColor:Color red.
       
    95 
       
    96      b := TriggerBox label:'baz' in:panel.
       
    97      b toggleView activeForegroundColor:Color blue.
       
    98 
       
    99      panel open
       
   100                                                                         [exEnd]
       
   101 
       
   102 
       
   103   using action-blocks:
       
   104                                                                         [exBegin]
       
   105      |b|
       
   106 
       
   107      b := TriggerBox label:'check'.
       
   108      b action:[:value | Transcript show:'trigger called: '].
       
   109      b open.
       
   110                                                                         [exEnd]
       
   111 
       
   112 
       
   113 
       
   114 
       
   115   with an enableChannel
       
   116                                                                         [exBegin]
       
   117      |b enaToggle enaHolder|
       
   118 
       
   119      enaHolder := true asValue.
       
   120 
       
   121      enaToggle := Toggle label:'enable'.
       
   122      enaToggle model:enaHolder.
       
   123      enaToggle open.
       
   124 
       
   125      b := TriggerBox label:'check'.
       
   126      b action:[:value | Transcript showCR:'triggered'].
       
   127      b enableChannel:enaHolder.
       
   128      b open.
       
   129                                                                         [exEnd]
       
   130 "
       
   131 ! !
       
   132 
       
   133 !TriggerBox methodsFor:'initialization & release'!
       
   134 
       
   135 defaultCheckToggleClass
       
   136     ^ Toggle "/ Button
       
   137 !
       
   138 
       
   139 defaultControllerClass
       
   140     ^ ButtonController
       
   141 !
       
   142 
       
   143 initialize
       
   144     super initialize.
       
   145     toggleView extent:16@16.
       
   146 
       
   147     toggleView activeLogo:nil.
       
   148     toggleView passiveLogo:nil.
       
   149     toggleView activeLevel:-2.
       
   150     toggleView passiveLevel:2.
       
   151     toggleView extent:10@10.
       
   152     toggleView sizeFixed:true.
       
   153 
       
   154     toggleView controller:(ButtonController new).
       
   155 ! !
       
   156 
       
   157 !TriggerBox class methodsFor:'documentation'!
       
   158 
       
   159 version
       
   160     ^ '$Header: /cvs/stx/stx/libwidg2/TriggerBox.st,v 1.1 2013-09-19 11:02:05 cg Exp $'
       
   161 !
       
   162 
       
   163 version_CVS
       
   164     ^ '$Header: /cvs/stx/stx/libwidg2/TriggerBox.st,v 1.1 2013-09-19 11:02:05 cg Exp $'
       
   165 ! !
       
   166