Logo Search packages:      
Sourcecode: qps version File versions  Download package


// infobar.h                        emacs, this is written in -*-c++-*-
// This program is free software. See the file COPYING for details.
// Author: Mattias Engdegård, 1997-1999

#ifndef INFOBAR_H
#define INFOBAR_H

#include <qpainter.h>
#include <qwidget.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qframe.h>
#include <qstring.h>
#include <qpixmap.h>
#include "misc.h"

class gwidget {
            gwidget(){x=0,y=0,width=0,height=0;       };
            gwidget(QWidget *p){parent=p;};
            virtual void draw(QPainter *p){printf("gwidget\n");};
            virtual void setPosition(int parent_width,int parent_height){};
            virtual char *info(){ return NULL; };
            void setParent(QWidget *p){parent=p;};
            void resize(int x_,int y_,int w,int h)
            { x=x_;y=y_;width=w;height=h;};
            bool  intersect(int cx,int cy)
                  cx = cx - x;
                  cy = cy - y;
                  if ( cx > 0 and cx < width)
                        if ( cy > 0 and cy < height)
                              return true;
                  return false;

            int  xpluswidth(){return x+width;};
            int x;
            int y;
            int width;
            int height;
            QRect rect;
            QWidget *parent;

class LoadGraph2 : public QFrame
    LoadGraph2(QWidget *parent, int history_size);

    void add_load_point();    // add current load as a data point
    void configure();         // respond to configuration change

    QPixmap *make_icon(int w, int h);

    void clicked();

    void drawContents(QPainter *p);
    //void paintEvent ( QPaintEvent * );
    void mousePressEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void leaveEvent ( QEvent * );

    void add_history_point(unsigned value);
    void make_graph(int w, int h);
    void make_graph2(int w, int h);
    void add_history_point2(float value);

    QPainter *p;
    List<gwidget*>  wlist;
    int hist_size;      // history buffer size
    int npoints;        // nr of history points currently remembered
    // history points are stored in fixed point, scaled by history_scale
    static const unsigned history_scale = 256;
    static const int time_dist = 60; // time between vertical lines (seconds)
    float *history;           // (circular) history buffer
    float peak;         // largest value in history
    int h_index;        // next history index to use
    bool dirty;               // history changed since pixmap was drawn
    QPixmap pm;

class Infobar : public QWidget
    Infobar(QWidget *parent);

    void refresh();
    void update_load();
    QPixmap *load_icon(int w, int h) { return load_graph->make_icon(w, h); }
    void configure();
    void configure_geometry();
    bool swaplim_exceeded();

public slots:
    void toggle_load();
    void toggle_cpu();
    void toggle_mem();
    void toggle_swap();

    void config_change();

    void resizeEvent(QResizeEvent *);

    LoadGraph2 *load_graph;

    bool is_vertical;

    void show_and_hide(bool, QWidget *, QWidget *);

#endif      // INFOBAR_H

Generated by  Doxygen 1.6.0   Back to index