Fixed some minor bugs
This commit is contained in:
parent
b54d1c2f38
commit
50fc6fdb63
|
@ -108,7 +108,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
|
|||
}
|
||||
else
|
||||
{
|
||||
for (uInt n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
delete button[n];
|
||||
|
||||
if ( mbox.getParentWidget() )
|
||||
|
@ -138,7 +138,7 @@ void FMessageBox::setHeadline (const FString& headline)
|
|||
headline_text.setString(headline);
|
||||
setHeight(getHeight() + 2, true);
|
||||
|
||||
for (uInt n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
button[n]->setY (int(getHeight()) - 4, false);
|
||||
|
||||
const std::size_t column_width = getColumnWidth(headline_text);
|
||||
|
@ -268,7 +268,7 @@ inline void FMessageBox::allocation()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FMessageBox::deallocation()
|
||||
{
|
||||
for (uInt n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
delete button[n];
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ void FMessageBox::resizeButtons() const
|
|||
std::size_t len[3]{};
|
||||
std::size_t max_size{};
|
||||
|
||||
for (std::size_t n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
{
|
||||
len[n] = button[n]->getText().getLength();
|
||||
|
||||
|
@ -410,7 +410,7 @@ void FMessageBox::resizeButtons() const
|
|||
if ( max_size < 7 )
|
||||
max_size = 7;
|
||||
|
||||
for (std::size_t n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
button[n]->setWidth(max_size + 3, false);
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ void FMessageBox::adjustButtons()
|
|||
static constexpr std::size_t gap = 4;
|
||||
std::size_t btn_width{0};
|
||||
|
||||
for (std::size_t n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
{
|
||||
if ( n == num_buttons - 1 )
|
||||
btn_width += button[n]->getWidth();
|
||||
|
@ -439,7 +439,7 @@ void FMessageBox::adjustButtons()
|
|||
|
||||
const int btn_x = int((getWidth() - btn_width) / 2);
|
||||
|
||||
for (std::size_t n{0}; n < num_buttons && button[n]; n++)
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
{
|
||||
if ( n == 0 )
|
||||
button[n]->setX(btn_x);
|
||||
|
|
|
@ -137,6 +137,9 @@ class FMessageBox : public FDialog
|
|||
void cb_processClick (int);
|
||||
|
||||
private:
|
||||
// Constants
|
||||
static constexpr std::size_t MAX_BUTTONS = 3;
|
||||
|
||||
// Methods
|
||||
void init();
|
||||
void allocation();
|
||||
|
@ -151,11 +154,11 @@ class FMessageBox : public FDialog
|
|||
FString headline_text{};
|
||||
FString text{};
|
||||
FStringList text_components{};
|
||||
FButton* button[3]{nullptr};
|
||||
FButton* button[MAX_BUTTONS]{nullptr};
|
||||
std::size_t max_line_width{0};
|
||||
FColor emphasis_color{getColorTheme()->dialog_emphasis_fg};
|
||||
int button_digit[3]{0};
|
||||
uInt num_buttons{0};
|
||||
int button_digit[MAX_BUTTONS]{0};
|
||||
std::size_t num_buttons{0};
|
||||
std::size_t text_num_lines{0};
|
||||
bool center_text{false};
|
||||
};
|
||||
|
|
|
@ -320,7 +320,7 @@ class FWidget : public FVTerm, public FObject
|
|||
void addCallback (const FString&, Args&&...);
|
||||
template<typename... Args>
|
||||
void delCallback (Args&&...);
|
||||
void emitCallback (const FString&);
|
||||
void emitCallback (const FString&) const;
|
||||
void addAccelerator (FKey);
|
||||
virtual void addAccelerator (FKey, FWidget*);
|
||||
void delAccelerator ();
|
||||
|
@ -997,7 +997,7 @@ inline void FWidget::delCallback (Args&&... args)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FWidget::emitCallback (const FString& emit_signal)
|
||||
inline void FWidget::emitCallback (const FString& emit_signal) const
|
||||
{
|
||||
callback_impl.emitCallback(emit_signal);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue