Kaydet (Commit) 356f6c5d authored tarafından Caolán McNamara's avatar Caolán McNamara

teach FrameSelector to be resizable

Change-Id: I0fd91d707b89197d57dc6eaf7dcebfdb055d73c6
üst 8a324a3b
...@@ -84,6 +84,7 @@ class SVX_DLLPUBLIC FrameSelector : public Control ...@@ -84,6 +84,7 @@ class SVX_DLLPUBLIC FrameSelector : public Control
{ {
public: public:
explicit FrameSelector( Window* pParent, const ResId& rResId ); explicit FrameSelector( Window* pParent, const ResId& rResId );
FrameSelector(Window* pParent);
virtual ~FrameSelector(); virtual ~FrameSelector();
/** Initializes the control, enables/disables frame borders according to flags. */ /** Initializes the control, enables/disables frame borders according to flags. */
...@@ -186,6 +187,8 @@ protected: ...@@ -186,6 +187,8 @@ protected:
virtual void GetFocus(); virtual void GetFocus();
virtual void LoseFocus(); virtual void LoseFocus();
virtual void DataChanged( const DataChangedEvent& rDCEvt ); virtual void DataChanged( const DataChangedEvent& rDCEvt );
virtual void Resize();
virtual Size GetOptimalSize() const;
private: private:
std::auto_ptr< FrameSelectorImpl > mxImpl; std::auto_ptr< FrameSelectorImpl > mxImpl;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <svx/frmsel.hxx> #include <svx/frmsel.hxx>
#include <vcl/builder.hxx>
#include <algorithm> #include <algorithm>
#include <math.h> #include <math.h>
...@@ -374,6 +375,13 @@ void FrameSelectorImpl::InitBorderGeometry() ...@@ -374,6 +375,13 @@ void FrameSelectorImpl::InitBorderGeometry()
/* Width for focus rectangles from center of frame borders. */ /* Width for focus rectangles from center of frame borders. */
mnFocusOffs = FRAMESEL_GEOM_WIDTH / 2 + 1; mnFocusOffs = FRAMESEL_GEOM_WIDTH / 2 + 1;
maLeft.ClearFocusArea();
maVer.ClearFocusArea();
maRight.ClearFocusArea();
maTop.ClearFocusArea();
maHor.ClearFocusArea();
maBottom.ClearFocusArea();
maLeft.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine1 + mnFocusOffs, mnLine3 + mnFocusOffs ) ); maLeft.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine1 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
maVer.AddFocusPolygon( Rectangle( mnLine2 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine2 + mnFocusOffs, mnLine3 + mnFocusOffs ) ); maVer.AddFocusPolygon( Rectangle( mnLine2 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine2 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
maRight.AddFocusPolygon( Rectangle( mnLine3 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) ); maRight.AddFocusPolygon( Rectangle( mnLine3 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
...@@ -477,6 +485,11 @@ void FrameSelectorImpl::InitVirtualDevice() ...@@ -477,6 +485,11 @@ void FrameSelectorImpl::InitVirtualDevice()
InitColors(); InitColors();
InitArrowImageList(); InitArrowImageList();
sizeChanged();
}
void FrameSelectorImpl::sizeChanged()
{
// initialize geometry // initialize geometry
InitGlobalGeometry(); InitGlobalGeometry();
InitBorderGeometry(); InitBorderGeometry();
...@@ -773,6 +786,19 @@ FrameSelector::FrameSelector( Window* pParent, const ResId& rResId ) : ...@@ -773,6 +786,19 @@ FrameSelector::FrameSelector( Window* pParent, const ResId& rResId ) :
EnableRTL( false ); // #107808# don't mirror the mouse handling EnableRTL( false ); // #107808# don't mirror the mouse handling
} }
FrameSelector::FrameSelector(Window* pParent)
: Control(pParent, WB_BORDER|WB_TABSTOP)
{
// not in c'tor init list (avoid warning about usage of *this)
mxImpl.reset( new FrameSelectorImpl( *this ) );
EnableRTL( false ); // #107808# don't mirror the mouse handling
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxFrameSelector(Window *pParent, VclBuilder::stringmap &)
{
return new FrameSelector(pParent);
}
FrameSelector::~FrameSelector() FrameSelector::~FrameSelector()
{ {
} }
...@@ -1181,6 +1207,17 @@ void FrameSelector::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -1181,6 +1207,17 @@ void FrameSelector::DataChanged( const DataChangedEvent& rDCEvt )
mxImpl->InitVirtualDevice(); mxImpl->InitVirtualDevice();
} }
void FrameSelector::Resize()
{
Control::Resize();
mxImpl->sizeChanged();
}
Size FrameSelector::GetOptimalSize() const
{
return LogicToPixel(Size(61, 65), MAP_APPFONT);
}
// ============================================================================ // ============================================================================
template< typename Cont, typename Iter, typename Pred > template< typename Cont, typename Iter, typename Pred >
......
...@@ -163,6 +163,9 @@ struct FrameSelectorImpl : public Resource ...@@ -163,6 +163,9 @@ struct FrameSelectorImpl : public Resource
void InitClickAreas(); void InitClickAreas();
/** Draws the entire control into the internal virtual device. */ /** Draws the entire control into the internal virtual device. */
void InitVirtualDevice(); void InitVirtualDevice();
/** call this to recalculate based on parent size */
void sizeChanged();
// frame border access ---------------------------------------------------- // frame border access ----------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment