2017-07-18 23:50:51 +02:00
|
|
|
// File: flistview.h
|
|
|
|
// Provides: class FListViewItem
|
|
|
|
// class FListView
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FListView ▏- - - -▕ FListViewItem ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef FLISTVIEW_H
|
|
|
|
#define FLISTVIEW_H
|
|
|
|
|
|
|
|
#include "fscrollbar.h"
|
|
|
|
#include "fstring.h"
|
|
|
|
#include "ftermbuffer.h"
|
|
|
|
#include "fwidget.h"
|
|
|
|
|
|
|
|
// class forward declaration
|
|
|
|
class FListView;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FListViewItem
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FListViewItem : public FObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FListViewItem (const FListViewItem&); // copy constructor
|
2017-07-28 22:18:42 +02:00
|
|
|
FListViewItem (FListViewItem*);
|
2017-07-18 23:50:51 +02:00
|
|
|
FListViewItem (FListView*);
|
|
|
|
FListViewItem ( const std::vector<FString>&
|
|
|
|
, FWidget::data_ptr = 0
|
|
|
|
, FListView* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~FListViewItem();
|
|
|
|
|
|
|
|
// Assignment operator (=)
|
|
|
|
FListViewItem& operator = (const FListViewItem&);
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
const char* getClassName() const;
|
|
|
|
uInt getCount() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Friend classes
|
|
|
|
friend class FListView;
|
|
|
|
|
|
|
|
// Data Member
|
|
|
|
std::vector<FString> column_line;
|
|
|
|
FWidget::data_ptr data_pointer;
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FListViewItem inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FListViewItem::getClassName() const
|
|
|
|
{ return "FListViewItem"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline uInt FListViewItem::getCount() const
|
|
|
|
{ return uInt(column_line.size()); }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FListView
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FListView : public FWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Typedef
|
|
|
|
typedef std::vector<FListViewItem*> listViewItems;
|
|
|
|
|
|
|
|
// Using-declaration
|
|
|
|
using FWidget::setGeometry;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
explicit FListView (FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~FListView();
|
|
|
|
|
|
|
|
// Accessors
|
2017-07-28 22:18:42 +02:00
|
|
|
const char* getClassName() const;
|
|
|
|
fc::text_alignment getColumnAlignment (int);
|
2017-07-18 23:50:51 +02:00
|
|
|
|
|
|
|
// Mutators
|
2017-07-28 22:18:42 +02:00
|
|
|
void setGeometry (int, int, int, int, bool = true);
|
|
|
|
void setColumnAlignment (int, fc::text_alignment);
|
2017-07-18 23:50:51 +02:00
|
|
|
|
|
|
|
// Methods
|
2017-07-28 22:18:42 +02:00
|
|
|
virtual int addColumn (const FString&, int = USE_MAX_SIZE);
|
|
|
|
void insert (FListViewItem*);
|
|
|
|
void insert ( const std::vector<FString>&
|
|
|
|
, data_ptr = 0
|
|
|
|
, FListView* = 0 );
|
|
|
|
void insert ( const std::vector<long>&
|
|
|
|
, data_ptr = 0
|
|
|
|
, FListView* = 0 );
|
2017-07-18 23:50:51 +02:00
|
|
|
|
|
|
|
// Event handlers
|
2017-07-28 22:18:42 +02:00
|
|
|
void onKeyPress (FKeyEvent*);
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
void onMouseDoubleClick (FMouseEvent*);
|
|
|
|
void onWheel (FWheelEvent*);
|
|
|
|
void onTimer (FTimerEvent*);
|
|
|
|
void onFocusIn (FFocusEvent*);
|
|
|
|
void onFocusOut (FFocusEvent*);
|
2017-07-18 23:50:51 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Methods
|
2017-07-28 22:18:42 +02:00
|
|
|
void adjustYOffset();
|
|
|
|
void adjustSize();
|
2017-07-18 23:50:51 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Typedef
|
|
|
|
struct Header
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Header()
|
|
|
|
: name()
|
|
|
|
, width (0)
|
|
|
|
, fixed_width (-1)
|
2017-07-28 22:18:42 +02:00
|
|
|
, alignment (fc::alignLeft)
|
2017-07-18 23:50:51 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
~Header()
|
|
|
|
{ }
|
2017-07-23 01:19:59 +02:00
|
|
|
|
2017-07-18 23:50:51 +02:00
|
|
|
FString name;
|
|
|
|
int width;
|
|
|
|
bool fixed_width;
|
2017-07-28 22:18:42 +02:00
|
|
|
fc::text_alignment alignment;
|
2017-07-18 23:50:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<Header> headerItems;
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
static const int USE_MAX_SIZE = -1;
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FListView (const FListView&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FListView& operator = (const FListView&);
|
|
|
|
|
|
|
|
// Methods
|
2017-07-28 22:18:42 +02:00
|
|
|
void init();
|
|
|
|
uInt getAlignOffset (fc::text_alignment, uInt, uInt);
|
|
|
|
void draw();
|
|
|
|
void drawColumnLabels();
|
|
|
|
void drawList();
|
|
|
|
void recalculateHorizontalBar (int);
|
|
|
|
void recalculateVerticalBar (int);
|
|
|
|
void processClick();
|
|
|
|
void processChanged();
|
2017-07-23 01:19:59 +02:00
|
|
|
listViewItems::iterator index2iterator (int);
|
|
|
|
|
|
|
|
// Callback methods
|
2017-07-28 22:18:42 +02:00
|
|
|
void cb_VBarChange (FWidget*, data_ptr);
|
|
|
|
void cb_HBarChange (FWidget*, data_ptr);
|
2017-07-18 23:50:51 +02:00
|
|
|
|
|
|
|
// Data Members
|
2017-07-28 22:18:42 +02:00
|
|
|
listViewItems data;
|
|
|
|
headerItems header;
|
|
|
|
FTermBuffer headerline;
|
|
|
|
FScrollbar* vbar;
|
|
|
|
FScrollbar* hbar;
|
|
|
|
fc::dragScroll drag_scroll;
|
|
|
|
bool scroll_timer;
|
|
|
|
int scroll_repeat;
|
|
|
|
int scroll_distance;
|
|
|
|
int current;
|
|
|
|
int xoffset;
|
|
|
|
int yoffset;
|
|
|
|
int nf_offset;
|
|
|
|
int max_line_width;
|
2017-07-18 23:50:51 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FListView inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FListView::getClassName() const
|
|
|
|
{ return "FListView"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FListView::listViewItems::iterator FListView::index2iterator (int index)
|
|
|
|
{
|
|
|
|
listViewItems::iterator iter = data.begin();
|
|
|
|
std::advance (iter, index);
|
|
|
|
return iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FLISTVIEW_H
|