2017-01-02 08:07:46 +01:00
|
|
|
// 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;
|
2017-01-07 22:09:09 +01:00
|
|
|
using FWidget::setPrintPos;
|
2017-01-02 08:07:46 +01:00
|
|
|
using FWidget::setPos;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
explicit FScrollView (FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FScrollView();
|
|
|
|
|
|
|
|
// Accessors
|
2017-01-03 05:19:44 +01:00
|
|
|
const char* getClassName() const;
|
2017-01-07 22:09:09 +01:00
|
|
|
int getScrollWidth() const;
|
|
|
|
int getScrollHeight() const;
|
|
|
|
const FPoint getScrollPos() const;
|
|
|
|
int getScrollX() const;
|
|
|
|
int getScrollY() const;
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// Mutator
|
2017-01-03 05:19:44 +01:00
|
|
|
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);
|
2017-01-07 22:09:09 +01:00
|
|
|
void setPrintPos (register int, register int);
|
2017-01-03 05:19:44 +01:00
|
|
|
void setHorizontalScrollBarMode (fc::scrollBarMode);
|
|
|
|
void setVerticalScrollBarMode (fc::scrollBarMode);
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// Method
|
2017-01-03 05:19:44 +01:00
|
|
|
virtual void clearArea (int = ' ');
|
2017-01-07 22:09:09 +01:00
|
|
|
void scrollToX (int);
|
|
|
|
void scrollToY (int);
|
|
|
|
void scrollTo (FPoint);
|
|
|
|
void scrollTo (int, int);
|
|
|
|
void scrollBy (int, int);
|
2017-01-03 05:19:44 +01:00
|
|
|
virtual void draw();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// Event handlers
|
2017-01-03 19:02:04 +01:00
|
|
|
void onKeyPress (FKeyEvent*);
|
2017-01-03 05:19:44 +01:00
|
|
|
void onWheel (FWheelEvent*);
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Using-declaration
|
|
|
|
using FVTerm::clearArea;
|
|
|
|
|
|
|
|
// Accessor
|
2017-01-03 05:19:44 +01:00
|
|
|
term_area* getPrintArea();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// Method
|
2017-01-03 05:19:44 +01:00
|
|
|
void adjustSize();
|
|
|
|
void copy2area();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
FScrollView (const FScrollView&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FScrollView& operator = (const FScrollView&);
|
|
|
|
|
|
|
|
// Methods
|
2017-01-03 05:19:44 +01:00
|
|
|
void init();
|
|
|
|
void calculateScrollbarPos();
|
|
|
|
void setHorizontalScrollBarVisibility();
|
|
|
|
void setVerticalScrollBarVisibility();
|
2017-01-07 22:09:09 +01:00
|
|
|
void redrawHBar();
|
|
|
|
void redrawVBar();
|
|
|
|
void drawHBar();
|
|
|
|
void drawVBar();
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// Callback methods
|
2017-01-03 05:19:44 +01:00
|
|
|
void cb_VBarChange (FWidget*, void*);
|
|
|
|
void cb_HBarChange (FWidget*, void*);
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
// Data Members
|
2017-01-03 05:19:44 +01:00
|
|
|
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;
|
2017-01-02 08:07:46 +01:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FScrollView inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FScrollView::getClassName() const
|
|
|
|
{ return "FScrollView"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-01-07 22:09:09 +01:00
|
|
|
inline int FScrollView::getScrollWidth() const
|
2017-01-02 08:07:46 +01:00
|
|
|
{ return scroll_size.getWidth(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-01-07 22:09:09 +01:00
|
|
|
inline int FScrollView::getScrollHeight() const
|
2017-01-02 08:07:46 +01:00
|
|
|
{ return scroll_size.getHeight(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-01-07 22:09:09 +01:00
|
|
|
inline const FPoint FScrollView::getScrollPos() const
|
|
|
|
{ return scroll_offset; }
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-01-07 22:09:09 +01:00
|
|
|
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()); }
|
|
|
|
|
2017-01-02 08:07:46 +01:00
|
|
|
|
|
|
|
#endif // _FSCROLLVIEW_H
|