summaryrefslogtreecommitdiff
path: root/vcl/source/control
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/control')
-rw-r--r--vcl/source/control/button.cxx57
-rw-r--r--vcl/source/control/fixed.cxx28
-rw-r--r--vcl/source/control/slider.cxx71
-rw-r--r--vcl/source/control/tabctrl.cxx100
4 files changed, 179 insertions, 77 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 1cda2308aa9c..08759f37d7a6 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -367,7 +367,8 @@ USHORT Button::ImplGetTextStyle( XubString& rText, WinBits nWinStyle,
void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos,
Size& rSize, BOOL bLayout,
ULONG nImageSep, ULONG nDrawFlags,
- USHORT nTextStyle, Rectangle *pSymbolRect )
+ USHORT nTextStyle, Rectangle *pSymbolRect,
+ bool bAddImageSep )
{
XubString aText( GetText() );
BOOL bDrawImage = HasImage() && ! ( ImplGetButtonState() & BUTTON_DRAW_NOIMAGE );
@@ -502,6 +503,13 @@ void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos,
if ( aTSSize.Height() < aTextSize.Height() )
aTSSize.Height() = aTextSize.Height();
+
+ if( bAddImageSep && bDrawImage )
+ {
+ long nDiff = (aImageSize.Height() - aTextSize.Height()) / 3;
+ if( nDiff > 0 )
+ nImageSep += nDiff;
+ }
}
aMax.Width() = aTSSize.Width() > aImageSize.Width() ? aTSSize.Width() : aImageSize.Width();
@@ -880,7 +888,9 @@ void PushButton::ImplInitSettings( BOOL bFont,
EnableChildTransparentMode( TRUE );
SetParentClipMode( PARENTCLIPMODE_NOCLIP );
SetPaintTransparent( TRUE );
- mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
+ mpWindowImpl->mbUseNativeFocus = (GetStyle() & WB_FLATBUTTON)
+ ? false
+ : ImplGetSVData()->maNWFData.mbNoFocusRects;
}
else
{
@@ -1191,8 +1201,13 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, ULONG nDrawFlags
else
{
Rectangle aSymbolRect;
- ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1, nDrawFlags,
- nTextStyle, IsSymbol() ? &aSymbolRect : NULL );
+ ULONG nImageSep = 1 + (pDev->GetTextHeight()-10)/2;
+ if( nImageSep < 1 )
+ nImageSep = 1;
+ // FIXME: (GetStyle() & WB_FLATBUTTON) != 0 is preliminary
+ // in the next major this should be replaced by "true"
+ ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags,
+ nTextStyle, IsSymbol() ? &aSymbolRect : NULL, (GetStyle() & WB_FLATBUTTON) != 0 );
if ( IsSymbol() && ! bLayout )
{
@@ -1320,6 +1335,7 @@ void PushButton::ImplDrawPushButton( bool bLayout )
if( bNativeOK )
return;
+ bool bRollOver = (IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ));
if ( (bNativeOK=IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == TRUE )
{
PushButtonValue aPBVal;
@@ -1334,7 +1350,7 @@ void PushButton::ImplDrawPushButton( bool bLayout )
if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT;
if ( Window::IsEnabled() ) nState |= CTRL_STATE_ENABLED;
- if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) )
+ if ( bRollOver )
nState |= CTRL_STATE_ROLLOVER;
if( GetStyle() & WB_BEVELBUTTON )
@@ -1359,8 +1375,15 @@ void PushButton::ImplDrawPushButton( bool bLayout )
Size aInRectSize( LogicToPixel( Size( aInRect.GetWidth(), aInRect.GetHeight() ) ) );
aPBVal.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() );
- bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
- aControlValue, rtl::OUString()/*PushButton::GetText()*/ );
+ if( ((nState & CTRL_STATE_ROLLOVER)) || ! (GetStyle() & WB_FLATBUTTON) )
+ {
+ bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
+ aControlValue, rtl::OUString()/*PushButton::GetText()*/ );
+ }
+ else
+ {
+ bNativeOK = true;
+ }
// draw content using the same aInRect as non-native VCL would do
ImplDrawPushButtonContent( this,
@@ -1374,8 +1397,21 @@ void PushButton::ImplDrawPushButton( bool bLayout )
if ( bNativeOK == FALSE )
{
// draw PushButtonFrame, aInRect has content size afterwards
- if( ! bLayout )
- ImplDrawPushButtonFrame( this, aInRect, nButtonStyle );
+ if( (GetStyle() & WB_FLATBUTTON) )
+ {
+ Rectangle aTempRect( aInRect );
+ if( ! bLayout && bRollOver )
+ ImplDrawPushButtonFrame( this, aTempRect, nButtonStyle );
+ aInRect.Left() += 2;
+ aInRect.Top() += 2;
+ aInRect.Right() -= 2;
+ aInRect.Bottom() -= 2;
+ }
+ else
+ {
+ if( ! bLayout )
+ ImplDrawPushButtonFrame( this, aInRect, nButtonStyle );
+ }
// draw content
ImplDrawPushButtonContent( this, 0, aInRect, bLayout );
@@ -1855,7 +1891,8 @@ long PushButton::PreNotify( NotifyEvent& rNEvt )
pBorder->Update();
}
}
- else if( IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL) )
+ else if( (GetStyle() & WB_FLATBUTTON) ||
+ IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL) )
{
Invalidate();
}
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 4b83540c1aa1..37406293d7cf 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -496,16 +496,11 @@ void FixedLine::ImplDraw( bool bLayout )
{
Size aOutSize = GetOutputSizePixel();
String aText = GetText();
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
WinBits nWinStyle = GetStyle();
MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
- if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
- SetLineColor( Color( COL_BLACK ) );
- else
- SetLineColor( rStyleSettings.GetShadowColor() );
-
+ DecorationView aDecoView( this );
if ( !aText.Len() || (nWinStyle & WB_VERT) )
{
if( !pVector )
@@ -516,21 +511,12 @@ void FixedLine::ImplDraw( bool bLayout )
if ( nWinStyle & WB_VERT )
{
nX = (aOutSize.Width()-1)/2;
- DrawLine( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) );
+ aDecoView.DrawSeparator( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) );
}
else
{
nY = (aOutSize.Height()-1)/2;
- DrawLine( Point( 0, nY ), Point( aOutSize.Width()-1, nY ) );
- }
-
- if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
- {
- SetLineColor( rStyleSettings.GetLightColor() );
- if ( nWinStyle & WB_VERT )
- DrawLine( Point( nX+1, 0 ), Point( nX+1, aOutSize.Height()-1 ) );
- else
- DrawLine( Point( 0, nY+1 ), Point( aOutSize.Width()-1, nY+1 ) );
+ aDecoView.DrawSeparator( Point( 0, nY ), Point( aOutSize.Width()-1, nY ), false );
}
}
}
@@ -538,6 +524,7 @@ void FixedLine::ImplDraw( bool bLayout )
{
USHORT nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS;
Rectangle aRect( 0, 0, aOutSize.Width(), aOutSize.Height() );
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if ( !IsEnabled() )
nStyle |= TEXT_DRAW_DISABLE;
@@ -551,12 +538,7 @@ void FixedLine::ImplDraw( bool bLayout )
if( !pVector )
{
long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2);
- DrawLine( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ) );
- if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
- {
- SetLineColor( rStyleSettings.GetLightColor() );
- DrawLine( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop+1 ), Point( aOutSize.Width()-1, nTop+1 ) );
- }
+ aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false );
}
}
}
diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx
index 5e7e9709607f..2390a8e3e9a6 100644
--- a/vcl/source/control/slider.cxx
+++ b/vcl/source/control/slider.cxx
@@ -168,6 +168,7 @@ void Slider::ImplInitSettings()
void Slider::ImplUpdateRects( BOOL bUpdate )
{
Rectangle aOldThumbRect = maThumbRect;
+ bool bInvalidateAll = false;
if ( mnThumbPixRange )
{
@@ -193,6 +194,18 @@ void Slider::ImplUpdateRects( BOOL bUpdate )
}
else
maChannel2Rect.SetEmpty();
+
+ const Region aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) );
+ Region aThumbBounds, aThumbContent;
+ if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_HORZ,
+ aControlRegion, 0, ImplControlValue(), rtl::OUString(),
+ aThumbBounds, aThumbContent ) )
+ {
+ Rectangle aRect( aThumbBounds.GetBoundRect() );
+ maThumbRect.Left() = mnThumbPixPos - aRect.GetWidth()/2;
+ maThumbRect.Right() = maThumbRect.Left() + aRect.GetWidth() - 1;
+ bInvalidateAll = true;
+ }
}
else
{
@@ -216,6 +229,18 @@ void Slider::ImplUpdateRects( BOOL bUpdate )
}
else
maChannel2Rect.SetEmpty();
+
+ const Region aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) );
+ Region aThumbBounds, aThumbContent;
+ if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_VERT,
+ aControlRegion, 0, ImplControlValue(), rtl::OUString(),
+ aThumbBounds, aThumbContent ) )
+ {
+ Rectangle aRect( aThumbBounds.GetBoundRect() );
+ maThumbRect.Top() = mnThumbPixPos - aRect.GetHeight()/2;
+ maThumbRect.Bottom() = maThumbRect.Top() + aRect.GetHeight() - 1;
+ bInvalidateAll = true;
+ }
}
}
else
@@ -229,17 +254,22 @@ void Slider::ImplUpdateRects( BOOL bUpdate )
{
if ( aOldThumbRect != maThumbRect )
{
- Region aInvalidRegion( aOldThumbRect );
- aInvalidRegion.Union( maThumbRect );
-
- if( !IsBackground() && GetParent() )
+ if( bInvalidateAll )
+ Invalidate();
+ else
{
- const Point aPos( GetPosPixel() );
- aInvalidRegion.Move( aPos.X(), aPos.Y() );
- GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE );
+ Region aInvalidRegion( aOldThumbRect );
+ aInvalidRegion.Union( maThumbRect );
+
+ if( !IsBackground() && GetParent() )
+ {
+ const Point aPos( GetPosPixel() );
+ aInvalidRegion.Move( aPos.X(), aPos.Y() );
+ GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE );
+ }
+ else
+ Invalidate( aInvalidRegion );
}
- else
- Invalidate( aInvalidRegion );
}
}
}
@@ -357,6 +387,29 @@ void Slider::ImplDraw( USHORT nDrawFlags )
if ( mbCalcSize )
ImplCalc( FALSE );
+ ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA;
+ ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 );
+ ControlState nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 );
+ SliderValue sldValue;
+
+ sldValue.mnMin = mnMinRange;
+ sldValue.mnMax = mnMaxRange;
+ sldValue.mnCur = mnThumbPos;
+ sldValue.maThumbRect = maThumbRect;
+
+ if( IsMouseOver() )
+ {
+ if( maThumbRect.IsInside( GetPointerPosPixel() ) )
+ sldValue.mnThumbState |= CTRL_STATE_ROLLOVER;
+ }
+ aControlValue.setOptionalVal( (void *)(&sldValue) );
+
+ const Region aCtrlRegion( Rectangle( Point(0,0), GetOutputSizePixel() ) );
+ bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart,
+ aCtrlRegion, nState, aControlValue, rtl::OUString() );
+ if( bNativeOK )
+ return;
+
if ( (nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty() )
{
long nRectSize;
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 5c08cdb8a36b..741267044829 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -174,6 +174,9 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle )
// otherwise they will paint with a wrong background
if( IsNativeControlSupported(CTRL_TAB_PANE, PART_ENTIRE_CONTROL) )
EnableChildTransparentMode( TRUE );
+
+ if ( pParent->IsDialog() )
+ pParent->AddChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) );
}
// -----------------------------------------------------------------
@@ -288,6 +291,9 @@ void TabControl::ImplLoadRes( const ResId& rResId )
TabControl::~TabControl()
{
+ if ( GetParent()->IsDialog() )
+ GetParent()->RemoveChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) );
+
ImplFreeLayoutData();
// TabCtrl-Daten loeschen
@@ -1070,6 +1076,42 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo
// -----------------------------------------------------------------------
+long TabControl::ImplHandleKeyEvent( const KeyEvent& rKeyEvent )
+{
+ long nRet = 0;
+
+ if ( GetPageCount() > 1 )
+ {
+ KeyCode aKeyCode = rKeyEvent.GetKeyCode();
+ USHORT nKeyCode = aKeyCode.GetCode();
+
+ if ( aKeyCode.IsMod1() )
+ {
+ if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
+ {
+ if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
+ {
+ ImplActivateTabPage( FALSE );
+ nRet = 1;
+ }
+ }
+ else
+ {
+ if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
+ {
+ ImplActivateTabPage( TRUE );
+ nRet = 1;
+ }
+ }
+ }
+ }
+
+ return nRet;
+}
+
+
+// -----------------------------------------------------------------------
+
IMPL_LINK( TabControl, ImplScrollBtnHdl, PushButton*, EMPTYARG )
{
ImplSetScrollBtnsState();
@@ -1086,6 +1128,24 @@ IMPL_LINK( TabControl, ImplListBoxSelectHdl, ListBox*, EMPTYARG )
// -----------------------------------------------------------------------
+IMPL_LINK( TabControl, ImplWindowEventListener, VclSimpleEvent*, pEvent )
+{
+ if ( pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() == VCLEVENT_WINDOW_KEYINPUT) )
+ {
+ VclWindowEvent* pWindowEvent = static_cast< VclWindowEvent* >(pEvent);
+ // Do not handle events from TabControl or it's children, which is done in Notify(), where the events can be consumed.
+ if ( !IsWindowOrChild( pWindowEvent->GetWindow() ) )
+ {
+ KeyEvent* pKeyEvent = static_cast< KeyEvent* >(pWindowEvent->GetData());
+ ImplHandleKeyEvent( *pKeyEvent );
+ }
+ }
+ return 0;
+}
+
+
+// -----------------------------------------------------------------------
+
void TabControl::MouseButtonDown( const MouseEvent& rMEvt )
{
if( mpTabCtrlData->mpListBox == NULL )
@@ -1655,44 +1715,14 @@ long TabControl::PreNotify( NotifyEvent& rNEvt )
// -----------------------------------------------------------------------
-bool TabControl::ImplHandleNotifyEvent( NotifyEvent& rNEvt )
-{
- if ( (rNEvt.GetType() == EVENT_KEYINPUT) && (GetPageCount() > 1) )
- {
- const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
- KeyCode aKeyCode = pKEvt->GetKeyCode();
- USHORT nKeyCode = aKeyCode.GetCode();
-
- if ( aKeyCode.IsMod1() )
- {
- if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
- {
- if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
- {
- ImplActivateTabPage( FALSE );
- return TRUE;
- }
- }
- else
- {
- if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
- {
- ImplActivateTabPage( TRUE );
- return TRUE;
- }
- }
- }
- }
- return false;
-}
-
-
-// -----------------------------------------------------------------------
-
long TabControl::Notify( NotifyEvent& rNEvt )
{
+ long nRet = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ nRet = ImplHandleKeyEvent( *rNEvt.GetKeyEvent() );
- return ImplHandleNotifyEvent( rNEvt ) ? TRUE : Control::Notify( rNEvt );
+ return nRet ? nRet : Control::Notify( rNEvt );
}
// -----------------------------------------------------------------------