let the pixel control find parent tabpage in layout

Change-Id: I3097e7d33bdf1331a71621af6dee823a803a17b7
This commit is contained in:
Caolán McNamara
2013-07-29 10:28:11 +01:00
parent 802c52fb98
commit adf9406450
3 changed files with 35 additions and 16 deletions

View File

@@ -184,6 +184,8 @@ public:
virtual void Paint( const Rectangle& rRect ); virtual void Paint( const Rectangle& rRect );
virtual void MouseButtonDown( const MouseEvent& rMEvt ); virtual void MouseButtonDown( const MouseEvent& rMEvt );
virtual void Resize();
virtual Size GetOptimalSize() const;
void SetXBitmap( const BitmapEx& rBitmapEx ); void SetXBitmap( const BitmapEx& rBitmapEx );

View File

@@ -755,7 +755,7 @@ VCL_DLLPUBLIC bool isInitialLayout(const Window *pWindow);
Size getLegacyBestSizeForChildren(const Window &rWindow); Size getLegacyBestSizeForChildren(const Window &rWindow);
//Get first parent which is not a layout widget //Get first parent which is not a layout widget
Window* getNonLayoutParent(Window *pParent); VCL_DLLPUBLIC Window* getNonLayoutParent(Window *pParent);
//Get first real parent which is not a layout widget //Get first real parent which is not a layout widget
Window* getNonLayoutRealParent(Window *pParent); Window* getNonLayoutRealParent(Window *pParent);

View File

@@ -362,8 +362,9 @@ void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
{ {
SetActualRP( eNewRP ); SetActualRP( eNewRP );
if( WINDOW_TABPAGE == GetParent()->GetType() ) Window *pTabPage = getNonLayoutParent(this);
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
((SvxTabPage*) pTabPage)->PointChanged(this, eRP);
SetFocusRect(); SetFocusRect();
} }
@@ -676,8 +677,9 @@ void SvxRectCtl::SetState( CTL_STATE nState )
eRP = GetRPFromPoint( _aPtNew ); eRP = GetRPFromPoint( _aPtNew );
Invalidate(); Invalidate();
if( WINDOW_TABPAGE == GetParent()->GetType() ) Window *pTabPage = getNonLayoutParent(this);
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
((SvxTabPage*)pTabPage)->PointChanged(this, eRP);
} }
sal_uInt8 SvxRectCtl::GetNumOfChildren( void ) const sal_uInt8 SvxRectCtl::GetNumOfChildren( void ) const
@@ -766,14 +768,11 @@ SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumb
memset(pPixel, 0, nSquares * sizeof(sal_uInt16)); memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
} }
SvxPixelCtl::SvxPixelCtl( Window* pParent, sal_uInt16 nNumber ) : SvxPixelCtl::SvxPixelCtl(Window* pParent, sal_uInt16 nNumber)
Control ( pParent, WB_BORDER ), : Control(pParent, WB_BORDER)
nLines ( nNumber ), , nLines(nNumber)
bPaintable ( sal_True ) , bPaintable(true)
{ {
//aRectSize = GetOutputSize();
aRectSize = LogicToPixel(Size(72, 72), MAP_APPFONT);
SetPixelColor( Color( COL_BLACK ) ); SetPixelColor( Color( COL_BLACK ) );
SetBackgroundColor( Color( COL_WHITE ) ); SetBackgroundColor( Color( COL_WHITE ) );
SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() ); SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
@@ -783,9 +782,20 @@ bPaintable ( sal_True )
memset(pPixel, 0, nSquares * sizeof(sal_uInt16)); memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
} }
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxPixelCtl(Window *pParent, sal_uInt16 nNumber) void SvxPixelCtl::Resize()
{ {
return new SvxPixelCtl(pParent, 8 ); //nNumber); Control::Resize();
aRectSize = GetOutputSize();
}
Size SvxPixelCtl::GetOptimalSize() const
{
return LogicToPixel(Size(72, 72), MAP_APPFONT);
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxPixelCtl(Window *pParent, VclBuilder::stringmap&)
{
return new SvxPixelCtl(pParent, 8);
} }
// Destructor dealocating the dynamic array // Destructor dealocating the dynamic array
@@ -808,6 +818,9 @@ void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt ) void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
{ {
if (!aRectSize.Width() || !aRectSize.Height())
return;
Point aPt = PixelToLogic( rMEvt.GetPosPixel() ); Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
Point aPtTl, aPtBr; Point aPtTl, aPtBr;
sal_uInt16 nX, nY; sal_uInt16 nX, nY;
@@ -824,14 +837,18 @@ void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
Invalidate( Rectangle( aPtTl, aPtBr ) ); Invalidate( Rectangle( aPtTl, aPtBr ) );
if( WINDOW_TABPAGE == GetParent()->GetType() ) Window *pTabPage = getNonLayoutParent(this);
( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint is a dummy if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
((SvxTabPage*)pTabPage)->PointChanged(this, RP_MM); // RectPoint is a dummy
} }
// Draws the Control (Rectangle with nine circles) // Draws the Control (Rectangle with nine circles)
void SvxPixelCtl::Paint( const Rectangle& ) void SvxPixelCtl::Paint( const Rectangle& )
{ {
if (!aRectSize.Width() || !aRectSize.Height())
return;
sal_uInt16 i, j, nTmp; sal_uInt16 i, j, nTmp;
Point aPtTl, aPtBr; Point aPtTl, aPtBr;