FDataPtr was replaced by the template class FData
This commit is contained in:
parent
ff555baf3b
commit
5092244b81
|
@ -1,3 +1,7 @@
|
||||||
|
2020-09-18 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* The generic data type FDataPtr is now deprecated and was
|
||||||
|
completely replaced by the template class FData
|
||||||
|
|
||||||
2020-09-11 Markus Gans <guru.mail@muenster.de>
|
2020-09-11 Markus Gans <guru.mail@muenster.de>
|
||||||
* Fixes a problem with mouse input in Cygwin in non-blocking read mode
|
* Fixes a problem with mouse input in Cygwin in non-blocking read mode
|
||||||
|
|
||||||
|
|
|
@ -431,7 +431,7 @@ class extendedApplication : public FApplication
|
||||||
|| last_avg[2] != load_avg[2] )
|
|| last_avg[2] != load_avg[2] )
|
||||||
{
|
{
|
||||||
FUserEvent user_event(fc::User_Event, 0);
|
FUserEvent user_event(fc::User_Event, 0);
|
||||||
user_event.setData (FDataPtr(&load_avg));
|
user_event.setData (load_avg);
|
||||||
FApplication::sendEvent (getMainWidget(), &user_event);
|
FApplication::sendEvent (getMainWidget(), &user_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,8 +458,7 @@ class dialogWidget final : public FDialog
|
||||||
private:
|
private:
|
||||||
void onUserEvent (FUserEvent* ev) override
|
void onUserEvent (FUserEvent* ev) override
|
||||||
{
|
{
|
||||||
FDataPtr dataPtr = ev->getData();
|
const auto& lavg = ev->getData<LoadAvg>();
|
||||||
auto& lavg = *(reinterpret_cast<LoadAvg*>(dataPtr));
|
|
||||||
std::setlocale(LC_NUMERIC, "C");
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
loadavg_label.clear();
|
loadavg_label.clear();
|
||||||
loadavg_label << "Load average: " << lavg[0] << ", "
|
loadavg_label << "Load average: " << lavg[0] << ", "
|
||||||
|
@ -530,9 +529,9 @@ to other widget objects.
|
||||||
1. For calling functions or static methods via a pointer:
|
1. For calling functions or static methods via a pointer:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename FunctionPointer<Function>::type = nullptr
|
, typename FunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -542,9 +541,9 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
2. For calling functions or static methods via a reference:
|
2. For calling functions or static methods via a reference:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr
|
, typename FunctionReference<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -554,11 +553,11 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
3. For calling a member method of a specific instance:
|
3. For calling a member method of a specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename MemberFunctionPointer<Function>::type = nullptr
|
, typename MemberFunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_member
|
, Function&& cb_member
|
||||||
|
@ -568,9 +567,9 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
|
|
||||||
4. For calling a std::bind call wrapper or a lambda expression:
|
4. For calling a std::bind call wrapper or a lambda expression:
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -580,11 +579,11 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
5. For calling a std::bind call wrapper to a specific instance:
|
5. For calling a std::bind call wrapper to a specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
|
@ -596,9 +595,9 @@ void FWidget::addCallback ( const FString& cb_signal
|
||||||
with the keyword auto:
|
with the keyword auto:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args >
|
||||||
void FWidget::addCallback ( const FString& cb_signal
|
void FWidget::addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args)
|
, Args&&... args)
|
||||||
|
@ -612,8 +611,8 @@ remove all existing callbacks from an object.
|
||||||
1. To delete functions or static methods callbacks via a pointer:
|
1. To delete functions or static methods callbacks via a pointer:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename FunctionPtr
|
template< typename FunctionPtr
|
||||||
, typename FunctionPointer<FunctionPtr>::type = nullptr>
|
, typename FunctionPointer<FunctionPtr>::type = nullptr >
|
||||||
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
|
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -621,8 +620,8 @@ void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
|
||||||
2. To delete functions or static methods callbacks via a reference:
|
2. To delete functions or static methods callbacks via a reference:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Function
|
template< typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr>
|
, typename FunctionReference<Function>::type = nullptr >
|
||||||
void FWidget::delCallback (Function& cb_function)
|
void FWidget::delCallback (Function& cb_function)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -630,8 +629,8 @@ void FWidget::delCallback (Function& cb_function)
|
||||||
3. To delete all callbacks from a specific instance:
|
3. To delete all callbacks from a specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr >
|
||||||
void FWidget::delCallback (Object&& cb_instance)
|
void FWidget::delCallback (Object&& cb_instance)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
@ -646,8 +645,8 @@ void delCallback (const FString& cb_signal)
|
||||||
5. To delete all callbacks of a signal and specific instance:
|
5. To delete all callbacks of a signal and specific instance:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename Object
|
template< typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr >
|
||||||
void delCallback (const FString& cb_signal, Object&& cb_instance)
|
void delCallback (const FString& cb_signal, Object&& cb_instance)
|
||||||
{...}
|
{...}
|
||||||
```
|
```
|
||||||
|
|
|
@ -108,8 +108,7 @@ Background::Background (finalcut::FWidget* parent)
|
||||||
|
|
||||||
for (auto& c : color_list)
|
for (auto& c : color_list)
|
||||||
{
|
{
|
||||||
FDataPtr data_ptr = reinterpret_cast<FDataPtr>(&c.second);
|
finalcut::FListBoxItem item (c.first, c.second);
|
||||||
finalcut::FListBoxItem item (c.first, data_ptr);
|
|
||||||
color_choice.insert(item);
|
color_choice.insert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +198,8 @@ void Background::cb_choice()
|
||||||
uChar r{};
|
uChar r{};
|
||||||
uChar g{};
|
uChar g{};
|
||||||
uChar b{};
|
uChar b{};
|
||||||
const FDataPtr data_ptr = color_choice.getItemData();
|
const RGB rgb = color_choice.getItemData<RGB>();
|
||||||
const RGB* rgb = reinterpret_cast<RGB*>(data_ptr);
|
std::tie(r, g, b) = rgb;
|
||||||
std::tie(r, g, b) = *rgb;
|
|
||||||
red.setValue(r);
|
red.setValue(r);
|
||||||
green.setValue(g);
|
green.setValue(g);
|
||||||
blue.setValue(b);
|
blue.setValue(b);
|
||||||
|
|
|
@ -38,8 +38,8 @@ static std::weak_ptr<FString> temp_str;
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void doubleToItem ( FListBoxItem&
|
void doubleToItem ( FListBoxItem&
|
||||||
, FDataPtr container
|
, FDataAccess* container
|
||||||
, int index);
|
, std::size_t index);
|
||||||
FString& doubleToString (std::list<double>::const_iterator iter);
|
FString& doubleToString (std::list<double>::const_iterator iter);
|
||||||
FString& mapToString ( std::map<FString
|
FString& mapToString ( std::map<FString
|
||||||
, FString>::const_iterator iter );
|
, FString>::const_iterator iter );
|
||||||
|
@ -47,14 +47,15 @@ FString& mapToString ( std::map<FString
|
||||||
|
|
||||||
// Lazy conversion insert function
|
// Lazy conversion insert function
|
||||||
void doubleToItem ( FListBoxItem& item
|
void doubleToItem ( FListBoxItem& item
|
||||||
, FDataPtr container, int index)
|
, FDataAccess* container
|
||||||
|
, std::size_t index )
|
||||||
{
|
{
|
||||||
typedef std::list<double>* double_list_ptr;
|
typedef std::list<double> DblList;
|
||||||
double_list_ptr dbllist = static_cast<double_list_ptr>(container);
|
DblList& dbl_list = FListBoxHelper::getContainer<DblList>(container);
|
||||||
std::list<double>::iterator iter = dbllist->begin();
|
std::list<double>::iterator iter = dbl_list.begin();
|
||||||
std::advance (iter, index);
|
std::advance (iter, index);
|
||||||
item.setText (FString() << *iter);
|
item.setText (FString() << *iter);
|
||||||
item.setData (FDataPtr(&(*iter)));
|
item.setData (*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert converter functions
|
// Insert converter functions
|
||||||
|
@ -129,7 +130,7 @@ Listbox::Listbox (FWidget* parent)
|
||||||
//
|
//
|
||||||
// Insert via lazy conversion on print
|
// Insert via lazy conversion on print
|
||||||
//
|
//
|
||||||
list2.insert (&double_list, doubleToItem);
|
list2.insert (double_list, doubleToItem); // (container, converter)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Direct insert of the complete list
|
// Direct insert of the complete list
|
||||||
|
|
|
@ -199,7 +199,9 @@ class Window final : public finalcut::FDialog
|
||||||
void configureDialogButtons();
|
void configureDialogButtons();
|
||||||
void activateWindow (finalcut::FDialog*) const;
|
void activateWindow (finalcut::FDialog*) const;
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
template<typename InstanceT, typename CallbackT, typename... Args>
|
template <typename InstanceT
|
||||||
|
, typename CallbackT
|
||||||
|
, typename... Args>
|
||||||
void addClickedCallback ( finalcut::FWidget*
|
void addClickedCallback ( finalcut::FWidget*
|
||||||
, InstanceT&&, CallbackT&&, Args&&... );
|
, InstanceT&&, CallbackT&&, Args&&... );
|
||||||
template <typename IteratorT>
|
template <typename IteratorT>
|
||||||
|
@ -378,7 +380,9 @@ void Window::adjustSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename InstanceT, typename CallbackT, typename... Args>
|
template <typename InstanceT
|
||||||
|
, typename CallbackT
|
||||||
|
, typename... Args>
|
||||||
void Window::addClickedCallback ( finalcut::FWidget* widget
|
void Window::addClickedCallback ( finalcut::FWidget* widget
|
||||||
, InstanceT&& instance
|
, InstanceT&& instance
|
||||||
, CallbackT&& callback
|
, CallbackT&& callback
|
||||||
|
|
|
@ -10,7 +10,7 @@ function create_code_file ()
|
||||||
echo -e "#define ${INCLUDE_GUARD}\\n"
|
echo -e "#define ${INCLUDE_GUARD}\\n"
|
||||||
echo -e "namespace finalcut\\n{\\n"
|
echo -e "namespace finalcut\\n{\\n"
|
||||||
echo -e "namespace fc\\n{\\n"
|
echo -e "namespace fc\\n{\\n"
|
||||||
echo -e "static unsigned char ${NAME}[] =\\n{"
|
echo -e "constexpr unsigned char ${NAME}[] =\\n{"
|
||||||
|
|
||||||
grep -A"${HEIGHT}" "^BITMAP" "$NEWFONTFILE" \
|
grep -A"${HEIGHT}" "^BITMAP" "$NEWFONTFILE" \
|
||||||
| tr '\n' ',' \
|
| tr '\n' ',' \
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char __8x16graph[] =
|
constexpr unsigned char __8x16graph[] =
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char __9x16graph[] =
|
constexpr unsigned char __9x16graph[] =
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static struct unipair unicode_cp437_pairs[] =
|
constexpr struct unipair unicode_cp437_pairs[] =
|
||||||
{
|
{
|
||||||
// .----------- unicode
|
// .----------- unicode
|
||||||
// | .---- fontpos
|
// | .---- fontpos
|
||||||
|
@ -306,7 +306,7 @@ static struct unipair unicode_cp437_pairs[] =
|
||||||
{0x266c, 0x0e}
|
{0x266c, 0x0e}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct unipair unicode_newfont_pairs[] =
|
constexpr struct unipair unicode_newfont_pairs[] =
|
||||||
{
|
{
|
||||||
// .----------- unicode
|
// .----------- unicode
|
||||||
// | .---- fontpos
|
// | .---- fontpos
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace finalcut
|
||||||
namespace fc
|
namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
static unsigned char __8x16std[] =
|
constexpr unsigned char __8x16std[] =
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
|
||||||
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */
|
||||||
|
|
|
@ -121,6 +121,12 @@ FApplication* FApplication::getApplicationObject()
|
||||||
return app_object;
|
return app_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
FWidget* FApplication::getKeyboardWidget()
|
||||||
|
{
|
||||||
|
return keyboard_widget;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FApplication::FLogPtr& FApplication::getLog()
|
FApplication::FLogPtr& FApplication::getLog()
|
||||||
{
|
{
|
||||||
|
@ -306,6 +312,12 @@ void FApplication::setDarkTheme()
|
||||||
setColorTheme<default16ColorDarkTheme>();
|
setColorTheme<default16ColorDarkTheme>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FApplication::setKeyboardWidget (FWidget* widget)
|
||||||
|
{
|
||||||
|
keyboard_widget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* This file is part of the FINAL CUT widget toolkit *
|
||||||
* *
|
* *
|
||||||
* Copyright 2015-2019 Markus Gans *
|
* Copyright 2015-2020 Markus Gans *
|
||||||
* *
|
* *
|
||||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -163,7 +163,7 @@ const std::size_t lastCharItem = \
|
||||||
std::size_t((sizeof(character) / sizeof(character[0])) - 1);
|
std::size_t((sizeof(character) / sizeof(character[0])) - 1);
|
||||||
|
|
||||||
|
|
||||||
int vt100_key_to_utf8[][2] =
|
constexpr int vt100_key_to_utf8[][2] =
|
||||||
{
|
{
|
||||||
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
|
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
|
||||||
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
|
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
|
||||||
|
@ -210,7 +210,7 @@ const std::size_t lastKeyItem = \
|
||||||
std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
|
std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
|
||||||
|
|
||||||
|
|
||||||
wchar_t cp437_ucs[][2] =
|
constexpr wchar_t cp437_ucs[][2] =
|
||||||
{
|
{
|
||||||
{0x00, 0x0000}, // null
|
{0x00, 0x0000}, // null
|
||||||
{0x01, 0x263a}, // white smiling face
|
{0x01, 0x263a}, // white smiling face
|
||||||
|
@ -474,7 +474,7 @@ const std::size_t lastCP437Item = \
|
||||||
std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1);
|
std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1);
|
||||||
|
|
||||||
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
||||||
const wchar_t halfWidth_fullWidth[][2] =
|
constexpr wchar_t halfWidth_fullWidth[][2] =
|
||||||
{
|
{
|
||||||
// Fullwidth ASCII variants
|
// Fullwidth ASCII variants
|
||||||
{0x0020, 0x3000}, // ' ' -> ' '
|
{0x0020, 0x3000}, // ' ' -> ' '
|
||||||
|
|
|
@ -366,18 +366,13 @@ FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FUserEvent::~FUserEvent() // destructor
|
FUserEvent::~FUserEvent() // destructor
|
||||||
{ }
|
{
|
||||||
|
if ( ! external_data_pointer && data_pointer )
|
||||||
|
delete data_pointer;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FUserEvent::getUserId() const
|
int FUserEvent::getUserId() const
|
||||||
{ return uid; }
|
{ return uid; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FDataPtr FUserEvent::getData() const
|
|
||||||
{ return data_pointer; }
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FUserEvent::setData (FDataPtr data)
|
|
||||||
{ data_pointer = data; }
|
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -214,7 +214,7 @@ FKeyMap fkey[] =
|
||||||
{ 0 , nullptr, "\0" }
|
{ 0 , nullptr, "\0" }
|
||||||
};
|
};
|
||||||
|
|
||||||
FMetakeyMap fmetakey[] =
|
constexpr FMetakeyMap fmetakey[] =
|
||||||
{
|
{
|
||||||
{ fc::Fmkey_ic , "\033[2;3~" }, // M-insert
|
{ fc::Fmkey_ic , "\033[2;3~" }, // M-insert
|
||||||
{ fc::Fmkey_ic , "\033\033[2~" }, // M-insert
|
{ fc::Fmkey_ic , "\033\033[2~" }, // M-insert
|
||||||
|
@ -447,7 +447,7 @@ FMetakeyMap fmetakey[] =
|
||||||
{ 0 , "\0" }
|
{ 0 , "\0" }
|
||||||
};
|
};
|
||||||
|
|
||||||
FKeyName fkeyname[] =
|
constexpr FKeyName fkeyname[] =
|
||||||
{
|
{
|
||||||
{ fc::Fckey_a , "Ctrl+A" },
|
{ fc::Fckey_a , "Ctrl+A" },
|
||||||
{ fc::Fckey_b , "Ctrl+B" },
|
{ fc::Fckey_b , "Ctrl+B" },
|
||||||
|
|
|
@ -51,12 +51,6 @@ FListBoxItem::FListBoxItem (const FListBoxItem& item)
|
||||||
, selected{item.selected}
|
, selected{item.selected}
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FListBoxItem::FListBoxItem (const FString& txt, FDataPtr data)
|
|
||||||
: text{txt}
|
|
||||||
, data_pointer{data}
|
|
||||||
{ }
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FListBoxItem::~FListBoxItem() // destructor
|
FListBoxItem::~FListBoxItem() // destructor
|
||||||
{ }
|
{ }
|
||||||
|
@ -95,6 +89,9 @@ FListBox::FListBox (FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FListBox::~FListBox() // destructor
|
FListBox::~FListBox() // destructor
|
||||||
{
|
{
|
||||||
|
if ( source_container )
|
||||||
|
delete source_container; // for lazy conversion
|
||||||
|
|
||||||
delOwnTimers();
|
delOwnTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1729,12 +1726,12 @@ void FListBox::changeOnResize() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
|
void FListBox::lazyConvert(listBoxItems::iterator iter, std::size_t y)
|
||||||
{
|
{
|
||||||
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
|
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lazy_inserter (*iter, source_container, y + yoffset);
|
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
||||||
const auto column_width = getColumnWidth(iter->text);
|
const auto column_width = getColumnWidth(iter->text);
|
||||||
recalculateHorizontalBar (column_width, hasBrackets(iter));
|
recalculateHorizontalBar (column_width, hasBrackets(iter));
|
||||||
|
|
||||||
|
|
|
@ -198,21 +198,6 @@ FListViewItem::FListViewItem (iterator parent_iter)
|
||||||
insert (this, parent_iter);
|
insert (this, parent_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FListViewItem::FListViewItem ( const FStringList& cols
|
|
||||||
, FDataPtr data
|
|
||||||
, iterator parent_iter )
|
|
||||||
: FObject{nullptr}
|
|
||||||
, column_list{cols}
|
|
||||||
, data_pointer{data}
|
|
||||||
{
|
|
||||||
if ( cols.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
replaceControlCodes();
|
|
||||||
insert (this, parent_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FListViewItem::~FListViewItem() // destructor
|
FListViewItem::~FListViewItem() // destructor
|
||||||
{
|
{
|
||||||
|
@ -895,33 +880,6 @@ FObject::iterator FListView::insert ( FListViewItem* item
|
||||||
return item_iter;
|
return item_iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
FObject::iterator FListView::insert ( const FStringList& cols
|
|
||||||
, FDataPtr d
|
|
||||||
, iterator parent_iter )
|
|
||||||
{
|
|
||||||
FListViewItem* item;
|
|
||||||
|
|
||||||
if ( cols.empty() || parent_iter == getNullIterator() )
|
|
||||||
return getNullIterator();
|
|
||||||
|
|
||||||
if ( ! *parent_iter )
|
|
||||||
parent_iter = root;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
item = new FListViewItem (cols, d, getNullIterator());
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FListViewItem");
|
|
||||||
return getNullIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
item->replaceControlCodes();
|
|
||||||
return insert(item, parent_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::remove (FListViewItem* item)
|
void FListView::remove (FListViewItem* item)
|
||||||
{
|
{
|
||||||
|
|
|
@ -605,47 +605,42 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
|
||||||
while ( iter != getDialogList()->end() && *iter )
|
while ( iter != getDialogList()->end() && *iter )
|
||||||
{
|
{
|
||||||
auto win = static_cast<FDialog*>(*iter);
|
auto win = static_cast<FDialog*>(*iter);
|
||||||
|
FMenuItem* win_item{};
|
||||||
|
const uInt32 n = uInt32(std::distance(first, iter));
|
||||||
|
// get the dialog title
|
||||||
|
const auto& name = win->getText();
|
||||||
|
|
||||||
if ( win )
|
try
|
||||||
{
|
{
|
||||||
FMenuItem* win_item{};
|
// create a new dialog list item
|
||||||
const uInt32 n = uInt32(std::distance(first, iter));
|
win_item = new FMenuItem (name, winmenu);
|
||||||
// get the dialog title
|
}
|
||||||
const auto& name = win->getText();
|
catch (const std::bad_alloc&)
|
||||||
|
{
|
||||||
try
|
badAllocOutput ("FMenuItem");
|
||||||
{
|
return;
|
||||||
// create a new dialog list item
|
|
||||||
win_item = new FMenuItem (name, winmenu);
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FMenuItem");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( n < 9 )
|
|
||||||
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
|
|
||||||
|
|
||||||
win_item->addCallback
|
|
||||||
(
|
|
||||||
"clicked",
|
|
||||||
static_cast<std::remove_reference<decltype(win_item)>::type>(win_item),
|
|
||||||
&FMenuItem::cb_switchToDialog,
|
|
||||||
win
|
|
||||||
);
|
|
||||||
|
|
||||||
win->addCallback
|
|
||||||
(
|
|
||||||
"destroy",
|
|
||||||
static_cast<std::remove_reference<decltype(win_item)>::type>(win_item),
|
|
||||||
&FMenuItem::cb_destroyDialog,
|
|
||||||
win
|
|
||||||
);
|
|
||||||
|
|
||||||
win_item->associated_window = win;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( n < 9 )
|
||||||
|
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
|
||||||
|
|
||||||
|
win_item->addCallback
|
||||||
|
(
|
||||||
|
"clicked",
|
||||||
|
static_cast<std::remove_reference<decltype(win_item)>::type>(win_item),
|
||||||
|
&FMenuItem::cb_switchToDialog,
|
||||||
|
win
|
||||||
|
);
|
||||||
|
|
||||||
|
win->addCallback
|
||||||
|
(
|
||||||
|
"destroy",
|
||||||
|
static_cast<std::remove_reference<decltype(win_item)>::type>(win_item),
|
||||||
|
&FMenuItem::cb_destroyDialog,
|
||||||
|
win
|
||||||
|
);
|
||||||
|
|
||||||
|
win_item->associated_window = win;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1212,7 +1212,7 @@ inline void FString::_initLength (std::size_t len)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string = new wchar_t[bufsize]();
|
string = new wchar_t[bufsize];
|
||||||
std::wmemset (string, L'\0', bufsize);
|
std::wmemset (string, L'\0', bufsize);
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
|
@ -1244,7 +1244,7 @@ void FString::_assign (const wchar_t s[])
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string = new wchar_t[bufsize]();
|
string = new wchar_t[bufsize];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1272,7 +1272,7 @@ void FString::_insert (std::size_t len, const wchar_t s[])
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string = new wchar_t[bufsize]();
|
string = new wchar_t[bufsize];
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1319,7 +1319,7 @@ void FString::_insert ( std::size_t pos
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sptr = new wchar_t[bufsize](); // generate new string
|
sptr = new wchar_t[bufsize]; // generate new string
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1363,7 +1363,7 @@ void FString::_remove (std::size_t pos, std::size_t len)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sptr = new wchar_t[bufsize](); // generate new string
|
sptr = new wchar_t[bufsize]; // generate new string
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
|
@ -1417,7 +1417,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
c_string = new char[size]();
|
c_string = new char[size];
|
||||||
|
|
||||||
// pre-initialiaze the whole string with '\0'
|
// pre-initialiaze the whole string with '\0'
|
||||||
std::memset (c_string, '\0', size);
|
std::memset (c_string, '\0', size);
|
||||||
|
@ -1467,7 +1467,7 @@ inline const wchar_t* FString::_to_wcstring (const char s[]) const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dest = new wchar_t[size]();
|
dest = new wchar_t[size];
|
||||||
// pre-initialiaze the whole string with '\0'
|
// pre-initialiaze the whole string with '\0'
|
||||||
std::wmemset (dest, L'\0', size);
|
std::wmemset (dest, L'\0', size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,15 +141,15 @@ void FSwitch::drawCheckButton()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FSwitch::drawChecked()
|
inline void FSwitch::drawChecked()
|
||||||
{
|
{
|
||||||
wchar_t on[6]{L" On "};
|
FString on{L" On "};
|
||||||
const wchar_t off[6]{L" Off "};
|
const FString off{L" Off "};
|
||||||
const auto& wc = getColorTheme();
|
const auto& wc = getColorTheme();
|
||||||
|
|
||||||
if ( hasFocus() && ! button_pressed )
|
if ( hasFocus() && ! button_pressed )
|
||||||
{
|
{
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
{
|
{
|
||||||
std::wcsncpy (on, L" <On>", 6);
|
on.setString(L" <On>");
|
||||||
setBold(true);
|
setBold(true);
|
||||||
}
|
}
|
||||||
else if ( FTerm::getMaxColor() < 16 )
|
else if ( FTerm::getMaxColor() < 16 )
|
||||||
|
@ -191,8 +191,8 @@ inline void FSwitch::drawChecked()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FSwitch::drawUnchecked()
|
inline void FSwitch::drawUnchecked()
|
||||||
{
|
{
|
||||||
const wchar_t on[6]{L" On "};
|
const FString on{L" On "};
|
||||||
wchar_t off[6]{L" Off "};
|
FString off{L" Off "};
|
||||||
|
|
||||||
const auto& wc = getColorTheme();
|
const auto& wc = getColorTheme();
|
||||||
setColor (wc->button_inactive_fg, wc->button_inactive_bg);
|
setColor (wc->button_inactive_fg, wc->button_inactive_bg);
|
||||||
|
@ -206,7 +206,7 @@ inline void FSwitch::drawUnchecked()
|
||||||
{
|
{
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
{
|
{
|
||||||
std::wcsncpy (off, L"<Off>", 6);
|
off.setString(L"<Off>");
|
||||||
setBold(true);
|
setBold(true);
|
||||||
}
|
}
|
||||||
else if ( FTerm::getMaxColor() < 16 )
|
else if ( FTerm::getMaxColor() < 16 )
|
||||||
|
|
|
@ -278,7 +278,7 @@ bool FTermLinux::loadVGAFont()
|
||||||
struct unimapdesc unimap;
|
struct unimapdesc unimap;
|
||||||
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
|
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
|
||||||
/ sizeof(unipair) );
|
/ sizeof(unipair) );
|
||||||
unimap.entries = &fc::unicode_cp437_pairs[0];
|
unimap.entries = const_cast<unipair*>(&fc::unicode_cp437_pairs[0]);
|
||||||
setUnicodeMap(&unimap);
|
setUnicodeMap(&unimap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -327,7 +327,7 @@ bool FTermLinux::loadNewFont()
|
||||||
struct unimapdesc unimap;
|
struct unimapdesc unimap;
|
||||||
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_newfont_pairs)
|
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_newfont_pairs)
|
||||||
/ sizeof(unipair) );
|
/ sizeof(unipair) );
|
||||||
unimap.entries = &fc::unicode_newfont_pairs[0];
|
unimap.entries = const_cast<unipair*>(&fc::unicode_newfont_pairs[0]);
|
||||||
setUnicodeMap(&unimap);
|
setUnicodeMap(&unimap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -660,7 +660,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
|
||||||
, uInt fontwidth, uInt fontheight
|
, uInt fontwidth, uInt fontheight
|
||||||
, bool direct)
|
, bool direct)
|
||||||
{
|
{
|
||||||
|
@ -681,7 +681,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
||||||
font.charcount = count;
|
font.charcount = count;
|
||||||
|
|
||||||
if ( direct )
|
if ( direct )
|
||||||
font.data = fontdata;
|
font.data = const_cast<uChar*>(fontdata);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const std::size_t bytes_per_line = font.width / 8;
|
const std::size_t bytes_per_line = font.width / 8;
|
||||||
|
|
|
@ -1471,20 +1471,17 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
|
||||||
|
|
||||||
if ( FWidget::getWindowList() && ! FWidget::getWindowList()->empty() )
|
if ( FWidget::getWindowList() && ! FWidget::getWindowList()->empty() )
|
||||||
{
|
{
|
||||||
bool found( area == vdesktop );
|
bool found{ area == vdesktop };
|
||||||
|
|
||||||
for (auto& win_obj : *FWidget::getWindowList())
|
for (auto& win_obj : *FWidget::getWindowList())
|
||||||
{
|
{
|
||||||
const auto& win = win_obj->getVWin();
|
const auto& win = win_obj->getVWin();
|
||||||
|
|
||||||
if ( ! win )
|
if ( ! (win && win->visible) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( ! win->visible )
|
const int& win_x = win->offset_left;
|
||||||
continue;
|
const int& win_y = win->offset_top;
|
||||||
|
|
||||||
const int win_x = win->offset_left;
|
|
||||||
const int win_y = win->offset_top;
|
|
||||||
const FRect geometry { win_x , win_y
|
const FRect geometry { win_x , win_y
|
||||||
, std::size_t(win->width) + std::size_t(win->right_shadow)
|
, std::size_t(win->width) + std::size_t(win->right_shadow)
|
||||||
, std::size_t(win->height) + std::size_t(win->bottom_shadow) };
|
, std::size_t(win->height) + std::size_t(win->bottom_shadow) };
|
||||||
|
@ -1492,9 +1489,9 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
|
||||||
if ( found && geometry.contains(pos) )
|
if ( found && geometry.contains(pos) )
|
||||||
{
|
{
|
||||||
const int width = win->width + win->right_shadow;
|
const int width = win->width + win->right_shadow;
|
||||||
const int x = pos.getX();
|
const int& x = pos.getX();
|
||||||
const int y = pos.getY();
|
const int& y = pos.getY();
|
||||||
auto tmp = &win->data[(y - win_y) * width + (x - win_x)];
|
const auto& tmp = &win->data[(y - win_y) * width + (x - win_x)];
|
||||||
|
|
||||||
if ( tmp->attr.bit.color_overlay )
|
if ( tmp->attr.bit.color_overlay )
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,6 +109,10 @@ FWidget::~FWidget() // destructor
|
||||||
if ( this == getClickedWidget() )
|
if ( this == getClickedWidget() )
|
||||||
setClickedWidget(nullptr);
|
setClickedWidget(nullptr);
|
||||||
|
|
||||||
|
// unset keyboard widget
|
||||||
|
if ( this == FApplication::getKeyboardWidget() )
|
||||||
|
FApplication::setKeyboardWidget(nullptr);
|
||||||
|
|
||||||
// unset the local window widget focus
|
// unset the local window widget focus
|
||||||
if ( flags.focus )
|
if ( flags.focus )
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,6 +114,7 @@ class FApplication : public FWidget
|
||||||
int getArgc() const;
|
int getArgc() const;
|
||||||
char** getArgv() const;
|
char** getArgv() const;
|
||||||
static FApplication* getApplicationObject();
|
static FApplication* getApplicationObject();
|
||||||
|
static FWidget* getKeyboardWidget();
|
||||||
static FLogPtr& getLog();
|
static FLogPtr& getLog();
|
||||||
|
|
||||||
// Mutator
|
// Mutator
|
||||||
|
@ -136,6 +137,7 @@ class FApplication : public FWidget
|
||||||
void initTerminal() override;
|
void initTerminal() override;
|
||||||
static void setDefaultTheme();
|
static void setDefaultTheme();
|
||||||
static void setDarkTheme();
|
static void setDarkTheme();
|
||||||
|
static void setKeyboardWidget (FWidget*);
|
||||||
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct FCallbackData
|
||||||
FCallbackData()
|
FCallbackData()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename FuncPtr>
|
template <typename FuncPtr>
|
||||||
FCallbackData (const FString& s, FWidget* i, FuncPtr m, const FCall& c)
|
FCallbackData (const FString& s, FWidget* i, FuncPtr m, const FCall& c)
|
||||||
: cb_signal(s)
|
: cb_signal(s)
|
||||||
, cb_instance(i)
|
, cb_instance(i)
|
||||||
|
@ -88,7 +88,7 @@ class FCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Using-declaration
|
// Using-declaration
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using ObjectPointer =
|
using ObjectPointer =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -97,7 +97,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& ! std::is_class<T>::value
|
&& ! std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using ClassObject =
|
using ClassObject =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -106,7 +106,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& std::is_class<T>::value
|
&& std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using MemberFunctionPointer =
|
using MemberFunctionPointer =
|
||||||
typename std::enable_if< std::is_member_function_pointer<T>::value
|
typename std::enable_if< std::is_member_function_pointer<T>::value
|
||||||
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
&& ! std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -115,7 +115,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& ! std::is_class<T>::value
|
&& ! std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using FunctionPointer =
|
using FunctionPointer =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -124,7 +124,7 @@ class FCallback
|
||||||
&& std::is_object<T>::value
|
&& std::is_object<T>::value
|
||||||
&& ! std::is_class<T>::value
|
&& ! std::is_class<T>::value
|
||||||
, std::nullptr_t >;
|
, std::nullptr_t >;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
using FunctionReference =
|
using FunctionReference =
|
||||||
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
typename std::enable_if< ! std::is_member_function_pointer<T>::value
|
||||||
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
&& std::is_function<typename std::remove_pointer<T>::type>::value
|
||||||
|
@ -151,61 +151,61 @@ class FCallback
|
||||||
std::size_t getCallbackCount() const;
|
std::size_t getCallbackCount() const;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename MemberFunctionPointer<Function>::type = nullptr
|
, typename MemberFunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_member
|
, Function&& cb_member
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename ObjectPointer<Object>::type = nullptr
|
, typename ObjectPointer<Object>::type = nullptr
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template < typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename ClassObject<Function>::type = nullptr
|
, typename ClassObject<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr
|
, typename FunctionReference<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FunctionPointer<Function>::type = nullptr
|
, typename FunctionPointer<Function>::type = nullptr
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
void addCallback ( const FString& cb_signal
|
void addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept;
|
, Args&&... args) noexcept;
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr>
|
||||||
void delCallback (Object&& cb_instance) noexcept;
|
void delCallback (Object&& cb_instance) noexcept;
|
||||||
void delCallback (const FString& cb_signal);
|
void delCallback (const FString& cb_signal);
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename ObjectPointer<Object>::type = nullptr>
|
, typename ObjectPointer<Object>::type = nullptr>
|
||||||
void delCallback ( const FString& cb_signal
|
void delCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance ) noexcept;
|
, Object&& cb_instance ) noexcept;
|
||||||
template<typename FunctionPtr
|
template <typename FunctionPtr
|
||||||
, typename FunctionPointer<FunctionPtr>::type = nullptr>
|
, typename FunctionPointer<FunctionPtr>::type = nullptr>
|
||||||
void delCallback (FunctionPtr&& cb_func_ptr) noexcept;
|
void delCallback (FunctionPtr&& cb_func_ptr) noexcept;
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FunctionReference<Function>::type = nullptr>
|
, typename FunctionReference<Function>::type = nullptr>
|
||||||
void delCallback (const Function& cb_function);
|
void delCallback (const Function& cb_function);
|
||||||
void delCallback();
|
void delCallback();
|
||||||
void emitCallback (const FString& emit_signal) const;
|
void emitCallback (const FString& emit_signal) const;
|
||||||
|
@ -228,11 +228,11 @@ inline std::size_t FCallback::getCallbackCount() const
|
||||||
{ return callback_objects.size(); }
|
{ return callback_objects.size(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename FCallback::ObjectPointer<Object>::type
|
, typename FCallback::ObjectPointer<Object>::type
|
||||||
, typename FCallback::MemberFunctionPointer<Function>::type
|
, typename FCallback::MemberFunctionPointer<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_member
|
, Function&& cb_member
|
||||||
|
@ -249,11 +249,11 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename Function
|
, typename Function
|
||||||
, typename FCallback::ObjectPointer<Object>::type
|
, typename FCallback::ObjectPointer<Object>::type
|
||||||
, typename FCallback::ClassObject<Function>::type
|
, typename FCallback::ClassObject<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance
|
, Object&& cb_instance
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
|
@ -267,9 +267,9 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::ClassObject<Function>::type
|
, typename FCallback::ClassObject<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept
|
, Args&&... args) noexcept
|
||||||
|
@ -283,9 +283,9 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::ClassObject<Function>::type
|
, typename FCallback::ClassObject<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args) noexcept
|
, Args&&... args) noexcept
|
||||||
|
@ -298,9 +298,9 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::FunctionReference<Function>::type
|
, typename FCallback::FunctionReference<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
, Function& cb_function
|
, Function& cb_function
|
||||||
, Args&&... args) noexcept
|
, Args&&... args) noexcept
|
||||||
|
@ -314,9 +314,9 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::FunctionPointer<Function>::type
|
, typename FCallback::FunctionPointer<Function>::type
|
||||||
, typename... Args>
|
, typename... Args>
|
||||||
inline void FCallback::addCallback ( const FString& cb_signal
|
inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
, Function&& cb_function
|
, Function&& cb_function
|
||||||
, Args&&... args) noexcept
|
, Args&&... args) noexcept
|
||||||
|
@ -331,8 +331,8 @@ inline void FCallback::addCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename FCallback::ObjectPointer<Object>::type>
|
, typename FCallback::ObjectPointer<Object>::type>
|
||||||
inline void FCallback::delCallback (Object&& cb_instance) noexcept
|
inline void FCallback::delCallback (Object&& cb_instance) noexcept
|
||||||
{
|
{
|
||||||
// Deletes entries with the given instance from the callback list
|
// Deletes entries with the given instance from the callback list
|
||||||
|
@ -352,8 +352,8 @@ inline void FCallback::delCallback (Object&& cb_instance) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Object
|
template <typename Object
|
||||||
, typename FCallback::ObjectPointer<Object>::type>
|
, typename FCallback::ObjectPointer<Object>::type>
|
||||||
inline void FCallback::delCallback ( const FString& cb_signal
|
inline void FCallback::delCallback ( const FString& cb_signal
|
||||||
, Object&& cb_instance ) noexcept
|
, Object&& cb_instance ) noexcept
|
||||||
{
|
{
|
||||||
|
@ -376,8 +376,8 @@ inline void FCallback::delCallback ( const FString& cb_signal
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename FunctionPtr
|
template <typename FunctionPtr
|
||||||
, typename FCallback::FunctionPointer<FunctionPtr>::type>
|
, typename FCallback::FunctionPointer<FunctionPtr>::type>
|
||||||
inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept
|
inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept
|
||||||
{
|
{
|
||||||
// Deletes entries with the given function pointer
|
// Deletes entries with the given function pointer
|
||||||
|
@ -399,8 +399,8 @@ inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Function
|
template <typename Function
|
||||||
, typename FCallback::FunctionReference<Function>::type>
|
, typename FCallback::FunctionReference<Function>::type>
|
||||||
inline void FCallback::delCallback (const Function& cb_function)
|
inline void FCallback::delCallback (const Function& cb_function)
|
||||||
{
|
{
|
||||||
// Deletes entries with the given function reference
|
// Deletes entries with the given function reference
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* This file is part of the FINAL CUT widget toolkit *
|
||||||
* *
|
* *
|
||||||
* Copyright 2015-2019 Markus Gans *
|
* Copyright 2015-2020 Markus Gans *
|
||||||
* *
|
* *
|
||||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -39,10 +39,10 @@ namespace fc
|
||||||
extern uInt character[][fc::NUM_OF_ENCODINGS];
|
extern uInt character[][fc::NUM_OF_ENCODINGS];
|
||||||
extern const std::size_t lastCharItem;
|
extern const std::size_t lastCharItem;
|
||||||
|
|
||||||
extern int vt100_key_to_utf8[][2];
|
extern const int vt100_key_to_utf8[][2];
|
||||||
extern const std::size_t lastKeyItem;
|
extern const std::size_t lastKeyItem;
|
||||||
|
|
||||||
extern wchar_t cp437_ucs[][2];
|
extern const wchar_t cp437_ucs[][2];
|
||||||
extern const std::size_t lastCP437Item;
|
extern const std::size_t lastCP437Item;
|
||||||
|
|
||||||
extern const wchar_t halfWidth_fullWidth[][2];
|
extern const wchar_t halfWidth_fullWidth[][2];
|
||||||
|
|
|
@ -150,7 +150,8 @@ class FComboBox : public FWidget
|
||||||
const FString getClassName() const override;
|
const FString getClassName() const override;
|
||||||
std::size_t getCount() const;
|
std::size_t getCount() const;
|
||||||
FString getText() const;
|
FString getText() const;
|
||||||
FDataPtr getItemData();
|
template <typename DT>
|
||||||
|
clean_fdata_t<DT>& getItemData();
|
||||||
FLineEdit::label_o getLabelOrientation() const;
|
FLineEdit::label_o getLabelOrientation() const;
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
|
@ -182,11 +183,13 @@ class FComboBox : public FWidget
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void insert (const FListBoxItem&);
|
void insert (const FListBoxItem&);
|
||||||
template <typename T>
|
template <typename T
|
||||||
|
, typename DT = std::nullptr_t>
|
||||||
void insert ( const std::initializer_list<T>& list
|
void insert ( const std::initializer_list<T>& list
|
||||||
, FDataPtr = nullptr );
|
, DT&& = DT() );
|
||||||
template <typename ItemT>
|
template <typename ItemT
|
||||||
void insert (const ItemT&, FDataPtr = nullptr);
|
, typename DT = std::nullptr_t>
|
||||||
|
void insert (const ItemT&, DT&& = DT());
|
||||||
void remove (std::size_t);
|
void remove (std::size_t);
|
||||||
void reserve (std::size_t);
|
void reserve (std::size_t);
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -247,10 +250,11 @@ inline FString FComboBox::getText() const
|
||||||
{ return input_field.getText(); }
|
{ return input_field.getText(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FDataPtr FComboBox::getItemData()
|
template <typename DT>
|
||||||
|
inline clean_fdata_t<DT>& FComboBox::getItemData()
|
||||||
{
|
{
|
||||||
const std::size_t index = list_window.list.currentItem();
|
const std::size_t index = list_window.list.currentItem();
|
||||||
return list_window.list.getItem(index).getData();
|
return list_window.list.getItem(index).getData<DT>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -298,21 +302,23 @@ inline bool FComboBox::hasShadow() const
|
||||||
{ return getFlags().shadow; }
|
{ return getFlags().shadow; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T
|
||||||
void FComboBox::insert (const std::initializer_list<T>& list, FDataPtr d)
|
, typename DT>
|
||||||
|
void FComboBox::insert (const std::initializer_list<T>& list, DT&& d)
|
||||||
{
|
{
|
||||||
for (auto& item : list)
|
for (auto& item : list)
|
||||||
{
|
{
|
||||||
FListBoxItem listItem (FString() << item, d);
|
FListBoxItem listItem (FString() << item, std::forward<DT>(d));
|
||||||
insert (listItem);
|
insert (listItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename ItemT>
|
template <typename ItemT
|
||||||
void FComboBox::insert (const ItemT& item, FDataPtr d)
|
, typename DT>
|
||||||
|
void FComboBox::insert (const ItemT& item, DT&& d)
|
||||||
{
|
{
|
||||||
FListBoxItem listItem (FString() << item, d);
|
FListBoxItem listItem (FString() << item, std::forward<DT>(d));
|
||||||
insert (listItem);
|
insert (listItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,19 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
/* Inheritance diagram
|
||||||
|
* ═══════════════════
|
||||||
|
*
|
||||||
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||||
|
* ▕ FDataAccess ▏
|
||||||
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||||
|
* ▲
|
||||||
|
* │
|
||||||
|
* ▕▔▔▔▔▔▔▔▏
|
||||||
|
* ▕ FData ▏
|
||||||
|
* ▕▁▁▁▁▁▁▁▏
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef FDATA_H
|
#ifndef FDATA_H
|
||||||
#define FDATA_H
|
#define FDATA_H
|
||||||
|
|
||||||
|
@ -29,11 +42,55 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
template<typename T>
|
namespace finalcut
|
||||||
struct FData
|
|
||||||
{
|
{
|
||||||
explicit FData (T v) // constructor
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// struct FDataAccess
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct FData; // Class forward declaration
|
||||||
|
|
||||||
|
struct FDataAccess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~FDataAccess();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
const T& get() const
|
||||||
|
{
|
||||||
|
return static_cast<const FData<T>&>(*this).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T
|
||||||
|
, typename V>
|
||||||
|
void set (const V& v)
|
||||||
|
{
|
||||||
|
static_cast<FData<T>&>(*this).set(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline FDataAccess::~FDataAccess()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// struct FData
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct FData : public FDataAccess
|
||||||
|
{
|
||||||
|
explicit FData (T& v) // constructor
|
||||||
|
: value_ref{v}
|
||||||
|
{ }
|
||||||
|
|
||||||
|
explicit FData (T&& v) // constructor
|
||||||
: value{v}
|
: value{v}
|
||||||
|
, value_ref{value}
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~FData() // destructor
|
~FData() // destructor
|
||||||
|
@ -41,64 +98,131 @@ struct FData
|
||||||
|
|
||||||
FData (const FData& d) // Copy constructor
|
FData (const FData& d) // Copy constructor
|
||||||
: value{d.value}
|
: value{d.value}
|
||||||
|
, value_ref{d.value_ref}
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
FData& operator = (const FData& d) // Copy assignment operator (=)
|
FData& operator = (const FData& d) // Copy assignment operator (=)
|
||||||
{
|
{
|
||||||
value = d.value;
|
value = d.value;
|
||||||
return *this;
|
value_ref = d.value_ref;
|
||||||
}
|
|
||||||
|
|
||||||
FData (FData&& d) noexcept // Move constructor
|
|
||||||
: value{std::move(d.value)}
|
|
||||||
{ }
|
|
||||||
|
|
||||||
FData& operator = (FData&& d) noexcept // Move assignment operator (=)
|
|
||||||
{
|
|
||||||
value = std::move(d.value);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T operator () () const
|
T operator () () const
|
||||||
{
|
{
|
||||||
return value;
|
return value_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
T operator () (Args... args) const
|
T operator () (Args... args) const
|
||||||
{
|
{
|
||||||
return value(args...);
|
return value_ref(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator T () const
|
explicit operator T () const
|
||||||
{
|
{
|
||||||
return value;
|
return value_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& get()
|
T& get()
|
||||||
{
|
{
|
||||||
return value;
|
return value_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set (const T& v)
|
void set (const T& v)
|
||||||
{
|
{
|
||||||
value = v;
|
value_ref = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInitializedCopy()
|
||||||
|
{
|
||||||
|
return bool(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInitializedReference()
|
||||||
|
{
|
||||||
|
return ! isInitializedCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
FData& operator << (const T& v)
|
FData& operator << (const T& v)
|
||||||
{
|
{
|
||||||
value = v;
|
value_ref = v;
|
||||||
return *this;
|
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;
|
os << data.value_ref;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
T value;
|
private:
|
||||||
|
T value{};
|
||||||
|
|
||||||
|
public:
|
||||||
|
T& value_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FDATA_H
|
|
||||||
|
|
||||||
|
// non-member functions
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T
|
||||||
|
, bool isArray = std::is_array<T>::value
|
||||||
|
, bool isFunction = std::is_function<T>::value>
|
||||||
|
struct cleanCondition;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
struct cleanCondition<T, false, false>
|
||||||
|
{
|
||||||
|
// Leave the type untouched
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
struct cleanCondition<T, true, false>
|
||||||
|
{
|
||||||
|
// Array to pointer
|
||||||
|
typedef typename std::remove_extent<T>::type* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
struct cleanCondition<T, false, true>
|
||||||
|
{
|
||||||
|
// Add pointer to function
|
||||||
|
typedef typename std::add_pointer<T>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
class cleanFData
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
typedef typename std::remove_reference<T>::type remove_ref;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Similar to std::decay, but keeps const and volatile
|
||||||
|
typedef typename internal::cleanCondition<remove_ref>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
using clean_fdata_t = typename cleanFData<T>::type;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
constexpr FData<clean_fdata_t<T>>* makeFData (T&& data)
|
||||||
|
{
|
||||||
|
return new FData<clean_fdata_t<T>>(std::forward<T>(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace finalcut
|
||||||
|
|
||||||
|
#endif // FDATA_H
|
||||||
|
|
|
@ -342,15 +342,51 @@ class FUserEvent : public FEvent // user event
|
||||||
// Disable copy assignment operator (=)
|
// Disable copy assignment operator (=)
|
||||||
FUserEvent& operator = (const FUserEvent&) = delete;
|
FUserEvent& operator = (const FUserEvent&) = delete;
|
||||||
|
|
||||||
int getUserId() const;
|
int getUserId() const;
|
||||||
FDataPtr getData() const;
|
template <typename T>
|
||||||
void setData (FDataPtr);
|
FData<T>&& getFDataObject() const;
|
||||||
|
template <typename T>
|
||||||
|
clean_fdata_t<T>& getData() const;
|
||||||
|
template <typename T>
|
||||||
|
void setFDataObject (T&&);
|
||||||
|
template <typename T>
|
||||||
|
void setData (T&&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int uid{0};
|
int uid{0};
|
||||||
FDataPtr data_pointer{nullptr};
|
FDataAccess* data_pointer{nullptr};
|
||||||
|
bool external_data_pointer{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
inline FData<T>&& FUserEvent::getFDataObject() const
|
||||||
|
{
|
||||||
|
return static_cast<FData<T>&&>(*data_pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
inline clean_fdata_t<T>& FUserEvent::getData() const
|
||||||
|
{
|
||||||
|
return static_cast<FData<clean_fdata_t<T>>&>(*data_pointer).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
inline void FUserEvent::setFDataObject (T&& fdata)
|
||||||
|
{
|
||||||
|
external_data_pointer = true;
|
||||||
|
data_pointer = &(std::forward<T>(fdata));
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
inline void FUserEvent::setData (T&& data)
|
||||||
|
{
|
||||||
|
external_data_pointer = false;
|
||||||
|
data_pointer = makeFData(std::forward<T>(data));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
#endif // FEVENT_H
|
#endif // FEVENT_H
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* This file is part of the FINAL CUT widget toolkit *
|
||||||
* *
|
* *
|
||||||
* Copyright 2015-2019 Markus Gans *
|
* Copyright 2015-2020 Markus Gans *
|
||||||
* *
|
* *
|
||||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -34,8 +34,8 @@ namespace fc
|
||||||
{
|
{
|
||||||
|
|
||||||
extern FKeyMap fkey[];
|
extern FKeyMap fkey[];
|
||||||
extern FMetakeyMap fmetakey[];
|
extern const FMetakeyMap fmetakey[];
|
||||||
extern FKeyName fkeyname[];
|
extern const FKeyName fkeyname[];
|
||||||
|
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,8 @@ class FListBoxItem
|
||||||
// Constructors
|
// Constructors
|
||||||
FListBoxItem ();
|
FListBoxItem ();
|
||||||
FListBoxItem (const FListBoxItem&); // copy constructor
|
FListBoxItem (const FListBoxItem&); // copy constructor
|
||||||
explicit FListBoxItem (const FString&, FDataPtr = nullptr);
|
template <typename DT = std::nullptr_t>
|
||||||
|
explicit FListBoxItem (const FString&, DT&& = DT() );
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~FListBoxItem();
|
virtual ~FListBoxItem();
|
||||||
|
@ -83,11 +84,13 @@ class FListBoxItem
|
||||||
// Accessors
|
// Accessors
|
||||||
virtual const FString getClassName() const;
|
virtual const FString getClassName() const;
|
||||||
virtual FString getText() const;
|
virtual FString getText() const;
|
||||||
virtual FDataPtr getData() const;
|
template <typename DT>
|
||||||
|
clean_fdata_t<DT>& getData() const;
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
void setText (const FString&);
|
void setText (const FString&);
|
||||||
void setData (FDataPtr);
|
template <typename DT>
|
||||||
|
void setData (DT&&);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -95,7 +98,7 @@ class FListBoxItem
|
||||||
private:
|
private:
|
||||||
// Data members
|
// Data members
|
||||||
FString text{};
|
FString text{};
|
||||||
FDataPtr data_pointer{nullptr};
|
FDataAccess* data_pointer{nullptr};
|
||||||
fc::brackets_type brackets{fc::NoBrackets};
|
fc::brackets_type brackets{fc::NoBrackets};
|
||||||
bool selected{false};
|
bool selected{false};
|
||||||
|
|
||||||
|
@ -105,6 +108,13 @@ class FListBoxItem
|
||||||
|
|
||||||
|
|
||||||
// FListBoxItem inline functions
|
// FListBoxItem inline functions
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename DT>
|
||||||
|
inline FListBoxItem::FListBoxItem (const FString& txt, DT&& data)
|
||||||
|
: text{txt}
|
||||||
|
, data_pointer{makeFData(std::forward<DT>(data))}
|
||||||
|
{ }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FListBoxItem::getClassName() const
|
inline const FString FListBoxItem::getClassName() const
|
||||||
{ return "FListBoxItem"; }
|
{ return "FListBoxItem"; }
|
||||||
|
@ -114,16 +124,22 @@ inline FString FListBoxItem::getText() const
|
||||||
{ return text; }
|
{ return text; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FDataPtr FListBoxItem::getData() const
|
template <typename DT>
|
||||||
{ return data_pointer; }
|
inline clean_fdata_t<DT>& FListBoxItem::getData() const
|
||||||
|
{
|
||||||
|
return static_cast<FData<clean_fdata_t<DT>>&>(*data_pointer).get();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBoxItem::setText (const FString& txt)
|
inline void FListBoxItem::setText (const FString& txt)
|
||||||
{ text.setString(txt); }
|
{ text.setString(txt); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBoxItem::setData (FDataPtr data)
|
template <typename DT>
|
||||||
{ data_pointer = data; }
|
inline void FListBoxItem::setData (DT&& data)
|
||||||
|
{
|
||||||
|
data_pointer = makeFData(std::forward<DT>(data));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBoxItem::clear()
|
inline void FListBoxItem::clear()
|
||||||
|
@ -145,9 +161,11 @@ class FListBox : public FWidget
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
explicit FListBox (FWidget* = nullptr);
|
explicit FListBox (FWidget* = nullptr);
|
||||||
template <typename Iterator, typename InsertConverter>
|
template <typename Iterator
|
||||||
|
, typename InsertConverter>
|
||||||
FListBox (Iterator, Iterator, InsertConverter, FWidget* = nullptr);
|
FListBox (Iterator, Iterator, InsertConverter, FWidget* = nullptr);
|
||||||
template <typename Container, typename LazyConverter>
|
template <typename Container
|
||||||
|
, typename LazyConverter>
|
||||||
FListBox (Container, LazyConverter, FWidget* = nullptr);
|
FListBox (Container, LazyConverter, FWidget* = nullptr);
|
||||||
|
|
||||||
// Disable copy constructor
|
// Disable copy constructor
|
||||||
|
@ -197,21 +215,30 @@ class FListBox : public FWidget
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void hide() override;
|
void hide() override;
|
||||||
template <typename Iterator, typename InsertConverter>
|
template <typename Iterator
|
||||||
void insert (Iterator, Iterator, InsertConverter);
|
, typename InsertConverter>
|
||||||
template <typename Container, typename LazyConverter>
|
void insert ( Iterator, Iterator
|
||||||
void insert (Container, LazyConverter);
|
, const InsertConverter& );
|
||||||
|
template <typename Container
|
||||||
|
, typename LazyConverter>
|
||||||
|
void insert ( const Container&
|
||||||
|
, const LazyConverter& );
|
||||||
|
template <typename Container
|
||||||
|
, typename LazyConverter>
|
||||||
|
void insert (Container*, const LazyConverter&);
|
||||||
void insert (const FListBoxItem&);
|
void insert (const FListBoxItem&);
|
||||||
template <typename T>
|
template <typename T
|
||||||
|
, typename DT = std::nullptr_t>
|
||||||
void insert ( const std::initializer_list<T>& list
|
void insert ( const std::initializer_list<T>& list
|
||||||
, fc::brackets_type = fc::NoBrackets
|
, fc::brackets_type = fc::NoBrackets
|
||||||
, bool = false
|
, bool = false
|
||||||
, FDataPtr = nullptr );
|
, DT&& = DT() );
|
||||||
template <typename ItemT>
|
template <typename ItemT
|
||||||
|
, typename DT = std::nullptr_t>
|
||||||
void insert ( const ItemT&
|
void insert ( const ItemT&
|
||||||
, fc::brackets_type = fc::NoBrackets
|
, fc::brackets_type = fc::NoBrackets
|
||||||
, bool = false
|
, bool = false
|
||||||
, FDataPtr = nullptr );
|
, DT&& = DT() );
|
||||||
void remove (std::size_t);
|
void remove (std::size_t);
|
||||||
void reserve (std::size_t);
|
void reserve (std::size_t);
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -236,7 +263,7 @@ class FListBox : public FWidget
|
||||||
// Typedefs
|
// Typedefs
|
||||||
typedef std::unordered_map<int, std::function<void()>> keyMap;
|
typedef std::unordered_map<int, std::function<void()>> keyMap;
|
||||||
typedef std::unordered_map<int, std::function<bool()>> keyMapResult;
|
typedef std::unordered_map<int, std::function<bool()>> keyMapResult;
|
||||||
typedef std::function<void(FListBoxItem&, FDataPtr, int)> lazyInsert;
|
typedef std::function<void(FListBoxItem&, FDataAccess*, std::size_t)> lazyInsert;
|
||||||
|
|
||||||
// Enumeration
|
// Enumeration
|
||||||
enum convert_type
|
enum convert_type
|
||||||
|
@ -305,7 +332,7 @@ class FListBox : public FWidget
|
||||||
void processSelect() const;
|
void processSelect() const;
|
||||||
void processChanged() const;
|
void processChanged() const;
|
||||||
void changeOnResize() const;
|
void changeOnResize() const;
|
||||||
void lazyConvert (listBoxItems::iterator, int);
|
void lazyConvert (listBoxItems::iterator, std::size_t);
|
||||||
listBoxItems::iterator index2iterator (std::size_t);
|
listBoxItems::iterator index2iterator (std::size_t);
|
||||||
listBoxItems::const_iterator index2iterator (std::size_t index) const;
|
listBoxItems::const_iterator index2iterator (std::size_t index) const;
|
||||||
// Callback methods
|
// Callback methods
|
||||||
|
@ -317,7 +344,7 @@ class FListBox : public FWidget
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
listBoxItems itemlist{};
|
listBoxItems itemlist{};
|
||||||
FDataPtr source_container{nullptr};
|
FDataAccess* source_container{nullptr};
|
||||||
FScrollbarPtr vbar{nullptr};
|
FScrollbarPtr vbar{nullptr};
|
||||||
FScrollbarPtr hbar{nullptr};
|
FScrollbarPtr hbar{nullptr};
|
||||||
FString text{};
|
FString text{};
|
||||||
|
@ -342,10 +369,23 @@ class FListBox : public FWidget
|
||||||
bool click_on_list{false};
|
bool click_on_list{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// non-member function
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
namespace FListBoxHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename Container>
|
||||||
|
constexpr clean_fdata_t<Container>& getContainer(FDataAccess* container)
|
||||||
|
{
|
||||||
|
return static_cast<FData<clean_fdata_t<Container>>&>(*container).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace FListBoxHelper
|
||||||
|
|
||||||
// FListBox inline functions
|
// FListBox inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename Iterator, typename InsertConverter>
|
template <typename Iterator
|
||||||
|
, typename InsertConverter>
|
||||||
inline FListBox::FListBox ( Iterator first
|
inline FListBox::FListBox ( Iterator first
|
||||||
, Iterator last
|
, Iterator last
|
||||||
, InsertConverter convert
|
, InsertConverter convert
|
||||||
|
@ -362,7 +402,8 @@ inline FListBox::FListBox ( Iterator first
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename Container, typename LazyConverter>
|
template <typename Container
|
||||||
|
, typename LazyConverter>
|
||||||
inline FListBox::FListBox ( Container container
|
inline FListBox::FListBox ( Container container
|
||||||
, LazyConverter convert
|
, LazyConverter convert
|
||||||
, FWidget* parent )
|
, FWidget* parent )
|
||||||
|
@ -475,10 +516,11 @@ inline void FListBox::reserve (std::size_t new_cap)
|
||||||
{ itemlist.reserve(new_cap); }
|
{ itemlist.reserve(new_cap); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename Iterator, typename InsertConverter>
|
template <typename Iterator
|
||||||
|
, typename InsertConverter>
|
||||||
inline void FListBox::insert ( Iterator first
|
inline void FListBox::insert ( Iterator first
|
||||||
, Iterator last
|
, Iterator last
|
||||||
, InsertConverter convert )
|
, const InsertConverter& convert )
|
||||||
{
|
{
|
||||||
conv_type = direct_convert;
|
conv_type = direct_convert;
|
||||||
|
|
||||||
|
@ -490,13 +532,14 @@ inline void FListBox::insert ( Iterator first
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename Container, typename LazyConverter>
|
template <typename Container
|
||||||
void FListBox::insert (Container container, LazyConverter convert)
|
, typename LazyConverter>
|
||||||
|
void FListBox::insert (const Container& container, const LazyConverter& converter)
|
||||||
{
|
{
|
||||||
conv_type = lazy_convert;
|
conv_type = lazy_convert;
|
||||||
source_container = container;
|
source_container = makeFData(container);
|
||||||
lazy_inserter = convert;
|
lazy_inserter = converter;
|
||||||
const std::size_t size = container->size();
|
const std::size_t size = container.size();
|
||||||
|
|
||||||
if ( size > 0 )
|
if ( size > 0 )
|
||||||
itemlist.resize(size);
|
itemlist.resize(size);
|
||||||
|
@ -505,15 +548,24 @@ void FListBox::insert (Container container, LazyConverter convert)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename Container
|
||||||
|
, typename LazyConverter>
|
||||||
|
void FListBox::insert (Container* container, const LazyConverter& converter)
|
||||||
|
{
|
||||||
|
insert (*container, converter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T
|
||||||
|
, typename DT>
|
||||||
void FListBox::insert ( const std::initializer_list<T>& list
|
void FListBox::insert ( const std::initializer_list<T>& list
|
||||||
, fc::brackets_type b
|
, fc::brackets_type b
|
||||||
, bool s
|
, bool s
|
||||||
, FDataPtr d )
|
, DT&& d )
|
||||||
{
|
{
|
||||||
for (auto& item : list)
|
for (auto& item : list)
|
||||||
{
|
{
|
||||||
FListBoxItem listItem (FString() << item, d);
|
FListBoxItem listItem (FString() << item, std::forward<DT>(d));
|
||||||
listItem.brackets = b;
|
listItem.brackets = b;
|
||||||
listItem.selected = s;
|
listItem.selected = s;
|
||||||
insert (listItem);
|
insert (listItem);
|
||||||
|
@ -521,13 +573,14 @@ void FListBox::insert ( const std::initializer_list<T>& list
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename ItemT>
|
template <typename ItemT
|
||||||
|
, typename DT>
|
||||||
void FListBox::insert ( const ItemT& item
|
void FListBox::insert ( const ItemT& item
|
||||||
, fc::brackets_type b
|
, fc::brackets_type b
|
||||||
, bool s
|
, bool s
|
||||||
, FDataPtr d )
|
, DT&& d )
|
||||||
{
|
{
|
||||||
FListBoxItem listItem (FString() << item, d);
|
FListBoxItem listItem (FString() << item, std::forward<DT>(d));
|
||||||
listItem.brackets = b;
|
listItem.brackets = b;
|
||||||
listItem.selected = s;
|
listItem.selected = s;
|
||||||
insert (listItem);
|
insert (listItem);
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
|
|
||||||
#include "final/fscrollbar.h"
|
#include "final/fscrollbar.h"
|
||||||
#include "final/ftermbuffer.h"
|
#include "final/ftermbuffer.h"
|
||||||
|
#include "final/ftypes.h"
|
||||||
#include "final/fwidget.h"
|
#include "final/fwidget.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
@ -74,9 +75,8 @@ class FListViewItem : public FObject
|
||||||
// Constructor
|
// Constructor
|
||||||
FListViewItem (const FListViewItem&); // copy constructor
|
FListViewItem (const FListViewItem&); // copy constructor
|
||||||
explicit FListViewItem (iterator);
|
explicit FListViewItem (iterator);
|
||||||
FListViewItem ( const FStringList&
|
template <typename DT>
|
||||||
, FDataPtr
|
FListViewItem (const FStringList&, DT&&, iterator);
|
||||||
, iterator );
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~FListViewItem() override;
|
~FListViewItem() override;
|
||||||
|
@ -89,12 +89,14 @@ class FListViewItem : public FObject
|
||||||
uInt getColumnCount() const;
|
uInt getColumnCount() const;
|
||||||
int getSortColumn() const;
|
int getSortColumn() const;
|
||||||
FString getText (int) const;
|
FString getText (int) const;
|
||||||
FDataPtr getData() const;
|
template <typename DT>
|
||||||
|
clean_fdata_t<DT>& getData() const;
|
||||||
uInt getDepth() const;
|
uInt getDepth() const;
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
void setText (int, const FString&);
|
void setText (int, const FString&);
|
||||||
void setData (FDataPtr);
|
template <typename DT>
|
||||||
|
void setData (DT&&);
|
||||||
void setCheckable (bool);
|
void setCheckable (bool);
|
||||||
void setChecked (bool);
|
void setChecked (bool);
|
||||||
|
|
||||||
|
@ -124,7 +126,7 @@ class FListViewItem : public FObject
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
FStringList column_list{};
|
FStringList column_list{};
|
||||||
FDataPtr data_pointer{nullptr};
|
FDataAccess* data_pointer{nullptr};
|
||||||
iterator root{};
|
iterator root{};
|
||||||
std::size_t visible_lines{1};
|
std::size_t visible_lines{1};
|
||||||
bool expandable{false};
|
bool expandable{false};
|
||||||
|
@ -139,6 +141,22 @@ class FListViewItem : public FObject
|
||||||
|
|
||||||
|
|
||||||
// FListViewItem inline functions
|
// FListViewItem inline functions
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename DT>
|
||||||
|
inline FListViewItem::FListViewItem ( const FStringList& cols
|
||||||
|
, DT&& data
|
||||||
|
, iterator parent_iter )
|
||||||
|
: FObject{nullptr}
|
||||||
|
, column_list{cols}
|
||||||
|
, data_pointer{makeFData(std::forward<DT>(data))}
|
||||||
|
{
|
||||||
|
if ( cols.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
replaceControlCodes();
|
||||||
|
insert (this, parent_iter);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FString FListViewItem::getClassName() const
|
inline const FString FListViewItem::getClassName() const
|
||||||
{ return "FListViewItem"; }
|
{ return "FListViewItem"; }
|
||||||
|
@ -148,12 +166,18 @@ inline uInt FListViewItem::getColumnCount() const
|
||||||
{ return uInt(column_list.size()); }
|
{ return uInt(column_list.size()); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FDataPtr FListViewItem::getData() const
|
template <typename DT>
|
||||||
{ return data_pointer; }
|
inline clean_fdata_t<DT>& FListViewItem::getData() const
|
||||||
|
{
|
||||||
|
return static_cast<FData<clean_fdata_t<DT>>&>(*data_pointer).get();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListViewItem::setData (FDataPtr data)
|
template <typename DT>
|
||||||
{ data_pointer = data; }
|
inline void FListViewItem::setData (DT&& data)
|
||||||
|
{
|
||||||
|
data_pointer = makeFData(std::forward<DT>(data));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListViewItem::setChecked (bool checked)
|
inline void FListViewItem::setChecked (bool checked)
|
||||||
|
@ -312,32 +336,38 @@ class FListView : public FWidget
|
||||||
void hide() override;
|
void hide() override;
|
||||||
iterator insert (FListViewItem*);
|
iterator insert (FListViewItem*);
|
||||||
iterator insert (FListViewItem*, iterator);
|
iterator insert (FListViewItem*, iterator);
|
||||||
|
template <typename DT = std::nullptr_t>
|
||||||
iterator insert ( const FStringList&
|
iterator insert ( const FStringList&
|
||||||
, FDataPtr = nullptr );
|
, DT&& = DT() );
|
||||||
iterator insert ( const FStringList&
|
iterator insert ( const FStringList&
|
||||||
, iterator );
|
, iterator );
|
||||||
|
template <typename DT>
|
||||||
iterator insert ( const FStringList&
|
iterator insert ( const FStringList&
|
||||||
, FDataPtr
|
, DT&&
|
||||||
, iterator );
|
, iterator );
|
||||||
template <typename T>
|
template <typename T
|
||||||
|
, typename DT = std::nullptr_t>
|
||||||
iterator insert ( const std::initializer_list<T>&
|
iterator insert ( const std::initializer_list<T>&
|
||||||
, FDataPtr = nullptr );
|
, DT&& = DT() );
|
||||||
template <typename T>
|
template <typename T>
|
||||||
iterator insert ( const std::initializer_list<T>&
|
iterator insert ( const std::initializer_list<T>&
|
||||||
, iterator );
|
, iterator );
|
||||||
template <typename T>
|
template <typename T
|
||||||
|
, typename DT>
|
||||||
iterator insert ( const std::initializer_list<T>&
|
iterator insert ( const std::initializer_list<T>&
|
||||||
, FDataPtr
|
, DT&&
|
||||||
, iterator );
|
, iterator );
|
||||||
template <typename ColT>
|
template <typename ColT
|
||||||
|
, typename DT = std::nullptr_t>
|
||||||
iterator insert ( const std::vector<ColT>&
|
iterator insert ( const std::vector<ColT>&
|
||||||
, FDataPtr = nullptr );
|
, DT&& = DT() );
|
||||||
template <typename ColT>
|
template <typename ColT>
|
||||||
iterator insert ( const std::vector<ColT>&
|
iterator insert ( const std::vector<ColT>&
|
||||||
, iterator );
|
, iterator );
|
||||||
template <typename ColT>
|
template <typename ColT
|
||||||
|
, typename DT>
|
||||||
iterator insert ( const std::vector<ColT>&
|
iterator insert ( const std::vector<ColT>&
|
||||||
, FDataPtr
|
, DT&&
|
||||||
, iterator );
|
, iterator );
|
||||||
void remove (FListViewItem*);
|
void remove (FListViewItem*);
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -560,9 +590,10 @@ inline FObject::iterator FListView::insert (FListViewItem* item)
|
||||||
{ return insert (item, root); }
|
{ return insert (item, root); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
template <typename DT>
|
||||||
inline FObject::iterator
|
inline FObject::iterator
|
||||||
FListView::insert (const FStringList& cols, FDataPtr d)
|
FListView::insert (const FStringList& cols, DT&& d)
|
||||||
{ return insert (cols, d, root); }
|
{ return insert (cols, std::forward<DT>(d), root); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FObject::iterator
|
inline FObject::iterator
|
||||||
|
@ -571,23 +602,53 @@ inline FObject::iterator
|
||||||
{ return insert (cols, nullptr, parent_iter); }
|
{ return insert (cols, nullptr, parent_iter); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename T>
|
template <typename DT>
|
||||||
inline FObject::iterator
|
inline FObject::iterator FListView::insert ( const FStringList& cols
|
||||||
FListView::insert (const std::initializer_list<T>& list, FDataPtr d)
|
, DT&& d
|
||||||
{ return insert (list, d, root); }
|
, iterator parent_iter )
|
||||||
|
{
|
||||||
|
FListViewItem* item;
|
||||||
|
|
||||||
|
if ( cols.empty() || parent_iter == getNullIterator() )
|
||||||
|
return getNullIterator();
|
||||||
|
|
||||||
|
if ( ! *parent_iter )
|
||||||
|
parent_iter = root;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item = new FListViewItem (cols, std::forward<DT>(d), getNullIterator());
|
||||||
|
}
|
||||||
|
catch (const std::bad_alloc&)
|
||||||
|
{
|
||||||
|
badAllocOutput ("FListViewItem");
|
||||||
|
return getNullIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
item->replaceControlCodes();
|
||||||
|
return insert(item, parent_iter);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename T>
|
template <typename T
|
||||||
|
, typename DT>
|
||||||
|
inline FObject::iterator
|
||||||
|
FListView::insert (const std::initializer_list<T>& list, DT&& d)
|
||||||
|
{ return insert (list, std::forward<DT>(d), root); }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
inline FObject::iterator
|
inline FObject::iterator
|
||||||
FListView::insert ( const std::initializer_list<T>& list
|
FListView::insert ( const std::initializer_list<T>& list
|
||||||
, iterator parent_iter )
|
, iterator parent_iter )
|
||||||
{ return insert (list, 0, parent_iter); }
|
{ return insert (list, 0, parent_iter); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename T>
|
template <typename T
|
||||||
|
, typename DT>
|
||||||
FObject::iterator
|
FObject::iterator
|
||||||
FListView::insert ( const std::initializer_list<T>& list
|
FListView::insert ( const std::initializer_list<T>& list
|
||||||
, FDataPtr d
|
, DT&& d
|
||||||
, iterator parent_iter )
|
, iterator parent_iter )
|
||||||
{
|
{
|
||||||
FStringList str_cols;
|
FStringList str_cols;
|
||||||
|
@ -602,15 +663,16 @@ FObject::iterator
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
auto item_iter = insert (str_cols, d, parent_iter);
|
auto item_iter = insert (str_cols, std::forward<DT>(d), parent_iter);
|
||||||
return item_iter;
|
return item_iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename ColT>
|
template <typename ColT
|
||||||
|
, typename DT>
|
||||||
inline FObject::iterator
|
inline FObject::iterator
|
||||||
FListView::insert (const std::vector<ColT>& cols, FDataPtr d)
|
FListView::insert (const std::vector<ColT>& cols, DT&& d)
|
||||||
{ return insert (cols, d, root); }
|
{ return insert (cols, std::forward<DT>(d), root); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename ColT>
|
template <typename ColT>
|
||||||
|
@ -620,10 +682,11 @@ inline FObject::iterator
|
||||||
{ return insert (cols, 0, parent_iter); }
|
{ return insert (cols, 0, parent_iter); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename ColT>
|
template <typename ColT
|
||||||
|
, typename DT>
|
||||||
FObject::iterator
|
FObject::iterator
|
||||||
FListView::insert ( const std::vector<ColT>& cols
|
FListView::insert ( const std::vector<ColT>& cols
|
||||||
, FDataPtr d
|
, DT&& d
|
||||||
, iterator parent_iter )
|
, iterator parent_iter )
|
||||||
{
|
{
|
||||||
FStringList str_cols;
|
FStringList str_cols;
|
||||||
|
@ -638,7 +701,7 @@ FObject::iterator
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
auto item_iter = insert (str_cols, d, parent_iter);
|
auto item_iter = insert (str_cols, std::forward<DT>(d), parent_iter);
|
||||||
return item_iter;
|
return item_iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ class FMouse
|
||||||
bool isInputDataPending() const;
|
bool isInputDataPending() const;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
template<typename ClassT>
|
template <typename ClassT>
|
||||||
static FMouse* createMouseObject ();
|
static FMouse* createMouseObject ();
|
||||||
void clearButtonState();
|
void clearButtonState();
|
||||||
virtual void setRawData (FKeyboard::keybuffer&) = 0;
|
virtual void setRawData (FKeyboard::keybuffer&) = 0;
|
||||||
|
@ -193,7 +193,7 @@ class FMouse
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename ClassT>
|
template <typename ClassT>
|
||||||
inline FMouse* FMouse::createMouseObject()
|
inline FMouse* FMouse::createMouseObject()
|
||||||
{
|
{
|
||||||
return new ClassT;
|
return new ClassT;
|
||||||
|
|
|
@ -170,9 +170,10 @@ class FScrollbar : public FWidget
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// non-member function forward declarations
|
// non-member function
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Instance, typename Callback>
|
template <typename Instance
|
||||||
|
, typename Callback>
|
||||||
void initScrollbar ( FScrollbarPtr& bar
|
void initScrollbar ( FScrollbarPtr& bar
|
||||||
, fc::orientation o
|
, fc::orientation o
|
||||||
, Instance cb_instance
|
, Instance cb_instance
|
||||||
|
|
|
@ -163,7 +163,7 @@ class FScrollView : public FWidget
|
||||||
void init();
|
void init();
|
||||||
void mapKeyFunctions();
|
void mapKeyFunctions();
|
||||||
void calculateScrollbarPos() const;
|
void calculateScrollbarPos() const;
|
||||||
template<typename Callback>
|
template <typename Callback>
|
||||||
void initScrollbar ( FScrollbarPtr&
|
void initScrollbar ( FScrollbarPtr&
|
||||||
, fc::orientation
|
, fc::orientation
|
||||||
, Callback );
|
, Callback );
|
||||||
|
@ -268,7 +268,7 @@ inline void FScrollView::print (const FPoint& pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Callback>
|
template <typename Callback>
|
||||||
inline void FScrollView::initScrollbar ( FScrollbarPtr& bar
|
inline void FScrollView::initScrollbar ( FScrollbarPtr& bar
|
||||||
, fc::orientation o
|
, fc::orientation o
|
||||||
, Callback cb_handler )
|
, Callback cb_handler )
|
||||||
|
|
|
@ -177,7 +177,7 @@ class FString
|
||||||
wchar_t front() const;
|
wchar_t front() const;
|
||||||
wchar_t back() const;
|
wchar_t back() const;
|
||||||
|
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
FString& sprintf (const FString&, Args&&...);
|
FString& sprintf (const FString&, Args&&...);
|
||||||
FString clear();
|
FString clear();
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ inline wchar_t FString::back() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
inline FString& FString::sprintf (const FString& format, Args&&... args)
|
inline FString& FString::sprintf (const FString& format, Args&&... args)
|
||||||
{
|
{
|
||||||
static constexpr int BUFSIZE = 4096;
|
static constexpr int BUFSIZE = 4096;
|
||||||
|
|
|
@ -278,7 +278,7 @@ class FTerm final
|
||||||
static void saveColorMap();
|
static void saveColorMap();
|
||||||
static void resetColorMap();
|
static void resetColorMap();
|
||||||
static void setPalette (FColor, int, int, int);
|
static void setPalette (FColor, int, int, int);
|
||||||
template<typename ClassT>
|
template <typename ClassT>
|
||||||
static void setColorPaletteTheme (const FSetPalette& = &FTerm::setPalette);
|
static void setColorPaletteTheme (const FSetPalette& = &FTerm::setPalette);
|
||||||
static void setBeep (int, int);
|
static void setBeep (int, int);
|
||||||
static void resetBeep();
|
static void resetBeep();
|
||||||
|
@ -295,7 +295,7 @@ class FTerm final
|
||||||
static bool scrollTermReverse();
|
static bool scrollTermReverse();
|
||||||
|
|
||||||
static defaultPutChar& putchar(); // function pointer
|
static defaultPutChar& putchar(); // function pointer
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
static void putstringf (const char[], Args&&...);
|
static void putstringf (const char[], Args&&...);
|
||||||
static void putstring (const char[], int = 1);
|
static void putstring (const char[], int = 1);
|
||||||
static int putchar_ASCII (int);
|
static int putchar_ASCII (int);
|
||||||
|
@ -443,7 +443,7 @@ inline bool FTerm::unsetUTF8()
|
||||||
{ return setUTF8(false); }
|
{ return setUTF8(false); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename ClassT>
|
template <typename ClassT>
|
||||||
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
||||||
{
|
{
|
||||||
getColorPaletteTheme() = std::make_shared<ClassT>(f);
|
getColorPaletteTheme() = std::make_shared<ClassT>(f);
|
||||||
|
@ -451,7 +451,7 @@ inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
inline void FTerm::putstringf (const char format[], Args&&... args)
|
inline void FTerm::putstringf (const char format[], Args&&... args)
|
||||||
{
|
{
|
||||||
const int size = std::snprintf (nullptr, 0, format, args...) + 1;
|
const int size = std::snprintf (nullptr, 0, format, args...) + 1;
|
||||||
|
|
|
@ -63,7 +63,7 @@ class FTermBuffer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FTermBuffer() = default;
|
FTermBuffer() = default;
|
||||||
template<typename Iterator>
|
template <typename Iterator>
|
||||||
FTermBuffer (Iterator, Iterator);
|
FTermBuffer (Iterator, Iterator);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
@ -95,7 +95,7 @@ class FTermBuffer
|
||||||
FChar back() const;
|
FChar back() const;
|
||||||
const FString toString() const;
|
const FString toString() const;
|
||||||
void clear();
|
void clear();
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
int writef (const FString&, Args&&...);
|
int writef (const FString&, Args&&...);
|
||||||
int write (const FString&);
|
int write (const FString&);
|
||||||
int write (wchar_t);
|
int write (wchar_t);
|
||||||
|
@ -114,7 +114,7 @@ class FTermBuffer
|
||||||
|
|
||||||
// FTermBuffer inline functions
|
// FTermBuffer inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename Iterator>
|
template <typename Iterator>
|
||||||
inline FTermBuffer::FTermBuffer(Iterator first, Iterator last)
|
inline FTermBuffer::FTermBuffer(Iterator first, Iterator last)
|
||||||
{
|
{
|
||||||
data.assign(first, last);
|
data.assign(first, last);
|
||||||
|
@ -216,7 +216,7 @@ inline void FTermBuffer::clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
inline int FTermBuffer::writef (const FString& format, Args&&... args)
|
inline int FTermBuffer::writef (const FString& format, Args&&... args)
|
||||||
{
|
{
|
||||||
FString str{};
|
FString str{};
|
||||||
|
|
|
@ -96,17 +96,18 @@ class FTermcap final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
const FString getClassName() const;
|
const FString getClassName() const;
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
static bool getFlag (const CharT&);
|
static bool getFlag (const CharT&);
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
static int getNumber (const CharT&);
|
static int getNumber (const CharT&);
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
static char* getString (const CharT&);
|
static char* getString (const CharT&);
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
static char* encodeMotionParameter (const CharT&, int, int);
|
static char* encodeMotionParameter (const CharT&, int, int);
|
||||||
template<typename CharT, typename... Args>
|
template <typename CharT
|
||||||
|
, typename... Args>
|
||||||
static char* encodeParameter (const CharT&, Args&&...);
|
static char* encodeParameter (const CharT&, Args&&...);
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
static int paddingPrint (const CharT&, int, fn_putc);
|
static int paddingPrint (const CharT&, int, fn_putc);
|
||||||
|
|
||||||
// Inquiry
|
// Inquiry
|
||||||
|
@ -159,42 +160,43 @@ inline const FString FTermcap::getClassName() const
|
||||||
{ return "FTermcap"; }
|
{ return "FTermcap"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
bool FTermcap::getFlag (const CharT& cap)
|
bool FTermcap::getFlag (const CharT& cap)
|
||||||
{
|
{
|
||||||
return ::tgetflag(C_STR(cap));
|
return ::tgetflag(C_STR(cap));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
int FTermcap::getNumber (const CharT& cap)
|
int FTermcap::getNumber (const CharT& cap)
|
||||||
{
|
{
|
||||||
return ::tgetnum(C_STR(cap));
|
return ::tgetnum(C_STR(cap));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
char* FTermcap::getString (const CharT& cap)
|
char* FTermcap::getString (const CharT& cap)
|
||||||
{
|
{
|
||||||
return ::tgetstr(C_STR(cap), reinterpret_cast<char**>(&string_buf));
|
return ::tgetstr(C_STR(cap), reinterpret_cast<char**>(&string_buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
char* FTermcap::encodeMotionParameter (const CharT& cap, int col, int row)
|
char* FTermcap::encodeMotionParameter (const CharT& cap, int col, int row)
|
||||||
{
|
{
|
||||||
return ::tgoto(C_STR(cap), col, row);
|
return ::tgoto(C_STR(cap), col, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename CharT, typename... Args>
|
template <typename CharT
|
||||||
|
, typename... Args>
|
||||||
inline char* FTermcap::encodeParameter (const CharT& cap, Args&&... args)
|
inline char* FTermcap::encodeParameter (const CharT& cap, Args&&... args)
|
||||||
{
|
{
|
||||||
return ::tparm (C_STR(cap), std::forward<Args>(args)...);
|
return ::tparm (C_STR(cap), std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename CharT>
|
template <typename CharT>
|
||||||
int FTermcap::paddingPrint (const CharT& str, int affcnt, fn_putc putc)
|
int FTermcap::paddingPrint (const CharT& str, int affcnt, fn_putc putc)
|
||||||
{
|
{
|
||||||
return _tputs (C_STR(str), affcnt, putc);
|
return _tputs (C_STR(str), affcnt, putc);
|
||||||
|
|
|
@ -152,7 +152,7 @@ class FTermLinux final
|
||||||
modifier_key& getModifierKey();
|
modifier_key& getModifierKey();
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
int setScreenFont ( uChar[], uInt, uInt, uInt
|
int setScreenFont ( const uChar[], uInt, uInt, uInt
|
||||||
, bool = false );
|
, bool = false );
|
||||||
int setUnicodeMap (struct unimapdesc*);
|
int setUnicodeMap (struct unimapdesc*);
|
||||||
void setLinuxCursorStyle (fc::linuxConsoleCursorStyle) const;
|
void setLinuxCursorStyle (fc::linuxConsoleCursorStyle) const;
|
||||||
|
|
|
@ -112,10 +112,10 @@ class FTextView : public FWidget
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void hide() override;
|
void hide() override;
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void append (const std::initializer_list<T>&);
|
void append (const std::initializer_list<T>&);
|
||||||
void append (const FString&);
|
void append (const FString&);
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void insert (const std::initializer_list<T>&, int);
|
void insert (const std::initializer_list<T>&, int);
|
||||||
void insert (const FString&, int);
|
void insert (const FString&, int);
|
||||||
void replaceRange (const FString&, int, int);
|
void replaceRange (const FString&, int, int);
|
||||||
|
@ -232,7 +232,7 @@ inline void FTextView::scrollTo (const FPoint& pos)
|
||||||
{ scrollTo(pos.getX(), pos.getY()); }
|
{ scrollTo(pos.getX(), pos.getY()); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void FTextView::append (const std::initializer_list<T>& list)
|
void FTextView::append (const std::initializer_list<T>& list)
|
||||||
{
|
{
|
||||||
for (auto& str : list)
|
for (auto& str : list)
|
||||||
|
@ -240,7 +240,7 @@ void FTextView::append (const std::initializer_list<T>& list)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void FTextView::insert (const std::initializer_list<T>& list, int pos)
|
void FTextView::insert (const std::initializer_list<T>& list, int pos)
|
||||||
{
|
{
|
||||||
for (auto& str : list)
|
for (auto& str : list)
|
||||||
|
|
|
@ -75,7 +75,11 @@ typedef std::function<void()> FCall;
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename T, bool is_signed>
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T
|
||||||
|
, bool is_signed>
|
||||||
struct is_negative
|
struct is_negative
|
||||||
{
|
{
|
||||||
inline bool operator () (const T& x) const
|
inline bool operator () (const T& x) const
|
||||||
|
@ -93,10 +97,12 @@ struct is_negative<T, false>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool isNegative (const T& x)
|
constexpr bool isNegative (const T& x)
|
||||||
{
|
{
|
||||||
return is_negative<T, std::numeric_limits<T>::is_signed>()(x);
|
return internal::is_negative<T, std::numeric_limits<T>::is_signed>()(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -259,7 +259,7 @@ class FVTerm
|
||||||
virtual void addPreprocessingHandler ( const FVTerm*
|
virtual void addPreprocessingHandler ( const FVTerm*
|
||||||
, const FPreprocessingFunction& );
|
, const FPreprocessingFunction& );
|
||||||
virtual void delPreprocessingHandler (const FVTerm*);
|
virtual void delPreprocessingHandler (const FVTerm*);
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
int printf (const FString&, Args&&...);
|
int printf (const FString&, Args&&...);
|
||||||
int print (const FString&);
|
int print (const FString&);
|
||||||
int print (FTermArea*, const FString&);
|
int print (FTermArea*, const FString&);
|
||||||
|
@ -926,7 +926,7 @@ inline bool FVTerm::isInheritBackground()
|
||||||
{ return next_attribute.attr.bit.inherit_background; }
|
{ return next_attribute.attr.bit.inherit_background; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
inline int FVTerm::printf (const FString& format, Args&&... args)
|
inline int FVTerm::printf (const FString& format, Args&&... args)
|
||||||
{
|
{
|
||||||
FString str{};
|
FString str{};
|
||||||
|
|
|
@ -240,7 +240,7 @@ class FWidget : public FVTerm, public FObject
|
||||||
static void setMoveSizeWidget (FWidget*);
|
static void setMoveSizeWidget (FWidget*);
|
||||||
static void setActiveWindow (FWidget*);
|
static void setActiveWindow (FWidget*);
|
||||||
static void setOpenMenu (FWidget*);
|
static void setOpenMenu (FWidget*);
|
||||||
template<typename ClassT>
|
template <typename ClassT>
|
||||||
static void setColorTheme();
|
static void setColorTheme();
|
||||||
FAcceleratorList& setAcceleratorList();
|
FAcceleratorList& setAcceleratorList();
|
||||||
virtual void setStatusbarMessage (const FString&);
|
virtual void setStatusbarMessage (const FString&);
|
||||||
|
@ -317,9 +317,9 @@ class FWidget : public FVTerm, public FObject
|
||||||
int numOfFocusableChildren();
|
int numOfFocusableChildren();
|
||||||
virtual bool close();
|
virtual bool close();
|
||||||
void clearStatusbarMessage();
|
void clearStatusbarMessage();
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
void addCallback (const FString&, Args&&...) noexcept;
|
void addCallback (const FString&, Args&&...) noexcept;
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
void delCallback (Args&&...) noexcept;
|
void delCallback (Args&&...) noexcept;
|
||||||
void emitCallback (const FString&) const;
|
void emitCallback (const FString&) const;
|
||||||
void addAccelerator (FKey);
|
void addAccelerator (FKey);
|
||||||
|
@ -770,7 +770,7 @@ inline void FWidget::setOpenMenu (FWidget* obj)
|
||||||
{ open_menu = obj; }
|
{ open_menu = obj; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename ClassT>
|
template <typename ClassT>
|
||||||
inline void FWidget::setColorTheme()
|
inline void FWidget::setColorTheme()
|
||||||
{
|
{
|
||||||
getColorTheme() = std::make_shared<ClassT>();
|
getColorTheme() = std::make_shared<ClassT>();
|
||||||
|
@ -984,14 +984,14 @@ inline void FWidget::clearStatusbarMessage()
|
||||||
{ statusbar_message.clear(); }
|
{ statusbar_message.clear(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
inline void FWidget::addCallback (const FString& cb_signal, Args&&... args) noexcept
|
inline void FWidget::addCallback (const FString& cb_signal, Args&&... args) noexcept
|
||||||
{
|
{
|
||||||
callback_impl.addCallback (cb_signal, std::forward<Args>(args)...);
|
callback_impl.addCallback (cb_signal, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
inline void FWidget::delCallback (Args&&... args) noexcept
|
inline void FWidget::delCallback (Args&&... args) noexcept
|
||||||
{
|
{
|
||||||
callback_impl.delCallback(std::forward<Args>(args)...);
|
callback_impl.delCallback(std::forward<Args>(args)...);
|
||||||
|
|
|
@ -39,13 +39,13 @@
|
||||||
class Widget
|
class Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
void addCallback (const finalcut::FString& cb_signal, Args&&... args)
|
void addCallback (const finalcut::FString& cb_signal, Args&&... args)
|
||||||
{
|
{
|
||||||
cb.addCallback (cb_signal, std::forward<Args>(args)...);
|
cb.addCallback (cb_signal, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template <typename... Args>
|
||||||
void delCallback (Args&&... args)
|
void delCallback (Args&&... args)
|
||||||
{
|
{
|
||||||
cb.delCallback (std::forward<Args>(args)...);
|
cb.delCallback (std::forward<Args>(args)...);
|
||||||
|
|
|
@ -122,7 +122,12 @@ class FObject_userEvent : public finalcut::FObject
|
||||||
virtual void onUserEvent (finalcut::FUserEvent* ev)
|
virtual void onUserEvent (finalcut::FUserEvent* ev)
|
||||||
{
|
{
|
||||||
if ( ev->getUserId() == 42 )
|
if ( ev->getUserId() == 42 )
|
||||||
value = *(static_cast<int*>(ev->getData()));
|
{
|
||||||
|
value = ev->getData<int>();
|
||||||
|
|
||||||
|
if ( ev->getFDataObject<int>().isInitializedReference() )
|
||||||
|
ev->getData<int>()++; // this has external effects
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -625,9 +630,10 @@ void FObjectTest::userEventTest()
|
||||||
|
|
||||||
int n = 9;
|
int n = 9;
|
||||||
finalcut::FUserEvent user_ev (finalcut::fc::User_Event, 42);
|
finalcut::FUserEvent user_ev (finalcut::fc::User_Event, 42);
|
||||||
user_ev.setData( (void*)(&n) );
|
user_ev.setData(n);
|
||||||
finalcut::FApplication::sendEvent (&user, &user_ev);
|
finalcut::FApplication::sendEvent (&user, &user_ev);
|
||||||
CPPUNIT_ASSERT ( user.getValue() == 9 );
|
CPPUNIT_ASSERT ( user.getValue() == 9 );
|
||||||
|
CPPUNIT_ASSERT ( n == 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the test suite in the registry
|
// Put the test suite in the registry
|
||||||
|
|
Loading…
Reference in New Issue