00001 #ifndef BCPOT_H
00002 #define BCPOT_H
00003
00004 #include "bcpixmap.h"
00005 #include "vframe.inc"
00006 #include "bcsubwindow.h"
00007
00008 #define POT_UP 0
00009 #define POT_HIGH 1
00010 #define POT_DN 2
00011 #define POT_STATES 3
00012
00013 class BC_FPot;
00014 class BC_IPot;
00015 class BC_QPot;
00016 class BC_PercentagePot;
00017
00018 class BC_Pot : public BC_SubWindow
00019 {
00020 public:
00021 BC_Pot(int x, int y, VFrame **data);
00022 virtual ~BC_Pot();
00023
00024 friend class BC_FPot;
00025 friend class BC_IPot;
00026 friend class BC_QPot;
00027 friend class BC_PercentagePot;
00028
00029
00030 static int calculate_h();
00031 int initialize();
00032 virtual float get_percentage() { return 0; };
00033 virtual int percentage_to_value(float percentage) { return 0; };
00034 virtual int handle_event() { return 0; };
00035 virtual char* get_caption() { return ""; };
00036 virtual int increase_value() { return 0; };
00037 virtual int decrease_value() { return 0; };
00038 void set_use_caption(int value);
00039
00040 int reposition_window(int x, int y);
00041 int repeat_event(int64_t repeat_id);
00042 int cursor_enter_event();
00043 int cursor_leave_event();
00044 int button_press_event();
00045 virtual int button_release_event();
00046 int cursor_motion_event();
00047 int keypress_event();
00048
00049 private:
00050 int set_data(VFrame **data);
00051 int draw();
00052 float percentage_to_angle(float percentage);
00053 float angle_to_percentage(float angle);
00054 int angle_to_coords(int &x1, int &y1, int &x2, int &y2, float angle);
00055 float coords_to_angle(int x2, int y2);
00056 void show_value_tooltip();
00057
00058 VFrame **data;
00059 BC_Pixmap *images[POT_STATES];
00060 char caption[BCTEXTLEN], temp_tooltip_text[BCTEXTLEN];
00061 int status;
00062 int64_t keypress_tooltip_timer;
00063 float angle_offset;
00064 float start_cursor_angle;
00065 float start_needle_angle;
00066 float prev_angle, angle_correction;
00067 int use_caption;
00068 };
00069
00070 class BC_FPot : public BC_Pot
00071 {
00072 public:
00073 BC_FPot(int x,
00074 int y,
00075 float value,
00076 float minvalue,
00077 float maxvalue,
00078 VFrame **data = 0);
00079 ~BC_FPot();
00080
00081 char* get_caption();
00082 int increase_value();
00083 int decrease_value();
00084 float get_percentage();
00085 float get_value();
00086 int percentage_to_value(float percentage);
00087 void update(float value);
00088 void update(float value, float minvalue, float maxvalue);
00089 void set_precision(float value);
00090
00091 private:
00092 float value, minvalue, maxvalue;
00093 float precision;
00094 };
00095
00096 class BC_IPot : public BC_Pot
00097 {
00098 public:
00099 BC_IPot(int x,
00100 int y,
00101 int64_t value,
00102 int64_t minvalue,
00103 int64_t maxvalue,
00104 VFrame **data = 0);
00105 ~BC_IPot();
00106
00107 char* get_caption();
00108 int increase_value();
00109 int decrease_value();
00110 float get_percentage();
00111 int percentage_to_value(float percentage);
00112 int64_t get_value();
00113 void update(int64_t value);
00114 void update(int64_t value, int64_t minvalue, int64_t maxvalue);
00115
00116 private:
00117 int64_t value, minvalue, maxvalue;
00118 };
00119
00120 class BC_QPot : public BC_Pot
00121 {
00122 public:
00123 BC_QPot(int x,
00124 int y,
00125 int64_t value,
00126 VFrame **data = 0);
00127 ~BC_QPot();
00128
00129 char* get_caption();
00130 int increase_value();
00131 int decrease_value();
00132 float get_percentage();
00133 int percentage_to_value(float percentage);
00134
00135 int64_t get_value();
00136
00137 void update(int64_t value);
00138
00139 private:
00140
00141 int64_t value, minvalue, maxvalue;
00142 };
00143
00144 class BC_PercentagePot : public BC_Pot
00145 {
00146 public:
00147 BC_PercentagePot(int x,
00148 int y,
00149 float value,
00150 float minvalue,
00151 float maxvalue,
00152 VFrame **data = 0);
00153 ~BC_PercentagePot();
00154
00155 char* get_caption();
00156 int increase_value();
00157 int decrease_value();
00158 float get_percentage();
00159 float get_value();
00160 int percentage_to_value(float percentage);
00161 void update(float value);
00162
00163 private:
00164 float value, minvalue, maxvalue;
00165 };
00166
00167 #endif