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

View File

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

View File

@ -213,6 +213,7 @@ class Calc final : public finalcut::FDialog
// Event handlers
void onKeyPress (finalcut::FKeyEvent*) override;
void onShow (finalcut::FShowEvent*) override;
void onClose (finalcut::FCloseEvent*) override;
// Callback method
@ -255,7 +256,6 @@ Calc::Calc (FWidget* parent)
mapKeyFunctions();
clearInfixOperator();
std::setlocale(LC_NUMERIC, "C");
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)
{

View File

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

View File

@ -41,7 +41,7 @@
*
*
* * 1
* FCheckMenuItem - - - - - FMenu
* FCheckMenuItem - - - - FMenu
*
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -452,6 +452,7 @@ class FWidget : public FVTerm, public FObject
static bool isDefaultTheme();
static void initColorTheme();
void destroyColorTheme();
void removeQueuedEvent();
void setStatusbarText (bool) const;
// 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 *
* *

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>