/**************************************************************************************** * Name: pcmics2_gtk * * Purpose: House all of the GTK construction and callback functions * * Role: GUI * * Author: Luke Scharf (lscharf@vt.edu) * ***************************************************************************************/ /******************************* * Multiple Include Protection ******************************/ #ifndef _PCMICS2_GTK_H_ #define _PCMICS2_GTK_H_ /*********** * Include **********/ #include /************************ * Forward Declarations ***********************/ #ifndef __GDK_TYPES_H__ typedef struct _GtkObject GtkObject; typedef struct _GtkWidget GtkWidget; typedef struct _GtkWidget GtkWidget; typedef struct _GdkPixmap GdkPixmap; typedef struct _GtkAdjustment GtkAdjustment; typedef struct _GdkEventConfigure GdkEventConfigure; typedef struct _GdkEventExpose GdkEventExpose; typedef struct _GdkEvent GdkEvent; typedef struct _gpointer gpointer; typedef struct _GdkGC GdkGC; typedef int gint; #endif /**************************************************************************************** * Class gui * * Purpose: To encapsulte GUI construction and gtk functions ***************************************************************************************/ class gui { //-- Graphical Elements -- private: //-- Colors -- GdkGC* gc_black; GdkGC* gc_white; GdkGC* gc_red; GdkGC* gc_green; GdkGC* gc_blue; //-- Widgets -- GtkWidget* window; GtkWidget* vbox; GtkWidget* canvas; GdkPixmap* pixmap; GtkWidget* hbox_scrollers; GtkWidget* vbox_mic_dist; GtkWidget* mic_dist_label; GtkWidget* mic_dist; GtkObject* adj_mic_dist; GtkWidget* vbox_wave_len; GtkWidget* wave_len_label; GtkWidget* wave_len; GtkObject* adj_wave_len; GtkWidget* vbox_zoom; GtkWidget* zoom_label; GtkWidget* zoom; GtkObject* adj_zoom; GtkWidget* vbox_ray_scale; GtkWidget* ray_scale_label; GtkWidget* ray_scale; GtkObject* adj_ray_scale; GtkWidget* vbox_buttons; GtkWidget* hbox_buttons_scrollers; GtkWidget* default_button; GtkWidget* apply_button; GtkWidget* hbox_buttons_sound; GtkWidget* start_button; GtkWidget* snap_button; GtkWidget* stop_button; GtkWidget* quit_button; //-- Widget Handlers -- private: static gint configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); static gint expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); static gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); static void mic_dist_adj_hand(gpointer user_data); static void wave_len_adj_hand(gpointer user_data); static void ray_scale_adj_hand(gpointer user_data); static void zoom_adj_hand(gpointer user_data); static void start_button_hand(gpointer data); static void snapshot_button_hand(gpointer data); static void stop_button_hand(gpointer data); static void default_button_hand(gpointer data); static void destroy(GtkWidget *widget, gpointer data); //-- What will the widgets do? -- protected: virtual void set_wave_len(int wave_len)=0; virtual void set_mic_dist(int mic_dist)=0; virtual void set_amp_scale(int amp_scale)=0; virtual void set_zoom(int zoom)=0; virtual void snd_snapshot()=0; virtual void snd_calibrate(int& wave_len, int& mic_dist)=0; virtual void snd_save(char* filename)=0; //-- Thread Support -- private: pthread_t thread_continuous; pthread_mutex_t flag_running_mutex; bool flag_running; bool flag_continue; static void continuous(void* data); pthread_mutex_t snd_mutex; //-- Application Level -- public: gui(int* argc_p, char*** argv_p); virtual ~gui(); void go(); //-- Graphics Primitives -- public: inline void clear(); //Clear the drawing area inline void commit(); //Commit changes to real screen inline int height(); //Height of the drawing area inline int width(); //Width of the drawing area inline void text(int x, int y, char* text); //Put text inline void circle(int x, int y, int r); //Draw a circle inline void line(int x1, int y1, int x2, int y2, char c='B');//A normal line inline void ray(int x1, int y1, int r2, double t2); //A line beginning at x,y and //Extending for r units in //theta direction. //First pair: catesian //Second pair: polar }; /******************************* * Multiple Include Protection ******************************/ #endif