Small improvements
This commit is contained in:
parent
a14c45d8c7
commit
2c9778698e
|
@ -370,7 +370,7 @@ void stringConcatenationExample()
|
|||
|
||||
// Test: concatenate a FString and a wide string (operator +)
|
||||
const finalcut::FString& add3 = finalcut::FString("FString + ")
|
||||
+ const_cast<wchar_t*>(L"wchar_t*");
|
||||
+ L"wchar_t*";
|
||||
std::cout << " add: " << add3 << std::endl;
|
||||
|
||||
// Test: concatenate a FString and a c++ string (operator +)
|
||||
|
@ -402,7 +402,7 @@ void stringConcatenationExample()
|
|||
std::cout << " add: " << add9 << std::endl;
|
||||
|
||||
// Test: concatenate a c-string and a FString (operator +)
|
||||
const finalcut::FString& add10 = const_cast<char*>("char*")
|
||||
const finalcut::FString& add10 = "char*"
|
||||
+ finalcut::FString(" + FString");
|
||||
std::cout << " add: " << add10 << std::endl;
|
||||
|
||||
|
@ -412,7 +412,7 @@ void stringConcatenationExample()
|
|||
std::cout << " add: " << add11 << std::endl;
|
||||
|
||||
// Test: concatenate a wide string and a FString (operator +)
|
||||
const finalcut::FString& add12 = const_cast<wchar_t*>(L"wchar_t*")
|
||||
const finalcut::FString& add12 = L"wchar_t*"
|
||||
+ finalcut::FString(" + FString");
|
||||
std::cout << " add: " << add12 << std::endl;
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ class MyDialog final : public finalcut::FDialog
|
|||
void cb_copyClipboard();
|
||||
void cb_pasteClipboard();
|
||||
void cb_clearInput();
|
||||
void cb_switchTheme (const finalcut::FCheckMenuItem*) const;
|
||||
void cb_switchTheme (const finalcut::FCheckMenuItem*);
|
||||
void cb_input2buttonText ( finalcut::FButton&
|
||||
, const finalcut::FLineEdit& ) const;
|
||||
void cb_setTitlebar (const finalcut::FLineEdit&);
|
||||
|
@ -936,7 +936,7 @@ void MyDialog::cb_clearInput()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_switchTheme (const finalcut::FCheckMenuItem* check_menu) const
|
||||
void MyDialog::cb_switchTheme (const finalcut::FCheckMenuItem* check_menu)
|
||||
{
|
||||
if ( check_menu->isChecked() )
|
||||
finalcut::FApplication::setDarkTheme();
|
||||
|
|
|
@ -762,7 +762,7 @@ inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::sendKeyboardAccelerator() const
|
||||
inline void FApplication::sendKeyboardAccelerator()
|
||||
{
|
||||
if ( FWidget::getOpenMenu() )
|
||||
return;
|
||||
|
@ -782,7 +782,7 @@ inline void FApplication::sendKeyboardAccelerator() const
|
|||
// Global keyboard accelerator
|
||||
if ( ! accpt )
|
||||
{
|
||||
auto root_widget = static_cast<const FWidget*>(getRootWidget());
|
||||
auto root_widget = getRootWidget();
|
||||
|
||||
if ( root_widget )
|
||||
processAccelerator (root_widget);
|
||||
|
@ -1319,17 +1319,17 @@ void FApplication::performTimerAction (FObject* receiver, FEvent* event)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::isEventProcessable ( const FObject* receiver
|
||||
bool FApplication::isEventProcessable ( FObject* receiver
|
||||
, const FEvent* event )
|
||||
{
|
||||
if ( ! receiver->isWidget() ) // No restrictions for non-widgets
|
||||
return true;
|
||||
|
||||
const auto widget = static_cast<const FWidget*>(receiver);
|
||||
auto widget = static_cast<FWidget*>(receiver);
|
||||
|
||||
if ( getModalDialogCounter() > 0 )
|
||||
{
|
||||
const FWidget* window;
|
||||
FWidget* window;
|
||||
|
||||
if ( widget->isWindowWidget() )
|
||||
window = widget;
|
||||
|
|
|
@ -2849,11 +2849,8 @@ void FListView::cb_vbarChange (const FWidget*)
|
|||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
{
|
||||
int value = vbar->getValue();
|
||||
scrollToY (value);
|
||||
scrollToY (vbar->getValue());
|
||||
break;
|
||||
}
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
wheelUp (wheel_distance);
|
||||
|
|
|
@ -694,9 +694,9 @@ void FScrollView::copy2area()
|
|||
|
||||
// private methods of FScrollView
|
||||
//----------------------------------------------------------------------
|
||||
inline FPoint FScrollView::getViewportCursorPos() const
|
||||
inline FPoint FScrollView::getViewportCursorPos()
|
||||
{
|
||||
const auto& window = FWindow::getWindowWidget(this);
|
||||
auto window = FWindow::getWindowWidget(this);
|
||||
|
||||
if ( window )
|
||||
{
|
||||
|
@ -846,7 +846,7 @@ void FScrollView::setVerticalScrollBarVisibility() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setViewportCursor() const
|
||||
void FScrollView::setViewportCursor()
|
||||
{
|
||||
if ( ! isChild(getFocusWidget()) )
|
||||
return;
|
||||
|
|
|
@ -128,10 +128,8 @@ FString::FString (fc::SpecialCharacter c)
|
|||
{
|
||||
if ( c )
|
||||
{
|
||||
wchar_t s[2];
|
||||
s[0] = static_cast<wchar_t>(c);
|
||||
s[1] = L'\0';
|
||||
_assign (s);
|
||||
std::array<wchar_t, 2> s{{ static_cast<wchar_t>(c), L'\0' }};
|
||||
_assign (s.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,10 +138,8 @@ FString::FString (const wchar_t c)
|
|||
{
|
||||
if ( c )
|
||||
{
|
||||
wchar_t s[2];
|
||||
s[0] = c;
|
||||
s[1] = L'\0';
|
||||
_assign (s);
|
||||
std::array<wchar_t, 2> s{{ c, L'\0' }};
|
||||
_assign (s.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,10 +148,8 @@ FString::FString (const char c)
|
|||
{
|
||||
if ( c )
|
||||
{
|
||||
wchar_t s[2];
|
||||
s[0] = wchar_t(c & 0xff);
|
||||
s[1] = L'\0';
|
||||
_assign (s);
|
||||
std::array<wchar_t, 2> s{{ wchar_t(c & 0xff), L'\0' }};
|
||||
_assign (s.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +397,10 @@ char* FString::c_str()
|
|||
if ( length > 0 )
|
||||
return const_cast<char*>(_to_cstring(string));
|
||||
else if ( string )
|
||||
return const_cast<char*>("");
|
||||
{
|
||||
static char empty_string[] = "";
|
||||
return empty_string;
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -769,7 +766,7 @@ FString& FString::setString (const FString& s)
|
|||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (sInt64 num)
|
||||
{
|
||||
wchar_t buf[30]{};
|
||||
std::array<wchar_t, 30> buf{};
|
||||
wchar_t* s = &buf[29]; // Pointer to the last character
|
||||
auto abs_num = static_cast<uInt64>(num);
|
||||
|
||||
|
@ -813,7 +810,7 @@ FString& FString::setNumber (uInt64 num)
|
|||
//----------------------------------------------------------------------
|
||||
FString& FString::setNumber (lDouble f_num, int precision)
|
||||
{
|
||||
wchar_t format[20]{}; // = "%.<precision>Lg"
|
||||
std::array<wchar_t, 20> format{}; // = "%.<precision>Lg"
|
||||
wchar_t* s = &format[0];
|
||||
*s++ = L'%';
|
||||
*s++ = L'.';
|
||||
|
@ -838,14 +835,14 @@ FString& FString::setNumber (lDouble f_num, int precision)
|
|||
*s++ = L'g';
|
||||
*s = L'\0';
|
||||
|
||||
return sprintf(format, f_num);
|
||||
return sprintf(format.data(), f_num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::setFormatedNumber (sInt64 num, char separator)
|
||||
{
|
||||
int n{0};
|
||||
wchar_t buf[30]{};
|
||||
std::array<wchar_t, 30> buf{};
|
||||
wchar_t* s = &buf[29]; // Pointer to the last character
|
||||
auto abs_num = static_cast<uInt64>(num);
|
||||
|
||||
|
@ -1515,7 +1512,7 @@ inline const wchar_t* FString::_extractToken ( wchar_t* rest[]
|
|||
if ( ! token[0] )
|
||||
return nullptr;
|
||||
|
||||
*rest = std::wcspbrk(token, delim);
|
||||
*rest = std::wcspbrk(std::move(token), delim);
|
||||
|
||||
if ( *rest )
|
||||
*(*rest)++ = '\0';
|
||||
|
@ -1555,9 +1552,9 @@ std::ostream& operator << (std::ostream& outstr, const FString& s)
|
|||
//----------------------------------------------------------------------
|
||||
std::istream& operator >> (std::istream& instr, FString& s)
|
||||
{
|
||||
char buf[FString::INPBUFFER + 1]{};
|
||||
instr.getline (buf, FString::INPBUFFER);
|
||||
const wchar_t* wc_str = s._to_wcstring(buf);
|
||||
std::array<char, FString::INPBUFFER + 1> buf{};
|
||||
instr.getline (buf.data(), FString::INPBUFFER);
|
||||
const wchar_t* wc_str = s._to_wcstring(buf.data());
|
||||
|
||||
if ( wc_str )
|
||||
{
|
||||
|
@ -1589,9 +1586,9 @@ std::wostream& operator << (std::wostream& outstr, const FString& s)
|
|||
//----------------------------------------------------------------------
|
||||
std::wistream& operator >> (std::wistream& instr, FString& s)
|
||||
{
|
||||
wchar_t buf[FString::INPBUFFER + 1]{};
|
||||
instr.getline (buf, FString::INPBUFFER);
|
||||
s._assign (buf);
|
||||
std::array<wchar_t, FString::INPBUFFER + 1> buf{};
|
||||
instr.getline (buf.data(), FString::INPBUFFER);
|
||||
s._assign (buf.data());
|
||||
return instr;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ bool FTermDetection::getTTYtype()
|
|||
term_basename++;
|
||||
|
||||
std::FILE* fp{};
|
||||
char str[BUFSIZ]{};
|
||||
std::array<char, BUFSIZ> str{};
|
||||
|
||||
if ( ! fsystem )
|
||||
return false;
|
||||
|
@ -220,11 +220,11 @@ bool FTermDetection::getTTYtype()
|
|||
return false;
|
||||
|
||||
// Read and parse the file
|
||||
while ( fgets(str, sizeof(str) - 1, fp) != nullptr )
|
||||
while ( fgets(str.data(), str.size() - 1, fp) != nullptr )
|
||||
{
|
||||
const char* type{nullptr}; // nullptr == not found
|
||||
const char* name{nullptr};
|
||||
char* p = str;
|
||||
char* p = str.data();
|
||||
|
||||
while ( *p )
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ bool FTermDetection::getTTYtype()
|
|||
*p = '\0';
|
||||
else if ( type == nullptr )
|
||||
type = p;
|
||||
else if ( name == nullptr && p != str && p[-1] == '\0' )
|
||||
else if ( name == nullptr && p != str.data() && p[-1] == '\0' )
|
||||
name = p;
|
||||
|
||||
p++;
|
||||
|
|
|
@ -141,9 +141,9 @@ FWidget::~FWidget() // destructor
|
|||
|
||||
// public methods of FWidget
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FWidget::getRootWidget() const
|
||||
FWidget* FWidget::getRootWidget()
|
||||
{
|
||||
auto obj = const_cast<FWidget*>(this);
|
||||
FWidget* obj = this;
|
||||
auto p_obj = getParentWidget();
|
||||
|
||||
while ( ! obj->isRootWidget() && p_obj )
|
||||
|
@ -1322,7 +1322,7 @@ void FWidget::adjustSize()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::adjustSizeGlobal() const
|
||||
void FWidget::adjustSizeGlobal()
|
||||
{
|
||||
if ( ! isRootWidget() )
|
||||
{
|
||||
|
|
|
@ -483,7 +483,7 @@ void FWindow::delWindow (const FWidget* obj)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWindow* FWindow::getWindowWidget (const FWidget* obj)
|
||||
FWindow* FWindow::getWindowWidget (FWidget* obj)
|
||||
{
|
||||
// returns the window object to the given widget obj
|
||||
auto p_obj = obj->getParentWidget();
|
||||
|
@ -495,17 +495,17 @@ FWindow* FWindow::getWindowWidget (const FWidget* obj)
|
|||
}
|
||||
|
||||
if ( obj->isWindowWidget() )
|
||||
return const_cast<FWindow*>(reinterpret_cast<const FWindow*>(obj));
|
||||
return static_cast<FWindow*>(obj);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FWindow::getWindowLayer (const FWidget* obj)
|
||||
int FWindow::getWindowLayer (FWidget* obj)
|
||||
{
|
||||
// returns the window layer from the widget obj
|
||||
|
||||
const FWidget* window;
|
||||
FWidget* window;
|
||||
|
||||
if ( ! getWindowList() )
|
||||
return -1;
|
||||
|
|
|
@ -186,7 +186,7 @@ class FApplication : public FWidget
|
|||
bool sendKeyDownEvent (FWidget*) const;
|
||||
bool sendKeyPressEvent (FWidget*) const;
|
||||
bool sendKeyUpEvent (FWidget*) const;
|
||||
void sendKeyboardAccelerator() const;
|
||||
void sendKeyboardAccelerator();
|
||||
void processKeyboardEvent() const;
|
||||
bool processDialogSwitchAccelerator() const;
|
||||
bool processAccelerator (const FWidget* const&) const;
|
||||
|
@ -216,7 +216,7 @@ class FApplication : public FWidget
|
|||
void processLogger() const;
|
||||
bool processNextEvent();
|
||||
void performTimerAction (FObject*, FEvent*) override;
|
||||
static bool isEventProcessable (const FObject*, const FEvent*);
|
||||
static bool isEventProcessable (FObject*, const FEvent*);
|
||||
static bool isNextEventTimeout();
|
||||
|
||||
// Data members
|
||||
|
|
|
@ -157,7 +157,7 @@ class FScrollView : public FWidget
|
|||
static constexpr int horizontal_border_spacing = 2;
|
||||
|
||||
// Accessors
|
||||
FPoint getViewportCursorPos() const;
|
||||
FPoint getViewportCursorPos();
|
||||
|
||||
// Methods
|
||||
void init();
|
||||
|
@ -169,7 +169,7 @@ class FScrollView : public FWidget
|
|||
, Callback );
|
||||
void setHorizontalScrollBarVisibility() const;
|
||||
void setVerticalScrollBarVisibility() const;
|
||||
void setViewportCursor() const;
|
||||
void setViewportCursor();
|
||||
|
||||
// Callback methods
|
||||
void cb_vbarChange (const FWidget*);
|
||||
|
|
|
@ -83,7 +83,7 @@ class FStringStream : public std::wiostream
|
|||
virtual FString getClassName() const;
|
||||
void swap (FStringStream&) noexcept;
|
||||
void clear();
|
||||
std::wstringbuf* rdbuf() const;
|
||||
std::wstringbuf* rdbuf();
|
||||
FString str() const;
|
||||
|
||||
private:
|
||||
|
@ -101,8 +101,8 @@ inline void FStringStream::clear()
|
|||
{ buffer.str(L""); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline std::wstringbuf* FStringStream::rdbuf() const
|
||||
{ return const_cast<std::wstringbuf*>(&buffer); }
|
||||
inline std::wstringbuf* FStringStream::rdbuf()
|
||||
{ return &buffer; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FStringStream::str() const
|
||||
|
|
|
@ -184,7 +184,7 @@ class FWidget : public FVTerm, public FObject
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const override;
|
||||
FWidget* getRootWidget() const;
|
||||
FWidget* getRootWidget();
|
||||
FWidget* getParentWidget() const;
|
||||
static FWidget*& getMainWidget();
|
||||
static FWidget*& getActiveWindow();
|
||||
|
@ -364,7 +364,7 @@ class FWidget : public FVTerm, public FObject
|
|||
void initTerminal() override;
|
||||
void initDesktop();
|
||||
virtual void adjustSize();
|
||||
void adjustSizeGlobal() const;
|
||||
void adjustSizeGlobal();
|
||||
void hideArea (const FSize&);
|
||||
virtual bool focusNextChild(); // Change child...
|
||||
virtual bool focusPrevChild(); // ...focus
|
||||
|
|
|
@ -84,8 +84,8 @@ class FWindow : public FWidget
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const override;
|
||||
static FWindow* getWindowWidget (const FWidget*);
|
||||
static int getWindowLayer (const FWidget*);
|
||||
static FWindow* getWindowWidget (FWidget*);
|
||||
static int getWindowLayer (FWidget*);
|
||||
FWidget* getWindowFocusWidget() const;
|
||||
|
||||
// Mutators
|
||||
|
|
Loading…
Reference in New Issue