#ifndef __widget_h__ // -*-c++-*- #define __widget_h__ #include "gui.h" // for event_t #include "mrpc.h" class widget { public: int frame_x; // location in subwindow. not using os windows for widgets (no overlap) int frame_y; int frame_width; // for those that need resolution or aspect info, but the main int frame_height; // idea is to not make too many dependencies on resolution void *receiver; // event delegate class widget *next; // chainable void realestate(void); // setup gl for drawing widget widget(); virtual ~widget(); virtual void draw(); virtual void event(event_t *e); virtual void resize(int x, int y, int width, int height); }; class container : public widget { // container class private: class widget *_first; // list of widgets public: int nb_widgets(void); class widget *index(int i); void update(void); virtual void draw(); virtual void event(event_t *e); virtual void resize(int x, int y, int width, int height); virtual void add(class widget *w); virtual void remove(class widget *w); virtual ~container(); container(); }; class pack : public container { // split into hpack/vpack later public: pack(); virtual ~pack(); virtual void event(event_t *e); virtual void resize(int x, int y, int width, int height); private: int drag; // if ( >= 0) : button pressed, index of receiver of motion events int orientation; // if 1 -> horizontal }; class wvvw : public widget { public: wvvw(void *receiver); // connects widget to receiver virtual ~wvvw(); virtual void draw(); virtual void event(event_t *e); virtual void resize(int x, int y, int width, int height); void set_array(float *f, int elements); void set_selection(int start, int endx); void set_view(int start, int endx); private: // associate on the other side of the fence void *receiver; // display state float *vec; // data array int elements; // size int view_start; // view dimensions int view_endx; int sel_start; // selection location int sel_endx; int point; // playback point float zoom; // zoom level float gain; // amplitude gain // motion state (press data) typedef void (wvvw::*motion_handler_t)(event_t *e); motion_handler_t motion_handler; float press_x; float press_y; int press_point; float press_zoom; // cache class mrpc *cache; float waveform_color[4]; float selection_color[4]; float needle_color[4]; int update_cache(void); void clear_cache(void); float unzoom(void); // update zoom from view_start, view_endx and width float zoom_to_spp(float zoom); // map zoom to samples per pixel void draw_peakline(float *f, int stride); void draw_waveform_lines(pair_t *peaks); void draw_waveform(void); void draw_selection(void); void draw_needle(void); double dpoint(double fraction); // return double fp sample coordinate from fraction void left_motion_handler(event_t *e); void middle_motion_handler(event_t *e); void right_motion_handler(event_t *e); void dummy_motion_handler(event_t *e); void set_point(int index); void send_app(event_t *e); void center(void); }; #endif