|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TEXTLIST_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TEXTLIST_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/tw.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/scrollview.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TWIN_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4251)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TGenericTextListAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
virtual ~TGenericTextListAction() {}
|
|
Shinya Kitaoka |
120a6e |
virtual void sendCommand(int itemIndex) = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TTextListAction : public TGenericTextListAction {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef void (T::*Method)(int itemIndex);
|
|
Shinya Kitaoka |
120a6e |
TTextListAction(T *target, Method method)
|
|
Shinya Kitaoka |
120a6e |
: m_target(target), m_method(method) {}
|
|
Shinya Kitaoka |
120a6e |
void sendCommand(int itemIndex) { (m_target->*m_method)(itemIndex); }
|
|
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 DVAPI TTextListItem {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TTextListItem(const std::string &id, const std::string &caption);
|
|
Shinya Kitaoka |
120a6e |
virtual ~TTextListItem() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::string getId() { return m_id; }
|
|
Shinya Kitaoka |
120a6e |
std::string getCaption() { return m_caption; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
std::string m_id;
|
|
Shinya Kitaoka |
120a6e |
std::string m_caption;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TTextList : public TWidget {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TTextList(TWidget *parent, std::string name = "textlist");
|
|
Shinya Kitaoka |
120a6e |
~TTextList();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addItem(TTextListItem *item);
|
|
Shinya Kitaoka |
120a6e |
void removeItem(const std::string &itemId);
|
|
Shinya Kitaoka |
120a6e |
void clearAll();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getItemCount() const;
|
|
Shinya Kitaoka |
120a6e |
TTextListItem *getItem(int i) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// returns the index of item, -1 if not present
|
|
Shinya Kitaoka |
120a6e |
int itemToIndex(const std::string &itemId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getSelectedItemCount() const;
|
|
Shinya Kitaoka |
120a6e |
TTextListItem *getSelectedItem(int i) const;
|
|
Shinya Kitaoka |
120a6e |
std::string getSelectedItemId(
|
|
Shinya Kitaoka |
120a6e |
int i) const; // returns the id of the i-th item selected
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void select(int i, bool on);
|
|
Shinya Kitaoka |
120a6e |
void select(const std::string &itemId, bool on);
|
|
Shinya Kitaoka |
120a6e |
void unselectAll();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isSelected(int i) const;
|
|
Shinya Kitaoka |
120a6e |
bool isSelected(const std::string &itemId) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setSelAction(TGenericTextListAction *action);
|
|
Shinya Kitaoka |
120a6e |
void setDblClickAction(TGenericTextListAction *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 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
|