comparison dwt/custom/ScrolledComposite.d @ 146:05e03d23ca3a

Fixes #27
author Jacob Carlborg <doob@me.com>
date Sat, 06 Jun 2009 23:35:37 +0200
parents 6337764516f1
children
comparison
equal deleted inserted replaced
145:1324fd764db4 146:05e03d23ca3a
161 super(parent, checkStyle(style)); 161 super(parent, checkStyle(style));
162 super.setLayout(new ScrolledCompositeLayout()); 162 super.setLayout(new ScrolledCompositeLayout());
163 ScrollBar hBar = getHorizontalBar (); 163 ScrollBar hBar = getHorizontalBar ();
164 if (hBar !is null) { 164 if (hBar !is null) {
165 hBar.setVisible(false); 165 hBar.setVisible(false);
166 hBar.addListener (DWT.Selection, new class() Listener { 166 hBar.addListener (DWT.Selection, new class(this) Listener {
167 ScrolledComposite sc;
168
169 this (ScrolledComposite sc) {
170 this.sc = sc;
171 }
172
167 public void handleEvent (Event e) { 173 public void handleEvent (Event e) {
168 hScroll(); 174 hScroll();
169 } 175 }
170 }); 176 });
171 } 177 }
172 178
173 ScrollBar vBar = getVerticalBar (); 179 ScrollBar vBar = getVerticalBar ();
174 if (vBar !is null) { 180 if (vBar !is null) {
175 vBar.setVisible(false); 181 vBar.setVisible(false);
176 vBar.addListener (DWT.Selection, new class() Listener { 182 vBar.addListener (DWT.Selection, new class(this) Listener {
183 ScrolledComposite sc;
184
185 this (ScrolledComposite sc) {
186 this.sc = sc;
187 }
188
177 public void handleEvent (Event e) { 189 public void handleEvent (Event e) {
178 vScroll(); 190 sc.vScroll();
179 } 191 }
180 }); 192 });
181 } 193 }
182 194
183 contentListener = new class() Listener { 195 contentListener = new class(this) Listener {
196 ScrolledComposite sc;
197
198 this (ScrolledComposite sc) {
199 this.sc = sc;
200 }
201
184 public void handleEvent(Event e) { 202 public void handleEvent(Event e) {
185 if (e.type !is DWT.Resize) return; 203 if (e.type !is DWT.Resize) return;
186 layout(false); 204 sc.layout(false);
187 } 205 }
188 }; 206 };
189 207
190 filter = new class() Listener { 208 filter = new class(this) Listener {
209 ScrolledComposite sc;
210
211 this (ScrolledComposite sc) {
212 this.sc = sc;
213 }
214
191 public void handleEvent(Event event) { 215 public void handleEvent(Event event) {
192 if (auto control = cast(Control)event.widget ) { 216 if (auto control = cast(Control)event.widget ) {
193 if (contains(control)) showControl(control); 217 if (contains(control)) sc.showControl(control);
194 } 218 }
195 } 219 }
196 }; 220 };
197 221
198 addDisposeListener(new class() DisposeListener { 222 addDisposeListener(new class(this) DisposeListener {
223 ScrolledComposite sc;
224
225 this (ScrolledComposite sc) {
226 this.sc = sc;
227 }
228
199 public void widgetDisposed(DisposeEvent e) { 229 public void widgetDisposed(DisposeEvent e) {
200 getDisplay().removeFilter(DWT.FocusIn, filter); 230 sc.getDisplay().removeFilter(DWT.FocusIn, filter);
201 } 231 }
202 }); 232 });
203 } 233 }
204 234
205 static int checkStyle (int style) { 235 static int checkStyle (int style) {