summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-07-29 10:28:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-07-29 10:29:38 +0100
commitadf9406450652046e19dbfc4246ce1228b8aceea (patch)
tree163df8551b39ac36c2b347db02a484b1f1f60e42
parent802c52fb98958ec93d9791b3b4a88f3865211c47 (diff)
let the pixel control find parent tabpage in layout
Change-Id: I3097e7d33bdf1331a71621af6dee823a803a17b7
-rw-r--r--include/svx/dlgctrl.hxx2
-rw-r--r--include/vcl/layout.hxx2
-rw-r--r--svx/source/dialog/dlgctrl.cxx47
3 files changed, 35 insertions, 16 deletions
diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx
index 9107b6852fc7..f5ff8053cefc 100644
--- a/include/svx/dlgctrl.hxx
+++ b/include/svx/dlgctrl.hxx
@@ -184,6 +184,8 @@ public:
virtual void Paint( const Rectangle& rRect );
virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Resize();
+ virtual Size GetOptimalSize() const;
void SetXBitmap( const BitmapEx& rBitmapEx );
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 14635699cb16..bdcbedf48e3d 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -755,7 +755,7 @@ VCL_DLLPUBLIC bool isInitialLayout(const Window *pWindow);
Size getLegacyBestSizeForChildren(const Window &rWindow);
//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
Window* getNonLayoutRealParent(Window *pParent);
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index 225909032442..76ba1b741635 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -362,8 +362,9 @@ void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
{
SetActualRP( eNewRP );
- if( WINDOW_TABPAGE == GetParent()->GetType() )
- ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
+ Window *pTabPage = getNonLayoutParent(this);
+ if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
+ ((SvxTabPage*) pTabPage)->PointChanged(this, eRP);
SetFocusRect();
}
@@ -676,8 +677,9 @@ void SvxRectCtl::SetState( CTL_STATE nState )
eRP = GetRPFromPoint( _aPtNew );
Invalidate();
- if( WINDOW_TABPAGE == GetParent()->GetType() )
- ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
+ Window *pTabPage = getNonLayoutParent(this);
+ if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
+ ((SvxTabPage*)pTabPage)->PointChanged(this, eRP);
}
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));
}
-SvxPixelCtl::SvxPixelCtl( Window* pParent, sal_uInt16 nNumber ) :
-Control ( pParent, WB_BORDER ),
-nLines ( nNumber ),
-bPaintable ( sal_True )
+SvxPixelCtl::SvxPixelCtl(Window* pParent, sal_uInt16 nNumber)
+ : Control(pParent, WB_BORDER)
+ , nLines(nNumber)
+ , bPaintable(true)
{
- //aRectSize = GetOutputSize();
- aRectSize = LogicToPixel(Size(72, 72), MAP_APPFONT);
-
SetPixelColor( Color( COL_BLACK ) );
SetBackgroundColor( Color( COL_WHITE ) );
SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
@@ -783,9 +782,20 @@ bPaintable ( sal_True )
memset(pPixel, 0, nSquares * sizeof(sal_uInt16));
}
-extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxPixelCtl(Window *pParent, sal_uInt16 nNumber)
+void SvxPixelCtl::Resize()
+{
+ Control::Resize();
+ aRectSize = GetOutputSize();
+}
+
+Size SvxPixelCtl::GetOptimalSize() const
{
- return new SvxPixelCtl(pParent, 8 ); //nNumber);
+ 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
@@ -808,6 +818,9 @@ void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
{
+ if (!aRectSize.Width() || !aRectSize.Height())
+ return;
+
Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
Point aPtTl, aPtBr;
sal_uInt16 nX, nY;
@@ -824,14 +837,18 @@ void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
Invalidate( Rectangle( aPtTl, aPtBr ) );
- if( WINDOW_TABPAGE == GetParent()->GetType() )
- ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint is a dummy
+ Window *pTabPage = getNonLayoutParent(this);
+ if (pTabPage && WINDOW_TABPAGE == pTabPage->GetType())
+ ((SvxTabPage*)pTabPage)->PointChanged(this, RP_MM); // RectPoint is a dummy
}
// Draws the Control (Rectangle with nine circles)
void SvxPixelCtl::Paint( const Rectangle& )
{
+ if (!aRectSize.Width() || !aRectSize.Height())
+ return;
+
sal_uInt16 i, j, nTmp;
Point aPtTl, aPtBr;