Main Page   Class Hierarchy   Alphabetical List   Compound List   File List  

clickarea.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #include "clickarea.h"
00011 
00012 
00013 ClickArea::ClickArea( int x, int y, int w, int h )
00014         : Meter( x, y, w, h )
00015 {
00016     value = "";
00017     rect = QRect( x, y, w, h );
00018 }
00019 
00020 ClickArea::~ClickArea()
00021 {}
00022 
00023 
00024 void ClickArea::click( QMouseEvent *e )
00025 {
00026     if( rect.contains( e->x(), e->y() ) )
00027     {
00028         //qDebug(QString::number(e->type()));
00029         //KShellProcess ksp;
00030         QString program;
00031         if( e->button() == Qt::LeftButton )
00032             program = onClick;
00033         program.replace( QRegExp("%v", false), value );
00034 
00035         if( program != "" )
00036         {
00037             //qDebug(program);
00038           KRun::runCommand(program);
00039           //  ksp << program;
00040           //  ksp.start(KProcIO::DontCare, KProcIO::NoCommunication);
00041         }
00042     }
00043 
00044 }
00045 
00046 void ClickArea::setOnClick( QString oc )
00047 {
00048     onClick = oc;
00049 }
00050 
00051 void ClickArea::setOnMiddleClick( QString oc )
00052 {
00053     onMiddleClick = oc;
00054 }
00055 
00056 
00057 QRect ClickArea::getRectangle()
00058 {
00059     return rect;
00060 }
00061 
00062 void ClickArea::mUpdate( QPainter *p )
00063 {
00064 
00065     p->drawRect( x, y, width, height );
00066 
00067 }
00068 
00069 
00070 void ClickArea::setValue( int v)
00071 {
00072 
00073     setValue( QString::number( v ) );
00074 
00075 }
00076 
00077 
00078 void ClickArea::setValue( QString v )
00079 {
00080     value = v;
00081 }
00082 
00083 
00084 
00085 

Generated on Tue Apr 29 19:56:57 2003 for karamba by doxygen1.2.18