lib/COBase.h

Go to the documentation of this file.
00001 /*
00002  *  Qtstalker stock charter
00003  *
00004  *  Copyright (C) 2001-2007 Stefan S. Stratigakos
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019  *  USA.
00020  */
00021 
00022 #ifndef COBASE_HPP
00023 #define COBASE_HPP
00024 
00025 #include "Scaler.h"
00026 #include "BarData.h"
00027 #include "Setting.h"
00028 #include <qpixmap.h>
00029 #include <qobject.h>
00030 #include <qstring.h>
00031 #include <qpopupmenu.h>
00032 #include <qpoint.h>
00033 #include <qregion.h>
00034 #include <qcolor.h>
00035 #include <qptrlist.h>
00036 #include <qdatetime.h>
00037 
00038 #define HANDLE_WIDTH 6
00039 
00040 class COBase : public QObject
00041 {
00042   Q_OBJECT
00043   
00044   signals:
00045     void signalDraw ();
00046     void signalRefresh ();
00047     void message (QString);
00048     void signalObjectDeleted (QString);
00049     void signalSave (QString);
00050 
00051   public:
00052     enum Status
00053     {
00054       None,
00055       ClickWait,
00056       ClickWait2,
00057       Selected,
00058       Moving
00059     };
00060 
00061     COBase ();
00062     virtual ~COBase ();
00063     virtual void draw (QPixmap &, Scaler &, int, int, int);
00064     virtual void newObject (QString &, QString &);
00065     virtual void keyEvent (QKeyEvent *);
00066     virtual double getHigh ();
00067     virtual double getLow ();
00068     virtual void getSettings (Setting &);
00069     virtual void setSettings (Setting &);
00070     virtual void adjustForSplit (QDateTime &, double);
00071     
00072     void setData (BarData *);
00073     QString getHelpFile ();
00074     void setSaveFlag (bool);
00075     bool getSaveFlag ();
00076     void clearGrabHandles ();
00077     void setGrabHandle (QRegion *);
00078     void clearSelectionArea ();
00079     void setSelectionArea (QRegion *);
00080     QString getName ();
00081     void setDate (QDateTime &);
00082     void getDate (QDateTime &);
00083     void setColor (QColor);
00084     QColor getColor ();
00085     void setValue (double);
00086     double getValue ();
00087     void setStatus (Status);
00088     COBase::Status getStatus ();
00089     bool isSelected (QPoint point);
00090     bool isGrabSelected (QPoint point);
00091     COBase * getCO (Setting &);
00092     COBase * getCO (QString &);
00093 
00094   public slots:    
00095     virtual void prefDialog ();
00096     virtual COBase::Status pointerClick (QPoint &, QDateTime &, double);
00097     virtual void pointerMoving (QPixmap &, QPoint &, QDateTime &, double y);
00098 
00099     void removeObject ();
00100     void moveObject ();
00101     void addObject (Setting &);
00102     void showMenu ();
00103     
00104   protected:
00105     BarData *data;
00106     QPopupMenu *menu;
00107     QString indicator;
00108     QString name;
00109     QString helpFile;
00110     QString plot;
00111     Status status;
00112     QColor defaultColor;
00113     bool saveFlag;
00114     QPtrList<QRegion> grabHandles;
00115     QPtrList<QRegion> selectionArea;
00116     QColor color;
00117     QDateTime date;
00118     double value;
00119     QString type;
00120     QString dateFormat;
00121     QString dateLabel;
00122     QString valueLabel;
00123     QString colorLabel;
00124     QString plotLabel;
00125     QString nameLabel;
00126     QString typeLabel;
00127     QString identifier;
00128     QString identifierLabel;
00129     QString price;
00130     QString priceLabel;
00131 };
00132 
00133 #endif