Small code and text changes

This commit is contained in:
Markus Gans 2020-08-23 00:32:41 +02:00
parent 2b33c1875a
commit b9042d5a03
61 changed files with 1090 additions and 851 deletions

View File

@ -510,7 +510,7 @@ clicked by a keyboard or mouse, it sends the string "clicked". A signal
handler explicitly provided by Widget, in the form of a callback function
or a callback method, can react to such a signal.
A callback function has no return value can have various arguments:
A callback function has no return value and can have various arguments:
```cpp
void cb_function (FWidget* w, int* i, double* d, ...)
@ -527,29 +527,137 @@ void classname::cb_methode (FWidget* w, int* i, double* d, ...)
We use the `addCallback()` method of the `FWidget` class to connect
to other widget objects.
For calling functions and static methods:
(1) For calling functions or static methods via a pointer:
```cpp
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, FCallback cb_handler
, FDataPtr data )
, Function&& cb_function
, Args&&... args)
{...}
```
For calling a member method of a specific instance:
(2) For calling functions or static methods via a reference:
```cpp
template<typename Function
, typename FunctionReference<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, FWidget* cb_instance
, FMemberCallback cb_handler
, FDataPtr data )
, Function& cb_function
, Args&&... args)
{...}
```
There are two macros `F_FUNCTION_CALLBACK` and `F_METHOD_CALLBACK` to avoid
having to deal with necessary type conversions. With `delCallback()` you can
remove a connection to a signal handler or a widget. Alternatively, you can
use `delAllCallbacks()` to remove all existing callbacks from an object.
(3) For calling a member method of a specific instance:
```cpp
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename MemberFunctionPointer<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args)
{...}
```
(4) For calling a std::bind call wrapper or a lambda expression:
```cpp
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{...}
```
(5) For calling a std::bind call wrapper to a specific instance:
```cpp
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args)
{...}
```
(6) For calling a lambda function that has been stored in a variable
with the keyword auto:
```cpp
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{...}
```
With `delCallback(...)` you can remove a connection to a signal handler
or a widget instance. Alternatively, you can use `delCallbacks()` to
remove all existing callbacks from an object.
To delete functions or static methods callbacks via a pointer:(4)
```cpp
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
{...}
```
To delete functions or static methods callbacks via a reference:(5)
```cpp
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void FWidget::delCallback (Function& cb_function)
{...}
```
To delete all callbacks from a specific instance:(1)
```cpp
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void FWidget::delCallback (Object&& cb_instance)
{...}
```
To delete all callbacks of a signal:(2)
```cpp
void delCallback (const FString& cb_signal)
{...}
```
To delete all callbacks of a signal and specific instance:(3)
```cpp
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance)
{...}
```
To delete all callbacks from a widget:(6)
```cpp
void delCallback()
{...}
```
### The FINAL CUT widgets emit the following default signals ###

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <iomanip>
#include <memory>
#include <string>
#include <final/final.h>

View File

@ -28,7 +28,10 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using namespace std::chrono;
using std::chrono::duration_cast;
using std::chrono::milliseconds;
using std::chrono::system_clock;
using std::chrono::time_point;
using finalcut::FPoint;
using finalcut::FSize;

View File

@ -32,7 +32,7 @@ namespace fc = finalcut::fc;
void tcapBoolean (const std::string&, bool);
void tcapNumeric (const std::string&, int);
void tcapString (const std::string&, const char[]);
void debug (finalcut::FApplication&);
void debug (const finalcut::FApplication&);
void booleans();
void numeric();
void string();
@ -207,7 +207,7 @@ void tcapString (const std::string& name, const char cap_str[])
//----------------------------------------------------------------------
#if DEBUG
void debug (finalcut::FApplication& TermApp)
void debug (const finalcut::FApplication& TermApp)
{
const auto& fterm = TermApp.getFTerm();
auto& debug_data = fterm.getFTermDebugData();

View File

@ -103,7 +103,6 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
//progressBar.setPercentage(78);
using namespace std::placeholders;
reset.addCallback
(
"clicked",
@ -293,7 +292,7 @@ class MyDialog final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override;
// Callback methods
void cb_noFunctionMsg (finalcut::FButton&);
void cb_noFunctionMsg (const finalcut::FButton&);
void cb_about();
void cb_terminfo();
void cb_drives();
@ -311,7 +310,7 @@ class MyDialog final : public finalcut::FDialog
void cb_activateButton ( const finalcut::FRadioButton&
, finalcut::FButton& ) const;
void cb_view (const finalcut::FMenuItem*);
void cb_setInput (finalcut::FListBox&, finalcut::FLineEdit&) const;
void cb_setInput (const finalcut::FListBox&, finalcut::FLineEdit&) const;
// Data members
bool initialized{false};
@ -805,7 +804,7 @@ void MyDialog::onClose (finalcut::FCloseEvent* ev)
}
//----------------------------------------------------------------------
void MyDialog::cb_noFunctionMsg (finalcut::FButton& button)
void MyDialog::cb_noFunctionMsg (const finalcut::FButton& button)
{
auto text = button.getText();
text = text.replace('&', "");
@ -1033,7 +1032,7 @@ void MyDialog::cb_view (const finalcut::FMenuItem* item)
}
//----------------------------------------------------------------------
void MyDialog::cb_setInput ( finalcut::FListBox& listbox
void MyDialog::cb_setInput ( const finalcut::FListBox& listbox
, finalcut::FLineEdit& lineedit) const
{
lineedit = listbox.getItem(listbox.currentItem()).getText();

View File

@ -20,7 +20,9 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include <vector>
#include <final/final.h>
namespace fc = finalcut::fc;

View File

@ -38,5 +38,52 @@ FCallback::FCallback()
FCallback::~FCallback() // destructor
{ }
// public methods of FCallback
//----------------------------------------------------------------------
void FCallback::delCallback (const FString& cb_signal)
{
// Deletes entries with the given signal from the callback list
if ( callback_objects.empty() )
return;
auto iter = callback_objects.begin();
while ( iter != callback_objects.end() )
{
if ( iter->cb_signal == cb_signal )
iter = callback_objects.erase(iter);
else
++iter;
}
}
//----------------------------------------------------------------------
void FCallback::delCallback()
{
// Delete all callbacks from this widget
callback_objects.clear(); // function pointer
}
//----------------------------------------------------------------------
void FCallback::emitCallback (const FString& emit_signal) const
{
// Initiate callback for the given signal
if ( callback_objects.empty() )
return;
for (auto&& cback : callback_objects)
{
if ( cback.cb_signal == emit_signal )
{
// Calling the stored function pointer
cback.cb_function();
}
}
}
} // namespace finalcut

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <memory>
#include "final/fapplication.h"
#include "final/fcolorpair.h"
#include "final/fcombobox.h"

View File

@ -235,7 +235,7 @@ void FFocusEvent::ignore()
// class FAccelEvent
//----------------------------------------------------------------------
FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor
FAccelEvent::FAccelEvent (fc::events ev_type, FWidget* focused) // constructor
: FEvent{ev_type}
, focus_widget{focused}
{ }
@ -245,7 +245,7 @@ FAccelEvent::~FAccelEvent() // destructor
{ }
//----------------------------------------------------------------------
void* FAccelEvent::focusedWidget() const
FWidget* FAccelEvent::focusedWidget() const
{ return focus_widget; }
//----------------------------------------------------------------------

View File

@ -644,7 +644,7 @@ void FListBox::adjustSize()
// private methods of FListBox
//----------------------------------------------------------------------
inline FString& FListBox::getString (listBoxItems::iterator iter)
inline FString FListBox::getString (listBoxItems::iterator iter)
{
return iter->getText();
}

View File

@ -24,8 +24,10 @@
#include <strings.h> // need for strcasecmp
#endif
#include <limits>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include "final/emptyfstring.h"

View File

@ -45,7 +45,7 @@ FLog::~FLog() // destructor
//----------------------------------------------------------------------
FLog& FLog::operator << (LogLevel l)
{
using namespace std::placeholders;
using std::placeholders::_1;
sync();
switch ( l )

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <string>
#include "final/flogger.h"
namespace finalcut

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <memory>
#include <utility>
#include "final/fapplication.h"
#include "final/fdialog.h"

View File

@ -20,12 +20,13 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <new>
#include <stdio.h>
#include <unistd.h>
#include "final/fconfig.h"
#include "final/fkeyboard.h"
@ -843,7 +844,8 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
}
//----------------------------------------------------------------------
void FMouseSGR::setPressedButtonState (const int btn, const struct timeval* time)
void FMouseSGR::setPressedButtonState ( const int btn
, const struct timeval* time )
{
// Gets the extended x11 mouse mode (SGR) status for pressed buttons

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include "final/fpoint.h"
namespace finalcut

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include "final/fc.h"
#include "final/fradiomenuitem.h"
#include "final/fmenu.h"

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <algorithm>
#include <utility>
#include "final/fpoint.h"
#include "final/frect.h"

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <limits>
#include <utility>
#include "final/fpoint.h"
#include "final/fsize.h"

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include "final/fstring.h"
#include "final/fstringstream.h"

View File

@ -25,7 +25,9 @@
#endif
#include <algorithm>
#include <limits>
#include <numeric>
#include <utility>
#include "final/fapplication.h"
#include "final/fcharmap.h"

View File

@ -35,6 +35,7 @@
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
#endif

View File

@ -32,6 +32,7 @@
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
#endif

View File

@ -41,6 +41,7 @@
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}

View File

@ -159,8 +159,9 @@ void FToolTip::calculateDimensions()
int x{};
int y{};
const std::size_t h = ( hasBorder() ) ? text_num_lines + 2 : text_num_lines;
const std::size_t w = ( hasBorder() ) ? max_line_width + 4 : max_line_width + 2;
bool border = hasBorder();
const std::size_t h = ( border ) ? text_num_lines + 2 : text_num_lines;
const std::size_t w = ( border ) ? max_line_width + 4 : max_line_width + 2;
const auto& r = getRootWidget();
if ( r )

View File

@ -252,7 +252,7 @@ void FVTerm::putVTerm()
}
//----------------------------------------------------------------------
void FVTerm::updateTerminal()
void FVTerm::updateTerminal() const
{
// Updates pending changes to the terminal
@ -655,7 +655,7 @@ void FVTerm::flush()
while ( ! output_buffer->empty() )
{
const static FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
static const FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
FTermPutchar (output_buffer->front());
output_buffer->pop();
}

View File

@ -78,7 +78,7 @@ class FButton : public FWidget
// Accessors
const FString getClassName() const override;
FString& getText();
FString getText() const;
// Mutators
void setForegroundColor (FColor) override;
@ -178,7 +178,7 @@ inline const FString FButton::getClassName() const
{ return "FButton"; }
//----------------------------------------------------------------------
inline FString& FButton::getText()
inline FString FButton::getText() const
{ return text; }
//----------------------------------------------------------------------

View File

@ -35,6 +35,9 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <utility>
#include <vector>
#include "final/fstring.h"
#include "final/ftypes.h"
@ -64,7 +67,7 @@ struct FCallbackData
{ }
FCallbackData (const FCallbackData&) = default;
FCallbackData (FCallbackData&&) noexcept = default;
FCallbackData (FCallbackData&&) = default;
FCallbackData& operator = (const FCallbackData&) = default;
FCallbackData& operator = (FCallbackData&&) noexcept = default;
@ -144,15 +147,8 @@ class FCallback
FCallback& operator = (const FCallback&) = delete;
// Accessors
const FString getClassName() const
{
return "FCallback";
}
std::size_t getCallbackCount() const
{
return callback_objects.size();
}
const FString getClassName() const;
std::size_t getCallbackCount() const;
// Methods
template<typename Object
@ -161,6 +157,82 @@ class FCallback
, typename MemberFunctionPointer<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args);
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args);
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args);
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args);
template<typename Function
, typename FunctionReference<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args);
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args);
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (Object&& cb_instance);
void delCallback (const FString& cb_signal);
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance);
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void delCallback (FunctionPtr&& cb_func_ptr);
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void delCallback (const Function& cb_function);
void delCallback();
void emitCallback (const FString& emit_signal) const;
private:
// Typedefs
typedef std::vector<FCallbackData> FCallbackObjects;
// Data members
FCallbackObjects callback_objects{};
};
// FCallback inline functions
//----------------------------------------------------------------------
inline const FString FCallback::getClassName() const
{ return "FCallback"; }
//----------------------------------------------------------------------
inline std::size_t FCallback::getCallbackCount() const
{ return callback_objects.size(); }
//----------------------------------------------------------------------
template<typename Object
, typename Function
, typename FCallback::ObjectPointer<Object>::type
, typename FCallback::MemberFunctionPointer<Function>::type
, typename... Args>
inline void FCallback::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args)
@ -175,12 +247,13 @@ class FCallback
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename ClassObject<Function>::type = nullptr
, typename FCallback::ObjectPointer<Object>::type
, typename FCallback::ClassObject<Function>::type
, typename... Args>
void addCallback ( const FString& cb_signal
inline void FCallback::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args)
@ -192,10 +265,11 @@ class FCallback
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename FCallback::ClassObject<Function>::type
, typename... Args>
void addCallback ( const FString& cb_signal
inline void FCallback::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{
@ -207,14 +281,30 @@ class FCallback
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Function
, typename FunctionReference<Function>::type = nullptr
, typename FCallback::ClassObject<Function>::type
, typename... Args>
void addCallback ( const FString& cb_signal
inline void FCallback::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{
// Add a function as callback
// Add a function object reference as callback
auto fn = std::bind (cb_function, std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, nullptr, nullptr, fn };
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Function
, typename FCallback::FunctionReference<Function>::type
, typename... Args>
inline void FCallback::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{
// Add a function reference as callback
auto ptr = reinterpret_cast<void*>(&cb_function);
auto fn = std::bind (cb_function, std::forward<Args>(args)...);
@ -222,10 +312,11 @@ class FCallback
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
, typename FCallback::FunctionPointer<Function>::type
, typename... Args>
void addCallback ( const FString& cb_signal
inline void FCallback::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{
@ -238,23 +329,10 @@ class FCallback
callback_objects.push_back(obj);
}
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{
// Add a non-union class type as callback
auto fn = std::bind (cb_function, std::forward<Args>(args)...);
FCallbackData obj{ cb_signal, nullptr, nullptr, fn };
callback_objects.push_back(obj);
}
//----------------------------------------------------------------------
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (Object&& cb_instance)
, typename FCallback::ObjectPointer<Object>::type>
inline void FCallback::delCallback (Object&& cb_instance)
{
// Deletes entries with the given instance from the callback list
@ -272,27 +350,10 @@ class FCallback
}
}
void delCallback (const FString& cb_signal)
{
// Deletes entries with the given signal from the callback list
if ( callback_objects.empty() )
return;
auto iter = callback_objects.begin();
while ( iter != callback_objects.end() )
{
if ( iter->cb_signal == cb_signal )
iter = callback_objects.erase(iter);
else
++iter;
}
}
//----------------------------------------------------------------------
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance)
, typename FCallback::ObjectPointer<Object>::type>
inline void FCallback::delCallback (const FString& cb_signal, Object&& cb_instance)
{
// Deletes entries with the given signal and instance
// from the callback list
@ -312,9 +373,10 @@ class FCallback
}
}
//----------------------------------------------------------------------
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void delCallback (FunctionPtr&& cb_func_ptr)
, typename FCallback::FunctionPointer<FunctionPtr>::type>
inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr)
{
// Deletes entries with the given function pointer
// from the callback list
@ -334,11 +396,13 @@ class FCallback
}
}
//----------------------------------------------------------------------
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void delCallback (Function& cb_function)
, typename FCallback::FunctionReference<Function>::type>
inline void FCallback::delCallback (const Function& cb_function)
{
// Deletes entries with the given function from the callback list
// Deletes entries with the given function reference
// from the callback list
if ( callback_objects.empty() )
return;
@ -355,39 +419,6 @@ class FCallback
}
}
void delCallback()
{
// Delete all callbacks from this widget
callback_objects.clear(); // function pointer
}
void emitCallback (const FString& emit_signal) const
{
// Initiate callback for the given signal
if ( callback_objects.empty() )
return;
for (auto&& cback : callback_objects)
{
if ( cback.cb_signal == emit_signal )
{
// Calling the stored function pointer
cback.cb_function();
}
}
}
private:
// Typedefs
typedef std::vector<FCallbackData> FCallbackObjects;
// Data members
FCallbackObjects callback_objects{};
};
} // namespace finalcut
#endif // FCALLBACK_H

View File

@ -27,6 +27,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <utility>
template<typename T>
struct FData
{

View File

@ -194,7 +194,8 @@ class FDialog : public FWindow
void leaveZoomButton (const mouseStates&);
void pressZoomButton (const mouseStates&);
bool isMouseOverMenu (const FPoint&) const;
void passEventToSubMenu (const mouseStates&, const FMouseEvent*);
void passEventToSubMenu ( const mouseStates&
, const FMouseEvent* );
void moveSizeKey (FKeyEvent*);
void raiseActivateDialog();
void lowerActivateDialog();

View File

@ -218,24 +218,25 @@ class FFocusEvent : public FEvent // focus event
//----------------------------------------------------------------------
// class FAccelEvent
//----------------------------------------------------------------------
class FWidget; // class forward declaration
class FAccelEvent : public FEvent // focus event
{
public:
FAccelEvent() = default;
FAccelEvent (fc::events, void*);
FAccelEvent (fc::events, FWidget*);
FAccelEvent (const FAccelEvent&) = delete;
~FAccelEvent();
FAccelEvent& operator = (const FAccelEvent&) = delete;
void* focusedWidget() const;
FWidget* focusedWidget() const;
bool isAccepted() const;
void accept();
void ignore();
private:
bool accpt{false};
void* focus_widget{};
FWidget* focus_widget{};
};

View File

@ -82,7 +82,7 @@ class FListBoxItem
// Accessors
virtual const FString getClassName() const;
virtual FString& getText();
virtual FString getText() const;
virtual FDataPtr getData() const;
// Mutators
@ -110,7 +110,7 @@ inline const FString FListBoxItem::getClassName() const
{ return "FListBoxItem"; }
//----------------------------------------------------------------------
inline FString& FListBoxItem::getText()
inline FString FListBoxItem::getText() const
{ return text; }
//----------------------------------------------------------------------
@ -247,7 +247,7 @@ class FListBox : public FWidget
};
// Accessors
static FString& getString (listBoxItems::iterator);
static FString getString (listBoxItems::iterator);
// Inquiry
bool isHorizontallyScrollable() const;

View File

@ -49,6 +49,7 @@
#include <list>
#include <stack>
#include <unordered_map>
#include <vector>
#include "final/fscrollbar.h"

View File

@ -54,6 +54,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <tuple>
#include "final/fwindow.h"
#include "final/fmenulist.h"

View File

@ -36,6 +36,7 @@
#endif
#include <iostream>
#include <utility>
#include "final/fstring.h"

View File

@ -40,6 +40,7 @@
#endif
#include <algorithm>
#include <utility>
#include "final/fstring.h"

View File

@ -188,7 +188,6 @@ void initScrollbar ( FScrollbarPtr& bar
return;
}
using namespace std::placeholders;
bar->setMinimum(0);
bar->setValue(0);
bar->hide();

View File

@ -37,6 +37,7 @@
#include <limits>
#include <iostream>
#include <utility>
#include "final/fstring.h"
#include "final/ftypes.h"

View File

@ -47,6 +47,8 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <limits>
#include "final/fwidget.h"
namespace finalcut

View File

@ -166,7 +166,7 @@ class FTerm final
typedef FColorPalette::FSetPalette FSetPalette;
// Constructor
explicit FTerm();
FTerm();
// Disable copy constructor
FTerm (const FTerm&) = delete;

View File

@ -35,6 +35,7 @@
#error "Only <final/final.h> can be included directly."
#endif
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

View File

@ -56,6 +56,7 @@
#endif
#include <string>
#include <utility>
#include <vector>
// FTermcap string macro

View File

@ -118,7 +118,7 @@ class FVTerm
};
// Constructor
explicit FVTerm();
FVTerm();
// Disable copy constructor
FVTerm (const FVTerm&) = delete;
@ -148,7 +148,7 @@ class FVTerm
const FTermArea* getVWin() const;
const FPoint getPrintCursor();
static const FChar getAttribute();
FTerm& getFTerm();
FTerm& getFTerm() const;
// Mutators
void setTermXY (int, int) const;
@ -253,7 +253,7 @@ class FVTerm
void createVTerm (const FSize&);
void resizeVTerm (const FSize&) const;
void putVTerm();
void updateTerminal();
void updateTerminal() const;
virtual void addPreprocessingHandler ( const FVTerm*
, const FPreprocessingFunction& );
virtual void delPreprocessingHandler (const FVTerm*);
@ -629,7 +629,7 @@ inline const FChar FVTerm::getAttribute()
{ return next_attribute; }
//----------------------------------------------------------------------
inline FTerm& FVTerm::getFTerm()
inline FTerm& FVTerm::getFTerm() const
{ return *fterm; }
//----------------------------------------------------------------------

View File

@ -95,6 +95,7 @@
#endif
#include <functional>
#include <memory>
#include <utility>
#include <vector>

View File

@ -21,6 +21,7 @@
***********************************************************************/
#include <cstring>
#include <vector>
#include "final/fc.h"
#include "final/sgr_optimizer.h"

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <utility>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -121,12 +123,12 @@ class FCallbackTest : public CPPUNIT_NS::TestFixture
protected:
void classNameTest();
void memberFunctionCallbackTest();
void instanceWithFunctionCallbackTest();
void functionObjectTest();
void functionCallbackTest();
void memberFunctionPointerCallbackTest();
void instanceWithFunctionObjectCallbackTest();
void functionObjectCallbackTest();
void functionObjectReferenceCallbackTest();
void functionReferenceCallbackTest();
void functionPointerCallbackTest();
void nonUnionClassCallbackTest();
void ownWidgetTest();
private:
@ -135,12 +137,12 @@ class FCallbackTest : public CPPUNIT_NS::TestFixture
// Add a methods to the test suite
CPPUNIT_TEST (classNameTest);
CPPUNIT_TEST (memberFunctionCallbackTest);
CPPUNIT_TEST (instanceWithFunctionCallbackTest);
CPPUNIT_TEST (functionObjectTest);
CPPUNIT_TEST (functionCallbackTest);
CPPUNIT_TEST (memberFunctionPointerCallbackTest);
CPPUNIT_TEST (instanceWithFunctionObjectCallbackTest);
CPPUNIT_TEST (functionObjectCallbackTest);
CPPUNIT_TEST (functionObjectReferenceCallbackTest);
CPPUNIT_TEST (functionReferenceCallbackTest);
CPPUNIT_TEST (functionPointerCallbackTest);
CPPUNIT_TEST (nonUnionClassCallbackTest);
CPPUNIT_TEST (ownWidgetTest);
// End of test suite definition
@ -162,7 +164,7 @@ void FCallbackTest::classNameTest()
}
//----------------------------------------------------------------------
void FCallbackTest::memberFunctionCallbackTest()
void FCallbackTest::memberFunctionPointerCallbackTest()
{
finalcut::FCallback cb{};
cb_class c{5, &root_widget};
@ -228,7 +230,7 @@ void FCallbackTest::memberFunctionCallbackTest()
}
//----------------------------------------------------------------------
void FCallbackTest::instanceWithFunctionCallbackTest()
void FCallbackTest::instanceWithFunctionObjectCallbackTest()
{
finalcut::FCallback cb{};
cb_class c{15, &root_widget};
@ -317,7 +319,7 @@ void FCallbackTest::instanceWithFunctionCallbackTest()
}
//----------------------------------------------------------------------
void FCallbackTest::functionObjectTest()
void FCallbackTest::functionObjectCallbackTest()
{
finalcut::FCallback cb{};
int i1{2};
@ -377,7 +379,47 @@ void FCallbackTest::functionObjectTest()
}
//----------------------------------------------------------------------
void FCallbackTest::functionCallbackTest()
void FCallbackTest::functionObjectReferenceCallbackTest()
{
finalcut::FCallback cb{};
int i{4};
auto lambda1 = [] (int* value)
{
*value = *value << 8;
};
auto lambda2 = [] (int& value)
{
value = value >> 4;
};
using NonUnionClass = decltype(lambda1);
CPPUNIT_ASSERT ( 0 == std::is_member_function_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<typename std::remove_pointer<NonUnionClass>::type>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_object<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_class<NonUnionClass>::value );
cb.addCallback ("toggled", lambda1, &i);
CPPUNIT_ASSERT ( cb.getCallbackCount() == 1 );
CPPUNIT_ASSERT ( i == 4 );
cb.emitCallback ("toggled");
CPPUNIT_ASSERT ( i == 1024 );
cb.addCallback ("row-selected", lambda2, std::ref(i));
CPPUNIT_ASSERT ( cb.getCallbackCount() == 2 );
CPPUNIT_ASSERT ( i == 1024 );
cb.emitCallback ("row-selected");
CPPUNIT_ASSERT ( i == 64 );
cb.delCallback();
CPPUNIT_ASSERT ( cb.getCallbackCount() == 0 );
}
//----------------------------------------------------------------------
void FCallbackTest::functionReferenceCallbackTest()
{
finalcut::FCallback cb{};
int i1{22};
@ -464,45 +506,6 @@ void FCallbackTest::functionPointerCallbackTest()
}
//----------------------------------------------------------------------
void FCallbackTest::nonUnionClassCallbackTest()
{
finalcut::FCallback cb{};
int i{4};
auto lambda1 = [] (int* value)
{
*value = *value << 8;
};
auto lambda2 = [] (int& value)
{
value = value >> 4;
};
using NonUnionClass = decltype(lambda1);
CPPUNIT_ASSERT ( 0 == std::is_member_function_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<typename std::remove_pointer<NonUnionClass>::type>::value );
CPPUNIT_ASSERT ( 0 == std::is_function<NonUnionClass>::value );
CPPUNIT_ASSERT ( 0 == std::is_pointer<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_object<NonUnionClass>::value );
CPPUNIT_ASSERT ( 1 == std::is_class<NonUnionClass>::value );
cb.addCallback ("toggled", lambda1, &i);
CPPUNIT_ASSERT ( cb.getCallbackCount() == 1 );
CPPUNIT_ASSERT ( i == 4 );
cb.emitCallback ("toggled");
CPPUNIT_ASSERT ( i == 1024 );
cb.addCallback ("row-selected", lambda2, std::ref(i));
CPPUNIT_ASSERT ( cb.getCallbackCount() == 2 );
CPPUNIT_ASSERT ( i == 1024 );
cb.emitCallback ("row-selected");
CPPUNIT_ASSERT ( i == 64 );
cb.delCallback();
CPPUNIT_ASSERT ( cb.getCallbackCount() == 0 );
}
void FCallbackTest::ownWidgetTest()
{
Widget w;

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,7 +30,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <string>
#include <final/final.h>
namespace test

View File

@ -20,6 +20,10 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <memory>
#include <sstream>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,8 +32,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <sstream>
#include <final/final.h>
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2019 Markus Gans *
* Copyright 2018-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 *
@ -20,6 +20,9 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <iomanip>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -27,12 +30,9 @@
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/SourceLine.h>
#include <cppunit/TestAssert.h>
#include <iomanip>
#include <string>
#include <final/final.h>

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2019 Markus Gans *
* Copyright 2018-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 *
@ -20,6 +20,9 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <iomanip>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -27,12 +30,9 @@
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/SourceLine.h>
#include <cppunit/TestAssert.h>
#include <iomanip>
#include <string>
#include <final/final.h>

View File

@ -328,7 +328,6 @@ void FPointTest::moveTest()
p1.move (-2, -7);
CPPUNIT_ASSERT ( p1.getX() == 4 );
CPPUNIT_ASSERT ( p1.getY() == -1 );
}
//----------------------------------------------------------------------

View File

@ -28,6 +28,7 @@
#include <clocale>
#include <iomanip>
#include <string>
#include <utility>
#include <vector>
#include <cppunit/BriefTestProgressListener.h>

View File

@ -20,6 +20,10 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <sstream>
#include <string>
#include <utility>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,8 +32,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <sstream>
#include <final/final.h>
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2019 Markus Gans *
* Copyright 2018-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 *
@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -28,7 +30,6 @@
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <string>
#include <final/final.h>
#define CPPUNIT_ASSERT_CSTRING(expected, actual) \

View File

@ -20,6 +20,11 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <unistd.h>
#include <limits>
#include <string>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/HelperMacros.h>
@ -27,10 +32,6 @@
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <unistd.h>
#include <limits>
#include <string>
#include "conemu.h"
#include <final/final.h>