|
From: Davy D. <dd...@ne...> - 2001-12-11 05:55:21
|
ohOHoh... It all makes sense now... I was looking at FXScrollBox's implementations of getContentWidth/Height methods and trying to figure out HOW-IN-THE-WORLD just returning 1 did any good.... I was like... is this thing just not useful yet? It didn't even cross my mind to override these.... Thanks... This is my initial reaction to reading your mail... I may have more questions... but this helps a lot.... jeroen wrote: > You're on the right track using FXScrollArea for this; it supports auto-scrolling, > i.e. when you get near the edge it starts to scroll (the speed is proportional > to the closeness to the edge). > > FXScrollArea is meant as a base class. At the very least, you should implement: > > virtual FXint getContentWidth(); > virtual FXint getContentHeight(); > > These two will measure the content size (in your case this may depend on the zoom > factor) and return that. Note, sometimes the content size must be obtained via > painful amount of computation (e.g. iterating over all wave samples and measuring > the peaks so as to determine vertical size). In that case it is customary to > keep member variables representing the computed size and return that, and only > recompute them when there is reason to believe content may have changed. > > long onPaint(FXObject*,FXSelector,void*); > > Of course, this should paint the waveform. Note that the content is offset by > pos_x and pos_y. These numbers are negative! > > long onLeftBtnPress(FXObject*,FXSelector,void*); > > Initiate selection operation. > > long onLeftBtnRelease(FXObject*,FXSelector,void*); > > End selection operation. > > long onRightBtnPress(FXObject*,FXSelector,void*); > > Start right-mouse scroll. > > long onRightBtnRelease(FXObject*,FXSelector,void*); > > End right mouse scroll; if we didn't move the mouse, then this may also popup > a context menu. > > long onMotion(FXObject*,FXSelector,void*); > > If we were right-mouse scrolling, call setPosition() to adjust the scroll position > accordingly. > > If we were selecting, call startAutoScroll(). This tests if we're close to the > edge. If startAutoScroll() returns TRUE then simply return. Otherwise, we're > not close to the edge and you should process the mouse coords to select the > appropriate audio samples. > > long onAutoScroll(FXObject*,FXSelector,void*); > > This handler is a kind-of mouse moved message issued while the mouse is more-or-less > standing still near an edge. The implementation should call FXScrollArea::onAutoScroll() > then perform similar code as in onMotion() to select audio samples. > > If you're not scrolling ALL of the content, you may have to implement > > virtual void moveContents(FXint x,FXint y); > > To BLIT the fragment that *is* scrolled. For example some tick marks on the > left or right will probably not be scrolled (see FXTable for an extreme case). > > In some cases, a widget needs to update some info when its resized; in this case > you will re-implement: > > virtual void layout(); > > The implementation should call FXScrollArea::layout() to place the scrollbars. > You can perform some extra stuff before or after. > > This may look a bit complex, but I think if you look at FXList and FXImageView, > you'll see that your code will be very similar to that. FXScrollArea does a > lot already (placing scrollbars, based on the viewport and content size, and > the autoscrolling timer management. > > === > > If you want to go all-out, you can extend this with clipboard, drag-and-drop, > selection support. This will allow cut-and-paste between FXWaveView and other > WAV aware applications (provided the mime-types match). > > Good luck. > > Jeroen > > _______________________________________________ > Foxgui-users mailing list > Fox...@li... > https://lists.sourceforge.net/lists/listinfo/foxgui-users |