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

refactor "basctl" classes to use RenderContext

Change-Id: I6eb54af9f793c614c823123c6f16a3dc4f3a0c0b
üst 9128ef68
......@@ -78,7 +78,7 @@ char const FilterMask_All[] = "*";
char const FilterMask_All[] = "*.*";
#endif
} // namespace
} // end anonymous namespace
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
......@@ -179,22 +179,13 @@ bool bSourceLinesEnabled = false;
} // namespace
// ModulWindow
ModulWindow::ModulWindow (
ModulWindowLayout* pParent,
ScriptDocument const& rDocument,
const OUString& aLibName, const OUString& aName, OUString& aModule
) :
BaseWindow(pParent, rDocument, aLibName, aName),
rLayout(*pParent),
nValid(ValidWindow),
aXEditorWindow(VclPtr<ComplexEditorWindow>::Create(this)),
m_aModule(aModule)
ModulWindow::ModulWindow (ModulWindowLayout* pParent, ScriptDocument const& rDocument,
const OUString& aLibName, const OUString& aName, OUString& aModule)
: BaseWindow(pParent, rDocument, aLibName, aName)
, rLayout(*pParent)
, nValid(ValidWindow)
, aXEditorWindow(VclPtr<ComplexEditorWindow>::Create(this))
, m_aModule(aModule)
{
aXEditorWindow->Show();
SetBackground();
......@@ -250,14 +241,13 @@ void ModulWindow::GetFocus()
void ModulWindow::DoInit()
{
if ( GetVScrollBar() )
if (GetVScrollBar())
GetVScrollBar()->Hide();
GetHScrollBar()->Show();
GetEditorWindow().InitScrollBars();
}
void ModulWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
void ModulWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle&)
{
}
......@@ -267,7 +257,6 @@ void ModulWindow::Resize()
Size( GetOutputSizePixel() ) );
}
void ModulWindow::CheckCompileBasic()
{
if ( XModule().Is() )
......@@ -775,7 +764,6 @@ void ModulWindow::EditMacro( const OUString& rMacroName )
}
}
void ModulWindow::StoreData()
{
// StoreData is called when the BasicManager is destroyed or
......@@ -789,13 +777,11 @@ bool ModulWindow::CanClose()
return true;
}
bool ModulWindow::AllowUndo()
{
return GetEditorWindow().CanModify();
}
void ModulWindow::UpdateData()
{
DBG_ASSERT( XModule().Is(), "Kein Modul!" );
......@@ -901,7 +887,6 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
return nCurPage;
}
void ModulWindow::ExecuteCommand (SfxRequest& rReq)
{
AssertValidEditEngine();
......@@ -1179,7 +1164,6 @@ void ModulWindow::GetState( SfxItemSet &rSet )
}
}
void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
{
if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
......@@ -1193,14 +1177,11 @@ void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
}
}
bool ModulWindow::IsModified()
{
return GetEditEngine() && GetEditEngine()->IsModified();
}
void ModulWindow::GoOnTop()
{
GetShell()->GetViewFrame()->ToTop();
......@@ -1234,7 +1215,6 @@ void ModulWindow::ShowCursor( bool bOn )
}
}
void ModulWindow::AssertValidEditEngine()
{
if ( !GetEditEngine() )
......@@ -1295,7 +1275,7 @@ sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem,
return nFound;
}
::svl::IUndoManager* ModulWindow::GetUndoManager()
svl::IUndoManager* ModulWindow::GetUndoManager()
{
if ( GetEditEngine() )
return &GetEditEngine()->GetUndoManager();
......@@ -1462,12 +1442,6 @@ void ModulWindow::UpdateModule ()
MarkDocumentModified(m_aDocument);
}
// ModulWindowLayout
ModulWindowLayout::ModulWindowLayout (vcl::Window* pParent, ObjectCatalog& rObjectCatalog_) :
Layout(pParent),
pChild(0),
......@@ -1495,9 +1469,9 @@ void ModulWindowLayout::UpdateDebug (bool bBasicStopped)
aStackWindow->UpdateCalls();
}
void ModulWindowLayout::Paint (vcl::RenderContext& /*rRenderContext*/, Rectangle const&)
void ModulWindowLayout::Paint (vcl::RenderContext& rRenderContext, Rectangle const&)
{
DrawText(Point(), IDEResId(RID_STR_NOMODULE).toString());
rRenderContext.DrawText(Point(), IDEResId(RID_STR_NOMODULE).toString());
}
// virtual
......@@ -1508,7 +1482,6 @@ void ModulWindowLayout::DataChanged (DataChangedEvent const& rDCEvt)
aSyntaxColors.SettingsChanged();
}
void ModulWindowLayout::Activating (BaseWindow& rChild)
{
assert(dynamic_cast<ModulWindow*>(&rChild));
......@@ -1563,12 +1536,6 @@ void ModulWindowLayout::OnFirstSize (long const nWidth, long const nHeight)
AddToBottom(aStackWindow.get(), Size(nWidth * 0.33, nHeight * 0.25));
}
// SyntaxColors
ModulWindowLayout::SyntaxColors::SyntaxColors () :
pEditor(0)
{
......
......@@ -177,9 +177,9 @@ private:
void setBackgroundColor(Color aColor);
protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) SAL_OVERRIDE;
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE;
BreakPoint* FindBreakPoint( const Point& rMousePos );
void ShowMarker( bool bShow );
void ShowMarker(vcl::RenderContext& rRenderContext);
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
......
......@@ -71,23 +71,20 @@ char const FilterMask_All[] = "*";
TYPEINIT1( DialogWindow, BaseWindow );
DialogWindow::DialogWindow (
DialogWindowLayout* pParent,
ScriptDocument const& rDocument,
const OUString& aLibName, const OUString& aName,
com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel
) :
BaseWindow(pParent, rDocument, aLibName, aName),
rLayout(*pParent),
pEditor(new DlgEditor(*this, rLayout, rDocument.isDocument() ? rDocument.getDocument() : Reference<frame::XModel>(), xDialogModel)),
pUndoMgr(new SfxUndoManager)
DialogWindow::DialogWindow(DialogWindowLayout* pParent, ScriptDocument const& rDocument,
const OUString& aLibName, const OUString& aName,
css::uno::Reference<css::container::XNameContainer> const& xDialogModel)
: BaseWindow(pParent, rDocument, aLibName, aName)
,rLayout(*pParent)
,pEditor(new DlgEditor(*this, rLayout, rDocument.isDocument()
? rDocument.getDocument()
: Reference<frame::XModel>(), xDialogModel))
,pUndoMgr(new SfxUndoManager)
{
InitSettings( true, true, true );
aOldNotifyUndoActionHdl = pEditor->GetModel().GetNotifyUndoActionHdl();
pEditor->GetModel().SetNotifyUndoActionHdl(
LINK(this, DialogWindow, NotifyUndoActionHdl)
);
pEditor->GetModel().SetNotifyUndoActionHdl(LINK(this, DialogWindow, NotifyUndoActionHdl));
SetHelpId( HID_BASICIDE_DIALOGWINDOW );
......@@ -108,24 +105,19 @@ void DialogWindow::LoseFocus()
Window::LoseFocus();
}
void DialogWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
void DialogWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{
pEditor->Paint( rRect );
pEditor->Paint(rRenderContext, rRect);
}
void DialogWindow::Resize()
{
if ( GetHScrollBar() && GetVScrollBar() ) {
if (GetHScrollBar() && GetVScrollBar())
{
pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
}
void DialogWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
pEditor->MouseButtonDown( rMEvt );
......@@ -134,8 +126,6 @@ void DialogWindow::MouseButtonDown( const MouseEvent& rMEvt )
pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
}
void DialogWindow::MouseButtonUp( const MouseEvent& rMEvt )
{
pEditor->MouseButtonUp( rMEvt );
......@@ -155,15 +145,11 @@ void DialogWindow::MouseButtonUp( const MouseEvent& rMEvt )
}
}
void DialogWindow::MouseMove( const MouseEvent& rMEvt )
{
pEditor->MouseMove( rMEvt );
}
void DialogWindow::KeyInput( const KeyEvent& rKEvt )
{
SfxBindings* pBindings = GetBindingsPtr();
......@@ -238,8 +224,6 @@ IMPL_STATIC_LINK(
return 0;
}
void DialogWindow::DoInit()
{
GetHScrollBar()->Show();
......@@ -247,8 +231,6 @@ void DialogWindow::DoInit()
pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
void DialogWindow::DoScroll( ScrollBar* pCurScrollBar )
{
pEditor->DoScroll( pCurScrollBar );
......
......@@ -36,24 +36,24 @@ void LineNumberWindow::dispose()
Window::dispose();
}
void LineNumberWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
void LineNumberWindow::Paint( vcl::RenderContext& rRenderContext, const Rectangle&)
{
if(SyncYOffset())
return;
ExtTextEngine* txtEngine = m_pModulWindow->GetEditEngine();
if(!txtEngine)
if (!txtEngine)
return;
TextView* txtView = m_pModulWindow->GetEditView();
if(!txtView)
if (!txtView)
return;
GetParent()->Resize();
int windowHeight = GetOutputSize().Height();
int nLineHeight = GetTextHeight();
if(!nLineHeight)
int windowHeight = rRenderContext.GetOutputSize().Height();
int nLineHeight = rRenderContext.GetTextHeight();
if (!nLineHeight)
{
return;
}
......@@ -62,7 +62,7 @@ void LineNumberWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
int nStartLine = startY / nLineHeight + 1;
int nEndLine = (startY + windowHeight) / nLineHeight + 1;
if(txtEngine->GetParagraphCount() + 1 < (unsigned int)nEndLine)
if (txtEngine->GetParagraphCount() + 1 < (unsigned int)nEndLine)
nEndLine = txtEngine->GetParagraphCount() + 1;
// FIXME: it would be best if we could get notified of a font change
......@@ -72,15 +72,15 @@ void LineNumberWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rect
// reserve enough for 3 sigit minimum, with a bit to spare for confort
m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
int i = (nEndLine + 1) / 1000;
while(i)
while (i)
{
i /= 10;
m_nWidth += m_nBaseWidth;
}
sal_Int64 y = (nStartLine - 1) * (sal_Int64)nLineHeight;
for(sal_Int32 n = nStartLine; n <= nEndLine; ++n, y += nLineHeight)
DrawText(Point(0, y - m_nCurYOffset), OUString::number(n));
for (sal_Int32 n = nStartLine; n <= nEndLine; ++n, y += nLineHeight)
rRenderContext.DrawText(Point(0, y - m_nCurYOffset), OUString::number(n));
}
void LineNumberWindow::DataChanged(DataChangedEvent const & rDCEvt)
......
......@@ -26,7 +26,7 @@ private:
virtual void DataChanged (DataChangedEvent const& rDCEvt) SAL_OVERRIDE;
protected:
virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) SAL_OVERRIDE;
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
public:
LineNumberWindow (vcl::Window* pParent, ModulWindow* pModulWin);
......
......@@ -472,31 +472,29 @@ bool DlgEditor::KeyInput( const KeyEvent& rKEvt )
}
void DlgEditor::Paint( const Rectangle& rRect )
void DlgEditor::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{
aPaintRect = rRect;
mnPaintGuard++;
Size aMacSize;
if( bFirstDraw &&
rWindow.IsVisible() &&
(rWindow.GetOutputSize() != aMacSize) )
if (bFirstDraw && rWindow.IsVisible() && (rRenderContext.GetOutputSize() != aMacSize))
{
bFirstDraw = false;
// get property set
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(pDlgEdForm->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
css::uno::Reference<css::beans::XPropertySet> xPSet(pDlgEdForm->GetUnoControlModel(), css::uno::UNO_QUERY);
if ( xPSet.is() )
if (xPSet.is())
{
// get dialog size from properties
sal_Int32 nWidth = 0, nHeight = 0;
xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
if ( nWidth == 0 && nHeight == 0 )
if (nWidth == 0 && nHeight == 0)
{
Size aSize = rWindow.PixelToLogic( Size( 400, 300 ) );
Size aSize = rRenderContext.PixelToLogic( Size( 400, 300 ) );
// align with grid
Size aGridSize_(long(pDlgEdView->GetSnapGridWidthX()), long(pDlgEdView->GetSnapGridWidthY()));
......@@ -504,7 +502,7 @@ void DlgEditor::Paint( const Rectangle& rRect )
aSize.Height() -= aSize.Height() % aGridSize_.Height();
Point aPos;
Size aOutSize = rWindow.GetOutputSize();
Size aOutSize = rRenderContext.GetOutputSize();
aPos.X() = (aOutSize.Width()>>1) - (aSize.Width()>>1);
aPos.Y() = (aOutSize.Height()>>1) - (aSize.Height()>>1);
......@@ -513,7 +511,7 @@ void DlgEditor::Paint( const Rectangle& rRect )
aPos.Y() -= aPos.Y() % aGridSize_.Height();
// don't put in the corner
Point aMinPos = rWindow.PixelToLogic( Point( 30, 20 ) );
Point aMinPos = rRenderContext.PixelToLogic( Point( 30, 20 ) );
if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
{
aPos = aMinPos;
......@@ -531,10 +529,16 @@ void DlgEditor::Paint( const Rectangle& rRect )
// set position and size of controls
if (const size_t nObjCount = pDlgEdPage->GetObjCount())
{
for ( size_t i = 0 ; i < nObjCount ; ++i )
for (size_t i = 0 ; i < nObjCount ; ++i)
{
if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pDlgEdPage->GetObj(i)))
{
if (!dynamic_cast<DlgEdForm*>(pDlgEdObj))
{
pDlgEdObj->SetRectFromProps();
}
}
}
}
}
}
......@@ -544,27 +548,26 @@ void DlgEditor::Paint( const Rectangle& rRect )
SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
const vcl::Region aPaintRectRegion(aPaintRect);
// #i74769#
SdrPaintWindow* pTargetPaintWindow = 0;
// mark repaint start
if(pPgView)
if (pPgView)
{
pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(&rWindow, aPaintRectRegion);
pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(&rRenderContext, aPaintRectRegion);
OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
}
// draw background self using wallpaper
// #i79128# ...and use correct OutDev for that
if(pTargetPaintWindow)
if (pTargetPaintWindow)
{
OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(Color(COL_WHITE)));
}
// do paint (unbuffered) and mark repaint end
if(pPgView)
if (pPgView)
{
// paint of control layer is done in EndDrawLayers anyway...
pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
......@@ -609,9 +612,6 @@ void DlgEditor::SetInsertObj( sal_uInt16 eObj )
pDlgEdView->SetCurrentObj( eActObj, DlgInventor );
}
void DlgEditor::CreateDefaultObject()
{
// create object by factory
......
......@@ -62,7 +62,7 @@ private:
OUString aCurPath;
protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) SAL_OVERRIDE;
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
......
......@@ -31,6 +31,7 @@
#include <vcl/timer.hxx>
#include <vcl/idle.hxx>
#include <vcl/vclptr.hxx>
#include <vcl/window.hxx>
#include <boost/scoped_ptr.hpp>
......@@ -184,7 +185,7 @@ public:
void MouseButtonDown( const MouseEvent& rMEvt );
void MouseButtonUp( const MouseEvent& rMEvt );
void MouseMove( const MouseEvent& rMEvt );
void Paint( const Rectangle& rRect );
void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
bool KeyInput( const KeyEvent& rKEvt );
void SetMode (Mode eMode);
......
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