2017-10-02 07:32:33 +02:00
|
|
|
/************************************************************************
|
|
|
|
* ftextview.h - Widget FTextView (a multiline text viewer) *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
|
|
|
* Copyright 2014-2017 Markus Gans *
|
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/* Inheritance diagram
|
|
|
|
* ═══════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲ ▲
|
|
|
|
* │ │
|
|
|
|
* └─────┬─────┘
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FVTerm ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FWidget ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTextView ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FTEXTVIEW_H
|
|
|
|
#define FTEXTVIEW_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fapplication.h"
|
|
|
|
#include "final/fscrollbar.h"
|
|
|
|
#include "final/fstatusbar.h"
|
|
|
|
#include "final/fstring.h"
|
|
|
|
#include "final/fwidget.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTextView
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FTextView : public FWidget
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Using-declarations
|
|
|
|
using FWidget::setGeometry;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
explicit FTextView (FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~FTextView();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
const char* getClassName() const;
|
|
|
|
uInt getColumns() const;
|
|
|
|
uInt getRows() const;
|
|
|
|
const FString getText() const;
|
2017-09-20 16:56:20 +02:00
|
|
|
const FStringList& getLines() const;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void setGeometry (int, int, int, int, bool = true);
|
|
|
|
void setPosition (int);
|
|
|
|
void setText (const FString&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void hide();
|
|
|
|
void append (const FString&);
|
|
|
|
void insert (const FString&, int);
|
|
|
|
void replaceRange (const FString&, int, int);
|
|
|
|
void deleteRange (int, int);
|
|
|
|
void deleteLine (int);
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
void onKeyPress (FKeyEvent*);
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
void onWheel (FWheelEvent*);
|
|
|
|
void onFocusIn (FFocusEvent*);
|
|
|
|
void onFocusOut (FFocusEvent*);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Method
|
|
|
|
void adjustSize();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
FTextView (const FTextView&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FTextView& operator = (const FTextView&);
|
|
|
|
|
|
|
|
// Methods
|
2017-09-20 16:56:20 +02:00
|
|
|
void init();
|
|
|
|
void draw();
|
|
|
|
void drawText();
|
|
|
|
void processChanged();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Callback methods
|
2017-09-20 16:56:20 +02:00
|
|
|
void cb_VBarChange (FWidget*, data_ptr);
|
|
|
|
void cb_HBarChange (FWidget*, data_ptr);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Data Members
|
2017-09-20 16:56:20 +02:00
|
|
|
FStringList data;
|
|
|
|
FScrollbar* vbar;
|
|
|
|
FScrollbar* hbar;
|
|
|
|
int xoffset;
|
|
|
|
int yoffset;
|
|
|
|
int nf_offset;
|
|
|
|
uInt maxLineWidth;
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FListBox inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTextView::getClassName() const
|
|
|
|
{ return "FTextView"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline uInt FTextView::getColumns() const
|
|
|
|
{ return maxLineWidth; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline uInt FTextView::getRows() const
|
|
|
|
{ return uInt(data.size()); }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
2017-09-20 16:56:20 +02:00
|
|
|
inline const FStringList& FTextView::getLines() const
|
2016-11-02 00:37:58 +01:00
|
|
|
{ return data; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-09-17 01:50:41 +02:00
|
|
|
inline void FTextView::deleteRange (int from, int to)
|
|
|
|
{ replaceRange (FString(), from, to); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTextView::deleteLine (int pos)
|
|
|
|
{ deleteRange (pos, pos); }
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FTEXTVIEW_H
|