finalcut/src/fscrollview.h

170 lines
5.1 KiB
C
Raw Normal View History

// File: fscrollview.h
// Provides: class FScrollView
//
// Inheritance diagram
// ═══════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │
// └─────┬─────┘
// │
// ▕▔▔▔▔▔▔▔▔▏
// ▕ FVTerm ▏
// ▕▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FWidget ▏
// ▕▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FScrollView ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏
#ifndef _FSCROLLVIEW_H
#define _FSCROLLVIEW_H
#include "fscrollbar.h"
#include "fwidget.h"
//----------------------------------------------------------------------
// class FScrollView
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FScrollView : public FWidget
{
public:
// Using-declaration
using FWidget::setGeometry;
using FWidget::setPrintPos;
using FWidget::setPos;
// Constructor
explicit FScrollView (FWidget* = 0);
// Destructor
virtual ~FScrollView();
// Accessors
const char* getClassName() const;
int getScrollWidth() const;
int getScrollHeight() const;
const FPoint getScrollPos() const;
int getScrollX() const;
int getScrollY() const;
// Mutator
void setScrollWidth (int);
void setScrollHeight (int);
void setScrollSize (int, int);
virtual void setX (int, bool = true);
virtual void setY (int, bool = true);
virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true);
void setGeometry (int, int, int, int, bool = true);
void setPrintPos (register int, register int);
void setHorizontalScrollBarMode (fc::scrollBarMode);
void setVerticalScrollBarMode (fc::scrollBarMode);
// Method
virtual void clearArea (int = ' ');
void scrollToX (int);
void scrollToY (int);
void scrollTo (FPoint);
void scrollTo (int, int);
void scrollBy (int, int);
virtual void draw();
// Event handlers
2017-01-03 19:02:04 +01:00
void onKeyPress (FKeyEvent*);
void onWheel (FWheelEvent*);
protected:
// Using-declaration
using FVTerm::clearArea;
// Accessor
term_area* getPrintArea();
// Method
void adjustSize();
void copy2area();
private:
// Disable copy constructor
FScrollView (const FScrollView&);
// Disable assignment operator (=)
FScrollView& operator = (const FScrollView&);
// Methods
void init();
void calculateScrollbarPos();
void setHorizontalScrollBarVisibility();
void setVerticalScrollBarVisibility();
void redrawHBar();
void redrawVBar();
void drawHBar();
void drawVBar();
// Callback methods
void cb_VBarChange (FWidget*, void*);
void cb_HBarChange (FWidget*, void*);
// Data Members
FRect scroll_size;
FPoint scroll_offset;
term_area* viewport; // virtual scroll content
FScrollbar* vbar;
FScrollbar* hbar;
int nf_offset;
bool use_own_print_area;
fc::scrollBarMode vMode; // fc:Auto, fc::Hidden or fc::Scroll
fc::scrollBarMode hMode;
};
#pragma pack(pop)
// FScrollView inline functions
//----------------------------------------------------------------------
inline const char* FScrollView::getClassName() const
{ return "FScrollView"; }
//----------------------------------------------------------------------
inline int FScrollView::getScrollWidth() const
{ return scroll_size.getWidth(); }
//----------------------------------------------------------------------
inline int FScrollView::getScrollHeight() const
{ return scroll_size.getHeight(); }
//----------------------------------------------------------------------
inline const FPoint FScrollView::getScrollPos() const
{ return scroll_offset; }
//----------------------------------------------------------------------
inline int FScrollView::getScrollX() const
{ return scroll_offset.getX(); }
//----------------------------------------------------------------------
inline int FScrollView::getScrollY() const
{ return scroll_offset.getY(); }
//----------------------------------------------------------------------
inline void FScrollView::scrollTo (FPoint pos)
{ scrollTo(pos.getX(), pos.getY()); }
#endif // _FSCROLLVIEW_H