diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/clickable.cpp karamba-0.17_RMC_01/src/clickable.cpp --- karamba-0.17/src/clickable.cpp 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/clickable.cpp 2003-04-30 10:31:42.000000000 -0500 @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "clickable.h" + + +Clickable::Clickable( int x, int y, int w, int h ) +{ + rect = QRect( x, y, w, h ); +} + +Clickable::~Clickable() +{} + +/* +void Clickable::setOnClick( QString oc ) +{ + onClick = oc; +} + +void Clickable::setOnMiddleClick( QString oc ) +{ + onMiddleClick = oc; +} +*/ + +QRect Clickable::getRectangle() +{ + return rect; +} diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/clickable.h karamba-0.17_RMC_01/src/clickable.h --- karamba-0.17/src/clickable.h 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/clickable.h 2003-04-30 10:27:08.000000000 -0500 @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef CLICKABLE_H +#define CLICKABLE_H + +#include +#include +#include + + +/** + * + * Ralph M. Churchill + **/ +class Clickable +{ +public: + Clickable(int x, int y, int w, int h ); + + virtual ~Clickable(); + + virtual void click( QMouseEvent* ) = 0; + /* + void setOnClick( QString ); + void setOnMiddleClick( QString ); + */ + + virtual QRect getRectangle(); + +protected: + QRect rect; + /* + QString onClick; + QString onMiddleClick; + */ +}; + +#endif diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/clickarea.cpp karamba-0.17_RMC_01/src/clickarea.cpp --- karamba-0.17/src/clickarea.cpp 2003-04-14 14:09:50.000000000 -0500 +++ karamba-0.17_RMC_01/src/clickarea.cpp 2003-04-23 15:16:38.000000000 -0500 @@ -11,10 +11,11 @@ ClickArea::ClickArea( int x, int y, int w, int h ) - : Meter( x, y, w, h ) + : Meter( x, y, w, h ), + Clickable(x, y, w, h ) { value = ""; - rect = QRect( x, y, w, h ); + // rect = QRect( x, y, w, h ); } ClickArea::~ClickArea() @@ -54,10 +55,12 @@ } +/* QRect ClickArea::getRectangle() { return rect; } +*/ void ClickArea::mUpdate( QPainter *p ) { diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/clickarea.h karamba-0.17_RMC_01/src/clickarea.h --- karamba-0.17/src/clickarea.h 2003-04-04 13:37:02.000000000 -0600 +++ karamba-0.17_RMC_01/src/clickarea.h 2003-04-23 15:15:04.000000000 -0500 @@ -12,12 +12,12 @@ #include #include - +#include "clickable.h" /** * * Hans Karlsson **/ -class ClickArea : public Meter +class ClickArea : public Meter, public Clickable { Q_OBJECT public: @@ -30,13 +30,13 @@ void setOnMiddleClick( QString ); - QRect getRectangle(); + // QRect getRectangle(); void mUpdate( QPainter* ); void setValue( int ); void setValue( QString ); - QRect rect; + // QRect rect; QString onClick; QString onMiddleClick; QString value; diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/clickmap.cpp karamba-0.17_RMC_01/src/clickmap.cpp --- karamba-0.17/src/clickmap.cpp 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/clickmap.cpp 2003-04-30 10:32:04.000000000 -0500 @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "clickmap.h" +#include +#include + +ClickMap::ClickMap( int x, int y, int w, int h ) + :Meter( x, y, w, h ), + Clickable( x, y, w, h ) +{ +/* + if( h != 0 || w != 0) + clip = 0; + else + clip = Qt::DontClip; +*/ + + if( h == 0 || w == 0) + { + width = -1; + height = -1; + } +} + +ClickMap::~ClickMap() +{ +} + +void ClickMap::setTextProps( TextField *t ) +{ + text = *t; +} + +void ClickMap::click( QMouseEvent *e ) +{ + + int index = e->y() / text.getLineHeight(); + qDebug( "You clicked item " + QString::number( index ) + ", " + + displays[index - 1] + " " + links[index - 1] ); + KRun::runCommand("konqueror " + links[index - 1]); +} + +void ClickMap::mUpdate( QPainter *p ) +{ + int i = 0; //text.getLineHeight(); + int row = 1; + + p->setFont(text.getFont()); + QStringList::Iterator it = displays.begin(); + while( it != displays.end() && (row <= height || height == -1 ) ) + { + p->setPen( text.getColor() ); + // p->drawText(x,y+i,width,height, Qt::AlignCenter | Qt::ExpandTabs, *it); + p->drawText(x, y+i, *it); + i += text.getLineHeight(); + it++; + row++; + } +} + +void ClickMap::setValue( QString v ) +{ + QRegExp rx("^http://", false ); + if ( rx.search( v ) == -1 ) + { + displays.append( v ); + } + else + { + links.append( v ); + } +} + +void ClickMap::setValue( int v ) +{ + if ( v == 0 ) + { + links.clear(); + displays.clear(); + } +} diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/clickmap.h karamba-0.17_RMC_01/src/clickmap.h --- karamba-0.17/src/clickmap.h 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/clickmap.h 2003-04-30 10:28:30.000000000 -0500 @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef CLICKMAP_H +#define CLICKMAP_H + +#include +#include "clickable.h" +#include "textfield.h" + + +/** + * + * Ralph M. Churchill + **/ +class ClickMap : public Meter, public Clickable +{ +Q_OBJECT +public: + ClickMap(int x, int y, int w, int h); + ~ClickMap(); + + void click( QMouseEvent* ); + void mUpdate( QPainter* ); + void setValue( QString ); + void setValue( int ); + void setTextProps( TextField * ); + +private: + TextField text; + + QStringList links; + QStringList displays; +}; + +#endif diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/karamba.cpp karamba-0.17_RMC_01/src/karamba.cpp --- karamba-0.17/src/karamba.cpp 2003-04-14 13:44:12.000000000 -0500 +++ karamba-0.17_RMC_01/src/karamba.cpp 2003-04-25 09:14:00.000000000 -0500 @@ -54,7 +54,7 @@ meterList->setAutoDelete( true ); sensorList = new QObjectList(); sensorList->setAutoDelete( true ); - clickList = new QObjectList(); + clickList = new list; client = kapp->dcopClient(); @@ -100,7 +100,7 @@ if( clickList != 0 ) { - clickList->clear(); + // clickList->clear(); delete clickList; } @@ -122,7 +122,7 @@ QString line; QString meter; int interval = 0; - TextLabel *defaultTextLabel = 0; + TextField *defaultTextField = 0; if ( file.open(IO_ReadOnly | IO_Translate) ) { @@ -261,7 +261,7 @@ tmp->setOnClick( getString( "ONCLICK", line ) ); setSensor( line, (Meter*) tmp ); - clickList->append( tmp ); + clickList->push_back( tmp ); if( getBoolean( "PREVIEW", line ) ) meterList->append( tmp ); } @@ -292,93 +292,114 @@ { int r,g,b; - delete defaultTextLabel; - defaultTextLabel = new TextLabel(x, y, w, h ); + delete defaultTextField; + defaultTextField = new TextField( ); get3Int( "COLOR", line, r, g, b ); - defaultTextLabel->setColor( r, g, b ); + defaultTextField->setColor( r, g, b ); get3Int( "BGCOLOR", line, r, g, b ); - defaultTextLabel->setBGColor( r, g, b ); + defaultTextField->setBGColor( r, g, b ); - defaultTextLabel->setFont( getString( "FONT", line ) ); - defaultTextLabel->setFontSize( getInt( "FONTSIZE", line ) ); - defaultTextLabel->setAlignment( getString( "ALIGN", line ) ); - defaultTextLabel->setFixedPitch( getBoolean( "FIXEDPITCH", line ) ); - defaultTextLabel->setShadow( getInt( "SHADOW", line ) ); + defaultTextField->setFont( getString( "FONT", line ) ); + defaultTextField->setFontSize( getInt( "FONTSIZE", line ) ); + defaultTextField->setAlignment( getString( "ALIGN", line ) ); + defaultTextField->setFixedPitch( getBoolean( "FIXEDPITCH", line ) ); + defaultTextField->setShadow( getInt( "SHADOW", line ) ); - qDebug(QString::number( getInt( "SHADOW", line ) )); - - qDebug("default font: " + defaultTextLabel->getFont()); + // qDebug("default font: " + defaultTextField->getFont()); } - if(meter == "TEXT") + // this should become "gather common text field attributes... " + if(meter == "TEXT" || meter == "CLICKMAP" ) // || meter == "anything that has a Text portion { int r,g,b; - TextLabel *tmp = new TextLabel(x, y, w, h ); + TextField* tmpText = new TextField(); bool paramFound = false; get3Int( "COLOR", line, r, g, b, paramFound ); - if ( paramFound || !defaultTextLabel ) - tmp->setColor ( r, g, b ); + if ( paramFound || !defaultTextField ) + tmpText->setColor ( r, g, b ); else - if ( defaultTextLabel ) + if ( defaultTextField ) { - defaultTextLabel->getColor().rgb ( &r, &g, &b ); - tmp->setColor( r, g, b ); + defaultTextField->getColor().rgb ( &r, &g, &b ); + tmpText->setColor( r, g, b ); } get3Int( "BGCOLOR", line, r, g, b, paramFound ); - if ( paramFound || !defaultTextLabel ) - tmp->setBGColor( r, g, b ); + if ( paramFound || !defaultTextField ) + tmpText->setBGColor( r, g, b ); else - if ( defaultTextLabel ) + if ( defaultTextField ) { - defaultTextLabel->getBGColor().rgb ( &r, &g, &b ); - tmp->setBGColor( r, g, b ); + defaultTextField->getBGColor().rgb ( &r, &g, &b ); + tmpText->setBGColor( r, g, b ); } QString dFont = getString("FONT", line, paramFound); - if( paramFound || !defaultTextLabel ) - tmp->setFont( dFont ); + if( paramFound || !defaultTextField ) + tmpText->setFont( dFont ); else - if( defaultTextLabel ) - tmp->setFont( defaultTextLabel->getFont() ); + if( defaultTextField ) + tmpText->setFont( defaultTextField->getFont() ); int dFontSize = getInt( "FONTSIZE", line, paramFound ); - if( paramFound || !defaultTextLabel ) - tmp->setFontSize( dFontSize ); + if( paramFound || !defaultTextField ) + tmpText->setFontSize( dFontSize ); else - if( defaultTextLabel ) - tmp->setFontSize( defaultTextLabel->getFontSize() ); + if( defaultTextField ) + tmpText->setFontSize( defaultTextField->getFontSize() ); QString dAlign = getString( "ALIGN", line, paramFound ); - if( paramFound || !defaultTextLabel ) - tmp->setAlignment( dAlign ); + if( paramFound || !defaultTextField ) + tmpText->setAlignment( dAlign ); else - if( defaultTextLabel ) - tmp->setAlignment( defaultTextLabel->getAlignment() ); + if( defaultTextField ) + tmpText->setAlignment( defaultTextField->getAlignment() ); bool dFp = getBoolean( "FIXEDPITCH", line, paramFound ); - if( paramFound || !defaultTextLabel ) - tmp->setFixedPitch( dFp ); + if( paramFound || !defaultTextField ) + tmpText->setFixedPitch( dFp ); else - if( defaultTextLabel ) - tmp->setFixedPitch( defaultTextLabel->getFixedPitch() ); + if( defaultTextField ) + tmpText->setFixedPitch( defaultTextField->getFixedPitch() ); int dShadow = getInt( "SHADOW", line, paramFound ); - if( paramFound || !defaultTextLabel ) - tmp->setShadow( dShadow ); + if( paramFound || !defaultTextField ) + tmpText->setShadow( dShadow ); else - if( defaultTextLabel ) - tmp->setShadow( defaultTextLabel->getShadow() ); + if( defaultTextField ) + tmpText->setShadow( defaultTextField->getShadow() ); - tmp->setValue( getString( "VALUE", line ) ); + // //////////////////////////////////////////////////// + // Now handle the specifics + if( meter == "TEXT" ) + { + + TextLabel *tmp = new TextLabel( x, y, w, h ); + tmp->setTextProps( tmpText ); + tmp->setValue( getString( "VALUE", line ) ); - setSensor( line, (Meter*)tmp ); - meterList->append ( tmp ); + setSensor( line, (Meter*)tmp ); + meterList->append ( tmp ); + } + + if(meter == "CLICKMAP") + { + if( !hasMouseTracking() ) + setMouseTracking(true); + ClickMap *tmp = new ClickMap( x, y, w, h ); + tmp->setTextProps( tmpText ); + + setSensor( line, (Meter*) tmp ); + // set all params + clickList->push_back( tmp ); + meterList->append( tmp ); + + } } @@ -766,6 +787,27 @@ sensor->addMeter(sp); } + if( sens == "RSS" ) + { + QString source = getString( "SOURCE", line ); + QString format = getString( "FORMAT", line ); + + sensor = sensorMap["RSS"+source]; + if (sensor == 0) + { + int interval = getInt( "INTERVAL", line ); + interval = ( interval == 0 )?60000:interval; + QString encoding = getString( "ENCODING", line ); + + sensor = ( sensorMap["RSS"+source] = + new RssSensor( source, interval, format, encoding ) ); + sensorList->append( sensor ); + } + SensorParams *sp = new SensorParams(meter); + sp->addParam("SOURCE",getString("SOURCE",line)); + sensor->addMeter(sp); + } + if (sensor != 0) { QTimer::singleShot( 0, sensor, SLOT(update()) ); @@ -776,11 +818,9 @@ void karamba::passClick( QMouseEvent *e ) { - QObjectListIt it( *clickList ); // iterate over meters - while ( it != 0 ) + for(list::iterator itr = clickList->begin(); itr != clickList->end(); ++itr) { - (( ClickArea* ) *it)->click( e ); - ++it; + ((Clickable*)(*itr))->click(e); } } @@ -841,11 +881,11 @@ else { // Change cursor over ClickArea - QObjectListIt it( *clickList ); // iterate over meters + list::iterator it = clickList->begin(); // iterate over meters bool insideArea = false; - while ( it != 0 && !insideArea ) + while ( it != clickList->end() && !insideArea ) { - insideArea = (((ClickArea*) *it)->getRectangle()).contains(e->pos()); + insideArea = (((Clickable*) *it)->getRectangle()).contains(e->pos()); ++it; } if(insideArea) diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/karamba.h karamba-0.17_RMC_01/src/karamba.h --- karamba-0.17/src/karamba.h 2003-04-14 11:22:00.000000000 -0500 +++ karamba-0.17_RMC_01/src/karamba.h 2003-04-30 10:24:16.000000000 -0500 @@ -64,6 +64,14 @@ #include "sensorsensor.h" #include "textfilesensor.h" +#include "clickmap.h" +#include "rsssensor.h" +#include "clickable.h" + +#include + +using std::list; + /** * @short Application Main Window * @author Hans Karlsson @@ -111,7 +119,7 @@ QMap sensorMap; QObjectList *meterList; QObjectList *sensorList; - QObjectList *clickList; + list *clickList; QTime lowerTimer; // use only the first occurance of KARAMBA in a config file diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/Makefile.am karamba-0.17_RMC_01/src/Makefile.am --- karamba-0.17/src/Makefile.am 2003-04-04 22:03:48.000000000 -0600 +++ karamba-0.17_RMC_01/src/Makefile.am 2003-04-23 15:17:14.000000000 -0500 @@ -20,7 +20,7 @@ bin_PROGRAMS = karamba # the application source, library search path, and link libraries -karamba_SOURCES = main.cpp karamba.cpp meter.h meter.cpp bar.h bar.cpp sensor.h sensor.cpp datesensor.h datesensor.cpp textlabel.h textlabel.cpp memsensor.h memsensor.cpp uptimesensor.h uptimesensor.cpp cpusensor.h cpusensor.cpp networksensor.h networksensor.cpp imagelabel.h imagelabel.cpp graph.h graph.cpp xmmssensor.h xmmssensor.cpp programsensor.h programsensor.cpp disksensor.h disksensor.cpp sensorparams.h sensorparams.cpp sensorsensor.h sensorsensor.cpp textfilesensor.h textfilesensor.cpp clickarea.h clickarea.cpp noatunsensor.h noatunsensor.cpp karambarootpixmap.h karambarootpixmap.cpp +karamba_SOURCES = main.cpp karamba.cpp meter.h meter.cpp bar.h bar.cpp sensor.h sensor.cpp datesensor.h datesensor.cpp textlabel.h textlabel.cpp memsensor.h memsensor.cpp uptimesensor.h uptimesensor.cpp cpusensor.h cpusensor.cpp networksensor.h networksensor.cpp imagelabel.h imagelabel.cpp graph.h graph.cpp xmmssensor.h xmmssensor.cpp programsensor.h programsensor.cpp disksensor.h disksensor.cpp sensorparams.h sensorparams.cpp sensorsensor.h sensorsensor.cpp textfilesensor.h textfilesensor.cpp clickarea.h clickarea.cpp noatunsensor.h noatunsensor.cpp karambarootpixmap.h karambarootpixmap.cpp rsssensor.h rsssensor.cpp clickmap.h clickmap.cpp textfield.h textfield.cpp clickable.h clickable.cpp karamba_LDFLAGS = $(KDE_RPATH) $(all_libraries) karamba_LDADD = -lkio $(LIB_KDEUI) $(XMMS_LIBS) diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/rsssensor.cpp karamba-0.17_RMC_01/src/rsssensor.cpp --- karamba-0.17/src/rsssensor.cpp 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/rsssensor.cpp 2003-04-30 10:32:28.000000000 -0500 @@ -0,0 +1,129 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "rsssensor.h" +#include +#include +#include +#include + +RssSensor::RssSensor( QString src, int interval, QString form, QString enc) + : Sensor(interval), + source(src), + format(form), + encoding(enc) + +{ + // Format: + // %t = title (DEFAULT) + // %d = desc + + if( encoding != "" ) + { + codec = QTextCodec::codecForName( encoding ); + if ( codec == 0) + codec = QTextCodec::codecForLocale(); + } + else + codec = QTextCodec::codecForLocale(); +} + +RssSensor::~RssSensor() +{ +} + +void RssSensor::update() +{ + QDomDocument doc; + QFile file; + QString tmpFile; + bool OK = false; + + if(KIO::NetAccess::download(KURL(source), tmpFile)) + { + file.setName(tmpFile); + if ( file.open(IO_ReadOnly | IO_Translate) ) + { + if ( doc.setContent( &file ) ) + { + OK = true; + } + else + { + qDebug("Error on building DOM"); + } + } + else + { + qDebug("Error opening file"); + } + } + else { + qDebug( "Error Downloading: " + source ); + } + + if ( OK ) + { + SensorParams *sp; + Meter *meter; + + QObjectListIt it( *objList ); + while (it != 0) + { + sp = (SensorParams*)(*it); + meter = sp->getMeter(); + + // this is a hack to force the + // clickmap to reset its data lists + meter->setValue(0); + + QDomElement docElem = doc.documentElement(); + QDomNode n = docElem.firstChild(); + if (!n.isNull()) + { + QDomNodeList links = docElem.elementsByTagName( "link" ); + QDomNodeList displays; + if ( format.contains( "%d", false ) > 0 ) + { + displays = docElem.elementsByTagName( "description" ); + } + else + { + displays = docElem.elementsByTagName( "title" ); + } + + QRegExp rx("^http://", false ); + for (uint i=0; i < displays.count(); ++i ) + { + QString dispTxt = displays.item( i ).toElement().text(); + QString linkTxt = links.item( i ).toElement().text(); + if( (rx.search(dispTxt) == -1) && (rx.search(linkTxt) != -1) ) + { + meter->setValue( dispTxt ); + meter->setValue( linkTxt ); + } + else + { + qDebug("Skipping"); + } + } + } + else + { + qDebug ("Document Node was null!!"); + } + + ++it; + } + } + // Cleanup + file.close(); + KIO::NetAccess::removeTempFile( tmpFile ); +} diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/rsssensor.h karamba-0.17_RMC_01/src/rsssensor.h --- karamba-0.17/src/rsssensor.h 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/rsssensor.h 2003-04-30 10:28:44.000000000 -0500 @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef RSSSENSOR_H +#define RSSSENSOR_H + +#include +#include +#include + +/** + * + * Ralph M. Churchill + **/ +class RssSensor : public Sensor +{ + Q_OBJECT +public: + RssSensor( QString source, int interval, QString format, QString encoding="" ); + + ~RssSensor(); + + void update(); +private: + QTextCodec *codec; + QString source; + QString format; + QString encoding; + +}; + +#endif // RSSSENSOR_H diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/textfield.cpp karamba-0.17_RMC_01/src/textfield.cpp --- karamba-0.17/src/textfield.cpp 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/textfield.cpp 2003-04-30 10:32:56.000000000 -0500 @@ -0,0 +1,157 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "textfield.h" +#include + +TextField::TextField( ) +{ +} + +TextField::~TextField() +{ +} + +TextField::TextField( const TextField& def ) +{ + setFontSize( def.getFontSize() ); + + int r, g, b; + def.getColor().rgb ( &r, &g, &b ); + setColor( r, g, b ); + def.getBGColor().rgb ( &r, &g, &b ); + setBGColor( r, g, b ); + + setFont( def.getFont() ); + setAlignment( def.getAlignment() ); + setFixedPitch( def.getFixedPitch() ); + setShadow( def.getShadow() ); +} + +TextField& TextField::operator=(const TextField& rhs) +{ + if( this == &rhs) + return *this; + + setFontSize( rhs.getFontSize() ); + + int r, g, b; + rhs.getColor().rgb ( &r, &g, &b ); + setColor( r, g, b ); + rhs.getBGColor().rgb ( &r, &g, &b ); + setBGColor( r, g, b ); + + setFont( rhs.getFont() ); + setAlignment( rhs.getAlignment() ); + setFixedPitch( rhs.getFixedPitch() ); + setShadow( rhs.getShadow() ); + + return *this; +} + +void TextField::setColor(int r, int g, int b) +{ + color.setRgb(r,g,b); +} + +QColor TextField::getColor() const +{ + return color; +} + +void TextField::setBGColor( int r, int g, int b ) +{ + bgColor.setRgb( r, g, b ); +} + +QColor TextField::getBGColor() const +{ + return bgColor; +} + + +void TextField::setFont(QString f) +{ + font.setFamily(f); + lineHeight = QFontMetrics(font).height(); +} + + +QString TextField::getFont() const +{ + return font.family(); +} + +void TextField::setFontSize(int size) +{ + font.setPointSize(size); + lineHeight = QFontMetrics(font).height(); +} + +int TextField::getFontSize() const +{ + return font.pointSize(); +} + +void TextField::setAlignment( QString align ) +{ + QString a = align.upper(); + if( a == "LEFT" || a == "" ) + alignment = Qt::AlignLeft; + if( a == "RIGHT" ) + alignment = Qt::AlignRight; + if( a == "CENTER" ) + alignment = Qt::AlignHCenter; +} + +void TextField::setAlignment( int af ) +{ + alignment = af; +} + +int TextField::getAlignment() const +{ + return alignment; +} + +QString TextField::getAlignmentAsString() const +{ + if( alignment == Qt::AlignHCenter ) + return "CENTER"; + else if( alignment == Qt::AlignRight ) + return "RIGHT"; + else + return "LEFT"; +} + +void TextField::setFixedPitch( bool fp) +{ + font.setFixedPitch( fp ); +} + +bool TextField::getFixedPitch() const +{ + return font.fixedPitch(); +} + +void TextField::setShadow ( int s ) +{ + shadow = s; +} + +int TextField::getShadow() const +{ + return shadow; +} + +int TextField::getLineHeight() const +{ + return lineHeight; +} diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/textfield.h karamba-0.17_RMC_01/src/textfield.h --- karamba-0.17/src/textfield.h 1969-12-31 18:00:00.000000000 -0600 +++ karamba-0.17_RMC_01/src/textfield.h 2003-04-30 10:29:12.000000000 -0500 @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * mrchucho@yahoo.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef TEXTFIELD_H +#define TEXTFIELD_H +#include +#include +#include + +/** + * + * Ralph M. Churchill + **/ +class TextField +{ +public: + TextField(); + TextField( const TextField& ); + ~TextField(); + + TextField& operator=(const TextField& ); + + void setFontSize( int ); + void setColor( int, int, int ); + void setBGColor( int, int, int); + void setFont( QString ); + void setAlignment( int ); + void setAlignment( QString ); + void setFixedPitch( bool ); + void setShadow( int ); + + int getFontSize() const; + QColor getColor() const; + QColor getBGColor() const; + QString getFont() const; + int getAlignment() const; + QString getAlignmentAsString() const; + bool getFixedPitch() const; + int getShadow() const; + int getLineHeight() const; + +protected: + int alignment; + QFont font; + QColor color; + QColor bgColor; + int shadow; + int lineHeight; + +} +; +#endif // TEXTFIELD_H diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/textlabel.cpp karamba-0.17_RMC_01/src/textlabel.cpp --- karamba-0.17/src/textlabel.cpp 2003-04-10 08:43:56.000000000 -0500 +++ karamba-0.17_RMC_01/src/textlabel.cpp 2003-04-25 09:11:42.000000000 -0500 @@ -9,10 +9,9 @@ ***************************************************************************/ #include "textlabel.h" -TextLabel::TextLabel( int x,int y,int w,int h) +TextLabel::TextLabel( int x,int y,int w,int h ) : Meter(x,y,w,h) { - lineHeight = QFontMetrics(font).height(); if( h != 0 || w != 0) clip = 0; else @@ -33,6 +32,11 @@ { } +void TextLabel::setTextProps( TextField* t ) +{ + text = *t; +} + void TextLabel::setValue( QString text) { value = QStringList::split('\n',text); @@ -43,118 +47,25 @@ value = QStringList( QString::number( v ) ); } -void TextLabel::setColor(int r, int g, int b) -{ - color.setRgb(r,g,b); -} - -QColor TextLabel::getColor() const -{ - return color; -} - -void TextLabel::setBGColor( int r, int g, int b ) -{ - bgColor.setRgb( r, g, b ); -} - -QColor TextLabel::getBGColor() const -{ - return bgColor; -} - - -void TextLabel::setFont(QString f) -{ - font.setFamily(f); - lineHeight = QFontMetrics(font).height(); -} - - -QString TextLabel::getFont() const -{ - return font.family(); -} - -void TextLabel::setFontSize(int size) -{ - font.setPointSize(size); - lineHeight = QFontMetrics(font).height(); -} - -int TextLabel::getFontSize() const -{ - return font.pointSize(); -} - -void TextLabel::setAlignment( QString align ) -{ - QString a = align.upper(); - if( a == "LEFT" || a == "" ) - alignment = Qt::AlignLeft; - if( a == "RIGHT" ) - alignment = Qt::AlignRight; - if( a == "CENTER" ) - alignment = Qt::AlignHCenter; -} - -QString TextLabel::getAlignment() const -{ - if( alignment == Qt::AlignHCenter ) - return "CENTER"; - else if( alignment == Qt::AlignRight ) - return "RIGHT"; - else - return "LEFT"; -} - -void TextLabel::setFixedPitch( bool fp) -{ - font.setFixedPitch( fp ); -} - -bool TextLabel::getFixedPitch() const -{ - return font.fixedPitch(); -} - -void TextLabel::setShadow ( int s ) -{ - shadow = s; -} - - -int TextLabel::getShadow() const -{ - return shadow; -} - - void TextLabel::mUpdate(QPainter *p) { int i = 0; //lineHeight; int row = 1; - p->setFont(font); + p->setFont(text.getFont()); QStringList::Iterator it = value.begin(); while( it != value.end() && (row <= height || height == -1 ) ) { - if( shadow != 0) + if( text.getShadow() != 0) { - p->setPen( bgColor ); - p->drawText(x+shadow, y+i+shadow, width, - height, alignment | clip | Qt::ExpandTabs,*it); + p->setPen( text.getBGColor() ); + p->drawText(x+text.getShadow(), y+i+text.getShadow(), width, + height, text.getAlignment() | clip | Qt::ExpandTabs,*it); } - p->setPen( color ); - p->drawText(x,y+i,width,height, alignment | clip | Qt::ExpandTabs,*it); - i += lineHeight; + p->setPen( text.getColor() ); + p->drawText(x,y+i,width,height, text.getAlignment() | clip | Qt::ExpandTabs,*it); + i += text.getLineHeight(); it++; row++; } } - - - - - - diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/src/textlabel.h karamba-0.17_RMC_01/src/textlabel.h --- karamba-0.17/src/textlabel.h 2003-04-10 08:43:56.000000000 -0500 +++ karamba-0.17_RMC_01/src/textlabel.h 2003-04-24 15:06:16.000000000 -0500 @@ -10,6 +10,7 @@ #ifndef TEXTLABEL_H #define TEXTLABEL_H #include "meter.h" +#include "textfield.h" #include #include #include @@ -17,6 +18,7 @@ #include #include #include + class TextLabel : public Meter { public: @@ -26,34 +28,13 @@ void setValue( QString ); void setValue( int ); - void setFontSize( int ); - void setColor( int, int, int ); - void setBGColor( int, int, int); - void setFont( QString ); - void setAlignment( QString ); - void setFixedPitch( bool ); - void setShadow( int ); void mUpdate( QPainter * ); - - int getFontSize() const; - QColor getColor() const; - QColor getBGColor() const; - QString getFont() const; - QString getAlignment() const; - bool getFixedPitch() const; - int getShadow() const; - + void setTextProps( TextField * ); private: - int alignment; int clip; QStringList value; - QFont font; - QColor color; - QColor bgColor; - int lineHeight; - int shadow; - + TextField text; } ; #endif // TEXTLABEL_H diff -rN -U 3 -x Makefile -x Makefile.in -x 'karamba.kde*' karamba-0.17/TODO karamba-0.17_RMC_01/TODO --- karamba-0.17/TODO 2003-01-18 17:47:30.000000000 -0600 +++ karamba-0.17_RMC_01/TODO 2003-04-30 10:20:32.000000000 -0500 @@ -1 +1,7 @@ +TODO +---- +* Add support for launching something besides konqueror (High) +* Add a built in IMAGE tag +* Add parameter for indicating how many headlines to display/download +* Handle translating "HTML" entities (e.g. &)