2017-11-04 07:03:53 +01:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* fcheckbox.cpp - Widget FCheckBox *
|
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
|
* This file is part of the FINAL CUT widget toolkit *
|
2017-11-04 07:03:53 +01:00
|
|
|
|
* *
|
2020-05-02 00:07:35 +02:00
|
|
|
|
* Copyright 2014-2020 Markus Gans *
|
2017-11-04 07:03:53 +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 *
|
2017-11-04 07:03:53 +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 *
|
2017-11-04 07:03:53 +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/>. *
|
|
|
|
|
***********************************************************************/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
2019-07-21 23:31:21 +02:00
|
|
|
|
#include "final/fc.h"
|
2017-09-17 21:32:46 +02:00
|
|
|
|
#include "final/fcheckbox.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
|
namespace finalcut
|
|
|
|
|
{
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
// class FCheckBox
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// constructor and destructor
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-10 04:01:22 +02:00
|
|
|
|
FCheckBox::FCheckBox(FWidget* parent)
|
2020-05-24 23:55:08 +02:00
|
|
|
|
: FToggleButton{parent}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
{
|
2015-07-04 22:51:47 +02:00
|
|
|
|
init();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-10 04:01:22 +02:00
|
|
|
|
FCheckBox::FCheckBox (const FString& txt, FWidget* parent)
|
2020-05-24 23:55:08 +02:00
|
|
|
|
: FToggleButton{txt, parent}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
{
|
2015-07-04 22:51:47 +02:00
|
|
|
|
init();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
FCheckBox::~FCheckBox() // destructor
|
2015-09-22 04:18:20 +02:00
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private methods of FCheckBox
|
2015-07-04 22:51:47 +02:00
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
void FCheckBox::init()
|
|
|
|
|
{
|
2019-09-04 23:57:31 +02:00
|
|
|
|
setLabelOffsetPos(4);
|
|
|
|
|
setButtonWidth(4);
|
2015-08-11 00:11:07 +02:00
|
|
|
|
setVisibleCursor();
|
2015-07-04 22:51:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
void FCheckBox::draw()
|
|
|
|
|
{
|
2019-08-11 20:07:39 +02:00
|
|
|
|
if ( ! isVisible() )
|
|
|
|
|
return;
|
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
drawCheckButton();
|
|
|
|
|
drawLabel();
|
|
|
|
|
FToggleButton::draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
void FCheckBox::drawCheckButton()
|
|
|
|
|
{
|
2020-05-02 00:07:35 +02:00
|
|
|
|
print() << FPoint{1, 1};
|
2020-06-06 21:10:06 +02:00
|
|
|
|
setColor();
|
2016-01-08 01:00:05 +01:00
|
|
|
|
|
2020-05-16 22:24:36 +02:00
|
|
|
|
if ( FTerm::isMonochron() )
|
2015-10-11 21:56:16 +02:00
|
|
|
|
{
|
|
|
|
|
if ( hasFocus() )
|
|
|
|
|
setReverse(false);
|
|
|
|
|
else
|
|
|
|
|
setReverse(true);
|
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
|
2019-09-04 23:57:31 +02:00
|
|
|
|
if ( isChecked() )
|
2019-08-11 20:07:39 +02:00
|
|
|
|
drawChecked();
|
|
|
|
|
else
|
|
|
|
|
drawUnchecked();
|
|
|
|
|
|
2020-05-16 22:24:36 +02:00
|
|
|
|
if ( FTerm::isMonochron() )
|
2019-08-11 20:07:39 +02:00
|
|
|
|
setReverse(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
inline void FCheckBox::drawChecked()
|
|
|
|
|
{
|
2020-05-16 22:24:36 +02:00
|
|
|
|
if ( FTerm::isNewFont() )
|
2019-08-11 20:07:39 +02:00
|
|
|
|
print (CHECKBOX_ON);
|
|
|
|
|
else
|
2015-05-23 13:35:12 +02:00
|
|
|
|
{
|
2019-08-11 20:07:39 +02:00
|
|
|
|
print ('[');
|
|
|
|
|
print (fc::Times); // Times ×
|
|
|
|
|
print (']');
|
2015-05-23 13:35:12 +02:00
|
|
|
|
}
|
2019-08-11 20:07:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
inline void FCheckBox::drawUnchecked()
|
|
|
|
|
{
|
2020-05-16 22:24:36 +02:00
|
|
|
|
if ( FTerm::isNewFont() )
|
2019-08-11 20:07:39 +02:00
|
|
|
|
print (CHECKBOX);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-08-11 20:07:39 +02:00
|
|
|
|
print ('[');
|
|
|
|
|
print (' ');
|
|
|
|
|
print (']');
|
2015-05-23 13:35:12 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-20 23:59:01 +02:00
|
|
|
|
|
|
|
|
|
} // namespace finalcut
|