Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!mips!prls!pieter From: pieter@prls.UUCP (Pieter van der Meulen) Newsgroups: comp.lang.smalltalk Subject: Switches in 3D !! Keywords: SwichView 3D Message-ID: <26675@prls.UUCP> Date: 10 Oct 89 01:26:28 GMT Organization: Philips Res. Labs, Sunnyvale, CA Lines: 105 'Anybody who attended the OOPSLA89 exhibits may have noticed that the new fashion in user-interfaces is 3D (depth effects). I have seen only some effort in Smalltalk80 with respect to 3D. Even though (I think) that it is not very important to have these features, users are attracted/amused by them. And, I have even heard someone saying that Smalltalk has not the most advanced user-interface anymore (such sacrilege :-) ). Anyway, I thought it should be really easy to get some of you Smalltalkers motivated to come up with some examples. To show how simple this is, I included an example for ParcPlace Smalltalk-80 V2.3 (but will probably also work for other versions). The Switch3DView, a subclass of SwitchView, adds 3D effects to Switches. If you want all SwitchViews in the environment (like the ones in BinaryChoice) to have this behavior, you may use the methods here as SwitchView methods. In that case, omit the definition and replace Switch3DView with SwitchView. I do not like MODIFYING the system classes, so you do it. Note: the method is really all you need........ Try the example and have fun, Pieter S. van der Meulen.'! SwitchView subclass: #Switch3DView instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Interface-Menus'! Switch3DView comment: 'Add 3D effects to Switches. Try . Written by Pieter S. van der Meulen. '! !Switch3DView methodsFor: 'displaying'! clearInside "Create a view with depth effects. Cash a BitBlt for speed. Appropriate for most Smalltalk80 versions." | aRect aBitBlt | aRect _ self insetDisplayBox copy. aBitBlt _ BitBlt destForm: Display sourceForm: nil halftoneForm: nil combinationRule: Form over destOrigin: aRect origin sourceOrigin: Display boundingBox origin extent: aRect extent clipRect: Display boundingBox. (label isNil ifTrue: [6] ifFalse: [((aRect height - label height min: (aRect width - label width)) // 2 - 1) min: 10]) timesRepeat: [aBitBlt destRect: aRect; mask: Form darkGray; copyBits. aRect corner: aRect corner - (1@1). aBitBlt destRect: aRect; mask: Form lightGray; copyBits. aRect origin: aRect origin + (1@1)]. aBitBlt destRect: aRect; mask: self insideColor; copyBits! highlight "Keep the switches de-emphasized appearance close to its emphasized appearance. Only appropriate for ParcPlace Smalltalk." highlightForm == nil ifFalse: [^highlightForm displayOn: Display at: self displayBox topLeft clippingBox: self insetDisplayBox rule: Form reverse mask: nil]. emphasisOn ifTrue: [Display reverse: (self insetDisplayBox insetBy: 1)] ifFalse: ["Display reverse: (self insetDisplayBox insetBy: 1)." Display reverse: (self insetDisplayBox insetBy: 2)]! ! !Switch3DView class methodsFor: 'examples'! restoreDisplayView "To create a Switch which allows you to restore the display, execute : " "Switch3DView restoreDisplayView controller open" | topView aSwitch aView | topView _ StandardSystemView new. topView minimumSize: 128@40. topView maximumSize: 128@40. aSwitch _ Switch newOn. aSwitch onAction: [ScheduledControllers restore]. "aSwitch offAction: [ScheduledControllers restore]." aView _ SwitchView new model: aSwitch. aView borderWidth: 1; label: 'Restore display' asDisplayText. topView addSubView: aView. ^topView! ! -- --------------------------------------------- P.S. van der Meulen, MS 02 prls!pieter PRLS, Signetics div. of NAPC ----------- 811 E.Arques Avenue, Sunnyvale, CA 94088-3409