summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorAugust Sodora <augsod@gmail.com>2011-11-16 14:48:49 -0500
committerNorbert Thiebaud <nthiebaud@gmail.com>2011-11-17 18:41:19 -0600
commitdeb6bcf8d91a14767ed4cd6c377e1ffe6b6a9521 (patch)
tree11c12ed8835a029e492979d2f185f5facc84afd4 /basctl
parent291bd1f0bfd0d7639e4a211a6e3d267403ddc44c (diff)
Added missing files
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/linenumberwindow.cxx58
-rw-r--r--basctl/source/basicide/linenumberwindow.hxx26
2 files changed, 84 insertions, 0 deletions
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
new file mode 100644
index 000000000000..5168da1b092a
--- /dev/null
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -0,0 +1,58 @@
+#include "baside2.hxx"
+#include "linenumberwindow.hxx"
+
+#include <svtools/xtextedt.hxx>
+#include <svtools/textview.hxx>
+
+LineNumberWindow::LineNumberWindow( Window* pParent, ModulWindow* pModulWin ) :
+ Window( pParent, WB_BORDER ),
+ pModulWindow(pModulWin),
+ nWidth(1)
+{
+ SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
+}
+
+LineNumberWindow::~LineNumberWindow() { }
+
+void LineNumberWindow::Paint( const Rectangle& )
+{
+ ExtTextEngine* txtEngine = pModulWindow->GetEditEngine();
+ if(!txtEngine)
+ return;
+
+ TextView* txtView = pModulWindow->GetEditView();
+ if(!txtView)
+ return;
+
+ GetParent()->Resize();
+
+ ulong windowHeight = GetOutputSize().Height();
+ ulong startY = txtView->GetStartDocPos().Y();
+ ulong nLineHeight = GetTextHeight();
+
+ ulong nStartLine = startY / nLineHeight + 1;
+ ulong nEndLine = (startY + windowHeight) / nLineHeight + 1;
+
+ if(txtEngine->GetParagraphCount() + 1 < nEndLine)
+ nEndLine = txtEngine->GetParagraphCount() + 1;
+
+ nWidth = String::CreateFromInt64(nEndLine).Len() * 10;
+
+ for(ulong i = nStartLine, y = 0; i < nEndLine; ++i, y += nLineHeight)
+ DrawText(Point(0, y), String::CreateFromInt64(i));
+}
+
+void LineNumberWindow::DataChanged(DataChangedEvent const & rDCEvt)
+{
+ Window::DataChanged(rDCEvt);
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS
+ && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
+ {
+ Color aColor(GetSettings().GetStyleSettings().GetFieldColor());
+ if (aColor != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor())
+ {
+ SetBackground(Wallpaper(aColor));
+ Invalidate();
+ }
+ }
+}
diff --git a/basctl/source/basicide/linenumberwindow.hxx b/basctl/source/basicide/linenumberwindow.hxx
new file mode 100644
index 000000000000..885ea1485542
--- /dev/null
+++ b/basctl/source/basicide/linenumberwindow.hxx
@@ -0,0 +1,26 @@
+#ifndef BASICIDE_LINENUMBERWINDOW_HXX
+#define BASICIDE_LINENUMBERWINDOW_HXX
+
+#include <vcl/window.hxx>
+
+class ModulWindow;
+
+class LineNumberWindow : public Window
+{
+private:
+ ModulWindow* pModulWindow;
+ ulong nWidth;
+
+ virtual void DataChanged(DataChangedEvent const & rDCEvt);
+
+protected:
+ virtual void Paint( const Rectangle& );
+
+public:
+ LineNumberWindow( Window* pParent, ModulWindow* pModulWin );
+ ~LineNumberWindow();
+
+ ulong GetWidth() { return (nWidth < 20 ? 20 : nWidth); }
+};
+
+#endif // BASICIDE_LINENUMBERWINDOW_HXX