InfoBox.st
changeset 1172 d10e4627b0e3
parent 797 2f9cd56f48ee
child 1365 aa6a855b5013
equal deleted inserted replaced
1171:71f7a035396f 1172:d10e4627b0e3
    17 	classVariableNames:'InfoBitmap'
    17 	classVariableNames:'InfoBitmap'
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Views-DialogBoxes'
    19 	category:'Views-DialogBoxes'
    20 !
    20 !
    21 
    21 
    22 !InfoBox  class methodsFor:'documentation'!
    22 !InfoBox class methodsFor:'documentation'!
    23 
    23 
    24 copyright
    24 copyright
    25 "
    25 "
    26  COPYRIGHT (c) 1989 by Claus Gittinger
    26  COPYRIGHT (c) 1989 by Claus Gittinger
    27 	      All Rights Reserved
    27 	      All Rights Reserved
   164                                                                         [exEnd]
   164                                                                         [exEnd]
   165 
   165 
   166 "
   166 "
   167 ! !
   167 ! !
   168 
   168 
   169 !InfoBox  class methodsFor:'instance creation'!
   169 !InfoBox class methodsFor:'instance creation'!
   170 
   170 
   171 title:titleString
   171 title:titleString
   172     "create a new infoBox with title, aTitleString"
   172     "create a new infoBox with title, aTitleString"
   173 
   173 
   174     ^ (self new) title:titleString
   174     ^ (self new) title:titleString
   176     "
   176     "
   177      (InfoBox title:'hello') open
   177      (InfoBox title:'hello') open
   178     "
   178     "
   179 ! !
   179 ! !
   180 
   180 
   181 !InfoBox  class methodsFor:'defaults'!
   181 !InfoBox class methodsFor:'defaults'!
   182 
   182 
   183 defaultLabel
   183 defaultLabel
   184     "return the boxes default window title."
   184     "return the boxes default window title."
   185 
   185 
   186     ^ 'Info'
   186     ^ 'Info'
   188     "Created: 23.4.1996 / 17:12:33 / cg"
   188     "Created: 23.4.1996 / 17:12:33 / cg"
   189 !
   189 !
   190 
   190 
   191 iconBitmap
   191 iconBitmap
   192     "return the bitmap shown as icon in my instances.
   192     "return the bitmap shown as icon in my instances.
   193      The form is cached and reused, for faster opening."
   193      This is the default image; you can overwrite this in a concrete
       
   194      instance with the #image: message"
       
   195 
       
   196     <resource: #style (#infoBoxIcon #infoBoxIconFile)>
       
   197 
       
   198     |img imgFileName|
   194 
   199 
   195     InfoBitmap isNil ifTrue:[
   200     InfoBitmap isNil ifTrue:[
   196 	InfoBitmap := Image fromFile:'bitmaps/Information.xbm'. 
   201         img := StyleSheet at:'infoBoxIcon'.
   197 	InfoBitmap notNil ifTrue:[
   202         img notNil ifTrue:[
   198 	    InfoBitmap := InfoBitmap on:Display 
   203             InfoBitmap := img
   199 	]
   204         ] ifFalse:[
       
   205             imgFileName := StyleSheet at:'infoBoxIconFile' default:'bitmaps/Information.xbm'.
       
   206             InfoBitmap := Image fromFile:imgFileName.
       
   207         ].
       
   208         InfoBitmap notNil ifTrue:[
       
   209             InfoBitmap := InfoBitmap on:Display
       
   210         ]
   200     ].
   211     ].
   201     ^ InfoBitmap
   212     ^ InfoBitmap
   202 ! !
   213 
   203 
   214     "Modified: 1.4.1997 / 14:44:12 / cg"
   204 !InfoBox  class methodsFor:'styles'!
   215 ! !
       
   216 
       
   217 !InfoBox class methodsFor:'styles'!
   205 
   218 
   206 updateStyleCache
   219 updateStyleCache
   207     "extract values from the styleSheet and cache them in class variables"
   220     "extract values from the styleSheet and cache them in class variables.
   208 
   221      Here, the cached infoBitmap is simply flushed."
   209     <resource: #style (#informationBoxIcon)>
   222 
   210 
   223     InfoBitmap := nil
   211     |img|
   224 
   212 
   225     "Modified: 1.4.1997 / 14:44:50 / cg"
   213     img := StyleSheet at:'informationBoxIcon'.
       
   214     img notNil ifTrue:[InfoBitmap := img on:Display].
       
   215 
       
   216     "Modified: 1.3.1996 / 13:45:38 / cg"
       
   217 ! !
   226 ! !
   218 
   227 
   219 !InfoBox methodsFor:'accessing'!
   228 !InfoBox methodsFor:'accessing'!
   220 
   229 
   221 form:aFormOrImage
   230 form:aFormOrImage
   288     "Created: 16.11.1995 / 18:32:32 / cg"
   297     "Created: 16.11.1995 / 18:32:32 / cg"
   289     "Modified: 22.4.1996 / 18:15:37 / cg"
   298     "Modified: 22.4.1996 / 18:15:37 / cg"
   290 !
   299 !
   291 
   300 
   292 initialize
   301 initialize
   293     |mm|
   302     |mm sep|
   294 
   303 
   295     super initialize.
   304     super initialize.
   296     self addOkButton.
   305     self addOkButton.
   297 
   306 
   298 "/    label := 'Info'.
   307 "/    label := 'Info'.
   303     self initFormBitmap.
   312     self initFormBitmap.
   304 
   313 
   305     textLabel := Label label:'Information' in:self.
   314     textLabel := Label label:'Information' in:self.
   306     textLabel borderWidth:0.
   315     textLabel borderWidth:0.
   307     textLabel origin:[(mm + formLabel widthIncludingBorder + mm) @ mm].
   316     textLabel origin:[(mm + formLabel widthIncludingBorder + mm) @ mm].
       
   317 
       
   318     (styleSheet at:'infoBoxSeparator' default:false) ifTrue:[
       
   319         sep := Separator in:self.
       
   320         sep origin:[0.0 @ ((formLabel bottom max:textLabel bottom) + ViewSpacing)].
       
   321         sep extent:(1.0 @ sep preferredExtent y).
       
   322     ].
   308 
   323 
   309     "
   324     "
   310      |b|
   325      |b|
   311 
   326 
   312      b := InfoBox new.
   327      b := InfoBox new.
   313      b title:'hello'.
   328      b title:'hello'.
   314      b open
   329      b open
   315     "
   330     "
   316 
   331 
   317     "Modified: 23.4.1996 / 17:12:39 / cg"
   332     "Modified: 1.4.1997 / 14:53:16 / cg"
   318 ! !
   333 ! !
   319 
   334 
   320 !InfoBox methodsFor:'queries'!
   335 !InfoBox methodsFor:'queries'!
   321 
   336 
   322 preferredExtent 
   337 preferredExtent 
   340 
   355 
   341     h := (mm * 6)
   356     h := (mm * 6)
   342          + ((formLabel heightIncludingBorder) max:(textLabel height))
   357          + ((formLabel heightIncludingBorder) max:(textLabel height))
   343          + okButton heightIncludingBorder.
   358          + okButton heightIncludingBorder.
   344 
   359 
       
   360     (styleSheet at:'infoBoxSeparator' default:false) ifTrue:[
       
   361         h := h + (ViewSpacing * 3)
       
   362     ].
       
   363 
   345     ^ w @ h
   364     ^ w @ h
   346 
   365 
   347     "Modified: 19.7.1996 / 20:44:35 / cg"
   366     "Modified: 1.4.1997 / 14:53:35 / cg"
   348 ! !
   367 ! !
   349 
   368 
   350 !InfoBox  class methodsFor:'documentation'!
   369 !InfoBox class methodsFor:'documentation'!
   351 
   370 
   352 version
   371 version
   353     ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.31 1996-07-19 18:49:51 cg Exp $'
   372     ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.32 1997-04-01 12:54:08 cg Exp $'
   354 ! !
   373 ! !