2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fbutton.cpp - Widget FButton *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-01-02 20:38:45 +01: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/>. *
|
|
|
|
***********************************************************************/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fapplication.h"
|
|
|
|
#include "final/fbutton.h"
|
|
|
|
#include "final/fstatusbar.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 FButton
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructors and destructor
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-22 04:18:20 +02:00
|
|
|
FButton::FButton(FWidget* parent)
|
|
|
|
: FWidget(parent)
|
|
|
|
, text()
|
|
|
|
, button_down(false)
|
|
|
|
, click_animation(true)
|
|
|
|
, click_time(150)
|
2017-12-25 21:17:08 +01:00
|
|
|
, indent(0)
|
|
|
|
, space(int(' '))
|
|
|
|
, center_offset(0)
|
|
|
|
, vcenter_offset(0)
|
|
|
|
, txtlength(0)
|
|
|
|
, hotkeypos(-1)
|
2015-09-22 04:18:20 +02:00
|
|
|
, button_fg(wc.button_active_fg)
|
|
|
|
, button_bg(wc.button_active_bg)
|
|
|
|
, button_hotkey_fg(wc.button_hotkey_fg)
|
|
|
|
, button_focus_fg(wc.button_active_focus_fg)
|
|
|
|
, button_focus_bg(wc.button_active_focus_bg)
|
|
|
|
, button_inactive_fg(wc.button_inactive_fg)
|
|
|
|
, button_inactive_bg(wc.button_inactive_bg)
|
2017-12-25 21:17:08 +01:00
|
|
|
, is()
|
2015-09-22 04:18:20 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FButton::FButton (const FString& txt, FWidget* parent)
|
|
|
|
: FWidget(parent)
|
|
|
|
, text(txt)
|
|
|
|
, button_down(false)
|
|
|
|
, click_animation(true)
|
|
|
|
, click_time(150)
|
2017-12-25 21:17:08 +01:00
|
|
|
, indent(0)
|
|
|
|
, space(int(' '))
|
|
|
|
, center_offset(0)
|
|
|
|
, vcenter_offset(0)
|
|
|
|
, txtlength(0)
|
|
|
|
, hotkeypos(-1)
|
2015-09-22 04:18:20 +02:00
|
|
|
, button_fg(wc.button_active_fg)
|
|
|
|
, button_bg(wc.button_active_bg)
|
|
|
|
, button_hotkey_fg(wc.button_hotkey_fg)
|
|
|
|
, button_focus_fg(wc.button_active_focus_fg)
|
|
|
|
, button_focus_bg(wc.button_active_focus_bg)
|
|
|
|
, button_inactive_fg(wc.button_inactive_fg)
|
|
|
|
, button_inactive_bg(wc.button_inactive_bg)
|
2017-12-25 21:17:08 +01:00
|
|
|
, is()
|
2015-09-22 04:18:20 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
detectHotkey();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FButton::~FButton() // destructor
|
|
|
|
{
|
2015-11-12 01:33:16 +01:00
|
|
|
delAccelerator();
|
2015-12-19 20:49:01 +01:00
|
|
|
delOwnTimer();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// public methods of FButton
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setForegroundColor (short color)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget::setForegroundColor(color);
|
|
|
|
updateButtonColor();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setBackgroundColor (short color)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget::setBackgroundColor(color);
|
|
|
|
updateButtonColor();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::setHotkeyForegroundColor (short color)
|
|
|
|
{
|
|
|
|
// valid colors -1..254
|
|
|
|
if ( color == fc::Default || color >> 8 == 0 )
|
|
|
|
button_hotkey_fg = color;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-12 22:59:48 +01:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setFocusForegroundColor (short color)
|
|
|
|
{
|
|
|
|
// valid colors -1..254
|
|
|
|
if ( color == fc::Default || color >> 8 == 0 )
|
|
|
|
button_focus_fg = color;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
updateButtonColor();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setFocusBackgroundColor (short color)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// valid colors -1..254
|
|
|
|
if ( color == fc::Default || color >> 8 == 0 )
|
|
|
|
button_focus_bg = color;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
updateButtonColor();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2015-09-22 04:18:20 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setInactiveForegroundColor (short color)
|
2015-09-22 04:18:20 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// valid colors -1..254
|
|
|
|
if ( color == fc::Default || color >> 8 == 0 )
|
|
|
|
button_inactive_fg = color;
|
|
|
|
|
|
|
|
updateButtonColor();
|
2015-09-22 04:18:20 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setInactiveBackgroundColor (short color)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// valid colors -1..254
|
|
|
|
if ( color == fc::Default || color >> 8 == 0 )
|
|
|
|
button_inactive_bg = color;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
updateButtonColor();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FButton::setNoUnderline (bool on)
|
|
|
|
{
|
|
|
|
if ( on )
|
|
|
|
flags |= fc::no_underline;
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
flags &= ~fc::no_underline;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return on;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FButton::setEnable (bool on)
|
|
|
|
{
|
|
|
|
FWidget::setEnable(on);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on )
|
|
|
|
setHotkeyAccelerator();
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
delAccelerator();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
updateButtonColor();
|
|
|
|
return on;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FButton::setFocus (bool on)
|
|
|
|
{
|
|
|
|
FWidget::setFocus(on);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isEnabled() )
|
|
|
|
{
|
|
|
|
if ( getStatusBar() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-03-26 20:40:04 +02:00
|
|
|
const FString& msg = getStatusbarMessage();
|
|
|
|
const FString& curMsg = getStatusBar()->getMessage();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( curMsg != msg )
|
|
|
|
getStatusBar()->setMessage(msg);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isEnabled() && getStatusBar() )
|
|
|
|
getStatusBar()->clearMessage();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
updateButtonColor();
|
|
|
|
return on;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FButton::setFlat (bool on)
|
|
|
|
{
|
|
|
|
if ( on )
|
|
|
|
flags |= fc::flat;
|
|
|
|
else
|
|
|
|
flags &= ~fc::flat;
|
|
|
|
return on;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FButton::setShadow (bool on)
|
|
|
|
{
|
|
|
|
if ( on
|
2018-05-06 21:41:55 +02:00
|
|
|
&& getEncoding() != fc::VT100
|
|
|
|
&& getEncoding() != fc::ASCII )
|
2017-01-26 00:31:07 +01:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
flags |= fc::shadow;
|
2017-01-26 00:31:07 +01:00
|
|
|
setShadowSize(1,1);
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2017-01-26 00:31:07 +01:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
flags &= ~fc::shadow;
|
2017-01-26 00:31:07 +01:00
|
|
|
setShadowSize(0,0);
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return on;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FButton::setDown (bool on)
|
|
|
|
{
|
|
|
|
if ( button_down != on )
|
|
|
|
{
|
|
|
|
button_down = on;
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
return on;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::setText (const FString& txt)
|
|
|
|
{
|
2018-03-21 00:02:43 +01:00
|
|
|
if ( txt.isNull() )
|
2016-11-02 00:37:58 +01:00
|
|
|
text = "";
|
2018-03-21 00:02:43 +01:00
|
|
|
else
|
|
|
|
text = txt;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
detectHotkey();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::hide()
|
|
|
|
{
|
|
|
|
int s, f, size;
|
|
|
|
short fg, bg;
|
|
|
|
char* blank;
|
|
|
|
FWidget* parent_widget = getParentWidget();
|
|
|
|
FWidget::hide();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( parent_widget )
|
|
|
|
{
|
|
|
|
fg = parent_widget->getForegroundColor();
|
|
|
|
bg = parent_widget->getBackgroundColor();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
fg = wc.dialog_fg;
|
|
|
|
bg = wc.dialog_bg;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setColor (fg, bg);
|
|
|
|
s = hasShadow() ? 1 : 0;
|
|
|
|
f = isFlat() ? 1 : 0;
|
|
|
|
size = getWidth() + s + (f << 1);
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( size < 0 )
|
|
|
|
return;
|
|
|
|
|
2017-08-12 22:55:29 +02:00
|
|
|
try
|
|
|
|
{
|
2018-10-08 04:14:20 +02:00
|
|
|
blank = new char[std::size_t(size) + 1];
|
2017-08-12 22:55:29 +02:00
|
|
|
}
|
|
|
|
catch (const std::bad_alloc& ex)
|
|
|
|
{
|
|
|
|
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2018-09-12 22:51:15 +02:00
|
|
|
|
2018-10-08 04:14:20 +02:00
|
|
|
std::memset(blank, ' ', std::size_t(size));
|
2016-11-02 00:37:58 +01:00
|
|
|
blank[size] = '\0';
|
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int y = 0; y < getHeight() + s + (f << 1); y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (1 - f, 1 + y - f);
|
2016-11-02 00:37:58 +01:00
|
|
|
print (blank);
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
delete[] blank;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onKeyPress (FKeyEvent* ev)
|
|
|
|
{
|
|
|
|
int key;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isEnabled() )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
key = ev->key();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
switch ( key )
|
|
|
|
{
|
|
|
|
case fc::Fkey_return:
|
|
|
|
case fc::Fkey_enter:
|
|
|
|
case fc::Fkey_space:
|
|
|
|
if ( click_animation )
|
|
|
|
{
|
|
|
|
setDown();
|
|
|
|
addTimer(click_time);
|
|
|
|
}
|
|
|
|
processClick();
|
|
|
|
ev->accept();
|
|
|
|
break;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
default:
|
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onMouseDown (FMouseEvent* ev)
|
|
|
|
{
|
|
|
|
if ( ev->getButton() != fc::LeftButton )
|
|
|
|
{
|
|
|
|
setUp();
|
|
|
|
return;
|
|
|
|
}
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! hasFocus() )
|
|
|
|
{
|
|
|
|
FWidget* focused_widget = getFocusWidget();
|
|
|
|
FFocusEvent out (fc::FocusOut_Event);
|
|
|
|
FApplication::queueEvent(focused_widget, &out);
|
|
|
|
setFocus();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( focused_widget )
|
|
|
|
focused_widget->redraw();
|
|
|
|
|
|
|
|
if ( getStatusBar() )
|
|
|
|
getStatusBar()->drawMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
FPoint tPos = ev->getTermPos();
|
|
|
|
|
|
|
|
if ( getTermGeometry().contains(tPos) )
|
|
|
|
setDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onMouseUp (FMouseEvent* ev)
|
|
|
|
{
|
|
|
|
if ( ev->getButton() != fc::LeftButton )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( button_down )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
setUp();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( getTermGeometry().contains(ev->getTermPos()) )
|
|
|
|
processClick();
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onMouseMove (FMouseEvent* ev)
|
|
|
|
{
|
|
|
|
if ( ev->getButton() != fc::LeftButton )
|
|
|
|
return;
|
|
|
|
|
|
|
|
FPoint tPos = ev->getTermPos();
|
|
|
|
|
|
|
|
if ( click_animation )
|
|
|
|
{
|
|
|
|
if ( getTermGeometry().contains(tPos) )
|
|
|
|
setDown();
|
|
|
|
else
|
|
|
|
setUp();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onTimer (FTimerEvent* ev)
|
|
|
|
{
|
|
|
|
delTimer(ev->timerId());
|
2018-03-14 00:53:28 +01:00
|
|
|
|
|
|
|
if ( hasShadow() )
|
|
|
|
clearShadow();
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setUp();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onAccel (FAccelEvent* ev)
|
|
|
|
{
|
|
|
|
if ( ! isEnabled() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ! hasFocus() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
2016-08-21 21:27:44 +02:00
|
|
|
|
2017-06-14 01:23:10 +02:00
|
|
|
if ( focused_widget && focused_widget->isWidget() )
|
2017-06-11 17:47:50 +02:00
|
|
|
{
|
|
|
|
FFocusEvent out (fc::FocusOut_Event);
|
|
|
|
FApplication::queueEvent(focused_widget, &out);
|
|
|
|
setFocus();
|
2017-06-14 01:23:10 +02:00
|
|
|
focused_widget->redraw();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( click_animation )
|
|
|
|
setDown();
|
|
|
|
else
|
|
|
|
redraw();
|
|
|
|
|
|
|
|
if ( getStatusBar() )
|
|
|
|
getStatusBar()->drawMessage();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else if ( click_animation )
|
|
|
|
setDown();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( click_animation )
|
|
|
|
addTimer(click_time);
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
processClick();
|
|
|
|
ev->accept();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onFocusIn (FFocusEvent*)
|
|
|
|
{
|
|
|
|
if ( getStatusBar() )
|
|
|
|
getStatusBar()->drawMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::onFocusOut (FFocusEvent*)
|
|
|
|
{
|
|
|
|
if ( getStatusBar() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
getStatusBar()->clearMessage();
|
|
|
|
getStatusBar()->drawMessage();
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// private methods of FButton
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::init()
|
|
|
|
{
|
|
|
|
setForegroundColor (wc.button_active_fg);
|
|
|
|
setBackgroundColor (wc.button_active_bg);
|
|
|
|
setShadow();
|
|
|
|
}
|
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::getButtonState()
|
|
|
|
{
|
|
|
|
int active_focus = fc::active + fc::focus;
|
|
|
|
is.active_focus = ((flags & active_focus) == active_focus);
|
|
|
|
is.active = ((flags & fc::active) != 0);
|
|
|
|
is.focus = ((flags & fc::focus) != 0);
|
|
|
|
is.flat = isFlat();
|
|
|
|
is.non_flat_shadow = ((flags & (fc::shadow + fc::flat)) == fc::shadow);
|
|
|
|
is.no_underline = ((flags & fc::no_underline) != 0);
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uChar FButton::getHotkey()
|
|
|
|
{
|
2018-10-08 04:14:20 +02:00
|
|
|
uInt length;
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( text.isEmpty() )
|
|
|
|
return 0;
|
|
|
|
|
2018-10-08 04:14:20 +02:00
|
|
|
length = text.getLength();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2018-10-08 04:14:20 +02:00
|
|
|
for (uInt i = 0; i < length; i++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2018-10-08 04:14:20 +02:00
|
|
|
if ( i + 1 < length && text[i] == '&' )
|
|
|
|
return uChar(text[++i]);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
catch (const std::out_of_range&)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
return 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
return 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2015-06-19 19:53:30 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::setHotkeyAccelerator()
|
2015-06-19 19:53:30 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
int hotkey = getHotkey();
|
|
|
|
|
|
|
|
if ( hotkey )
|
2015-06-19 19:53:30 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( std::isalpha(hotkey) || std::isdigit(hotkey) )
|
2015-06-19 19:53:30 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
addAccelerator (std::tolower(hotkey));
|
|
|
|
addAccelerator (std::toupper(hotkey));
|
|
|
|
// Meta + hotkey
|
|
|
|
addAccelerator (fc::Fmkey_meta + std::tolower(hotkey));
|
2015-06-19 19:53:30 +02:00
|
|
|
}
|
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
addAccelerator (getHotkey());
|
2015-06-19 19:53:30 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
|
|
|
delAccelerator();
|
2015-06-19 19:53:30 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline void FButton::detectHotkey()
|
2015-06-19 19:53:30 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isEnabled() )
|
|
|
|
{
|
|
|
|
delAccelerator();
|
|
|
|
setHotkeyAccelerator();
|
|
|
|
}
|
2015-06-19 19:53:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-12-25 21:17:08 +01:00
|
|
|
int FButton::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
|
2015-06-19 19:53:30 +02:00
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
// find hotkey position in string
|
|
|
|
// + generate a new string without the '&'-sign
|
|
|
|
int pos = -1;
|
|
|
|
wchar_t* txt = src;
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (uInt i = 0; i < length; i++)
|
2017-08-12 22:55:29 +02:00
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( i < length && txt[i] == L'&' && pos == -1 )
|
|
|
|
{
|
|
|
|
pos = int(i);
|
|
|
|
i++;
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*dest++ = *src++;
|
2017-08-12 22:55:29 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
return pos;
|
|
|
|
}
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FButton::clickAnimationIndent (FWidget* parent_widget)
|
|
|
|
{
|
|
|
|
if ( ! button_down || ! click_animation )
|
|
|
|
return 0;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
// noshadow + indent one character to the right
|
|
|
|
if ( is.flat )
|
|
|
|
clearFlatBorder();
|
2018-03-14 00:53:28 +01:00
|
|
|
else if ( hasShadow() )
|
2017-12-25 21:17:08 +01:00
|
|
|
clearShadow();
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( parent_widget )
|
|
|
|
setColor ( parent_widget->getForegroundColor()
|
|
|
|
, parent_widget->getBackgroundColor() );
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int y = 1; y <= getHeight(); y++)
|
|
|
|
{
|
|
|
|
setPrintPos (1, y);
|
|
|
|
print (' '); // clear one left █
|
|
|
|
}
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FButton::clearRightMargin (FWidget* parent_widget)
|
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( button_down || isNewFont() )
|
2017-12-25 21:17:08 +01:00
|
|
|
return;
|
2015-06-19 19:53:30 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
// Restore the right background after button down
|
|
|
|
if ( parent_widget )
|
|
|
|
setColor ( parent_widget->getForegroundColor()
|
|
|
|
, parent_widget->getBackgroundColor() );
|
2016-08-21 21:27:44 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int y = 1; y <= getHeight(); y++)
|
2016-08-21 21:27:44 +02:00
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( isMonochron() )
|
|
|
|
setReverse(true); // Light background
|
2016-08-21 21:27:44 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
setPrintPos (1 + getWidth(), y);
|
|
|
|
print (' '); // clear right
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( is.active && isMonochron() )
|
|
|
|
setReverse(false); // Dark background
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2017-12-25 21:17:08 +01:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FButton::drawMarginLeft()
|
|
|
|
{
|
|
|
|
// Print left margin
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
setColor (getForegroundColor(), button_bg);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int y = 0; y < getHeight(); y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
setPrintPos (1 + indent, 1 + y);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( isMonochron() && is.active_focus && y == vcenter_offset )
|
|
|
|
print (fc::BlackRightPointingPointer); // ►
|
|
|
|
else
|
2017-09-11 03:06:02 +02:00
|
|
|
print (space); // full block █
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2017-12-25 21:17:08 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FButton::drawMarginRight()
|
|
|
|
{
|
|
|
|
// Print right margin
|
2016-11-13 22:08:40 +01:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int y = 0; y < getHeight(); y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
setPrintPos (getWidth() + indent, 1 + y);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( isMonochron() && is.active_focus && y == vcenter_offset )
|
|
|
|
print (fc::BlackLeftPointingPointer); // ◄
|
|
|
|
else
|
|
|
|
print (space); // full block █
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FButton::drawTopBottomBackground()
|
|
|
|
{
|
|
|
|
// Print top and bottom button background
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( getHeight() < 2 )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int y = 0; y < vcenter_offset; y++)
|
|
|
|
{
|
|
|
|
setPrintPos (2 + indent, 1 + y);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int x = 1; x < getWidth() - 1; x++)
|
|
|
|
print (space); // █
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (int y = vcenter_offset + 1; y < getHeight(); y++)
|
|
|
|
{
|
|
|
|
setPrintPos (2 + indent, 1 + y);
|
|
|
|
|
|
|
|
for (int x = 1; x < getWidth() - 1; x++)
|
|
|
|
print (space); // █
|
|
|
|
}
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FButton::drawButtonTextLine (wchar_t button_text[])
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
center_offset = int((getWidth() - txtlength - 1) / 2);
|
|
|
|
setPrintPos (2 + indent, 1 + vcenter_offset);
|
2016-11-02 00:37:58 +01:00
|
|
|
setColor (button_fg, button_bg);
|
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
// Print button text line --------
|
|
|
|
for (pos = 0; pos < center_offset; pos++)
|
2017-09-11 03:06:02 +02:00
|
|
|
print (space); // █
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( hotkeypos == -1 )
|
2017-12-25 21:17:08 +01:00
|
|
|
setCursorPos ( 2 + center_offset
|
|
|
|
, 1 + vcenter_offset ); // first character
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
2017-12-25 21:17:08 +01:00
|
|
|
setCursorPos ( 2 + center_offset + hotkeypos
|
|
|
|
, 1 + vcenter_offset ); // hotkey
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( ! is.active && isMonochron() )
|
|
|
|
setReverse(true); // Light background
|
2017-12-27 01:38:28 +01:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( is.active_focus && (isMonochron() || getMaxColor() < 16) )
|
2016-11-02 00:37:58 +01:00
|
|
|
setBold();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for ( int z = 0
|
|
|
|
; pos < center_offset + txtlength && z < getWidth() - 2
|
|
|
|
; z++, pos++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( (z == hotkeypos) && is.active )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
setColor (button_hotkey_fg, button_bg);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( ! is.active_focus && getMaxColor() < 16 )
|
2016-11-02 00:37:58 +01:00
|
|
|
setBold();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( ! is.no_underline )
|
2016-11-02 00:37:58 +01:00
|
|
|
setUnderline();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
print (button_text[z]);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( ! is.active_focus && getMaxColor() < 16 )
|
2016-11-02 00:37:58 +01:00
|
|
|
unsetBold();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( ! is.no_underline )
|
2016-11-02 00:37:58 +01:00
|
|
|
unsetUnderline();
|
2015-09-20 05:44:50 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setColor (button_fg, button_bg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-25 21:17:08 +01:00
|
|
|
print (button_text[z]);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2018-01-02 20:38:45 +01:00
|
|
|
if ( txtlength >= getWidth() - 1 )
|
2017-12-25 21:17:08 +01:00
|
|
|
{
|
|
|
|
// Print ellipsis
|
|
|
|
setPrintPos (getWidth() + indent - 2, 1);
|
|
|
|
print (L"..");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( is.active_focus && (isMonochron() || getMaxColor() < 16) )
|
2016-11-02 00:37:58 +01:00
|
|
|
unsetBold();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
for (pos = center_offset + txtlength; pos < getWidth() - 2; pos++)
|
2017-09-11 03:06:02 +02:00
|
|
|
print (space); // █
|
2017-12-25 21:17:08 +01:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::draw()
|
|
|
|
{
|
|
|
|
wchar_t* button_text;
|
|
|
|
FWidget* parent_widget = getParentWidget();
|
|
|
|
txtlength = int(text.getLength());
|
|
|
|
space = int(' ');
|
|
|
|
getButtonState();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
try
|
|
|
|
{
|
2018-10-08 04:14:20 +02:00
|
|
|
button_text = new wchar_t[std::size_t(txtlength) + 1]();
|
2017-12-25 21:17:08 +01:00
|
|
|
}
|
|
|
|
catch (const std::bad_alloc& ex)
|
|
|
|
{
|
|
|
|
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isMonochron() )
|
2017-12-25 21:17:08 +01:00
|
|
|
setReverse(true); // Light background
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-27 01:38:28 +01:00
|
|
|
// Click animation preprocessing
|
2017-12-25 21:17:08 +01:00
|
|
|
indent = clickAnimationIndent (parent_widget);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
// Clear right margin after animation
|
|
|
|
clearRightMargin (parent_widget);
|
2017-12-27 01:38:28 +01:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
if ( ! is.active && isMonochron() )
|
|
|
|
space = fc::MediumShade; // ▒ simulates greyed out at Monochron
|
|
|
|
|
|
|
|
if ( isMonochron() && (is.active || is.focus) )
|
|
|
|
setReverse(false); // Dark background
|
|
|
|
|
|
|
|
if ( is.flat && ! button_down )
|
|
|
|
drawFlatBorder();
|
|
|
|
|
|
|
|
hotkeypos = getHotkeyPos(text.wc_str(), button_text, uInt(txtlength));
|
|
|
|
|
|
|
|
if ( hotkeypos != -1 )
|
|
|
|
txtlength--;
|
|
|
|
|
|
|
|
if ( getHeight() >= 2 )
|
|
|
|
vcenter_offset = int((getHeight() - 1) / 2);
|
|
|
|
else
|
|
|
|
vcenter_offset = 0;
|
|
|
|
|
|
|
|
// Print left margin
|
|
|
|
drawMarginLeft();
|
|
|
|
|
|
|
|
// Print button text line
|
|
|
|
drawButtonTextLine(button_text);
|
|
|
|
|
|
|
|
// Print right margin
|
|
|
|
drawMarginRight();
|
|
|
|
|
|
|
|
// Print top and bottom button background
|
|
|
|
drawTopBottomBackground();
|
|
|
|
|
|
|
|
// Draw button shadow
|
|
|
|
if ( is.non_flat_shadow && ! button_down )
|
2016-11-02 00:37:58 +01:00
|
|
|
drawShadow();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isMonochron() )
|
2017-12-25 21:17:08 +01:00
|
|
|
setReverse(false); // Dark background
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
delete[] button_text;
|
|
|
|
updateStatusBar();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FButton::updateStatusBar()
|
|
|
|
{
|
|
|
|
if ( ! is.focus || ! getStatusBar() )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
const FString& msg = getStatusbarMessage();
|
|
|
|
const FString& curMsg = getStatusBar()->getMessage();
|
|
|
|
|
|
|
|
if ( curMsg != msg )
|
|
|
|
{
|
|
|
|
getStatusBar()->setMessage(msg);
|
|
|
|
getStatusBar()->drawMessage();
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-07-01 22:34:40 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::updateButtonColor()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isEnabled() )
|
2016-10-17 08:44:38 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( hasFocus() )
|
|
|
|
{
|
|
|
|
button_fg = button_focus_fg;
|
|
|
|
button_bg = button_focus_bg;
|
|
|
|
}
|
2016-10-17 08:44:38 +02:00
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
button_fg = getForegroundColor();
|
2017-09-11 03:06:02 +02:00
|
|
|
button_bg = getBackgroundColor();
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else // inactive
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
button_fg = button_inactive_fg;
|
|
|
|
button_bg = button_inactive_bg;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FButton::processClick()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
emitCallback("clicked");
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2018-09-20 23:59:01 +02:00
|
|
|
|
|
|
|
} // namespace finalcut
|