Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <tools/rc.h>
21 : #include <tools/poly.hxx>
22 :
23 : #include <vcl/event.hxx>
24 : #include <vcl/split.hxx>
25 : #include <vcl/svapp.hxx>
26 : #include <vcl/syswin.hxx>
27 : #include <vcl/taskpanelist.hxx>
28 : #include <vcl/gradient.hxx>
29 : #include <vcl/lineinfo.hxx>
30 :
31 : #include <rtl/instance.hxx>
32 :
33 : #include <window.h>
34 :
35 : namespace
36 : {
37 : struct ImplBlackWall
38 : : public rtl::StaticWithInit<Wallpaper, ImplBlackWall> {
39 27 : Wallpaper operator () () {
40 27 : return Wallpaper(COL_BLACK);
41 : }
42 : };
43 : struct ImplWhiteWall
44 : : public rtl::StaticWithInit<Wallpaper, ImplWhiteWall> {
45 0 : Wallpaper operator () () {
46 0 : return Wallpaper(COL_LIGHTGRAY);
47 : }
48 : };
49 : }
50 :
51 : // =======================================================================
52 :
53 407 : void Splitter::ImplInitSplitterData()
54 : {
55 407 : ImplGetWindowImpl()->mbSplitter = sal_True;
56 407 : mpRefWin = NULL;
57 407 : mnSplitPos = 0;
58 407 : mnLastSplitPos = 0;
59 407 : mnStartSplitPos = 0;
60 407 : mbDragFull = sal_False;
61 407 : mbKbdSplitting = sal_False;
62 407 : mbInKeyEvent = 0;
63 407 : mnKeyboardStepSize = SPLITTER_DEFAULTSTEPSIZE;
64 407 : }
65 :
66 : // -----------------------------------------------------------------------
67 :
68 : // Should only be called from a ImplInit method for initialization or
69 : // after checking bNew is different from the current mbHorzSplit value.
70 : // The public method that does that check is Splitter::SetHorizontal().
71 407 : void Splitter::ImplInitHorVer(bool bNew)
72 : {
73 407 : mbHorzSplit = bNew;
74 :
75 : PointerStyle ePointerStyle;
76 407 : const StyleSettings& rSettings = GetSettings().GetStyleSettings();
77 :
78 407 : if ( mbHorzSplit )
79 : {
80 204 : ePointerStyle = POINTER_HSPLIT;
81 204 : SetSizePixel( Size( rSettings.GetSplitSize(), rSettings.GetScrollBarSize() ) );
82 : }
83 : else
84 : {
85 203 : ePointerStyle = POINTER_VSPLIT;
86 203 : SetSizePixel( Size( rSettings.GetScrollBarSize(), rSettings.GetSplitSize() ) );
87 : }
88 :
89 407 : SetPointer( Pointer( ePointerStyle ) );
90 407 : }
91 :
92 : // -----------------------------------------------------------------------
93 :
94 407 : void Splitter::ImplInit( Window* pParent, WinBits nWinStyle )
95 : {
96 407 : Window::ImplInit( pParent, nWinStyle, NULL );
97 :
98 407 : mpRefWin = pParent;
99 :
100 407 : ImplInitHorVer(nWinStyle & WB_HSCROLL);
101 :
102 407 : if( GetSettings().GetStyleSettings().GetFaceColor().IsDark() )
103 0 : SetBackground( ImplWhiteWall::get() );
104 : else
105 407 : SetBackground( ImplBlackWall::get() );
106 :
107 407 : TaskPaneList *pTList = GetSystemWindow()->GetTaskPaneList();
108 407 : pTList->AddWindow( this );
109 407 : }
110 :
111 : // -----------------------------------------------------------------------
112 :
113 0 : void Splitter::ImplSplitMousePos( Point& rPos )
114 : {
115 0 : if ( mbHorzSplit )
116 : {
117 0 : if ( rPos.X() > maDragRect.Right()-1 )
118 0 : rPos.X() = maDragRect.Right()-1;
119 0 : if ( rPos.X() < maDragRect.Left()+1 )
120 0 : rPos.X() = maDragRect.Left()+1;
121 : }
122 : else
123 : {
124 0 : if ( rPos.Y() > maDragRect.Bottom()-1 )
125 0 : rPos.Y() = maDragRect.Bottom()-1;
126 0 : if ( rPos.Y() < maDragRect.Top()+1 )
127 0 : rPos.Y() = maDragRect.Top()+1;
128 : }
129 0 : }
130 :
131 : // -----------------------------------------------------------------------
132 :
133 0 : void Splitter::ImplDrawSplitter()
134 : {
135 0 : Rectangle aInvRect( maDragRect );
136 :
137 0 : if ( mbHorzSplit )
138 : {
139 0 : aInvRect.Left() = maDragPos.X() - 1;
140 0 : aInvRect.Right() = maDragPos.X() + 1;
141 : }
142 : else
143 : {
144 0 : aInvRect.Top() = maDragPos.Y() - 1;
145 0 : aInvRect.Bottom() = maDragPos.Y() + 1;
146 : }
147 :
148 0 : mpRefWin->InvertTracking( mpRefWin->PixelToLogic(aInvRect), SHOWTRACK_SPLIT );
149 0 : }
150 :
151 : // -----------------------------------------------------------------------
152 :
153 407 : Splitter::Splitter( Window* pParent, WinBits nStyle ) :
154 407 : Window( WINDOW_SPLITTER )
155 : {
156 407 : ImplInitSplitterData();
157 407 : ImplInit( pParent, nStyle );
158 :
159 407 : SetLineColor();
160 407 : SetFillColor();
161 407 : }
162 :
163 : // -----------------------------------------------------------------------
164 :
165 0 : Splitter::Splitter( Window* pParent, const ResId& rResId ) :
166 0 : Window( WINDOW_SPLITTER )
167 : {
168 0 : ImplInitSplitterData();
169 0 : rResId.SetRT( RSC_SPLITTER );
170 0 : WinBits nStyle = ImplInitRes( rResId );
171 0 : ImplInit( pParent, nStyle );
172 0 : ImplLoadRes( rResId );
173 :
174 0 : SetLineColor();
175 0 : SetFillColor();
176 :
177 0 : if ( !(nStyle & WB_HIDE) )
178 0 : Show();
179 0 : }
180 :
181 : // -----------------------------------------------------------------------
182 :
183 807 : Splitter::~Splitter()
184 : {
185 403 : TaskPaneList *pTList = GetSystemWindow()->GetTaskPaneList();
186 403 : pTList->RemoveWindow( this );
187 404 : }
188 :
189 : // -----------------------------------------------------------------------
190 :
191 0 : void Splitter::SetHorizontal(bool bNew)
192 : {
193 0 : if(bNew != (bool)mbHorzSplit)
194 : {
195 0 : ImplInitHorVer(bNew);
196 : }
197 0 : }
198 :
199 : // -----------------------------------------------------------------------
200 :
201 406 : void Splitter::SetKeyboardStepSize( long nStepSize )
202 : {
203 406 : mnKeyboardStepSize = nStepSize;
204 406 : }
205 :
206 : // -----------------------------------------------------------------------
207 :
208 0 : Splitter* Splitter::ImplFindSibling()
209 : {
210 : // look for another splitter with the same parent but different orientation
211 0 : Window *pWin = GetParent()->GetWindow( WINDOW_FIRSTCHILD );
212 0 : Splitter *pSplitter = NULL;
213 0 : while( pWin )
214 : {
215 0 : if( pWin->ImplIsSplitter() )
216 : {
217 0 : pSplitter = (Splitter*) pWin;
218 0 : if( pSplitter != this && IsHorizontal() != pSplitter->IsHorizontal() )
219 0 : return pSplitter;
220 : }
221 0 : pWin = pWin->GetWindow( WINDOW_NEXT );
222 : }
223 0 : return NULL;
224 : }
225 :
226 : // -----------------------------------------------------------------------
227 :
228 0 : sal_Bool Splitter::ImplSplitterActive()
229 : {
230 : // is splitter in document or at scrollbar handle ?
231 :
232 0 : sal_Bool bActive = sal_True;
233 0 : const StyleSettings& rSettings = GetSettings().GetStyleSettings();
234 0 : long nA = rSettings.GetScrollBarSize();
235 0 : long nB = rSettings.GetSplitSize();
236 :
237 0 : Size aSize = GetOutputSize();
238 0 : if ( mbHorzSplit )
239 : {
240 0 : if( aSize.Width() == nB && aSize.Height() == nA )
241 0 : bActive = sal_False;
242 : }
243 : else
244 : {
245 0 : if( aSize.Width() == nA && aSize.Height() == nB )
246 0 : bActive = sal_False;
247 : }
248 0 : return bActive;
249 : }
250 :
251 : // -----------------------------------------------------------------------
252 :
253 0 : void Splitter::MouseButtonDown( const MouseEvent& rMEvt )
254 : {
255 0 : if ( rMEvt.GetClicks() == 2 )
256 : {
257 0 : if ( mnLastSplitPos != mnSplitPos )
258 : {
259 0 : StartSplit();
260 0 : Point aPos = rMEvt.GetPosPixel();
261 0 : if ( mbHorzSplit )
262 0 : aPos.X() = mnLastSplitPos;
263 : else
264 0 : aPos.Y() = mnLastSplitPos;
265 0 : ImplSplitMousePos( aPos );
266 0 : Splitting( aPos );
267 0 : ImplSplitMousePos( aPos );
268 0 : long nTemp = mnSplitPos;
269 0 : if ( mbHorzSplit )
270 0 : SetSplitPosPixel( aPos.X() );
271 : else
272 0 : SetSplitPosPixel( aPos.Y() );
273 0 : mnLastSplitPos = nTemp;
274 0 : Split();
275 0 : EndSplit();
276 : }
277 : }
278 : else
279 0 : StartDrag();
280 0 : }
281 :
282 : // -----------------------------------------------------------------------
283 :
284 0 : void Splitter::Tracking( const TrackingEvent& rTEvt )
285 : {
286 0 : if ( rTEvt.IsTrackingEnded() )
287 : {
288 0 : if ( !mbDragFull )
289 0 : ImplDrawSplitter();
290 :
291 0 : if ( !rTEvt.IsTrackingCanceled() )
292 : {
293 : long nNewPos;
294 0 : if ( mbHorzSplit )
295 0 : nNewPos = maDragPos.X();
296 : else
297 0 : nNewPos = maDragPos.Y();
298 0 : if ( nNewPos != mnStartSplitPos )
299 : {
300 0 : SetSplitPosPixel( nNewPos );
301 0 : mnLastSplitPos = 0;
302 0 : Split();
303 : }
304 0 : EndSplit();
305 : }
306 0 : else if ( mbDragFull )
307 : {
308 0 : SetSplitPosPixel( mnStartSplitPos );
309 0 : Split();
310 : }
311 0 : mnStartSplitPos = 0;
312 : }
313 : else
314 : {
315 : //Point aNewPos = mpRefWin->ScreenToOutputPixel( OutputToScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
316 0 : Point aNewPos = mpRefWin->NormalizedScreenToOutputPixel( OutputToNormalizedScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
317 0 : ImplSplitMousePos( aNewPos );
318 0 : Splitting( aNewPos );
319 0 : ImplSplitMousePos( aNewPos );
320 :
321 0 : if ( mbHorzSplit )
322 : {
323 0 : if ( aNewPos.X() == maDragPos.X() )
324 0 : return;
325 : }
326 : else
327 : {
328 0 : if ( aNewPos.Y() == maDragPos.Y() )
329 0 : return;
330 : }
331 :
332 0 : if ( mbDragFull )
333 : {
334 0 : maDragPos = aNewPos;
335 : long nNewPos;
336 0 : if ( mbHorzSplit )
337 0 : nNewPos = maDragPos.X();
338 : else
339 0 : nNewPos = maDragPos.Y();
340 0 : if ( nNewPos != mnSplitPos )
341 : {
342 0 : SetSplitPosPixel( nNewPos );
343 0 : mnLastSplitPos = 0;
344 0 : Split();
345 : }
346 :
347 0 : GetParent()->Update();
348 : }
349 : else
350 : {
351 0 : ImplDrawSplitter();
352 0 : maDragPos = aNewPos;
353 0 : ImplDrawSplitter();
354 : }
355 : }
356 : }
357 :
358 : // -----------------------------------------------------------------------
359 :
360 0 : void Splitter::ImplKbdTracking( KeyCode aKeyCode )
361 : {
362 0 : sal_uInt16 nCode = aKeyCode.GetCode();
363 0 : if ( nCode == KEY_ESCAPE || nCode == KEY_RETURN )
364 : {
365 0 : if( !mbKbdSplitting )
366 0 : return;
367 : else
368 0 : mbKbdSplitting = sal_False;
369 :
370 0 : if ( nCode != KEY_ESCAPE )
371 : {
372 : long nNewPos;
373 0 : if ( mbHorzSplit )
374 0 : nNewPos = maDragPos.X();
375 : else
376 0 : nNewPos = maDragPos.Y();
377 0 : if ( nNewPos != mnStartSplitPos )
378 : {
379 0 : SetSplitPosPixel( nNewPos );
380 0 : mnLastSplitPos = 0;
381 0 : Split();
382 : }
383 : }
384 : else
385 : {
386 0 : SetSplitPosPixel( mnStartSplitPos );
387 0 : Split();
388 0 : EndSplit();
389 : }
390 0 : mnStartSplitPos = 0;
391 : }
392 : else
393 : {
394 0 : Point aNewPos;
395 0 : Size aSize = mpRefWin->GetOutputSize();
396 0 : Point aPos = GetPosPixel();
397 : // depending on the position calc allows continous moves or snaps to row/columns
398 : // continous mode is active when position is at the origin or end of the splitter
399 : // otherwise snap mode is active
400 : // default here is snap, holding shift sets continous mode
401 0 : if( mbHorzSplit )
402 0 : aNewPos = Point( ImplSplitterActive() ? aPos.X() : mnSplitPos, aKeyCode.IsShift() ? 0 : aSize.Height()/2);
403 : else
404 0 : aNewPos = Point( aKeyCode.IsShift() ? 0 : aSize.Width()/2, ImplSplitterActive() ? aPos.Y() : mnSplitPos );
405 :
406 0 : Point aOldWindowPos = GetPosPixel();
407 :
408 0 : int maxiter = 500; // avoid endless loop
409 0 : int delta=0;
410 0 : int delta_step = mbHorzSplit ? aSize.Width()/10 : aSize.Height()/10;
411 :
412 : // use the specified step size if it was set
413 0 : if( mnKeyboardStepSize != SPLITTER_DEFAULTSTEPSIZE )
414 0 : delta_step = mnKeyboardStepSize;
415 :
416 0 : while( maxiter-- && aOldWindowPos == GetPosPixel() )
417 : {
418 : // inc/dec position until application performs changes
419 : // thus a single key press really moves the splitter
420 0 : if( aKeyCode.IsShift() )
421 0 : delta++;
422 : else
423 0 : delta += delta_step;
424 :
425 0 : switch( nCode )
426 : {
427 : case KEY_LEFT:
428 0 : aNewPos.X()-=delta;
429 0 : break;
430 : case KEY_RIGHT:
431 0 : aNewPos.X()+=delta;
432 0 : break;
433 : case KEY_UP:
434 0 : aNewPos.Y()-=delta;
435 0 : break;
436 : case KEY_DOWN:
437 0 : aNewPos.Y()+=delta;
438 0 : break;
439 : default:
440 0 : maxiter = 0; // leave loop
441 0 : break;
442 : }
443 0 : ImplSplitMousePos( aNewPos );
444 0 : Splitting( aNewPos );
445 0 : ImplSplitMousePos( aNewPos );
446 :
447 0 : if ( mbHorzSplit )
448 : {
449 0 : if ( aNewPos.X() == maDragPos.X() )
450 0 : continue;
451 : }
452 : else
453 : {
454 0 : if ( aNewPos.Y() == maDragPos.Y() )
455 0 : continue;
456 : }
457 :
458 0 : maDragPos = aNewPos;
459 : long nNewPos;
460 0 : if ( mbHorzSplit )
461 0 : nNewPos = maDragPos.X();
462 : else
463 0 : nNewPos = maDragPos.Y();
464 0 : if ( nNewPos != mnSplitPos )
465 : {
466 0 : SetSplitPosPixel( nNewPos );
467 0 : mnLastSplitPos = 0;
468 0 : Split();
469 : }
470 0 : GetParent()->Update();
471 : }
472 : }
473 : }
474 :
475 : // -----------------------------------------------------------------------
476 :
477 0 : void Splitter::StartSplit()
478 : {
479 0 : maStartSplitHdl.Call( this );
480 0 : }
481 :
482 : // -----------------------------------------------------------------------
483 :
484 0 : void Splitter::Split()
485 : {
486 0 : maSplitHdl.Call( this );
487 0 : }
488 :
489 : // -----------------------------------------------------------------------
490 :
491 0 : void Splitter::EndSplit()
492 : {
493 0 : if ( maEndSplitHdl.IsSet() )
494 0 : maEndSplitHdl.Call( this );
495 0 : }
496 :
497 : // -----------------------------------------------------------------------
498 :
499 0 : void Splitter::Splitting( Point& /* rSplitPos */ )
500 : {
501 0 : }
502 :
503 : // -----------------------------------------------------------------------
504 :
505 1562 : void Splitter::SetDragRectPixel( const Rectangle& rDragRect, Window* _pRefWin )
506 : {
507 1562 : maDragRect = rDragRect;
508 1562 : if ( !_pRefWin )
509 7 : mpRefWin = GetParent();
510 : else
511 1555 : mpRefWin = _pRefWin;
512 1562 : }
513 :
514 : // -----------------------------------------------------------------------
515 :
516 1 : void Splitter::SetSplitPosPixel( long nNewPos )
517 : {
518 1 : mnSplitPos = nNewPos;
519 1 : }
520 :
521 : // -----------------------------------------------------------------------
522 :
523 0 : void Splitter::StartDrag()
524 : {
525 0 : if ( IsTracking() )
526 0 : return;
527 :
528 0 : StartSplit();
529 :
530 : // Tracking starten
531 0 : StartTracking();
532 :
533 : // Start-Positon ermitteln
534 0 : maDragPos = mpRefWin->GetPointerPosPixel();
535 0 : ImplSplitMousePos( maDragPos );
536 0 : Splitting( maDragPos );
537 0 : ImplSplitMousePos( maDragPos );
538 0 : if ( mbHorzSplit )
539 0 : mnStartSplitPos = maDragPos.X();
540 : else
541 0 : mnStartSplitPos = maDragPos.Y();
542 :
543 0 : mbDragFull = (Application::GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SPLIT) != 0;
544 0 : if ( !mbDragFull )
545 0 : ImplDrawSplitter();
546 : }
547 :
548 :
549 : // -----------------------------------------------------------------------
550 :
551 0 : void Splitter::ImplStartKbdSplitting()
552 : {
553 0 : if( mbKbdSplitting )
554 0 : return;
555 :
556 0 : mbKbdSplitting = sal_True;
557 :
558 0 : StartSplit();
559 :
560 : // determine start position
561 : // because we have no mouse position we take either the position
562 : // of the splitter window or the last split position
563 : // the other coordinate is just the center of the reference window
564 0 : Size aSize = mpRefWin->GetOutputSize();
565 0 : Point aPos = GetPosPixel();
566 0 : if( mbHorzSplit )
567 0 : maDragPos = Point( ImplSplitterActive() ? aPos.X() : mnSplitPos, aSize.Height()/2 );
568 : else
569 0 : maDragPos = Point( aSize.Width()/2, ImplSplitterActive() ? aPos.Y() : mnSplitPos );
570 0 : ImplSplitMousePos( maDragPos );
571 0 : Splitting( maDragPos );
572 0 : ImplSplitMousePos( maDragPos );
573 0 : if ( mbHorzSplit )
574 0 : mnStartSplitPos = maDragPos.X();
575 : else
576 0 : mnStartSplitPos = maDragPos.Y();
577 : }
578 :
579 : // -----------------------------------------------------------------------
580 :
581 0 : void Splitter::ImplRestoreSplitter()
582 : {
583 : // set splitter in the center of the ref window
584 0 : StartSplit();
585 0 : Size aSize = mpRefWin->GetOutputSize();
586 0 : Point aPos = Point( aSize.Width()/2 , aSize.Height()/2);
587 0 : if ( mnLastSplitPos != mnSplitPos && mnLastSplitPos > 5 )
588 : {
589 : // restore last pos if it was a useful position (>5)
590 0 : if ( mbHorzSplit )
591 0 : aPos.X() = mnLastSplitPos;
592 : else
593 0 : aPos.Y() = mnLastSplitPos;
594 : }
595 :
596 0 : ImplSplitMousePos( aPos );
597 0 : Splitting( aPos );
598 0 : ImplSplitMousePos( aPos );
599 0 : long nTemp = mnSplitPos;
600 0 : if ( mbHorzSplit )
601 0 : SetSplitPosPixel( aPos.X() );
602 : else
603 0 : SetSplitPosPixel( aPos.Y() );
604 0 : mnLastSplitPos = nTemp;
605 0 : Split();
606 0 : EndSplit();
607 0 : }
608 :
609 :
610 : // -----------------------------------------------------------------------
611 :
612 0 : void Splitter::GetFocus()
613 : {
614 0 : if( !ImplSplitterActive() )
615 0 : ImplRestoreSplitter();
616 :
617 0 : Invalidate();
618 0 : }
619 :
620 : // -----------------------------------------------------------------------
621 :
622 0 : void Splitter::LoseFocus()
623 : {
624 0 : if( mbKbdSplitting )
625 : {
626 0 : KeyCode aReturnKey( KEY_RETURN );
627 0 : ImplKbdTracking( aReturnKey );
628 0 : mbKbdSplitting = sal_False;
629 : }
630 0 : Invalidate();
631 0 : }
632 :
633 : // -----------------------------------------------------------------------
634 :
635 0 : void Splitter::KeyInput( const KeyEvent& rKEvt )
636 : {
637 0 : if( mbInKeyEvent )
638 0 : return;
639 :
640 0 : mbInKeyEvent = 1;
641 :
642 0 : Splitter *pSibling = ImplFindSibling();
643 0 : KeyCode aKeyCode = rKEvt.GetKeyCode();
644 0 : sal_uInt16 nCode = aKeyCode.GetCode();
645 0 : switch ( nCode )
646 : {
647 : case KEY_UP:
648 : case KEY_DOWN:
649 0 : if( !mbHorzSplit )
650 : {
651 0 : ImplStartKbdSplitting();
652 0 : ImplKbdTracking( aKeyCode );
653 : }
654 : else
655 : {
656 0 : if( pSibling )
657 : {
658 0 : pSibling->GrabFocus();
659 0 : pSibling->KeyInput( rKEvt );
660 : }
661 : }
662 0 : break;
663 : case KEY_RIGHT:
664 : case KEY_LEFT:
665 0 : if( mbHorzSplit )
666 : {
667 0 : ImplStartKbdSplitting();
668 0 : ImplKbdTracking( aKeyCode );
669 : }
670 : else
671 : {
672 0 : if( pSibling )
673 : {
674 0 : pSibling->GrabFocus();
675 0 : pSibling->KeyInput( rKEvt );
676 : }
677 : }
678 0 : break;
679 :
680 : case KEY_DELETE:
681 0 : if( ImplSplitterActive() )
682 : {
683 0 : if( mbKbdSplitting )
684 : {
685 0 : KeyCode aKey( KEY_ESCAPE );
686 0 : ImplKbdTracking( aKey );
687 : }
688 :
689 0 : StartSplit();
690 0 : Point aPos;
691 0 : if ( mbHorzSplit )
692 0 : aPos.X() = 0;
693 : else
694 0 : aPos.Y() = 0;
695 0 : ImplSplitMousePos( aPos );
696 0 : Splitting( aPos );
697 0 : ImplSplitMousePos( aPos );
698 0 : long nTemp = mnSplitPos;
699 0 : if ( mbHorzSplit )
700 0 : SetSplitPosPixel( aPos.X() );
701 : else
702 0 : SetSplitPosPixel( aPos.Y() );
703 0 : mnLastSplitPos = nTemp;
704 0 : Split();
705 0 : EndSplit();
706 :
707 : // Shift-Del deletes both splitters
708 0 : if( aKeyCode.IsShift() && pSibling )
709 0 : pSibling->KeyInput( rKEvt );
710 :
711 0 : GrabFocusToDocument();
712 : }
713 0 : break;
714 :
715 : case KEY_ESCAPE:
716 0 : if( mbKbdSplitting )
717 0 : ImplKbdTracking( aKeyCode );
718 : else
719 0 : GrabFocusToDocument();
720 0 : break;
721 :
722 : case KEY_RETURN:
723 0 : ImplKbdTracking( aKeyCode );
724 0 : GrabFocusToDocument();
725 0 : break;
726 : default: // let any key input fix the splitter
727 0 : Window::KeyInput( rKEvt );
728 0 : GrabFocusToDocument();
729 0 : break;
730 : }
731 0 : mbInKeyEvent = 0;
732 : }
733 :
734 : // -----------------------------------------------------------------------
735 :
736 50 : long Splitter::Notify( NotifyEvent& rNEvt )
737 : {
738 50 : return Window::Notify( rNEvt );
739 : }
740 :
741 : // -----------------------------------------------------------------------
742 :
743 0 : void Splitter::DataChanged( const DataChangedEvent& rDCEvt )
744 : {
745 0 : Window::DataChanged( rDCEvt );
746 0 : if( rDCEvt.GetType() == DATACHANGED_SETTINGS )
747 : {
748 0 : const AllSettings* pOldSettings = rDCEvt.GetOldSettings();
749 0 : if(!pOldSettings)
750 0 : return;
751 :
752 0 : Color oldFaceColor = pOldSettings->GetStyleSettings().GetFaceColor();
753 0 : Color newFaceColor = Application::GetSettings().GetStyleSettings().GetFaceColor();
754 0 : if( oldFaceColor.IsDark() != newFaceColor.IsDark() )
755 : {
756 0 : if( newFaceColor.IsDark() )
757 0 : SetBackground( ImplWhiteWall::get() );
758 : else
759 0 : SetBackground( ImplBlackWall::get() );
760 : }
761 : }
762 : }
763 :
764 : // -----------------------------------------------------------------------
765 :
766 1 : void Splitter::Paint( const Rectangle& rPaintRect )
767 : {
768 1 : DrawRect( rPaintRect );
769 :
770 1 : Polygon aPoly( rPaintRect );
771 2 : PolyPolygon aPolyPoly( aPoly );
772 1 : DrawTransparent( aPolyPoly, 85 );
773 :
774 1 : if( mbKbdSplitting )
775 : {
776 0 : LineInfo aInfo( LINE_DASH );
777 : //aInfo.SetDashLen( 2 );
778 : //aInfo.SetDashCount( 1 );
779 0 : aInfo.SetDistance( 1 );
780 0 : aInfo.SetDotLen( 2 );
781 0 : aInfo.SetDotCount( 3 );
782 :
783 0 : DrawPolyLine( aPoly, aInfo );
784 : }
785 : else
786 : {
787 1 : DrawRect( rPaintRect );
788 1 : }
789 466 : }
790 :
791 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|