1 /* cdrdao - write audio CD-Rs in disc-at-once mode 2 * 3 * Copyright (C) 1998 Andreas Mueller <mueller@daneb.ping.de> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 #ifndef __SAMPLE_DISPLAY_H 21 #define __SAMPLE_DISPLAY_H 22 23 #include <gtkmm.h> 24 #include <gdkmm.h> 25 #include <pangomm.h> 26 #include <gtk/gtk.h> 27 28 #include "TrackManager.h" 29 30 class Toc; 31 class Sample; 32 class TocEdit; 33 34 class SampleDisplay : public Gtk::DrawingArea 35 { 36 public: 37 SampleDisplay(); 38 39 void setTocEdit(TocEdit *); 40 bool getSelection(unsigned long* start, unsigned long* end); 41 void setSelectedTrackMarker(int trackNr, int indexNr); 42 void setMarker(unsigned long sample); 43 void clearMarker(); 44 int getMarker(unsigned long *); 45 void setView(unsigned long start, unsigned long end); 46 void getView(unsigned long *start, unsigned long *end); 47 void setRegion(unsigned long start, unsigned long end); 48 int getRegion(unsigned long *start, unsigned long *end); 49 void clearRegion(); getAdjustment()50 Gtk::Adjustment *getAdjustment() { return adjustment_; } 51 void updateTrackMarks(); 52 void setCursor(int, unsigned long); 53 54 void updateToc(unsigned long, unsigned long); 55 56 sigc::signal1<void, unsigned long> markerSet; 57 sigc::signal1<void, unsigned long> cursorMoved; 58 sigc::signal2<void, unsigned long, unsigned long> selectionSet; 59 sigc::signal0<void> selectionCleared; 60 sigc::signal3<void, const Track *, int, int> trackMarkSelected; 61 sigc::signal4<void, const Track *, int, int, unsigned long> trackMarkMoved; 62 sigc::signal2<void, unsigned long, unsigned long> viewModified; 63 64 protected: 65 bool handleConfigureEvent(GdkEventConfigure *); 66 bool handleExposeEvent(GdkEventExpose *event); 67 bool handleMotionNotifyEvent(GdkEventMotion *event); 68 bool handleButtonPressEvent(GdkEventButton*); 69 bool handleButtonReleaseEvent(GdkEventButton*); 70 bool handleEnterEvent(GdkEventCrossing*); 71 bool handleLeaveEvent(GdkEventCrossing*); 72 73 private: 74 enum DragMode { DRAG_NONE, DRAG_SAMPLE_MARKER, DRAG_TRACK_MARKER }; 75 76 Gtk::Adjustment *adjustment_; 77 78 Glib::RefPtr<Gdk::Pixmap> pixmap_; 79 Glib::RefPtr<Gdk::Pixmap> trackMarkerPixmap_; 80 Glib::RefPtr<Gdk::Pixmap> indexMarkerPixmap_; 81 Glib::RefPtr<Gdk::Pixmap> trackMarkerSelectedPixmap_; 82 Glib::RefPtr<Gdk::Pixmap> indexMarkerSelectedPixmap_; 83 Glib::RefPtr<Gdk::Pixmap> trackExtendPixmap_; 84 Glib::RefPtr<Gdk::Pixmap> indexExtendPixmap_; 85 86 Glib::RefPtr<Gdk::GC> drawGc_; 87 Gdk::Color sampleColor_; 88 Gdk::Color middleLineColor_; 89 Gdk::Color cursorColor_; 90 Gdk::Color markerColor_; 91 Gdk::Color selectionBackgroundColor_; 92 93 gint width_; 94 gint height_; 95 gint timeLineHeight_; 96 gint timeLineY_; 97 gint timeTickWidth_; 98 gint timeTickSep_; 99 gint sampleStartX_; 100 gint sampleEndX_; 101 gint sampleWidthX_; 102 103 gint trackLineHeight_; 104 gint trackLineY_; 105 gint trackMarkerWidth_; 106 const TrackManager::Entry *pickedTrackMarker_; 107 108 gint chanSep_; 109 gint chanHeight_; 110 gint lcenter_; 111 gint rcenter_; 112 113 TrackManager *trackManager_; 114 115 TocEdit *tocEdit_; 116 unsigned long minSample_; 117 unsigned long maxSample_; 118 unsigned long resolution_; 119 120 bool cursorDrawn_; 121 gint cursorX_; 122 bool cursorControlExtern_; 123 124 bool markerSet_; 125 gint markerX_; 126 unsigned long markerSample_; 127 128 bool selectionSet_; 129 unsigned long selectionStartSample_; 130 unsigned long selectionEndSample_; 131 gint selectionStart_; 132 gint selectionEnd_; 133 134 bool regionSet_; 135 unsigned long regionStartSample_; 136 unsigned long regionEndSample_; 137 138 int selectedTrack_; 139 int selectedIndex_; 140 141 DragMode dragMode_; 142 gint dragStart_, dragEnd_; 143 gint dragStopMin_, dragStopMax_; 144 gint dragLastX_; 145 146 void scrollTo(); 147 void redraw(gint x, gint y, gint width, gint height, int); 148 void readSamples(long startBlock, long endBlock); 149 void updateSamples(); 150 void drawCursor(gint); 151 void undrawCursor(); 152 void getColor(const char *, Gdk::Color *); 153 unsigned long pixel2sample(gint x); 154 gint sample2pixel(unsigned long); 155 void drawMarker(); 156 void removeMarker(); 157 void drawTimeTick(gint x, gint y, unsigned long sample); 158 void drawTimeLine(); 159 void drawTrackMarker(int mode, gint x, int trackNr, int indexNr, 160 int selected, int extend); 161 void drawTrackLine(); 162 }; 163 164 #endif 165