|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TGRID_H
|
|
Toshihiro Shimizu |
890ddd |
#define TGRID_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolumnset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/tw.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/scrollbar.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TGenericGridAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
virtual ~TGenericGridAction() {}
|
|
Shinya Kitaoka |
120a6e |
virtual void sendCommand(int item) = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TGridAction : public TGenericGridAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*Method)(int item);
|
|
Shinya Kitaoka |
120a6e |
TGridAction(T *target, Method method) : m_target(target), m_method(method) {}
|
|
Shinya Kitaoka |
120a6e |
void sendCommand(int item) { (m_target->*m_method)(item); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
T *m_target;
|
|
Shinya Kitaoka |
120a6e |
Method m_method;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TGridCell {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGridCell() {}
|
|
Shinya Kitaoka |
120a6e |
TGridCell(const string &text) : m_text(text) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
string m_text;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TGridColumn : public TColumnHeader {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
enum Alignment { LeftAlignment, CenterAlignment, RightAlignment };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TGridColumn(const string &name = "", Alignment alignment = CenterAlignment);
|
|
Shinya Kitaoka |
120a6e |
~TGridColumn();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static TGridColumn *createEmpty();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getRowCount() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const TGridCell &getCell(int row) const;
|
|
Shinya Kitaoka |
120a6e |
void setCell(int row, const TGridCell &cell);
|
|
Shinya Kitaoka |
120a6e |
void setCell(int row, const string &text) { setCell(row, TGridCell(text)); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getCells(int row, int rowCount, TGridCell cells[]);
|
|
Shinya Kitaoka |
120a6e |
void setCells(int row, int rowCount, const TGridCell cells[]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void insertEmptyCells(int row, int rowCount = 1);
|
|
Shinya Kitaoka |
120a6e |
void removeCells(int row, int rowCount = 1);
|
|
Shinya Kitaoka |
120a6e |
void clearCells(int row, int rowCount = 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
string getName() const;
|
|
Shinya Kitaoka |
120a6e |
Alignment getAlignment() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
class Imp;
|
|
Shinya Kitaoka |
120a6e |
Imp *m_imp;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef TSmartPointerT<tgridcolumn> TGridColumnP;</tgridcolumn>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TGrid : public TWidget {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TGrid(TWidget *parent, string name = "grid");
|
|
Shinya Kitaoka |
120a6e |
~TGrid();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addColumn(const string &name, int width,
|
|
Shinya Kitaoka |
120a6e |
TGridColumn::Alignment align = TGridColumn::CenterAlignment);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addRow();
|
|
Shinya Kitaoka |
120a6e |
void removeRow(int row);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getColIndex(const string &colName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setCell(int row, int col, const string &text);
|
|
Shinya Kitaoka |
120a6e |
string getCell(int row, int col);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getColCount() const;
|
|
Shinya Kitaoka |
120a6e |
int getRowCount() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getSelectedRowCount() const;
|
|
Shinya Kitaoka |
120a6e |
int getSelectedRowIndex(
|
|
Shinya Kitaoka |
120a6e |
int i) const; // returns the index of the i-th item selected
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void select(int row, bool on);
|
|
Shinya Kitaoka |
120a6e |
void unselectAll();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isSelected(int row) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setSelAction(TGenericGridAction *action);
|
|
Shinya Kitaoka |
120a6e |
void setDblClickAction(TGenericGridAction *action);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void draw();
|
|
Shinya Kitaoka |
120a6e |
void configureNotify(const TDimension &d);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDown(const TMouseEvent &e);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDrag(const TMouseEvent &e);
|
|
Shinya Kitaoka |
120a6e |
void leftButtonUp(const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
void leftButtonDoubleClick(const TMouseEvent &e);
|
|
Shinya Kitaoka |
120a6e |
void keyDown(int key, unsigned long mod, const TPoint &);
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void scrollTo(int y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
class Data;
|
|
Shinya Kitaoka |
120a6e |
Data *m_data;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|