|
From: CVS C. to T. <the...@li...> - 2011-06-04 10:10:34
|
Revision: 652
http://themis.svn.sourceforge.net/themis/?rev=652&view=rev
Author: mark_hellegers
Date: 2011-06-04 10:10:26 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
- Added class UrlItem which overrides the DrawItem call of BStringItem, so it can draw a truncated string.
- Used this new class to simplify the url popup window.
Modified Paths:
--------------
trunk/themis/framework/GlobalHistory.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.h
trunk/themis/makefile
Added Paths:
-----------
trunk/themis/framework/UrlItem.cpp
trunk/themis/framework/UrlItem.hpp
Modified: trunk/themis/framework/GlobalHistory.cpp
===================================================================
--- trunk/themis/framework/GlobalHistory.cpp 2011-06-02 22:31:02 UTC (rev 651)
+++ trunk/themis/framework/GlobalHistory.cpp 2011-06-04 10:10:26 UTC (rev 652)
@@ -37,6 +37,7 @@
// Themis headers
#include "../common/PrefsDefs.h"
#include "GlobalHistory.h"
+#include "UrlItem.hpp"
GlobalHistory :: GlobalHistory(int8 depth, int8 count) {
@@ -342,7 +343,7 @@
}
}
if (!found) {
- list->AddItem(new BStringItem(cached_url.String()));
+ list->AddItem(new UrlItem(cached_url.String()));
}
}
matchFound = false;
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-02 22:31:02 UTC (rev 651)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-04 10:10:26 UTC (rev 652)
@@ -14,6 +14,7 @@
#include "win.h"
#include "../common/commondefs.h"
#include "ThemisUrlPopUpWindow.h"
+#include "UrlItem.hpp"
ThemisUrlPopUpWindow :: ThemisUrlPopUpWindow(BWindow * aParent,
BRect aFrame,
@@ -31,7 +32,6 @@
lastitem = 0;
vscroll = NULL;
url_list = new BList;
- trunc_list = new BList;
urlpopupview = new ThemisUrlPopUpView(Bounds());
AddChild(urlpopupview);
@@ -40,22 +40,16 @@
ThemisUrlPopUpWindow::~ThemisUrlPopUpWindow()
{
- BStringItem* item = NULL;
+ UrlItem * item = NULL;
- for( int32 i = 0; i < url_list->CountItems(); i++ )
+ int32 length = url_list->CountItems();
+ for( int32 i = 0; i < length; i++ )
{
- item = ( BStringItem* )url_list->RemoveItem( (int32)0 );
+ item = (UrlItem *)url_list->RemoveItem((int32)0);
delete item;
}
- for(int32 i = 0; i < url_list->CountItems(); i++ )
- {
- item = ( BStringItem* )trunc_list->RemoveItem( (int32)0 );
- delete item;
- }
-
delete url_list;
- delete trunc_list;
}
void
@@ -146,44 +140,22 @@
}
}
-void
-ThemisUrlPopUpWindow::ListToDisplay( BList* list )
-{
- //cout << "ThemisUrlPopUpWindow::ListToDisplay()" << endl;
-
- if(list != NULL) {
+void ThemisUrlPopUpWindow :: ListToDisplay(BList * list) {
+
+ if (list != NULL) {
// First delete the contents of the old lists.
- if (url_list != NULL) {
- int32 length = url_list->CountItems();
- for (int32 i = 0; i < length; i++) {
- delete url_list->RemoveItem((int32) 0);
- }
+ int32 length = url_list->CountItems();
+ for (int32 i = 0; i < length; i++) {
+ delete url_list->RemoveItem((int32) 0);
}
- if (trunc_list != NULL) {
- int32 length = trunc_list->CountItems();
- for (int32 i = 0; i < length; i++) {
- delete trunc_list->RemoveItem((int32) 0);
- }
- }
-
- // we need the url_list with untruncated strings
- url_list->AddList(list);
// we need to totally independant but similar BLists
// ( copying with the copy-constructor won't do it )
- int i = 0;
- BStringItem * item;
- while (url_list->ItemAt( i ) != NULL) {
- item = ( BStringItem* )url_list->ItemAt(i);
- trunc_list->AddItem( new BStringItem(item->Text()));
- i++;
- }
+ url_list->AddList(list);
urlpopupview->ulv->MakeEmpty();
- urlpopupview->ulv->AddList(trunc_list);
+ urlpopupview->ulv->AddList(url_list);
- TruncateUrlStrings();
-
ResizeToPrefered();
}
}
@@ -241,7 +213,6 @@
0,
newheight - urlpopupview->ulv->Bounds().bottom );
}
- TruncateUrlStrings();
}
else
{
@@ -258,34 +229,9 @@
urlpopupview->Bounds().right + B_V_SCROLL_BAR_WIDTH,
urlpopupview->Bounds().bottom );
}
- TruncateUrlStrings();
}
}
-void ThemisUrlPopUpWindow :: TruncateUrlStrings() {
-
- int i = 0;
- BStringItem* urlitem = NULL;
- BStringItem* truncitem = NULL;
- BString text;
-
- while (url_list->ItemAt(i) != NULL) {
- urlitem = (BStringItem *)url_list->ItemAt(i);
- text.SetTo(urlitem->Text());
-
- urlpopupview->TruncateString(
- &text,
- B_TRUNCATE_END,
- urlpopupview->ulv->Bounds().right - 10);
-
- truncitem = (BStringItem *)urlpopupview->ulv->ItemAt(i);
- if (truncitem != NULL)
- truncitem->SetText(text.String());
-
- i++;
- }
-}
-
bool ThemisUrlPopUpWindow :: HasScrollBar() const {
return (vscroll != NULL);
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-02 22:31:02 UTC (rev 651)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-04 10:10:26 UTC (rev 652)
@@ -20,7 +20,6 @@
uint32 lastitem;
BList * url_list;
- BList * trunc_list;
BScrollBar * vscroll;
ThemisUrlPopUpView * urlpopupview;
@@ -31,7 +30,6 @@
virtual void MessageReceived(BMessage *msg);
void ListToDisplay(BList* list);
void ResizeToPrefered();
- void TruncateUrlStrings();
bool HasScrollBar() const;
Added: trunk/themis/framework/UrlItem.cpp
===================================================================
--- trunk/themis/framework/UrlItem.cpp (rev 0)
+++ trunk/themis/framework/UrlItem.cpp 2011-06-04 10:10:26 UTC (rev 652)
@@ -0,0 +1,77 @@
+/*
+ Copyright (c) 2011 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: June 4, 2011
+*/
+
+/* UrlItem implementation
+ See UrlItem.hpp for more information
+
+*/
+
+// BeOS headers
+#include "be/interface/GraphicsDefs.h"
+#include "be/interface/InterfaceDefs.h"
+#include "be/interface/View.h"
+#include "be/support/String.h"
+
+// Themis headers
+#include "UrlItem.hpp"
+
+UrlItem :: UrlItem(const char * aUrl)
+ : BStringItem(aUrl) {
+
+}
+
+void UrlItem :: DrawItem(BView * aOwner,
+ BRect aFrame,
+ bool aComplete) {
+
+ rgb_color color;
+ if (IsSelected() || aComplete) {
+ if (IsSelected()) {
+ color = ui_color(B_MENU_BACKGROUND_COLOR);
+ }
+ else {
+ color = aOwner->ViewColor();
+ }
+ aOwner->SetHighColor(color);
+ aOwner->FillRect(aFrame);
+ }
+
+ color = ui_color(B_MENU_ITEM_TEXT_COLOR);
+ aOwner->SetHighColor(color);
+ BString url(Text());
+ aOwner->TruncateString(
+ &url,
+ B_TRUNCATE_END,
+ aFrame.right - 10);
+
+ aOwner->MovePenTo(aFrame.left + 4, aFrame.bottom - 2);
+ aOwner->DrawString(url.String());
+
+}
Added: trunk/themis/framework/UrlItem.hpp
===================================================================
--- trunk/themis/framework/UrlItem.hpp (rev 0)
+++ trunk/themis/framework/UrlItem.hpp 2011-06-04 10:10:26 UTC (rev 652)
@@ -0,0 +1,49 @@
+/*
+ Copyright (c) 2011 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: June 4, 2011
+*/
+
+#ifndef URLITEM_HPP
+#define URLITEM_HPP
+
+// BeOS headers
+#include <ListItem.h>
+
+class UrlItem : public BStringItem {
+
+ public:
+ UrlItem(const char * aUrl);
+
+ virtual void DrawItem(BView * aOwner,
+ BRect aFrame,
+ bool aComplete = false);
+
+
+};
+
+#endif
Modified: trunk/themis/makefile
===================================================================
--- trunk/themis/makefile 2011-06-02 22:31:02 UTC (rev 651)
+++ trunk/themis/makefile 2011-06-04 10:10:26 UTC (rev 652)
@@ -86,7 +86,8 @@
framework/SiteHandler.cpp \
framework/SiteEntry.cpp \
framework/UrlEntry.cpp \
- framework/date.cpp
+ framework/date.cpp \
+ framework/UrlItem.cpp
# framework/UrlHandler.cpp
COMMONSOURCES= \
common/plugclass.cpp \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|