SimpleView.st
changeset 2506 221b75206a75
parent 2496 f3093d8a83f8
child 2510 32d7085d52cb
equal deleted inserted replaced
2505:b17657563552 2506:221b75206a75
  4492 
  4492 
  4493     "Modified: / 22.8.1998 / 17:32:53 / cg"
  4493     "Modified: / 22.8.1998 / 17:32:53 / cg"
  4494 !
  4494 !
  4495 
  4495 
  4496 focusIn
  4496 focusIn
  4497     "got keyboard focus (via the window manager)"
  4497     "got keyboard focus (via the window manager).
       
  4498      Nothing done here"
       
  4499 
       
  4500 !
       
  4501 
       
  4502 focusOut
       
  4503     "lost keyboard focus (via the window manager).
       
  4504      Nothing done here"
       
  4505 !
       
  4506 
       
  4507 hasKeyboardFocus:aBoolean
       
  4508     "notification from the windowGroup that I got the keyboardFocus."
  4498 
  4509 
  4499     delegate notNil ifTrue:[
  4510     delegate notNil ifTrue:[
  4500 	(delegate respondsTo:#handlesKeyPress:inView:) ifTrue:[
  4511         delegate perform:#hasKeyboardFocus: with:aBoolean ifNotUnderstood:nil
  4501 	    (delegate handlesKeyPress:#Any inView:self) ifTrue:[
  4512     ].
  4502 		delegate showFocus:false.
       
  4503 		^ self
       
  4504 	    ]
       
  4505 	]
       
  4506     ].
       
  4507     self showFocus:false
       
  4508 
       
  4509     "Modified: 28.2.1997 / 23:29:12 / cg"
       
  4510 !
       
  4511 
       
  4512 focusOut
       
  4513     "lost keyboard focus (via the window manager)"
       
  4514 
       
  4515     delegate notNil ifTrue:[
       
  4516 	(delegate respondsTo:#handlesKeyPress:inView:) ifTrue:[
       
  4517 	    (delegate handlesKeyPress:#Any inView:self) ifTrue:[
       
  4518 		delegate showNoFocus:false.
       
  4519 		^ self
       
  4520 	    ]
       
  4521 	]
       
  4522     ].
       
  4523     self showNoFocus:false
       
  4524 
       
  4525     "Modified: 28.2.1997 / 23:29:23 / cg"
       
  4526 !
       
  4527 
       
  4528 hasKeyboardFocus:aBoolean
       
  4529     ^ self
  4513     ^ self
  4530 !
  4514 !
  4531 
  4515 
  4532 keyPress:key x:x y:y
  4516 keyPress:key x:x y:y
  4533     "a key has been pressed. If there are components,
  4517     "a key has been pressed. If there are components,
  4637 
  4621 
  4638     "Modified: 25.2.1997 / 22:41:34 / cg"
  4622     "Modified: 25.2.1997 / 22:41:34 / cg"
  4639 !
  4623 !
  4640 
  4624 
  4641 pointerEnter:state x:x y:y
  4625 pointerEnter:state x:x y:y
  4642     "got mouse pointer"
  4626     "got mouse pointer.
  4643 
  4627      Nothing done here"
  4644     self focusIn
       
  4645 
  4628 
  4646     "Modified: 25.2.1997 / 23:43:21 / cg"
  4629     "Modified: 25.2.1997 / 23:43:21 / cg"
  4647 !
  4630 !
  4648 
  4631 
  4649 pointerLeave:state
  4632 pointerLeave:state
  4650     "got mouse pointer"
  4633     "got mouse pointer.
  4651 
  4634      Nothing done here"
  4652     self focusOut
       
  4653 
  4635 
  4654     "Modified: 25.2.1997 / 23:43:17 / cg"
  4636     "Modified: 25.2.1997 / 23:43:17 / cg"
  4655 !
  4637 !
  4656 
  4638 
  4657 reparented
  4639 reparented
  4854      Delay waitForSeconds:1.
  4836      Delay waitForSeconds:1.
  4855      v pushEvent:#buttonRelease:x:y: withArguments:#(1 10 10).
  4837      v pushEvent:#buttonRelease:x:y: withArguments:#(1 10 10).
  4856     "
  4838     "
  4857 
  4839 
  4858     "Modified: / 10.6.1998 / 17:28:16 / cg"
  4840     "Modified: / 10.6.1998 / 17:28:16 / cg"
       
  4841 ! !
       
  4842 
       
  4843 !SimpleView methodsFor:'focus handling'!
       
  4844 
       
  4845 requestFocus
       
  4846     "request focus from my windowGroup;
       
  4847      typically, this is invoked when the mouse pointer enters a
       
  4848      widget. The request may or may not be ignored by the wGroup
       
  4849      (it will be ignored, if an explicit focus-change is currently
       
  4850       active - i.e. if the user tabbed into a widget)"
       
  4851 
       
  4852     windowGroup notNil ifTrue:[
       
  4853         ^ windowGroup focusRequestFrom:self
       
  4854     ].
       
  4855     ^ true
       
  4856 !
       
  4857 
       
  4858 showFocus:explicit
       
  4859     "highlight myself somehow to tell user that I have the focus.
       
  4860      If explicit is true, the focus came via focusStepping (i.e. tabbing);
       
  4861      if false, it came via the window manager (i.e. pointer entering).
       
  4862      Only change my border, if this is an explicit focusChange."
       
  4863 
       
  4864     |delta clrId|
       
  4865 
       
  4866     explicit ifTrue:[
       
  4867         drawableId notNil ifTrue:[
       
  4868             (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
       
  4869                 delta := DefaultFocusBorderWidth - borderWidth.
       
  4870                 delta ~~ 0 ifTrue:[
       
  4871                     device moveWindow:drawableId x:left-delta y:top-delta.
       
  4872                     device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId.
       
  4873                 ].
       
  4874 
       
  4875                 clrId := (DefaultFocusColor on:device) colorId.
       
  4876                 clrId isNil ifTrue:[
       
  4877                     clrId := device blackpixel
       
  4878                 ].
       
  4879                 device setWindowBorderColor:clrId in:drawableId.
       
  4880             ]
       
  4881         ]
       
  4882     ] ifFalse:[
       
  4883         superView notNil ifTrue:[
       
  4884             superView showFocus:explicit
       
  4885         ]
       
  4886     ]
       
  4887 
       
  4888     "Modified: / 17.9.1998 / 15:08:34 / cg"
       
  4889 !
       
  4890 
       
  4891 showNoFocus:explicit
       
  4892     "undo the effect of showFocus.
       
  4893      Explicit tells if the focus came via focusStepping (i.e. tabbing)
       
  4894      or via the window manager (i.e. pointer entering).
       
  4895      Only change my border, if this is an explicit focusChange."
       
  4896 
       
  4897     |delta|
       
  4898 
       
  4899     explicit ifTrue:[
       
  4900         drawableId notNil ifTrue:[
       
  4901             (windowGroup notNil
       
  4902             and:[windowGroup focusView == self]) ifTrue:[
       
  4903                 (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
       
  4904                     delta := DefaultFocusBorderWidth - borderWidth.
       
  4905                     delta ~~ 0 ifTrue:[
       
  4906                         device setWindowBorderWidth:borderWidth in:drawableId.
       
  4907                         device moveWindow:drawableId x:left y:top.
       
  4908                     ].
       
  4909                     self setBorderColor.
       
  4910                 ]
       
  4911             ]
       
  4912         ]
       
  4913     ]
       
  4914 
       
  4915     "Modified: / 17.9.1998 / 15:08:02 / cg"
       
  4916 !
       
  4917 
       
  4918 wantsFocusWithButtonPress
       
  4919     "views which like to take the keyboard focus
       
  4920      with buttonPress can do so by redefining this
       
  4921      to return true"
       
  4922 
       
  4923     ^ false
  4859 ! !
  4924 ! !
  4860 
  4925 
  4861 !SimpleView methodsFor:'informing others of changes'!
  4926 !SimpleView methodsFor:'informing others of changes'!
  4862 
  4927 
  4863 contentsChanged
  4928 contentsChanged
  5831     |focusView delegate|
  5896     |focusView delegate|
  5832 
  5897 
  5833     windowGroup isNil ifTrue:[^ false].
  5898     windowGroup isNil ifTrue:[^ false].
  5834 
  5899 
  5835     (focusView := windowGroup focusView) == self ifTrue:[^ true].
  5900     (focusView := windowGroup focusView) == self ifTrue:[^ true].
       
  5901 
  5836     focusView notNil ifTrue:[
  5902     focusView notNil ifTrue:[
  5837 	"mhmh - is there a delegation to me ?"
  5903         "mhmh - is there a delegation to me ?"
  5838 	(delegate := focusView delegate) notNil ifTrue:[
  5904         (delegate := focusView delegate) notNil ifTrue:[
  5839 	    delegate == self ifTrue:[^ true].
  5905             delegate == self ifTrue:[^ true].
  5840 	    ^ delegate delegatesTo:self
  5906             ^ delegate delegatesTo:self
  5841 	]
  5907         ]
  5842     ].
  5908     ].
  5843     ^ false
  5909     ^ false
  5844 !
  5910 !
  5845 
  5911 
  5846 is3D
  5912 is3D
  7029      Nothing done here, but redefined in some classes."
  7095      Nothing done here, but redefined in some classes."
  7030 
  7096 
  7031     ^ self
  7097     ^ self
  7032 !
  7098 !
  7033 
  7099 
  7034 showFocus:explicit
       
  7035     "highlight myself somehow to tell user that I have the focus.
       
  7036      If explicit is true, the focus came via focusStepping (i.e. tabbing);
       
  7037      if false, it came via the window manager (i.e. pointer entering).
       
  7038      Only change my border, if this is an explicit focusChange."
       
  7039 
       
  7040     |delta clrId|
       
  7041 
       
  7042     explicit ifTrue:[
       
  7043         drawableId notNil ifTrue:[
       
  7044             (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
       
  7045                 delta := DefaultFocusBorderWidth - borderWidth.
       
  7046                 delta ~~ 0 ifTrue:[
       
  7047                     device moveWindow:drawableId x:left-delta y:top-delta.
       
  7048                     device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId.
       
  7049                 ].
       
  7050 
       
  7051                 clrId := (DefaultFocusColor on:device) colorId.
       
  7052                 clrId isNil ifTrue:[
       
  7053                     clrId := device blackpixel
       
  7054                 ].
       
  7055                 device setWindowBorderColor:clrId in:drawableId.
       
  7056             ]
       
  7057         ]
       
  7058     ] ifFalse:[
       
  7059         superView notNil ifTrue:[
       
  7060             superView showFocus:explicit
       
  7061         ]
       
  7062     ]
       
  7063 
       
  7064     "Modified: / 17.9.1998 / 15:08:34 / cg"
       
  7065 !
       
  7066 
       
  7067 showNoFocus:explicit
       
  7068     "undo the effect of showFocus.
       
  7069      Explicit tells if the focus came via focusStepping (i.e. tabbing)
       
  7070      or via the window manager (i.e. pointer entering).
       
  7071      Only change my border, if this is an explicit focusChange."
       
  7072 
       
  7073     |delta|
       
  7074 
       
  7075     explicit ifTrue:[
       
  7076         drawableId notNil ifTrue:[
       
  7077             (windowGroup notNil
       
  7078             and:[windowGroup focusView == self]) ifTrue:[
       
  7079                 (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
       
  7080                     delta := DefaultFocusBorderWidth - borderWidth.
       
  7081                     delta ~~ 0 ifTrue:[
       
  7082                         device setWindowBorderWidth:borderWidth in:drawableId.
       
  7083                         device moveWindow:drawableId x:left y:top.
       
  7084                     ].
       
  7085                     self setBorderColor.
       
  7086                 ]
       
  7087             ]
       
  7088         ]
       
  7089     ]
       
  7090 
       
  7091     "Modified: / 17.9.1998 / 15:08:02 / cg"
       
  7092 !
       
  7093 
       
  7094 showPassive
  7100 showPassive
  7095     "redraw myself as inactive (i.e. nonbusy).
  7101     "redraw myself as inactive (i.e. nonbusy).
  7096      Nothing done here, but redefined in some classes."
  7102      Nothing done here, but redefined in some classes."
  7097 
  7103 
  7098     ^ self
  7104     ^ self
  7993 ! !
  7999 ! !
  7994 
  8000 
  7995 !SimpleView class methodsFor:'documentation'!
  8001 !SimpleView class methodsFor:'documentation'!
  7996 
  8002 
  7997 version
  8003 version
  7998     ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.298 1999-03-10 22:31:00 cg Exp $'
  8004     ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.299 1999-03-14 12:59:19 cg Exp $'
  7999 ! !
  8005 ! !
  8000 SimpleView initialize!
  8006 SimpleView initialize!