John Mitchell / lpc4088_displaymodule_GC500_2_5inch

Dependencies:   DMBasicGUI DMSupport

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ProgressBar.h Source File

ProgressBar.h

00001 #ifndef PROGRESSBAR_H
00002 #define PROGRESSBAR_H
00003 
00004 #include "GuiLib.h"
00005 #include "GuiDisplay.h"
00006 
00007 
00008 typedef enum { vertical, horizontal } progressBarOrientation;
00009 
00010 class ProgressBar
00011 {
00012 public:
00013     ProgressBar();
00014     ProgressBar(int x, int y, int w, int h, progressBarOrientation o, double newCalibratedRange, GuiConst_INTCOLOR brColor, GuiConst_INTCOLOR bkColor, GuiConst_INTCOLOR brdColor);
00015     
00016     progressBarOrientation GetOrientation(void) { return orientation; }
00017     
00018     void UpdateCalibratedPosition(double newCalibratedPosition, bool forceFullDisplay);
00019     
00020     double GetCalibratedPosition(void) { return (barPosition * calibrationFactor); }
00021     
00022     void SetCalibratedRange(double newCalibratedRange);
00023     double GetCalibratedRange(void) { return calibratedRange; }
00024     
00025     void DisplayBarComplete(bool forceFullDisplay);
00026 
00027 private:
00028     int barX, barY; // This is the top left corner, in both orientations.
00029     int barW, barH; // The width and height.
00030     // The above apply to the (fixed) box containing the slider bar, not to the bar itself.
00031     
00032     GuiConst_INTCOLOR barColor;
00033     GuiConst_INTCOLOR backColor;
00034     GuiConst_INTCOLOR borderColor;
00035     
00036     progressBarOrientation orientation;
00037     
00038     int barPosition; // The RH end of the bar (horizontal), or top of the bar (vertical) - in display units (i.e. pixels)
00039                      // ** relative to the bottom (vertical) or left hand end (horizontal) of the bar as zero **
00040     int previousBarPositionDisplayed; // -1 if we have not yet displayed the bar
00041     
00042     double calibratedRange;
00043     double calibrationFactor; // calibratedPosition = (barPosition * calibrationFactor),
00044                               // which is equivalent to: calibrationFactor = (calibratedRange / barW)
00045     
00046     void DisplayNewPosition(void);
00047     
00048     void DisplayFullBar(void);
00049     void DisplayBarChangeOnly(void);
00050     
00051     // If this is false, we do not fill the background (at all) when we (re)draw the bar.
00052     // This is an advantage when we are using a bitmap as the background - 
00053     // we do not have to redraw parts of the bitmap.
00054     // *** This is OK as long as the bar always increases in length (which it should do,       ***
00055     // *** for a progress bar, unless the process we are representing somehow goes backwards). ***
00056     bool fillBackground;
00057 };
00058 
00059 #endif // PROGRESSBAR_H