Kaydet (Commit) 847c2ac5 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor optload / optpage to use RenderContext

Change-Id: I6b4897230963ecde335c5a04b1e34c8ca02d654c
üst adbd4969
...@@ -63,8 +63,7 @@ using namespace ::com::sun::star; ...@@ -63,8 +63,7 @@ using namespace ::com::sun::star;
#include <svl/eitem.hxx> #include <svl/eitem.hxx>
SwLoadOptPage::SwLoadOptPage(vcl::Window* pParent, const SfxItemSet& rSet) SwLoadOptPage::SwLoadOptPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptGeneralPage", : SfxTabPage(pParent, "OptGeneralPage", "modules/swriter/ui/optgeneralpage.ui", &rSet)
"modules/swriter/ui/optgeneralpage.ui", &rSet)
, m_pWrtShell(NULL) , m_pWrtShell(NULL)
, m_nLastTab(0) , m_nLastTab(0)
, m_nOldLinkMode(MANUAL) , m_nOldLinkMode(MANUAL)
...@@ -107,7 +106,7 @@ SwLoadOptPage::SwLoadOptPage(vcl::Window* pParent, const SfxItemSet& rSet) ...@@ -107,7 +106,7 @@ SwLoadOptPage::SwLoadOptPage(vcl::Window* pParent, const SfxItemSet& rSet)
m_pMetricLB->SetSelectHdl(LINK(this, SwLoadOptPage, MetricHdl)); m_pMetricLB->SetSelectHdl(LINK(this, SwLoadOptPage, MetricHdl));
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem ) if (SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem)
&& static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON) && static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON)
{ {
m_pTabFT->Hide(); m_pTabFT->Hide();
...@@ -382,8 +381,9 @@ SwCaptionOptDlg::SwCaptionOptDlg(vcl::Window* pParent, const SfxItemSet& rSet) ...@@ -382,8 +381,9 @@ SwCaptionOptDlg::SwCaptionOptDlg(vcl::Window* pParent, const SfxItemSet& rSet)
SetTabPage(SwCaptionOptPage::Create(get_content_area(), &rSet)); SetTabPage(SwCaptionOptPage::Create(get_content_area(), &rSet));
} }
SwCaptionPreview::SwCaptionPreview( vcl::Window* pParent, WinBits nStyle ) SwCaptionPreview::SwCaptionPreview(vcl::Window* pParent, WinBits nStyle)
: Window( pParent, nStyle ) : Window(pParent, nStyle)
, mbFontInitialized(false)
{ {
Init(); Init();
} }
...@@ -399,21 +399,30 @@ VCL_BUILDER_DECL_FACTORY(SwCaptionPreview) ...@@ -399,21 +399,30 @@ VCL_BUILDER_DECL_FACTORY(SwCaptionPreview)
void SwCaptionPreview::Init() void SwCaptionPreview::Init()
{ {
maDrawPos = Point( 4, 6 ); maDrawPos = Point(4, 6);
}
void SwCaptionPreview::ApplySettings(vcl::RenderContext& rRenderContext)
{
Wallpaper aBack(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor());
rRenderContext.SetBackground(aBack);
rRenderContext.SetFillColor(aBack.GetColor());
rRenderContext.SetLineColor(aBack.GetColor());
Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() ); if (!mbFontInitialized)
SetBackground( aBack ); {
SetFillColor( aBack.GetColor() ); maFont = vcl::Font(rRenderContext.GetFont());
SetLineColor( aBack.GetColor() ); maFont.SetHeight(maFont.GetHeight() * 120 / 100);
SetBorderStyle( WindowBorderStyle::MONO ); mbFontInitialized = true;
vcl::Font aFont(GetFont()); }
aFont.SetHeight(aFont.GetHeight() * 120 / 100 ); rRenderContext.SetFont(maFont);
SetFont(aFont);
SetBorderStyle(WindowBorderStyle::MONO);
} }
void SwCaptionPreview::SetPreviewText( const OUString& rText ) void SwCaptionPreview::SetPreviewText(const OUString& rText)
{ {
if( rText != maText ) if (rText != maText)
{ {
maText = rText; maText = rText;
Invalidate(); Invalidate();
...@@ -429,11 +438,11 @@ void SwCaptionPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle ...@@ -429,11 +438,11 @@ void SwCaptionPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle
{ {
Window::Paint(rRenderContext, rRect); Window::Paint(rRenderContext, rRect);
DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); rRenderContext.DrawRect(Rectangle(Point(0, 0), GetSizePixel()));
DrawText( Point( 4, 6 ), maText ); rRenderContext.DrawText(Point(4, 6), maText);
} }
SwCaptionOptPage::SwCaptionOptPage( vcl::Window* pParent, const SfxItemSet& rSet ) SwCaptionOptPage::SwCaptionOptPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptCaptionPage", "modules/swriter/ui/optcaptionpage.ui", &rSet) : SfxTabPage(pParent, "OptCaptionPage", "modules/swriter/ui/optcaptionpage.ui", &rSet)
, m_sSWTable(SW_RESSTR(STR_CAPTION_TABLE)) , m_sSWTable(SW_RESSTR(STR_CAPTION_TABLE))
, m_sSWFrame(SW_RESSTR(STR_CAPTION_FRAME)) , m_sSWFrame(SW_RESSTR(STR_CAPTION_FRAME))
...@@ -466,15 +475,12 @@ SwCaptionOptPage::SwCaptionOptPage( vcl::Window* pParent, const SfxItemSet& rSet ...@@ -466,15 +475,12 @@ SwCaptionOptPage::SwCaptionOptPage( vcl::Window* pParent, const SfxItemSet& rSet
get(m_pCharStyleLB, "charstyle"); get(m_pCharStyleLB, "charstyle");
get(m_pApplyBorderCB, "applyborder"); get(m_pApplyBorderCB, "applyborder");
Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
m_pPreview->SetBackground( aBack );
SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_ABB, m_sIllustration); SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_ABB, m_sIllustration);
SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_TABLE, m_sTable); SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_TABLE, m_sTable);
SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_FRAME, m_sText); SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_FRAME, m_sText);
SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_DRAWING, m_sDrawing); SwStyleNameMapper::FillUIName(RES_POOLCOLL_LABEL_DRAWING, m_sDrawing);
SwWrtShell *pSh = ::GetActiveWrtShell(); SwWrtShell* pSh = ::GetActiveWrtShell();
// m_pFormatBox // m_pFormatBox
sal_uInt16 nSelFmt = SVX_NUM_ARABIC; sal_uInt16 nSelFmt = SVX_NUM_ARABIC;
...@@ -839,19 +845,19 @@ IMPL_LINK_NOARG(SwCaptionOptPage, ModifyHdl) ...@@ -839,19 +845,19 @@ IMPL_LINK_NOARG(SwCaptionOptPage, ModifyHdl)
m_pTextText->Enable(bEnable); m_pTextText->Enable(bEnable);
m_pTextEdit->Enable(bEnable); m_pTextEdit->Enable(bEnable);
DrawSample(); InvalidatePreview();
return 0; return 0;
} }
IMPL_LINK_NOARG(SwCaptionOptPage, SelectHdl) IMPL_LINK_NOARG(SwCaptionOptPage, SelectHdl)
{ {
DrawSample(); InvalidatePreview();
return 0; return 0;
} }
IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox ) IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox )
{ {
DrawSample(); InvalidatePreview();
SvTreeListEntry* pSelEntry = m_pCheckLB->FirstSelected(); SvTreeListEntry* pSelEntry = m_pCheckLB->FirstSelected();
bool bChecked = false; bool bChecked = false;
...@@ -866,7 +872,7 @@ IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox ) ...@@ -866,7 +872,7 @@ IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox )
return 0; return 0;
} }
void SwCaptionOptPage::DrawSample() void SwCaptionOptPage::InvalidatePreview()
{ {
OUString aStr; OUString aStr;
...@@ -924,13 +930,13 @@ void SwCaptionOptPage::DrawSample() ...@@ -924,13 +930,13 @@ void SwCaptionOptPage::DrawSample()
} }
aStr += m_pTextEdit->GetText(); aStr += m_pTextEdit->GetText();
} }
m_pPreview->SetPreviewText( aStr ); m_pPreview->SetPreviewText(aStr);
} }
// Description: ComboBox without Spaces // Description: ComboBox without Spaces
void CaptionComboBox::KeyInput(const KeyEvent& rEvt) void CaptionComboBox::KeyInput(const KeyEvent& rEvt)
{ {
if( rEvt.GetKeyCode().GetCode() != KEY_SPACE ) if (rEvt.GetKeyCode().GetCode() != KEY_SPACE)
SwComboBox::KeyInput(rEvt); SwComboBox::KeyInput(rEvt);
} }
......
...@@ -1643,9 +1643,9 @@ void SwMarkPreview::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -1643,9 +1643,9 @@ void SwMarkPreview::DataChanged( const DataChangedEvent& rDCEvt )
InitColors(); InitColors();
} }
void SwMarkPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle &/*rRect*/) void SwMarkPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangle &/*rRect*/)
{ {
const Size aSz(GetOutputSizePixel()); const Size aSz(rRenderContext.GetOutputSizePixel());
// Page // Page
aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3)); aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
...@@ -1670,19 +1670,19 @@ void SwMarkPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangl ...@@ -1670,19 +1670,19 @@ void SwMarkPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangl
// draw shadow // draw shadow
Rectangle aShadow(aPage); Rectangle aShadow(aPage);
aShadow += Point(3, 3); aShadow += Point(3, 3);
DrawRect( aShadow, m_aShadowCol, m_aTransCol ); DrawRect(rRenderContext, aShadow, m_aShadowCol, m_aTransCol);
// draw page // draw page
DrawRect( aPage, m_aBgCol, m_aLineCol ); DrawRect(rRenderContext, aPage, m_aBgCol, m_aLineCol);
// draw separator // draw separator
Rectangle aPageSeparator(aPage); Rectangle aPageSeparator(aPage);
aPageSeparator.SetSize(Size(2, aPageSeparator.GetHeight())); aPageSeparator.SetSize(Size(2, aPageSeparator.GetHeight()));
aPageSeparator.Move(aPage.GetWidth() / 2 - 1, 0); aPageSeparator.Move(aPage.GetWidth() / 2 - 1, 0);
DrawRect( aPageSeparator, m_aLineCol, m_aTransCol ); DrawRect(rRenderContext, aPageSeparator, m_aLineCol, m_aTransCol);
PaintPage(aLeftPagePrtArea); PaintPage(rRenderContext, aLeftPagePrtArea);
PaintPage(aRightPagePrtArea); PaintPage(rRenderContext, aRightPagePrtArea);
Rectangle aLeftMark(Point(aPage.Left() + 2, aLeftPagePrtArea.Top() + 4), Size(aLeftPagePrtArea.Left() - 4, 2)); Rectangle aLeftMark(Point(aPage.Left() + 2, aLeftPagePrtArea.Top() + 4), Size(aLeftPagePrtArea.Left() - 4, 2));
Rectangle aRightMark(Point(aRightPagePrtArea.Right() + 2, aRightPagePrtArea.Bottom() - 6), Size(aLeftPagePrtArea.Left() - 4, 2)); Rectangle aRightMark(Point(aRightPagePrtArea.Right() + 2, aRightPagePrtArea.Bottom() - 6), Size(aLeftPagePrtArea.Left() - 4, 2));
...@@ -1709,14 +1709,14 @@ void SwMarkPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangl ...@@ -1709,14 +1709,14 @@ void SwMarkPreview::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangl
default: default:
return; return;
} }
DrawRect( aLeftMark, m_aMarkCol, m_aTransCol ); DrawRect(rRenderContext, aLeftMark, m_aMarkCol, m_aTransCol);
DrawRect( aRightMark, m_aMarkCol, m_aTransCol ); DrawRect(rRenderContext, aRightMark, m_aMarkCol, m_aTransCol);
} }
void SwMarkPreview::PaintPage(const Rectangle &rRect) void SwMarkPreview::PaintPage(vcl::RenderContext& rRenderContext, const Rectangle &rRect)
{ {
// draw PrintArea // draw PrintArea
DrawRect(rRect, m_aTransCol, m_aPrintAreaCol ); DrawRect(rRenderContext, rRect, m_aTransCol, m_aPrintAreaCol);
// draw Testparagraph // draw Testparagraph
sal_uLong nLTxtBorder = 4; sal_uLong nLTxtBorder = 4;
...@@ -1739,18 +1739,18 @@ void SwMarkPreview::PaintPage(const Rectangle &rRect) ...@@ -1739,18 +1739,18 @@ void SwMarkPreview::PaintPage(const Rectangle &rRect)
aTextLine.SetSize(Size(aTextLine.GetWidth() / 2, aTextLine.GetHeight())); aTextLine.SetSize(Size(aTextLine.GetWidth() / 2, aTextLine.GetHeight()));
if (aPage.IsInside(aTextLine)) if (aPage.IsInside(aTextLine))
DrawRect(aTextLine, m_aTxtCol, m_aTransCol ); DrawRect(rRenderContext, aTextLine, m_aTxtCol, m_aTransCol);
aTextLine.Move(0, nStep); aTextLine.Move(0, nStep);
} }
aTextLine.Move(0, -nStep); aTextLine.Move(0, -nStep);
} }
void SwMarkPreview::DrawRect(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor) void SwMarkPreview::DrawRect(vcl::RenderContext& rRenderContext, const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
{ {
SetFillColor(rFillColor); rRenderContext.SetFillColor(rFillColor);
SetLineColor(rLineColor); rRenderContext.SetLineColor(rLineColor);
Window::DrawRect(rRect); rRenderContext.DrawRect(rRect);
} }
Size SwMarkPreview::GetOptimalSize() const Size SwMarkPreview::GetOptimalSize() const
......
...@@ -95,10 +95,13 @@ class SwCaptionPreview : public vcl::Window ...@@ -95,10 +95,13 @@ class SwCaptionPreview : public vcl::Window
{ {
private: private:
OUString maText; OUString maText;
Point maDrawPos; bool mbFontInitialized;
vcl::Font maFont;
Point maDrawPos;
public: public:
SwCaptionPreview( vcl::Window* pParent, WinBits nStyle ); SwCaptionPreview(vcl::Window* pParent, WinBits nStyle);
void Init(); void Init();
virtual void ApplySettings(vcl::RenderContext& rRenderContext);
void SetPreviewText( const OUString& rText ); void SetPreviewText( const OUString& rText );
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE; virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
virtual Size GetOptimalSize() const SAL_OVERRIDE; virtual Size GetOptimalSize() const SAL_OVERRIDE;
...@@ -130,25 +133,25 @@ private: ...@@ -130,25 +133,25 @@ private:
VclPtr<ListBox> m_pCharStyleLB; VclPtr<ListBox> m_pCharStyleLB;
VclPtr<CheckBox> m_pApplyBorderCB; VclPtr<CheckBox> m_pApplyBorderCB;
OUString m_sSWTable; OUString m_sSWTable;
OUString m_sSWFrame; OUString m_sSWFrame;
OUString m_sSWGraphic; OUString m_sSWGraphic;
OUString m_sOLE; OUString m_sOLE;
OUString m_sIllustration; OUString m_sIllustration;
OUString m_sTable; OUString m_sTable;
OUString m_sText; OUString m_sText;
OUString m_sDrawing; OUString m_sDrawing;
OUString m_sBegin; OUString m_sBegin;
OUString m_sEnd; OUString m_sEnd;
OUString m_sAbove; OUString m_sAbove;
OUString m_sBelow; OUString m_sBelow;
OUString m_sNone; OUString m_sNone;
SwFldMgr *pMgr; SwFldMgr* pMgr;
bool bHTMLMode; bool bHTMLMode;
DECL_LINK(SelectHdl, void *); DECL_LINK(SelectHdl, void *);
DECL_LINK(ModifyHdl, void * = 0); DECL_LINK(ModifyHdl, void * = 0);
...@@ -156,12 +159,10 @@ private: ...@@ -156,12 +159,10 @@ private:
DECL_LINK(ShowEntryHdl, void *); DECL_LINK(ShowEntryHdl, void *);
DECL_LINK(SaveEntryHdl, void *); DECL_LINK(SaveEntryHdl, void *);
void DelUserData(); void DelUserData();
void SetOptions( const sal_uLong nPos, void SetOptions(const sal_uLong nPos, const SwCapObjType eType, const SvGlobalName *pOleId = 0);
const SwCapObjType eType, void SaveEntry(SvTreeListEntry* pEntry);
const SvGlobalName *pOleId = 0); void InvalidatePreview();
void SaveEntry( SvTreeListEntry* pEntry );
void DrawSample();
public: public:
SwCaptionOptPage( vcl::Window* pParent, SwCaptionOptPage( vcl::Window* pParent,
......
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