finalcut/src/fcheckbox.cpp

123 lines
3.5 KiB
C++
Raw Normal View History

2017-11-04 07:03:53 +01:00
/***********************************************************************
* fcheckbox.cpp - Widget FCheckBox *
* *
* This file is part of the FINAL CUT widget toolkit *
2017-11-04 07:03:53 +01:00
* *
* Copyright 2014-2020 Markus Gans *
2017-11-04 07:03:53 +01: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. *
* *
* 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
#include "final/fc.h"
#include "final/fcheckbox.h"
2015-05-23 13:35:12 +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)
: 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)
: 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()
{
setLabelOffsetPos(4);
setButtonWidth(4);
setVisibleCursor();
2015-07-04 22:51:47 +02:00
}
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
void FCheckBox::draw()
{
if ( ! isVisible() )
return;
2015-05-23 13:35:12 +02:00
drawCheckButton();
drawLabel();
FToggleButton::draw();
}
//----------------------------------------------------------------------
void FCheckBox::drawCheckButton()
{
print() << FPoint{1, 1};
2020-06-06 21:10:06 +02:00
setColor();
if ( FTerm::isMonochron() )
2015-10-11 21:56:16 +02:00
{
if ( hasFocus() )
setReverse(false);
else
setReverse(true);
}
if ( isChecked() )
drawChecked();
else
drawUnchecked();
if ( FTerm::isMonochron() )
setReverse(false);
}
//----------------------------------------------------------------------
inline void FCheckBox::drawChecked()
{
if ( FTerm::isNewFont() )
print (CHECKBOX_ON);
else
2015-05-23 13:35:12 +02:00
{
print ('[');
print (fc::Times); // Times ×
print (']');
2015-05-23 13:35:12 +02:00
}
}
//----------------------------------------------------------------------
inline void FCheckBox::drawUnchecked()
{
if ( FTerm::isNewFont() )
print (CHECKBOX);
2015-05-23 13:35:12 +02:00
else
{
print ('[');
print (' ');
print (']');
2015-05-23 13:35:12 +02:00
}
}
} // namespace finalcut