meter.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 "meter.h" 00011 00012 Meter::Meter(karamba* k, int ix, int iy, int iw, int ih): 00013 boundingBox(ix, iy, iw, ih), leftButtonAction(""), middleButtonAction(""), 00014 rightButtonAction(""), clickable(true), hidden(0), minValue(0), maxValue(0), 00015 color(0,0,0), m_karamba(k) 00016 { 00017 } 00018 00019 Meter::Meter(karamba* k): 00020 boundingBox(0, 0, 0, 0), leftButtonAction(""), middleButtonAction(""), 00021 rightButtonAction(""), clickable(true), hidden(0), minValue(0), maxValue(0), 00022 color(0,0,0), m_karamba(k) 00023 { 00024 } 00025 00026 Meter::~Meter() 00027 { 00028 } 00029 00030 bool Meter::click(TQMouseEvent*) 00031 { 00032 return false; 00033 } 00034 00035 void Meter::setSize(int ix, int iy, int iw, int ih) 00036 { 00037 boundingBox.setRect(ix, iy, iw, ih); 00038 recalculateValue(); 00039 } 00040 00041 void Meter::setThemePath( TQString path ) 00042 { 00043 themePath = path; 00044 } 00045 00046 int Meter::getX() 00047 { 00048 return boundingBox.x(); 00049 } 00050 00051 int Meter::getY() 00052 { 00053 return boundingBox.y(); 00054 } 00055 00056 void Meter::setX(int newx) 00057 { 00058 int temp = boundingBox.width(); 00059 boundingBox.setX(newx); 00060 boundingBox.setWidth(temp); 00061 } 00062 00063 void Meter::setY(int newy) 00064 { 00065 int temp = boundingBox.height(); 00066 boundingBox.setY(newy); 00067 boundingBox.setHeight(temp); 00068 } 00069 00070 int Meter::getWidth() 00071 { 00072 return boundingBox.width(); 00073 } 00074 int Meter::getHeight() 00075 { 00076 return boundingBox.height(); 00077 } 00078 00079 void Meter::setWidth(int width) 00080 { 00081 boundingBox.setWidth(width); 00082 recalculateValue(); 00083 } 00084 00085 void Meter::setHeight(int height) 00086 { 00087 boundingBox.setHeight(height); 00088 recalculateValue(); 00089 } 00090 00091 TQRect Meter::getBoundingBox() 00092 { 00093 return boundingBox; 00094 } 00095 00096 void Meter::setEnabled(bool e) 00097 { 00098 clickable = e; 00099 } 00100 00101 bool Meter::isEnabled() 00102 { 00103 return clickable; 00104 } 00105 00106 bool Meter::insideActiveArea(int x, int y) 00107 { 00108 return boundingBox.contains(x, y) && clickable; 00109 } 00110 00111 #include "meter.moc"