|
From: CVS C. to T. <the...@li...> - 2016-03-05 16:27:52
|
Revision: 728
http://sourceforge.net/p/themis/code/728
Author: mark_hellegers
Date: 2016-03-05 16:27:49 +0000 (Sat, 05 Mar 2016)
Log Message:
-----------
Implement horizontal scrolling in our own TOutlineListView (derived from BOutlineListView) and use that class where we were using BOutlineListView.
Modified Paths:
--------------
trunk/themis/makefile
trunk/themis/modules/CSSViewer/CSSView.cpp
trunk/themis/modules/CSSViewer/CSSView.hpp
trunk/themis/modules/DOMView/DOMView.cpp
trunk/themis/modules/DOMView/DOMView.h
Added Paths:
-----------
trunk/themis/common/TOutlineListView.cpp
trunk/themis/common/TOutlineListView.hpp
Added: trunk/themis/common/TOutlineListView.cpp
===================================================================
--- trunk/themis/common/TOutlineListView.cpp (rev 0)
+++ trunk/themis/common/TOutlineListView.cpp 2016-03-05 16:27:49 UTC (rev 728)
@@ -0,0 +1,85 @@
+/* TOutlineListView implementation
+ See TOutlineListView.hpp for more information
+*/
+
+// TOutlineListView header
+#include "TOutlineListView.hpp"
+
+// BeOS headers
+#include <ScrollView.h>
+
+TOutlineListView :: TOutlineListView(
+ BRect aFrame,
+ const char * aName,
+ list_view_type aType,
+ uint32 aResizingMode,
+ uint32 aFlags)
+ : BOutlineListView(
+ aFrame,
+ aName,
+ aType,
+ aResizingMode,
+ aFlags) {
+
+ fScroller = NULL;
+ fPrefWidth = 0;
+}
+
+TOutlineListView :: ~TOutlineListView() {
+
+}
+
+void TOutlineListView :: Draw(BRect aUpdateRect) {
+
+ BOutlineListView::Draw(aUpdateRect);
+
+ float prefWidth;
+ float prefHeight;
+ GetPreferredSize(&prefWidth, &prefHeight);
+
+ if (fPrefWidth != prefWidth) {
+ BRect rect = Bounds();
+ float proportion = 1;
+ if (rect.Width() < prefWidth) {
+ proportion = rect.Width() / prefWidth;
+ }
+
+ if (fScroller != NULL) {
+ BScrollBar * scrollBar = fScroller->ScrollBar(B_HORIZONTAL);
+ if (scrollBar != NULL) {
+ scrollBar->SetProportion(proportion);
+ scrollBar->SetRange(0, prefWidth - rect.Width());
+ }
+ }
+ fPrefWidth = prefWidth;
+ }
+
+}
+
+void TOutlineListView :: TargetedByScrollView(BScrollView * aScroller) {
+
+ BOutlineListView::TargetedByScrollView(aScroller);
+
+ fScroller = aScroller;
+
+}
+
+// Haiku's version of GetPreferredSize works fine
+#ifndef HAIKU
+
+void TOutlineListView :: GetPreferredSize(float * aWidth, float * aHeight) {
+
+ BOutlineListView::GetPreferredSize(aWidth, aHeight);
+
+ // Correct preferred width of BOutlineListView as BeOS calculates it wrong.
+ int32 count = CountItems();
+ float width = 0;
+ for (int32 i = 0; i < count; i++) {
+ width = ItemAt(i)->Width() + (ItemAt(i)->OutlineLevel() + 1) * be_plain_font->Size();
+ if (width > *aWidth)
+ *aWidth = width;
+ }
+
+}
+
+#endif
Added: trunk/themis/common/TOutlineListView.hpp
===================================================================
--- trunk/themis/common/TOutlineListView.hpp (rev 0)
+++ trunk/themis/common/TOutlineListView.hpp 2016-03-05 16:27:49 UTC (rev 728)
@@ -0,0 +1,44 @@
+/*
+ TOutlineListView
+ Same as a BOutlineListView, but properly sizes the horizontal scrollbar
+
+ Mark Hellegers (ma...@fi...)
+ 05-03-2016
+
+*/
+
+#ifndef TOUTLINELISTVIEW_HPP
+#define TOUTLINELISTVIEW_HPP
+
+// BeOS headers
+#include <OutlineListView.h>
+
+// Declarations used
+class BScrollView;
+
+class TOutlineListView : public BOutlineListView {
+
+ private:
+ BScrollView * fScroller;
+ float fPrefWidth;
+
+ public:
+ TOutlineListView(
+ BRect aFrame,
+ const char * aName,
+ list_view_type aType = B_SINGLE_SELECTION_LIST,
+ uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
+ uint32 aFlags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
+ virtual ~TOutlineListView();
+
+ virtual void Draw(BRect aUpdateRect);
+ virtual void TargetedByScrollView(BScrollView * aScroller);
+
+// Haiku's version of GetPreferredSize works fine
+#ifndef HAIKU
+ virtual void GetPreferredSize(float * aWidth, float * aHeight);
+#endif
+
+};
+
+#endif
Modified: trunk/themis/makefile
===================================================================
--- trunk/themis/makefile 2015-06-07 00:06:48 UTC (rev 727)
+++ trunk/themis/makefile 2016-03-05 16:27:49 UTC (rev 728)
@@ -107,7 +107,8 @@
common/CSSDOMEntry.cpp \
common/ColumnListView.cpp \
common/ColumnTypes.cpp \
- common/ColorTools.cpp
+ common/ColorTools.cpp \
+ common/TOutlineListView.cpp
#add similar lines for new plugins, libraries, etc.
HTTPADDONSOURCES= \
http/optionshandler.cpp \
Modified: trunk/themis/modules/CSSViewer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSViewer/CSSView.cpp 2015-06-07 00:06:48 UTC (rev 727)
+++ trunk/themis/modules/CSSViewer/CSSView.cpp 2016-03-05 16:27:49 UTC (rev 728)
@@ -58,6 +58,7 @@
#include "ColumnListView.h"
#include "ColumnTypes.h"
#include "TTextView.hpp"
+#include "TOutlineListView.hpp"
// Constants used
@@ -87,7 +88,7 @@
treeRect.bottom -= B_H_SCROLL_BAR_HEIGHT;
treeRect.right -= 350;
treeRect.right -= B_V_SCROLL_BAR_WIDTH;
- mTree = new BOutlineListView(treeRect,
+ mTree = new TOutlineListView(treeRect,
"CSSView",
B_SINGLE_SELECTION_LIST,
B_FOLLOW_ALL_SIDES);
Modified: trunk/themis/modules/CSSViewer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSViewer/CSSView.hpp 2015-06-07 00:06:48 UTC (rev 727)
+++ trunk/themis/modules/CSSViewer/CSSView.hpp 2016-03-05 16:27:49 UTC (rev 728)
@@ -38,7 +38,6 @@
#include <SupportDefs.h>
#include <Handler.h>
#include <Window.h>
-#include <OutlineListView.h>
// DOM Style headers
#include "CSSStyleSheet.hpp"
@@ -46,11 +45,12 @@
// Declarations of Themis classes
class TTextView;
class BColumnListView;
+class TOutlineListView;
class CSSView : public BWindow {
private:
- BOutlineListView * mTree;
+ TOutlineListView * mTree;
CSSStyleSheetPtr mStyleSheet;
BStringItem * mMediaItem;
BStringItem * mGeneralItem;
Modified: trunk/themis/modules/DOMView/DOMView.cpp
===================================================================
--- trunk/themis/modules/DOMView/DOMView.cpp 2015-06-07 00:06:48 UTC (rev 727)
+++ trunk/themis/modules/DOMView/DOMView.cpp 2016-03-05 16:27:49 UTC (rev 728)
@@ -55,6 +55,7 @@
// Themis headers
#include "TTextView.hpp"
+#include "TOutlineListView.hpp"
DOMView :: DOMView(TDocumentPtr aDocument)
: BWindow(BRect(100, 100, 450, 400),
@@ -76,7 +77,7 @@
treeRect.bottom -= B_H_SCROLL_BAR_HEIGHT;
treeRect.right -= 200;
treeRect.right -= B_V_SCROLL_BAR_WIDTH;
- mTree = new BOutlineListView(treeRect,
+ mTree = new TOutlineListView(treeRect,
"DOMView",
B_SINGLE_SELECTION_LIST,
B_FOLLOW_ALL_SIDES);
Modified: trunk/themis/modules/DOMView/DOMView.h
===================================================================
--- trunk/themis/modules/DOMView/DOMView.h 2015-06-07 00:06:48 UTC (rev 727)
+++ trunk/themis/modules/DOMView/DOMView.h 2016-03-05 16:27:49 UTC (rev 728)
@@ -38,7 +38,6 @@
#include <SupportDefs.h>
#include <Handler.h>
#include <Window.h>
-#include <OutlineListView.h>
#include <ListView.h>
#include <PopUpMenu.h>
@@ -50,6 +49,7 @@
// Declarations of Themis classes
class TTextView;
+class TOutlineListView;
// Namespaces used
using namespace std;
@@ -61,7 +61,7 @@
class DOMView : public BWindow {
private:
- BOutlineListView * mTree;
+ TOutlineListView * mTree;
BListView * mAttributes;
BListView * mValues;
BPopUpMenu * mTextMenu;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|