1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
|
/***************************************************************************
rstatuspanel.cpp - description
-------------------
begin : Mon Sep 27 1999
copyright : (C) 1999 by Andreas Mustun
email : andrew@ribbonsoft.com
***************************************************************************/
/****************************************************************************
** rstatuspanel.cpp 1998/09/20 A. Mustun RibbonSoft
**
** Copyright (C) 1998 RibbonSoft. All rights reserved.
**
*****************************************************************************/
#include "rstatuspanel.h"
#include <qprogressbar.h>
#include <qslider.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
#include <qwindowdefs.h>
#include "rappwin.h"
#include "rcadwidget.h"
#include "rgraphic.h"
#include "rconfig.h"
#include "rlabel.h"
#include "rlayoutdef.h"
#include "rlog.h"
#include "rxpmstat.h"
// Constructor:
//
RStatusPanel::RStatusPanel(QWidget* _parent,
const char* _name,
WFlags _f)
:RWidget(_parent, _name, _f)
{
graphic=0;
setFrameStyle(Panel|Raised);
setLineWidth(1);
fSep1 = new QFrame(this, "sep1");
fSep1->setFrameStyle(VLine|Sunken);
fSep2 = new QFrame(this, "sep2");
fSep2->setFrameStyle(VLine|Sunken);
lStatus = new RLabel("", this);
lStatus->setAlignment(AlignLeft|AlignTop|WordBreak);
lMouse = new RLabel(this);
lMouse->setPixmap(QPixmap(mouse_xpm));
lMouse->setAlignment(AlignCenter|AlignVCenter);
lLeftButton = new RLabel("", this);
lLeftButton->setAlignment(AlignRight|AlignTop|WordBreak);
lRightButton = new RLabel("", this);
lRightButton->setAlignment(AlignLeft|AlignTop|WordBreak);
lFunction = new RLabel("", this);
lFunction->setAlignment(AlignLeft|AlignTop|WordBreak);
progressBar = new QProgressBar(100, this, "progressbar");
progressBar->hide();
reinit();
}
// Destructor:
//
RStatusPanel::~RStatusPanel()
{
}
// Re-Initialize:
//
void
RStatusPanel::reinit()
{
lStatus->setFont(QFont("helvetica", RCONFIG->getSettingInt("Application:FontSize2")));
lLeftButton->setFont(QFont("helvetica", RCONFIG->getSettingInt("Application:FontSize2")));
lRightButton->setFont(QFont("helvetica", RCONFIG->getSettingInt("Application:FontSize2")));
lFunction->setFont(QFont("helvetica", RCONFIG->getSettingInt("Application:FontSize2")));
}
// Resize event:
//
void
RStatusPanel::resizeEvent(QResizeEvent* _ev)
{
RWidget::resizeEvent(_ev);
resizeChildren();
}
// Resize the children:
//
void
RStatusPanel::resizeChildren()
{
// Width of mouse icon in the center:
//
int mouseLabelWidth = lMouse->pixmap()->width();
// Resize Seperators:
//
if(fSep1) fSep1->setGeometry(width()/3, 2, 2, height()-4);
if(fSep2) fSep2->setGeometry(width()/3*2, 2, 2, height()-4);
// Resize Labels:
//
// Status label left:
//
if(lStatus) {
lStatus->setGeometry(2, 2, width()/3-4, height()-4);
}
// Left button information (center/left):
//
if(lLeftButton) {
lLeftButton->setGeometry(width()/3+2, 2,
width()/6-4-mouseLabelWidth/2, height()-4);
}
// Mouse icon (center/center):
//
if(lMouse) {
lMouse->setGeometry(width()/2-mouseLabelWidth/2, 2,
mouseLabelWidth, height()-4);
lMouse->hide();
}
// Right button information (center/right):
//
if(lRightButton) {
lRightButton->setGeometry(width()/2+mouseLabelWidth/2+2, 2,
width()/6-4-mouseLabelWidth/2, height()-4);
}
// Function information (right):
//
if(lFunction) {
lFunction->setGeometry(width()/3*2+2, 2,
width()/3-4, height()-4);
}
// Progress BAr:
//
if(progressBar) {
progressBar->setGeometry(4, height()/2+4, width()/3-8, height()/2-8);
}
}
// Set the pointer to a graphic and update the layers:
//
void
RStatusPanel::setGraphic(RGraphic* _graphic)
{
graphic=_graphic;
}
// Set a new Status Text:
//
void
RStatusPanel::setStatus(const char* _stat)
{
if(lStatus) {
if(_stat) lStatus->setText(_stat);
else lStatus->clear();
}
}
// Set a new Left Mouse Button Status Text:
//
void
RStatusPanel::setLeftButtonStatus(const char* _lButStat)
{
if(lLeftButton) {
if(_lButStat) {
lLeftButton->setText(_lButStat);
if(lMouse) lMouse->show();
}
else {
lLeftButton->clear();
if(lMouse) lMouse->hide();
}
}
}
// Set a new Right Mouse Button Status Text:
//
void
RStatusPanel::setRightButtonStatus(const char* _rButStat)
{
if(lRightButton) {
if(_rButStat) lRightButton->setText(_rButStat);
else lRightButton->clear();
}
}
// Set a new Function Status Text:
//
void
RStatusPanel::setFunctionStatus(const char* _fStat)
{
if(lFunction) {
if(_fStat) lFunction->setText(_fStat);
else lFunction->clear();
}
}
// Set a new Action Status Text:
// (mouse buttons / function)
//
void
RStatusPanel::setActionStatus(const char* _lButStat, const char* _rButStat, const char* _fStat)
{
setLeftButtonStatus(_lButStat);
setRightButtonStatus(_rButStat);
setFunctionStatus(_fStat);
}
// Clear all status texts:
//
void
RStatusPanel::clear()
{
setStatus();
setActionStatus();
}
//
// Progress bar:
//
// Set progress steps (progress bar in status bar)
//
// _prg: number of progress steps
//
void
RStatusPanel::iniProgress(int _prgSteps, const char* _label)
{
if(progressBar) {
progressBar->show();
progressBar->setTotalSteps(_prgSteps);
progressBar->reset();
setStatus(_label);
}
}
// Set progress (progress bar in status bar)
//
// _prg: progress in percentage
//
void
RStatusPanel::setProgress(int _prg, int _every)
{
static int every=0;
if(progressBar) {
// Set progress:
//
++every;
if(every>=_every &&
_prg<progressBar->totalSteps()) {
progressBar->setProgress(_prg);
every=0;
}
}
}
// Del progress (progress bar in status bar)
//
void
RStatusPanel::delProgress()
{
if(progressBar) {
// Remove progress bar:
//
progressBar->reset();
progressBar->hide();
setStatus();
}
}
// EOF
|