change prototype of Window::Recreate() and throw away almost-duplicated code
This commit is contained in:
@@ -83,7 +83,7 @@ void Scrollpad::Flush()
|
||||
space_pos = 0;
|
||||
}
|
||||
}
|
||||
Recreate();
|
||||
Recreate(itsWidth, std::max(itsHeight, itsRealHeight));
|
||||
itsBuffer.SetTemp(&s);
|
||||
static_cast<Window &>(*this) << itsBuffer;
|
||||
itsBuffer.SetTemp(0);
|
||||
@@ -118,15 +118,6 @@ void Scrollpad::RemoveFormatting()
|
||||
itsBuffer.RemoveFormatting(itsFoundValueBegin, itsFoundPattern, itsFoundValueEnd, itsFoundForEach);
|
||||
}
|
||||
|
||||
void Scrollpad::Recreate()
|
||||
{
|
||||
delwin(itsWindow);
|
||||
itsWindow = newpad(std::max(itsHeight, itsRealHeight), itsWidth);
|
||||
SetTimeout(itsWindowTimeout);
|
||||
SetColor(itsBaseColor, itsBgColor);
|
||||
keypad(itsWindow, 1);
|
||||
}
|
||||
|
||||
void Scrollpad::Refresh()
|
||||
{
|
||||
prefresh(itsWindow, itsBeginning, 0, itsStartY, itsStartX, itsStartY+itsHeight-1, itsStartX+itsWidth-1);
|
||||
|
||||
@@ -119,9 +119,7 @@ namespace NCurses
|
||||
Scrollpad &operator<<(const std::string &s);
|
||||
# endif // _UTF8
|
||||
|
||||
protected:
|
||||
virtual void Recreate();
|
||||
|
||||
private:
|
||||
basic_buffer<my_char_t> itsBuffer;
|
||||
|
||||
int itsBeginning;
|
||||
|
||||
@@ -177,7 +177,7 @@ void Window::SetBorder(Border border)
|
||||
itsStartY--;
|
||||
itsHeight += 2;
|
||||
itsWidth += 2;
|
||||
Recreate();
|
||||
Recreate(itsWidth, itsHeight);
|
||||
}
|
||||
else if (border != brNone && itsBorder == brNone)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ void Window::SetBorder(Border border)
|
||||
itsStartY++;
|
||||
itsHeight -= 2;
|
||||
itsWidth -= 2;
|
||||
Recreate();
|
||||
Recreate(itsWidth, itsHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,13 +208,13 @@ void Window::SetTitle(const std::string &new_title)
|
||||
{
|
||||
itsStartY += 2;
|
||||
itsHeight -= 2;
|
||||
Recreate();
|
||||
Recreate(itsWidth, itsHeight);
|
||||
}
|
||||
else if (new_title.empty() && !itsTitle.empty())
|
||||
{
|
||||
itsStartY -= 2;
|
||||
itsHeight += 2;
|
||||
Recreate();
|
||||
Recreate(itsWidth, itsHeight);
|
||||
}
|
||||
itsTitle = new_title;
|
||||
}
|
||||
@@ -231,10 +231,10 @@ void Window::DeleteHistory()
|
||||
itsHistory = 0;
|
||||
}
|
||||
|
||||
void Window::Recreate()
|
||||
void Window::Recreate(size_t width, size_t height)
|
||||
{
|
||||
delwin(itsWindow);
|
||||
itsWindow = newpad(itsHeight, itsWidth);
|
||||
itsWindow = newpad(height, width);
|
||||
SetTimeout(itsWindowTimeout);
|
||||
SetColor(itsColor, itsBgColor);
|
||||
keypad(itsWindow, 1);
|
||||
@@ -273,7 +273,7 @@ void Window::AdjustDimensions(size_t width, size_t height)
|
||||
void Window::Resize(size_t new_width, size_t new_height)
|
||||
{
|
||||
AdjustDimensions(new_width, new_height);
|
||||
Recreate();
|
||||
Recreate(itsWidth, itsHeight);
|
||||
}
|
||||
|
||||
void Window::ShowBorder() const
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace NCurses
|
||||
/// @see SetTitle()
|
||||
/// @see Resize()
|
||||
///
|
||||
virtual void Recreate();
|
||||
virtual void Recreate(size_t width, size_t height);
|
||||
|
||||
/// internal WINDOW pointers
|
||||
WINDOW *itsWindow;
|
||||
|
||||
Reference in New Issue
Block a user