OptionBox.st
changeset 77 565b052f5277
parent 63 f4eaf04d1eaf
child 85 c229bb31d758
equal deleted inserted replaced
76:81e3409404d2 77:565b052f5277
    19 
    19 
    20 OptionBox comment:'
    20 OptionBox comment:'
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    22 	     All Rights Reserved
    22 	     All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.9 1994-11-17 14:38:21 claus Exp $
    24 $Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.10 1995-02-06 00:52:53 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !OptionBox class methodsFor:'documentation'!
    27 !OptionBox class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.9 1994-11-17 14:38:21 claus Exp $
    45 $Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.10 1995-02-06 00:52:53 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
    90 	textLabel resize.
    90 	textLabel resize.
    91 	self resize
    91 	self resize
    92     ]
    92     ]
    93 !
    93 !
    94 
    94 
       
    95 formLabel
       
    96     "return the label-view which displays a bitmap"
       
    97 
       
    98     ^ formLabel
       
    99 !
       
   100 
       
   101 form:aFormOrImage
       
   102     "set the image shown in the label-view"
       
   103 
       
   104     formLabel form:aFormOrImage
       
   105 !
       
   106 
    95 numberOfOptions:nOptions
   107 numberOfOptions:nOptions
    96     "set the number of options"
   108     "set the number of options"
    97 
   109 
    98     buttons := Array new:nOptions.
   110     buttons := Array new:nOptions.
    99     actions := Array new:nOptions
   111     actions := Array new:nOptions
   140 ! !
   152 ! !
   141 
   153 
   142 !OptionBox methodsFor:'initializing'!
   154 !OptionBox methodsFor:'initializing'!
   143 
   155 
   144 initialize
   156 initialize
   145     |nButt|
   157     |nButt buttonPanel|
   146 
   158 
   147     super initialize.
   159     super initialize.
   148 
   160 
   149     formLabel := Label in:self.
   161     formLabel := Label in:self.
   150     self initFormBitmap.
   162     self initFormBitmap.
   153 
   165 
   154     textLabel := Label label:'Warning' in:self.
   166     textLabel := Label label:'Warning' in:self.
   155     textLabel borderWidth:0.
   167     textLabel borderWidth:0.
   156     textLabel origin:((ViewSpacing + formLabel width + ViewSpacing) @ ViewSpacing).
   168     textLabel origin:((ViewSpacing + formLabel width + ViewSpacing) @ ViewSpacing).
   157 
   169 
   158 "
   170     buttonPanel := HorizontalPanelView origin:(0.0 @ 1.0) corner:(1.0 @ 1.0) in:self.
   159     buttonPanel := HorizontalPanelView in:self.
   171     buttonPanel bottomInset:ViewSpacing;
   160     buttonPanel origin:(0.0 @ 1.0)
   172 		   topInset:(font height + ViewSpacing * 2) negated.
   161 		corner:(1.0 @ 1.0).
   173     buttonPanel borderWidth:0; layout:#fitSpace.
   162     buttonPanel leftInset:mm;
       
   163 	       rightInset:mm;
       
   164 		 topInset:(font height * 2 + mm + mm) negated;
       
   165 	      bottomInset:mm.
       
   166 "
       
   167 
   174 
   168     nButt := buttons size.
   175     nButt := buttons size.
   169 
   176 
   170     1 to:nButt do:[:index |
   177     1 to:nButt do:[:index |
   171 	|button|
   178 	|button|
   179 				   action := actions at:index.
   186 				   action := actions at:index.
   180 				   action notNil ifTrue:[
   187 				   action notNil ifTrue:[
   181 				       action value
   188 				       action value
   182 				   ]
   189 				   ]
   183 			       ]
   190 			       ]
   184 			    in:self.
   191 			    in:buttonPanel "self".
   185 	buttons at:index put:button.
   192 	buttons at:index put:button.
   186 	button origin:[( (index-1) * ((width-ViewSpacing) // nButt) + (ViewSpacing) )
       
   187 		       @
       
   188 		       (height - ViewSpacing - (buttons at:index) heightIncludingBorder)].
       
   189 	button extent:[(width-ViewSpacing-ViewSpacing // nButt - ViewSpacing) 
       
   190 		       @ 
       
   191 		       (buttons at:index) height
       
   192 		      ]
       
   193     ]
   193     ]
   194 !
   194 !
   195 
   195 
   196 initFormBitmap
   196 initFormBitmap
   197     WarnBitmap isNil ifTrue:[
   197     WarnBitmap isNil ifTrue:[
   198 	WarnBitmap := Form fromFile:'Warning.xbm' resolution:100 on:Display 
   198 	WarnBitmap := Form fromFile:'Warning.xbm' resolution:100 on:Display 
   199     ].
   199     ].
   200     formLabel form:WarnBitmap
   200     formLabel form:WarnBitmap
       
   201 !
       
   202 
       
   203 focusSequence
       
   204     ^ buttons
   201 ! !
   205 ! !
   202 
   206 
   203 !OptionBox methodsFor:'queries'!
   207 !OptionBox methodsFor:'queries'!
   204 
   208 
   205 positionOffset
   209 positionOffset