You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
(12) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
|
Feb
(23) |
Mar
(6) |
Apr
(6) |
May
(2) |
Jun
(41) |
Jul
(29) |
Aug
(28) |
Sep
(51) |
Oct
(19) |
Nov
(27) |
Dec
|
| 2003 |
Jan
(1) |
Feb
(11) |
Mar
(20) |
Apr
(18) |
May
(23) |
Jun
(18) |
Jul
(13) |
Aug
(49) |
Sep
(20) |
Oct
(3) |
Nov
(24) |
Dec
(1) |
| 2004 |
Jan
(12) |
Feb
(17) |
Mar
(38) |
Apr
(7) |
May
(22) |
Jun
(4) |
Jul
(26) |
Aug
(17) |
Sep
(18) |
Oct
(17) |
Nov
|
Dec
|
| 2005 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(14) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
| 2009 |
Jan
(5) |
Feb
(12) |
Mar
|
Apr
(10) |
May
(7) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(22) |
Dec
(6) |
| 2010 |
Jan
(14) |
Feb
(4) |
Mar
(4) |
Apr
(2) |
May
(3) |
Jun
|
Jul
|
Aug
(7) |
Sep
|
Oct
(2) |
Nov
(39) |
Dec
(3) |
| 2011 |
Jan
(28) |
Feb
(14) |
Mar
(8) |
Apr
(3) |
May
|
Jun
(14) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(3) |
Nov
(4) |
Dec
|
| 2012 |
Jan
(1) |
Feb
(12) |
Mar
(7) |
Apr
(4) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(11) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
(13) |
May
(2) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(2) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
(5) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: CVS C. to T. <the...@li...> - 2011-11-12 15:31:24
|
Revision: 670
http://themis.svn.sourceforge.net/themis/?rev=670&view=rev
Author: mark_hellegers
Date: 2011-11-12 15:31:17 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
Another attempt to reduce the cpu usage that is caused by busy looping.
Modified Paths:
--------------
trunk/themis/framework/tcpmanager.cpp
Modified: trunk/themis/framework/tcpmanager.cpp
===================================================================
--- trunk/themis/framework/tcpmanager.cpp 2011-11-09 23:43:31 UTC (rev 669)
+++ trunk/themis/framework/tcpmanager.cpp 2011-11-12 15:31:17 UTC (rev 670)
@@ -125,6 +125,7 @@
int32 connect_count = 0;
int32 current_time;
// int32 last_used;
+ bool actionTaken = false; // When no action has been taken in a run of the while loop, snooze to prevent a busy loop.
int32 time_out=DEFAULT_TIMEOUT;
@@ -148,18 +149,24 @@
if (!connection->already_connected)
connection->ConnectionEstablished();
connection->NotifyConnect();
+ actionTaken = true;
} else {
if (connection->IsDataWaiting()) {
connection->RetrieveData();
- if (connection->owner!=NULL) {
+ if (connection->owner!=NULL && connection->DataSize() > 0) {
connection->owner->DataIsWaiting(connection);
+ actionTaken = true;
}
+ else if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
+ connection->TimeOut();
+ Disconnect(connection);
+ actionTaken = true;
+ }
}
else if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
- // if (connection->owner!=NULL)
- // connection->owner->DestroyingConnectionObject(connection);
connection->TimeOut();
Disconnect(connection);
+ actionTaken = true;
}
}
} else {
@@ -168,25 +175,25 @@
int32 lastused=connection->LastUsed();
connection->RetrieveData();
connection->lastusedtime=lastused;
+ actionTaken = true;
}
else if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
- // if (connection->owner!=NULL)
- // connection->owner->DestroyingConnectionObject(connection);
connection->TimeOut();
Disconnect(connection);
+ actionTaken = true;
}
}
} else {
if (!connection->NotifiedDisconnect()) {
connection->NotifyDisconnect();
// Disconnect(connection);
+ actionTaken = true;
}
else {
if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
- // if (connection->owner!=NULL)
- // connection->owner->DestroyingConnectionObject(connection);
connection->TimeOut();
Disconnect(connection);
+ actionTaken = true;
}
}
}
@@ -200,11 +207,12 @@
connect_count = 0;
}
- if (connect_count == 0) {
- // No connections, so take it easy before we check again for connections.
+ if (!actionTaken) {
+ // Nothing done, so take it easy before we check again for connections.
// Otherwise we create a busy loop.
snooze(25000);
}
+ actionTaken = false;
// release_sem(process_sem_2);
// }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-11-09 23:43:37
|
Revision: 669
http://themis.svn.sourceforge.net/themis/?rev=669&view=rev
Author: mark_hellegers
Date: 2011-11-09 23:43:31 +0000 (Wed, 09 Nov 2011)
Log Message:
-----------
- Added an extra lock in NotifyDisconnect as it was accessing member variables.
- Only called timeout and disconnect when no other actions have been taken. Some other calls can end up calling Disconnect before the timeout check. Follow connection->owner->DataIsWaiting(connection) for an example.
Modified Paths:
--------------
trunk/themis/framework/connection.cpp
trunk/themis/framework/tcpmanager.cpp
Modified: trunk/themis/framework/connection.cpp
===================================================================
--- trunk/themis/framework/connection.cpp 2011-11-09 19:09:27 UTC (rev 668)
+++ trunk/themis/framework/connection.cpp 2011-11-09 23:43:31 UTC (rev 669)
@@ -133,8 +133,8 @@
return notified;
}
void Connection::NotifyDisconnect() {
-// BAutolock alock(lock);
-// if (alock.IsLocked()) {
+ BAutolock alock(lock);
+ if (alock.IsLocked()) {
if (owner!=NULL) {
if (notified_disconnect==0)
{
@@ -144,7 +144,7 @@
atomic_add(¬ified_disconnect,1);
}
}
-// }
+ }
}
Modified: trunk/themis/framework/tcpmanager.cpp
===================================================================
--- trunk/themis/framework/tcpmanager.cpp 2011-11-09 19:09:27 UTC (rev 668)
+++ trunk/themis/framework/tcpmanager.cpp 2011-11-09 23:43:31 UTC (rev 669)
@@ -122,7 +122,7 @@
int32 TCPManager::_Manager_Thread() {
// set_alarm(25000,B_PERIODIC_ALARM);
Connection *connection;
- int32 connect_count;
+ int32 connect_count = 0;
int32 current_time;
// int32 last_used;
@@ -131,14 +131,14 @@
while(!_quitter_) {
// if (acquire_sem(process_sem_1)==B_OK) {
// printf("processing\n");
- connect_count=Connection::CountConnections();
-
- if (connect_count>0) {
- current_time=real_time_clock();
- for (int32 i=0; i<connect_count; i++) {
+ if (lock.LockWithTimeout(25000)==B_OK)
+ {
+ connect_count=Connection::CountConnections();
+
+ if (connect_count>0) {
+ current_time=real_time_clock();
+ for (int32 i=0; i<connect_count; i++) {
- if (lock.LockWithTimeout(25000)==B_OK)
- {
// printf("TCP Manager: lock acquired\n");
connection=Connection::ConnectionAt(i);
if (connection != NULL && Connection::HasConnection(connection)) {
@@ -155,6 +155,12 @@
connection->owner->DataIsWaiting(connection);
}
}
+ else if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
+ // if (connection->owner!=NULL)
+ // connection->owner->DestroyingConnectionObject(connection);
+ connection->TimeOut();
+ Disconnect(connection);
+ }
}
} else {
if (connection->IsDataWaiting()) {
@@ -163,13 +169,13 @@
connection->RetrieveData();
connection->lastusedtime=lastused;
}
+ else if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
+ // if (connection->owner!=NULL)
+ // connection->owner->DestroyingConnectionObject(connection);
+ connection->TimeOut();
+ Disconnect(connection);
+ }
}
- if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
- // if (connection->owner!=NULL)
- // connection->owner->DestroyingConnectionObject(connection);
- connection->TimeOut();
- Disconnect(connection);
- }
} else {
if (!connection->NotifiedDisconnect()) {
connection->NotifyDisconnect();
@@ -185,13 +191,16 @@
}
}
}
- lock.Unlock();
}
// snooze(10000);
}
-
+ lock.Unlock();
}
else {
+ connect_count = 0;
+ }
+
+ if (connect_count == 0) {
// No connections, so take it easy before we check again for connections.
// Otherwise we create a busy loop.
snooze(25000);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-11-09 19:09:34
|
Revision: 668
http://themis.svn.sourceforge.net/themis/?rev=668&view=rev
Author: mark_hellegers
Date: 2011-11-09 19:09:27 +0000 (Wed, 09 Nov 2011)
Log Message:
-----------
- Avoid the busy loop by snoozing when there are no connections.
- Small cleanup of the code.
Modified Paths:
--------------
trunk/themis/framework/tcpmanager.cpp
Modified: trunk/themis/framework/tcpmanager.cpp
===================================================================
--- trunk/themis/framework/tcpmanager.cpp 2011-10-08 19:59:17 UTC (rev 667)
+++ trunk/themis/framework/tcpmanager.cpp 2011-11-09 19:09:27 UTC (rev 668)
@@ -141,65 +141,48 @@
{
// printf("TCP Manager: lock acquired\n");
connection=Connection::ConnectionAt(i);
- if (connection == NULL || !Connection::HasConnection(connection))
- {
- lock.Unlock();
- //snooze(10000);
- continue;
- }
- if (connection->IsConnected())
- {
- if (connection->IsInUse())
- {
- if (!connection->NotifiedConnect())
- {
- if (!connection->already_connected)
- connection->ConnectionEstablished();
- connection->NotifyConnect();
- } else
- {
- if (connection->IsDataWaiting())
- {
- connection->RetrieveData();
- if (connection->owner!=NULL)
- {
- connection->owner->DataIsWaiting(connection);
+ if (connection != NULL && Connection::HasConnection(connection)) {
+ if (connection->IsConnected()) {
+ if (connection->IsInUse()) {
+ if (!connection->NotifiedConnect()) {
+ if (!connection->already_connected)
+ connection->ConnectionEstablished();
+ connection->NotifyConnect();
+ } else {
+ if (connection->IsDataWaiting()) {
+ connection->RetrieveData();
+ if (connection->owner!=NULL) {
+ connection->owner->DataIsWaiting(connection);
+ }
}
}
+ } else {
+ if (connection->IsDataWaiting()) {
+ // printf("TCP Manager: data is waiting on unused connection; receiving and flushing data\n");
+ int32 lastused=connection->LastUsed();
+ connection->RetrieveData();
+ connection->lastusedtime=lastused;
+ }
}
- } else
- {
- if (connection->IsDataWaiting())
- {
-// printf("TCP Manager: data is waiting on unused connection; receiving and flushing data\n");
- int32 lastused=connection->LastUsed();
- connection->RetrieveData();
- connection->lastusedtime=lastused;
- }
- }
- if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out))
- {
-// if (connection->owner!=NULL)
-// connection->owner->DestroyingConnectionObject(connection);
- connection->TimeOut();
- Disconnect(connection);
- }
- } else
- {
- if (!connection->NotifiedDisconnect())
- {
- connection->NotifyDisconnect();
-// Disconnect(connection);
- }
- else
- {
- if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out))
- {
-// if (connection->owner!=NULL)
-// connection->owner->DestroyingConnectionObject(connection);
+ if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
+ // if (connection->owner!=NULL)
+ // connection->owner->DestroyingConnectionObject(connection);
connection->TimeOut();
Disconnect(connection);
}
+ } else {
+ if (!connection->NotifiedDisconnect()) {
+ connection->NotifyDisconnect();
+ // Disconnect(connection);
+ }
+ else {
+ if ((connection->LastUsed()!=0) && ((current_time-connection->LastUsed())>=time_out)) {
+ // if (connection->owner!=NULL)
+ // connection->owner->DestroyingConnectionObject(connection);
+ connection->TimeOut();
+ Disconnect(connection);
+ }
+ }
}
}
lock.Unlock();
@@ -208,7 +191,11 @@
}
}
- //snooze(25000);
+ else {
+ // No connections, so take it easy before we check again for connections.
+ // Otherwise we create a busy loop.
+ snooze(25000);
+ }
// release_sem(process_sem_2);
// }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-10-08 19:59:23
|
Revision: 667
http://themis.svn.sourceforge.net/themis/?rev=667&view=rev
Author: mark_hellegers
Date: 2011-10-08 19:59:17 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
Removed another unused variable.
Modified Paths:
--------------
trunk/themis/framework/win.cpp
trunk/themis/framework/win.h
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-10-08 19:44:30 UTC (rev 666)
+++ trunk/themis/framework/win.cpp 2011-10-08 19:59:17 UTC (rev 667)
@@ -77,7 +77,6 @@
BScreen Screen;
SetSizeLimits(300, Screen.Frame().right, 200, Screen.Frame().bottom);
- protocol=0;
urlpopupwindow = NULL;
fNextWindow = NULL;
fOldFrame = Frame();
Modified: trunk/themis/framework/win.h
===================================================================
--- trunk/themis/framework/win.h 2011-10-08 19:44:30 UTC (rev 666)
+++ trunk/themis/framework/win.h 2011-10-08 19:59:17 UTC (rev 667)
@@ -54,7 +54,6 @@
class Win : public BWindow, public MessageSystem {
private:
- uint32 protocol;
Win * fNextWindow;
BRect fOldFrame;
bool fMaximized;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-10-08 19:44:37
|
Revision: 666
http://themis.svn.sourceforge.net/themis/?rev=666&view=rev
Author: mark_hellegers
Date: 2011-10-08 19:44:30 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
Moved the actual setting of the history depth to the app
Modified Paths:
--------------
trunk/themis/framework/PrefsWin.cpp
trunk/themis/framework/app.cpp
Modified: trunk/themis/framework/PrefsWin.cpp
===================================================================
--- trunk/themis/framework/PrefsWin.cpp 2011-10-08 19:18:10 UTC (rev 665)
+++ trunk/themis/framework/PrefsWin.cpp 2011-10-08 19:44:30 UTC (rev 666)
@@ -15,7 +15,6 @@
// Themis headers
#include "app.h"
-#include "win.h"
#include "commondefs.h"
#include "plugclass.h"
#include "GlobalHistory.h"
@@ -304,23 +303,8 @@
}
else {
/* tell all windows to update their tab history depths */
- Win* win = ((App*)be_app)->FirstWindow();
-
- if(win == NULL) {
- printf("PREFS: First Window not valid anymore!\n");
- break;
- }
-
- BMessenger* msgr = new BMessenger(NULL, win, NULL);
- msgr->SendMessage(RE_INIT_TABHISTORY);
-
- while(win->NextWindow() != NULL) {
- win = win->NextWindow();
- delete msgr;
- msgr = new BMessenger(NULL, win, NULL);
- msgr->SendMessage(RE_INIT_TABHISTORY);
- }
- delete msgr;
+ /* use the app to do this*/
+ be_app_messenger.SendMessage(RE_INIT_TABHISTORY);
}
break;
Modified: trunk/themis/framework/app.cpp
===================================================================
--- trunk/themis/framework/app.cpp 2011-10-08 19:18:10 UTC (rev 665)
+++ trunk/themis/framework/app.cpp 2011-10-08 19:44:30 UTC (rev 666)
@@ -279,6 +279,17 @@
break;
}
+ case RE_INIT_TABHISTORY :
+ {
+ Win * win = FirstWindow();
+
+ while (win != NULL) {
+ BMessenger msgr(NULL, win, NULL);
+ msgr.SendMessage(RE_INIT_TABHISTORY);
+ win = win->NextWindow();
+ }
+ break;
+ }
case PREFSWIN_CLOSE :
{
printf( "APP PREFSWIN_CLOSE\n" );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-10-08 19:18:16
|
Revision: 665
http://themis.svn.sourceforge.net/themis/?rev=665&view=rev
Author: mark_hellegers
Date: 2011-10-08 19:18:10 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
Removed unused variable.
Modified Paths:
--------------
trunk/themis/framework/win.cpp
trunk/themis/framework/win.h
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-08-15 23:48:04 UTC (rev 664)
+++ trunk/themis/framework/win.cpp 2011-10-08 19:18:10 UTC (rev 665)
@@ -78,7 +78,6 @@
SetSizeLimits(300, Screen.Frame().right, 200, Screen.Frame().bottom);
protocol=0;
- startup=true;
urlpopupwindow = NULL;
fNextWindow = NULL;
fOldFrame = Frame();
@@ -472,11 +471,6 @@
void Win :: WindowActivated(bool active) {
- if (startup) {
- startup = false;
- printf("WindowActivated\n");
- }
-
if(active == false) {
CloseUrlPopUpWindow();
}
Modified: trunk/themis/framework/win.h
===================================================================
--- trunk/themis/framework/win.h 2011-08-15 23:48:04 UTC (rev 664)
+++ trunk/themis/framework/win.h 2011-10-08 19:18:10 UTC (rev 665)
@@ -54,7 +54,6 @@
class Win : public BWindow, public MessageSystem {
private:
- bool startup;
uint32 protocol;
Win * fNextWindow;
BRect fOldFrame;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-08-15 23:48:11
|
Revision: 664
http://themis.svn.sourceforge.net/themis/?rev=664&view=rev
Author: z3r0_one
Date: 2011-08-15 23:48:04 +0000 (Mon, 15 Aug 2011)
Log Message:
-----------
A start on removing some deadlocks in TCP/HTTP layers.
Modified Paths:
--------------
trunk/themis/framework/connection.cpp
trunk/themis/framework/tcpmanager.cpp
trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
trunk/themis/modules/http/httpv4.cpp
Modified: trunk/themis/framework/connection.cpp
===================================================================
--- trunk/themis/framework/connection.cpp 2011-07-30 18:48:36 UTC (rev 663)
+++ trunk/themis/framework/connection.cpp 2011-08-15 23:48:04 UTC (rev 664)
@@ -89,8 +89,8 @@
}
int32 Connection::CountConnections() {
int32 count=0;
- BAutolock alock(ListLock);
- if (alock.IsLocked())
+ //BAutolock alock(ListLock);
+ //if (alock.IsLocked())
if (ConnectionList!=NULL)
count=ConnectionList->CountItems();
return count;
@@ -452,17 +452,19 @@
if (lock.LockWithTimeout(10000)==B_OK) {
if (socket_id>=0) {
struct timeval tv;
- tv.tv_sec=2;
- tv.tv_usec=0;
+ tv.tv_sec=0;//2;
+ tv.tv_usec=50000;
struct fd_set fds;
FD_ZERO(&fds);
FD_SET(socket_id,&fds);
int32 err=select(socket_id+1,&fds,NULL,NULL,&tv);
- if (err<=0) {
+ if (err<0) {
+ //printf("IsDataWaiting socket error\n");
lock.Unlock();
return false;
}
waiting_data=FD_ISSET(socket_id,&fds);
+ printf("IsDataWaiting: %s\n",(waiting_data ? "yes":"no"));
}
lock.Unlock();
}
@@ -744,8 +746,8 @@
}
int32 Connection::IsInUse() {
int32 isinuse=0;
- BAutolock alock(lock);
- if (alock.IsLocked())
+ //BAutolock alock(lock);
+ //if (alock.IsLocked())
isinuse=in_use;
return isinuse;
}
@@ -788,8 +790,8 @@
// fflush(stdout);
// BAutolock alock(lock);
if (lock.LockWithTimeout(15000)==B_OK) {
- int16 size=10240;
- int16 bytes=0;
+ int32 size=1048576;
+ int32 bytes=0;
unsigned char *data=new unsigned char[size];
if (!IsInUse())
{
@@ -898,7 +900,7 @@
data=NULL;
lock.Unlock();
}
-// printf("Connection::Retrieve() is done.\n");
+ printf("Connection::Retrieve() is done.\n");
}
int32 Connection::LastUsed(){
return lastusedtime;
Modified: trunk/themis/framework/tcpmanager.cpp
===================================================================
--- trunk/themis/framework/tcpmanager.cpp 2011-07-30 18:48:36 UTC (rev 663)
+++ trunk/themis/framework/tcpmanager.cpp 2011-08-15 23:48:04 UTC (rev 664)
@@ -144,7 +144,7 @@
if (connection == NULL || !Connection::HasConnection(connection))
{
lock.Unlock();
- snooze(10000);
+ //snooze(10000);
continue;
}
if (connection->IsConnected())
@@ -162,7 +162,9 @@
{
connection->RetrieveData();
if (connection->owner!=NULL)
+ {
connection->owner->DataIsWaiting(connection);
+ }
}
}
} else
@@ -202,11 +204,11 @@
}
lock.Unlock();
}
- snooze(10000);
+ // snooze(10000);
}
}
- snooze(25000);
+ //snooze(25000);
// release_sem(process_sem_2);
// }
@@ -220,8 +222,8 @@
Connection *TCPManager::CreateConnection(NetworkableObject *net_obj,const char *host,uint16 port,bool secure,bool asynch) {
//printf("CreateConnection begun\n");
Connection *connection=NULL;
- BAutolock alock(lock);
- if (alock.IsLocked()) {
+// BAutolock alock(lock);
+// if (alock.IsLocked()) {
int32 connections=0;
Connection *target_connection=NULL;
connections=Connection::CountConnections();
@@ -251,7 +253,7 @@
sessions_created++;
}
- }
+// }
//printf("CreateConnection is done: %p\n",connection);
return connection;
}
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-07-30 18:48:36 UTC (rev 663)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-08-15 23:48:04 UTC (rev 664)
@@ -129,7 +129,7 @@
}
Window()->SetTitle(title.c_str());
SetViewColor(B_TRANSPARENT_COLOR);
-// mView->RetrieveResources();
+ mView->RetrieveResources();
}
Modified: trunk/themis/modules/http/httpv4.cpp
===================================================================
--- trunk/themis/modules/http/httpv4.cpp 2011-07-30 18:48:36 UTC (rev 663)
+++ trunk/themis/modules/http/httpv4.cpp 2011-08-15 23:48:04 UTC (rev 664)
@@ -35,6 +35,7 @@
#include <ctype.h>
#include <Autolock.h>
#include <String.h>
+#include <string.h>
#define PlugIDdef 'http'
#define PlugNamedef "Network (http)"
@@ -322,7 +323,7 @@
if (build_request_thid!=0)
wait_for_thread(build_request_thid,&status);
build_request_thid=spawn_thread(BuildRequest_th,"http - build request", B_LOW_PRIORITY,bri);
-// printf("HTTPv4 (Heartbeat):\tbuild request thread id %ld\n",build_request_thid);
+ printf("HTTPv4 (Heartbeat):\tbuild request thread id %ld\n",build_request_thid);
resume_thread(build_request_thid);
wait_for_thread(build_request_thid,&status);
@@ -480,7 +481,8 @@
return STATUS_NOTIFICATION_FAILED;
if (connection->NotifiedConnect())
return STATUS_NOTIFICATION_SUCCESSFUL;
- request_lock.Lock();
+ BAutolock alock(&request_lock);
+// request_lock.Lock();
// printf("HTTPv4 Connection established! %p\n",connection);
http_request_info_st *current=http_request_list;
while(current!=NULL)
@@ -503,7 +505,7 @@
}
current=current->next;
}
- request_lock.Unlock();
+// request_lock.Unlock();
return STATUS_NOTIFICATION_SUCCESSFUL;
}
@@ -631,8 +633,14 @@
{
if (_terminate_)
return STATUS_NOTIFICATION_FAILED;
+ printf("\n\tHTTPv4::DataIsWaiting\n");
if (request_lock.LockWithTimeout(10000)==B_OK)
{
+ unsigned char *buffer=(unsigned char*)malloc(BUFFER_SIZE);
+ off_t bytes_received=0L,data_size=0L;
+ off_t buffer_size=BUFFER_SIZE;
+ memset(buffer,0,BUFFER_SIZE);//we do an initial wipe of memory just to start things off fresh
+ printf("\nrequest lock achieved\n");
if (connection->DataSize()>0)
{
http_request_info_st *current=http_request_list;
@@ -640,17 +648,44 @@
{
if (current->connection==connection)
{
-// printf("Data is waiting for %s (s: %ld u: %ld ; %Ld bytes)\n",current->url,current->site_id,current->url_id,current->connection->DataSize());
+ printf("Data is waiting for %s (s: %ld u: %ld ; %Ld bytes)\n",current->url,current->site_id,current->url_id,current->connection->DataSize());
if ((current->internal_status&STATUS_RESPONSE_RECEIVED_FROM_SERVER)==0)
current->internal_status|=STATUS_RESPONSE_RECEIVED_FROM_SERVER;
if ((current->internal_status&STATUS_RECEIVING_DATA)==0)
current->internal_status|=STATUS_RECEIVING_DATA;
+ int32 data_size = current->connection->DataSize();
+ if( data_size > 0)
+ {
+ if(data_size > buffer_size)
+ {
+ buffer = (unsigned char*) realloc(buffer,data_size);
+ memset(buffer,0,data_size);
+ buffer_size = data_size;
+ }
+ else
+ {
+ if((data_size < BUFFER_SIZE) && (buffer_size > BUFFER_SIZE))
+ {
+ buffer = (unsigned char*) realloc(buffer, BUFFER_SIZE);
+ memset(buffer,0,BUFFER_SIZE);
+ buffer_size = BUFFER_SIZE;
+ }
+ else
+ memset(buffer,0,buffer_size);
+ }
+ bytes_received = current->connection->Receive(buffer,buffer_size);
+ ProcessData(current,buffer,bytes_received);
+ current->internal_status ^= STATUS_RECEIVING_DATA;
+ }
break;
}
current=current->next;
}
}
+ memset(buffer,0,BUFFER_SIZE);
+ free(buffer);
request_lock.Unlock();
+ printf("\nrequest_lock released\n");
return STATUS_NOTIFICATION_SUCCESSFUL;
}
return STATUS_NOTIFICATION_FAILED;
@@ -805,15 +840,18 @@
bri->url=new char[strlen(url)+1];
memset((char*)bri->url,0,strlen(url)+1);
strcpy((char*)bri->url,url);
- if (build_request_thid==0)
+ build_request_thid = find_thread("http - build request");
+ printf("build_request_thid: %d\n",build_request_thid);
+ if (build_request_thid==B_NAME_NOT_FOUND && request_build_lock.IsLocked() == false )
{
build_request_thid=spawn_thread(BuildRequest_th,"http - build request", B_LOW_PRIORITY,bri);
-// printf("HTTPv4:\tbuild request thread id %ld\n",build_request_thid);
+ printf("HTTPv4:\tbuild request thread id %ld\n",build_request_thid);
resume_thread(build_request_thid);
wait_for_thread(build_request_thid,&status);
build_request_thid=0;
-// printf("HTTPv4 (RB): build request thread completed\n");
+ printf("HTTPv4 (RB): build request thread completed\n");
} else {
+
//add it to a queue, and check that periodically in the heartbeat to see if we have anything we need to process.
request_queue->AddItem(bri);
}
@@ -1011,10 +1049,10 @@
//bri = build request info
HTTPv4 *http=bri->http;
// status_t status=B_ERROR;
-// printf("HTTPv4:\tBuild request for url: %s\n",bri->url);
- http->request_lock.Lock();
+ printf("HTTPv4:\tBuild request for url: %s\n",bri->url);
+// http->request_lock.Lock();
http_request_info_st *current_item=NULL,*new_item=new http_request_info_st;
- http->request_lock.Unlock();
+// http->request_lock.Unlock();
new_item->url=bri->url;
new_item->site_id=bri->site_id;
new_item->url_id=bri->url_id;
@@ -1511,6 +1549,7 @@
}//Request has been built but server connection hasn't been established begin
if ((current->internal_status&STATUS_CONNECTED_TO_SERVER)!=0)
{//we are connected to the server, so process here begin
+ /*TEST Ray 8/15/2011
if ((current->internal_status&STATUS_RECEIVING_DATA)!=0)
{//we have received data that needs to be processed begin
//we don't have to make sure the memory is clear here
@@ -1548,11 +1587,11 @@
current->internal_status^=STATUS_RECEIVING_DATA;
/*
special case; we want to receive data as quickly as possible.
- */
+ * /
previous=current;
current=current->next;
http->request_lock.Unlock();
- snooze(10000);
+ //snooze(10000);
continue;
} else
{
@@ -1566,6 +1605,7 @@
// printf("DataSize() returned size %Ld\n",data_size);
}
+
}
}//we have received data that needs to be processed end
else
@@ -1573,6 +1613,7 @@
if ((current->internal_status&STATUS_PROCESSING_TIMED_OUT)!=0)
ProcessChunkedData(current);
}
+ TEST Ray 8/15/2011*/
}//we are connected to the server, so process here end
//process current http request end
current=current->next;
@@ -1671,7 +1712,9 @@
printf("HTTPv4: Unknown HTTP response code: %d - %s\n",request->http_status_code,request->http_status_message);
}
+ printf("\nDone processing headers; moving on to ProcessData2\n");
ProcessData2(request,(unsigned char*)(end_of_header+4),length-((end_of_header+4)-(char*)buffer));
+ printf("\nDone with ProcessData2 (post header)\n");
} else
{
request->internal_status|=STATUS_HEADERS_STARTED;//we have more headers to receive and process
@@ -1766,7 +1809,9 @@
// printf("header length: %ld\n" ,((end_of_header+4)-(char*)data)+orig_head_len);
// printf("length received: %ld\n",length);
// printf("difference: %ld\n",length-((end_of_header+4)-(char*)data)+orig_head_len);
+ printf("\nDone processing headers (2), moving on to ProcessData2\n");
ProcessData2(request,(unsigned char*)(end_of_header+4),length-((end_of_header+4)-(char*)data)+orig_head_len);
+ printf("\nDone with ProcessData2 (2)\n");
}
} else
@@ -1774,7 +1819,9 @@
//if headers have been completed, process data
if (((request->internal_status&STATUS_HEADERS_STARTED)!=0) && ((request->internal_status&STATUS_HEADERS_COMPLETED)!=0))
{
+ printf("\nAbout to ProcessData2\n");
ProcessData2(request,buffer,length);
+ printf("\nDone with ProcessData2\n");
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-07-30 18:48:42
|
Revision: 663
http://themis.svn.sourceforge.net/themis/?rev=663&view=rev
Author: mark_hellegers
Date: 2011-07-30 18:48:36 +0000 (Sat, 30 Jul 2011)
Log Message:
-----------
Added support for loading other resources. Currently disabled as it seems to cause trouble in the http protocol on my machine.
Remove comment from mView->RetrieveResources() in CSSRendererView.cpp to enable it.
Modified Paths:
--------------
trunk/themis/framework/win.cpp
trunk/themis/modules/CSSRenderer/CSSRenderer.cpp
trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
trunk/themis/modules/CSSRenderer/CSSRendererView.hpp
trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp
trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp
trunk/themis/modules/CSSRenderer/CSSView.cpp
trunk/themis/modules/CSSRenderer/CSSView.hpp
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/framework/win.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -350,44 +350,67 @@
// stop, if there is no url, or about:blank
if ((url.Length() == 0) || (strcmp(url.String(), kAboutBlankPage) == 0))
break;
+
+ int32 siteId = 0;
+ msg->FindInt32("site_id", &siteId);
+ int32 urlId = 0;
+ msg->FindInt32("url_id", &urlId);
- uint32 selection = tabview->Selection();
- /* Get an unique ID from the app for the site entry*/
- int32 siteId = ((App *)be_app)->GetNewID();
- SiteEntry * siteEntry = new SiteEntry(siteId, url.String());
- /* Get an unique ID from the app for the url entry */
- int32 urlId = ((App *)be_app)->GetNewID();
- UrlEntry * urlEntry = new UrlEntry(urlId, url.String());
- siteEntry->addEntry(urlEntry);
- ((App *)be_app)->GetSiteHandler()->AddEntry(siteEntry);
+ bool visible;
+ if (msg->HasBool("visible")) {
+ msg->FindBool("visible", &visible);
+ }
+ else {
+ visible = true;
+ }
- ThemisTab * tab = NULL;
- if (msg->HasInt32("tab_to_open_in")) {
- int32 index = msg->FindInt32("tab_to_open_in");
- tab = (ThemisTab *) tabview->TabAt(index);
+ uint32 selection = 0;
+ if (visible) {
+ selection = tabview->Selection();
+ /* Get an unique ID from the app for the site entry*/
+ siteId = ((App *)be_app)->GetNewID();
+ SiteEntry * siteEntry = new SiteEntry(siteId, url.String());
+ /* Get an unique ID from the app for the url entry */
+ urlId = ((App *)be_app)->GetNewID();
+ UrlEntry * urlEntry = new UrlEntry(urlId, url.String());
+ siteEntry->addEntry(urlEntry);
+ ((App *)be_app)->GetSiteHandler()->AddEntry(siteEntry);
+
+ ThemisTab * tab = NULL;
+ if (msg->HasInt32("tab_to_open_in")) {
+ int32 index = msg->FindInt32("tab_to_open_in");
+ tab = (ThemisTab *) tabview->TabAt(index);
+ }
+ else {
+ tab = (ThemisTab *) tabview->TabAt(selection);
+ }
+ tab->SetSiteID(siteId);
+ // add history entry for tab
+ if(msg->HasBool("no_history_add") == false)
+ tab->GetHistory()->AddEntry(url.String());
+ BRect rect = tabview->Bounds();
+ siteEntry->SetSize(rect.Width() - 2, rect.Height() - 2);
+
+ /* add url to global history
+ * ( You ask, why I am also adding the url on RELOAD, and not only on URL_OPEN?
+ * Simple. Imagine a browser being open for longer then GlobalHistoryDepthInDays.
+ * The url would be deleted after this period of days. If the user would then reload
+ * the page, it would not be saved in the history. If he closes the browser, his url
+ * would be lost. Ok, this is somewhat unlikely, but could happen. )
+ */
+ ((App *)be_app)->GetGlobalHistory()->AddEntry(url.String());
}
else {
- tab = (ThemisTab *) tabview->TabAt(selection);
+ urlId = ((App *)be_app)->GetNewID();
+ UrlEntry * urlEntry = new UrlEntry(urlId, url.String());
+ SiteEntry * siteEntry = ((App *)be_app)->GetSiteHandler()->GetEntry(siteId);
+ siteEntry->addEntry(urlEntry);
}
- tab->SetSiteID(siteId);
- // add history entry for tab
- if(msg->HasBool("no_history_add") == false)
- tab->GetHistory()->AddEntry(url.String());
- BRect rect = tabview->Bounds();
- siteEntry->SetSize(rect.Width() - 2, rect.Height() - 2);
- /* add url to global history
- * ( You ask, why I am also adding the url on RELOAD, and not only on URL_OPEN?
- * Simple. Imagine a browser being open for longer then GlobalHistoryDepthInDays.
- * The url would be deleted after this period of days. If the user would then reload
- * the page, it would not be saved in the history. If he closes the browser, his url
- * would be lost. Ok, this is somewhat unlikely, but could happen. )
- */
- ((App *)be_app)->GetGlobalHistory()->AddEntry(url.String());
-
// I don't want to destroy anything working right now. So let's just
// get something new in.
+ printf("Url to load: %s\n", url.String());
BMessage * load = new BMessage(SH_RETRIEVE_START);
load->AddInt32("command", COMMAND_RETRIEVE);
load->AddInt32("site_id", siteId);
@@ -404,11 +427,12 @@
* Otherwise we wouldn't see any URL in UrlView during load.
* Sad, but true.
*/
-
- if (msg->FindBool("hidden") == true)
- tabview->DrawTabs();
- else
- tabview->Select(selection);
+ if (visible) {
+ if (msg->FindBool("hidden") == true)
+ tabview->DrawTabs();
+ else
+ tabview->Select(selection);
+ }
break;
}
Modified: trunk/themis/modules/CSSRenderer/CSSRenderer.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRenderer.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSRenderer.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -189,19 +189,21 @@
int width = 0;
int height = 0;
site->GetSize(width, height);
+ int32 urlId = 0;
+ aMessage->FindInt32("url_id", &urlId);
CSSScrolledRendererView * view =
new CSSScrolledRendererView(document,
stylesheet,
width,
- height);
+ height,
+ siteId,
+ urlId);
/* Get an unique ID from the app for the DOM entry */
int32 viewId = ((App *)be_app)->GetNewID();
BaseEntry * entry = new BaseEntry(viewId);
entry->set("render_view", (void *) view);
((App *)be_app)->GetSiteHandler()->AddEntry(entry, siteId, domEntry->getId());
- int32 urlId = 0;
- aMessage->FindInt32("url_id", &urlId);
//Do the Broadcasting to give the view to the UI
BMessage *message = new BMessage(SH_RENDER_FINISHED);
message->AddInt32("command", COMMAND_INFO);
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -50,7 +50,9 @@
CSSRendererView :: CSSRendererView(BRect aFrame,
TDocumentPtr aDocument,
- CSSStyleSheetPtr aStyleSheet)
+ CSSStyleSheetPtr aStyleSheet,
+ int32 aSiteId,
+ int32 aUrlId)
: BView(aFrame,
"CSSRendererView",
B_FOLLOW_ALL_SIDES,
@@ -74,6 +76,8 @@
root,
mStyleSheets,
rect,
+ aSiteId,
+ aUrlId,
defaultColor);
printf("Doing layout\n");
mView->Layout(rect, BPoint(rect.left, rect.top));
@@ -125,6 +129,7 @@
}
Window()->SetTitle(title.c_str());
SetViewColor(B_TRANSPARENT_COLOR);
+// mView->RetrieveResources();
}
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.hpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.hpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -65,7 +65,9 @@
public:
CSSRendererView(BRect aFrame,
TDocumentPtr aDocument,
- CSSStyleSheetPtr aStyleSheet);
+ CSSStyleSheetPtr aStyleSheet,
+ int32 aSiteId,
+ int32 aUrlId);
~CSSRendererView();
virtual void MouseDown(BPoint aPoint);
virtual void Draw(BRect aRect);
Modified: trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -60,7 +60,9 @@
CSSScrolledRendererView :: CSSScrolledRendererView(TDocumentPtr aDocument,
CSSStyleSheetPtr aStyleSheet,
float aWidth,
- float aHeight)
+ float aHeight,
+ int32 aSiteId,
+ int32 aUrlId)
: BView(BRect(0, 0, aWidth, aHeight),
"CSSScrolledRendererView",
B_FOLLOW_ALL_SIDES,
@@ -73,7 +75,7 @@
BRect rect = Bounds();
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
rect.right -= B_V_SCROLL_BAR_WIDTH;
- mView = new CSSRendererView(rect, mDocument, mStyleSheet);
+ mView = new CSSRendererView(rect, mDocument, mStyleSheet, aSiteId, aUrlId);
mScrollView = new BScrollView("CSS Scroll view",
mView,
B_FOLLOW_ALL_SIDES,
Modified: trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -67,7 +67,9 @@
CSSScrolledRendererView(TDocumentPtr aDocument,
CSSStyleSheetPtr aStyleSheet,
float aWidth,
- float aHeight);
+ float aHeight,
+ int32 aSiteId,
+ int32 aUrlId);
~CSSScrolledRendererView();
void FrameResized(float aWidth, float aHeight);
void MessageReceived(BMessage * aMessage);
Modified: trunk/themis/modules/CSSRenderer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -70,6 +70,8 @@
TNodePtr aNode,
CSSStyleContainer * aStyleSheets,
BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
rgb_color aColor,
BFont * aFont)
: BHandler("CSSView") {
@@ -78,6 +80,8 @@
mNode = aNode;
mStyleSheets = aStyleSheets;
mRect = aRect;
+ mSiteId = aSiteId;
+ mUrlId = aUrlId;
mDisplay = true;
mBlock = true;
mTable = false;
@@ -117,7 +121,7 @@
}
else if (mNode->getNodeType() == ELEMENT_NODE) {
TElementPtr element = shared_static_cast<TElement>(mNode);
- if (mNode->getNodeName() == "A") {
+ if (mName == "A") {
// Only A can have a href for a hyperlink, so it is hardcoded here.
if (element->hasAttribute("HREF")) {
mHref = element->getAttribute("HREF");
@@ -133,6 +137,8 @@
child,
mStyleSheets,
mRect,
+ mSiteId,
+ mUrlId,
mColor,
mFont);
mChildren.push_back(childView);
@@ -152,6 +158,15 @@
SplitText();
}
+ else if (mNode->getNodeType() == ELEMENT_NODE) {
+ TElementPtr element = shared_static_cast<TElement>(mNode);
+ if (mName == "IMG") {
+ // Images have the image source in the src attribute.
+ if (element->hasAttribute("SRC")) {
+ mHref = element->getAttribute("SRC");
+ }
+ }
+ }
}
@@ -170,7 +185,7 @@
}
-void CSSView :: RetrieveLink() {
+void CSSView :: RetrieveLink(bool aVisible) {
if (mHref.size() > 0) {
// Send a message to the window.
@@ -201,7 +216,10 @@
}
urlString += mHref;
BMessage message(URL_OPEN);
+ message.AddInt32("site_id", mSiteId);
+ message.AddInt32("url_id", mUrlId);
message.AddString("url_to_open", urlString.c_str());
+ message.AddBool("visible", aVisible);
BMessenger messenger(NULL, mBaseView->Window());
messenger.SendMessage(&message);
}
@@ -733,3 +751,20 @@
}
}
+
+void CSSView :: RetrieveResources() {
+
+// printf("Retrieving resources in %s with href %s\n", mName.c_str(), mHref.c_str());
+ if (mHref != "" && !mClickable) {
+ // Some resource that must be loaded.
+ printf("Retrieving %s\n", mHref.c_str());
+ RetrieveLink(false);
+ }
+
+ unsigned int length = mChildren.size();
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ childView->RetrieveResources();
+ }
+
+}
Modified: trunk/themis/modules/CSSRenderer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -47,6 +47,7 @@
#include <Handler.h>
#include <Rect.h>
#include <Point.h>
+#include <be/interface/GraphicsDefs.h>
// DOM headers
#include "DOMSupport.h"
@@ -98,8 +99,10 @@
string mBorderStyle;
float mBorderWidth;
BRect mListStyleRect;
+ int32 mSiteId;
+ int32 mUrlId;
- void RetrieveLink();
+ void RetrieveLink(bool aVisible = true);
protected:
void ApplyStyle(const TElementPtr aElement);
@@ -109,6 +112,8 @@
TNodePtr aNode,
CSSStyleContainer * aStyleSheets,
BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
rgb_color aColor,
BFont * aFont = NULL);
~CSSView();
@@ -120,10 +125,10 @@
bool IsClickable();
BRect Bounds();
BPoint GetEndPoint();
- void Layout(BRect aRect,
- BPoint aStartingPoint);
+ virtual void Layout(BRect aRect,
+ BPoint aStartingPoint);
void SplitText();
- CSSStyleDeclarationPtr GetComputedStyle(const TElementPtr aElement);
+ void RetrieveResources();
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-07-16 23:25:33
|
Revision: 662
http://themis.svn.sourceforge.net/themis/?rev=662&view=rev
Author: mark_hellegers
Date: 2011-07-16 23:25:27 +0000 (Sat, 16 Jul 2011)
Log Message:
-----------
Reworked parts of the url popup window. It is now simpler and the parts of the code are refactored.
Modified Paths:
--------------
trunk/themis/framework/GlobalHistory.cpp
trunk/themis/framework/ThemisUrlPopUpView.cpp
trunk/themis/framework/ThemisUrlPopUpView.h
trunk/themis/framework/ThemisUrlPopUpWindow.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.h
trunk/themis/framework/UrlItem.cpp
trunk/themis/framework/UrlItem.hpp
trunk/themis/framework/app.cpp
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/GlobalHistory.cpp
===================================================================
--- trunk/themis/framework/GlobalHistory.cpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/GlobalHistory.cpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -334,7 +334,7 @@
int32 j = 0;
while (j < count2 && !found) {
- BStringItem * storedUrl = (BStringItem *)list->ItemAt(j);
+ UrlItem * storedUrl = (UrlItem *)list->ItemAt(j);
if (strcmp(cached_url.String(), storedUrl->Text()) == 0) {
found = true;
}
Modified: trunk/themis/framework/ThemisUrlPopUpView.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpView.cpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/ThemisUrlPopUpView.cpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -4,9 +4,13 @@
#include <iostream>
#include <string>
+// BeOS headers
+#include <interface/ScrollBar.h>
+
// Themis headers
#include "../common/commondefs.h"
#include "ThemisUrlPopUpView.h"
+#include "UrlItem.hpp"
ThemisUrlPopUpView :: ThemisUrlPopUpView(BRect frame)
: BView(frame,
@@ -17,7 +21,7 @@
BRect rect = Bounds();
ulv = new BListView(
- BRect(rect.left + 19,
+ BRect(rect.left + 1,
rect.top + 1,
rect.right - 1,
rect.bottom - 1),
@@ -28,6 +32,7 @@
ulv->SetFontSize(10.0);
AddChild(ulv);
ulv->AddFilter(new ThemisUrlPopUpViewMessageFilter(Window()));
+ mScrollBar = NULL;
}
void
@@ -51,6 +56,80 @@
SetHighColor( hi );
}
+const char * ThemisUrlPopUpView :: SetUrlSelection(int aOffset) {
+
+ if (aOffset != 0) {
+ ulv->Select(ulv->CurrentSelection() + aOffset);
+ ulv->ScrollToSelection();
+ }
+
+ UrlItem * item = (UrlItem *)ulv->ItemAt(ulv->CurrentSelection());
+
+ return item->Text();
+
+}
+
+int32 ThemisUrlPopUpView :: CurrentSelection() {
+
+ return ulv->CurrentSelection();
+
+}
+
+void ThemisUrlPopUpView :: MakeEmpty() {
+
+ ulv->MakeEmpty();
+
+}
+
+void ThemisUrlPopUpView :: AddList(BList * aList) {
+
+ ulv->AddList(aList);
+
+}
+
+UrlItem * ThemisUrlPopUpView :: FirstItem() {
+
+ return (UrlItem *) ulv->FirstItem();
+
+}
+
+int32 ThemisUrlPopUpView :: CountItems() {
+
+ return ulv->CountItems();
+
+}
+
+void ThemisUrlPopUpView :: SetScrollBarRange(float aMin, float aMax) {
+
+ if (!mScrollBar) {
+ BRect scrollRect = Bounds();
+ scrollRect.left = scrollRect.right - B_V_SCROLL_BAR_WIDTH;
+ mScrollBar = new BScrollBar(
+ scrollRect,
+ "UrlScrollBar",
+ ulv,
+ aMin,
+ aMax,
+ B_VERTICAL);
+ AddChild(mScrollBar);
+ ulv->ResizeBy(-B_V_SCROLL_BAR_WIDTH - 1, 0);
+ }
+ else {
+ mScrollBar->SetRange(aMin, aMax);
+ }
+
+}
+
+void ThemisUrlPopUpView :: RemoveScrollBar() {
+
+ if (mScrollBar) {
+ RemoveChild(mScrollBar);
+ mScrollBar = NULL;
+ ulv->ResizeBy(B_V_SCROLL_BAR_WIDTH + 1, 0);
+ }
+
+}
+
/////////////////////////////////////
// ThemisUrlPopUpViewMessageFilter
/////////////////////////////////////
Modified: trunk/themis/framework/ThemisUrlPopUpView.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpView.h 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/ThemisUrlPopUpView.h 2011-07-16 23:25:27 UTC (rev 662)
@@ -9,20 +9,28 @@
#include <MessageFilter.h>
#include <GraphicsDefs.h>
-// C/C++ headers
+// Declarations used
+class UrlItem;
+class BScrollBar;
-// myheaders
+class ThemisUrlPopUpView : public BView {
-class ThemisUrlListView;
+ private:
+ BListView * ulv;
+ BScrollBar * mScrollBar;
-class ThemisUrlPopUpView : public BView {
-
public:
ThemisUrlPopUpView(BRect frame);
virtual void Draw(BRect updaterect);
- BListView * ulv;
-
+ const char * SetUrlSelection(int aOffset);
+ int32 CurrentSelection();
+ void MakeEmpty();
+ void AddList(BList * aList);
+ UrlItem * FirstItem();
+ int32 CountItems();
+ void SetScrollBarRange(float aMin, float aMax);
+ void RemoveScrollBar();
};
#endif
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -1,19 +1,15 @@
/* ThemisUrlPopUpWindow.cpp */
-// BeOS headers
-
// Standard C headers
#include <stdio.h>
-// Standard C++ headers
-#include <iostream>
-
// Themis headers
#include "ThemisUrlView.h"
#include "ThemisNavView.h"
#include "win.h"
#include "../common/commondefs.h"
#include "ThemisUrlPopUpWindow.h"
+#include "ThemisUrlPopUpView.h"
#include "UrlItem.hpp"
ThemisUrlPopUpWindow :: ThemisUrlPopUpWindow(BWindow * aParent,
@@ -30,67 +26,66 @@
parentwindow = aParent;
lastitem = 0;
- vscroll = NULL;
- url_list = new BList;
+ mUrlList = new BList();
- urlpopupview = new ThemisUrlPopUpView(Bounds());
- AddChild(urlpopupview);
+ mMaxHeight = (int32) Bounds().bottom;
+ mItemHeight = 0;
+ mUrlListView = new ThemisUrlPopUpView(
+ Bounds());
+ mUrlListView->SetFontSize(10.0);
ListToDisplay(aList);
+
+ AddChild(mUrlListView);
}
-ThemisUrlPopUpWindow::~ThemisUrlPopUpWindow()
-{
- UrlItem * item = NULL;
+ThemisUrlPopUpWindow::~ThemisUrlPopUpWindow() {
- int32 length = url_list->CountItems();
- for( int32 i = 0; i < length; i++ )
- {
- item = (UrlItem *)url_list->RemoveItem((int32)0);
- delete item;
- }
-
- delete url_list;
+ EmptyUrlList();
+ delete mUrlList;
+
}
void ThemisUrlPopUpWindow :: SetUrlSelection(int aOffset) {
- if (aOffset != 0) {
- urlpopupview->ulv->Select(urlpopupview->ulv->CurrentSelection() + aOffset);
- urlpopupview->ulv->ScrollToSelection();
- }
- UrlItem * item = (UrlItem *)url_list->ItemAt(
- urlpopupview->ulv->CurrentSelection());
+ const char * urlText = mUrlListView->SetUrlSelection(aOffset);
- if (item) {
+ if (urlText) {
parentwindow->Lock();
- ((Win *)parentwindow)->GetNavView()->SetUrl(item->Text());
+ ((Win *)parentwindow)->GetNavView()->SetUrl(urlText);
parentwindow->Unlock();
}
}
+void ThemisUrlPopUpWindow :: EmptyUrlList() {
-void
-ThemisUrlPopUpWindow::MessageReceived( BMessage *msg )
-{
- switch( msg->what )
- {
- case URL_SELECT_MOUSE :
- {
+ UrlItem * item = NULL;
+
+ int32 length = mUrlList->CountItems();
+
+ for (int32 i = 0; i < length; i++) {
+ item = (UrlItem *)mUrlList->RemoveItem((int32)0);
+ delete item;
+ }
+
+}
+
+
+void ThemisUrlPopUpWindow :: MessageReceived(BMessage *msg) {
+
+ switch (msg->what) {
+ case URL_SELECT_MOUSE: {
// set the urlview-text
SetUrlSelection();
// doubleclick opens url
- uint32 clickitem = urlpopupview->ulv->CurrentSelection();
- if( msg->HasBool( "doubleclick" ) )
- {
- if( msg->FindBool( "doubleclick" ) == true )
- {
- if( clickitem == lastitem )
- {
- BMessenger msgr( NULL, parentwindow, NULL );
- msgr.SendMessage( new BMessage( URL_OPEN ) );
+ uint32 clickitem = mUrlListView->CurrentSelection();
+ if (msg->HasBool( "doubleclick" )) {
+ if (msg->FindBool("doubleclick") == true) {
+ if (clickitem == lastitem) {
+ BMessenger msgr(NULL, parentwindow, NULL);
+ msgr.SendMessage(new BMessage(URL_OPEN));
}
}
}
@@ -98,122 +93,74 @@
break;
}
- case URL_SELECT_NEXT :
- {
+ case URL_SELECT_NEXT: {
SetUrlSelection(1);
break;
}
- case URL_SELECT_PREV :
- {
+ case URL_SELECT_PREV: {
SetUrlSelection(-1);
break;
}
case B_MOUSE_WHEEL_CHANGED: {
float value = msg->FindFloat( "be:wheel_delta_y");
value *= 10;
- urlpopupview->ulv->ScrollBy(0, value);
+ mUrlListView->ScrollBy(0, value);
break;
}
- default :
- BWindow::MessageReceived( msg );
+ default:
+ BWindow::MessageReceived(msg);
}
}
void ThemisUrlPopUpWindow :: ListToDisplay(BList * list) {
if (list != NULL) {
- // First delete the contents of the old lists.
- int32 length = url_list->CountItems();
- for (int32 i = 0; i < length; i++) {
- delete url_list->RemoveItem((int32) 0);
- }
+ mUrlListView->MakeEmpty();
+ EmptyUrlList();
+ mUrlList->AddList(list);
+ mUrlListView->AddList(mUrlList);
- // we need to totally independant but similar BLists
- // ( copying with the copy-constructor won't do it )
- url_list->AddList(list);
-
- urlpopupview->ulv->MakeEmpty();
- urlpopupview->ulv->AddList(url_list);
-
- ResizeToPrefered();
+ ResizeToPrefered();
}
}
-void
-ThemisUrlPopUpWindow::ResizeToPrefered()
-{
- BPoint parent_bottom = parentwindow->Bounds().RightBottom();
- BPoint parent_bottom_cts = parentwindow->ConvertToScreen( parent_bottom );
-
- float itemheight = urlpopupview->ulv->ItemAt( 0 )->Height();
- int32 count = urlpopupview->ulv->CountItems();
-
- float newheight = ( itemheight * count ) + ( 1.9 * count ) + 1;
-
- BPoint new_popup_bottom;
- new_popup_bottom.y = newheight;
- BPoint new_popup_bottom_cts = ConvertToScreen( new_popup_bottom );
-
- float difference = parent_bottom_cts.y - new_popup_bottom_cts.y - 20;
-
+void ThemisUrlPopUpWindow :: ResizeToPrefered() {
+
+ parentwindow->Lock();
float urlview_width = ((Win*)parentwindow)->GetNavView()->GetBoundsOfUrlView().right;
+ parentwindow->Unlock();
- if( difference < 0 )
- {
- // the urlpopup would reach over the parentwindows bottom
-
- new_popup_bottom.y -= -difference;
- ResizeTo( urlview_width, new_popup_bottom.y );
-
- if( vscroll == NULL )
- {
- urlpopupview->ResizeTo(
- urlpopupview->Bounds().right - B_V_SCROLL_BAR_WIDTH,
- urlpopupview->Bounds().bottom );
-
- BRect bounds = Bounds();
-
- vscroll = new BScrollBar(
- BRect(
- bounds.right - B_V_SCROLL_BAR_WIDTH,
- bounds.top,
- bounds.right,
- bounds.bottom ),
- "URLPOPUPVSCROLLBAR",
- urlpopupview->ulv,
- 0,
- newheight - urlpopupview->ulv->Bounds().bottom,
- B_VERTICAL );
- AddChild( vscroll );
- }
- else
- {
- vscroll->SetRange(
- 0,
- newheight - urlpopupview->ulv->Bounds().bottom );
- }
- }
- else
- {
- // the urlpopup fits into the parentwindow
-
- ResizeTo( urlview_width, new_popup_bottom.y );
-
- if( vscroll != NULL )
- {
- RemoveChild( vscroll );
- vscroll = NULL;
+ // Calculate the total height of the items to see if we should shrink the list view.
+ if (mItemHeight == 0) {
+ // Only calculate the height once. It won't change.
+ mItemHeight = mUrlListView->FirstItem()->Height();
+ if (mItemHeight == 0) {
+ // Happens sometimes and I don't know why. Get the lineheight as an approximation.
+ font_height height;
+ mUrlListView->GetFontHeight(&height);
+ mItemHeight = height.ascent + height.descent + height.leading;
- urlpopupview->ResizeTo(
- urlpopupview->Bounds().right + B_V_SCROLL_BAR_WIDTH,
- urlpopupview->Bounds().bottom );
}
}
+
+ int32 count = mUrlListView->CountItems();
+
+ int32 listHeight = (int32) ((mItemHeight * count) + (1.9 * count) + 1);
+ if (listHeight > mMaxHeight) {
+ mUrlListView->SetScrollBarRange(0, listHeight - mUrlListView->Bounds().bottom);
+ listHeight = mMaxHeight;
+ }
+ else {
+ mUrlListView->RemoveScrollBar();
+ }
+
+ // Only resize if needed
+ BRect rect = Bounds();
+ int32 width = (int32) rect.Width();
+ int32 height = (int32) rect.Height();
+ if ((width != urlview_width) || (height != listHeight)) {
+ ResizeTo(urlview_width, listHeight);
+ }
+
}
-
-bool ThemisUrlPopUpWindow :: HasScrollBar() const {
-
- return (vscroll != NULL);
-
-}
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-07-16 23:25:27 UTC (rev 662)
@@ -4,25 +4,26 @@
#define _THEMISURLPOPUPWINDOW_H_
// BeOS headers
-#include "Window.h"
-#include <ScrollBar.h>
+#include <Window.h>
-// C/C++ headers
+// Declarations used
+class BScrollBar;
+class BList;
+class ThemisUrlPopUpView;
-// myheaders
-#include "ThemisUrlPopUpView.h"
-#include "Window.h"
-
class ThemisUrlPopUpWindow : public BWindow {
private:
BWindow * parentwindow;
+ ThemisUrlPopUpView * mUrlListView;
+ BList * mUrlList;
+ int32 mMaxHeight;
+ float mItemHeight;
+
uint32 lastitem;
- BList * url_list;
- BScrollBar * vscroll;
- ThemisUrlPopUpView * urlpopupview;
void SetUrlSelection(int aOffset = 0);
+ void EmptyUrlList();
public:
ThemisUrlPopUpWindow(BWindow* aParent, BRect aFrame, BList * aList);
@@ -31,8 +32,6 @@
virtual void MessageReceived(BMessage *msg);
void ListToDisplay(BList* list);
void ResizeToPrefered();
- bool HasScrollBar() const;
-
};
Modified: trunk/themis/framework/UrlItem.cpp
===================================================================
--- trunk/themis/framework/UrlItem.cpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/UrlItem.cpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -33,18 +33,21 @@
*/
+#include <stdio.h>
+
// BeOS headers
-#include "be/interface/GraphicsDefs.h"
-#include "be/interface/InterfaceDefs.h"
-#include "be/interface/View.h"
-#include "be/support/String.h"
+#include <be/interface/GraphicsDefs.h>
+#include <be/interface/InterfaceDefs.h>
+#include <be/interface/View.h>
// Themis headers
#include "UrlItem.hpp"
UrlItem :: UrlItem(const char * aUrl)
- : BStringItem(aUrl) {
+ : BListItem() {
+ mUrl = BString(aUrl);
+
}
void UrlItem :: DrawItem(BView * aOwner,
@@ -65,13 +68,26 @@
color = ui_color(B_MENU_ITEM_TEXT_COLOR);
aOwner->SetHighColor(color);
- BString url(Text());
+ BString url = mUrl;
+/*
aOwner->TruncateString(
&url,
B_TRUNCATE_END,
- aFrame.right - 10);
-
- aOwner->MovePenTo(aFrame.left + 4, aFrame.bottom - 2);
+ aFrame.right - 29);
+*/
+ aOwner->MovePenTo(aFrame.left + 4 + 19, aFrame.bottom - 2);
aOwner->DrawString(url.String());
}
+
+void UrlItem :: SetText(const char * aText) {
+
+ mUrl.SetTo(aText);
+
+}
+
+const char * UrlItem :: Text() {
+
+ return mUrl.String();
+
+}
Modified: trunk/themis/framework/UrlItem.hpp
===================================================================
--- trunk/themis/framework/UrlItem.hpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/UrlItem.hpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -32,16 +32,22 @@
#define URLITEM_HPP
// BeOS headers
-#include <ListItem.h>
+#include <be/interface/ListItem.h>
+#include <be/support/String.h>
-class UrlItem : public BStringItem {
+class UrlItem : public BListItem {
+ private:
+ BString mUrl;
+
public:
UrlItem(const char * aUrl);
virtual void DrawItem(BView * aOwner,
BRect aFrame,
bool aComplete = false);
+ void SetText(const char * aText);
+ const char * Text();
};
Modified: trunk/themis/framework/app.cpp
===================================================================
--- trunk/themis/framework/app.cpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/app.cpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -47,7 +47,6 @@
#include "PrefsWin.h"
#include "ThemisTab.h"
#include "SiteHandler.h"
-#include "ThemisUrlView.h"
#include "ThemisNavView.h"
#include "app.h"
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-05 14:23:23 UTC (rev 661)
+++ trunk/themis/framework/win.cpp 2011-07-16 23:25:27 UTC (rev 662)
@@ -48,7 +48,6 @@
#include "SiteHandler.h"
#include "SiteEntry.h"
#include "UrlEntry.h"
-#include "ThemisUrlView.h"
#include "ThemisNavView.h"
#include "ThemisStatusView.h"
#include "ThemisTabView.h"
@@ -217,10 +216,8 @@
// as the urlpopupwindow never gets focus and thus
// never get the mouse wheel messages
if (urlpopupwindow != NULL) {
- if (urlpopupwindow->HasScrollBar()) {
- BMessenger* msgr = new BMessenger(NULL, urlpopupwindow, NULL);
- msgr->SendMessage(msg);
- }
+ BMessenger* msgr = new BMessenger(NULL, urlpopupwindow, NULL);
+ msgr->SendMessage(msg);
}
break;
}
@@ -665,7 +662,7 @@
BRect wframe(frame);
wframe.top = frame.bottom;
- wframe.bottom = wframe.top + 30;
+ wframe.bottom = wframe.top + 130;
urlpopupwindow = new ThemisUrlPopUpWindow(this, wframe, aList);
urlpopupwindow->Run();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-05 14:23:29
|
Revision: 661
http://themis.svn.sourceforge.net/themis/?rev=661&view=rev
Author: mark_hellegers
Date: 2011-06-05 14:23:23 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Made window variable of ContainerViewMessageFilter private.
Modified Paths:
--------------
trunk/themis/framework/ThemisTabView.cpp
trunk/themis/framework/ThemisTabView.h
Modified: trunk/themis/framework/ThemisTabView.cpp
===================================================================
--- trunk/themis/framework/ThemisTabView.cpp 2011-06-05 14:16:12 UTC (rev 660)
+++ trunk/themis/framework/ThemisTabView.cpp 2011-06-05 14:23:23 UTC (rev 661)
@@ -871,26 +871,24 @@
// ContainerViewMessageFilter
/////////////////////////////////////
-ContainerViewMessageFilter::ContainerViewMessageFilter( Win* win )
- : BMessageFilter( B_ANY_DELIVERY, B_ANY_SOURCE )
-{
+ContainerViewMessageFilter :: ContainerViewMessageFilter(Win * win)
+ : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE) {
+
window = win;
+
}
-filter_result
-ContainerViewMessageFilter::Filter( BMessage *msg, BHandler **target )
-{
- filter_result result( B_DISPATCH_MESSAGE );
+filter_result ContainerViewMessageFilter :: Filter(BMessage * msg, BHandler **target) {
+
+ filter_result result(B_DISPATCH_MESSAGE);
- switch( msg->what )
- {
- case B_MOUSE_DOWN :
- {
+ switch (msg->what) {
+ case B_MOUSE_DOWN: {
if (window->CloseUrlPopUpWindow())
result = B_SKIP_MESSAGE;
break;
}
- default :
+ default:
break;
}
return result;
Modified: trunk/themis/framework/ThemisTabView.h
===================================================================
--- trunk/themis/framework/ThemisTabView.h 2011-06-05 14:16:12 UTC (rev 660)
+++ trunk/themis/framework/ThemisTabView.h 2011-06-05 14:23:23 UTC (rev 661)
@@ -61,14 +61,15 @@
// Declarations used
class Win;
-class ContainerViewMessageFilter : public BMessageFilter
-{
+class ContainerViewMessageFilter : public BMessageFilter {
+
+ private:
+ Win * window;
+
public:
- ContainerViewMessageFilter( Win* win );
- virtual filter_result Filter( BMessage *msg, BHandler **target );
+ ContainerViewMessageFilter(Win * win);
+ virtual filter_result Filter(BMessage * msg, BHandler **target);
- Win* window;
-
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-05 14:16:19
|
Revision: 660
http://themis.svn.sourceforge.net/themis/?rev=660&view=rev
Author: mark_hellegers
Date: 2011-06-05 14:16:12 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Moved ThemisTabView variables to private and fixed code that broke as a result.
Modified Paths:
--------------
trunk/themis/framework/ThemisTab.cpp
trunk/themis/framework/ThemisTabView.cpp
trunk/themis/framework/ThemisTabView.h
trunk/themis/framework/app.cpp
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/ThemisTab.cpp
===================================================================
--- trunk/themis/framework/ThemisTab.cpp 2011-06-05 13:58:03 UTC (rev 659)
+++ trunk/themis/framework/ThemisTab.cpp 2011-06-05 14:16:12 UTC (rev 660)
@@ -171,7 +171,7 @@
//cout << "ThemisTab::DrawLabel()" << endl;
/* calculate truncate_length */
- float truncate_length = (( ThemisTabView* )owner)->tab_width - 25 - 5;
+ float truncate_length = (( ThemisTabView* )owner)->GetTabWidth() - 25 - 5;
/* the frame for the FavIcon */
BRect iconframe = frame;
Modified: trunk/themis/framework/ThemisTabView.cpp
===================================================================
--- trunk/themis/framework/ThemisTabView.cpp 2011-06-05 13:58:03 UTC (rev 659)
+++ trunk/themis/framework/ThemisTabView.cpp 2011-06-05 14:16:12 UTC (rev 660)
@@ -813,6 +813,18 @@
fake_single_view = false;
}
+float ThemisTabView :: GetTabWidth() const {
+
+ return tab_width;
+
+}
+
+void ThemisTabView :: DisableFakeSingleView() {
+
+ fake_single_view = false;
+
+}
+
void ThemisTabView :: MessageReceived(BMessage * aMessage) {
switch (aMessage->what) {
Modified: trunk/themis/framework/ThemisTabView.h
===================================================================
--- trunk/themis/framework/ThemisTabView.h 2011-06-05 13:58:03 UTC (rev 659)
+++ trunk/themis/framework/ThemisTabView.h 2011-06-05 14:16:12 UTC (rev 660)
@@ -12,42 +12,41 @@
// Declarations used
class TPictureButton;
-class ThemisTabView : public BTabView
-{
- public:
- ThemisTabView(
- BRect frame,
- const char* name,
- button_width width,
- uint32 resizingmode,
- uint32 flags );
+class ThemisTabView : public BTabView {
- virtual void AttachedToWindow();
- virtual void Draw( BRect updaterect );
- virtual void DrawBox( BRect selTabRect );
- virtual BRect DrawTabs( void );
- virtual void MakeFocus( bool focus );
- virtual void MouseDown( BPoint point );
- virtual void Select( int32 tabindex );
- virtual void SetFocusTab( int32 tab, bool focused );
-
- void CreateCloseTabViewButton();
- void DynamicTabs( bool newtab );
- void SetFakeSingleView();
- void SetNavButtonsByTabHistory();
- void SetNormalTabView();
-
- float tab_width;
- bool fake_single_view;
-
- TPictureButton* close_tabview_button;
- void MessageReceived(BMessage * aMessage);
-
private:
// for doubleclick detection on empty tabview-space
// ( doubleclick opens new tab )
- uint32 lastbutton;
+ uint32 lastbutton;
+ float tab_width;
+ bool fake_single_view;
+ TPictureButton * close_tabview_button;
+ public:
+ ThemisTabView(
+ BRect frame,
+ const char* name,
+ button_width width,
+ uint32 resizingmode,
+ uint32 flags);
+
+ virtual void AttachedToWindow();
+ virtual void Draw(BRect updaterect);
+ virtual void DrawBox(BRect selTabRect);
+ virtual BRect DrawTabs(void);
+ virtual void MakeFocus(bool focus);
+ virtual void MouseDown(BPoint point);
+ virtual void Select(int32 tabindex);
+ virtual void SetFocusTab(int32 tab, bool focused);
+ void CreateCloseTabViewButton();
+ void DynamicTabs(bool newtab);
+ void SetFakeSingleView();
+ void SetNavButtonsByTabHistory();
+ void SetNormalTabView();
+ float GetTabWidth() const;
+ void DisableFakeSingleView();
+ void MessageReceived(BMessage * aMessage);
+
};
#endif
Modified: trunk/themis/framework/app.cpp
===================================================================
--- trunk/themis/framework/app.cpp 2011-06-05 13:58:03 UTC (rev 659)
+++ trunk/themis/framework/app.cpp 2011-06-05 14:16:12 UTC (rev 660)
@@ -469,7 +469,7 @@
if( WindowAt( i )->IsActive() == true )
{
Win* win = ( Win* )WindowAt( i );
- currenturl.SetTo( win->GetNavView()->urlview->Text() );
+ currenturl.SetTo( win->GetNavView()->GetUrl() );
break;
}
}
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-05 13:58:03 UTC (rev 659)
+++ trunk/themis/framework/win.cpp 2011-06-05 14:16:12 UTC (rev 660)
@@ -300,7 +300,7 @@
case TAB_ADD: {
// dissallow adding of new tabs, if they wouldnt fit in the
// window anymore, and disable newtab button
- if (tabview->tab_width <= 30) {
+ if (tabview->GetTabWidth() <= 30) {
// calculate if still one tab would fit and not cover
// the closetabview button partially
float width = (tabview->CountTabs() + 1) * 25;
@@ -489,7 +489,7 @@
tabview->DynamicTabs(false);
// enable or disable the newtab button
- if ((tabview->CountTabs() * tabview->tab_width) <= (Bounds().right - 22))
+ if ((tabview->CountTabs() * tabview->GetTabWidth()) <= (Bounds().right - 22))
navview->SetButtonMode(4, 0);
else
navview->SetButtonMode(4, 3);
@@ -567,7 +567,7 @@
// needed already here as DynamicTabs would stop if true
// but we cannot call SetNormalTabView() here
- tabview->fake_single_view = false;
+ tabview->DisableFakeSingleView();
tabview->DynamicTabs(true);
ThemisTab * newtab = new ThemisTab(NULL);
tabview->AddTab(NULL, newtab);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-05 13:58:09
|
Revision: 659
http://themis.svn.sourceforge.net/themis/?rev=659&view=rev
Author: mark_hellegers
Date: 2011-06-05 13:58:03 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Moved Strings include header to cpp file.
Modified Paths:
--------------
trunk/themis/framework/PrefsViews.cpp
trunk/themis/framework/PrefsViews.h
Modified: trunk/themis/framework/PrefsViews.cpp
===================================================================
--- trunk/themis/framework/PrefsViews.cpp 2011-06-05 13:52:42 UTC (rev 658)
+++ trunk/themis/framework/PrefsViews.cpp 2011-06-05 13:58:03 UTC (rev 659)
@@ -17,6 +17,7 @@
#include <storage/Directory.h>
#include <storage/Entry.h>
#include <storage/Path.h>
+#include <support/String.h>
#include <stdio.h>
Modified: trunk/themis/framework/PrefsViews.h
===================================================================
--- trunk/themis/framework/PrefsViews.h 2011-06-05 13:52:42 UTC (rev 658)
+++ trunk/themis/framework/PrefsViews.h 2011-06-05 13:58:03 UTC (rev 659)
@@ -9,7 +9,6 @@
// BeOS headers
#include <View.h>
-#include <String.h>
// Themis headers
#include "BasePrefsView.hpp"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-05 13:52:48
|
Revision: 658
http://themis.svn.sourceforge.net/themis/?rev=658&view=rev
Author: mark_hellegers
Date: 2011-06-05 13:52:42 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Made textview private. Didn't break anything this time. :)
Modified Paths:
--------------
trunk/themis/framework/ThemisUrlView.h
Modified: trunk/themis/framework/ThemisUrlView.h
===================================================================
--- trunk/themis/framework/ThemisUrlView.h 2011-06-05 13:37:21 UTC (rev 657)
+++ trunk/themis/framework/ThemisUrlView.h 2011-06-05 13:52:42 UTC (rev 658)
@@ -37,10 +37,10 @@
void SetFavIcon( BBitmap* fav );
virtual void SetText( const char* newtext );
- ThemisUrlTextView* textview;
private:
BBitmap* fav_icon;
+ ThemisUrlTextView* textview;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-05 13:37:28
|
Revision: 657
http://themis.svn.sourceforge.net/themis/?rev=657&view=rev
Author: mark_hellegers
Date: 2011-06-05 13:37:21 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Moved urlview of ThemisNavView to private and fixed code that depended on it being public.
Modified Paths:
--------------
trunk/themis/framework/ThemisNavView.cpp
trunk/themis/framework/ThemisNavView.h
trunk/themis/framework/ThemisTabView.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.cpp
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/ThemisNavView.cpp
===================================================================
--- trunk/themis/framework/ThemisNavView.cpp 2011-06-05 13:05:17 UTC (rev 656)
+++ trunk/themis/framework/ThemisNavView.cpp 2011-06-05 13:37:21 UTC (rev 657)
@@ -243,3 +243,34 @@
buttons[aButton]->SetMode(aMode, aForceMode);
}
+
+const char * ThemisNavView :: GetUrl() const {
+
+ return urlview->Text();
+
+}
+
+void ThemisNavView :: SetFocusOnUrlView() {
+
+ urlview->TextView()->MakeFocus(true);
+
+}
+
+BRect ThemisNavView :: GetFrameOfUrlView() const {
+
+ return urlview->Frame();
+
+}
+
+BRect ThemisNavView :: GetBoundsOfUrlView() const {
+
+ return urlview->Bounds();
+
+}
+
+void ThemisNavView :: SetUrl(const char * aUrl, BBitmap * aFavIcon) {
+
+ urlview->SetText(aUrl);
+ urlview->SetFavIcon(aFavIcon);
+
+}
Modified: trunk/themis/framework/ThemisNavView.h
===================================================================
--- trunk/themis/framework/ThemisNavView.h 2011-06-05 13:05:17 UTC (rev 656)
+++ trunk/themis/framework/ThemisNavView.h 2011-06-05 13:37:21 UTC (rev 657)
@@ -14,6 +14,7 @@
private:
TPictureButton * buttons[7];
+ ThemisUrlView * urlview;
public:
ThemisNavView(BRect rect);
@@ -23,8 +24,12 @@
void MouseDown(BPoint point);
void CreateInterfaceButtons();
void SetButtonMode(int aButton, int8 aMode, bool aForceMode = false);
+ const char * GetUrl() const;
+ void SetFocusOnUrlView();
+ BRect GetFrameOfUrlView() const;
+ BRect GetBoundsOfUrlView() const;
+ void SetUrl(const char * aUrl, BBitmap * aFavIcon = NULL);
- ThemisUrlView * urlview;
};
#endif
Modified: trunk/themis/framework/ThemisTabView.cpp
===================================================================
--- trunk/themis/framework/ThemisTabView.cpp 2011-06-05 13:05:17 UTC (rev 656)
+++ trunk/themis/framework/ThemisTabView.cpp 2011-06-05 13:37:21 UTC (rev 657)
@@ -291,7 +291,7 @@
{
if( Window()->CurrentFocus() != NULL )
Window()->CurrentFocus()->MakeFocus( false );
- ( ( Win* )Window() )->GetNavView()->urlview->TextView()->MakeFocus( true );
+ ( ( Win* )Window() )->GetNavView()->SetFocusOnUrlView();
}
break;
}
@@ -450,8 +450,7 @@
win->SetTitle( wtitle.String() );
tab->SetLabel( ttitle.String() );
- win->GetNavView()->urlview->SetText( url.String() );
- win->GetNavView()->urlview->SetFavIcon( tab->GetFavIcon() );
+ win->GetNavView()->SetUrl(url.String(), tab->GetFavIcon());
win->SetLoadingInfo(lprog, stext.String());
}
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-05 13:05:17 UTC (rev 656)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-05 13:37:21 UTC (rev 657)
@@ -64,7 +64,7 @@
if (item) {
parentwindow->Lock();
- ((Win *)parentwindow)->GetNavView()->urlview->SetText(item->Text());
+ ((Win *)parentwindow)->GetNavView()->SetUrl(item->Text());
parentwindow->Unlock();
}
@@ -157,7 +157,7 @@
float difference = parent_bottom_cts.y - new_popup_bottom_cts.y - 20;
- float urlview_width = ((Win*)parentwindow)->GetNavView()->urlview->Bounds().right;
+ float urlview_width = ((Win*)parentwindow)->GetNavView()->GetBoundsOfUrlView().right;
if( difference < 0 )
{
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-05 13:05:17 UTC (rev 656)
+++ trunk/themis/framework/win.cpp 2011-06-05 13:37:21 UTC (rev 657)
@@ -149,7 +149,7 @@
// make the urlview the focusview for fast pasting :D
if (CurrentFocus() != NULL)
CurrentFocus()->MakeFocus(false);
- navview->urlview->TextView()->MakeFocus(true);
+ navview->SetFocusOnUrlView();
}
@@ -348,7 +348,7 @@
if (msg->HasString("url_to_open"))
url = msg->FindString("url_to_open");
else
- url = navview->urlview->Text();
+ url = navview->GetUrl();
// stop, if there is no url, or about:blank
if ((url.Length() == 0) || (strcmp(url.String(), kAboutBlankPage) == 0))
@@ -477,7 +477,7 @@
BWindow::FrameMoved(origin);
if (urlpopupwindow != NULL) {
- BPoint point(navview->ConvertToScreen(navview->urlview->Frame().LeftBottom()));
+ BPoint point(navview->ConvertToScreen(navview->GetFrameOfUrlView().LeftBottom()));
urlpopupwindow->MoveTo(point);
}
@@ -660,7 +660,7 @@
void Win :: CreateUrlPopUpWindow(BList * aList) {
if (urlpopupwindow == NULL) {
- BRect frame(navview->urlview->Frame());
+ BRect frame(navview->GetFrameOfUrlView());
frame = navview->ConvertToScreen(frame);
BRect wframe(frame);
@@ -675,7 +675,7 @@
// the urlpopup wouldnt be navigable by keyb
if (CurrentFocus() != NULL)
CurrentFocus()->MakeFocus(false);
- navview->urlview->textview->MakeFocus(true);
+ navview->SetFocusOnUrlView();
}
else {
urlpopupwindow->Lock();
@@ -834,7 +834,7 @@
if (show_all == true)
typed_url.SetTo("");
else {
- typed_url.SetTo(navview->urlview->Text());
+ typed_url.SetTo(navview->GetUrl());
typed_url.ToLower();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-05 13:05:23
|
Revision: 656
http://themis.svn.sourceforge.net/themis/?rev=656&view=rev
Author: mark_hellegers
Date: 2011-06-05 13:05:17 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
- Cleaned up the styling.
- Moved the buttons variable of ThemisNavView to be private and fixed code that depended on it being public.
Modified Paths:
--------------
trunk/themis/framework/ThemisNavView.cpp
trunk/themis/framework/ThemisNavView.h
trunk/themis/framework/ThemisTabView.cpp
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/ThemisNavView.cpp
===================================================================
--- trunk/themis/framework/ThemisNavView.cpp 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/ThemisNavView.cpp 2011-06-05 13:05:17 UTC (rev 656)
@@ -15,21 +15,23 @@
#include "ThemisNavView.h"
#include "TPictureButton.h"
-ThemisNavView::ThemisNavView( BRect rect ) :
- BView( rect, "THEMISNAVVIEW", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE )
-{
+ThemisNavView :: ThemisNavView(BRect rect)
+ : BView(rect,
+ "THEMISNAVVIEW",
+ B_FOLLOW_LEFT_RIGHT,
+ B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) {
+
}
-ThemisNavView::~ThemisNavView( void )
-{
+ThemisNavView :: ~ThemisNavView() {
+
}
-void
-ThemisNavView::AttachedToWindow( void )
-{
+void ThemisNavView :: AttachedToWindow() {
+
BRect rect = Bounds();
- SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// create the urlview first( we need its frame for go button later )
urlview = new ThemisUrlView(
@@ -39,87 +41,80 @@
rect.right - 25,
rect.bottom - 5 ), // minimum height automatically set by BTextControl
"URLVIEW", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | //B_NAVIGABLE |
- B_FULL_UPDATE_ON_RESIZE );
+ B_FULL_UPDATE_ON_RESIZE);
urlview->TextView()->AddFilter(new ThemisUrlViewMessageFilter(Window()));
- AddChild( urlview );
+ AddChild(urlview);
// now create the buttons in my adventurous method :D
CreateInterfaceButtons();
}
-void
-ThemisNavView::Draw( BRect updaterect )
-{
+void ThemisNavView :: Draw(BRect updaterect) {
+
// compromise for now
// make the updaterect the Bounds rectangle
updaterect = Bounds();
rgb_color lo = LowColor();
- rgb_color panel_color = ui_color( B_PANEL_BACKGROUND_COLOR );
+ rgb_color panel_color = ui_color(B_PANEL_BACKGROUND_COLOR);
- SetLowColor( panel_color );
- FillRect( updaterect, B_SOLID_LOW );
+ SetLowColor(panel_color);
+ FillRect(updaterect, B_SOLID_LOW);
- SetLowColor( kColorDarkBorder );
+ SetLowColor(kColorDarkBorder);
StrokeLine(
- BPoint( updaterect.left, updaterect.bottom ),
- BPoint( updaterect.right, updaterect.bottom ),
- B_SOLID_LOW );
+ BPoint(updaterect.left, updaterect.bottom),
+ BPoint(updaterect.right, updaterect.bottom),
+ B_SOLID_LOW);
- SetLowColor( kColorLightBorder );
+ SetLowColor(kColorLightBorder);
StrokeLine(
- BPoint( updaterect.left, updaterect.bottom - 1 ),
- BPoint( updaterect.right, updaterect.bottom - 1 ),
- B_SOLID_LOW );
+ BPoint(updaterect.left, updaterect.bottom - 1),
+ BPoint(updaterect.right, updaterect.bottom - 1),
+ B_SOLID_LOW);
- if( CountChildren() > 0 )
- {
- BView* child = NULL;
- for( int32 i = 0; i < CountChildren(); i++ )
- {
- child = ChildAt( i );
- child->Draw( child->Bounds() );
+ if (CountChildren() > 0) {
+ BView * child = NULL;
+ for (int32 i = 0; i < CountChildren(); i++) {
+ child = ChildAt(i);
+ child->Draw(child->Bounds());
}
}
- SetLowColor( lo );
+ SetLowColor(lo);
}
-void
-ThemisNavView::MouseDown( BPoint point )
-{
+void ThemisNavView :: MouseDown(BPoint point) {
+
// check, if the urlpopupwindow is still open
// if yes, close it and return.
- Win* win = ( Win* )Window();
+ Win * win = (Win *)Window();
if (!win->CloseUrlPopUpWindow()) {
BView::MouseDown(point);
}
}
-void
-ThemisNavView::CreateInterfaceButtons()
-{
- //cout << "ThemisNavView::CreateInterfaceButton()" << endl;
+void ThemisNavView :: CreateInterfaceButtons() {
// the small 16x16 bitmap for on, over, active or off
- BBitmap* smallbmp = NULL;
+ BBitmap * smallbmp = NULL;
// the pictures
- BPicture* onpic = NULL;
- BPicture* overpic = NULL;
- BPicture* activepic = NULL;
- BPicture* offpic = NULL;
+ BPicture * onpic = NULL;
+ BPicture * overpic = NULL;
+ BPicture * activepic = NULL;
+ BPicture * offpic = NULL;
// the start rect
- BRect posrect( 10,7,25,22 );
+ BRect posrect(10, 7, 25, 22);
// the view in which we will draw the Pictures
- BView *tempview = new BView( BRect( 0,0,15,15 ), "TEMPVIEW", B_FOLLOW_NONE, B_WILL_DRAW );
- tempview->SetDrawingMode( B_OP_ALPHA );
- AddChild( tempview );
+ BView * tempview = new BView(BRect(0, 0, 15, 15), "TEMPVIEW", B_FOLLOW_NONE, B_WILL_DRAW);
+ tempview->SetDrawingMode(B_OP_ALPHA);
+ AddChild(tempview);
- Win* win = ( Win* )Window();
+ Win * win = (Win *)Window();
// the array with button-names
const char* names[7];
@@ -133,61 +128,71 @@
names[5] = "BUTTONRELOADPICBUTTON";
names[6] = "BUTTONGOPICBUTTON";
- for( int i = 0; i < 7; i++ )
- {
+ for (int i = 0; i < 7; i++) {
// either 64x16 or 48x16 behaviour
int limit = 0;
- if( i <= 4 )
+ if (i <= 4)
limit = 3;
else
limit = 2;
- for( int j = 0; j <= limit; j++ )
- {
+ for (int j = 0; j <= limit; j++) {
// extract partial bitmaps
-
- smallbmp = new BBitmap( BRect( 0,0,15,15 ), B_RGB32 );
+ smallbmp = new BBitmap(BRect(0, 0, 15, 15), B_RGB32);
- unsigned char* p1 = ( unsigned char* )win->GetBitmap(i)->Bits();
- unsigned char* p2 = ( unsigned char* )smallbmp->Bits();
+ unsigned char * p1 = (unsigned char *)win->GetBitmap(i)->Bits();
+ unsigned char * p2 = (unsigned char *)smallbmp->Bits();
- for( int k = 0; k < 16; k++ )
- {
+ for (int k = 0; k < 16; k++) {
memcpy(
- ( void* )( p2 + ( k * 64 ) ),
- ( const void* )( p1 + ( ( j + ( ( limit + 1 ) * k ) ) * 64 ) ),
- 64 );
+ (void *)(p2 + (k * 64)),
+ (const void *)(p1 + ((j + ((limit + 1) * k)) * 64)),
+ 64);
}
- tempview->BeginPicture( new BPicture );
- tempview->DrawBitmap( smallbmp );
- if( j == 0 ) onpic = tempview->EndPicture();
- if( j == 1 ) overpic = tempview->EndPicture();
- if( j == 2 ) activepic = tempview->EndPicture();
- if( j == 3 ) offpic = tempview->EndPicture();
+ tempview->BeginPicture(new BPicture);
+ tempview->DrawBitmap(smallbmp);
+ if (j == 0) onpic = tempview->EndPicture();
+ if (j == 1) overpic = tempview->EndPicture();
+ if (j == 2) activepic = tempview->EndPicture();
+ if (j == 3) offpic = tempview->EndPicture();
delete smallbmp;
}
- BMessage* msg = NULL;
- if( i == 0 ) msg = new BMessage( BUTTON_BACK );
- if( i == 1 ) msg = new BMessage( BUTTON_FORWARD );
- if( i == 2 ) msg = new BMessage( BUTTON_STOP );
- if( i == 3 ) msg = new BMessage( BUTTON_HOME );
- if( i == 4 ) msg = new BMessage( TAB_ADD );
- if( i == 5 ) msg = new BMessage( BUTTON_RELOAD ); // URL_OPEN ??
- if( i == 6 ) msg = new BMessage( URL_OPEN );
+ BMessage * msg = NULL;
+ if (i == 0) msg = new BMessage(BUTTON_BACK);
+ if (i == 1) msg = new BMessage(BUTTON_FORWARD);
+ if (i == 2) msg = new BMessage(BUTTON_STOP);
+ if (i == 3) msg = new BMessage(BUTTON_HOME);
+ if (i == 4) msg = new BMessage(TAB_ADD);
+ if (i == 5) msg = new BMessage(BUTTON_RELOAD); // URL_OPEN ??
+ if (i == 6) msg = new BMessage(URL_OPEN);
// calculate the position rect
- switch( i )
- {
- case 0 : // back
- case 1 : // fwd
- case 2 : { posrect.left = 5 + ( i * 25 ); break; } // stop
- case 3 : { posrect.left = 5 + ( 4 * 25 ); break; } // home
- case 4 : { posrect.left = 5 + ( 5 * 25 ); break; } // newtab
- case 5 : { posrect.left = 5 + ( 3 * 25 ); break; } // reload
- case 6 : { posrect.left = urlview->Frame().right + 5; break; } // go
+ switch (i) {
+ case 0: // back
+ case 1: // fwd
+ case 2: {
+ posrect.left = 5 + ( i * 25 );
+ break;
+ } // stop
+ case 3: {
+ posrect.left = 5 + ( 4 * 25 );
+ break;
+ } // home
+ case 4: {
+ posrect.left = 5 + ( 5 * 25 );
+ break;
+ } // newtab
+ case 5: {
+ posrect.left = 5 + ( 3 * 25 );
+ break;
+ } // reload
+ case 6: {
+ posrect.left = urlview->Frame().right + 5;
+ break;
+ } // go
}
posrect.right = posrect.left + 15;
@@ -201,20 +206,22 @@
offpic,
msg,
0,
- B_WILL_DRAW );
+ B_WILL_DRAW);
- if( i == 6 )
- buttons[i]->SetResizingMode( buttons[i]->ResizingMode() | B_FOLLOW_RIGHT );
+ if (i == 6)
+ buttons[i]->SetResizingMode(buttons[i]->ResizingMode() | B_FOLLOW_RIGHT);
// set initial behaviour for back, fwd and stop button ( disabled )
- switch( i )
- {
- case 0 :
- case 1 :
- case 2 : buttons[i]->SetMode( 3 ); break;
+ switch(i) {
+ case 0:
+ case 1:
+ case 2: {
+ buttons[i]->SetMode( 3 );
+ break;
+ }
}
- AddChild( buttons[i] );
+ AddChild(buttons[i]);
// reset the bitmaps and pics
smallbmp = NULL;
@@ -225,6 +232,14 @@
}
// remove the tempview
- RemoveChild( tempview );
+ RemoveChild(tempview);
delete tempview;
}
+
+void ThemisNavView :: SetButtonMode(int aButton,
+ int8 aMode,
+ bool aForceMode) {
+
+ buttons[aButton]->SetMode(aMode, aForceMode);
+
+}
Modified: trunk/themis/framework/ThemisNavView.h
===================================================================
--- trunk/themis/framework/ThemisNavView.h 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/ThemisNavView.h 2011-06-05 13:05:17 UTC (rev 656)
@@ -6,27 +6,25 @@
// BeOS headers
#include <View.h>
-// C/C++ headers
-
// Declarations used
class ThemisUrlView;
class TPictureButton;
-class ThemisNavView : public BView
-{
+class ThemisNavView : public BView {
+
+ private:
+ TPictureButton * buttons[7];
+
public:
- ThemisNavView(
- BRect rect );
- virtual ~ThemisNavView( void );
- void AttachedToWindow( void );
- void Draw( BRect updaterect );
- void MouseDown( BPoint point );
-
- void CreateInterfaceButtons();
-
- ThemisUrlView* urlview;
-
- TPictureButton* buttons[7];
+ ThemisNavView(BRect rect);
+ virtual ~ThemisNavView();
+ void AttachedToWindow();
+ void Draw(BRect updaterect);
+ void MouseDown(BPoint point);
+ void CreateInterfaceButtons();
+ void SetButtonMode(int aButton, int8 aMode, bool aForceMode = false);
+
+ ThemisUrlView * urlview;
};
#endif
Modified: trunk/themis/framework/ThemisTabView.cpp
===================================================================
--- trunk/themis/framework/ThemisTabView.cpp 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/ThemisTabView.cpp 2011-06-05 13:05:17 UTC (rev 656)
@@ -19,6 +19,7 @@
#include <String.h>
#include <Messenger.h>
#include <Window.h>
+#include <Picture.h>
// Themis headers
#include "win.h"
@@ -362,7 +363,7 @@
// if the newtab button is disabled, and no more tabs are
// out of range, enable the button
if( ( CountTabs() * tab_width ) <= ( Bounds().right - 22 ) )
- ( ( Win* )Window() )->GetNavView()->buttons[4]->SetMode( 0 );
+ ( ( Win* )Window() )->GetNavView()->SetButtonMode(4, 0);
// calculate new ( bigger ) size of tabs and draw again
DynamicTabs( false );
@@ -764,25 +765,25 @@
if (tab->GetHistory()->GetCurrentPosition() == 0) {
if (tab->GetHistory()->GetEntryCount() > 1) {
// printf("TABVIEW: enabling back, disabling fwd button if needed.\n");
- nv->buttons[0]->SetMode(0);
- nv->buttons[1]->SetMode(3);
+ nv->SetButtonMode(0, 0);
+ nv->SetButtonMode(1, 3);
}
else {
// printf( "TABVIEW: only one ( or no )history item. disabling back and fwd if needed.\n" );
- nv->buttons[0]->SetMode(3);
- nv->buttons[1]->SetMode(3);
+ nv->SetButtonMode(0, 3);
+ nv->SetButtonMode(1, 3);
}
}
else {
if (tab->GetHistory()->GetCurrentPosition() == (tab->GetHistory()->GetEntryCount() - 1)) {
// printf("TABVIEW: at history end. disable back, enable fwd if needed.\n");
- nv->buttons[0]->SetMode(3);
- nv->buttons[1]->SetMode(0);
+ nv->SetButtonMode(0, 3);
+ nv->SetButtonMode(1, 0);
}
else {
// printf("TABVIEW: in middle of history. enabling back and fwd if needed.\n");
- nv->buttons[0]->SetMode(0);
- nv->buttons[1]->SetMode(0);
+ nv->SetButtonMode(0, 0);
+ nv->SetButtonMode(1, 0);
}
}
}
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-04 23:34:50 UTC (rev 655)
+++ trunk/themis/framework/win.cpp 2011-06-05 13:05:17 UTC (rev 656)
@@ -56,7 +56,6 @@
#include "../common/commondefs.h"
#include "../common/PrefsDefs.h"
#include "GlobalHistory.h"
-#include "TPictureButton.h"
#include "win.h"
extern plugman *PluginManager;
@@ -260,7 +259,7 @@
Lock();
// if the newtab button is disabled, enable it again
- navview->buttons[4]->SetMode(0);
+ navview->SetButtonMode(4, 0);
uint32 current_tab = 0;
uint32 count = tabview->CountTabs();
@@ -308,7 +307,7 @@
if (Bounds().right - width <= 22) {
// disable the newtab button
- navview->buttons[4]->SetMode(3);
+ navview->SetButtonMode(4, 3);
break;
}
// if we won't cover the button, go on...
@@ -491,9 +490,9 @@
// enable or disable the newtab button
if ((tabview->CountTabs() * tabview->tab_width) <= (Bounds().right - 22))
- navview->buttons[4]->SetMode(0);
+ navview->SetButtonMode(4, 0);
else
- navview->buttons[4]->SetMode(3);
+ navview->SetButtonMode(4, 3);
// resize urlpopupwindow
if (urlpopupwindow != NULL) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-04 23:34:58
|
Revision: 655
http://themis.svn.sourceforge.net/themis/?rev=655&view=rev
Author: mark_hellegers
Date: 2011-06-04 23:34:50 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Fixed the includes, so the impact of a change in TPictureButton.h causes less recompiles.
Modified Paths:
--------------
trunk/themis/framework/ThemisNavView.cpp
trunk/themis/framework/ThemisNavView.h
trunk/themis/framework/ThemisTabView.cpp
trunk/themis/framework/ThemisTabView.h
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/ThemisNavView.cpp
===================================================================
--- trunk/themis/framework/ThemisNavView.cpp 2011-06-04 23:19:10 UTC (rev 654)
+++ trunk/themis/framework/ThemisNavView.cpp 2011-06-04 23:34:50 UTC (rev 655)
@@ -6,9 +6,6 @@
#include <Picture.h>
#include <String.h>
-// Standard C++ headers
-#include <iostream>
-
// Themis headers
#include "ThemisIcons.h"
#include "ThemisUrlView.h"
@@ -16,6 +13,7 @@
#include "win.h"
#include "../common/commondefs.h"
#include "ThemisNavView.h"
+#include "TPictureButton.h"
ThemisNavView::ThemisNavView( BRect rect ) :
BView( rect, "THEMISNAVVIEW", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE )
Modified: trunk/themis/framework/ThemisNavView.h
===================================================================
--- trunk/themis/framework/ThemisNavView.h 2011-06-04 23:19:10 UTC (rev 654)
+++ trunk/themis/framework/ThemisNavView.h 2011-06-04 23:34:50 UTC (rev 655)
@@ -8,11 +8,9 @@
// C/C++ headers
-// myheaders
-#include "TPictureButton.h"
-
// Declarations used
class ThemisUrlView;
+class TPictureButton;
class ThemisNavView : public BView
{
Modified: trunk/themis/framework/ThemisTabView.cpp
===================================================================
--- trunk/themis/framework/ThemisTabView.cpp 2011-06-04 23:19:10 UTC (rev 654)
+++ trunk/themis/framework/ThemisTabView.cpp 2011-06-04 23:34:50 UTC (rev 655)
@@ -33,6 +33,7 @@
#include "ThemisUrlPopUpWindow.h"
#include "../common/PrefsDefs.h"
#include "ThemisTabView.h"
+#include "TPictureButton.h"
ThemisTabView::ThemisTabView(
BRect frame,
Modified: trunk/themis/framework/ThemisTabView.h
===================================================================
--- trunk/themis/framework/ThemisTabView.h 2011-06-04 23:19:10 UTC (rev 654)
+++ trunk/themis/framework/ThemisTabView.h 2011-06-04 23:34:50 UTC (rev 655)
@@ -9,8 +9,8 @@
// C/C++ headers
-// myheaders
-#include "TPictureButton.h"
+// Declarations used
+class TPictureButton;
class ThemisTabView : public BTabView
{
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-04 23:19:10 UTC (rev 654)
+++ trunk/themis/framework/win.cpp 2011-06-04 23:34:50 UTC (rev 655)
@@ -56,6 +56,7 @@
#include "../common/commondefs.h"
#include "../common/PrefsDefs.h"
#include "GlobalHistory.h"
+#include "TPictureButton.h"
#include "win.h"
extern plugman *PluginManager;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-04 23:19:16
|
Revision: 654
http://themis.svn.sourceforge.net/themis/?rev=654&view=rev
Author: mark_hellegers
Date: 2011-06-04 23:19:10 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Stop the flickering on the "go" button.
Modified Paths:
--------------
trunk/themis/framework/TPictureButton.cpp
trunk/themis/framework/TPictureButton.h
Modified: trunk/themis/framework/TPictureButton.cpp
===================================================================
--- trunk/themis/framework/TPictureButton.cpp 2011-06-04 12:54:58 UTC (rev 653)
+++ trunk/themis/framework/TPictureButton.cpp 2011-06-04 23:19:10 UTC (rev 654)
@@ -197,3 +197,11 @@
Draw( Bounds() );
}
+
+void TPictureButton :: AttachedToWindow()
+{
+ BView::AttachedToWindow();
+
+ SetViewColor(B_TRANSPARENT_COLOR);
+
+}
Modified: trunk/themis/framework/TPictureButton.h
===================================================================
--- trunk/themis/framework/TPictureButton.h 2011-06-04 12:54:58 UTC (rev 653)
+++ trunk/themis/framework/TPictureButton.h 2011-06-04 23:19:10 UTC (rev 654)
@@ -62,6 +62,7 @@
void SetMode(
int8 mode,
bool forcemode = false );
+ virtual void AttachedToWindow();
private:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-04 12:55:04
|
Revision: 653
http://themis.svn.sourceforge.net/themis/?rev=653&view=rev
Author: mark_hellegers
Date: 2011-06-04 12:54:58 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Moved duplicate code to a separate function.
Modified Paths:
--------------
trunk/themis/framework/ThemisUrlPopUpWindow.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.h
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-04 10:10:26 UTC (rev 652)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-04 12:54:58 UTC (rev 653)
@@ -52,6 +52,25 @@
delete url_list;
}
+void ThemisUrlPopUpWindow :: SetUrlSelection(int aOffset) {
+
+ if (aOffset != 0) {
+ urlpopupview->ulv->Select(urlpopupview->ulv->CurrentSelection() + aOffset);
+ urlpopupview->ulv->ScrollToSelection();
+ }
+
+ UrlItem * item = (UrlItem *)url_list->ItemAt(
+ urlpopupview->ulv->CurrentSelection());
+
+ if (item) {
+ parentwindow->Lock();
+ ((Win *)parentwindow)->GetNavView()->urlview->SetText(item->Text());
+ parentwindow->Unlock();
+ }
+
+}
+
+
void
ThemisUrlPopUpWindow::MessageReceived( BMessage *msg )
{
@@ -60,15 +79,8 @@
case URL_SELECT_MOUSE :
{
// set the urlview-text
- //cout << "URL_SELECT_MOUSE" << endl;
+ SetUrlSelection();
- BStringItem* item = ( BStringItem* )url_list->ItemAt(
- urlpopupview->ulv->CurrentSelection() );
-
- parentwindow->Lock();
- ((Win*)parentwindow)->GetNavView()->urlview->SetText( item->Text() );
- parentwindow->Unlock();
-
// doubleclick opens url
uint32 clickitem = urlpopupview->ulv->CurrentSelection();
if( msg->HasBool( "doubleclick" ) )
@@ -88,44 +100,12 @@
}
case URL_SELECT_NEXT :
{
- //cout << "URL_SELECT_NEXT received" << endl;
- Lock();
- urlpopupview->ulv->Select(
- urlpopupview->ulv->CurrentSelection() + 1 );
- urlpopupview->ulv->ScrollToSelection();
-
- // set the urlview-text
- BStringItem* item = ( BStringItem* )url_list->ItemAt(
- urlpopupview->ulv->CurrentSelection() );
- if( !item )
- break;
-
- parentwindow->Lock();
- ((Win*)parentwindow)->GetNavView()->urlview->SetText( item->Text() );
- parentwindow->Unlock();
-
- Unlock();
+ SetUrlSelection(1);
break;
}
case URL_SELECT_PREV :
{
- //cout << "URL_SELECT_PREV received" << endl;
- Lock();
- urlpopupview->ulv->Select(
- urlpopupview->ulv->CurrentSelection() - 1 );
- urlpopupview->ulv->ScrollToSelection();
-
- // set the urlview-text
- BStringItem* item = ( BStringItem* )url_list->ItemAt(
- urlpopupview->ulv->CurrentSelection() );
- if( !item )
- break;
-
- parentwindow->Lock();
- ((Win*)parentwindow)->GetNavView()->urlview->SetText( item->Text() );
- parentwindow->Unlock();
-
- Unlock();
+ SetUrlSelection(-1);
break;
}
case B_MOUSE_WHEEL_CHANGED: {
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-04 10:10:26 UTC (rev 652)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-04 12:54:58 UTC (rev 653)
@@ -22,6 +22,7 @@
BList * url_list;
BScrollBar * vscroll;
ThemisUrlPopUpView * urlpopupview;
+ void SetUrlSelection(int aOffset = 0);
public:
ThemisUrlPopUpWindow(BWindow* aParent, BRect aFrame, BList * aList);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-02 22:31:08
|
Revision: 651
http://themis.svn.sourceforge.net/themis/?rev=651&view=rev
Author: mark_hellegers
Date: 2011-06-02 22:31:02 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
- Code cleanup
- Moved public variables to private and adapted code
Modified Paths:
--------------
trunk/themis/framework/ThemisUrlPopUpView.cpp
trunk/themis/framework/ThemisUrlPopUpView.h
trunk/themis/framework/ThemisUrlPopUpWindow.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.h
trunk/themis/framework/win.cpp
Modified: trunk/themis/framework/ThemisUrlPopUpView.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpView.cpp 2011-06-02 18:11:12 UTC (rev 650)
+++ trunk/themis/framework/ThemisUrlPopUpView.cpp 2011-06-02 22:31:02 UTC (rev 651)
@@ -8,24 +8,26 @@
#include "../common/commondefs.h"
#include "ThemisUrlPopUpView.h"
-ThemisUrlPopUpView::ThemisUrlPopUpView(
- BRect frame )
- : BView(
- frame,
- "THEMISURLPOPUPVIEW",
- B_FOLLOW_ALL,
- B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE )
-{
+ThemisUrlPopUpView :: ThemisUrlPopUpView(BRect frame)
+ : BView(frame,
+ "THEMISURLPOPUPVIEW",
+ B_FOLLOW_ALL,
+ B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) {
+
BRect rect = Bounds();
- ulv = new ThemisUrlListView(
- BRect(
- rect.left + 19,
- rect.top + 1,
- rect.right - 1,
- rect.bottom - 1 ) );
- AddChild( ulv );
- ulv->AddFilter( new ThemisUrlPopUpViewMessageFilter( Window() ) );
+ ulv = new BListView(
+ BRect(rect.left + 19,
+ rect.top + 1,
+ rect.right - 1,
+ rect.bottom - 1),
+ "THEMISURLLISTVIEW",
+ B_SINGLE_SELECTION_LIST,
+ B_FOLLOW_ALL,
+ B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
+ ulv->SetFontSize(10.0);
+ AddChild(ulv);
+ ulv->AddFilter(new ThemisUrlPopUpViewMessageFilter(Window()));
}
void
@@ -50,55 +52,34 @@
}
/////////////////////////////////////
-// ThemisUrlListView
-/////////////////////////////////////
-
-ThemisUrlListView::ThemisUrlListView(
- BRect frame )
- : BListView(
- frame,
- "THEMISURLLISTVIEW",
- B_SINGLE_SELECTION_LIST,
- B_FOLLOW_ALL,
- B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE )
-{
- SetFontSize( 10.0 );
-}
-
-/////////////////////////////////////
// ThemisUrlPopUpViewMessageFilter
/////////////////////////////////////
-ThemisUrlPopUpViewMessageFilter::ThemisUrlPopUpViewMessageFilter( BWindow* win )
- : BMessageFilter( B_ANY_DELIVERY, B_ANY_SOURCE )
-{
- window = win;
+ThemisUrlPopUpViewMessageFilter :: ThemisUrlPopUpViewMessageFilter(BWindow* win)
+ : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE) {
lastbutton = 0;
}
-filter_result
-ThemisUrlPopUpViewMessageFilter::Filter( BMessage *msg, BHandler **target )
-{
- filter_result result( B_DISPATCH_MESSAGE );
+filter_result ThemisUrlPopUpViewMessageFilter :: Filter(BMessage * msg,
+ BHandler ** target) {
+
+ filter_result result(B_DISPATCH_MESSAGE);
- switch( msg->what )
- {
- case B_MOUSE_DOWN :
- {
+ switch(msg->what) {
+ case B_MOUSE_DOWN: {
int32 buttons, clicks;
- buttons = msg->FindInt32( "buttons" );
- clicks = msg->FindInt32( "clicks" );
+ buttons = msg->FindInt32("buttons");
+ clicks = msg->FindInt32("clicks");
- BMessage* selectmsg = new BMessage( URL_SELECT_MOUSE );
+ BMessage* selectmsg = new BMessage(URL_SELECT_MOUSE);
- if( buttons == lastbutton && clicks > 1 )
- {
- selectmsg->AddBool( "doubleclick", true );
+ if (buttons == lastbutton && clicks > 1) {
+ selectmsg->AddBool("doubleclick", true);
}
lastbutton = buttons;
- BMessenger msgr( (*target) );
- msgr.SendMessage( selectmsg );
+ BMessenger msgr((*target));
+ msgr.SendMessage(selectmsg);
delete selectmsg;
@@ -109,5 +90,6 @@
default :
break;
}
+
return result;
}
Modified: trunk/themis/framework/ThemisUrlPopUpView.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpView.h 2011-06-02 18:11:12 UTC (rev 650)
+++ trunk/themis/framework/ThemisUrlPopUpView.h 2011-06-02 22:31:02 UTC (rev 651)
@@ -15,52 +15,35 @@
class ThemisUrlListView;
-class ThemisUrlPopUpView : public BView
-{
+class ThemisUrlPopUpView : public BView {
+
public:
- ThemisUrlPopUpView(
- BRect frame );
-
- virtual void Draw( BRect updaterect );
+ ThemisUrlPopUpView(BRect frame);
+
+ virtual void Draw(BRect updaterect);
+ BListView * ulv;
- ThemisUrlListView* ulv;
};
#endif
/////////////////////////////////////
-// ThemisUrlListView
-/////////////////////////////////////
-// its just in here for later customization
-// i did nothing special in here afair :))
-
-#ifndef THEMISURLLISTVIEW
-#define THEMISURLLISTVIEW
-
-class ThemisUrlListView : public BListView
-{
- public:
- ThemisUrlListView(
- BRect frame );
-};
-
-#endif
-
-/////////////////////////////////////
// ThemisUrlPopUpViewMessageFilter
/////////////////////////////////////
#ifndef THEMISURLPOPUPVIEWMESSAGEFILTER
#define THEMISURLPOPUPVIEWMESSAGEFILTER
-class ThemisUrlPopUpViewMessageFilter : public BMessageFilter
-{
+class ThemisUrlPopUpViewMessageFilter : public BMessageFilter {
+
+ private:
+ int32 lastbutton;
+
public:
- ThemisUrlPopUpViewMessageFilter( BWindow* win );
- virtual filter_result Filter( BMessage *msg, BHandler **target );
+ ThemisUrlPopUpViewMessageFilter(BWindow* win);
+
+ virtual filter_result Filter(BMessage *msg, BHandler **target);
- BWindow* window;
- int32 lastbutton;
};
#endif
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-02 18:11:12 UTC (rev 650)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-02 22:31:02 UTC (rev 651)
@@ -134,6 +134,13 @@
Unlock();
break;
}
+ case B_MOUSE_WHEEL_CHANGED: {
+ float value = msg->FindFloat( "be:wheel_delta_y");
+ value *= 10;
+ urlpopupview->ulv->ScrollBy(0, value);
+
+ break;
+ }
default :
BWindow::MessageReceived( msg );
}
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-02 18:11:12 UTC (rev 650)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-02 22:31:02 UTC (rev 651)
@@ -22,6 +22,7 @@
BList * url_list;
BList * trunc_list;
BScrollBar * vscroll;
+ ThemisUrlPopUpView * urlpopupview;
public:
ThemisUrlPopUpWindow(BWindow* aParent, BRect aFrame, BList * aList);
@@ -33,7 +34,6 @@
void TruncateUrlStrings();
bool HasScrollBar() const;
- ThemisUrlPopUpView * urlpopupview;
};
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-02 18:11:12 UTC (rev 650)
+++ trunk/themis/framework/win.cpp 2011-06-02 22:31:02 UTC (rev 651)
@@ -218,16 +218,10 @@
// never get the mouse wheel messages
if (urlpopupwindow != NULL) {
if (urlpopupwindow->HasScrollBar()) {
- float value = msg->FindFloat( "be:wheel_delta_y");
- value *= 10;
-
- urlpopupwindow->Lock();
- urlpopupwindow->urlpopupview->ulv->ScrollBy(0, value);
- urlpopupwindow->Unlock();
+ BMessenger* msgr = new BMessenger(NULL, urlpopupwindow, NULL);
+ msgr->SendMessage(msg);
}
}
- // i dunno where the scroll-recognition of the rendered site shall
- // happen.. if here, then it should go into here later :D
break;
}
case BUTTON_BACK: {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-02 18:11:18
|
Revision: 650
http://themis.svn.sourceforge.net/themis/?rev=650&view=rev
Author: mark_hellegers
Date: 2011-06-02 18:11:12 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
- Changed the code style to be more compact
- Moved the retrieving of the filtered url list to the GlobalHistory and removed the stripped list function.
- vscroll variable is now private and a function HasScrollBar is added that can be called to check if there is a scrollbar in the popup window.
- Removed several memory leaks although there is at least one left. Can't find it yet, though.
Modified Paths:
--------------
trunk/themis/framework/GlobalHistory.cpp
trunk/themis/framework/GlobalHistory.h
trunk/themis/framework/ThemisUrlPopUpWindow.cpp
trunk/themis/framework/ThemisUrlPopUpWindow.h
trunk/themis/framework/win.cpp
trunk/themis/framework/win.h
Modified: trunk/themis/framework/GlobalHistory.cpp
===================================================================
--- trunk/themis/framework/GlobalHistory.cpp 2011-06-02 18:04:41 UTC (rev 649)
+++ trunk/themis/framework/GlobalHistory.cpp 2011-06-02 18:11:12 UTC (rev 650)
@@ -31,33 +31,33 @@
#include <stdio.h>
#include <time.h>
+// BeOS headers
+#include <String.h>
+
// Themis headers
#include "../common/PrefsDefs.h"
#include "GlobalHistory.h"
-GlobalHistory::GlobalHistory(
- int8 depth,
- int8 count )
-{
+GlobalHistory :: GlobalHistory(int8 depth, int8 count) {
+
fHistoryDepthInDays = depth;
fFreeUrlCount = 0;
- fList = new BList( 0 );
+ fList = new BList(0);
+
}
-GlobalHistory::~GlobalHistory()
-{
- printf( "GlobalHistory::~GlobalHistory()\n" );
- printf( " Putting GlobalHistoryData in AppSettings\n" );
+GlobalHistory :: ~GlobalHistory() {
+
+ printf("GlobalHistory::~GlobalHistory()\n");
+ printf(" Putting GlobalHistoryData in AppSettings\n");
BMessage collector;
int32 count = fList->CountItems();
- for( int32 i = 0; i < count; i++ )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( ( int32 )0 );
- if( item != NULL )
- {
+ for (int32 i = 0; i < count; i++) {
+ GlobalHistoryItem * item = (GlobalHistoryItem *)fList->ItemAt((int32) 0);
+ if (item != NULL) {
/*
* Pack up the item data in a BMessage, which will then be stored in the
* collector message.
@@ -67,46 +67,43 @@
// item->Print();
BMessage collitem;
- collitem.AddString( "url", item->Text() );
- collitem.AddInt32( "time", item->Time() );
+ collitem.AddString("url", item->Text());
+ collitem.AddInt32("time", item->Time());
- collector.AddMessage( kPrefsGlobalHistoryItemMessage, &collitem );
+ collector.AddMessage(kPrefsGlobalHistoryItemMessage, &collitem);
}
- fList->RemoveItem( ( int32 )0 );
+ fList->RemoveItem((int32) 0);
delete item;
}
delete fList;
// collector->PrintToStream();
- if( AppSettings->HasMessage( kPrefsGlobalHistoryData ) )
+ if (AppSettings->HasMessage(kPrefsGlobalHistoryData))
AppSettings->ReplaceMessage(
kPrefsGlobalHistoryData,
- &collector );
+ &collector);
else
AppSettings->AddMessage(
kPrefsGlobalHistoryData,
- &collector );
+ &collector);
// AppSettings->PrintToStream();
- printf( "GlobalHistory destructor end.\n" );
+ printf("GlobalHistory destructor end.\n");
}
-void
-GlobalHistory::AddEntry(
- const char* entry )
-{
+void GlobalHistory :: AddEntry(const char* entry) {
+
// printf( "GlobalHistoryItem::AddEntry()\n" );
// printf( " New entry: %s\n", entry );
- GlobalHistoryItem* newitem = new GlobalHistoryItem( entry, time( NULL ) );
+ GlobalHistoryItem * newitem = new GlobalHistoryItem(entry, time(NULL));
/* We don't want to add an item twice for a day.
* ( This has nothing to do about similar entries on different days. )
*/
- if( CheckDoubleDay( newitem ) == false )
- {
+ if (CheckDoubleDay(newitem) == false) {
/*
* Check wether newitem is really younger then the first item in the
* history. If not, cycle through the list to find a suitable place
@@ -117,20 +114,15 @@
int32 count = fList->CountItems();
- if( count == 0 )
- {
- fList->AddItem( newitem, 0 );
+ if (count == 0) {
+ fList->AddItem(newitem, 0);
}
- else
- {
- for( int32 i = 0; i < count; i++ )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( i );
- if( item != NULL )
- {
- if( item->Time() < newitem->Time() )
- {
- fList->AddItem( newitem, i );
+ else {
+ for (int32 i = 0; i < count; i++) {
+ GlobalHistoryItem * item = (GlobalHistoryItem *)fList->ItemAt(i);
+ if (item != NULL) {
+ if (item->Time() < newitem->Time()) {
+ fList->AddItem(newitem, i);
break;
}
}
@@ -145,55 +137,44 @@
// PrintHistory();
}
-bool
-GlobalHistory::CheckDoubleDay(
- GlobalHistoryItem* checkitem )
-{
+bool GlobalHistory :: CheckDoubleDay(GlobalHistoryItem * checkitem) {
+
// printf( "GlobalHistory::CheckDoubleDay()\n" );
const time_t checkitem_time_t = checkitem->Time();
struct tm checkitem_tm;
- if( localtime_r( &checkitem_time_t, &checkitem_tm ) == NULL )
- {
+ if (localtime_r(&checkitem_time_t, &checkitem_tm) == NULL) {
// printf( " checkitem_tm == NULL. aborting.\n" );
return true;
}
int32 count = fList->CountItems();
- for( int32 i = 0; i < count; i++ )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( i );
- if( item != NULL )
- {
+ for (int32 i = 0; i < count; i++) {
+ GlobalHistoryItem* item = (GlobalHistoryItem *)fList->ItemAt(i);
+ if (item != NULL) {
const time_t item_time_t = item->Time();
struct tm item_tm;
- if( localtime_r( &item_time_t, &item_tm ) != NULL )
- {
+ if (localtime_r(&item_time_t, &item_tm) != NULL) {
/* note: If we find an item from the day or year before, we can stop the check.
* ( List is kept chronologically. Newest first. )
*/
- if( item_tm.tm_year == checkitem_tm.tm_year )
- {
- if( item_tm.tm_yday == checkitem_tm.tm_yday )
- {
- if( strcmp( item->Text(), checkitem->Text() ) == 0 )
- {
+ if (item_tm.tm_year == checkitem_tm.tm_year) {
+ if (item_tm.tm_yday == checkitem_tm.tm_yday) {
+ if (strcmp(item->Text(), checkitem->Text()) == 0) {
// printf( " URL already stored today. skipping.\n" );
return true;
}
}
- else
- {
+ else {
// printf( " Found older (or newer) item [day]. break.\n" );
break;
}
}
- else
- {
+ else {
// printf( " Found older (or newer) item [year]. break.\n" );
break;
}
@@ -206,16 +187,15 @@
return false;
}
-void
-GlobalHistory::CheckEntryExpiration()
-{
+void GlobalHistory :: CheckEntryExpiration() {
+
// printf( "GlobalHistory::CheckEntryExpiration()\n" );
int32 count = fList->CountItems();
int8 freecount = 0;
- const time_t now = time( NULL );
+ const time_t now = time(NULL);
struct tm today_tm;
- localtime_r( &now, &today_tm );
+ localtime_r(&now, &today_tm);
// printf( " GlobalHistoryDepthInDays: %d\n", fHistoryDepthInDays );
// printf( " today_tm.tm_yday: %d\n", today_tm.tm_yday );
@@ -225,38 +205,33 @@
* ( Oldest item is stored at the end of the list. )
*/
- for( int32 i = count - 1; i >= 0; i-- )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( i );
+ for (int32 i = count - 1; i >= 0; i--) {
+ GlobalHistoryItem* item = (GlobalHistoryItem *)fList->ItemAt(i);
const time_t itemtime_t = item->Time();
struct tm item_tm;
- localtime_r( &itemtime_t, &item_tm );
+ localtime_r(&itemtime_t, &item_tm);
int16 limit = 0;
- if( item_tm.tm_yday >= fHistoryDepthInDays - 1 )
- {
+ if (item_tm.tm_yday >= fHistoryDepthInDays - 1) {
// printf( " Item within this year.\n" );
- limit = ( int16 )( today_tm.tm_yday - fHistoryDepthInDays );
+ limit = (int16)(today_tm.tm_yday - fHistoryDepthInDays);
}
- else
- {
+ else {
// printf( " Item from last year.\n" );
- limit = ( int16 )( 365 - ( fHistoryDepthInDays - ( item_tm.tm_yday + 1 ) ) );
+ limit = (int16)(365 - (fHistoryDepthInDays - (item_tm.tm_yday + 1)));
}
// printf( " limit: %d ( Entries <= this one are expired. )\n", limit );
- if( item_tm.tm_yday <= limit )
- {
+ if (item_tm.tm_yday <= limit) {
// printf( " The following item is expired. (Will be marked as free url.):\n" );
item->Print();
item->SetFree();
freecount++;
}
- else
- {
+ else {
// printf( " Found in time item. break.\n" );
break;
}
@@ -266,173 +241,173 @@
// remove free urls when we are over GlobalHistoryFreeUrlCount
int8 ghfuc = 0;
- AppSettings->FindInt8( kPrefsGlobalHistoryFreeURLCount, &ghfuc );
- if( freecount > ghfuc )
- {
+ AppSettings->FindInt8(kPrefsGlobalHistoryFreeURLCount, &ghfuc);
+ if (freecount > ghfuc) {
// printf( " Removing expired free URLs.\n" );
freecount -= ghfuc;
- for( int8 i = 0; i < freecount; i++ )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( fList->CountItems() -1 );
- if( item != NULL )
- {
+ for (int8 i = 0; i < freecount; i++) {
+ GlobalHistoryItem* item = (GlobalHistoryItem*)fList->ItemAt(fList->CountItems() -1);
+ if (item != NULL) {
// printf( " Removing following expired free URL:\n" );
// item->Print();
- fList->RemoveItem( item );
+ fList->RemoveItem(item);
delete item;
}
}
- }
+ }
}
-void
-GlobalHistory::Clear()
-{
- printf( "GlobalHistory::Clear()\n" );
- while( fList->CountItems() > 0 )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( 0 );
- if( item != NULL )
- {
- fList->RemoveItem( item );
+void GlobalHistory :: Clear() {
+
+ printf("GlobalHistory::Clear()\n");
+ while (fList->CountItems() > 0) {
+ GlobalHistoryItem* item = (GlobalHistoryItem *)fList->ItemAt(0);
+ if (item != NULL) {
+ fList->RemoveItem(item);
delete item;
}
}
}
-BList*
-GlobalHistory::GetStrippedList()
-{
-// printf( "GlobalHistory::GetStrippedList()\n" );
+BList * GlobalHistory :: GetFilteredList(BString & aText) {
- BList* slist = new BList( 0 );
-
+ BString cached_url; // the cached url
+ BString cached_url_proto(""); // protocol of the cached url
+ GlobalHistoryItem * item = NULL;
+ BList * list = new BList();
+ bool matchFound = false;
+
int32 count = fList->CountItems();
-
- /* start adding from last to first, so that we just have to BList::AddItem()
- * without index in Win::UrlTypedHandler(). This results in newer urls ( if
- * they match ) to be at top of the list.
- */
-
- for( int32 i = 0; i < count; i++ )
- {
-// printf( " ==================\n" );
-
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( i );
- if( item != NULL )
- {
-// printf( " Checking for: %s\n", item->Text() );
-
- bool filed = false;
- int32 count2 = slist->CountItems();
-
- for( int32 j = 0; j < count2; j++ )
- {
- GlobalHistoryItem* compareitem = ( GlobalHistoryItem* )slist->ItemAt( j );
- if( compareitem != NULL )
- {
- if( strcmp( item->Text(), compareitem->Text() ) == 0 )
- {
-// printf( " Entry already filed in stripped list. break.\n" );
- filed = true;
- break;
+
+ for (int32 i = 0; i < count; i++) {
+ item = (GlobalHistoryItem *)fList->ItemAt(i);
+ if (item != NULL) {
+ cached_url.SetTo(item->Text());
+
+ if (aText.Length() != 0) {
+ // if the typed url matches beginning of cached url, add it
+ if (strncmp(cached_url.String(), aText.String(), aText.Length()) == 0) {
+ matchFound = true;
+ }
+ else {
+ // if the urls dont match, take away the protocol of the cached url
+ if (cached_url.FindFirst("://") > 0) {
+ cached_url.MoveInto(cached_url_proto, 0, cached_url.FindFirst("://") + 3);
}
+
+ // if the urls fit now
+ if (strncmp(cached_url.String(), aText.String(), aText.Length()) == 0) {
+ // add the missing proto again
+ if (cached_url_proto.Length() != 0)
+ cached_url.Prepend(cached_url_proto);
+ matchFound = true;
+ }
+ else {
+ // if they still don't fit, remove 'www.' from cached url
+ if (cached_url.FindFirst("www.") == 0) {
+ cached_url.Remove(0, 4);
+ }
+
+ // check if they finally fit
+ if (strncmp(cached_url.String(), aText.String(), aText.Length()) == 0) {
+ // add missing 'www.' and proto
+ cached_url.Prepend("www.");
+
+ if (cached_url_proto.Length() != 0)
+ cached_url.Prepend(cached_url_proto);
+ matchFound = true;
+ }
+ }
+ cached_url_proto.SetTo("");
}
}
- if( filed == false )
- {
-// printf( " Entry not filed. Adding.\n" );
- GlobalHistoryItem* newitem = new GlobalHistoryItem(
- item->Text(),
- item->Time() );
- slist->AddItem( newitem );
+ else {
+ matchFound = true;
}
- }
+
+ if (matchFound) {
+ // Check if we already have it in our collection
+ bool found = false;
+ int32 count2 = list->CountItems();
+
+ int32 j = 0;
+ while (j < count2 && !found) {
+ BStringItem * storedUrl = (BStringItem *)list->ItemAt(j);
+ if (strcmp(cached_url.String(), storedUrl->Text()) == 0) {
+ found = true;
+ }
+ else {
+ j++;
+ }
+ }
+ if (!found) {
+ list->AddItem(new BStringItem(cached_url.String()));
+ }
+ }
+ matchFound = false;
+ } // if( item != NULL )
}
-
-// int32 scount = slist->CountItems();
-//
-// printf( " ============================\n" );
-// printf( " Stripped List: ( %ld items )\n", scount );
-// for( int32 k = 0; k < scount; k++ )
-// {
-// GlobalHistoryItem* item = ( GlobalHistoryItem* )slist->ItemAt( k );
-// if( item != NULL )
-// item->Print();
-// }
-// printf( " ============================\n" );
-
- return slist;
+
+ return list;
+
}
-void
-GlobalHistory::Init(
- BMessage* datamsg )
-{
- printf( "GlobalHistory::Init()\n" );
+void GlobalHistory :: Init(BMessage* datamsg) {
+
+ printf("GlobalHistory::Init()\n");
// datamsg->PrintToStream();
- if( datamsg == NULL )
- return;
-
- type_code tc = B_ANY_TYPE;
- int32 count = -1;
-
- if( datamsg->GetInfo( kPrefsGlobalHistoryItemMessage, &tc, &count ) == B_OK )
- {
- printf( " Found %ld GlobalHistoryItemMessages.\n", count );
+ if (datamsg != NULL) {
+ type_code tc = B_ANY_TYPE;
+ int32 count = -1;
- for( int32 i = 0; i < count; i++ )
- {
- BMessage* ghimsg = new BMessage;
- datamsg->FindMessage( kPrefsGlobalHistoryItemMessage, i, ghimsg );
- if( ghimsg != NULL )
- {
- GlobalHistoryItem* newitem = new GlobalHistoryItem(
- ghimsg->FindString( "url" ),
- ghimsg->FindInt32( "time" ) );
- newitem->Print();
- fList->AddItem( newitem, 0 );
+ if (datamsg->GetInfo(kPrefsGlobalHistoryItemMessage, &tc, &count ) == B_OK) {
+ printf(" Found %ld GlobalHistoryItemMessages.\n", count);
+
+ for (int32 i = 0; i < count; i++) {
+ BMessage* ghimsg = new BMessage;
+ datamsg->FindMessage(kPrefsGlobalHistoryItemMessage, i, ghimsg);
+ if (ghimsg != NULL) {
+ GlobalHistoryItem * newitem = new GlobalHistoryItem(
+ ghimsg->FindString("url"),
+ ghimsg->FindInt32("time"));
+ newitem->Print();
+ fList->AddItem(newitem, 0);
+ }
+ delete ghimsg;
}
- delete ghimsg;
+
+ CheckEntryExpiration();
}
-
- CheckEntryExpiration();
+ else {
+ printf(" No GlobalHistoryItemMessages found.\n");
+ }
}
- else
- {
- printf( " No GlobalHistoryItemMessages found.\n" );
- }
}
-void
-GlobalHistory::PrintHistory()
-{
- printf( "GlobalHistory::PrintHistory()\n" );
+void GlobalHistory :: PrintHistory() {
+
+ printf("GlobalHistory::PrintHistory()\n");
int32 count = fList->CountItems();
- printf( " =============================\n" );
- printf( " Global History: ( %ld items )\n", count );
- for( int32 i = 0; i < count; i++ )
- {
- GlobalHistoryItem* item = ( GlobalHistoryItem* )fList->ItemAt( i );
- if( item != NULL )
+ printf(" =============================\n");
+ printf(" Global History: ( %ld items )\n", count);
+ for (int32 i = 0; i < count; i++) {
+ GlobalHistoryItem* item = (GlobalHistoryItem *)fList->ItemAt(i);
+ if (item != NULL)
item->Print();
}
- printf( " =============================\n" );
+ printf(" =============================\n");
}
-void
-GlobalHistory::SetDepth(
- int8 newdepth )
-{
+void GlobalHistory :: SetDepth(int8 newdepth) {
+
// printf( "GlobalHistory::SetDepth()\n" );
- if( newdepth < fHistoryDepthInDays )
- {
+ if (newdepth < fHistoryDepthInDays) {
// remove entries if needed to suit fMaxDepth
fHistoryDepthInDays = newdepth;
CheckEntryExpiration();
@@ -444,44 +419,34 @@
/* GLOBALHISTORYITEM */
-GlobalHistoryItem::GlobalHistoryItem(
- const char* text,
- time_t time,
- uint32 level = 0,
- bool expanded = true )
- : BStringItem( text, level, expanded )
-{
+GlobalHistoryItem :: GlobalHistoryItem(const char* text,
+ time_t time,
+ uint32 level = 0,
+ bool expanded = true )
+ : BStringItem(text, level, expanded) {
+
fTime = time;
+
}
-GlobalHistoryItem::~GlobalHistoryItem()
-{
+GlobalHistoryItem :: ~GlobalHistoryItem() {
+
}
-void
-GlobalHistoryItem::Print()
-{
+void GlobalHistoryItem :: Print() {
+
// printf( "GlobalHistoryItem::Print()\n" );
// printf( " %s @ %s", Text(), asctime( localtime( &fTime ) ) );
}
-void
-GlobalHistoryItem::SetFree()
-{
+void GlobalHistoryItem :: SetFree() {
+
fTime = 0;
+
}
-//void
-//GlobalHistoryItem::SetTime(
-// time_t newtime )
-//{
-// printf( "GlobalHistoryItem::SetTime()\n" );
-//
-// fTime = newtime;
-//}
+time_t GlobalHistoryItem :: Time() {
-time_t
-GlobalHistoryItem::Time()
-{
return fTime;
+
}
Modified: trunk/themis/framework/GlobalHistory.h
===================================================================
--- trunk/themis/framework/GlobalHistory.h 2011-06-02 18:04:41 UTC (rev 649)
+++ trunk/themis/framework/GlobalHistory.h 2011-06-02 18:11:12 UTC (rev 650)
@@ -35,32 +35,28 @@
class GlobalHistoryItem;
-class GlobalHistory
-{
+class GlobalHistory {
+
+ private:
+ int8 fHistoryDepthInDays;
+ int8 fFreeUrlCount;
+ BList * fList;
+
+ bool CheckDoubleDay(GlobalHistoryItem* checkitem);
+ void CheckEntryExpiration();
+
public:
- GlobalHistory(
- int8 depth,
- int8 count );
- ~GlobalHistory();
+ GlobalHistory(int8 depth,
+ int8 count);
+ ~GlobalHistory();
- void AddEntry(
- const char* entry );
- void Clear();
- BList* GetStrippedList();
- void Init(
- BMessage* datamsg );
- void PrintHistory();
- void SetDepth(
- int8 newdepth );
+ void AddEntry(const char* entry);
+ void Clear();
+ BList * GetFilteredList(BString & aText);
+ void Init(BMessage* datamsg);
+ void PrintHistory();
+ void SetDepth(int8 newdepth);
- private:
- bool CheckDoubleDay(
- GlobalHistoryItem* checkitem );
- void CheckEntryExpiration();
-
- int8 fHistoryDepthInDays;
- int8 fFreeUrlCount;
- BList* fList;
};
#endif
@@ -70,25 +66,21 @@
#include <ListItem.h>
-class GlobalHistoryItem : public BStringItem
-{
+class GlobalHistoryItem : public BStringItem {
+ private:
+ time_t fTime;
+
public:
- GlobalHistoryItem(
- const char* text,
- time_t time,
- uint32 level = 0,
- bool expaned = true );
- virtual ~GlobalHistoryItem();
-
- void Print();
- void SetFree();
-// void SetTime(
-// time_t newtime );
- time_t Time();
+ GlobalHistoryItem(const char* text,
+ time_t time,
+ uint32 level = 0,
+ bool expaned = true);
+ virtual ~GlobalHistoryItem();
- private:
- time_t fTime;
-
+ void Print();
+ void SetFree();
+ time_t Time();
+
};
#endif
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.cpp
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-02 18:04:41 UTC (rev 649)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.cpp 2011-06-02 18:11:12 UTC (rev 650)
@@ -15,26 +15,27 @@
#include "../common/commondefs.h"
#include "ThemisUrlPopUpWindow.h"
-ThemisUrlPopUpWindow::ThemisUrlPopUpWindow( BWindow* parent, BRect frame )
- : BWindow(
- frame,
- "UrlPopUpWindow",
- B_NO_BORDER_WINDOW_LOOK,
- B_FLOATING_APP_WINDOW_FEEL,
- B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE |
- B_NOT_MINIMIZABLE | B_WILL_ACCEPT_FIRST_CLICK |
- B_AVOID_FOCUS | B_ASYNCHRONOUS_CONTROLS,
- B_CURRENT_WORKSPACE )
-{
- parentwindow = parent;
+ThemisUrlPopUpWindow :: ThemisUrlPopUpWindow(BWindow * aParent,
+ BRect aFrame,
+ BList * aList)
+ : BWindow(aFrame,
+ "UrlPopUpWindow",
+ B_NO_BORDER_WINDOW_LOOK,
+ B_FLOATING_APP_WINDOW_FEEL,
+ B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE |
+ B_NOT_MINIMIZABLE | B_WILL_ACCEPT_FIRST_CLICK |
+ B_AVOID_FOCUS | B_ASYNCHRONOUS_CONTROLS,
+ B_CURRENT_WORKSPACE) {
+
+ parentwindow = aParent;
lastitem = 0;
vscroll = NULL;
- url_list = NULL;
- trunc_list = NULL;
+ url_list = new BList;
+ trunc_list = new BList;
- urlpopupview = new ThemisUrlPopUpView(
- Bounds() );
- AddChild( urlpopupview );
+ urlpopupview = new ThemisUrlPopUpView(Bounds());
+ AddChild(urlpopupview);
+ ListToDisplay(aList);
}
ThemisUrlPopUpWindow::~ThemisUrlPopUpWindow()
@@ -143,30 +144,39 @@
{
//cout << "ThemisUrlPopUpWindow::ListToDisplay()" << endl;
- if( list != NULL )
- {
+ 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);
+ }
+ }
+ 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 = new BList( *list );
- // and the list with truncated urls if urlpopup is
- // smaller then the urls-length
- trunc_list = new BList( url_list->CountItems() );
+ 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() ) );
+ BStringItem * item;
+ while (url_list->ItemAt( i ) != NULL) {
+ item = ( BStringItem* )url_list->ItemAt(i);
+ trunc_list->AddItem( new BStringItem(item->Text()));
i++;
}
+ urlpopupview->ulv->MakeEmpty();
+ urlpopupview->ulv->AddList(trunc_list);
+
TruncateUrlStrings();
- urlpopupview->ulv->MakeEmpty();
- urlpopupview->ulv->AddList( trunc_list );
-
ResizeToPrefered();
}
}
@@ -245,30 +255,32 @@
}
}
-void
-ThemisUrlPopUpWindow::TruncateUrlStrings()
-{
+void ThemisUrlPopUpWindow :: TruncateUrlStrings() {
+
int i = 0;
BStringItem* urlitem = NULL;
BStringItem* truncitem = NULL;
- BString* string = new BString;
+ BString text;
- while( url_list->ItemAt( i ) != NULL )
- {
- urlitem = ( BStringItem* )url_list->ItemAt( i );
- if( urlitem != NULL );
- string->SetTo( urlitem->Text() );
+ while (url_list->ItemAt(i) != NULL) {
+ urlitem = (BStringItem *)url_list->ItemAt(i);
+ text.SetTo(urlitem->Text());
urlpopupview->TruncateString(
- string,
+ &text,
B_TRUNCATE_END,
- urlpopupview->ulv->Bounds().right - 10 );
+ urlpopupview->ulv->Bounds().right - 10);
- truncitem = ( BStringItem* )urlpopupview->ulv->ItemAt( i );
- if( truncitem != NULL )
- truncitem->SetText( string->String() );
-
+ truncitem = (BStringItem *)urlpopupview->ulv->ItemAt(i);
+ if (truncitem != NULL)
+ truncitem->SetText(text.String());
+
i++;
}
- delete string;
}
+
+bool ThemisUrlPopUpWindow :: HasScrollBar() const {
+
+ return (vscroll != NULL);
+
+}
Modified: trunk/themis/framework/ThemisUrlPopUpWindow.h
===================================================================
--- trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-02 18:04:41 UTC (rev 649)
+++ trunk/themis/framework/ThemisUrlPopUpWindow.h 2011-06-02 18:11:12 UTC (rev 650)
@@ -13,28 +13,28 @@
#include "ThemisUrlPopUpView.h"
#include "Window.h"
-class ThemisUrlPopUpWindow : public BWindow
-{
+class ThemisUrlPopUpWindow : public BWindow {
+
+ private:
+ BWindow * parentwindow;
+
+ uint32 lastitem;
+ BList * url_list;
+ BList * trunc_list;
+ BScrollBar * vscroll;
+
public:
- ThemisUrlPopUpWindow( BWindow* parent, BRect frame );
+ ThemisUrlPopUpWindow(BWindow* aParent, BRect aFrame, BList * aList);
+ ~ThemisUrlPopUpWindow();
- ~ThemisUrlPopUpWindow();
-
- virtual void MessageReceived( BMessage *msg );
+ virtual void MessageReceived(BMessage *msg);
+ void ListToDisplay(BList* list);
+ void ResizeToPrefered();
+ void TruncateUrlStrings();
+ bool HasScrollBar() const;
- void ListToDisplay( BList* list );
- void ResizeToPrefered();
- void TruncateUrlStrings();
-
- ThemisUrlPopUpView* urlpopupview;
- BScrollBar* vscroll;
-
- private:
- BWindow* parentwindow;
-
- uint32 lastitem;
- BList* url_list;
- BList* trunc_list;
+ ThemisUrlPopUpView * urlpopupview;
+
};
#endif
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-06-02 18:04:41 UTC (rev 649)
+++ trunk/themis/framework/win.cpp 2011-06-02 18:11:12 UTC (rev 650)
@@ -217,7 +217,7 @@
// as the urlpopupwindow never gets focus and thus
// never get the mouse wheel messages
if (urlpopupwindow != NULL) {
- if (urlpopupwindow->vscroll != NULL) {
+ if (urlpopupwindow->HasScrollBar()) {
float value = msg->FindFloat( "be:wheel_delta_y");
value *= 10;
@@ -663,7 +663,7 @@
}
-void Win :: CreateUrlPopUpWindow() {
+void Win :: CreateUrlPopUpWindow(BList * aList) {
if (urlpopupwindow == NULL) {
BRect frame(navview->urlview->Frame());
@@ -673,7 +673,7 @@
wframe.top = frame.bottom;
wframe.bottom = wframe.top + 30;
- urlpopupwindow = new ThemisUrlPopUpWindow(this, wframe);
+ urlpopupwindow = new ThemisUrlPopUpWindow(this, wframe, aList);
urlpopupwindow->Run();
urlpopupwindow->Show();
@@ -683,6 +683,11 @@
CurrentFocus()->MakeFocus(false);
navview->urlview->textview->MakeFocus(true);
}
+ else {
+ urlpopupwindow->Lock();
+ urlpopupwindow->ListToDisplay(aList);
+ urlpopupwindow->Unlock();
+ }
}
@@ -830,14 +835,7 @@
void Win :: UrlTypedHandler(bool show_all) {
- // get the stripped list from GlobalHistory
- BList * slist = ((App *)be_app)->GetGlobalHistory()->GetStrippedList();
- // create the matching urls list
- BList * list = new BList(0);
-
BString typed_url; // the typed url
- BString cached_url; // the cached url
- BString cached_url_proto(""); // protocol of the cached url
if (show_all == true)
typed_url.SetTo("");
@@ -846,80 +844,19 @@
typed_url.ToLower();
}
- int32 count = slist->CountItems();
-
- for (int32 i = 0; i < count; i++) {
- GlobalHistoryItem * item = (GlobalHistoryItem *)slist->ItemAt(i);
- if (item != NULL) {
- cached_url.SetTo(item->Text());
-
- if (typed_url.Length() != 0) {
- // if the typed url matches beginning of cached url, add it
- if (strncmp(cached_url.String(), typed_url.String(), typed_url.Length()) == 0) {
- list->AddItem(new BStringItem(cached_url.String()));
- }
- else {
- // if the urls dont match, take away the protocol of the cached url
- if (cached_url.FindFirst("://") > 0) {
- cached_url.MoveInto(cached_url_proto, 0, cached_url.FindFirst("://") + 3);
- }
-
- // if the urls fit now
- if (strncmp(cached_url.String(), typed_url.String(), typed_url.Length()) == 0) {
- // add the missing proto again
- if (cached_url_proto.Length() != 0)
- cached_url.Prepend(cached_url_proto);
-
- list->AddItem(new BStringItem(cached_url.String()));
- }
- else {
- // if they still don't fit, remove 'www.' from cached url
- if (cached_url.FindFirst("www.") == 0) {
- cached_url.Remove(0, 4);
- }
-
- // check if they finally fit
- if (strncmp(cached_url.String(), typed_url.String(), typed_url.Length()) == 0) {
- // add missing 'www.' and proto
- cached_url.Prepend("www.");
-
- if (cached_url_proto.Length() != 0)
- cached_url.Prepend(cached_url_proto);
-
- list->AddItem(new BStringItem(cached_url.String()));
- }
- }
- cached_url_proto.SetTo("");
- }
- }
- else {
- list->AddItem(new BStringItem(cached_url.String()));
- }
- } // if( item != NULL )
- }
-
- // delete slist ( not needed anymore )
- for (int32 i = 0; i < count; i++) {
- GlobalHistoryItem * item = (GlobalHistoryItem *)slist->ItemAt(i);
- if (item != NULL) {
- slist->RemoveItem(item);
- delete item;
- }
- }
- delete slist;
-
+ // create the matching urls list
+ BList * list = ((App *)be_app)->GetGlobalHistory()->GetFilteredList(typed_url);
+
// add the urlpopupwindow if needed
if (list->CountItems() > 0) {
- CreateUrlPopUpWindow();
- // add the list
- urlpopupwindow->Lock();
- urlpopupwindow->ListToDisplay(list);
- urlpopupwindow->Unlock();
+ CreateUrlPopUpWindow(list);
}
else {
CloseUrlPopUpWindow();
}
+ delete list;
+
}
status_t Win :: ReceiveBroadcast(BMessage * message) {
Modified: trunk/themis/framework/win.h
===================================================================
--- trunk/themis/framework/win.h 2011-06-02 18:04:41 UTC (rev 649)
+++ trunk/themis/framework/win.h 2011-06-02 18:11:12 UTC (rev 650)
@@ -96,7 +96,7 @@
bool CloseUrlPopUpWindow();
uint32 BroadcastTarget();
void CreateTabView();
- void CreateUrlPopUpWindow();
+ void CreateUrlPopUpWindow(BList * aList);
void SetLoadingInfo(int doc_progress,
const char* status_text);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-02 18:04:47
|
Revision: 649
http://themis.svn.sourceforge.net/themis/?rev=649&view=rev
Author: mark_hellegers
Date: 2011-06-02 18:04:41 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
Added mouse wheel scrolling.
Modified Paths:
--------------
trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp
Modified: trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp 2011-06-02 14:29:14 UTC (rev 648)
+++ trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp 2011-06-02 18:04:41 UTC (rev 649)
@@ -170,6 +170,11 @@
}
break;
}
+ case B_MOUSE_WHEEL_CHANGED: {
+ float value = aMessage->FindFloat( "be:wheel_delta_y");
+ mView->ScrollBy(0, value * 50);
+ break;
+ }
default: {
BView::MessageReceived(aMessage);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-06-02 14:29:20
|
Revision: 648
http://themis.svn.sourceforge.net/themis/?rev=648&view=rev
Author: mark_hellegers
Date: 2011-06-02 14:29:14 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
Only try to draw something when a view has been created.
Modified Paths:
--------------
trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-04-14 20:22:22 UTC (rev 647)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-06-02 14:29:14 UTC (rev 648)
@@ -107,7 +107,9 @@
// printf("Drawing in view\n");
FillRect(Bounds(), B_SOLID_LOW);
- mView->Draw();
+ if (mView) {
+ mView->Draw();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-04-14 20:22:29
|
Revision: 647
http://themis.svn.sourceforge.net/themis/?rev=647&view=rev
Author: mark_hellegers
Date: 2011-04-14 20:22:22 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
Moved the applying of the styles to a separate function and changed the code so it loops through the values instead of trying everything it knows about.
Modified Paths:
--------------
trunk/themis/modules/CSSRenderer/CSSView.cpp
trunk/themis/modules/CSSRenderer/CSSView.hpp
Modified: trunk/themis/modules/CSSRenderer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-04-14 19:07:55 UTC (rev 646)
+++ trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-04-14 20:22:22 UTC (rev 647)
@@ -124,10 +124,100 @@
mClickable = true;
}
}
- CSSStyleDeclarationPtr style = mStyleSheets->getComputedStyle(element);
- if (style.get()) {
- CSSValuePtr value = style->getPropertyCSSValue("display");
- if (value.get()) {
+ ApplyStyle(element);
+ }
+
+ for (unsigned int i = 0; i < length; i++) {
+ TNodePtr child = children->item(i);
+ CSSView * childView = new CSSView(aBaseView,
+ child,
+ mStyleSheets,
+ mRect,
+ mColor,
+ mFont);
+ mChildren.push_back(childView);
+ }
+ }
+ else if (mNode->getNodeType() == TEXT_NODE) {
+ if (mFont == NULL) {
+ mFont = new BFont(be_plain_font);
+ mInheritedFont = false;
+ }
+ font_height height;
+ mFont->GetHeight(&height);
+ mLineHeight = height.ascent + height.descent + height.leading;
+ mBottomMargin = height.descent;
+ mSpaceWidth = mFont->StringWidth(&cSpace, 1);
+ mBlock = false;
+
+ SplitText();
+ }
+
+}
+
+CSSView :: ~CSSView() {
+
+ unsigned int length = mChildren.size();
+ for (unsigned int i = 0; i < length; i++) {
+ delete mChildren[i];
+ }
+
+/*
+ if (!mInheritedFont) {
+ delete mFont;
+ }
+*/
+
+}
+
+void CSSView :: RetrieveLink() {
+
+ if (mHref.size() > 0) {
+ // Send a message to the window.
+ // The window will do all the actual work of requesting a new page.
+ string urlString = "";
+ unsigned int position = mHref.find("://");
+ if (position == string::npos) {
+ urlString = mBaseView->GetDocumentURI();
+ if (mHref[0] == '/') {
+ // Get past the :// in the base uri, so we can find the right /
+ position = urlString.find("://");
+ if (position != string::npos) {
+ position += 3;
+ }
+ else {
+ position = 0;
+ }
+ // Find domain and use that as the base of the url.
+ position = urlString.find_first_of("/", position);
+ urlString = urlString.substr(0, position);
+
+ }
+ else {
+ // Find last subdirectory and use that as the base of the url.
+ position = urlString.find_last_of("/");
+ urlString = urlString.substr(0, position + 1);
+ }
+ }
+ urlString += mHref;
+ BMessage message(URL_OPEN);
+ message.AddString("url_to_open", urlString.c_str());
+ BMessenger messenger(NULL, mBaseView->Window());
+ messenger.SendMessage(&message);
+ }
+
+}
+
+void CSSView :: ApplyStyle(const TElementPtr aElement) {
+
+ CSSStyleDeclarationPtr style = mStyleSheets->getComputedStyle(aElement);
+ if (style.get()) {
+ unsigned long length = style->getLength();
+ for (unsigned long i = 0; i < length; i++) {
+ TDOMString propertyName = style->item(i);
+ CSSValuePtr value = style->getPropertyCSSValue(propertyName);
+ if (value.get()) {
+ if (propertyName == "display") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
TDOMString valueString = primitiveValue->getStringValue();
// printf("Display property value: %s\n", valueString.c_str());
@@ -148,8 +238,7 @@
mTableCell = true;
}
}
- value = style->getPropertyCSSValue("font-size");
- if (value.get()) {
+ else if (propertyName == "font-size") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
if (primitiveValue->getPrimitiveType() == CSSPrimitiveValue::CSS_EMS) {
@@ -162,8 +251,7 @@
}
}
}
- value = style->getPropertyCSSValue("font-style");
- if (value.get()) {
+ else if (propertyName == "font-style") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
TDOMString valueString = primitiveValue->getStringValue();
@@ -176,8 +264,7 @@
}
}
}
- value = style->getPropertyCSSValue("font-weight");
- if (value.get()) {
+ else if (propertyName == "font-weight") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
TDOMString valueString = primitiveValue->getStringValue();
@@ -190,8 +277,7 @@
}
}
}
- value = style->getPropertyCSSValue("margin-bottom");
- if (value.get()) {
+ else if (propertyName == "margin-bottom") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
if (primitiveValue->getPrimitiveType() == CSSPrimitiveValue::CSS_PX) {
@@ -200,8 +286,7 @@
}
}
}
- value = style->getPropertyCSSValue("margin-right");
- if (value.get()) {
+ else if (propertyName == "margin-right") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
if (primitiveValue->getPrimitiveType() == CSSPrimitiveValue::CSS_PX) {
@@ -210,8 +295,7 @@
}
}
}
- value = style->getPropertyCSSValue("color");
- if (value.get()) {
+ else if (propertyName == "color") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
if (primitiveValue->getPrimitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR) {
@@ -229,22 +313,19 @@
}
}
}
- value = style->getPropertyCSSValue("list-style-type");
- if (value.get()) {
+ else if (propertyName == "list-style-type") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
mListStyleType = primitiveValue->getStringValue();
}
}
- value = style->getPropertyCSSValue("border-style");
- if (value.get()) {
+ else if (propertyName == "border-style") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
mBorderStyle = primitiveValue->getStringValue();
}
}
- value = style->getPropertyCSSValue("border-width");
- if (value.get()) {
+ else if (propertyName == "border-width") {
CSSPrimitiveValuePtr primitiveValue = shared_static_cast<CSSPrimitiveValue>(value);
if (primitiveValue.get()) {
if (primitiveValue->getPrimitiveType() == CSSPrimitiveValue::CSS_PX) {
@@ -255,88 +336,9 @@
}
}
}
-
- for (unsigned int i = 0; i < length; i++) {
- TNodePtr child = children->item(i);
- CSSView * childView = new CSSView(aBaseView,
- child,
- mStyleSheets,
- mRect,
- mColor,
- mFont);
- mChildren.push_back(childView);
- }
}
- else if (mNode->getNodeType() == TEXT_NODE) {
- if (mFont == NULL) {
- mFont = new BFont(be_plain_font);
- mInheritedFont = false;
- }
- font_height height;
- mFont->GetHeight(&height);
- mLineHeight = height.ascent + height.descent + height.leading;
- mBottomMargin = height.descent;
- mSpaceWidth = mFont->StringWidth(&cSpace, 1);
- mBlock = false;
-
- SplitText();
- }
-
}
-CSSView :: ~CSSView() {
-
- unsigned int length = mChildren.size();
- for (unsigned int i = 0; i < length; i++) {
- delete mChildren[i];
- }
-
-/*
- if (!mInheritedFont) {
- delete mFont;
- }
-*/
-
-}
-
-void CSSView :: RetrieveLink() {
-
- if (mHref.size() > 0) {
- // Send a message to the window.
- // The window will do all the actual work of requesting a new page.
- string urlString = "";
- unsigned int position = mHref.find("://");
- if (position == string::npos) {
- urlString = mBaseView->GetDocumentURI();
- if (mHref[0] == '/') {
- // Get past the :// in the base uri, so we can find the right /
- position = urlString.find("://");
- if (position != string::npos) {
- position += 3;
- }
- else {
- position = 0;
- }
- // Find domain and use that as the base of the url.
- position = urlString.find_first_of("/", position);
- urlString = urlString.substr(0, position);
-
- }
- else {
- // Find last subdirectory and use that as the base of the url.
- position = urlString.find_last_of("/");
- urlString = urlString.substr(0, position + 1);
- }
- }
- urlString += mHref;
- BMessage message(URL_OPEN);
- message.AddString("url_to_open", urlString.c_str());
- BMessenger messenger(NULL, mBaseView->Window());
- messenger.SendMessage(&message);
- }
-
-}
-
void CSSView :: MouseDown(BPoint aPoint) {
if (mClickable) {
Modified: trunk/themis/modules/CSSRenderer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-04-14 19:07:55 UTC (rev 646)
+++ trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-04-14 20:22:22 UTC (rev 647)
@@ -100,6 +100,9 @@
BRect mListStyleRect;
void RetrieveLink();
+
+ protected:
+ void ApplyStyle(const TElementPtr aElement);
public:
CSSView(CSSRendererView * aBaseView,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: CVS C. to T. <the...@li...> - 2011-04-14 19:08:01
|
Revision: 646
http://themis.svn.sourceforge.net/themis/?rev=646&view=rev
Author: mark_hellegers
Date: 2011-04-14 19:07:55 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
- Added separate class for the stylesheets. This should make future improvements easier. Especially multiple stylesheets.
- Added basic style for the TBODY element.
Modified Paths:
--------------
trunk/themis/makefile
trunk/themis/modules/CSSParser/html4.css
trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
trunk/themis/modules/CSSRenderer/CSSRendererView.hpp
trunk/themis/modules/CSSRenderer/CSSView.cpp
trunk/themis/modules/CSSRenderer/CSSView.hpp
Added Paths:
-----------
trunk/themis/modules/CSSRenderer/CSSStyleContainer.cpp
trunk/themis/modules/CSSRenderer/CSSStyleContainer.hpp
Modified: trunk/themis/makefile
===================================================================
--- trunk/themis/makefile 2011-04-11 20:42:39 UTC (rev 645)
+++ trunk/themis/makefile 2011-04-14 19:07:55 UTC (rev 646)
@@ -231,7 +231,8 @@
CSSRenderer/CSSRendererView.cpp \
CSSRenderer/CSSScrolledRendererView.cpp \
CSSRenderer/CSSView.cpp \
- CSSRenderer/TextBox.cpp
+ CSSRenderer/TextBox.cpp \
+ CSSRenderer/CSSStyleContainer.cpp
#make install directories as necessary
ifeq "$(shell if [ -d $(BASE_ADDON_INSTALL_DIR) ] ; then echo 1 ; else mkdir -p $(BASE_ADDON_INSTALL_DIR) ; echo 0 ; fi)" "0"
Modified: trunk/themis/modules/CSSParser/html4.css
===================================================================
--- trunk/themis/modules/CSSParser/html4.css 2011-04-11 20:42:39 UTC (rev 645)
+++ trunk/themis/modules/CSSParser/html4.css 2011-04-14 19:07:55 UTC (rev 646)
@@ -30,6 +30,9 @@
TABLE { display: table;
border-style: solid;
border-width: 1px; }
+TBODY { display: table-row-group;
+ border-style: solid;
+ border-width: 1px; }
TR { display: table-row;
border-style: solid;
border-width: 1px }
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-04-11 20:42:39 UTC (rev 645)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-04-14 19:07:55 UTC (rev 646)
@@ -46,6 +46,7 @@
// CSS Renderer headers
#include "CSSRendererView.hpp"
#include "CSSView.hpp"
+#include "CSSStyleContainer.hpp"
CSSRendererView :: CSSRendererView(BRect aFrame,
TDocumentPtr aDocument,
@@ -56,7 +57,8 @@
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) {
printf("Creating CSSRendererView\n");
- mStyleSheet = aStyleSheet;
+ mStyleSheets = new CSSStyleContainer();
+ mStyleSheets->addStyleSheet(aStyleSheet);
mDocument = aDocument;
BRect rect = Bounds();
if (mDocument->hasChildNodes()) {
@@ -65,9 +67,12 @@
defaultColor.green = 0;
defaultColor.blue = 0;
+
+ TNodePtr root = mDocument->getFirstChild();
+
mView = new CSSView(this,
- mDocument->getFirstChild(),
- mStyleSheet,
+ root,
+ mStyleSheets,
rect,
defaultColor);
printf("Doing layout\n");
@@ -85,6 +90,7 @@
printf("Destroying CSSRendererView\n");
delete mView;
+ delete mStyleSheets;
printf("Destroyed CSSRendererView\n");
}
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.hpp 2011-04-11 20:42:39 UTC (rev 645)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.hpp 2011-04-14 19:07:55 UTC (rev 646)
@@ -51,6 +51,7 @@
// Declarations used
class CSSView;
+class CSSStyleContainer;
class CSSRendererView : public BView {
@@ -59,7 +60,7 @@
TDOMString mTitle;
TDocumentPtr mDocument;
BRect mCSSViewSize;
- CSSStyleSheetPtr mStyleSheet;
+ CSSStyleContainer * mStyleSheets;
public:
CSSRendererView(BRect aFrame,
Added: trunk/themis/modules/CSSRenderer/CSSStyleContainer.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSStyleContainer.cpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/CSSStyleContainer.cpp 2011-04-14 19:07:55 UTC (rev 646)
@@ -0,0 +1,103 @@
+/*
+ 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: April 10, 2011
+*/
+
+/* CSSStyleContainer implementation
+ See CSSStyleContainer.hpp for more information
+
+*/
+
+// Standard C headers
+#include <stdio.h>
+
+// DOM Style headers
+#include "CSSRuleList.hpp"
+#include "CSSStyleRule.hpp"
+
+// CSS Renderer headers
+#include "CSSStyleContainer.hpp"
+
+CSSStyleContainer :: CSSStyleContainer() {
+}
+
+CSSStyleContainer :: ~CSSStyleContainer() {
+}
+
+void CSSStyleContainer :: addStyleSheet(const CSSStyleSheetPtr aStyleSheet) {
+
+ mStyleSheetList.push_back(aStyleSheet);
+
+}
+
+CSSStyleDeclarationPtr CSSStyleContainer :: getComputedStyle(const TElementPtr aElement) {
+
+ CSSStyleDeclarationPtr result;
+ unsigned int styleSheetLength = mStyleSheetList.size();
+
+ for (unsigned int j = 0; j < styleSheetLength; j++) {
+ CSSStyleSheetPtr styleSheet = mStyleSheetList[j];
+ CSSRuleListPtr rules = styleSheet->getCSSRules();
+ unsigned long length = rules->getLength();
+ bool found = false;
+ unsigned long i = 0;
+ while (i < length && !found) {
+ CSSRulePtr rule = rules->item(i);
+ switch (rule->getType()) {
+ case CSSRule::STYLE_RULE: {
+ CSSStyleRulePtr styleRule = shared_static_cast<CSSStyleRule>(rule);
+ // Trim trailing spaces before comparing.
+ string styleText = styleRule->getSelectorText();
+ size_t endPos = styleText.find_last_not_of(" ");
+ if (string::npos != endPos) {
+ styleText = styleText.substr(0, endPos + 1);
+ }
+ if (styleText == aElement->getTagName()) {
+ result = styleRule->getStyle();
+ found = true;
+ }
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ i++;
+ }
+ }
+
+/*
+ if (found) {
+ printf("Found a match for %s\n", aElement->getTagName().c_str());
+ }
+ else {
+ printf("Didn't find a match for %s\n", aElement->getTagName().c_str());
+ }
+*/
+ return result;
+}
Added: trunk/themis/modules/CSSRenderer/CSSStyleContainer.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSStyleContainer.hpp (rev 0)
+++ trunk/themis/modules/CSSRenderer/CSSStyleContainer.hpp 2011-04-14 19:07:55 UTC (rev 646)
@@ -0,0 +1,74 @@
+/*
+ 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: April 10, 2011
+*/
+
+/* CSSStyleContainer
+ Contains the CSS Stylesheets for a document
+ and provides a function to compute the style for an element of the document
+
+ Mark Hellegers (ma...@fi...)
+ 10-04-2011
+
+*/
+
+#ifndef CSSSTYLECONTAINER_HPP
+#define CSSSTYLECONTAINER_HPP
+
+// Standard C++ headers
+#include <vector>
+
+// DOM headers
+#include "TElement.h"
+
+// DOM Style headers
+#include "CSSStyleSheet.hpp"
+#include "CSSStyleDeclaration.hpp"
+
+// Namespaces used
+using std::vector;
+
+class CSSStyleContainer {
+
+ private:
+ vector<CSSStyleSheetPtr> mStyleSheetList;
+
+ public:
+ CSSStyleContainer();
+ ~CSSStyleContainer();
+ void addStyleSheet(const CSSStyleSheetPtr aStyleSheet);
+
+ /// A function to compute the style based on the stylesheets in the list.
+ /**
+ This functions computes the style for a given element by looking in the list
+ of stylesheets to see what applies to the element.
+ */
+ CSSStyleDeclarationPtr getComputedStyle(const TElementPtr aElement);
+};
+
+#endif
Modified: trunk/themis/modules/CSSRenderer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-04-11 20:42:39 UTC (rev 645)
+++ trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-04-14 19:07:55 UTC (rev 646)
@@ -61,13 +61,14 @@
// CSS Renderer headers
#include "CSSView.hpp"
#include "CSSRendererView.hpp"
+#include "CSSStyleContainer.hpp"
// Constants used
const char cSpace = ' ';
CSSView :: CSSView(CSSRendererView * aBaseView,
TNodePtr aNode,
- CSSStyleSheetPtr aStyleSheet,
+ CSSStyleContainer * aStyleSheets,
BRect aRect,
rgb_color aColor,
BFont * aFont)
@@ -75,7 +76,7 @@
mBaseView = aBaseView;
mNode = aNode;
- mStyleSheet = aStyleSheet;
+ mStyleSheets = aStyleSheets;
mRect = aRect;
mDisplay = true;
mBlock = true;
@@ -123,7 +124,7 @@
mClickable = true;
}
}
- CSSStyleDeclarationPtr style = GetComputedStyle(element);
+ CSSStyleDeclarationPtr style = mStyleSheets->getComputedStyle(element);
if (style.get()) {
CSSValuePtr value = style->getPropertyCSSValue("display");
if (value.get()) {
@@ -137,7 +138,7 @@
else if (valueString == "inline") {
mBlock = false;
}
- else if (valueString == "table") {
+ else if ((valueString == "table") || (valueString == "table-row-group")) {
mTable = true;
}
else if (valueString == "table-row") {
@@ -259,7 +260,7 @@
TNodePtr child = children->item(i);
CSSView * childView = new CSSView(aBaseView,
child,
- mStyleSheet,
+ mStyleSheets,
mRect,
mColor,
mFont);
@@ -730,46 +731,3 @@
}
}
-
-CSSStyleDeclarationPtr CSSView :: GetComputedStyle(TElementPtr aElement) {
-
- CSSStyleDeclarationPtr result;
- CSSRuleListPtr rules = mStyleSheet->getCSSRules();
- unsigned long length = rules->getLength();
- bool found = false;
- unsigned long i = 0;
- while (i < length && !found) {
- CSSRulePtr rule = rules->item(i);
- switch (rule->getType()) {
- case CSSRule::STYLE_RULE: {
- CSSStyleRulePtr styleRule = shared_static_cast<CSSStyleRule>(rule);
- // Trim trailing spaces before comparing.
- string styleText = styleRule->getSelectorText();
- size_t endPos = styleText.find_last_not_of(" ");
- if (string::npos != endPos) {
- styleText = styleText.substr(0, endPos + 1);
- }
- if (styleText == aElement->getTagName()) {
- result = styleRule->getStyle();
- found = true;
- }
- break;
- }
- default: {
- break;
- }
- }
- i++;
- }
-
-/*
- if (found) {
- printf("Found a match for %s\n", aElement->getTagName().c_str());
- }
- else {
- printf("Didn't find a match for %s\n", aElement->getTagName().c_str());
- }
-*/
- return result;
-
-}
Modified: trunk/themis/modules/CSSRenderer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-04-11 20:42:39 UTC (rev 645)
+++ trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-04-14 19:07:55 UTC (rev 646)
@@ -59,8 +59,9 @@
#include "TextBox.hpp"
// Declarations used
+class BFont;
class CSSRendererView;
-class BFont;
+class CSSStyleContainer;
// Namespaces used
using std::vector;
@@ -71,7 +72,7 @@
private:
vector<CSSView *> mChildren;
TNodePtr mNode;
- CSSStyleSheetPtr mStyleSheet;
+ CSSStyleContainer * mStyleSheets;
CSSRendererView * mBaseView;
vector<BRect> mRects;
BRect mRect;
@@ -103,7 +104,7 @@
public:
CSSView(CSSRendererView * aBaseView,
TNodePtr aNode,
- CSSStyleSheetPtr aStyleSheet,
+ CSSStyleContainer * aStyleSheets,
BRect aRect,
rgb_color aColor,
BFont * aFont = NULL);
@@ -119,7 +120,7 @@
void Layout(BRect aRect,
BPoint aStartingPoint);
void SplitText();
- CSSStyleDeclarationPtr GetComputedStyle(TElementPtr aElement);
+ CSSStyleDeclarationPtr GetComputedStyle(const TElementPtr aElement);
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|