{ import: Object } { import: Text } { import: TextLayout } { import: SDLSurface } TitleFont := [ (Face named: 'arialbd') fontAt: 16 ] "----------------" FrameMoveHandler : DraggingHandler () FrameMoveHandler buttonDown :anEvent [ box raise. super buttonDown :anEvent ] "----------------" FrameCloseHandler : DraggingHandler ( target ) "todo: it is not natural" FrameCloseHandler buttonDown :anEvent [ target := anEvent target. anEvent hand addEventHandler: self. ] FrameCloseHandler motion :anEvent [] FrameCloseHandler buttonUp :anEvent [ anEvent hand removeEventHandler: self. anEvent target == target ifTrue: [box removeFromList]. ] "----------------" FrameSizeHandler : DraggingHandler () FrameSizeHandler buttonDown :anEvent [ box raise. reference := anEvent position - box extent. anEvent hand addEventHandler: self. ] FrameSizeHandler motion :anEvent [ box damaged. box extent: anEvent position - reference. box damaged. ] "----------------" FrameBox : Box ( title resizer closer content ) FrameBox titleColor [ ^ColorWhite ] FrameBox frameColor [ ^Color withR: 250 withG: 250 withB: 250 ] FrameBox titleBackColor [ ^Color withR: 32 withG: 200 withB: 128 ] FrameBox borderColor [ ^Color gray: 50 ] FrameBox closerColor [ ^Color withR: 120 withG: 200 withB: 180 ] FrameBox closerBorderColor [ ^Color gray: 95 ] FrameBox content [ ^content ] FrameBox with: aBox title: titleString [ self := self new background: self frameColor; border: self borderColor. self titleString: titleString. self addFront: (closer := Box new extent: (title extent y - 6) , (title extent y - 6); background: self closerColor; border: self closerBorderColor). self addFront: (resizer := Box new extent: 8,8; background: self background). self addFront: (content := aBox position: 2, (2 + title extent y + 1)). self extent: (2 + aBox extent x + 2) , (2 + title extent y + 2 + aBox extent y + 2). self buttonDown: (FrameMoveHandler with: self). closer buttonDown: (FrameCloseHandler with: self). resizer buttonDown: (FrameSizeHandler with: self). aBox clip: true. self clip: true. ] FrameBox extent: aPoint [ super extent: aPoint. closer position: (aPoint x - title extent y) , 5. resizer position: aPoint - (8,8). content extent: (aPoint x - 4) , (aPoint y - (2 + title extent y + 2 + 1)). title extent: (aPoint x - 4), title extent y. ] FrameBox titleString: titleString [ | newTitle | newTitle := (titleString asText: TitleFont) position: 2,2; foreground: self titleColor; background: self titleBackColor. title ifTrue: [self add: newTitle inFrontOf: title. title removeFromList] ifFalse: [self addFront: newTitle]. title := newTitle. ] Box beMenu [ | x y wh h | wh := PointZero. self do: [:box | wh := wh max: box extent]. x := y := 2. h := wh y. self do: [:box | box position: x,y; extent: wh. y := y + h]. self extent: wh x, y + (4,4). ] "----------------" BoxList slotValues [ ^ Array with: ('myBox' -> (self _oopAt: 2)) withAll: super slotValues ] TextBox contentString [ | buf | buf := OrderedCollection new. self do: [:each | buf add: each glyph ucs4 ]. ^ String withAll: buf. ] TextBox printOn: aStream [ aStream nextPutAll: self debugName. aStream nextPutAll: ': ', self contentString printString. ]