2019-11-16 15:16:44 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fspinbox.h - Widget FSpinBox *
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* This file is part of the FINAL CUT widget toolkit *
|
2019-11-16 15:16:44 +01:00
|
|
|
* *
|
2020-01-20 21:40:00 +01:00
|
|
|
* Copyright 2019-2020 Markus Gans *
|
2019-11-16 15:16:44 +01:00
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* 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 *
|
2019-11-16 15:16:44 +01:00
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* FINAL CUT is distributed in the hope that it will be useful, but *
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
2019-11-16 15:16:44 +01:00
|
|
|
* 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/>. *
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/* Inheritance diagram
|
|
|
|
* ═══════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FVTerm ▏ ▕ FObject ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲ ▲
|
|
|
|
* │ │
|
|
|
|
* └─────┬─────┘
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FWidget ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FSpinBox ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FSPINBOX_H
|
|
|
|
#define FSPINBOX_H
|
|
|
|
|
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2020-08-23 00:32:41 +02:00
|
|
|
#include <limits>
|
|
|
|
|
2019-11-16 15:16:44 +01:00
|
|
|
#include "final/fwidget.h"
|
|
|
|
|
|
|
|
namespace finalcut
|
|
|
|
{
|
|
|
|
|
|
|
|
// class forward declaration
|
|
|
|
class FLineEdit;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FSpinBox
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FSpinBox : public FWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Using-declaration
|
|
|
|
using FWidget::setGeometry;
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
explicit FSpinBox (FWidget* = nullptr);
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FSpinBox (const FSpinBox&) = delete;
|
|
|
|
|
|
|
|
// Destructor
|
2020-02-19 21:59:13 +01:00
|
|
|
~FSpinBox() override;
|
2019-11-16 15:16:44 +01:00
|
|
|
|
2020-04-15 23:44:08 +02:00
|
|
|
// Disable copy assignment operator (=)
|
2019-11-16 15:16:44 +01:00
|
|
|
FSpinBox& operator = (const FSpinBox&) = delete;
|
|
|
|
|
|
|
|
// Accessors
|
2020-10-04 00:59:21 +02:00
|
|
|
FString getClassName() const override;
|
2020-07-12 15:25:21 +02:00
|
|
|
sInt64 getValue() const;
|
2019-11-16 15:16:44 +01:00
|
|
|
FString getPrefix() const;
|
|
|
|
FString getSuffix() const;
|
2020-07-12 17:00:16 +02:00
|
|
|
FLineEdit::label_o getLabelOrientation() const;
|
2019-11-16 15:16:44 +01:00
|
|
|
|
|
|
|
// Mutators
|
2019-12-23 03:53:32 +01:00
|
|
|
void setSize (const FSize&, bool = true) override;
|
2019-11-16 15:16:44 +01:00
|
|
|
void setGeometry ( const FPoint&, const FSize&
|
|
|
|
, bool = true ) override;
|
|
|
|
bool setEnable (bool) override;
|
|
|
|
bool setEnable() override;
|
|
|
|
bool unsetEnable() override;
|
|
|
|
bool setDisable() override;
|
|
|
|
bool setFocus (bool) override;
|
|
|
|
bool setFocus() override;
|
|
|
|
bool unsetFocus() override;
|
|
|
|
bool setShadow (bool);
|
|
|
|
bool setShadow();
|
|
|
|
bool unsetShadow();
|
|
|
|
void setValue (sInt64);
|
|
|
|
void setMinValue (sInt64);
|
|
|
|
void setMaxValue (sInt64);
|
|
|
|
void setRange (sInt64, sInt64);
|
|
|
|
void setPrefix (const FString&);
|
|
|
|
void setSuffix (const FString&);
|
|
|
|
void setLabelText (const FString&);
|
|
|
|
void setLabelOrientation (const FLineEdit::label_o);
|
|
|
|
|
|
|
|
// Inquiries
|
2020-05-02 00:07:35 +02:00
|
|
|
bool hasShadow() const;
|
2019-11-16 15:16:44 +01:00
|
|
|
|
|
|
|
// Methods
|
2019-11-16 19:10:08 +01:00
|
|
|
void hide() override;
|
2019-11-16 15:16:44 +01:00
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
void onKeyPress (FKeyEvent*) override;
|
|
|
|
void onMouseDown (FMouseEvent*) override;
|
|
|
|
void onMouseUp (FMouseEvent*) override;
|
|
|
|
void onWheel (FWheelEvent*) override;
|
|
|
|
void onTimer (FTimerEvent*) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Enumeration
|
|
|
|
enum spiningState
|
|
|
|
{
|
|
|
|
noSpin = 0,
|
|
|
|
spinUp = 1,
|
|
|
|
spinDown = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init();
|
2019-11-16 19:10:08 +01:00
|
|
|
void draw() override;
|
2019-11-16 15:16:44 +01:00
|
|
|
void updateInputField();
|
|
|
|
void increaseValue();
|
|
|
|
void decreaseValue();
|
2020-08-13 23:58:32 +02:00
|
|
|
void processActivate() const;
|
|
|
|
void processChanged() const;
|
2019-11-16 15:16:44 +01:00
|
|
|
void forceFocus();
|
|
|
|
|
|
|
|
// Callback methods
|
2020-08-15 23:42:29 +02:00
|
|
|
void cb_inputFieldActivate() const;
|
2020-08-11 23:04:46 +02:00
|
|
|
void cb_inputFieldChange (const FLineEdit&);
|
2019-11-16 15:16:44 +01:00
|
|
|
|
|
|
|
// Data members
|
|
|
|
FLineEdit input_field{this};
|
|
|
|
sInt64 value{0};
|
|
|
|
sInt64 min{std::numeric_limits<sInt64>::min()};
|
|
|
|
sInt64 max{std::numeric_limits<sInt64>::max()};
|
|
|
|
FString pfix{};
|
|
|
|
FString sfix{};
|
|
|
|
spiningState spining_state{FSpinBox::noSpin};
|
|
|
|
bool threshold_reached{false};
|
|
|
|
int threshold_time{500};
|
2020-05-16 22:24:36 +02:00
|
|
|
int repeat_time{80};
|
2019-11-16 15:16:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// FSpinBox inline functions
|
|
|
|
//----------------------------------------------------------------------
|
2020-10-04 00:59:21 +02:00
|
|
|
inline FString FSpinBox::getClassName() const
|
2019-12-16 11:14:24 +01:00
|
|
|
{ return "FSpinBox"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2020-07-12 15:25:21 +02:00
|
|
|
inline sInt64 FSpinBox::getValue() const
|
2019-11-16 15:16:44 +01:00
|
|
|
{ return value; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-12-15 20:32:36 +01:00
|
|
|
inline FString FSpinBox::getPrefix() const
|
2019-11-16 15:16:44 +01:00
|
|
|
{ return pfix; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-12-15 20:32:36 +01:00
|
|
|
inline FString FSpinBox::getSuffix() const
|
2019-11-16 15:16:44 +01:00
|
|
|
{ return sfix; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2020-07-12 17:00:16 +02:00
|
|
|
inline FLineEdit::label_o FSpinBox::getLabelOrientation() const
|
2019-11-16 15:16:44 +01:00
|
|
|
{ return input_field.getLabelOrientation(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::setEnable()
|
|
|
|
{ return setEnable(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::unsetEnable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::setDisable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::setFocus()
|
|
|
|
{ return setFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::unsetFocus()
|
|
|
|
{ return setFocus(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::setShadow()
|
|
|
|
{ return setShadow(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FSpinBox::unsetShadow()
|
|
|
|
{ return setShadow(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2020-05-02 00:07:35 +02:00
|
|
|
inline bool FSpinBox::hasShadow() const
|
2019-11-16 15:16:44 +01:00
|
|
|
{ return getFlags().shadow; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FSpinBox::setLabelText (const FString& s)
|
|
|
|
{ input_field.setLabelText(s); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FSpinBox::setLabelOrientation (const FLineEdit::label_o o)
|
|
|
|
{ input_field.setLabelOrientation(o); }
|
|
|
|
|
|
|
|
} // namespace finalcut
|
|
|
|
|
|
|
|
#endif // FSPINBOX_H
|