edn/sources/appl/Gui/TextViewer.h

131 lines
4.3 KiB
C
Raw Normal View History

2013-09-19 22:23:31 +02:00
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_TEXT_VIEWER_H__
#define __APPL_TEXT_VIEWER_H__
2013-10-25 20:49:26 +02:00
#include <appl/debug.h>
#include <appl/Buffer.h>
2013-09-19 22:23:31 +02:00
#include <appl/globalMsg.h>
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
2013-10-29 21:13:45 +01:00
#include <appl/BufferManager.h>
2013-09-19 22:23:31 +02:00
2013-10-09 22:00:24 +02:00
namespace appl {
class TextViewerPlugin;
class TextPluginCopy;
class TextPluginMultiLineTab;
2013-10-21 22:11:16 +02:00
class TextPluginAutoIndent;
2013-10-22 21:34:13 +02:00
class TextPluginHistory;
2013-10-09 22:00:24 +02:00
class TextViewer : public widget::WidgetScrooled {
friend class appl::TextViewerPlugin;
friend class appl::TextPluginCopy;
friend class appl::TextPluginMultiLineTab;
2013-10-21 22:11:16 +02:00
friend class appl::TextPluginAutoIndent;
2013-10-22 21:34:13 +02:00
friend class appl::TextPluginHistory;
private:
appl::GlyphPainting* m_paintingProperties; //!< element painting property
esize_t m_colorBackground;
esize_t m_colorSpace;
esize_t m_colorTabulation;
esize_t m_colorCursor;
esize_t m_colorLineNumber;
esize_t m_colorSelection;
esize_t m_colorNormal;
2013-10-29 21:13:45 +01:00
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
2013-09-19 22:23:31 +02:00
public:
TextViewer(const etk::UString& _fontName="", int32_t _fontSize=-1);
virtual ~TextViewer(void);
private:
2013-09-26 22:15:39 +02:00
appl::Buffer* m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer)
ewol::Text m_displayText; //!< Text display properties.
2013-10-09 22:00:24 +02:00
ewol::Drawing m_displayDrawing; //!< Other diaplay requested.
2013-09-19 22:23:31 +02:00
public:
2013-10-07 22:04:21 +02:00
void setFontSize(int32_t _size);
void setFontName(const etk::UString& _fontName);
2013-09-19 22:23:31 +02:00
protected: // derived function
2013-10-07 22:04:21 +02:00
virtual void onDraw(void);
2013-09-19 22:23:31 +02:00
public: // Derived function
const char * const getObjectType(void) { return "appl::TextViewer"; };
2013-10-07 22:04:21 +02:00
virtual bool calculateMinSize(void);
virtual void onRegenerateDisplay(void);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
2013-10-29 21:13:45 +01:00
virtual void onObjectRemove(ewol::EObject* _removeObject);
2013-10-07 22:04:21 +02:00
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
2013-11-11 20:20:25 +01:00
virtual void onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID);
2013-10-07 22:04:21 +02:00
virtual void onGetFocus(void);
virtual void onLostFocus(void);
private:
float m_lastOffsetDisplay; //!< Line number ofssed in the display
2013-09-26 22:15:39 +02:00
private:
bool m_insertMode; //!< the insert mode is enable
public:
public:
// TODO : Doc : write data on buffer
bool moveCursor(const appl::Buffer::Iterator& _pos);
bool write(const etk::UString& _data);
bool write(const etk::UString& _data, const appl::Buffer::Iterator& _pos);
bool replace(const etk::UString& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
bool replace(const etk::UString& _data);
void remove(void);
appl::Buffer::Iterator getMousePosition(const vec2& _relativePos);
void mouseEventDouble(void);
void mouseEventTriple(void);
private:
enum moveMode {
moveLetter,
moveWord,
moveEnd
};
/**
* Move the cursor right in the line (no stop of a new line)
* @param[in] _mode Moving mode char, word, ...
*/
void moveCursorRight(moveMode _mode = moveLetter);
/**
* Move the cursor left in the line (no stop of a new line)
* @param[in] _mode Moving mode char, word, ...
*/
void moveCursorLeft(moveMode _mode = moveLetter);
/**
* @brief Move the cursor at an other position upper.
* @param[in] _nbLine number of up line that might be moved
*/
void moveCursorUp(esize_t _nbLine);
/**
* @brief Move the cursor at an other position under.
* @param[in] _nbLine number of down line that might be moved
*/
void moveCursorDown(esize_t _nbLine);
appl::Buffer::Iterator getPosSize(const appl::Buffer::Iterator& _startLinePos, float _distance);
float getScreenSize(const appl::Buffer::Iterator& _startLinePos, const appl::Buffer::Iterator& _stopPos);
2013-11-07 21:08:57 +01:00
private:
static TextViewer* m_currentBufferSelect; //!< to know which buffer is currently last selected
/**
* @brief Set the current buffer selected
*/
void setCurrentSelect(void);
/**
* @brief Check if the current buffer is last selected
* @return true if selected last
*/
bool isSelectedLast(void);
2013-09-19 22:23:31 +02:00
};
};
#endif