gui.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include <wx/app.h>
  2. #include <wx/event.h>
  3. #include <wx/window.h>
  4. #include <wx/panel.h>
  5. #include <wx/frame.h>
  6. #include <wx/stattext.h>
  7. #include <wx/bitmap.h>
  8. #define MAXIMAGES 400
  9. #define MAXVIEWS 4
  10. struct gui_data
  11. {
  12. int step, speed, stop, direction;
  13. int rewind, prevframe, curframe, nframes;
  14. int loop, swing, shownames;
  15. };
  16. class MyCanvas: public wxPanel
  17. {
  18. public:
  19. MyCanvas(wxWindow *parent, wxWindowID id, const wxSize& size);
  20. void erase(wxEraseEvent &ev);
  21. void draw_image(wxBitmap *bmp);
  22. void draw_text(int style, int x, int y, const char *str);
  23. DECLARE_EVENT_TABLE()
  24. };
  25. class MyFrame: public wxFrame
  26. {
  27. public:
  28. MyFrame(const wxString& title, int ncols, int nrows, struct gui_data *cd);
  29. void change_label(const char *label);
  30. MyCanvas *canvas;
  31. private:
  32. struct gui_data *cd;
  33. wxStaticText *flabel;
  34. void make_buttons(wxSizer *);
  35. void rewind_callback(wxCommandEvent &);
  36. void rplay_callback(wxCommandEvent &);
  37. void stepb_callback(wxCommandEvent &);
  38. void stop_callback(wxCommandEvent &);
  39. void stepf_callback(wxCommandEvent &);
  40. void play_callback(wxCommandEvent &);
  41. void loop_callback(wxCommandEvent &);
  42. void swing_callback(wxCommandEvent &);
  43. void exit_callback(wxCommandEvent &);
  44. void names_callback(wxCommandEvent &);
  45. void slower_callback(wxCommandEvent &);
  46. void faster_callback(wxCommandEvent &);
  47. DECLARE_EVENT_TABLE()
  48. };
  49. class MyApp: public wxApp
  50. {
  51. private:
  52. wxBitmap *pic_array[MAXIMAGES];
  53. public:
  54. virtual bool OnInit();
  55. private:
  56. MyFrame *mainwin;
  57. struct gui_data gd;
  58. int load_files(void);
  59. void do_run(wxIdleEvent &);
  60. DECLARE_EVENT_TABLE()
  61. };