40 " |
40 " |
41 ! |
41 ! |
42 |
42 |
43 version |
43 version |
44 " |
44 " |
45 $Header: /cvs/stx/stx/libview/ModalBox.st,v 1.15 1994-11-28 21:01:03 claus Exp $ |
45 $Header: /cvs/stx/stx/libview/ModalBox.st,v 1.16 1995-02-06 00:37:31 claus Exp $ |
46 " |
46 " |
47 ! |
47 ! |
48 |
48 |
49 documentation |
49 documentation |
50 " |
50 " |
51 this class implements modal boxes; ModalBoxes are different from |
51 this class implements modal boxes; ModalBoxes are different from |
52 others, in that they take control over the current topview, until |
52 others, in that they take control over the current topview, until |
53 all processing is done (i.e. the currently active topview and all of |
53 all processing is done (i.e. the currently active topview and all of |
54 its subviews will not handle user events while the box is active). |
54 its subviews will not handle user events while the box is active). |
|
55 |
|
56 ModalBoxes are either implemented as transient windows |
|
57 (if UseTransientViews := true) or as override redirect views. |
|
58 Some window managers have problems with either; so you may want to |
|
59 change the default setting from your display.rc file. |
55 " |
60 " |
56 ! ! |
61 ! ! |
57 |
62 |
58 !ModalBox class methodsFor:'initialization'! |
63 !ModalBox class methodsFor:'initialization'! |
59 |
64 |
60 initialize |
65 initialize |
61 UseTransientViews := false. |
66 UseTransientViews := true. |
|
67 ! ! |
|
68 |
|
69 !ModalBox class methodsFor:'defaults'! |
|
70 |
|
71 defaultExtent |
|
72 "this defines the defaultExtent for instances of me; |
|
73 the value returned here is usually not correct for concrete subclasses, |
|
74 so you better redefine this method" |
|
75 |
|
76 ^ (Display pixelPerMillimeter * (60 @ 30)) rounded |
|
77 ! |
|
78 |
|
79 useTransientViews:aBoolean |
|
80 "change the way modalBoxes are created on the Display. |
|
81 If the argument is true, transient views are used; otherwise |
|
82 override redirect views are used. Depending on your windowmanager, |
|
83 either one may have problems. You may want to change the setting |
|
84 from your display.rc or d_xxx.rc file." |
|
85 |
|
86 UseTransientViews := aBoolean. |
|
87 |
|
88 " |
|
89 ModalBox useTransient:false |
|
90 ModalBox useTransient:true |
|
91 " |
62 ! ! |
92 ! ! |
63 |
93 |
64 !ModalBox methodsFor:'initialize / release'! |
94 !ModalBox methodsFor:'initialize / release'! |
65 |
95 |
66 initialize |
96 initialize |
67 |form resizeButton| |
97 |form resizeButton moveButton| |
68 |
98 |
69 super initialize. |
99 super initialize. |
70 |
100 |
71 haveControl := false. |
|
72 exclusiveKeyboard := false. |
101 exclusiveKeyboard := false. |
73 label := ' '. |
102 label := ' '. |
|
103 |
|
104 label := 'Popup'. |
74 |
105 |
75 UseTransientViews ifFalse:[ |
106 UseTransientViews ifFalse:[ |
76 (StyleSheet at:#popupShadow default:false) ifTrue:[ |
107 (StyleSheet at:#popupShadow default:false) ifTrue:[ |
77 shadowView := (ShadowView on:device) for:self |
108 shadowView := (ShadowView on:device) for:self |
78 ] |
109 ]. |
79 ]. |
110 |
80 |
111 form := Form width:8 height:8 |
81 form := Form width:8 height:8 |
112 fromArray:#[2r00000000 |
82 fromArray:#[2r00000000 |
113 2r00000000 |
83 2r00000000 |
114 2r00000000 |
84 2r00000000 |
115 2r00000001 |
85 2r00000001 |
116 2r00000011 |
86 2r00000011 |
117 2r00000111 |
87 2r00000111 |
118 2r00001111 |
88 2r00001111 |
119 2r00011111 |
89 2r00011111 |
120 ] |
90 ] |
121 on:device. |
91 on:device. |
122 resizeButton := Button form:form in:self. |
92 resizeButton := Button form:form in:self. |
123 resizeButton origin:1.0 @ 1.0 corner:1.0@1.0. |
93 resizeButton origin:1.0 @ 1.0 corner:1.0@1.0. |
124 resizeButton activeForegroundColor:(resizeButton foregroundColor). |
94 resizeButton activeForegroundColor:(resizeButton foregroundColor). |
125 resizeButton activeBackgroundColor:(resizeButton backgroundColor). |
95 resizeButton leftInset:-8; topInset:-8. |
126 resizeButton enteredBackgroundColor:(resizeButton backgroundColor). |
96 resizeButton releaseAction:[]. |
127 resizeButton leftInset:-8; topInset:-8. |
97 resizeButton pressAction:[resizeButton turnOff; redraw. self doResize]. |
128 resizeButton releaseAction:[]. |
98 resizeButton borderWidth:0. |
129 resizeButton pressAction:[resizeButton turnOff; redraw. self doResize]. |
99 resizeButton onLevel:-2; offLevel:0. |
130 resizeButton borderWidth:0. |
100 resizeButton cursor:(Cursor corner) |
131 resizeButton onLevel:0; offLevel:0. |
|
132 resizeButton cursor:(Cursor corner). |
|
133 |
|
134 form := Form width:8 height:8 |
|
135 fromArray:#[2r11111000 |
|
136 2r11110000 |
|
137 2r11100000 |
|
138 2r11000000 |
|
139 2r10000000 |
|
140 2r00000000 |
|
141 2r00000000 |
|
142 2r00000000 |
|
143 ] |
|
144 on:device. |
|
145 moveButton := Button form:form in:self. |
|
146 moveButton origin:0.0 @ 0.0 corner:0.0@0.0. |
|
147 moveButton activeForegroundColor:(moveButton foregroundColor). |
|
148 moveButton activeBackgroundColor:(moveButton backgroundColor). |
|
149 moveButton enteredBackgroundColor:(moveButton backgroundColor). |
|
150 moveButton rightInset:-8; bottomInset:-8. |
|
151 moveButton releaseAction:[]. |
|
152 moveButton pressAction:[moveButton turnOff; redraw. self doMove]. |
|
153 moveButton borderWidth:0. |
|
154 moveButton onLevel:0; offLevel:0. |
|
155 moveButton cursor:(Cursor origin) |
|
156 ]. |
|
157 |
101 ! |
158 ! |
102 |
159 |
103 initEvents |
160 initEvents |
|
161 super initEvents. |
104 self enableEvent:#visibilityChange |
162 self enableEvent:#visibilityChange |
105 ! |
163 ! |
106 |
164 |
107 initStyle |
165 initStyle |
108 super initStyle. |
166 super initStyle. |
109 ((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[ |
167 ((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[ |
110 borderWidth := 0. |
168 borderWidth := 0. |
111 self level:2 |
169 UseTransientViews ifFalse:[ |
|
170 self level:2 |
|
171 ] |
112 ] |
172 ] |
113 ! |
173 ! |
114 |
174 |
115 reinitialize |
175 reinitialize |
116 super reinitialize. |
176 super reinitialize. |
527 self origin:r origin extent:(r extent max:(100@100)). |
589 self origin:r origin extent:(r extent max:(100@100)). |
528 shadowView notNil ifTrue:[ |
590 shadowView notNil ifTrue:[ |
529 shadowView realize. |
591 shadowView realize. |
530 self raise |
592 self raise |
531 ]. |
593 ]. |
|
594 ! |
|
595 |
|
596 doResize |
|
597 "the resize button was pressed" |
|
598 |
|
599 |r| |
|
600 |
|
601 r := device rectangleFromUser:(self origin corner:self corner). |
|
602 shadowView notNil ifTrue:[ |
|
603 shadowView unrealize |
|
604 ]. |
|
605 self origin:r origin extent:(r extent max:(100@100)). |
|
606 shadowView notNil ifTrue:[ |
|
607 shadowView realize. |
|
608 self raise |
|
609 ]. |
|
610 ! ! |
|
611 |
|
612 !ModalBox methodsFor:'event handling'! |
|
613 |
|
614 terminate |
|
615 "this is the close from a windowmanager |
|
616 (only if UseTransientViews == true)" |
|
617 |
|
618 self hide |
532 ! |
619 ! |
533 |
620 |
534 visibilityChange:how |
621 visibilityChange:how |
535 "raise when covered - this should not be needed, since we |
622 "raise when covered - this should not be needed, since we |
536 have been created as override-redirect window (which should |
623 have been created as override-redirect window (which should |
537 stay on top - but some window managers (fvwm) seem to ignore |
624 stay on top - but some window managers (fvwm) seem to ignore |
538 this ..." |
625 this ..." |
539 |
626 |
540 "code below is not good, since it will lead to |
627 "the code below is not good, since it will lead to |
541 oscillating raises when two modalBoxes are going to cover |
628 oscillating raises when two modalBoxes are going to cover |
542 each other - see coveredBy:-handling ..." |
629 each other - see coveredBy:-handling ..." |
543 |
630 |
544 "/ how ~~ #fullyVisible ifTrue:[ |
631 "/ how ~~ #fullyVisible ifTrue:[ |
545 "/ self raise |
632 "/ self raise |