summaryrefslogtreecommitdiffstats
path: root/khexedit/statusbarprogress.h
blob: fb7e36256a429a2279af039cd4abd9931a661168 (plain)
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
/*
 *   khexedit - Versatile hex editor
 *   Copyright (C) 1999  Espen Sand, espensa@online.no
 *   This file is based on the work by Martynas Kunigelis (KProgress)
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#ifndef _STATUSBAR_PROGRESS_H_
#define _STATUSBAR_PROGRESS_H_

#include <tqframe.h>
#include <tqrangecontrol.h>

class CStatusBarProgress : public TQFrame, public TQRangeControl
{
  Q_OBJECT


  public:
  /**
  * Possible values for orientation
  */
  enum Orientation { Horizontal, Vertical };

  /**
  * Possible values for bar style.
  *
  * Solid means one continuous progress bar, Blocked means a
  * progress bar made up of several blocks.
  */
  enum BarStyle { Solid, Blocked };

  /**
  * Construct a default progress bar. Orientation is horizontal.
  */
  CStatusBarProgress(TQWidget *parent=0, const char *name=0);

  /**
  * Construct a KProgress bar with an orientation.
  */
  CStatusBarProgress(Orientation, TQWidget *parent=0, const char *name=0);

  /**
  * Construct a KProgress bar with minimum, maximum and initial value.
  */
  CStatusBarProgress(int minValue, int maxValue, int value, Orientation,
		     TQWidget *parent=0, const char *name=0);

  /**
  * Destructor
  */
  ~CStatusBarProgress( void );

  /**
  * Set the progress bar style. Allowed values are Solid and Blocked.
  */
  void setBarStyle(BarStyle style);

  /**
  * Set the color of the progress bar.
  */
  void setBarColor(const TQColor &);

  /**
  * Set a pixmap to be shown in the progress bar.
  */
  void setBarPixmap(const TQPixmap &);

  /**
  * Set the orientation of the progress bar.
  * Allowed values are Horizonzal and Vertical.
  */
  void setOrientation(Orientation);

  /**
  * Retrieve the bar style.
  */
  BarStyle barStyle() const;

  /**
  * Retrieve the bar color.
  */
  const TQColor &barColor() const;

  /**
  * Retrieve the bar pixmap.
  */
  const TQPixmap *barPixmap() const;

  /**
  * Retrieve the orientation.
  */
  Orientation orientation() const;

  /**
  * Returns TRUE if progress text will be displayed, FALSE otherwise.
  */
  bool textEnabled() const;

  /**
   * Returns the recommended width for vertical progress bars or
   * the recommended height for vertical progress bars
   */
  virtual TQSize sizeHint() const;


  public slots:
    void setValue( int );
    void setValue( int, int);
    void advance( int );
    void setTextEnabled( bool state );
    void setText( const TQString &msg );

  signals:
    void percentageChanged(int);
    void pressed( void );

  protected:
    void valueChange();
    void rangeChange();
    void styleChange( GUIStyle );
    void paletteChange( const TQPalette & );
    void drawContents( TQPainter * );
    void mousePressEvent( TQMouseEvent *e );

  private:
    TQPixmap     *mBarPixmap;
    TQColor	mBarColor;
    TQColor	mBarTextColor;
    TQColor	mTextColor;
    TQRect       fr;
    BarStyle    mBarStyle;
    Orientation mOrientation;
    bool	mTextEnabled;
    TQString     mMsg;
    int         mCurPage;
    int         mMaxPage;

    void initialize( void );
    int recalcValue( int );
    void drawText( TQPainter * );
    void adjustStyle( void );
};


#endif