2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* flineedit.h - Widget FLineEdit *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-09-20 23:59:01 +02:00
|
|
|
* Copyright 2012-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
/* Inheritance diagram
|
|
|
|
* ═══════════════════
|
|
|
|
*
|
2017-10-29 14:27:50 +01:00
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTerm ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
2017-10-02 07:32:33 +02:00
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
2017-10-29 14:27:50 +01:00
|
|
|
* ▕ FVTerm ▏ ▕ FObject ▏
|
2017-10-02 07:32:33 +02:00
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲ ▲
|
|
|
|
* │ │
|
|
|
|
* └─────┬─────┘
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FWidget ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FLineEdit ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FLINEEDIT_H
|
|
|
|
#define FLINEEDIT_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-10-31 00:41:59 +01:00
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fwidget.h"
|
|
|
|
#include "final/flabel.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2015-09-25 21:37:19 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FLineEdit
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FLineEdit : public FWidget
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Enumeration
|
|
|
|
enum label_o
|
|
|
|
{
|
|
|
|
label_above = 0,
|
|
|
|
label_left = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
explicit FLineEdit (FWidget* = 0);
|
2018-10-24 00:16:45 +02:00
|
|
|
explicit FLineEdit (const FString&, FWidget* = 0);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FLineEdit();
|
|
|
|
|
2017-09-21 07:22:08 +02:00
|
|
|
// Overloaded operators
|
|
|
|
FLineEdit& operator = (const FString&);
|
|
|
|
FLineEdit& operator << (const FString&);
|
2018-12-06 02:28:24 +01:00
|
|
|
FLineEdit& operator << (fc::SpecialCharacter);
|
2017-09-21 07:22:08 +02:00
|
|
|
FLineEdit& operator << (const wchar_t);
|
|
|
|
FLineEdit& operator << (const uInt);
|
|
|
|
FLineEdit& operator << (const int);
|
|
|
|
FLineEdit& operator << (const uLong);
|
|
|
|
FLineEdit& operator << (const long);
|
|
|
|
FLineEdit& operator << (const float);
|
|
|
|
FLineEdit& operator << (const double);
|
|
|
|
FLineEdit& operator << (const lDouble);
|
|
|
|
const FLineEdit& operator >> (FString&);
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Accessors
|
2018-09-24 04:02:35 +02:00
|
|
|
const char* getClassName() const;
|
|
|
|
FString getText() const;
|
|
|
|
int getLabelOrientation();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Mutators
|
2018-09-24 04:02:35 +02:00
|
|
|
void setText (const FString&);
|
|
|
|
void setLabelText (const FString&);
|
|
|
|
void setLabelOrientation(const label_o);
|
|
|
|
virtual bool setEnable(bool);
|
|
|
|
virtual bool setEnable();
|
|
|
|
virtual bool unsetEnable();
|
|
|
|
virtual bool setDisable();
|
|
|
|
virtual bool setFocus(bool);
|
|
|
|
virtual bool setFocus();
|
|
|
|
virtual bool unsetFocus();
|
|
|
|
bool setShadow(bool);
|
|
|
|
bool setShadow();
|
|
|
|
bool unsetShadow();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Inquiry
|
2018-09-24 04:02:35 +02:00
|
|
|
bool hasShadow();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Methods
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual void hide();
|
|
|
|
void clear();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Event handlers
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual void onKeyPress (FKeyEvent*);
|
|
|
|
virtual void onMouseDown (FMouseEvent*);
|
|
|
|
virtual void onMouseUp (FMouseEvent*);
|
|
|
|
virtual void onMouseMove (FMouseEvent*);
|
|
|
|
virtual void onTimer (FTimerEvent*);
|
|
|
|
virtual void onAccel (FAccelEvent*);
|
|
|
|
virtual void onHide (FHideEvent*);
|
|
|
|
virtual void onFocusIn (FFocusEvent*);
|
|
|
|
virtual void onFocusOut (FFocusEvent*);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
protected:
|
2018-09-24 04:02:35 +02:00
|
|
|
void adjustLabel();
|
|
|
|
virtual void adjustSize();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Enumeration
|
|
|
|
enum dragScroll
|
|
|
|
{
|
|
|
|
noScroll = 0,
|
|
|
|
scrollLeft = 1,
|
|
|
|
scrollRight = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FLineEdit (const FLineEdit&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FLineEdit& operator = (const FLineEdit&);
|
|
|
|
|
|
|
|
// Methods
|
2018-09-24 04:02:35 +02:00
|
|
|
void init();
|
|
|
|
bool hasHotkey();
|
|
|
|
virtual void draw();
|
|
|
|
void drawInputField();
|
|
|
|
void keyLeft();
|
|
|
|
void keyRight();
|
|
|
|
void keyHome();
|
|
|
|
void keyEnd();
|
|
|
|
void keyDel();
|
|
|
|
void keyBackspace();
|
|
|
|
void keyInsert();
|
|
|
|
void keyEnter();
|
2018-11-21 20:07:08 +01:00
|
|
|
bool keyInput (FKey);
|
2018-09-24 04:02:35 +02:00
|
|
|
void processActivate();
|
|
|
|
void processChanged();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Data Members
|
2018-12-03 03:22:36 +01:00
|
|
|
FString text{""};
|
|
|
|
FString label_text{""};
|
|
|
|
FLabel* label{};
|
|
|
|
label_o label_orientation{FLineEdit::label_left};
|
|
|
|
dragScroll drag_scroll{FLineEdit::noScroll};
|
|
|
|
bool scroll_timer{false};
|
|
|
|
int scroll_repeat{100};
|
|
|
|
bool insert_mode{true};
|
|
|
|
std::size_t cursor_pos{0};
|
|
|
|
std::size_t text_offset{0};
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FLineEdit inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FLineEdit::getClassName() const
|
|
|
|
{ return "FLineEdit"; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FLineEdit::getText() const
|
|
|
|
{ return text; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FLineEdit::getLabelOrientation()
|
|
|
|
{ return int(label_orientation); }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::setEnable()
|
|
|
|
{ return setEnable(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::unsetEnable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::setDisable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::setFocus()
|
|
|
|
{ return setFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::unsetFocus()
|
|
|
|
{ return setFocus(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::setShadow()
|
|
|
|
{ return setShadow(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::unsetShadow()
|
|
|
|
{ return setShadow(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLineEdit::hasShadow()
|
2018-11-04 23:00:06 +01:00
|
|
|
{ return flags.shadow; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FLINEEDIT_H
|