Files
k7/SensitiveTreeTableNodeText.h
SET f5416addc0 Create and use a sensitive WText in some tree table nodes.
It may be of interest to copy WTreeTableNode items text content. These
cannot be selected with the mouse for copy to clipboard. The text is
here shown read-only in an extended auto-replaced WLineEdit.
2020-11-04 09:06:48 +01:00

74 lines
1.9 KiB
C++

/*
* File: SensitiveTreeTableNodeText.h
* Author: SET - nmset@yandex.com
* License : LGPL v2.1
* Copyright SET - © 2019
*
* Created on November 3, 2020, 8:26 PM
*/
#ifndef TREETABLENODETEXT_H
#define TREETABLENODETEXT_H
#include <Wt/WText.h>
#include <Wt/WTreeTableNode.h>
#include <Wt/WLineEdit.h>
using namespace Wt;
class TreeTableNodeText;
class TreeTableNodeLineEdit;
/**
* An extended WText in a WTreeTableNode.
* It is replaced by a TreeTableNodeLineEdit on click.
* \n This allows to copy the text to clipboard.
*/
class TreeTableNodeText : public WText
{
public:
TreeTableNodeText(WTreeTableNode * node, uint colIndex);
TreeTableNodeText(const WString& text,
WTreeTableNode * node, uint colIndex);
TreeTableNodeText(const WString& text, TextFormat textFormat,
WTreeTableNode * node, uint colIndex);
virtual ~TreeTableNodeText();
/**
* Creates a read-only TreeTableNodeLineEdit replacing this
* TreeTableNodeText.
*/
void OnClick();
private:
WTreeTableNode * m_node;
uint m_colIndex;
TreeTableNodeLineEdit * m_lineEdit;
void Init(WTreeTableNode * node, uint colIndex);
};
/**
* An extended WLineEdit replacing a WText in a WTreeTableNode.
* Switches back to a WTreeTableNodeText when it loses focus.
*/
class TreeTableNodeLineEdit : public WLineEdit
{
public:
TreeTableNodeLineEdit(WTreeTableNode * node, uint colIndex);
TreeTableNodeLineEdit(const WString& content,
WTreeTableNode * node, uint colIndex);
virtual ~TreeTableNodeLineEdit();
/**
* Creates back a TreeTableNodeText replacing this TreeTableNodeLineEdit.
*/
void OnBlurred();
private:
WTreeTableNode * m_node;
uint m_colIndex;
TreeTableNodeText * m_text;
void Init(WTreeTableNode * node, uint colIndex);
};
#endif /* TREETABLENODETEXT_H */