Fixes minor bugs

This commit is contained in:
Markus Gans 2020-09-20 14:11:35 +02:00
parent ff2e29b246
commit 44d6d8cdb9
15 changed files with 211 additions and 58 deletions

View File

@ -136,7 +136,10 @@ printf(...)
## Class digramm ## Class digramm
<pre style="line-height: 1 !important;"> <pre style="line-height: 1 !important;">
1┌──────────────┐ 1┌────────────┐
┌-----------┤ FTermLinux │
: └────────────┘
: 1┌──────────────┐
┌-----------┤ FTermFreeBSD │ ┌-----------┤ FTermFreeBSD │
: └──────────────┘ : └──────────────┘
: 1┌──────────────┐ : 1┌──────────────┐
@ -172,12 +175,15 @@ printf(...)
: 1┌───────────────┐ │ ┌─────────────┐ : 1┌───────────────┐ │ ┌─────────────┐
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
: └───────────────┘ │ └─────────────┘ : └───────────────┘ │ └─────────────┘
: 1┌─────────┐ │ ┌──────┐ ┌─────────┐ : 1┌─────────┐ │ ┌────────────┐1 1┌───────┐
┌-----------┤ FSystem │ │ │ FLog │◄──┤ FLogger │ ┌-----------┤ FSystem │ ├────┤ FUserEvent ├------┤ FData │
: └─────────┘ │ └──┬───┘ └─────────┘ : └─────────┘ │ └────────────┘ └───────┘
: *┌─────────┐ │ :1 : *┌─────────┐ │ ┌──────┐ ┌─────────┐
: ┌--------┤ FString │ │ ┌──┴───────────┐ : ┌--------┤ FString │ │ │ FLog │◄──┤ FLogger │
: : └─────────┘ │ ┌────┤ FApplication │ : : └─────────┘ │ └──┬───┘ └─────────┘
: : *┌───────────────┐ │ :1
: ┌--------┤ FStringStream │ │ ┌──┴───────────┐
: : └───────────────┘ │ ┌────┤ FApplication │
: : *┌────────┐ │ │ └──────────────┘ : : *┌────────┐ │ │ └──────────────┘
: ┌--------┤ FPoint │ │ │ ┌────────┐ : ┌--------┤ FPoint │ │ │ ┌────────┐
: : └────────┘ │ ├────┤ FLabel │ : : └────────┘ │ ├────┤ FLabel │
@ -209,15 +215,16 @@ printf(...)
│ ┌───────────┐1 1┌──────────────────┐ │ ┌───────────┐1 1┌──────────────────┐
├────┤ FComboBox ├------┤ FDropDownListBox │ ├────┤ FComboBox ├------┤ FDropDownListBox │
│ └───────────┘ └──────────────────┘ │ └───────────┘ └──────────────────┘
┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐ ┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐1
│ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem │ │ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem ├--┐
└─────────────┘ │ └──────────┘ └──────────────┘ └─────────────┘ │ └──────────┘ └──────────────┘ :
│ 1┌───────────┐1 *┌───────────────┐ │ 1┌───────────┐1 *┌───────────────┐ :
├────┤ FListView ├------┤ FListViewItem │ ├────┤ FListView ├------┤ FListViewItem │ :
│ └───────────┘ └───────────────┘ │ └───────────┘ └────────┬──────┘ :
│ ┌─────────────┐ │ ┌─────────────┐ :1 :
├────┤ FScrollView │ ├────┤ FScrollView │ ┌───┴───┐1 :
│ └─────────────┘ │ └─────────────┘ │ FData ├----┘
│ └───────┘
│ ┌────────────┐1 *┌────────────┐ │ ┌────────────┐1 *┌────────────┐
│ ┌──┤ FStatusBar ├-----┤ FStatusKey │ │ ┌──┤ FStatusBar ├-----┤ FStatusKey │
│ │ └────────────┘ └────────────┘ │ │ └────────────┘ └────────────┘

View File

@ -1,7 +1,10 @@
══════════════════════════════════════════════════════════════════════════════ ══════════════════════════════════════════════════════════════════════════════
Class digramm Class digramm
══════════════════════════════════════════════════════════════════════════════ ══════════════════════════════════════════════════════════════════════════════
1┌──────────────┐ 1┌────────────┐
┌-----------┤ FTermLinux │
: └────────────┘
: 1┌──────────────┐
┌-----------┤ FTermFreeBSD │ ┌-----------┤ FTermFreeBSD │
: └──────────────┘ : └──────────────┘
: 1┌──────────────┐ : 1┌──────────────┐
@ -37,12 +40,15 @@
: 1┌───────────────┐ │ ┌─────────────┐ : 1┌───────────────┐ │ ┌─────────────┐
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
: └───────────────┘ │ └─────────────┘ : └───────────────┘ │ └─────────────┘
: 1┌─────────┐ │ ┌──────┐ ┌─────────┐ : 1┌─────────┐ │ ┌────────────┐1 1┌───────┐
┌-----------┤ FSystem │ │ │ FLog │◄──┤ FLogger │ ┌-----------┤ FSystem │ ├────┤ FUserEvent ├------┤ FData │
: └─────────┘ │ └──┬───┘ └─────────┘ : └─────────┘ │ └────────────┘ └───────┘
: *┌─────────┐ │ :1 : *┌─────────┐ │ ┌──────┐ ┌─────────┐
: ┌--------┤ FString │ │ ┌──┴───────────┐ : ┌--------┤ FString │ │ │ FLog │◄──┤ FLogger │
: : └─────────┘ │ ┌────┤ FApplication │ : : └─────────┘ │ └──┬───┘ └─────────┘
: : *┌───────────────┐ │ :1
: ┌--------┤ FStringStream │ │ ┌──┴───────────┐
: : └───────────────┘ │ ┌────┤ FApplication │
: : *┌────────┐ │ │ └──────────────┘ : : *┌────────┐ │ │ └──────────────┘
: ┌--------┤ FPoint │ │ │ ┌────────┐ : ┌--------┤ FPoint │ │ │ ┌────────┐
: : └────────┘ │ ├────┤ FLabel │ : : └────────┘ │ ├────┤ FLabel │
@ -74,15 +80,16 @@
│ ┌───────────┐1 1┌──────────────────┐ │ ┌───────────┐1 1┌──────────────────┐
├────┤ FComboBox ├------┤ FDropDownListBox │ ├────┤ FComboBox ├------┤ FDropDownListBox │
│ └───────────┘ └──────────────────┘ │ └───────────┘ └──────────────────┘
┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐ ┌─────────────┐1 │ ┌──────────┐1 *┌──────────────┐1
│ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem │ │ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem ├--┐
└─────────────┘ │ └──────────┘ └──────────────┘ └─────────────┘ │ └──────────┘ └──────────────┘ :
│ 1┌───────────┐1 *┌───────────────┐ │ 1┌───────────┐1 *┌───────────────┐ :
├────┤ FListView ├------┤ FListViewItem │ ├────┤ FListView ├------┤ FListViewItem │ :
│ └───────────┘ └───────────────┘ │ └───────────┘ └────────┬──────┘ :
│ ┌─────────────┐ │ ┌─────────────┐ :1 :
├────┤ FScrollView │ ├────┤ FScrollView │ ┌───┴───┐1 :
│ └─────────────┘ │ └─────────────┘ │ FData ├----┘
│ └───────┘
│ ┌────────────┐1 *┌────────────┐ │ ┌────────────┐1 *┌────────────┐
│ ┌──┤ FStatusBar ├-----┤ FStatusKey │ │ ┌──┤ FStatusBar ├-----┤ FStatusKey │
│ │ └────────────┘ └────────────┘ │ │ └────────────┘ └────────────┘

View File

@ -213,6 +213,7 @@ class Calc final : public finalcut::FDialog
// Event handlers // Event handlers
void onKeyPress (finalcut::FKeyEvent*) override; void onKeyPress (finalcut::FKeyEvent*) override;
void onShow (finalcut::FShowEvent*) override;
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
@ -255,7 +256,6 @@ Calc::Calc (FWidget* parent)
mapKeyFunctions(); mapKeyFunctions();
clearInfixOperator(); clearInfixOperator();
std::setlocale(LC_NUMERIC, "C");
for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1)) for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
{ {
@ -357,6 +357,13 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
} }
} }
//----------------------------------------------------------------------
void Calc::onShow (finalcut::FShowEvent*)
{
// Overwrites the initialized value of LC_NUMERIC
std::setlocale(LC_NUMERIC, "C");
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::onClose (finalcut::FCloseEvent* ev) void Calc::onClose (finalcut::FCloseEvent* ev)
{ {

View File

@ -102,8 +102,7 @@ FWidget::~FWidget() // destructor
{ {
processDestroy(); processDestroy();
delCallback(); delCallback();
auto app_object = FApplication::getApplicationObject(); removeQueuedEvent();
app_object->removeQueuedEvent(this);
// unset clicked widget // unset clicked widget
if ( this == getClickedWidget() ) if ( this == getClickedWidget() )
@ -2015,6 +2014,15 @@ void FWidget::destroyColorTheme()
delete theme; delete theme;
} }
//----------------------------------------------------------------------
void FWidget::removeQueuedEvent()
{
auto app_object = FApplication::getApplicationObject();
if ( app_object )
app_object->removeQueuedEvent(this);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setStatusbarText (bool enable) const void FWidget::setStatusbarText (bool enable) const
{ {

View File

@ -40,9 +40,9 @@
* *
* *
* *
* * 1 * * 1
* FCheckMenuItem - - - - - FMenu * FCheckMenuItem - - - - FMenu
* *
*/ */
#ifndef FCHECKMENUITEM_H #ifndef FCHECKMENUITEM_H

View File

@ -47,6 +47,7 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include "final/fdata.h"
#include "final/flineedit.h" #include "final/flineedit.h"
#include "final/flistbox.h" #include "final/flistbox.h"
#include "final/fwidget.h" #include "final/fwidget.h"

View File

@ -42,10 +42,11 @@
#include <utility> #include <utility>
#include "final/fstring.h"
namespace finalcut namespace finalcut
{ {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// struct FDataAccess // struct FDataAccess
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -56,12 +57,23 @@ class FData; // Class forward declaration
class FDataAccess class FDataAccess
{ {
public: public:
// Destructor
virtual ~FDataAccess()
{ }
// Accessors
virtual const FString getClassName() const
{
return "FDataAccess";
}
template <typename T> template <typename T>
const T& get() const const T& get() const
{ {
return static_cast<const FData<T>&>(*this).get(); return static_cast<const FData<T>&>(*this).get();
} }
// Mutator
template <typename T template <typename T
, typename V> , typename V>
void set (const V& v) void set (const V& v)
@ -79,6 +91,7 @@ template <typename T>
class FData : public FDataAccess class FData : public FDataAccess
{ {
public: public:
// Constructors
explicit FData (T& v) // constructor explicit FData (T& v) // constructor
: value_ref{v} : value_ref{v}
{ } { }
@ -88,6 +101,7 @@ class FData : public FDataAccess
, value_ref{value} , value_ref{value}
{ } { }
// Overloaded operators
T operator () () const T operator () () const
{ {
return value_ref; return value_ref;
@ -104,16 +118,30 @@ class FData : public FDataAccess
return value_ref; return value_ref;
} }
FData& operator << (const T& v)
{
value_ref = v;
return *this;
}
// Accessors
const FString getClassName() const override
{
return "FData";
}
T& get() T& get()
{ {
return value_ref; return value_ref;
} }
// Mutator
void set (const T& v) void set (const T& v)
{ {
value_ref = v; value_ref = v;
} }
// Inquiries
bool isInitializedCopy() bool isInitializedCopy()
{ {
return bool(value); return bool(value);
@ -124,12 +152,7 @@ class FData : public FDataAccess
return ! isInitializedCopy(); return ! isInitializedCopy();
} }
FData& operator << (const T& v) // Friend Non-member operator functions
{
value_ref = v;
return *this;
}
friend std::ostream& operator << (std::ostream &os, const FData& data) friend std::ostream& operator << (std::ostream &os, const FData& data)
{ {
os << data.value_ref; os << data.value_ref;
@ -142,7 +165,6 @@ class FData : public FDataAccess
T& value_ref; T& value_ref;
}; };
// non-member functions // non-member functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
namespace internal namespace internal

View File

@ -68,9 +68,9 @@
* FTimerEvent * FTimerEvent
* *
* *
* * 1 1
* FUserEvent * FUserEvent - - - - FData
* *
*/ */
#ifndef FEVENT_H #ifndef FEVENT_H
@ -81,6 +81,7 @@
#endif #endif
#include "final/fc.h" #include "final/fc.h"
#include "final/fdata.h"
#include "final/fpoint.h" #include "final/fpoint.h"
#include "final/ftypes.h" #include "final/ftypes.h"

View File

@ -34,6 +34,7 @@
#include <final/fbutton.h> #include <final/fbutton.h>
#include <final/fbusyindicator.h> #include <final/fbusyindicator.h>
#include <final/fc.h> #include <final/fc.h>
#include <final/fdata.h>
#include <final/fobject.h> #include <final/fobject.h>
#include <final/fcolorpalette.h> #include <final/fcolorpalette.h>
#include <final/fcolorpair.h> #include <final/fcolorpair.h>

View File

@ -35,9 +35,9 @@
* *
* *
* *
* 1 * * 1 *1 1
* FListBox - - - - FListBoxItem * FListBox - - - - FListBoxItem - - - - FData
* *
* *
*/ */
@ -51,6 +51,7 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "final/fdata.h"
#include "final/fscrollbar.h" #include "final/fscrollbar.h"
#include "final/fwidget.h" #include "final/fwidget.h"

View File

@ -35,9 +35,9 @@
* *
* *
* *
* 1 * * 1 *1 1
* FListView - - - - FListViewItem * FListView - - - - FListViewItem - - - - FData
* *
*/ */
#ifndef FLISTVIEW_H #ifndef FLISTVIEW_H
@ -52,6 +52,7 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "final/fdata.h"
#include "final/fscrollbar.h" #include "final/fscrollbar.h"
#include "final/ftermbuffer.h" #include "final/ftermbuffer.h"
#include "final/ftypes.h" #include "final/ftypes.h"

View File

@ -36,8 +36,6 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <final/fdata.h>
#define null nullptr #define null nullptr
#define badAllocOutput(object_name) \ #define badAllocOutput(object_name) \

View File

@ -452,6 +452,7 @@ class FWidget : public FVTerm, public FObject
static bool isDefaultTheme(); static bool isDefaultTheme();
static void initColorTheme(); static void initColorTheme();
void destroyColorTheme(); void destroyColorTheme();
void removeQueuedEvent();
void setStatusbarText (bool) const; void setStatusbarText (bool) const;
// Data members // Data members

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* callback-test.cpp - FCallback unit tests * * fcallback-test.cpp - FCallback unit tests *
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *

98
test/fdata-test.cpp Normal file
View File

@ -0,0 +1,98 @@
/***********************************************************************
* fdata-test.cpp - FCallback unit tests *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2020 Markus Gans *
* *
* 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. *
* *
* 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/>. *
***********************************************************************/
#include <utility>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestFixture.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <final/final.h>
//----------------------------------------------------------------------
// functions
//----------------------------------------------------------------------
/*void cb_function_ptr (int* value)
{
(*value)++;
}
//----------------------------------------------------------------------
void cb_function_ref (int& value)
{
value += 2;
}*/
//----------------------------------------------------------------------
// class FDataTest
//----------------------------------------------------------------------
class FDataTest : public CPPUNIT_NS::TestFixture
{
public:
FDataTest()
{ }
protected:
void classNameTest();
void dataTest();
private:
// Adds code needed to register the test suite
CPPUNIT_TEST_SUITE (FDataTest);
// Add a methods to the test suite
CPPUNIT_TEST (classNameTest);
CPPUNIT_TEST (dataTest);
// End of test suite definition
CPPUNIT_TEST_SUITE_END();
// Data member
static finalcut::FWidget root_widget;
};
// static class attributes
finalcut::FWidget FDataTest::root_widget{nullptr};
//----------------------------------------------------------------------
void FDataTest::classNameTest()
{
const finalcut::FCallback d;
const finalcut::FString& classname = d.getClassName();
CPPUNIT_ASSERT ( classname == "FData" );
}
//----------------------------------------------------------------------
void FDataTest::dataTest()
{
}
// Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION (FDataTest);
// The general unit test main part
#include <main-test.inc>