Merge pull request #20 from gansm/master

Merge
This commit is contained in:
Markus Gans 2018-10-22 08:42:38 +02:00 committed by GitHub
commit fea2d1f5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
102 changed files with 2755 additions and 2649 deletions

View File

@ -1,3 +1,29 @@
2018-10-21 Markus Gans <guru.mail@muenster.de>
* Moving static attributes from FApplication to FWidget
2018-10-17 Markus Gans <guru.mail@muenster.de>
* Changed more variables from int to std::size_t
2018-10-14 Markus Gans <guru.mail@muenster.de>
* A width or height can not be negative.
For that reason the change from int to std::size_t
* FString fix for 32-bit architectures
2018-10-13 Markus Gans <guru.mail@muenster.de>
* Avoid using dynamic_cast so that you can compile Final Cut
without Run-Time Type Information (RTTI).
Thanks to user1095108 for reporting that.
2018-10-11 Markus Gans <guru.mail@muenster.de>
* FKeyboard now uses references for keyboard buffer passing
2018-10-09 Markus Gans <guru.mail@muenster.de>
* Terminal detection for newer vte libraries (>= 0.53.0)
2018-10-08 Markus Gans <guru.mail@muenster.de>
* Move all termcap code into FTermcap
* Some small code splits
2018-10-05 Markus Gans <guru.mail@muenster.de>
* Remove redundant program code from FString

View File

@ -43,7 +43,7 @@ fi
# Build commands
case "$1" in
"--release"|"release")
if ! ./configure --prefix="$PREFIX"
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3 -fno-rtti"
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit -1

View File

@ -29,7 +29,7 @@ endif
all: $(OBJS)
debug:
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded"
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded -Wno-reserved-id-macro"
profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg"

View File

@ -1100,10 +1100,10 @@ void Calc::cb_buttonClicked (finalcut::FWidget*, data_ptr data)
//----------------------------------------------------------------------
void Calc::adjustSize()
{
int pw = getParentWidget()->getWidth();
int ph = getParentWidget()->getHeight();
setX (1 + (pw - getWidth()) / 2, false);
setY (1 + (ph - getHeight()) / 2, false);
std::size_t pw = getParentWidget()->getWidth();
std::size_t ph = getParentWidget()->getHeight();
setX (1 + int(pw - getWidth()) / 2, false);
setY (1 + int(ph - getHeight()) / 2, false);
finalcut::FDialog::adjustSize();
}

View File

@ -99,10 +99,10 @@ int main (int argc, char* argv[])
finalcut::FDialog dgl(&app);
dgl.setModal();
dgl.setText ("UNIX select");
int w = 20;
int h = 13;
int x = (app.getDesktopWidth() - w) / 2;
int y = (app.getDesktopHeight() - h) / 2;
std::size_t w = 20;
std::size_t h = 13;
int x = int(app.getDesktopWidth() - w) / 2;
int y = int(app.getDesktopHeight() - h) / 2;
dgl.setGeometry (x, y, w, h);
// Create a button group

View File

@ -56,7 +56,7 @@ void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
int key_id = ev->key();
bool is_last_line = false;
if ( getPrintPos().getY() == getDesktopHeight() )
if ( getPrintPos().getY() == int(getDesktopHeight()) )
is_last_line = true;
print() << "Key " << getKeyName(key_id).c_str()

View File

@ -80,8 +80,8 @@ void Mandelbrot::draw()
xoffset = 2;
yoffset = 2;
current_line = 0;
Cols = getClientWidth();
Lines = getClientHeight();
Cols = int(getClientWidth());
Lines = int(getClientHeight());
dX = (x_max - x_min) / (Cols - 1);
dY = (y_max - y_min) / Lines;
@ -131,8 +131,8 @@ void Mandelbrot::onClose (finalcut::FCloseEvent* ev)
//----------------------------------------------------------------------
void Mandelbrot::adjustSize()
{
int h = getParentWidget()->getHeight() - 1;
int w = getParentWidget()->getWidth() - 10;
std::size_t h = getParentWidget()->getHeight() - 1;
std::size_t w = getParentWidget()->getWidth() - 10;
setGeometry(6, 1, w, h, false);
finalcut::FDialog::adjustSize();
}

View File

@ -337,10 +337,10 @@ void Menu::defaultCallback (finalcut::FMenuList* mb)
//----------------------------------------------------------------------
void Menu::adjustSize()
{
int pw = getParentWidget()->getWidth();
int ph = getParentWidget()->getHeight();
setX (1 + (pw - getWidth()) / 2, false);
setY (1 + (ph - getHeight()) / 4, false);
int pw = int(getParentWidget()->getWidth());
int ph = int(getParentWidget()->getHeight());
setX (1 + (pw - int(getWidth())) / 2, false);
setY (1 + (ph - int(getHeight())) / 4, false);
finalcut::FDialog::adjustSize();
}

View File

@ -323,7 +323,7 @@ class MouseDraw : public finalcut::FDialog
~MouseDraw();
// Methods
void setGeometry (int, int, int, int, bool = true);
void setGeometry (int, int, std::size_t, std::size_t, bool = true);
// Event handlers
virtual void onAccel (finalcut::FAccelEvent*);
@ -382,7 +382,7 @@ MouseDraw::~MouseDraw()
{ }
//----------------------------------------------------------------------
void MouseDraw::setGeometry (int x, int y, int w, int h, bool adjust)
void MouseDraw::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
int old_w, old_h;
finalcut::FDialog::setGeometry (x, y, w, h, adjust);
@ -416,7 +416,7 @@ void MouseDraw::onClose (finalcut::FCloseEvent* ev)
//----------------------------------------------------------------------
void MouseDraw::draw()
{
int y_max = getHeight();
int y_max = int(getHeight());
finalcut::FDialog::draw();
setColor();
@ -452,8 +452,8 @@ void MouseDraw::draw()
//----------------------------------------------------------------------
void MouseDraw::drawBrush (int x, int y, bool swap_color)
{
int Cols = getWidth();
int Lines = getHeight();
int Cols = int(getWidth());
int Lines = int(getHeight());
if ( x > 10 && x < Cols && y > 2 && y < Lines )
{
@ -508,10 +508,9 @@ void MouseDraw::drawCanvas()
//----------------------------------------------------------------------
void MouseDraw::adjustSize()
{
int w = 60
, h = 18
, x = 1 + (getParentWidget()->getWidth() - w) / 2
, y = 1 + (getParentWidget()->getHeight() - h) / 2;
std::size_t w = 60, h = 18;
int x = 1 + int((getParentWidget()->getWidth() - w) / 2);
int y = 1 + int((getParentWidget()->getHeight() - h) / 2);
setGeometry (x, y, w, h, false);
finalcut::FDialog::adjustSize();
}

View File

@ -66,8 +66,8 @@ bool keyPressed()
void term_boundaries (int& x, int& y)
{
// checks and corrects the terminal boundaries
int term_width = app->getDesktopWidth();
int term_height = app->getDesktopHeight();
int term_width = int(app->getDesktopWidth());
int term_height = int(app->getDesktopHeight());
if ( x < 0 )
x = 0;
@ -152,9 +152,9 @@ int main (int argc, char* argv[])
app = &TermApp;
// Get screen dimension
xmax = TermApp.getDesktopWidth() - 1;
ymax = TermApp.getDesktopHeight() - 1;
finalcut::FString line(xmax + 1, '-');
xmax = int(TermApp.getDesktopWidth() - 1);
ymax = int(TermApp.getDesktopHeight() - 1);
finalcut::FString line(std::size_t(xmax) + 1, '-');
// Place the cursor in the upper left corner
TermApp.setTermXY(0,0);

View File

@ -40,7 +40,7 @@ class Scrollview : public finalcut::FScrollView
~Scrollview ();
// Mutator
void setScrollSize (int, int);
void setScrollSize (std::size_t, std::size_t);
private:
// Disable copy constructor
@ -83,9 +83,9 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
{
// Sets the navigation button geometry
go_east.setGeometry (1, 1, 5, 1);
go_south.setGeometry (getScrollWidth() - 5, 1, 5, 1);
go_west.setGeometry (getScrollWidth() - 5, getScrollHeight() - 2, 5, 1);
go_north.setGeometry (1, getScrollHeight() - 2, 5, 1);
go_south.setGeometry (int(getScrollWidth()) - 5, 1, 5, 1);
go_west.setGeometry (int(getScrollWidth()) - 5, int(getScrollHeight()) - 2, 5, 1);
go_north.setGeometry (1, int(getScrollHeight()) - 2, 5, 1);
// Add scroll function callbacks to the buttons
go_east.addCallback
@ -118,12 +118,12 @@ Scrollview::~Scrollview()
{ }
//----------------------------------------------------------------------
void Scrollview::setScrollSize (int width, int height)
void Scrollview::setScrollSize (std::size_t width, std::size_t height)
{
FScrollView::setScrollSize (width, height);
go_south.setPos (width - 5, 1);
go_west.setPos (width - 5, height - 1);
go_north.setPos (1, height - 1);
go_south.setPos (int(width) - 5, 1);
go_west.setPos (int(width) - 5, int(height) - 1);
go_north.setPos (1, int(height) - 1);
}
//----------------------------------------------------------------------
@ -135,11 +135,11 @@ void Scrollview::draw()
setColor (wc.label_inactive_fg, wc.dialog_bg);
clearArea();
for (int y = 0; y < getScrollHeight(); y++)
for (int y = 0; y < int(getScrollHeight()); y++)
{
setPrintPos (1, 1 + y);
for (int x = 0; x < getScrollWidth(); x++)
for (int x = 0; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f));
}
@ -152,7 +152,7 @@ void Scrollview::draw()
//----------------------------------------------------------------------
void Scrollview::cb_go_east (finalcut::FWidget*, data_ptr)
{
scrollToX (getScrollWidth() - getViewportWidth() + 1);
scrollToX (int(getScrollWidth() - getViewportWidth()) + 1);
go_south.setFocus();
go_east.redraw();
go_south.redraw();
@ -161,7 +161,7 @@ void Scrollview::cb_go_east (finalcut::FWidget*, data_ptr)
//----------------------------------------------------------------------
void Scrollview::cb_go_south (finalcut::FWidget*, data_ptr)
{
scrollToY (getScrollHeight() - getViewportHeight() + 1);
scrollToY (int(getScrollHeight() - getViewportHeight()) + 1);
go_west.setFocus();
go_south.redraw();
go_west.redraw();

View File

@ -77,9 +77,9 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
+ finalcut::FString(getTermType())
+ ")");
next_button.setGeometry(getWidth() - 13, getHeight() - 4, 10, 1);
next_button.setGeometry(int(getWidth()) - 13, int(getHeight()) - 4, 10, 1);
next_button.addAccelerator(finalcut::fc::Fkey_right);
back_button.setGeometry(getWidth() - 25, getHeight() - 4, 10, 1);
back_button.setGeometry(int(getWidth()) - 25, int(getHeight()) - 4, 10, 1);
back_button.addAccelerator(finalcut::fc::Fkey_left);
// Add function callbacks
@ -155,8 +155,8 @@ void AttribDlg::cb_back (finalcut::FWidget*, data_ptr)
//----------------------------------------------------------------------
void AttribDlg::adjustSize()
{
int x = ((getParentWidget()->getWidth() - getWidth()) / 2);
int y = ((getParentWidget()->getHeight() - getHeight()) / 2) + 1;
int x = int((getParentWidget()->getWidth() - getWidth()) / 2);
int y = int((getParentWidget()->getHeight() - getHeight()) / 2) + 1;
if ( x < 1 )
x = 1;
@ -165,8 +165,8 @@ void AttribDlg::adjustSize()
y = 1;
setGeometry(x, y, 69, 21, false);
next_button.setGeometry(getWidth() - 13, getHeight() - 4, 10, 1, false);
back_button.setGeometry(getWidth() - 25, getHeight() - 4, 10, 1, false);
next_button.setGeometry(int(getWidth()) - 13, int(getHeight()) - 4, 10, 1, false);
back_button.setGeometry(int(getWidth()) - 25, int(getHeight()) - 4, 10, 1, false);
finalcut::FDialog::adjustSize();
}
@ -399,7 +399,7 @@ void AttribDemo::draw()
// test alternate character set
printAltCharset();
for (int y = 0; y < getParentWidget()->getHeight() - 7; y++)
for (int y = 0; y < int(getParentWidget()->getHeight()) - 7; y++)
{
setPrintPos (1, 2 + y);

View File

@ -72,7 +72,7 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
bool is_last_line = false;
int timer_id = ev->timerId();
if ( getPrintPos().getY() == getDesktopHeight() )
if ( getPrintPos().getY() == int(getDesktopHeight()) )
is_last_line = true;
setColor (short(1 + timer_id), finalcut::fc::Default);

View File

@ -105,7 +105,7 @@ void Transparent::draw()
finalcut::FString line(getClientWidth(), wchar_t('.'));
for (int n = 1; n <= getClientHeight(); n++)
for (int n = 1; n <= int(getClientHeight()); n++)
{
setPrintPos (2, 2 + n);
print(line);
@ -264,7 +264,7 @@ void MainWindow::onShow (finalcut::FShowEvent*)
void MainWindow::onTimer (finalcut::FTimerEvent*)
{
wchar_t first_Char[2];
uInt length = line1.getLength();
std::size_t length = line1.getLength();
first_Char[0] = line1[0];
first_Char[1] = line2[0];
line1 = line1.right(length - 1) + first_Char[0];

View File

@ -297,7 +297,7 @@ Treeview::~Treeview() // destructor
//----------------------------------------------------------------------
void Treeview::adjustSize()
{
int h = getParentWidget()->getHeight() - 4;
std::size_t h = getParentWidget()->getHeight() - 4;
setHeight (h, false);
int X = int((getParentWidget()->getWidth() - getWidth()) / 2);
@ -309,7 +309,7 @@ void Treeview::adjustSize()
if ( initialized )
{
listView.setHeight (getHeight() - 6, false);
Quit.setY(getHeight() - 4);
Quit.setY(int(getHeight()) - 4);
}
finalcut::FDialog::adjustSize();

View File

@ -132,7 +132,7 @@ void ProgressDialog::onShow (finalcut::FShowEvent*)
//----------------------------------------------------------------------
void ProgressDialog::onTimer (finalcut::FTimerEvent*)
{
int p = progressBar.getPercentage();
std::size_t p = progressBar.getPercentage();
progressBar.setPercentage(++p);
flush_out();
@ -164,7 +164,7 @@ void ProgressDialog::cb_reset_bar (finalcut::FWidget*, data_ptr)
//----------------------------------------------------------------------
void ProgressDialog::cb_more_bar (finalcut::FWidget*, data_ptr)
{
int p = progressBar.getPercentage();
std::size_t p = progressBar.getPercentage();
progressBar.setPercentage(++p);
}
@ -780,7 +780,7 @@ void MyDialog::initWidgetsCallbacks()
//----------------------------------------------------------------------
void MyDialog::adjustSize()
{
int h = getParentWidget()->getHeight() - 4;
std::size_t h = getParentWidget()->getHeight() - 4;
setHeight (h, false);
int X = int((getParentWidget()->getWidth() - getWidth()) / 2);
@ -830,8 +830,8 @@ void MyDialog::cb_about (finalcut::FWidget*, data_ptr)
//----------------------------------------------------------------------
void MyDialog::cb_terminfo (finalcut::FWidget*, data_ptr)
{
int x = getDesktopWidth();
int y = getDesktopHeight();
std::size_t x = getDesktopWidth();
std::size_t y = getDesktopHeight();
finalcut::FMessageBox info1 \
(
"Environment"
@ -961,10 +961,10 @@ void MyDialog::cb_updateNumber (finalcut::FWidget* widget, data_ptr data)
finalcut::FListBox* list = static_cast<finalcut::FListBox*>(widget);
finalcut::FLabel* num = static_cast<finalcut::FLabel*>(data);
int select_num = 0;
uInt count = list->getCount();
std::size_t count = list->getCount();
for (uInt n = 1; n <= count; n++)
if ( list->isSelected(int(n)) )
for (std::size_t n = 1; n <= count; n++)
if ( list->isSelected(n) )
select_num++;
num->clear();
@ -1006,7 +1006,7 @@ void MyDialog::cb_view (finalcut::FWidget*, data_ptr data)
view->setGeometry ( 1 + int((getRootWidget()->getWidth() - 60) / 2),
int(getRootWidget()->getHeight() / 6),
60,
int(getRootWidget()->getHeight() * 3 / 4) );
getRootWidget()->getHeight() * 3 / 4 );
view->setResizeable();
std::string line = "";

View File

@ -83,7 +83,7 @@ Watch::Watch (FWidget* parent)
, quit_btn(L"&Quit", this)
{
setText ("Watch");
int pw = getParentWidget()->getWidth();
int pw = int(getParentWidget()->getWidth());
setGeometry (1 + (pw - 22) / 2, 3, 22, 13);
// Labels
@ -198,7 +198,7 @@ void Watch::cb_seconds (finalcut::FWidget*, data_ptr)
//----------------------------------------------------------------------
void Watch::adjustSize()
{
int pw = getParentWidget()->getWidth();
int pw = int(getParentWidget()->getWidth());
setX (1 + (pw - 22) / 2, false);
finalcut::FDialog::adjustSize();
}

View File

@ -86,7 +86,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
right_arrow.setForegroundColor (wc.label_inactive_fg);
right_arrow.setEmphasis();
right_arrow.ignorePadding();
right_arrow.setGeometry (getWidth() - 1, 2, 1, 1);
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1);
top_left_label = "menu";
top_left_label.setForegroundColor (wc.label_inactive_fg);
@ -97,7 +97,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
top_right_label.setAlignment (finalcut::fc::alignRight);
top_right_label.setForegroundColor (wc.label_inactive_fg);
top_right_label.setEmphasis();
top_right_label.setGeometry (getClientWidth() - 5, 1, 6, 1);
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1);
finalcut::FString bottom_label_text = "resize\n"
"corner\n";
@ -131,9 +131,9 @@ void SmallWindow::adjustSize()
}
finalcut::FDialog::adjustSize();
right_arrow.setGeometry (getWidth() - 1, 2, 1, 1);
top_right_label.setGeometry (getClientWidth() - 5, 1, 6, 1);
bottom_label.setGeometry (1, getClientHeight() - 2, getClientWidth(), 3);
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1);
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1);
bottom_label.setGeometry (1, int(getClientHeight()) - 2, getClientWidth(), 3);
}
//----------------------------------------------------------------------
@ -368,12 +368,12 @@ void Window::activateWindow (finalcut::FDialog* win)
void Window::adjustSize()
{
std::vector<win_data*>::const_iterator iter, first;
int w = getRootWidget()->getWidth()
, h = getRootWidget()->getHeight()
, X = int(1 + (w - 40) / 2)
std::size_t w = getRootWidget()->getWidth();
std::size_t h = getRootWidget()->getHeight();
int X = int(1 + (w - 40) / 2)
, Y = int(1 + (h - 22) / 2)
, dx = ( w > 80 ) ? (w - 80) / 2 : 0
, dy = ( h > 24 ) ? (h - 24) / 2 : 0;
, dx = ( w > 80 ) ? int(w - 80) / 2 : 0
, dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
if ( Y < 2 )
Y = 2;
@ -436,10 +436,10 @@ void Window::cb_createWindows (finalcut::FWidget*, data_ptr)
{
std::vector<win_data*>::const_iterator iter, first;
iter = first = windows.begin();
int w = getRootWidget()->getWidth()
, h = getRootWidget()->getHeight()
, dx = ( w > 80 ) ? (w - 80) / 2 : 0
, dy = ( h > 24 ) ? (h - 24) / 2 : 0;
std::size_t w = getRootWidget()->getWidth();
std::size_t h = getRootWidget()->getHeight();
int dx = ( w > 80 ) ? int(w - 80) / 2 : 0;
int dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
while ( iter != windows.end() )
{

View File

@ -247,12 +247,12 @@
y="93.333893"
transform="scale(0.95126779,1.0512287)"
id="text37-5"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:start;fill:#9f9f9f;fill-opacity:0.6206896;fill-rule:evenodd;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:start;fill:#9f9f9f;fill-opacity:0.6206896;fill-rule:evenodd;stroke:none;font-family:FreeSans, Arial, Bitstream Vera Sans, DejaVu Sans, Open Sans, sans-serif">
<tspan
x="160.94762"
y="93.333893"
id="tspan3006-1"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#9f9f9f;fill-opacity:0.6206896;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">FINAL CUT</tspan>
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#9f9f9f;fill-opacity:0.6206896;stroke:none;font-family:FreeSans, Arial, Bitstream Vera Sans, DejaVu Sans, Open Sans, sans-serif">FINAL CUT</tspan>
</text>
<g
id="g23"
@ -293,11 +293,11 @@
y="91.775856"
transform="scale(0.95126779,1.0512287)"
id="text37"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:start;fill:#083c99;fill-opacity:0.88747732;fill-rule:evenodd;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:start;fill:#083c99;fill-opacity:0.88747732;fill-rule:evenodd;stroke:none;font-family:FreeSans, Arial, Bitstream Vera Sans, DejaVu Sans, Open Sans, sans-serif">
<tspan
x="158.56929"
y="91.775856"
id="tspan3006"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#083c99;fill-opacity:0.88747732;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">FINAL CUT</tspan>
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#083c99;fill-opacity:0.88747732;stroke:none;font-family:FreeSans, Arial, Bitstream Vera Sans, DejaVu Sans, Open Sans, sans-serif">FINAL CUT</tspan>
</text>
</svg>

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -62,7 +62,7 @@ INCLUDE_HEADERS = \
# compiler parameter
CXX = clang++
CCXFLAGS = $(OPTIMIZE) $(PROFILE) -DCOMPILE_FINAL_CUT $(DEBUG) $(VER) $(GPM) -march=x86-64 -frtti -fexceptions
CCXFLAGS = $(OPTIMIZE) $(PROFILE) -DCOMPILE_FINAL_CUT $(DEBUG) $(VER) $(GPM) -fexceptions
MAKEFILE = -f Makefile.clang
LDFLAGS = $(TERMCAP) -lgpm
INCLUDES = -Iinclude
@ -148,7 +148,7 @@ all: dep $(OBJS)
$(LIB): all
debug:
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded"
$(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded -Wno-reserved-id-macro"
profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg"

View File

@ -62,7 +62,7 @@ INCLUDE_HEADERS = \
# compiler parameter
CXX = g++
CCXFLAGS = $(OPTIMIZE) $(PROFILE) -DCOMPILE_FINAL_CUT $(DEBUG) $(VER) $(GPM) -march=x86-64 -frtti -fexceptions
CCXFLAGS = $(OPTIMIZE) $(PROFILE) -DCOMPILE_FINAL_CUT $(DEBUG) $(VER) $(GPM) -fexceptions
MAKEFILE = -f Makefile.gcc
LDFLAGS = $(TERMCAP) -lgpm
INCLUDES = -Iinclude

View File

@ -31,23 +31,23 @@
namespace finalcut
{
// global application object
static FApplication* rootObj = 0;
// Global application object
static FApplication* app_object = 0;
// flag to exit local loop
// Flag to exit the local event loop
static bool app_exit_loop = false;
// static attributes
int FApplication::loop_level = 0; // event loop level
FWidget* FApplication::main_widget = 0; // main application widget
FWidget* FApplication::active_window = 0; // the active window
FWidget* FApplication::focus_widget = 0; // has keyboard input focus
FWidget* FApplication::clicked_widget = 0; // is focused by click
FWidget* FApplication::open_menu = 0; // currently open menu
FWidget* FApplication::move_size_widget = 0; // move/size by keyboard
// Static attributes
FWidget* FWidget::main_widget = 0; // main application widget
FWidget* FWidget::active_window = 0; // the active window
FWidget* FWidget::focus_widget = 0; // has keyboard input focus
FWidget* FWidget::clicked_widget = 0; // is focused by click
FWidget* FWidget::open_menu = 0; // currently open menu
FWidget* FWidget::move_size_widget = 0; // move/size by keyboard
FWidget* FApplication::keyboard_widget = 0; // has the keyboard focus
FKeyboard* FApplication::keyboard = 0; // keyboard access
FMouseControl* FApplication::mouse = 0; // mouse control
int FApplication::loop_level = 0; // event loop level
int FApplication::quit_code = 0;
bool FApplication::quit_now = false;
@ -69,9 +69,9 @@ FApplication::FApplication ( const int& _argc
, key_timeout(100000) // 100 ms
, dblclick_interval(500000) // 500 ms
{
assert ( ! rootObj
assert ( ! app_object
&& "FApplication: There should be only one application object" );
rootObj = this;
app_object = this;
if ( ! (_argc && _argv) )
{
@ -89,27 +89,21 @@ FApplication::~FApplication() // destructor
if ( event_queue )
delete event_queue;
rootObj = 0;
app_object = 0;
}
// public methods of FApplication
//----------------------------------------------------------------------
void FApplication::setMainWidget (FWidget* widget)
FWidget* FApplication::getApplicationObject()
{
main_widget = widget;
if ( widget && ! getFocusWidget() )
rootObj->focusFirstChild();
return static_cast<FWidget*>(app_object);
}
//----------------------------------------------------------------------
bool FApplication::isQuit()
{
if ( rootObj )
return quit_now;
else
return true;
return ( app_object ) ? quit_now : true;
}
//----------------------------------------------------------------------
@ -152,7 +146,7 @@ void FApplication::exit_loop()
//----------------------------------------------------------------------
void FApplication::exit (int retcode)
{
if ( ! rootObj ) // no global app object
if ( ! app_object ) // no global app object
return;
if ( quit_now ) // don't overwrite quit code
@ -264,7 +258,7 @@ void FApplication::sendQueuedEvents()
//----------------------------------------------------------------------
bool FApplication::eventInQueue()
{
if ( rootObj )
if ( app_object )
return ( ! event_queue->empty() );
else
return false;
@ -317,45 +311,43 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
void FApplication::showParameterUsage()
{
std::cout \
<< "Generic options:" << std::endl
<< "Generic options:\n"
<< " -h, --help "
<< " Display this help and exit" << std::endl
<< std::endl
<< "The Final Cut options:" << std::endl
<< " Display this help and exit\n"
<< "\n"
<< "The Final Cut options:\n"
<< " --encoding <name> "
<< " Sets the character encoding mode" << std::endl
<< " Sets the character encoding mode\n"
<< " "
<< " {utf8, vt100, pc, ascii}" << std::endl
<< " {utf8, vt100, pc, ascii}\n"
<< " --no-mouse "
<< " Disable mouse support" << std::endl
<< " Disable mouse support\n"
<< " --no-optimized-cursor "
<< " Disable cursor optimization" << std::endl
<< " Disable cursor optimization\n"
<< " --no-terminal-detection"
<< " Disable terminal detection" << std::endl
<< " Disable terminal detection\n"
<< " --no-color-change "
<< " Do not redefine the color palette" << std::endl
<< " Do not redefine the color palette\n"
<< " --vgafont "
<< " Set the standard vga 8x16 font" << std::endl
<< " Set the standard vga 8x16 font\n"
<< " --newfont "
<< " Enables the graphical font" << std::endl
<< " Enables the graphical font\n"
#if defined(__FreeBSD__) || defined(__DragonFly__)
<< std::endl
<< "FreeBSD console options:" << std::endl
<< "\n"
<< "FreeBSD console options:\n"
<< " --no-esc-for-alt-meta "
<< " Do not send a ESC prefix for the alt/meta key" << std::endl
<< " Do not send a ESC prefix for the alt/meta key\n"
<< " --no-cursorstyle-change"
<< " Do not change the current cursor style" << std::endl
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
<< std::endl
<< "NetBSD/OpenBSD console options:" << std::endl
<< " Do not change the current cursor style\n"
#elif defined(__NetBSD__) || defined(__OpenBSD__)
<< "\n"
<< "NetBSD/OpenBSD console options:\n"
<< " --no-esc-for-alt-meta "
<< " Do not send a ESC prefix for the alt/meta key" << std::endl
<< " Do not send a ESC prefix for the alt/meta key\n"
#endif
<< std::endl;
<< std::endl; // newline character + flushes the output stream
std::exit(EXIT_SUCCESS);
}
@ -436,9 +428,7 @@ void FApplication::cmd_options (const int& argc, char* argv[])
#if defined(__FreeBSD__) || defined(__DragonFly__)
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
{C_STR("no-cursorstyle-change"), no_argument, 0, 0 },
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
#endif
@ -497,9 +487,7 @@ void FApplication::cmd_options (const int& argc, char* argv[])
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
init_values.change_cursorstyle = false;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
init_values.meta_sends_escape = false;
#endif
@ -513,6 +501,8 @@ inline void FApplication::findKeyboardWidget()
// Find the widget that has the keyboard focus
FWidget* widget = 0;
FWidget* focus_widget = getFocusWidget();
FWidget* move_size_widget = getMoveSizeWidget();
if ( focus_widget )
{
@ -523,7 +513,7 @@ inline void FApplication::findKeyboardWidget()
}
else
{
widget = main_widget;
widget = getMainWidget();
if ( widget && widget->numOfChildren() >= 1 )
widget->focusFirstChild();
@ -571,9 +561,8 @@ inline void FApplication::performKeyboardAction()
case fc::Fkey_mouse:
if ( mouse )
{
char* buffer = keyboard->getKeyBuffer();
int buffer_size = keyboard->getKeyBufferSize();
mouse->setRawData (FMouse::x11, buffer, buffer_size);
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
mouse->setRawData (FMouse::x11, buffer);
keyboard->unprocessedInput() = mouse->isInputDataPending();
processMouseEvent();
}
@ -582,9 +571,8 @@ inline void FApplication::performKeyboardAction()
case fc::Fkey_extended_mouse:
if ( mouse )
{
char* buffer = keyboard->getKeyBuffer();
int buffer_size = keyboard->getKeyBufferSize();
mouse->setRawData (FMouse::sgr, buffer, buffer_size);
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
mouse->setRawData (FMouse::sgr, buffer);
keyboard->unprocessedInput() = mouse->isInputDataPending();
processMouseEvent();
}
@ -593,9 +581,8 @@ inline void FApplication::performKeyboardAction()
case fc::Fkey_urxvt_mouse:
if ( mouse )
{
char* buffer = keyboard->getKeyBuffer();
int buffer_size = keyboard->getKeyBufferSize();
mouse->setRawData (FMouse::urxvt, buffer, buffer_size);
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
mouse->setRawData (FMouse::urxvt, buffer);
keyboard->unprocessedInput() = mouse->isInputDataPending();
processMouseEvent();
}
@ -650,7 +637,7 @@ inline bool FApplication::sendKeyUpEvent (FWidget* widget)
//----------------------------------------------------------------------
inline void FApplication::sendKeyboardAccelerator()
{
if ( open_menu )
if ( getOpenMenu() )
return;
// Switch to a specific dialog with Meta + 1..9
@ -659,7 +646,7 @@ inline void FApplication::sendKeyboardAccelerator()
// Windows keyboard accelerator
if ( ! accpt )
{
const FWidget* window = active_window;
const FWidget* window = getActiveWindow();
if ( window )
accpt = processAccelerator (window);
@ -705,14 +692,16 @@ bool FApplication::processDialogSwitchAccelerator()
if ( s > 0 && s >= n )
{
// unset the move/size mode
FWidget* move_size_widget = getMoveSizeWidget();
if ( move_size_widget )
{
FWidget* w = move_size_widget;
move_size_widget = 0;
setMoveSizeWidget(0);
w->redraw();
}
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
sendEvent (dialog_list->at(n - 1), &a_ev);
return true;
}
@ -742,14 +731,16 @@ bool FApplication::processAccelerator (const FWidget*& widget)
if ( iter->key == keyboard->getKey() )
{
// unset the move/size mode
FWidget* move_size_widget = getMoveSizeWidget();
if ( move_size_widget )
{
FWidget* w = move_size_widget;
move_size_widget = 0;
setMoveSizeWidget(0);
w->redraw();
}
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
sendEvent (iter->object, &a_ev);
accpt = a_ev.isAccepted();
break;
@ -781,6 +772,8 @@ bool FApplication::getMouseEvent()
//----------------------------------------------------------------------
FWidget*& FApplication::determineClickedWidget()
{
FWidget*& clicked_widget = getClickedWidget();
if ( clicked_widget )
return clicked_widget;
@ -805,6 +798,7 @@ FWidget*& FApplication::determineClickedWidget()
// Determine the widget at the current click position
FWidget* child = childWidgetAt (window, mouse_position);
clicked_widget = ( child != 0 ) ? child : window;
setClickedWidget (clicked_widget);
}
return clicked_widget;
@ -814,10 +808,13 @@ FWidget*& FApplication::determineClickedWidget()
void FApplication::unsetMoveSizeMode()
{
// Unset the move/size mode
FWidget* move_size_widget = getMoveSizeWidget();
if ( move_size_widget )
{
FWidget* w = move_size_widget;
move_size_widget = 0;
setMoveSizeWidget(0);
w->redraw();
}
}
@ -827,11 +824,12 @@ void FApplication::closeOpenMenu()
{
// Close the open menu
FWidget* open_menu = getOpenMenu();
FMenu* menu = static_cast<FMenu*>(open_menu);
if ( ! open_menu || ( mouse && mouse->isMoved()) )
return;
FMenu* menu = static_cast<FMenu*>(open_menu);
if ( mouse )
{
const FPoint& mouse_position = mouse->getPos();
@ -854,7 +852,7 @@ void FApplication::closeOpenMenu()
menu->hideSuperMenus();
// No widget was been clicked and the menu is no dialog menu
if ( ! (clicked_widget || is_window_menu) )
if ( ! (getClickedWidget() || is_window_menu) )
FWindow::switchToPrevWindow();
if ( getStatusBar() )
@ -869,11 +867,12 @@ void FApplication::unselectMenubarItems()
{
// Unselect the menu bar items
FWidget* open_menu = getOpenMenu();
FMenuBar* menu_bar = getMenuBar();
if ( open_menu || (mouse && mouse->isMoved()) )
return;
FMenuBar* menu_bar = getMenuBar();
if ( ! menu_bar )
return;
@ -894,7 +893,7 @@ void FApplication::unselectMenubarItems()
getMenuBar()->redraw();
// No widget was been clicked
if ( ! clicked_widget )
if ( ! getClickedWidget() )
FWindow::switchToPrevWindow();
if ( getStatusBar() )
@ -908,6 +907,8 @@ void FApplication::unselectMenubarItems()
//----------------------------------------------------------------------
void FApplication::sendMouseEvent()
{
FWidget* clicked_widget = getClickedWidget();
if ( ! clicked_widget )
return;
@ -952,6 +953,8 @@ void FApplication::sendMouseMoveEvent ( const FPoint& widgetMousePos
if ( ! mouse )
return;
FWidget* clicked_widget = getClickedWidget();
if ( mouse->isLeftButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
@ -988,6 +991,8 @@ void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
if ( ! mouse )
return;
FWidget* clicked_widget = getClickedWidget();
if ( mouse->isLeftButtonDoubleClick() )
{
FMouseEvent m_dblclick_ev ( fc::MouseDoubleClick_Event
@ -1014,7 +1019,7 @@ void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
if ( ! mouse->isRightButtonPressed()
&& ! mouse->isMiddleButtonPressed() )
clicked_widget = 0;
setClickedWidget(0);
sendEvent (released_widget, &m_up_ev);
}
@ -1028,6 +1033,8 @@ void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
if ( ! mouse )
return;
FWidget* clicked_widget = getClickedWidget();
if ( mouse->isRightButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
@ -1046,7 +1053,7 @@ void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
if ( ! mouse->isLeftButtonPressed()
&& ! mouse->isMiddleButtonPressed() )
clicked_widget = 0;
setClickedWidget(0);
sendEvent (released_widget, &m_up_ev);
}
@ -1060,6 +1067,8 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
if ( ! mouse )
return;
FWidget* clicked_widget = getClickedWidget();
if ( mouse->isMiddleButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
@ -1070,7 +1079,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
// gnome-terminal sends no released on middle click
if ( isGnomeTerminal() )
clicked_widget = 0;
setClickedWidget(0);
}
else if ( mouse->isMiddleButtonReleased() )
{
@ -1083,7 +1092,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
if ( ! mouse->isLeftButtonPressed()
&& ! mouse->isRightButtonPressed() )
{
clicked_widget = 0;
setClickedWidget(0);
}
sendEvent (released_widget, &m_up_ev);
@ -1097,6 +1106,8 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
if ( ! mouse )
return;
FWidget* clicked_widget = getClickedWidget();
if ( mouse->isWheelUp() )
{
FWheelEvent wheel_ev ( fc::MouseWheel_Event
@ -1104,7 +1115,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
, mouse_position
, fc::WheelUp );
FWidget* scroll_over_widget = clicked_widget;
clicked_widget = 0;
setClickedWidget(0);
sendEvent(scroll_over_widget, &wheel_ev);
}
@ -1115,7 +1126,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
, mouse_position
, fc::WheelDown );
FWidget* scroll_over_widget = clicked_widget;
clicked_widget = 0;
setClickedWidget(0);
sendEvent (scroll_over_widget, &wheel_ev);
}
}
@ -1142,7 +1153,7 @@ void FApplication::processResizeEvent()
if ( hasChangedTermSize() )
{
FResizeEvent r_ev(fc::Resize_Event);
sendEvent(rootObj, &r_ev);
sendEvent(app_object, &r_ev);
if ( r_ev.isAccepted() )
changeTermSizeFinished();

View File

@ -39,12 +39,12 @@ FButton::FButton(FWidget* parent)
, button_down(false)
, click_animation(true)
, click_time(150)
, space_char(int(' '))
, hotkeypos(NOT_SET)
, indent(0)
, space(int(' '))
, center_offset(0)
, vcenter_offset(0)
, txtlength(0)
, hotkeypos(-1)
, button_fg(wc.button_active_fg)
, button_bg(wc.button_active_bg)
, button_hotkey_fg(wc.button_hotkey_fg)
@ -64,12 +64,12 @@ FButton::FButton (const FString& txt, FWidget* parent)
, button_down(false)
, click_animation(true)
, click_time(150)
, space_char(int(' '))
, hotkeypos(NOT_SET)
, indent(0)
, space(int(' '))
, center_offset(0)
, vcenter_offset(0)
, txtlength(0)
, hotkeypos(-1)
, button_fg(wc.button_active_fg)
, button_bg(wc.button_active_bg)
, button_hotkey_fg(wc.button_hotkey_fg)
@ -263,9 +263,8 @@ void FButton::setText (const FString& txt)
//----------------------------------------------------------------------
void FButton::hide()
{
int s, f, size;
std::size_t s, f, size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
@ -285,29 +284,18 @@ void FButton::hide()
f = isFlat() ? 1 : 0;
size = getWidth() + s + (f << 1);
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getHeight() + s + (f << 1); y++)
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
{
setPrintPos (1 - f, 1 + y - f);
setPrintPos (1 - int(f), 1 + int(y - f));
print (blank);
}
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
@ -489,19 +477,17 @@ void FButton::getButtonState()
//----------------------------------------------------------------------
uChar FButton::getHotkey()
{
int length;
if ( text.isEmpty() )
return 0;
length = int(text.getLength());
std::size_t length = text.getLength();
for (int i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[uInt(i)] == '&' )
return uChar(text[uInt(++i)]);
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
@ -544,18 +530,20 @@ inline void FButton::detectHotkey()
}
//----------------------------------------------------------------------
int FButton::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
std::size_t FButton::getHotkeyPos ( wchar_t src[]
, wchar_t dest[]
, std::size_t length )
{
// find hotkey position in string
// + generate a new string without the '&'-sign
int pos = -1;
wchar_t* txt = src;
std::size_t pos = NOT_SET;
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
if ( i < length && txt[i] == L'&' && pos == -1 )
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
{
pos = int(i);
pos = i;
i++;
src++;
}
@ -567,7 +555,7 @@ int FButton::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
}
//----------------------------------------------------------------------
inline int FButton::clickAnimationIndent (FWidget* parent_widget)
inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
{
if ( ! button_down || ! click_animation )
return 0;
@ -582,9 +570,9 @@ inline int FButton::clickAnimationIndent (FWidget* parent_widget)
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y = 1; y <= getHeight(); y++)
for (std::size_t y = 1; y <= getHeight(); y++)
{
setPrintPos (1, y);
setPrintPos (1, int(y));
print (' '); // clear one left █
}
@ -602,12 +590,12 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y = 1; y <= getHeight(); y++)
for (int y = 1; y <= int(getHeight()); y++)
{
if ( isMonochron() )
setReverse(true); // Light background
setPrintPos (1 + getWidth(), y);
setPrintPos (1 + int(getWidth()), y);
print (' '); // clear right
if ( is.active && isMonochron() )
@ -622,14 +610,14 @@ inline void FButton::drawMarginLeft()
setColor (getForegroundColor(), button_bg);
for (int y = 0; y < getHeight(); y++)
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (1 + indent, 1 + y);
setPrintPos (1 + int(indent), 1 + int(y));
if ( isMonochron() && is.active_focus && y == vcenter_offset )
print (fc::BlackRightPointingPointer); // ►
else
print (space); // full block █
print (space_char); // full block █
}
}
@ -638,14 +626,14 @@ inline void FButton::drawMarginRight()
{
// Print right margin
for (int y = 0; y < getHeight(); y++)
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (getWidth() + indent, 1 + y);
setPrintPos (int(getWidth() + indent), 1 + int(y));
if ( isMonochron() && is.active_focus && y == vcenter_offset )
print (fc::BlackLeftPointingPointer); // ◄
else
print (space); // full block █
print (space_char); // full block █
}
}
@ -657,41 +645,41 @@ inline void FButton::drawTopBottomBackground()
if ( getHeight() < 2 )
return;
for (int y = 0; y < vcenter_offset; y++)
for (std::size_t y = 0; y < vcenter_offset; y++)
{
setPrintPos (2 + indent, 1 + y);
setPrintPos (2 + int(indent), 1 + int(y));
for (int x = 1; x < getWidth() - 1; x++)
print (space); // █
for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █
}
for (int y = vcenter_offset + 1; y < getHeight(); y++)
for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++)
{
setPrintPos (2 + indent, 1 + y);
setPrintPos (2 + int(indent), 1 + int(y));
for (int x = 1; x < getWidth() - 1; x++)
print (space); // █
for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █
}
}
//----------------------------------------------------------------------
inline void FButton::drawButtonTextLine (wchar_t button_text[])
{
int pos;
center_offset = int((getWidth() - txtlength - 1) / 2);
setPrintPos (2 + indent, 1 + vcenter_offset);
std::size_t pos;
center_offset = (getWidth() - txtlength - 1) / 2;
setPrintPos (2 + int(indent), 1 + int(vcenter_offset));
setColor (button_fg, button_bg);
// Print button text line --------
for (pos = 0; pos < center_offset; pos++)
print (space); // █
print (space_char); // █
if ( hotkeypos == -1 )
setCursorPos ( 2 + center_offset
, 1 + vcenter_offset ); // first character
if ( hotkeypos == NOT_SET )
setCursorPos ( 2 + int(center_offset)
, 1 + int(vcenter_offset) ); // first character
else
setCursorPos ( 2 + center_offset + hotkeypos
, 1 + vcenter_offset ); // hotkey
setCursorPos ( 2 + int(center_offset + hotkeypos)
, 1 + int(vcenter_offset) ); // hotkey
if ( ! is.active && isMonochron() )
setReverse(true); // Light background
@ -699,11 +687,11 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
if ( is.active_focus && (isMonochron() || getMaxColor() < 16) )
setBold();
for ( int z = 0
for ( std::size_t z = 0
; pos < center_offset + txtlength && z < getWidth() - 2
; z++, pos++)
{
if ( (z == hotkeypos) && is.active )
if ( z == hotkeypos && is.active )
{
setColor (button_hotkey_fg, button_bg);
@ -732,7 +720,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
if ( txtlength >= getWidth() - 1 )
{
// Print ellipsis
setPrintPos (getWidth() + indent - 2, 1);
setPrintPos (int(getWidth() + indent) - 2, 1);
print (L"..");
}
@ -740,7 +728,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
unsetBold();
for (pos = center_offset + txtlength; pos < getWidth() - 2; pos++)
print (space); // █
print (space_char); // █
}
//----------------------------------------------------------------------
@ -748,13 +736,13 @@ void FButton::draw()
{
wchar_t* button_text;
FWidget* parent_widget = getParentWidget();
txtlength = int(text.getLength());
space = int(' ');
txtlength = text.getLength();
space_char = int(' ');
getButtonState();
try
{
button_text = new wchar_t[uInt(txtlength) + 1]();
button_text = new wchar_t[txtlength + 1]();
}
catch (const std::bad_alloc& ex)
{
@ -772,7 +760,7 @@ void FButton::draw()
clearRightMargin (parent_widget);
if ( ! is.active && isMonochron() )
space = fc::MediumShade; // ▒ simulates greyed out at Monochron
space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron
if ( isMonochron() && (is.active || is.focus) )
setReverse(false); // Dark background
@ -782,11 +770,11 @@ void FButton::draw()
hotkeypos = getHotkeyPos(text.wc_str(), button_text, uInt(txtlength));
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
txtlength--;
if ( getHeight() >= 2 )
vcenter_offset = int((getHeight() - 1) / 2);
vcenter_offset = (getHeight() - 1) / 2;
else
vcenter_offset = 0;

View File

@ -189,9 +189,8 @@ bool FButtonGroup::hasCheckedButton() const
//----------------------------------------------------------------------
void FButtonGroup::hide()
{
int size;
std::size_t size;
short fg, bg;
char* blank;
FWidget::hide();
FWidget* parent_widget = getParentWidget();
@ -223,29 +222,18 @@ void FButtonGroup::hide()
setColor (fg, bg);
size = getWidth();
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getHeight(); y++)
for (int y = 0; y < int(getHeight()); y++)
{
FWidget::setPrintPos (1, 1 + y);
print (blank);
}
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
@ -443,14 +431,12 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr)
//----------------------------------------------------------------------
uChar FButtonGroup::getHotkey()
{
uInt length;
if ( text.isEmpty() )
return 0;
length = text.getLength();
std::size_t length = text.getLength();
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
try
{
@ -506,13 +492,13 @@ void FButtonGroup::draw()
void FButtonGroup::drawLabel()
{
wchar_t* LabelText;
int hotkeypos;
std::size_t hotkeypos;
if ( text.isNull() || text.isEmpty() )
return;
FString txt = " " + text + " ";
uInt length = txt.getLength();
std::size_t length = txt.getLength();
try
{
@ -527,9 +513,9 @@ void FButtonGroup::drawLabel()
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText);
unsetViewportPrint();
hotkeypos = getHotkeyPos(src, dest, uInt(length));
hotkeypos = getHotkeyPos(src, dest, length);
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
length--;
if ( hasBorder() )
@ -567,18 +553,20 @@ void FButtonGroup::init()
}
//----------------------------------------------------------------------
int FButtonGroup::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
std::size_t FButtonGroup::getHotkeyPos ( wchar_t src[]
, wchar_t dest[]
, std::size_t length )
{
// find hotkey position in string
// + generate a new string without the '&'-sign
int pos = -1;
std::size_t pos = NOT_SET;
wchar_t* txt = src;
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
if ( i < length && txt[i] == L'&' && pos == -1 )
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
{
pos = int(i);
pos = i;
i++;
src++;
}
@ -590,7 +578,9 @@ int FButtonGroup::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
}
//----------------------------------------------------------------------
void FButtonGroup::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
void FButtonGroup::drawText ( wchar_t LabelText[]
, std::size_t hotkeypos
, std::size_t length )
{
bool isActive = ((flags & fc::active) != 0);
bool isNoUnderline = ((flags & fc::no_underline) != 0);
@ -603,7 +593,7 @@ void FButtonGroup::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
else
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
for (int z = 0; z < int(length); z++)
for (std::size_t z = 0; z < length; z++)
{
if ( (z == hotkeypos) && isActive )
{

View File

@ -193,7 +193,7 @@ void FDialog::hide()
}
//----------------------------------------------------------------------
int FDialog::exec()
FDialog::DialogCode FDialog::exec()
{
result_code = FDialog::Reject;
show();
@ -213,11 +213,14 @@ void FDialog::setPos (int x, int y, bool)
return;
}
width = getWidth();
height = getHeight();
width = int(getWidth());
height = int(getHeight());
// Avoid to move widget completely outside the terminal
if ( x + width <= 1 || x > getMaxWidth() || y < 1 || y > getMaxHeight() )
if ( x + width <= 1
|| x > int(getMaxWidth())
|| y < 1
|| y > int(getMaxHeight()) )
{
setPos_error = true;
return;
@ -256,7 +259,7 @@ void FDialog::setPos (int x, int y, bool)
{
if ( dy > 0 )
restoreVTerm ( old_x + width + rsw - dx, old_y
, dx, getHeight() + bsh - dy );
, dx, height + bsh - dy );
else
restoreVTerm ( old_x + width + rsw - dx, old_y + std::abs(dy)
, dx, height + bsh - std::abs(dy));
@ -321,7 +324,7 @@ inline bool FDialog::moveRight (int n)
}
//----------------------------------------------------------------------
void FDialog::setSize (int w, int h, bool adjust)
void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
{
setSize_error = false;
@ -339,10 +342,10 @@ void FDialog::setSize (int w, int h, bool adjust)
int x = getTermX()
, y = getTermY()
, old_width = getWidth()
, old_height = getHeight()
, dw = old_width - w
, dh = old_height - h;
, old_width = int(getWidth())
, old_height = int(getHeight())
, dw = old_width - int(w)
, dh = old_height - int(h);
const FPoint& shadow = getShadow();
int rsw = shadow.getX(); // right shadow width;
int bsh = shadow.getY(); // bottom shadow height
@ -362,10 +365,10 @@ void FDialog::setSize (int w, int h, bool adjust)
// restoring the non-covered terminal areas
if ( dw > 0 )
restoreVTerm (x + w + rsw, y, dw, h + bsh + dh); // restore right
restoreVTerm (x + int(w) + rsw, y, dw, int(h) + bsh + dh); // restore right
if ( dh > 0 )
restoreVTerm (x, y + h + bsh, w + rsw + dw, dh); // restore bottom
restoreVTerm (x, y + int(h) + bsh, int(w) + rsw + dw, dh); // restore bottom
redraw();
@ -406,17 +409,17 @@ bool FDialog::reduceHeight (int n)
if ( ! isResizeable() )
return false;
setSize (getWidth(), getHeight() - n);
setSize (getWidth(), getHeight() - std::size_t(n));
return ! setSize_error;
}
//----------------------------------------------------------------------
bool FDialog::expandHeight (int n)
{
if ( ! isResizeable() || getHeight() + getY() > getMaxHeight() )
if ( ! isResizeable() || getHeight() + std::size_t(getY()) > getMaxHeight() )
return false;
setSize (getWidth(), getHeight() + n);
setSize (getWidth(), getHeight() + std::size_t(n));
return ! setSize_error;
}
@ -426,17 +429,17 @@ bool FDialog::reduceWidth (int n)
if ( ! isResizeable() )
return false;
setSize (getWidth() - n, getHeight());
setSize (getWidth() - std::size_t(n), getHeight());
return ! setSize_error;
}
//----------------------------------------------------------------------
bool FDialog::expandWidth (int n)
{
if ( ! isResizeable() || getWidth() + getX() > getMaxWidth() )
if ( ! isResizeable() || getWidth() + std::size_t(getX()) > getMaxWidth() )
return false;
setSize (getWidth() + n, getHeight());
setSize (getWidth() + std::size_t(n), getHeight());
return ! setSize_error;
}
@ -515,6 +518,8 @@ void FDialog::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FDialog::onMouseDown (FMouseEvent* ev)
{
int width = int(getWidth());
mouseStates ms =
{
ev->getX(),
@ -532,7 +537,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
raiseActivateDialog();
if ( ms.mouse_x >= 4
&& ms.mouse_x <= getWidth() - ms.zoom_btn
&& ms.mouse_x <= width - int(ms.zoom_btn)
&& ms.mouse_y == 1 )
titlebar_click_pos.setPoint (ev->getTermX(), ev->getTermY());
else
@ -560,13 +565,13 @@ void FDialog::onMouseDown (FMouseEvent* ev)
// Click on titlebar: just activate
if ( ev->getButton() == fc::RightButton
&& ms.mouse_x >= 4
&& ms.mouse_x <= getWidth()
&& ms.mouse_x <= width
&& ms.mouse_y == 1 )
activateDialog();
// Click on titlebar: lower + activate
if ( ev->getButton() == fc::MiddleButton
&& ms.mouse_x >= 4 && ms.mouse_x <= getWidth()
&& ms.mouse_x >= 4 && ms.mouse_x <= width
&& ms.mouse_y == 1 )
lowerActivateDialog();
}
@ -589,9 +594,9 @@ void FDialog::onMouseUp (FMouseEvent* ev)
, titlebar_y = titlebar_click_pos.getY();
if ( ! titlebar_click_pos.isNull()
&& titlebar_x > getTermX() + 3
&& titlebar_x < getTermX() + getWidth()
&& titlebar_y == getTermY() )
&& titlebar_x > int(getTermX()) + 3
&& titlebar_x < getTermX() + int(getWidth())
&& titlebar_y == int(getTermY()) )
{
FPoint deltaPos = ms.termPos - titlebar_click_pos;
move (deltaPos);
@ -693,7 +698,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
}
else if ( isResizeable()
&& ms.mouse_x >= 4
&& ms.mouse_x <= getWidth() - ms.zoom_btn
&& ms.mouse_x <= int(getWidth() - ms.zoom_btn)
&& ms.mouse_y == 1 )
{
// Double click on titlebar
@ -804,7 +809,7 @@ void FDialog::onWindowLowered (FEvent*)
// protected methods of FDialog
//----------------------------------------------------------------------
void FDialog::done(int result)
void FDialog::done(DialogCode result)
{
hide();
result_code = result;
@ -828,7 +833,7 @@ void FDialog::draw()
clearArea();
drawBorder();
drawTitleBar();
setCursorPos(2, getHeight() - 1);
setCursorPos(2, int(getHeight()) - 1);
if ( (flags & fc::shadow) != 0 )
drawDialogShadow();
@ -920,12 +925,8 @@ void FDialog::initDialogMenu()
dialog_menu->setPos (getX(), getY() + 1);
dgl_menuitem = dialog_menu->getItem();
if ( dgl_menuitem )
{
dgl_menuitem->ignorePadding();
dgl_menuitem->unsetFocusable();
}
// Add the move/size menu item
initMoveSizeMenuItem (dialog_menu);
@ -1009,9 +1010,9 @@ void FDialog::initCloseMenuItem (FMenu* menu)
void FDialog::drawBorder()
{
int x1 = 1
, x2 = 1 + getWidth() - 1
, x2 = 1 + int(getWidth()) - 1
, y1 = 2
, y2 = 1 + getHeight() - 1;
, y2 = 1 + int(getHeight()) - 1;
if ( (getMoveSizeWidget() == this || ! resize_click_pos.isNull() )
&& ! isZoomed() )
@ -1035,7 +1036,7 @@ void FDialog::drawBorder()
// Lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
for (int x = 1; x < getWidth() - 1; x++) // low line _
for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _
print (fc::NF_border_line_bottom);
setPrintPos (x2, y2);
@ -1193,7 +1194,8 @@ inline void FDialog::drawZoomedButton()
void FDialog::drawTextBar()
{
// Fill with spaces (left of the title)
int center_offset
std::size_t center_offset
, width
, zoom_btn
, length
, x;
@ -1206,9 +1208,10 @@ void FDialog::drawTextBar()
else
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
width = std::size_t(getWidth());
zoom_btn = getZoomButtonWidth();
length = int(tb_text.getLength());
center_offset = int((getWidth() - length - MENU_BTN - zoom_btn) / 2);
length = tb_text.getLength();
center_offset = (width - length - MENU_BTN - zoom_btn) / 2;
for (x = 1; x <= center_offset; x++)
print (' ');
@ -1216,18 +1219,18 @@ void FDialog::drawTextBar()
// Print title bar text
if ( ! tb_text.isEmpty() )
{
if ( length <= getWidth() - MENU_BTN - zoom_btn )
if ( length <= width - MENU_BTN - zoom_btn )
print (tb_text);
else
{
// Print ellipsis
print (tb_text.left(getWidth() - MENU_BTN - zoom_btn - 2));
print (tb_text.left(width - MENU_BTN - zoom_btn - 2));
print ("..");
}
}
// Fill the rest of the bar
for ( ; x + 1 + length < getWidth() - zoom_btn - 1; x++)
for ( ; x + 1 + length < width - zoom_btn - 1; x++)
print (' ');
if ( getMaxColor() < 16 )
@ -1358,7 +1361,7 @@ void FDialog::setZoomItem()
}
//----------------------------------------------------------------------
inline int FDialog::getZoomButtonWidth()
inline std::size_t FDialog::getZoomButtonWidth()
{
if ( ! isResizeable() )
return 0;
@ -1382,7 +1385,7 @@ inline void FDialog::deactivateZoomButton()
//----------------------------------------------------------------------
inline void FDialog::activateZoomButton (mouseStates& ms)
{
if ( ms.mouse_x <= getWidth() - ms.zoom_btn
if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn)
|| ms.mouse_y != 1 )
return;
@ -1396,8 +1399,8 @@ inline void FDialog::leaveZoomButton (mouseStates& ms)
{
bool zoom_button_pressed_before = zoom_button_pressed;
if ( ms.mouse_x > getWidth() - ms.zoom_btn
&& ms.mouse_x <= getWidth()
if ( ms.mouse_x > int(getWidth() - ms.zoom_btn)
&& ms.mouse_x <= int(getWidth())
&& ms.mouse_y == 1
&& zoom_button_active )
zoom_button_pressed = true;
@ -1411,7 +1414,7 @@ inline void FDialog::leaveZoomButton (mouseStates& ms)
//----------------------------------------------------------------------
void FDialog::pressZoomButton (mouseStates& ms)
{
if ( ms.mouse_x <= getWidth() - ms.zoom_btn
if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn)
|| ms.mouse_y != 1
|| ! zoom_button_pressed )
return;
@ -1555,9 +1558,9 @@ bool FDialog::isLowerRightResizeCorner (mouseStates& ms)
// x
// -----xx
if ( (ms.mouse_x == getWidth() && ms.mouse_y == getHeight() - 1)
|| ( ( ms.mouse_x == getWidth() - 1
|| ms.mouse_x == getWidth() ) && ms.mouse_y == getHeight() ) )
if ( (ms.mouse_x == int(getWidth()) && ms.mouse_y == int(getHeight()) - 1)
|| ( ( ms.mouse_x == int(getWidth()) - 1
|| ms.mouse_x == int(getWidth()) ) && ms.mouse_y == int(getHeight()) ) )
{
return true;
}
@ -1582,7 +1585,7 @@ void FDialog::resizeMouseDown (mouseStates& ms)
FPoint deltaPos = ms.termPos - lower_right_pos;
int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1;
int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1;
setSize (w, h);
setSize (std::size_t(w), std::size_t(h));
}
else
drawBorder();
@ -1615,17 +1618,17 @@ void FDialog::resizeMouseUpMove (mouseStates& ms, bool mouse_up)
int w, h;
FPoint deltaPos = ms.termPos - resize_click_pos;
if ( x2 - x2_offset <= getMaxWidth() )
if ( x2 - x2_offset <= int(getMaxWidth()) )
w = resize_click_pos.getX() + deltaPos.getX() - getTermX() + 1;
else
w = getMaxWidth() - getTermX() + x2_offset + 1;
w = int(getMaxWidth()) - getTermX() + x2_offset + 1;
if ( y2 - y2_offset <= getMaxHeight() )
if ( y2 - y2_offset <= int(getMaxHeight()) )
h = resize_click_pos.getY() + deltaPos.getY() - getTermY() + 1;
else
h = getMaxHeight() - getTermY() + y2_offset + 1;
h = int(getMaxHeight()) - getTermY() + y2_offset + 1;
setSize (w, h);
setSize (std::size_t(w), std::size_t(h));
}
if ( mouse_up )

View File

@ -54,8 +54,6 @@ FDialogListMenu::~FDialogListMenu()
void FDialogListMenu::init()
{
FMenuItem* menuitem = getItem();
if ( menuitem )
menuitem->dialog_index = true;
}

View File

@ -337,11 +337,10 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
//----------------------------------------------------------------------
void FFileDialog::adjustSize()
{
int h
, X
, Y
, max_width
, max_height;
int X, Y;
std::size_t max_width;
std::size_t max_height;
std::size_t h;
FWidget* root_widget = getRootWidget();
if ( root_widget )
@ -369,9 +368,9 @@ void FFileDialog::adjustSize()
Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false);
filebrowser.setHeight (h - 8, false);
hidden.setY (h - 4, false);
cancel.setY (h - 4, false);
open.setY (h - 4, false);
hidden.setY (int(h) - 4, false);
cancel.setY (int(h) - 4, false);
open.setY (int(h) - 4, false);
FDialog::adjustSize();
printPath(directory);
}
@ -381,8 +380,8 @@ void FFileDialog::adjustSize()
//----------------------------------------------------------------------
void FFileDialog::init()
{
static const int w = 42;
static const int h = 15;
static const std::size_t w = 42;
static const std::size_t h = 15;
int x, y;
FWidget* parent_widget;
@ -751,7 +750,7 @@ int FFileDialog::changeDir (const FString& dirname)
filename.setText('/');
else if ( ! dir_entries.empty() )
{
int i = 1;
std::size_t i = 1;
std::vector<dir_entry>::const_iterator iter, last;
const char* const baseName = \
basename(C_STR(lastdir.c_str()));
@ -872,14 +871,14 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr)
//----------------------------------------------------------------------
void FFileDialog::cb_processRowChanged (FWidget*, data_ptr)
{
const int n = filebrowser.currentItem();
const std::size_t n = filebrowser.currentItem();
if ( n == 0 )
return;
const FString& name = dir_entries[uLong(n - 1)].name;
const FString& name = dir_entries[n - 1].name;
if ( dir_entries[uLong(n - 1)].directory )
if ( dir_entries[n - 1].directory )
filename.setText( name + '/' );
else
filename.setText( name );

View File

@ -70,7 +70,6 @@ FKeyboard::FKeyboard()
: key(0)
, fifo_offset(0)
, fifo_in_use(false)
, fifo_buf_size(sizeof(fifo_buf))
, stdin_status_flags(0)
, input_data_pending(false)
, utf8_input(false)
@ -92,8 +91,8 @@ FKeyboard::FKeyboard()
std::abort();
// Initialize arrays with '\0'
std::fill_n (k_buf, sizeof(k_buf), '\0');
std::fill_n (fifo_buf, fifo_buf_size, '\0');
std::fill_n (read_buf, READ_BUF_SIZE, '\0');
std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
}
//----------------------------------------------------------------------
@ -159,7 +158,7 @@ void FKeyboard::clearKeyBuffer()
fifo_offset = 0;
key = 0;
std::fill_n (fifo_buf, fifo_buf_size, '\0');
std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
fifo_in_use = false;
}
@ -230,7 +229,7 @@ inline int FKeyboard::getTermcapKey()
{
// Looking for termcap key strings in the buffer
assert ( fifo_buf_size > 0 );
assert ( FIFO_BUF_SIZE > 0 );
if ( ! key_map )
return -1;
@ -239,16 +238,16 @@ inline int FKeyboard::getTermcapKey()
for (int i = 0; keymap[i].tname[0] != 0; i++)
{
char* k = keymap[i].string;
int len = ( k ) ? int(std::strlen(k)) : 0;
std::size_t len = ( k ) ? std::strlen(k) : 0;
if ( k && std::strncmp(k, fifo_buf, uInt(len)) == 0 ) // found
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
{
int n;
std::size_t n;
for (n = len; n < fifo_buf_size; n++) // Remove founded entry
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n];
for (n = n - len; n < fifo_buf_size; n++) // Fill rest with '\0'
for (n = n - len; n < FIFO_BUF_SIZE; n++) // Fill rest with '\0'
fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
@ -264,16 +263,16 @@ inline int FKeyboard::getMetaKey()
{
// Looking for meta key strings in the buffer
assert ( fifo_buf_size > 0 );
assert ( FIFO_BUF_SIZE > 0 );
for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++)
{
char* kmeta = fc::Fmetakey[i].string; // The string is never null
int len = int(std::strlen(kmeta));
std::size_t len = std::strlen(kmeta);
if ( std::strncmp(kmeta, fifo_buf, uInt(len)) == 0 ) // found
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
{
int n;
std::size_t n;
if ( len == 2 && ( fifo_buf[1] == 'O'
|| fifo_buf[1] == '['
@ -283,10 +282,10 @@ inline int FKeyboard::getMetaKey()
return NEED_MORE_DATA;
}
for (n = len; n < fifo_buf_size; n++) // Remove founded entry
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n];
for (n = n - len; n < fifo_buf_size; n++) // Fill rest with '\0'
for (n = n - len; n < FIFO_BUF_SIZE; n++) // Fill rest with '\0'
fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
@ -303,8 +302,9 @@ inline int FKeyboard::getSingleKey()
// Looking for single key code in the buffer
uChar firstchar = uChar(fifo_buf[0]);
int keycode, n, len;
len = 1;
std::size_t n;
std::size_t len = 1;
int keycode;
// Look for a utf-8 character
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
@ -318,7 +318,7 @@ inline int FKeyboard::getSingleKey()
else if ( (firstchar & 0xf8) == 0xf0 )
len = 4;
for (int i = 0; i < len ; i++)
for (std::size_t i = 0; i < len ; i++)
utf8char[i] = char(fifo_buf[i] & 0xff);
keycode = UTF8decode(utf8char);
@ -326,10 +326,10 @@ inline int FKeyboard::getSingleKey()
else
keycode = uChar(fifo_buf[0] & 0xff);
for (n = len; n < fifo_buf_size; n++) // Remove the key from the buffer front
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove the key from the buffer front
fifo_buf[n - len] = fifo_buf[n];
for (n = n - len; n < fifo_buf_size; n++) // Fill the rest with '\0' bytes
for (n = n - len; n < FIFO_BUF_SIZE; n++) // Fill the rest with '\0' bytes
fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
@ -424,7 +424,7 @@ inline ssize_t FKeyboard::readKey()
{
ssize_t bytes;
setNonBlockingInput();
bytes = read(FTermios::getStdIn(), &k_buf, sizeof(k_buf) - 1);
bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
unsetNonBlockingInput();
return bytes;
}
@ -437,11 +437,11 @@ void FKeyboard::parseKeyBuffer()
while ( (bytesread = readKey()) > 0 )
{
if ( bytesread + fifo_offset <= fifo_buf_size )
if ( bytesread + fifo_offset <= int(FIFO_BUF_SIZE) )
{
for (int i = 0; i < bytesread; i++)
{
fifo_buf[fifo_offset] = k_buf[i];
fifo_buf[fifo_offset] = read_buf[i];
fifo_offset++;
}
@ -474,7 +474,7 @@ void FKeyboard::parseKeyBuffer()
key = 0;
}
std::fill_n (k_buf, sizeof(k_buf), '\0');
std::fill_n (read_buf, READ_BUF_SIZE, '\0');
}
//----------------------------------------------------------------------

View File

@ -242,8 +242,7 @@ void FLabel::setText (const FString& txt)
void FLabel::hide()
{
short fg, bg;
int size;
char* blank;
std::size_t size;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
@ -262,24 +261,13 @@ void FLabel::hide()
setColor (fg, bg);
size = getWidth();
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
std::memset(blank, ' ', uLong(size));
blank[getWidth()] = '\0';
char* blank = createBlankArray(size + 1);
setPrintPos (1, 1);
print (blank);
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
@ -397,14 +385,12 @@ void FLabel::init()
//----------------------------------------------------------------------
uChar FLabel::getHotkey()
{
uInt length;
if ( text.isEmpty() )
return 0;
length = text.getLength();
std::size_t length = text.getLength();
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
try
{
@ -421,18 +407,20 @@ uChar FLabel::getHotkey()
}
//----------------------------------------------------------------------
int FLabel::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
std::size_t FLabel::getHotkeyPos ( wchar_t src[]
, wchar_t dest[]
, std::size_t length )
{
// find hotkey position in string
// + generate a new string without the '&'-sign
int hotkeypos = -1;
std::size_t hotkeypos = NOT_SET;
wchar_t* txt = src;
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
if ( i < length && txt[i] == L'&' && hotkeypos == -1 )
if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET )
{
hotkeypos = int(i);
hotkeypos = i;
i++;
src++;
}
@ -446,7 +434,7 @@ int FLabel::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
//----------------------------------------------------------------------
void FLabel::setHotkeyAccelerator()
{
int hotkey = getHotkey();
uChar hotkey = getHotkey();
if ( hotkey )
{
@ -465,22 +453,24 @@ void FLabel::setHotkeyAccelerator()
}
//----------------------------------------------------------------------
int FLabel::getAlignOffset (int length)
std::size_t FLabel::getAlignOffset (std::size_t length)
{
std::size_t width = std::size_t(getWidth());
switch ( alignment )
{
case fc::alignLeft:
return 0;
case fc::alignCenter:
if ( length < getWidth() )
return int((getWidth() - length) / 2);
if ( length < width )
return (width - length) / 2;
else
return 0;
case fc::alignRight:
if ( length < getWidth() )
return getWidth() - length;
if ( length < width )
return width - length;
else
return 0;
}
@ -522,15 +512,16 @@ void FLabel::draw()
//----------------------------------------------------------------------
void FLabel::drawMultiLine()
{
uInt y = 0;
uInt text_lines = uInt(multiline_text.size());
std::size_t y = 0;
std::size_t text_lines = multiline_text.size();
bool hotkey_printed = false;
while ( y < text_lines && y < uInt(getHeight()) )
while ( y < text_lines && y < std::size_t(getHeight()) )
{
wchar_t* label_text;
int align_offset, hotkeypos = -1;
uInt length = multiline_text[y].getLength();
std::size_t hotkeypos = NOT_SET;
std::size_t align_offset;
std::size_t length = multiline_text[y].getLength();
try
{
@ -552,16 +543,16 @@ void FLabel::drawMultiLine()
setPrintPos (1, 1 + int(y));
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
{
align_offset = getAlignOffset (int(length - 1));
align_offset = getAlignOffset(length - 1);
printLine (label_text, length - 1, hotkeypos, align_offset);
hotkey_printed = true;
}
else
{
align_offset = getAlignOffset (int(length));
printLine (label_text, length, -1, align_offset);
align_offset = getAlignOffset(length);
printLine (label_text, length, NOT_SET, align_offset);
}
y++;
@ -573,8 +564,9 @@ void FLabel::drawMultiLine()
void FLabel::drawSingleLine()
{
wchar_t* label_text;
int hotkeypos = -1, align_offset;
uInt length = text.getLength();
std::size_t hotkeypos = NOT_SET;
std::size_t align_offset;
std::size_t length = text.getLength();
try
{
@ -588,22 +580,23 @@ void FLabel::drawSingleLine()
hotkeypos = getHotkeyPos (text.wc_str(), label_text, length);
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
length--;
setPrintPos (1, 1);
align_offset = getAlignOffset (int(length));
align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text;
}
//----------------------------------------------------------------------
void FLabel::printLine ( wchar_t line[]
, uInt length
, int hotkeypos
, int align_offset )
, std::size_t length
, std::size_t hotkeypos
, std::size_t align_offset )
{
int to_char;
std::size_t to_char;
std::size_t width = std::size_t(getWidth());
bool isActive, isNoUnderline;
isActive = ((flags & fc::active) != 0);
isNoUnderline = ((flags & fc::no_underline) != 0);
@ -611,15 +604,15 @@ void FLabel::printLine ( wchar_t line[]
if ( align_offset > 0 )
print (FString(align_offset, ' ')); // leading spaces
if ( length <= uInt(getWidth()) )
to_char = int(length);
if ( length <= width )
to_char = length;
else
to_char = getWidth() - 2;
to_char = width - 2;
if ( hasReverseMode() )
setReverse(true);
for (int z = 0; z < to_char; z++)
for (std::size_t z = 0; z < to_char; z++)
{
if ( ! std::iswprint(wint_t(line[z])) )
{
@ -630,7 +623,7 @@ void FLabel::printLine ( wchar_t line[]
}
}
if ( (z == hotkeypos) && isActive )
if ( z == hotkeypos && isActive )
{
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
@ -651,17 +644,17 @@ void FLabel::printLine ( wchar_t line[]
print (line[z]);
}
if ( length > uInt(getWidth()) )
if ( length > width )
{
// Print ellipsis
setColor (ellipsis_color, getBackgroundColor());
print ("..");
setColor();
}
else if ( align_offset + to_char < getWidth() )
else if ( align_offset + to_char < width )
{
// Print trailing spaces
int len = getWidth() - align_offset - to_char;
std::size_t len = width - align_offset - to_char;
print (FString(len, ' '));
}

View File

@ -281,9 +281,8 @@ void FLineEdit::setLabelOrientation(const label_o o)
//----------------------------------------------------------------------
void FLineEdit::hide()
{
int s, size;
std::size_t s, size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
@ -303,29 +302,18 @@ void FLineEdit::hide()
s = hasShadow() ? 1 : 0;
size = getWidth() + s;
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getHeight() + s; y++)
for (std::size_t y = 0; y < getHeight() + s; y++)
{
setPrintPos (1, 1 + y);
setPrintPos (1, 1 + int(y));
print (blank);
}
delete[] blank;
destroyBlankArray(blank);
if ( label )
label->hide();
@ -434,10 +422,10 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x >= 2 && mouse_x <= getWidth() && mouse_y == 1 )
if ( mouse_x >= 2 && mouse_x <= int(getWidth()) && mouse_y == 1 )
{
int len = int(text.getLength());
cursor_pos = text_offset + mouse_x - 2;
std::size_t len = text.getLength();
cursor_pos = text_offset + std::size_t(mouse_x) - 2;
if ( cursor_pos >= len )
cursor_pos = len;
@ -461,18 +449,19 @@ void FLineEdit::onMouseUp (FMouseEvent*)
//----------------------------------------------------------------------
void FLineEdit::onMouseMove (FMouseEvent* ev)
{
int len, mouse_x, mouse_y;
std::size_t len;
int mouse_x, mouse_y;
if ( ev->getButton() != fc::LeftButton )
return;
len = int(text.getLength());
len = text.getLength();
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x >= 2 && mouse_x <= getWidth() && mouse_y == 1 )
if ( mouse_x >= 2 && mouse_x <= int(getWidth()) && mouse_y == 1 )
{
cursor_pos = text_offset + mouse_x - 2;
cursor_pos = text_offset + std::size_t(mouse_x) - 2;
if ( cursor_pos >= len )
cursor_pos = len;
@ -498,7 +487,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
drag_scroll = FLineEdit::noScroll;
}
}
else if ( mouse_x >= getWidth() )
else if ( mouse_x >= int(getWidth()) )
{
// drag right
if ( ! scroll_timer && text_offset <= len - getWidth() + 1 )
@ -526,7 +515,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FLineEdit::onTimer (FTimerEvent*)
{
int len = int(text.getLength());
std::size_t len = text.getLength();
switch ( int(drag_scroll) )
{
@ -540,7 +529,6 @@ void FLineEdit::onTimer (FTimerEvent*)
return;
}
if ( text_offset > 0 )
text_offset--;
if ( cursor_pos > 0 )
@ -642,7 +630,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
//----------------------------------------------------------------------
void FLineEdit::adjustLabel()
{
int label_length = int(label_text.getLength());
std::size_t label_length = label_text.getLength();
if ( hasHotkey() )
label_length--;
@ -657,7 +645,7 @@ void FLineEdit::adjustLabel()
break;
case label_left:
label->setGeometry(getX() - label_length - 1, getY(), label_length, 1);
label->setGeometry(getX() - int(label_length) - 1, getY(), label_length, 1);
break;
}
}
@ -731,7 +719,7 @@ void FLineEdit::draw()
void FLineEdit::drawInputField()
{
bool isActiveFocus, isShadow;
int x;
std::size_t x;
FString show_text;
int active_focus = fc::active + fc::focus;
isActiveFocus = ((flags & active_focus) == active_focus);
@ -757,7 +745,7 @@ void FLineEdit::drawInputField()
if ( isActiveFocus && getMaxColor() < 16 )
setBold();
show_text = text.mid(uInt(1 + text_offset), uInt(getWidth() - 2));
show_text = text.mid(1 + text_offset, getWidth() - 2);
if ( isLinuxTerm() && hasUTF8() )
{
@ -771,7 +759,7 @@ void FLineEdit::drawInputField()
else if ( show_text )
print (show_text);
x = int(show_text.getLength());
x = show_text.getLength();
while ( x < getWidth() - 1 )
{
@ -792,7 +780,7 @@ void FLineEdit::drawInputField()
drawShadow ();
// set the cursor to the first pos.
setCursorPos (2 + cursor_pos - text_offset, 1);
setCursorPos (int(2 + cursor_pos - text_offset), 1);
}
//----------------------------------------------------------------------
@ -808,7 +796,7 @@ inline void FLineEdit::keyLeft()
//----------------------------------------------------------------------
inline void FLineEdit::keyRight()
{
int len = int(text.getLength());
std::size_t len = text.getLength();
if ( cursor_pos < len )
cursor_pos++;
@ -828,7 +816,7 @@ inline void FLineEdit::keyHome()
//----------------------------------------------------------------------
inline void FLineEdit::keyEnd()
{
int len = int(text.getLength());
std::size_t len = text.getLength();
cursor_pos = len;
if ( cursor_pos >= getWidth() - 1 )
@ -838,7 +826,7 @@ inline void FLineEdit::keyEnd()
//----------------------------------------------------------------------
inline void FLineEdit::keyDel()
{
int len = int(text.getLength());
std::size_t len = text.getLength();
if ( len > 0 && cursor_pos < len )
{
@ -849,9 +837,6 @@ inline void FLineEdit::keyDel()
if ( cursor_pos >= len )
cursor_pos = len;
if ( cursor_pos < 0 )
cursor_pos = 0;
if ( text_offset > 0 && len - text_offset < getWidth() - 1 )
text_offset--;
}
@ -892,7 +877,7 @@ inline bool FLineEdit::keyInput (int key)
{
if ( key >= 0x20 && key <= 0x10fff )
{
int len = int(text.getLength());
std::size_t len = text.getLength();
if ( cursor_pos == len )
{
@ -902,9 +887,9 @@ inline bool FLineEdit::keyInput (int key)
else if ( len > 0 )
{
if ( insert_mode )
text.insert(wchar_t(key), uInt(cursor_pos));
text.insert(wchar_t(key), cursor_pos);
else
text.overwrite(wchar_t(key), uInt(cursor_pos));
text.overwrite(wchar_t(key), cursor_pos);
processChanged();
}
@ -913,6 +898,7 @@ inline bool FLineEdit::keyInput (int key)
text = wchar_t(key);
processChanged();
}
cursor_pos++;
if ( cursor_pos >= getWidth() - 1 )

View File

@ -127,14 +127,14 @@ FListBox::~FListBox() // destructor
// public methods of FListBox
//----------------------------------------------------------------------
void FListBox::setCurrentItem (int index)
void FListBox::setCurrentItem (std::size_t index)
{
int element_count;
std::size_t element_count;
if ( index == current )
return;
element_count = int(getCount());
element_count = getCount();
if ( index > element_count )
current = element_count;
@ -155,12 +155,12 @@ void FListBox::setCurrentItem (int index)
//----------------------------------------------------------------------
void FListBox::setCurrentItem (listBoxItems::iterator iter)
{
int index = int(std::distance(itemlist.begin(), iter) + 1);
std::size_t index = std::size_t(std::distance(itemlist.begin(), iter)) + 1;
setCurrentItem(index);
}
//----------------------------------------------------------------------
void FListBox::showInsideBrackets ( int index
void FListBox::showInsideBrackets ( std::size_t index
, fc::brackets_type b )
{
listBoxItems::iterator iter = index2iterator(index - 1);
@ -169,7 +169,7 @@ void FListBox::showInsideBrackets ( int index
if ( b == fc::NoBrackets )
return;
int len = int(iter->getText().getLength() + 2);
std::size_t len = iter->getText().getLength() + 2;
if ( len > max_line_width )
{
@ -177,8 +177,8 @@ void FListBox::showInsideBrackets ( int index
if ( len >= getWidth() - nf_offset - 3 )
{
hbar->setMaximum (max_line_width - getWidth() + nf_offset + 4);
hbar->setPageSize (max_line_width, getWidth() - nf_offset - 4);
hbar->setMaximum (int(max_line_width - getWidth() + nf_offset + 4));
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
hbar->setValue (xoffset);
if ( ! hbar->isVisible() )
@ -188,7 +188,7 @@ void FListBox::showInsideBrackets ( int index
}
//----------------------------------------------------------------------
void FListBox::setGeometry (int x, int y, int w, int h, bool adjust)
void FListBox::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Set the widget geometry
@ -196,13 +196,13 @@ void FListBox::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() )
{
vbar->setGeometry (getWidth(), 2, 2, getHeight() - 2);
hbar->setGeometry (1, getHeight(), getWidth() - 2 - nf_offset, 1);
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2);
hbar->setGeometry (1, int(getHeight()), getWidth() - 2 - nf_offset, 1);
}
else
{
vbar->setGeometry (getWidth(), 2, 1, getHeight() - 2);
hbar->setGeometry (2, getHeight(), getWidth() - 2, 1);
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2);
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1);
}
}
@ -240,11 +240,9 @@ void FListBox::setText (const FString& txt)
//----------------------------------------------------------------------
void FListBox::hide()
{
int n, size;
std::size_t n, size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
if ( parent_widget )
@ -262,41 +260,30 @@ void FListBox::hide()
n = isNewFont() ? 1 : 0;
size = getWidth() + n;
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset (blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getHeight(); y++)
for (int y = 0; y < int(getHeight()); y++)
{
setPrintPos (1, 1 + y);
print (blank);
}
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
void FListBox::insert (FListBoxItem listItem)
{
int len = int(listItem.text.getLength());
std::size_t len = listItem.text.getLength();
bool has_brackets = bool(listItem.brackets);
recalculateHorizontalBar (len, has_brackets);
itemlist.push_back (listItem);
int element_count = int(getCount());
std::size_t element_count = getCount();
recalculateVerticalBar (element_count);
}
@ -322,22 +309,22 @@ void FListBox::insert ( long item
}
//----------------------------------------------------------------------
void FListBox::remove (int item)
void FListBox::remove (std::size_t item)
{
int element_count;
std::size_t element_count;
if ( int(getCount()) < item )
if ( item > getCount() )
return;
itemlist.erase (itemlist.begin() + item - 1);
element_count = int(getCount());
itemlist.erase (itemlist.begin() + int(item) - 1);
element_count = getCount();
max_line_width = 0;
listBoxItems::iterator iter = itemlist.begin();
while ( iter != itemlist.end() )
{
int len = int(iter->getText().getLength());
std::size_t len = iter->getText().getLength();
if ( len > max_line_width )
max_line_width = len;
@ -345,14 +332,14 @@ void FListBox::remove (int item)
++iter;
}
hbar->setMaximum (max_line_width - getWidth() + nf_offset + 4);
hbar->setPageSize (max_line_width, getWidth() - nf_offset - 4);
hbar->setMaximum (int(max_line_width - getWidth() + nf_offset + 4));
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
if ( hbar->isVisible() && max_line_width < getWidth() - nf_offset - 3 )
hbar->hide();
vbar->setMaximum (element_count - getHeight() + 2);
vbar->setPageSize (element_count, getHeight() - 2);
vbar->setMaximum (int(element_count - getHeight()) + 2);
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
if ( vbar->isVisible() && element_count < getHeight() - 1 )
vbar->hide();
@ -363,8 +350,8 @@ void FListBox::remove (int item)
if ( current > element_count )
current = element_count;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
if ( yoffset > int(element_count - getHeight()) + 2 )
yoffset = int(element_count - getHeight()) + 2;
if ( yoffset < 0 )
yoffset = 0;
@ -373,11 +360,8 @@ void FListBox::remove (int item)
//----------------------------------------------------------------------
void FListBox::clear()
{
int size;
char* blank;
std::size_t size;
itemlist.clear();
current = 0;
xoffset = 0;
yoffset = 0;
@ -397,36 +381,28 @@ void FListBox::clear()
setColor (wc.list_fg, wc.list_bg);
size = getWidth() - 2;
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset (blank, ' ', uLong(size));
std::memset (blank, ' ', size);
blank[size] = '\0';
for (int y = 0; y < getHeight() - 2; y++)
for (int y = 0; y < int(getHeight()) - 2; y++)
{
setPrintPos (2, 2 + y);
print (blank);
}
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
void FListBox::onKeyPress (FKeyEvent* ev)
{
int current_before = current
, xoffset_before = xoffset
std::size_t current_before = current;
int xoffset_before = xoffset
, yoffset_before = yoffset
, key = ev->key();
@ -543,11 +519,11 @@ void FListBox::onMouseDown (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
int element_count = int(getCount());
current = yoffset + mouse_y - 1;
std::size_t element_count = getCount();
current = std::size_t(yoffset + mouse_y - 1);
if ( current > element_count )
current = element_count;
@ -581,8 +557,8 @@ void FListBox::onMouseUp (FMouseEvent* ev)
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
processChanged();
@ -602,16 +578,16 @@ void FListBox::onMouseMove (FMouseEvent* ev)
if ( ev->getButton() == fc::RightButton && ! isMultiSelection() )
return;
int current_before = current;
std::size_t current_before = current;
int yoffset_before = yoffset;
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
int element_count = int(getCount());
current = yoffset + mouse_y - 1;
std::size_t element_count = getCount();
current = std::size_t(yoffset + mouse_y - 1);
if ( current > element_count )
current = element_count;
@ -640,7 +616,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
// Auto-scrolling when dragging mouse outside the widget
if ( mouse_y < 2 )
dragUp (ev->getButton());
else if ( mouse_y >= getHeight() )
else if ( mouse_y >= int(getHeight()) )
dragDown (ev->getButton());
else
stopDragScroll();
@ -657,8 +633,8 @@ void FListBox::onMouseDoubleClick (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
if ( yoffset + mouse_y - 1 > int(getCount()) )
return;
@ -670,7 +646,7 @@ void FListBox::onMouseDoubleClick (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListBox::onTimer (FTimerEvent*)
{
int current_before = current;
std::size_t current_before = current;
int yoffset_before = yoffset;
switch ( int(drag_scroll) )
@ -719,8 +695,8 @@ void FListBox::onTimer (FTimerEvent*)
//----------------------------------------------------------------------
void FListBox::onWheel (FWheelEvent* ev)
{
std::size_t current_before = current;
int wheel
, current_before = current
, yoffset_before = yoffset
, pagesize = 4;
@ -791,44 +767,41 @@ void FListBox::onFocusOut (FFocusEvent*)
//----------------------------------------------------------------------
void FListBox::adjustYOffset()
{
int element_count = int(getCount());
std::size_t element_count = getCount();
if ( getClientHeight() < 0 )
if ( element_count == 0 || getClientHeight() == 0 )
return;
if ( element_count == 0 || getClientHeight() <= 0 )
return;
if ( yoffset > element_count - getClientHeight() )
yoffset = element_count - getClientHeight();
if ( yoffset > int(element_count - getClientHeight()) )
yoffset = int(element_count - getClientHeight());
if ( yoffset < 0 )
yoffset = 0;
if ( current < yoffset )
current = yoffset;
if ( current < std::size_t(yoffset) )
current = std::size_t(yoffset);
if ( yoffset < current - getClientHeight() )
yoffset = current - getClientHeight();
if ( yoffset < int(current - getClientHeight()) )
yoffset = int(current - getClientHeight());
}
//----------------------------------------------------------------------
void FListBox::adjustSize()
{
int element_count;
std::size_t element_count;
FWidget::adjustSize();
adjustYOffset();
element_count = int(getCount());
vbar->setMaximum (element_count - getClientHeight());
vbar->setPageSize (element_count, getClientHeight());
vbar->setX (getWidth());
element_count = getCount();
vbar->setMaximum (int(element_count - getClientHeight()));
vbar->setPageSize (int(element_count), int(getClientHeight()));
vbar->setX (int(getWidth()));
vbar->setHeight (getClientHeight(), false);
vbar->resize();
hbar->setMaximum (max_line_width - getClientWidth() + 2);
hbar->setPageSize (max_line_width, getClientWidth() - 2);
hbar->setY (getHeight());
hbar->setMaximum (int(max_line_width - getClientWidth() + 2));
hbar->setPageSize (int(max_line_width), int(getClientWidth()) - 2);
hbar->setY (int(getHeight()));
hbar->setWidth (getClientWidth() + nf_offset, false);
hbar->resize();
@ -893,7 +866,7 @@ void FListBox::init()
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + nf_offset);
setRightPadding(1 + int(nf_offset));
}
//----------------------------------------------------------------------
@ -910,7 +883,7 @@ void FListBox::draw()
setReverse(true);
if ( isNewFont() )
drawBorder (1, 1, getWidth() - 1, getHeight());
drawBorder (1, 1, int(getWidth()) - 1, int(getHeight()));
else
drawBorder();
@ -918,9 +891,9 @@ void FListBox::draw()
{
setColor();
for (int y = 2; y < getHeight(); y++)
for (int y = 2; y < int(getHeight()); y++)
{
setPrintPos (getWidth(), y);
setPrintPos (int(getWidth()), y);
print (' '); // clear right side of the scrollbar
}
}
@ -955,14 +928,11 @@ void FListBox::draw()
//----------------------------------------------------------------------
void FListBox::drawLabel()
{
FString txt;
uInt length;
if ( text.isNull() || text.isEmpty() )
return;
txt = " " + text + " ";
length = txt.getLength();
FString txt = " " + text + " ";
std::size_t length = txt.getLength();
setPrintPos (2, 1);
if ( isEnabled() )
@ -984,7 +954,7 @@ void FListBox::drawLabel()
//----------------------------------------------------------------------
void FListBox::drawList()
{
uInt start, num;
std::size_t start, num;
listBoxItems::iterator iter;
if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
@ -998,18 +968,18 @@ void FListBox::drawList()
if ( last_yoffset >= 0
&& last_yoffset == yoffset
&& last_current != current )
&& last_current != int(current) )
{
// speed up: redraw only the changed rows
uInt last_pos = uInt(current - yoffset) - 1;
uInt current_pos = uInt(last_current - yoffset) - 1;
std::size_t last_pos = current - std::size_t(yoffset) - 1;
std::size_t current_pos = std::size_t(last_current - yoffset) - 1;
start = std::min(last_pos, current_pos);
num = std::max(last_pos, current_pos) + 1;
}
iter = index2iterator(int(start) + yoffset);
iter = index2iterator(start + std::size_t(yoffset));
for (uInt y = start; y < num && iter != itemlist.end() ; y++)
for (std::size_t y = start; y < num && iter != itemlist.end() ; y++)
{
bool serach_mark = false;
bool lineHasBrackets = hasBrackets(iter);
@ -1036,7 +1006,7 @@ void FListBox::drawList()
unsetAttributes();
last_yoffset = yoffset;
last_current = current;
last_current = int(current);
}
//----------------------------------------------------------------------
@ -1044,13 +1014,13 @@ inline void FListBox::drawListLine ( int y
, listBoxItems::iterator iter
, bool serach_mark )
{
uInt i, len;
uInt inc_len = inc_search.getLength();
bool isCurrentLine = bool(y + yoffset + 1 == current);
std::size_t i, len;
std::size_t inc_len = inc_search.getLength();
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
bool isFocus = ((flags & fc::focus) != 0);
FString element;
element = getString(iter).mid ( uInt(1 + xoffset)
, uInt(getWidth() - nf_offset - 4) );
element = getString(iter).mid ( std::size_t(1 + xoffset)
, getWidth() - nf_offset - 4 );
const wchar_t* const& element_str = element.wc_str();
len = element.getLength();
@ -1078,7 +1048,7 @@ inline void FListBox::drawListLine ( int y
i++;
}
for (; i < uInt(getWidth() - nf_offset - 3); i++)
for (; i < getWidth() - nf_offset - 3; i++)
print (' ');
}
@ -1139,13 +1109,13 @@ inline void FListBox::drawListBracketsLine ( int y
, listBoxItems::iterator iter
, bool serach_mark )
{
int full_length;
FString element;
uInt len
std::size_t len
, full_length
, inc_len = inc_search.getLength()
, i = 0
, b = 0;
bool isCurrentLine = bool(y + yoffset + 1 == current);
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
bool isFocus = ((flags & fc::focus) != 0);
if ( isMonochron() && isCurrentLine && isFocus )
@ -1158,12 +1128,12 @@ inline void FListBox::drawListBracketsLine ( int y
b = 1;
printLeftBracket (iter->brackets);
element = getString(iter).mid ( uInt(1 + xoffset)
, uInt(getWidth() - nf_offset - 5) );
element = getString(iter).mid ( std::size_t(xoffset) + 1
, getWidth() - nf_offset - 5 );
}
else
element = getString(iter).mid ( uInt(xoffset)
, uInt(getWidth() - nf_offset - 4) );
element = getString(iter).mid ( std::size_t(xoffset)
, getWidth() - nf_offset - 4 );
const wchar_t* const& element_str = element.wc_str();
len = element.getLength();
@ -1181,10 +1151,10 @@ inline void FListBox::drawListBracketsLine ( int y
print (element_str[i]);
}
full_length = int(getString(iter).getLength());
full_length = getString(iter).getLength();
if ( b + i < uInt(getWidth() - nf_offset - 4 )
&& xoffset <= full_length + 1 )
if ( b + i < getWidth() - nf_offset - 4
&& std::size_t(xoffset) <= full_length + 1 )
{
if ( serach_mark && i == inc_len )
setColor ( wc.current_element_focus_fg
@ -1200,7 +1170,7 @@ inline void FListBox::drawListBracketsLine ( int y
i++;
}
for (; b + i < uInt(getWidth() - nf_offset - 3); i++)
for (; b + i < getWidth() - nf_offset - 3; i++)
print (' ');
}
@ -1211,8 +1181,8 @@ inline void FListBox::setLineAttributes ( int y
, bool& serach_mark )
{
bool isFocus = ((flags & fc::focus) != 0)
, isCurrentLine = bool(y + yoffset + 1 == current);
uInt inc_len = inc_search.getLength();
, isCurrentLine = bool(y + yoffset + 1 == int(current));
std::size_t inc_len = inc_search.getLength();
setPrintPos (2, 2 + int(y));
@ -1316,7 +1286,7 @@ inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar)
}
//----------------------------------------------------------------------
void FListBox::recalculateHorizontalBar (int len, bool has_brackets)
void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets)
{
if ( has_brackets )
len += 2;
@ -1328,8 +1298,8 @@ void FListBox::recalculateHorizontalBar (int len, bool has_brackets)
if ( len >= getWidth() - nf_offset - 3 )
{
hbar->setMaximum (max_line_width - getWidth() + nf_offset + 4);
hbar->setPageSize (max_line_width, getWidth() - nf_offset - 4);
hbar->setMaximum (int(max_line_width - getWidth() + nf_offset + 4));
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
@ -1338,10 +1308,10 @@ void FListBox::recalculateHorizontalBar (int len, bool has_brackets)
}
//----------------------------------------------------------------------
void FListBox::recalculateVerticalBar (int element_count)
void FListBox::recalculateVerticalBar (std::size_t element_count)
{
vbar->setMaximum (element_count - getHeight() + 2);
vbar->setPageSize (element_count, getHeight() - 2);
vbar->setMaximum (int(element_count - getHeight() + 2));
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
@ -1367,7 +1337,7 @@ inline void FListBox::getWidgetFocus()
}
//----------------------------------------------------------------------
void FListBox::multiSelection (int pos)
void FListBox::multiSelection (std::size_t pos)
{
if ( ! isMultiSelection() )
return;
@ -1384,29 +1354,29 @@ void FListBox::multiSelection (int pos)
}
processSelect();
secect_from_item = pos;
secect_from_item = int(pos);
}
//----------------------------------------------------------------------
void FListBox::multiSelectionUpTo (int pos)
void FListBox::multiSelectionUpTo (std::size_t pos)
{
int from, to;
std::size_t from, to;
if ( ! isMultiSelection() )
return;
if ( secect_from_item > pos )
if ( std::size_t(secect_from_item) > pos )
{
from = pos;
to = secect_from_item - 1;
to = std::size_t(secect_from_item) - 1;
}
else
{
from = secect_from_item + 1;
from = std::size_t(secect_from_item) + 1;
to = pos;
}
for (int i = from; i <= to; i++)
for (std::size_t i = from; i <= to; i++)
{
if ( mouse_select )
{
@ -1420,7 +1390,7 @@ void FListBox::multiSelectionUpTo (int pos)
}
}
secect_from_item = pos;
secect_from_item = int(pos);
}
//----------------------------------------------------------------------
@ -1433,11 +1403,11 @@ void FListBox::wheelUp (int pagesize)
if ( yoffset < 0 )
{
current -= pagesize + yoffset;
current -= std::size_t(pagesize + yoffset);
yoffset = 0;
}
else
current -= pagesize;
current -= std::size_t(pagesize);
if ( current < 1 )
current = 1;
@ -1446,8 +1416,8 @@ void FListBox::wheelUp (int pagesize)
//----------------------------------------------------------------------
void FListBox::wheelDown (int pagesize)
{
int element_count = int(getCount());
int yoffset_end = element_count - getClientHeight();
std::size_t element_count = getCount();
int yoffset_end = int(element_count - getClientHeight());
if ( yoffset_end < 0 )
yoffset_end = 0;
@ -1459,11 +1429,11 @@ void FListBox::wheelDown (int pagesize)
if ( yoffset > yoffset_end )
{
current += pagesize - (yoffset - yoffset_end);
current += std::size_t(pagesize - (yoffset - yoffset_end));
yoffset = yoffset_end;
}
else
current += pagesize;
current += std::size_t(pagesize);
if ( current > element_count )
current = element_count;
@ -1485,7 +1455,7 @@ bool FListBox::dragScrollUp()
//----------------------------------------------------------------------
bool FListBox::dragScrollDown()
{
int element_count = int(getCount());
std::size_t element_count = getCount();
if ( current == element_count )
{
@ -1501,7 +1471,7 @@ bool FListBox::dragScrollDown()
void FListBox::dragUp (int mouse_button)
{
if ( drag_scroll != fc::noScroll
&& scroll_distance < getClientHeight() )
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
if ( ! scroll_timer && current > 1 )
@ -1526,10 +1496,10 @@ void FListBox::dragUp (int mouse_button)
void FListBox::dragDown (int mouse_button)
{
if ( drag_scroll != fc::noScroll
&& scroll_distance < getClientHeight() )
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
if ( ! scroll_timer && current < int(getCount()) )
if ( ! scroll_timer && current < getCount() )
{
scroll_timer = true;
addTimer(scroll_repeat);
@ -1540,7 +1510,7 @@ void FListBox::dragDown (int mouse_button)
drag_scroll = fc::scrollDown;
}
if ( current == int(getCount()) )
if ( current == getCount() )
{
delOwnTimer();
drag_scroll = fc::noScroll;
@ -1562,12 +1532,12 @@ void FListBox::prevListItem (int distance)
if ( current == 1 )
return;
current -= distance;
current -= std::size_t(distance);
if ( current < 1 )
current = 1;
if ( current <= yoffset )
if ( current <= std::size_t(yoffset) )
{
yoffset -= distance;
@ -1579,18 +1549,18 @@ void FListBox::prevListItem (int distance)
//----------------------------------------------------------------------
void FListBox::nextListItem (int distance)
{
int element_count = int(getCount());
int yoffset_end = element_count - getClientHeight();
std::size_t element_count = getCount();
int yoffset_end = int(element_count - getClientHeight());
if ( current == element_count )
return;
current += distance;
current += std::size_t(distance);
if ( current > element_count )
current = element_count;
if ( current - yoffset > getClientHeight() )
if ( current - std::size_t(yoffset) > getClientHeight() )
{
yoffset += distance;
@ -1601,16 +1571,16 @@ void FListBox::nextListItem (int distance)
//----------------------------------------------------------------------
void FListBox::scrollToX (int val)
{
static const int padding_space = 2; // 1 leading space + 1 trailing space
int xoffset_end = max_line_width - getClientWidth() + padding_space;
static const std::size_t padding_space = 2; // 1 leading space + 1 trailing space
std::size_t xoffset_end = max_line_width - getClientWidth() + padding_space;
if ( xoffset == val )
return;
xoffset = val;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset > int(xoffset_end) )
xoffset = int(xoffset_end);
if ( xoffset < 0 )
xoffset = 0;
@ -1619,13 +1589,13 @@ void FListBox::scrollToX (int val)
//----------------------------------------------------------------------
void FListBox::scrollToY (int val)
{
int element_count = int(getCount());
int yoffset_end = element_count - getClientHeight();
std::size_t element_count = getCount();
int yoffset_end = int(element_count - getClientHeight());
if ( yoffset == val )
return;
int c = current - yoffset;
int c = int(current) - yoffset;
yoffset = val;
if ( yoffset > yoffset_end )
@ -1634,10 +1604,10 @@ void FListBox::scrollToY (int val)
if ( yoffset < 0 )
yoffset = 0;
current = yoffset + c;
current = std::size_t(yoffset + c);
if ( current < yoffset )
current = yoffset;
if ( current < std::size_t(yoffset) )
current = std::size_t(yoffset);
if ( current > element_count )
current = element_count;
@ -1658,15 +1628,15 @@ void FListBox::scrollLeft (int distance)
//----------------------------------------------------------------------
void FListBox::scrollRight (int distance)
{
static const int padding_space = 2; // 1 leading space + 1 trailing space
int xoffset_end = max_line_width - getClientWidth() + padding_space;
static const std::size_t padding_space = 2; // 1 leading space + 1 trailing space
std::size_t xoffset_end = max_line_width - getClientWidth() + padding_space;
xoffset += distance;
if ( xoffset == xoffset_end )
if ( xoffset == int(xoffset_end) )
return;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset > int(xoffset_end) )
xoffset = int(xoffset_end);
if ( xoffset < 0 )
xoffset = 0;
@ -1703,7 +1673,7 @@ inline void FListBox::keyRight()
//----------------------------------------------------------------------
inline void FListBox::keyPgUp()
{
int pagesize = getClientHeight() - 1;
int pagesize = int(getClientHeight()) - 1;
prevListItem (pagesize);
inc_search.clear();
}
@ -1711,7 +1681,7 @@ inline void FListBox::keyPgUp()
//----------------------------------------------------------------------
inline void FListBox::keyPgDn()
{
int pagesize = getClientHeight() - 1;
int pagesize = int(getClientHeight()) - 1;
nextListItem (pagesize);
inc_search.clear();
}
@ -1727,8 +1697,8 @@ inline void FListBox::keyHome()
//----------------------------------------------------------------------
inline void FListBox::keyEnd()
{
int element_count = int(getCount());
int yoffset_end = element_count - getClientHeight();
std::size_t element_count = getCount();
int yoffset_end = int(element_count - getClientHeight());
current = element_count;
if ( current > getClientHeight() )
@ -1759,7 +1729,7 @@ inline void FListBox::keyEnter()
//----------------------------------------------------------------------
inline bool FListBox::keySpace()
{
uInt inc_len = inc_search.getLength();
std::size_t inc_len = inc_search.getLength();
if ( inc_len > 0 )
{
@ -1806,7 +1776,7 @@ inline bool FListBox::keyInsert()
{
if ( isMultiSelection() )
{
int element_count = int(getCount());
std::size_t element_count = getCount();
if ( isSelected(current) )
unselectItem(current);
@ -1819,7 +1789,7 @@ inline bool FListBox::keyInsert()
if ( current > element_count )
current = element_count;
if ( current - yoffset >= getHeight() - 1 )
if ( current - std::size_t(yoffset) >= getHeight() - 1 )
yoffset++;
return true;
@ -1832,7 +1802,7 @@ inline bool FListBox::keyInsert()
//----------------------------------------------------------------------
inline bool FListBox::keyBackspace()
{
uInt inc_len = inc_search.getLength();
std::size_t inc_len = inc_search.getLength();
if ( inc_len > 0 )
{
@ -1873,7 +1843,7 @@ inline bool FListBox::keyIncSearchInput (int key)
else
inc_search += wchar_t(key);
uInt inc_len = inc_search.getLength();
std::size_t inc_len = inc_search.getLength();
bool inc_found = false;
listBoxItems::iterator iter = itemlist.begin();
@ -1929,7 +1899,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
return;
convertToItem (*iter, source_container, y + yoffset);
int len = int(iter->text.getLength());
std::size_t len = iter->text.getLength();
recalculateHorizontalBar (len, hasBrackets(iter));
if ( hbar->isVisible() )
@ -1940,9 +1910,9 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
void FListBox::cb_VBarChange (FWidget*, data_ptr)
{
FScrollbar::sType scrollType;
std::size_t current_before = current;
int distance = 1
, pagesize = 4
, current_before = current
, yoffset_before = yoffset;
scrollType = vbar->getScrollType();
@ -1952,14 +1922,14 @@ void FListBox::cb_VBarChange (FWidget*, data_ptr)
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
distance = int(getClientHeight());
// fall through
case FScrollbar::scrollStepBackward:
prevListItem (distance);
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
distance = int(getClientHeight());
// fall through
case FScrollbar::scrollStepForward:
nextListItem (distance);
@ -2019,14 +1989,14 @@ void FListBox::cb_HBarChange (FWidget*, data_ptr)
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth() - padding_space;
distance = int(getClientWidth()) - padding_space;
// fall through
case FScrollbar::scrollStepBackward:
scrollLeft (distance);
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth() - padding_space;
distance = int(getClientWidth()) - padding_space;
// fall through
case FScrollbar::scrollStepForward:
scrollRight (distance);

View File

@ -49,6 +49,8 @@ long firstNumberFromString (const FString& str)
FString::iterator iter = str.begin();
FString::iterator first_pos;
FString::iterator last_pos;
std::size_t pos;
std::size_t length;
long number;
while ( iter != last )
@ -82,8 +84,8 @@ long firstNumberFromString (const FString& str)
if ( last_pos == last )
return 0;
uInt pos = uInt(std::distance(str.begin(), first_pos)) + 1;
uInt length = uInt(std::distance(first_pos, last_pos));
pos = std::size_t(std::distance(str.begin(), first_pos)) + 1;
length = std::size_t(std::distance(first_pos, last_pos));
const FString num_str = str.mid(pos, length);
try
@ -237,8 +239,9 @@ FString FListViewItem::getText (int column) const
|| column > int(column_list.size()) )
return fc::emptyFString::get();
column--; // Convert column position to address offset (index)
return column_list[uInt(column)];
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
return column_list[index];
}
//----------------------------------------------------------------------
@ -263,23 +266,24 @@ void FListViewItem::setText (int column, const FString& text)
|| column > int(column_list.size()) )
return;
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
FObject* parent = getParent();
column--; // Convert column position to address offset (index)
if ( parent && parent->isInstanceOf("FListView") )
{
FListView* listview = static_cast<FListView*>(parent);
if ( ! listview->header[uInt(column)].fixed_width )
if ( ! listview->header[index].fixed_width )
{
int length = int(text.getLength());
if ( length > listview->header[uInt(column)].width )
listview->header[uInt(column)].width = length;
if ( length > listview->header[index].width )
listview->header[index].width = length;
}
}
column_list[uInt(column)] = text;
column_list[index] = text;
}
//----------------------------------------------------------------------
@ -346,15 +350,15 @@ void FListViewItem::sort (Compare cmp)
return;
// Sort the top level
FObject::FObjectList& children_list = getChildren();
FObject::FObjectList& children = getChildren();
if ( ! children_list.empty() )
children_list.sort(cmp);
if ( ! children.empty() )
children.sort(cmp);
// Sort the sublevels
FListViewIterator iter = children_list.begin();
FListViewIterator iter = begin();
while ( iter != children_list.end() )
while ( iter != end() )
{
if ( *iter )
{
@ -391,7 +395,7 @@ void FListViewItem::replaceControlCodes()
}
//----------------------------------------------------------------------
int FListViewItem::getVisibleLines()
std::size_t FListViewItem::getVisibleLines()
{
if ( visible_lines > 1 )
return visible_lines;
@ -629,7 +633,7 @@ FListView::~FListView() // destructor
// public methods of FListView
//----------------------------------------------------------------------
uInt FListView::getCount()
std::size_t FListView::getCount()
{
int n = 0;
FObjectIterator iter = itemlist.begin();
@ -641,7 +645,7 @@ uInt FListView::getCount()
++iter;
}
return uInt(n);
return std::size_t(n);
}
//----------------------------------------------------------------------
@ -652,8 +656,9 @@ fc::text_alignment FListView::getColumnAlignment (int column) const
if ( column < 1 || header.empty() || column > int(header.size()) )
return fc::alignLeft;
column--; // Convert column position to address offset (index)
return header[uInt(column)].alignment;
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
return header[index].alignment;
}
//----------------------------------------------------------------------
@ -664,19 +669,20 @@ FString FListView::getColumnText (int column) const
if ( column < 1 || header.empty() || column > int(header.size()) )
return fc::emptyFString::get();
column--; // Convert column position to address offset (index)
return header[uInt(column)].name;
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
return header[index].name;
}
//----------------------------------------------------------------------
fc::sorting_type FListView::getColumnSortType (int column) const
{
fc::sorting_type type;
std::size_t size = uInt(column);
std::size_t col = uInt(column);
try
{
type = sort_type.at(size);
type = sort_type.at(col);
}
catch (const std::out_of_range&)
{
@ -687,7 +693,7 @@ fc::sorting_type FListView::getColumnSortType (int column) const
}
//----------------------------------------------------------------------
void FListView::setGeometry (int x, int y, int w, int h, bool adjust)
void FListView::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Set the widget geometry
@ -695,13 +701,13 @@ void FListView::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() )
{
vbar->setGeometry (getWidth(), 2, 2, getHeight() - 2);
hbar->setGeometry (1, getHeight(), getWidth() - 2, 1);
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2);
hbar->setGeometry (1, int(getHeight()), getWidth() - 2, 1);
}
else
{
vbar->setGeometry (getWidth(), 2, 1, getHeight() - 2);
hbar->setGeometry (2, getHeight(), getWidth() - 2, 1);
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2);
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1);
}
}
@ -713,8 +719,9 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align)
if ( column < 1 || header.empty() || column > int(header.size()) )
return;
column--; // Convert column position to address offset (index)
header[uInt(column)].alignment = align;
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
header[index].alignment = align;
}
//----------------------------------------------------------------------
@ -725,17 +732,18 @@ void FListView::setColumnText (int column, const FString& label)
if ( column < 1 || header.empty() || column > int(header.size()) )
return;
column--; // Convert column position to address offset (index)
// Convert column position to address offset (index)
std::size_t index = uInt(column - 1);
if ( ! header[uInt(column)].fixed_width )
if ( ! header[index].fixed_width )
{
int length = int(label.getLength());
if ( length > header[uInt(column)].width )
header[uInt(column)].width = length;
if ( length > header[index].width )
header[index].width = length;
}
header[uInt(column)].name = label;
header[index].name = label;
}
//----------------------------------------------------------------------
@ -940,7 +948,7 @@ void FListView::onKeyPress (FKeyEvent* ev)
int position_before = current_iter.getPosition()
, xoffset_before = xoffset
, first_line_position_before = first_visible_line.getPosition()
, pagesize = getClientHeight() - 1
, pagesize = int(getClientHeight()) - 1
, key = ev->key();
clicked_expander_pos.setPoint(-1, -1);
@ -1045,8 +1053,8 @@ void FListView::onMouseDown (FMouseEvent* ev)
, mouse_x = ev->getX()
, mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
int new_pos = first_visible_line.getPosition() + mouse_y - 2;
@ -1087,8 +1095,8 @@ void FListView::onMouseUp (FMouseEvent* ev)
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
if ( tree_view )
{
@ -1128,8 +1136,8 @@ void FListView::onMouseMove (FMouseEvent* ev)
, mouse_x = ev->getX()
, mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
int new_pos = first_visible_line.getPosition() + mouse_y - 2;
@ -1152,7 +1160,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
// auto-scrolling when dragging mouse outside the widget
if ( mouse_y < 2 )
dragUp (ev->getButton());
else if ( mouse_y >= getHeight() )
else if ( mouse_y >= int(getHeight()) )
dragDown (ev->getButton());
else
stopDragScroll();
@ -1169,8 +1177,8 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) )
{
if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) )
return;
@ -1301,7 +1309,7 @@ void FListView::onFocusOut (FFocusEvent*)
void FListView::adjustViewport()
{
int element_count = int(getCount());
int height = getClientHeight();
int height = int(getClientHeight());
if ( element_count == 0 || height <= 0 )
return;
@ -1341,20 +1349,20 @@ void FListView::adjustViewport()
//----------------------------------------------------------------------
void FListView::adjustSize()
{
int element_count;
std::size_t element_count;
FWidget::adjustSize();
adjustViewport();
element_count = int(getCount());
vbar->setMaximum (element_count - getClientHeight());
vbar->setPageSize (element_count, getClientHeight());
vbar->setX (getWidth());
element_count = getCount();
vbar->setMaximum (int(element_count - getClientHeight()));
vbar->setPageSize (int(element_count), int(getClientHeight()));
vbar->setX (int(getWidth()));
vbar->setHeight (getClientHeight(), false);
vbar->resize();
hbar->setMaximum (max_line_width - getClientWidth());
hbar->setPageSize (max_line_width, getClientWidth());
hbar->setY (getHeight() );
hbar->setMaximum (max_line_width - int(getClientWidth()));
hbar->setPageSize (max_line_width, int(getClientWidth()));
hbar->setY (int(getHeight()));
hbar->setWidth (getClientWidth(), false);
hbar->resize();
@ -1363,7 +1371,7 @@ void FListView::adjustSize()
else
vbar->setVisible();
if ( max_line_width <= getClientWidth() )
if ( max_line_width <= int(getClientWidth()) )
hbar->hide();
else
hbar->setVisible();
@ -1443,9 +1451,9 @@ void FListView::sort (Compare cmp)
}
//----------------------------------------------------------------------
uInt FListView::getAlignOffset ( fc::text_alignment align
, uInt txt_length
, uInt width )
std::size_t FListView::getAlignOffset ( fc::text_alignment align
, std::size_t txt_length
, std::size_t width )
{
switch ( align )
{
@ -1454,7 +1462,7 @@ uInt FListView::getAlignOffset ( fc::text_alignment align
case fc::alignCenter:
if ( txt_length < width )
return uInt((width - txt_length) / 2);
return (width - txt_length) / 2;
else
return 0;
@ -1482,7 +1490,7 @@ void FListView::draw()
setReverse(true);
if ( isNewFont() )
drawBorder (1, 1, getWidth() - 1, getHeight());
drawBorder (1, 1, int(getWidth()) - 1, int(getHeight()));
else
drawBorder();
@ -1490,9 +1498,9 @@ void FListView::draw()
{
setColor();
for (int y = 2; y < getHeight(); y++)
for (int y = 2; y < int(getHeight()); y++)
{
setPrintPos (getWidth(), y);
setPrintPos (int(getWidth()), y);
print (' '); // clear right side of the scrollbar
}
}
@ -1557,11 +1565,11 @@ void FListView::drawColumnLabels()
h << headerline;
first = h.begin() + xoffset;
if ( int(h.size()) <= getClientWidth() )
if ( h.size() <= getClientWidth() )
last = h.end();
else
{
int len = getClientWidth() + xoffset - 1;
int len = int(getClientWidth()) + xoffset - 1;
if ( len > int(h.size()) )
len = int(h.size());
@ -1612,7 +1620,7 @@ void FListView::drawList()
while ( y < uInt(getClientHeight()) )
{
setPrintPos (2, 2 + int(y));
print (FString(getClientWidth(), ' '));
print (FString(std::size_t(getClientWidth()), ' '));
y++;
}
}
@ -1622,7 +1630,7 @@ void FListView::drawListLine ( const FListViewItem* item
, bool is_focus
, bool is_current )
{
uInt indent = item->getDepth() << 1; // indent = 2 * depth
std::size_t indent = item->getDepth() << 1; // indent = 2 * depth
// Set line color and attributes
setLineAttributes (is_current, is_focus);
@ -1633,19 +1641,19 @@ void FListView::drawListLine ( const FListViewItem* item
// Print columns
if ( ! item->column_list.empty() )
{
for (uInt i = 0; i < item->column_list.size(); )
for (std::size_t i = 0; i < item->column_list.size(); )
{
static const int leading_space = 1;
static const int ellipsis_length = 2;
static const std::size_t leading_space = 1;
static const std::size_t ellipsis_length = 2;
const FString& text = item->column_list[i];
int width = header[i].width;
uInt txt_length = text.getLength();
std::size_t width = std::size_t(header[i].width);
std::size_t txt_length = text.getLength();
// Increment the value of i for the column position
// and the next iteration
i++;
fc::text_alignment align = getColumnAlignment(int(i));
uInt align_offset = getAlignOffset (align, txt_length, uInt(width));
std::size_t align_offset = getAlignOffset (align, txt_length, width);
if ( tree_view && i == 1 )
{
@ -1657,12 +1665,12 @@ void FListView::drawListLine ( const FListViewItem* item
if ( align_offset > 0 )
line += FString(align_offset, L' ');
if ( align_offset + txt_length <= uInt(width) )
if ( align_offset + txt_length <= width )
{
// Insert text and trailing space
line += text.left(width);
line += FString ( leading_space + width
- int(align_offset + txt_length), L' ');
- align_offset - txt_length, L' ');
}
else if ( align == fc::alignRight )
{
@ -1680,16 +1688,16 @@ void FListView::drawListLine ( const FListViewItem* item
}
}
line = line.mid ( uInt(1 + xoffset)
, uInt(getWidth() - nf_offset - 2) );
line = line.mid ( std::size_t(xoffset) + 1
, getWidth() - std::size_t(nf_offset) - 2);
const wchar_t* const& element_str = line.wc_str();
uInt len = line.getLength();
uInt i;
std::size_t len = line.getLength();
std::size_t i;
for (i = 0; i < len; i++)
*this << element_str[i];
for (; i < uInt(getWidth() - nf_offset - 2); i++)
for (; i < getWidth() - std::size_t(nf_offset) - 2; i++)
print (' ');
}
@ -1730,7 +1738,7 @@ inline void FListView::setLineAttributes ( bool is_current
//----------------------------------------------------------------------
inline FString FListView::getLinePrefix ( const FListViewItem* item
, uInt indent )
, std::size_t indent )
{
FString line = "";
@ -1765,30 +1773,30 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item
void FListView::drawColumnText (headerItems::const_iterator& iter)
{
// Print lable text
static const int leading_space = 1;
static const int trailing_space = 1;
static const std::size_t leading_space = 1;
static const std::size_t trailing_space = 1;
const FString& text = iter->name;
int width = iter->width;
std::size_t width = std::size_t(iter->width);
FString txt = " " + text;
uInt txt_length = txt.getLength();
int column_width = leading_space + width;
std::size_t txt_length = txt.getLength();
std::size_t column_width = leading_space + width;
if ( isEnabled() )
setColor (wc.label_emphasis_fg, wc.label_bg);
else
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
if ( txt_length <= uInt(column_width) )
if ( txt_length <= column_width )
{
headerline << txt;
if ( txt_length < uInt(column_width) )
if ( txt_length < column_width )
headerline << ' '; // trailing space
if ( txt_length + trailing_space < uInt(column_width) )
if ( txt_length + trailing_space < column_width )
{
setColor();
const FString line ( uInt(column_width) - trailing_space - txt_length
const FString line ( column_width - trailing_space - txt_length
, wchar_t(fc::BoxDrawingsHorizontal) );
headerline << line; // horizontal line
}
@ -1878,10 +1886,10 @@ void FListView::recalculateHorizontalBar (int len)
max_line_width = len;
if ( len >= getWidth() - nf_offset - 3 )
if ( len >= int(getWidth()) - nf_offset - 3 )
{
hbar->setMaximum (max_line_width - getWidth() + nf_offset + 4);
hbar->setPageSize (max_line_width, getWidth() - nf_offset - 4);
hbar->setMaximum (max_line_width - int(getWidth()) + nf_offset + 4);
hbar->setPageSize (max_line_width, int(getWidth()) - nf_offset - 4);
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
@ -1892,11 +1900,11 @@ void FListView::recalculateHorizontalBar (int len)
//----------------------------------------------------------------------
void FListView::recalculateVerticalBar (int element_count)
{
vbar->setMaximum (element_count - getHeight() + 2);
vbar->setPageSize (element_count, getHeight() - 2);
vbar->setMaximum (element_count - int(getHeight()) + 2);
vbar->setPageSize (element_count, int(getHeight()) - 2);
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
if ( ! vbar->isVisible() && element_count >= int(getHeight()) - 1 )
vbar->setVisible();
}
@ -1982,7 +1990,7 @@ bool FListView::dragScrollDown (int position_before)
void FListView::dragUp (int mouse_button)
{
if ( drag_scroll != fc::noScroll
&& scroll_distance < getClientHeight() )
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
if ( ! scroll_timer && current_iter.getPosition() > 0 )
@ -2007,7 +2015,7 @@ void FListView::dragUp (int mouse_button)
void FListView::dragDown (int mouse_button)
{
if ( drag_scroll != fc::noScroll
&& scroll_distance < getClientHeight() )
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
if ( ! scroll_timer && current_iter.getPosition() <= int(getCount()) )
@ -2115,7 +2123,7 @@ inline void FListView::keyLeft (int& first_line_position_before)
//----------------------------------------------------------------------
inline void FListView::keyRight (int& first_line_position_before)
{
int xoffset_end = max_line_width - getClientWidth();
int xoffset_end = max_line_width - int(getClientWidth());
FListViewItem* item = getCurrentItem();
if ( tree_view && item->isExpandable() && ! item->isExpand() )
@ -2293,7 +2301,7 @@ void FListView::stepBackward (int distance)
//----------------------------------------------------------------------
void FListView::scrollToX (int x)
{
int xoffset_end = max_line_width - getClientWidth();
int xoffset_end = max_line_width - int(getClientWidth());
if ( xoffset == x )
return;
@ -2310,7 +2318,7 @@ void FListView::scrollToX (int x)
//----------------------------------------------------------------------
void FListView::scrollToY (int y)
{
int pagesize = getClientHeight() - 1;
int pagesize = int(getClientHeight()) - 1;
int element_count = int(getCount());
if ( first_visible_line.getPosition() == y )
@ -2369,14 +2377,14 @@ void FListView::cb_VBarChange (FWidget*, data_ptr)
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
distance = int(getClientHeight());
// fall through
case FScrollbar::scrollStepBackward:
stepBackward(distance);
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
distance = int(getClientHeight());
// fall through
case FScrollbar::scrollStepForward:
stepForward(distance);
@ -2429,14 +2437,14 @@ void FListView::cb_HBarChange (FWidget*, data_ptr)
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth();
distance = int(getClientWidth());
// fall through
case FScrollbar::scrollStepBackward:
scrollBy (-distance, 0);
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth();
distance = int(getClientWidth());
// fall through
case FScrollbar::scrollStepForward:
scrollBy (distance, 0);

View File

@ -43,7 +43,7 @@ FMenu::FMenu(FWidget* parent)
, opened_sub_menu(0)
, shown_sub_menu(0)
, max_item_width(0)
, hotkeypos(-1)
, hotkeypos(NOT_SET)
, mouse_down(false)
, has_checkable_items(false)
{
@ -58,7 +58,7 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
, opened_sub_menu(0)
, shown_sub_menu(0)
, max_item_width(0)
, hotkeypos(-1)
, hotkeypos(NOT_SET)
, mouse_down(false)
, has_checkable_items(false)
{
@ -495,7 +495,7 @@ void FMenu::calculateDimensions()
// find the maximum item width
while ( iter != last )
{
uInt item_width = (*iter)->getTextLength() + 2;
std::size_t item_width = (*iter)->getTextLength() + 2;
int accel_key = (*iter)->accel_key;
bool has_menu = (*iter)->hasMenu();
@ -505,7 +505,7 @@ void FMenu::calculateDimensions()
}
else if ( accel_key )
{
uInt accel_len = getKeyName(accel_key).getLength();
std::size_t accel_len = getKeyName(accel_key).getLength();
item_width += accel_len + 2;
}
@ -521,7 +521,7 @@ void FMenu::calculateDimensions()
adjust_X = adjustX(getX());
// set widget geometry
setGeometry (adjust_X, getY(), int(max_item_width + 2), int(getCount() + 2));
setGeometry (adjust_X, getY(), max_item_width + 2, getCount() + 2);
// set geometry of all items
iter = item_list.begin();
@ -530,7 +530,7 @@ void FMenu::calculateDimensions()
while ( iter != last )
{
(*iter)->setGeometry (item_X, item_Y, int(max_item_width), 1);
(*iter)->setGeometry (item_X, item_Y, max_item_width, 1);
if ( (*iter)->hasMenu() )
{
@ -579,9 +579,9 @@ void FMenu::adjustItems()
int FMenu::adjustX (int x_pos)
{
// Is menu outside on the right of the screen?
if ( x_pos + int(max_item_width) >= getDesktopWidth() - 1 )
if ( x_pos + int(max_item_width) >= int(getDesktopWidth() - 1) )
{
x_pos = getDesktopWidth() - int(max_item_width + 1);
x_pos = int(getDesktopWidth() - max_item_width + 1);
// Menu to large for the screen
if ( x_pos < 1 )
x_pos = 1;
@ -689,7 +689,7 @@ bool FMenu::mouseDownOverList (FPoint mouse_pos)
while ( iter != last )
{
int x1 = (*iter)->getX()
, x2 = (*iter)->getX() + (*iter)->getWidth()
, x2 = (*iter)->getX() + int((*iter)->getWidth())
, y = (*iter)->getY()
, mouse_x = mouse_pos.getX()
, mouse_y = mouse_pos.getY();
@ -780,7 +780,7 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
while ( iter != last )
{
int x1 = (*iter)->getX()
, x2 = (*iter)->getX() + (*iter)->getWidth()
, x2 = (*iter)->getX() + int((*iter)->getWidth())
, y = (*iter)->getY()
, mouse_x = mouse_pos.getX()
, mouse_y = mouse_pos.getY();
@ -840,7 +840,7 @@ void FMenu::mouseMoveOverList (FPoint mouse_pos, mouseStates& ms)
while ( iter != last )
{
int x1 = (*iter)->getX()
, x2 = (*iter)->getX() + (*iter)->getWidth()
, x2 = (*iter)->getX() + int((*iter)->getWidth())
, y = (*iter)->getY()
, mouse_x = mouse_pos.getX()
, mouse_y = mouse_pos.getY();
@ -1222,18 +1222,20 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
}
//----------------------------------------------------------------------
int FMenu::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
std::size_t FMenu::getHotkeyPos ( wchar_t src[]
, wchar_t dest[]
, std::size_t length )
{
// Find hotkey position in string
// + generate a new string without the '&'-sign
int pos = -1;
std::size_t pos = NOT_SET;
wchar_t* txt = src;
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
if ( i < length && txt[i] == L'&' && pos == -1 )
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
{
pos = int(i);
pos = i;
i++;
src++;
}
@ -1294,14 +1296,16 @@ inline void FMenu::drawSeparator (int y)
if ( isNewFont() )
{
print (fc::NF_border_line_vertical_right);
FString line(getWidth() - 2, wchar_t(fc::BoxDrawingsHorizontal));
FString line ( std::size_t(getWidth()) - 2
, wchar_t(fc::BoxDrawingsHorizontal) );
print (line);
print (fc::NF_rev_border_line_vertical_left);
}
else
{
print (fc::BoxDrawingsVerticalAndRight);
FString line(getWidth() - 2, wchar_t(fc::BoxDrawingsHorizontal));
FString line ( std::size_t(getWidth()) - 2
, wchar_t(fc::BoxDrawingsHorizontal));
print (line);
print (fc::BoxDrawingsVerticalAndLeft);
}
@ -1315,8 +1319,8 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
{
FString txt = menuitem->getText();
menuText txtdata;
uInt txt_length = uInt(txt.getLength());
int to_char = int(txt_length);
std::size_t txt_length = txt.getLength();
std::size_t to_char = txt_length;
int accel_key = menuitem->accel_key;
bool is_enabled = menuitem->isEnabled();
bool is_selected = menuitem->isSelected();
@ -1342,7 +1346,7 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
hotkeypos = getHotkeyPos(txt.wc_str(), txtdata.text, txt_length);
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
to_char--;
txtdata.length = to_char;
@ -1350,7 +1354,7 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
setCursorToHotkeyPosition (menuitem);
if ( ! is_enabled || is_selected )
txtdata.hotkeypos = -1;
txtdata.hotkeypos = NOT_SET;
else
txtdata.hotkeypos = hotkeypos;
@ -1421,7 +1425,7 @@ inline void FMenu::drawMenuText (menuText& data)
{
// Print menu text
for (int z = 0; z < data.length; z++)
for (std::size_t z = 0; z < data.length; z++)
{
if ( ! std::iswprint(wint_t(data.text[z])) )
{
@ -1454,10 +1458,10 @@ inline void FMenu::drawMenuText (menuText& data)
}
//----------------------------------------------------------------------
inline void FMenu::drawSubMenuIndicator (int& startpos)
inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
{
int c = ( has_checkable_items ) ? 1 : 0;
int len = int(max_item_width) - (startpos + c + 3);
std::size_t c = ( has_checkable_items ) ? 1 : 0;
std::size_t len = max_item_width - (startpos + c + 3);
if ( len > 0 )
{
@ -1465,33 +1469,34 @@ inline void FMenu::drawSubMenuIndicator (int& startpos)
print (FString(len, wchar_t(' ')));
// Print BlackRightPointingPointer ►
print (wchar_t(fc::BlackRightPointingPointer));
startpos = int(max_item_width) - (c + 2);
startpos = max_item_width - (c + 2);
}
}
//----------------------------------------------------------------------
inline void FMenu::drawAcceleratorKey (int& startpos, int accel_key)
inline void FMenu::drawAcceleratorKey (std::size_t& startpos, int accel_key)
{
FString accel_name (getKeyName(accel_key));
int c = ( has_checkable_items ) ? 1 : 0;
int accel_len = int(accel_name.getLength());
int len = int(max_item_width) - (startpos + accel_len + c + 2);
std::size_t c = ( has_checkable_items ) ? 1 : 0;
std::size_t accel_len = accel_name.getLength();
std::size_t len = max_item_width - (startpos + accel_len + c + 2);
if ( len > 0 )
{
// Print filling blank spaces + accelerator key name
FString spaces (len, wchar_t(' '));
print (spaces + accel_name);
startpos = int(max_item_width) - (c + 2);
startpos = max_item_width - (c + 2);
}
}
//----------------------------------------------------------------------
inline void FMenu::drawTrailingSpaces (int startpos)
inline void FMenu::drawTrailingSpaces (std::size_t startpos)
{
int c = ( has_checkable_items ) ? 1 : 0;
std::size_t c = ( has_checkable_items ) ? 1 : 0;
// Print trailing blank space
for (uInt i = uInt(startpos + c); i < max_item_width - 1; i++)
for (std::size_t i = startpos + c; i < max_item_width - 1; i++)
print (' ');
}
@ -1539,7 +1544,7 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
bool is_checkable = menuitem->checkable;
bool is_selected = menuitem->isSelected();
if ( hotkeypos == -1 )
if ( hotkeypos == NOT_SET )
{
// set cursor to the first character
if ( is_selected )
@ -1556,9 +1561,9 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
{
// set cursor to the hotkey position
if ( is_checkable )
menuitem->setCursorPos (3 + hotkeypos, 1);
menuitem->setCursorPos (3 + int(hotkeypos), 1);
else
menuitem->setCursorPos (2 + hotkeypos, 1);
menuitem->setCursorPos (2 + int(hotkeypos), 1);
}
}
}

View File

@ -64,32 +64,15 @@ void FMenuBar::resetMenu()
void FMenuBar::hide()
{
short fg, bg;
char* blank;
FWindow::hide();
fg = wc.term_fg;
bg = wc.term_bg;
setColor (fg, bg);
screenWidth = getDesktopWidth();
if ( screenWidth < 0 )
return;
try
{
blank = new char[uInt(screenWidth) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
std::memset(blank, ' ', uLong(screenWidth));
blank[screenWidth] = '\0';
char* blank = createBlankArray (screenWidth + 1);
setPrintPos (1, 1);
print (blank);
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
@ -256,7 +239,7 @@ void FMenuBar::cb_item_deactivated (FWidget* widget, data_ptr)
void FMenuBar::init()
{
FWidget* r = getRootWidget();
int w = r->getWidth();
std::size_t w = r->getWidth();
// initialize geometry values
setGeometry (1, 1, w, 1, false);
setAlwaysOnTop();
@ -285,11 +268,11 @@ void FMenuBar::calculateDimensions()
// find the maximum item width
while ( iter != last )
{
uInt len = (*iter)->getTextLength();
int item_width = int(len + 2);
std::size_t len = (*iter)->getTextLength();
int item_width = int(len) + 2;
// set item geometry
(*iter)->setGeometry (item_X, item_Y, item_width, 1, false);
(*iter)->setGeometry (item_X, item_Y, std::size_t(item_width), 1, false);
// set menu position
if ( (*iter)->hasMenu() )
@ -497,18 +480,20 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
}
//----------------------------------------------------------------------
int FMenuBar::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
std::size_t FMenuBar::getHotkeyPos ( wchar_t src[]
, wchar_t dest[]
, std::size_t length )
{
// find hotkey position in string
// + generate a new string without the '&'-sign
int hotkeypos = -1;
std::size_t hotkeypos = NOT_SET;
wchar_t* txt = src;
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
if ( i < length && txt[i] == L'&' && hotkeypos == -1 )
if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET )
{
hotkeypos = int(i);
hotkeypos = i;
i++;
src++;
}
@ -529,7 +514,7 @@ void FMenuBar::draw()
void FMenuBar::drawItems()
{
std::vector<FMenuItem*>::const_iterator iter, last;
int x = 1;
std::size_t x = 1;
if ( item_list.empty() )
return;
@ -558,13 +543,13 @@ void FMenuBar::drawItems()
}
//----------------------------------------------------------------------
inline void FMenuBar::drawItem (FMenuItem* menuitem, int& x)
inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
{
FString txt = menuitem->getText();
menuText txtdata;
uInt txt_length = txt.getLength();
int hotkeypos;
int to_char;
std::size_t txt_length = txt.getLength();
std::size_t to_char;
std::size_t hotkeypos;
bool is_enabled = menuitem->isEnabled();
bool is_selected = menuitem->isSelected();
@ -586,23 +571,23 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, int& x)
}
if ( x - 1 <= screenWidth )
to_char = int(txt_length);
to_char = txt_length;
else
to_char = int(txt_length) - (screenWidth - x - 1);
to_char = txt_length - screenWidth - x - 1;
hotkeypos = getHotkeyPos (txt.wc_str(), txtdata.text, txt_length);
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
{
txt_length--;
to_char--;
}
txtdata.length = to_char;
x += int(txt_length);
x += txt_length;
if ( ! is_enabled || is_selected )
txtdata.hotkeypos = -1;
txtdata.hotkeypos = NOT_SET;
else
txtdata.hotkeypos = hotkeypos;
@ -654,7 +639,7 @@ inline void FMenuBar::drawMenuText (menuText& data)
{
// Print menu text
for (int z = 0; z < data.length; z++)
for (std::size_t z = 0; z < data.length; z++)
{
if ( data.startpos > screenWidth - z )
break;
@ -689,27 +674,27 @@ inline void FMenuBar::drawMenuText (menuText& data)
}
//----------------------------------------------------------------------
inline void FMenuBar::drawEllipsis (menuText& txtdata, int x)
inline void FMenuBar::drawEllipsis (menuText& txtdata, std::size_t x)
{
if ( x > screenWidth + 1 )
{
if ( txtdata.startpos < screenWidth )
{
// Print ellipsis
setPrintPos (screenWidth - 1, 1);
setPrintPos (int(screenWidth) - 1, 1);
print ("..");
}
else if ( txtdata.startpos - 1 <= screenWidth )
{
// Hide first character from text
setPrintPos (screenWidth, 1);
setPrintPos (int(screenWidth), 1);
print (' ');
}
}
}
//----------------------------------------------------------------------
inline void FMenuBar::drawLeadingSpace (int& x)
inline void FMenuBar::drawLeadingSpace (std::size_t& x)
{
// Print a leading blank space
@ -721,7 +706,7 @@ inline void FMenuBar::drawLeadingSpace (int& x)
}
//----------------------------------------------------------------------
inline void FMenuBar::drawTrailingSpace (int& x)
inline void FMenuBar::drawTrailingSpace (std::size_t& x)
{
// Print a trailing blank space
@ -744,7 +729,7 @@ void FMenuBar::adjustItems()
while ( iter != last )
{
// get item width
int item_width = (*iter)->getWidth();
int item_width = int((*iter)->getWidth());
if ( (*iter)->hasMenu() )
{
@ -874,7 +859,7 @@ void FMenuBar::mouseDownOverList (FMouseEvent* ev)
{
int x1, x2;
x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth();
x2 = (*iter)->getX() + int((*iter)->getWidth());
if ( mouse_y == 1 )
{
@ -924,7 +909,7 @@ void FMenuBar::mouseUpOverList (FMouseEvent* ev)
{
int x1, x2;
x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth();
x2 = (*iter)->getX() + int((*iter)->getWidth());
if ( mouse_y == 1
&& mouse_x >= x1
@ -974,7 +959,7 @@ void FMenuBar::mouseMoveOverList (FMouseEvent* ev)
{
int x1, x2;
x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth();
x2 = (*iter)->getX() + int((*iter)->getWidth());
if ( mouse_x >= x1
&& mouse_x < x2

View File

@ -101,7 +101,7 @@ FMenuItem::~FMenuItem() // destructor
{
if ( super_menu && (isMenu(super_menu) || isMenuBar(super_menu)) )
{
FMenuList* menu_list = dynamic_cast<FMenuList*>(super_menu);
FMenuList* menu_list = getFMenuList(*super_menu);
if ( menu_list )
menu_list->remove(this);
@ -150,7 +150,7 @@ bool FMenuItem::setFocus (bool on)
{
if ( ! selected )
{
FMenuList* menu_list = dynamic_cast<FMenuList*>(getSuperMenu());
FMenuList* menu_list = getFMenuList(*getSuperMenu());
setSelected();
if ( menu_list )
@ -227,7 +227,7 @@ void FMenuItem::setText (const FString& txt)
if ( hotkey )
text_length--;
setWidth(int(text_length));
setWidth(text_length);
}
//----------------------------------------------------------------------
@ -559,6 +559,27 @@ bool FMenuItem::isMenu (FWidget* w) const
// private methods of FMenuItem
//----------------------------------------------------------------------
FMenuList* FMenuItem::getFMenuList (FWidget& widget)
{
FMenuList* menu_list;
if ( isMenu(&widget) )
{
FMenu* Menu = static_cast<FMenu*>(&widget);
menu_list = static_cast<FMenuList*>(Menu);
}
else if ( isMenuBar(&widget) )
{
FMenuBar* Menubar = static_cast<FMenuBar*>(&widget);
menu_list = static_cast<FMenuList*>(Menubar);
}
else
menu_list = 0;
return menu_list;
}
//----------------------------------------------------------------------
void FMenuItem::init (FWidget* parent)
{
@ -568,18 +589,17 @@ void FMenuItem::init (FWidget* parent)
if ( hotkey )
text_length--;
setGeometry (1, 1, int(text_length + 2), 1, false);
setGeometry (1, 1, text_length + 2, 1, false);
if ( ! parent )
return;
FMenuList* menu_list;
setSuperMenu (parent);
if ( accel_key )
addAccelerator (accel_key);
menu_list = dynamic_cast<FMenuList*>(parent);
FMenuList* menu_list = getFMenuList(*parent);
if ( menu_list )
menu_list->insert(this);
@ -609,14 +629,14 @@ void FMenuItem::init (FWidget* parent)
//----------------------------------------------------------------------
uChar FMenuItem::hotKey()
{
uInt length;
std::size_t length;
if ( text.isEmpty() )
return 0;
length = text.getLength();
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
try
{
@ -704,7 +724,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
}
//----------------------------------------------------------------------
template<class T>
template <typename T>
void FMenuItem::passMouseEvent ( T widget, FMouseEvent* ev
, fc::events ev_type )
{

View File

@ -159,9 +159,9 @@ void FMessageBox::setHeadline (const FString& headline)
setHeight(getHeight() + 2, true);
for (uInt n = 0; n < num_buttons; n++)
button[n]->setY (getHeight() - 4, false);
button[n]->setY (int(getHeight()) - 4, false);
uInt len = headline_text.getLength();
std::size_t len = headline_text.getLength();
if ( len > max_line_width )
max_line_width = len;
@ -172,13 +172,13 @@ void FMessageBox::setText (const FString& txt)
{
text = txt;
calculateDimensions();
button[0]->setY (getHeight() - 4, false);
button[0]->setY (int(getHeight()) - 4, false);
if ( button_digit[1] != 0 )
button[1]->setY (getHeight() - 4, false);
button[1]->setY (int(getHeight()) - 4, false);
if ( button_digit[2] != 0 )
button[2]->setY (getHeight() - 4, false);
button[2]->setY (int(getHeight()) - 4, false);
adjustButtons();
}
@ -279,10 +279,9 @@ int FMessageBox::error ( FWidget* parent
//----------------------------------------------------------------------
void FMessageBox::adjustSize()
{
int X
, Y
, max_width
, max_height;
int X, Y;
std::size_t max_width;
std::size_t max_height;
FWidget* root_widget = getRootWidget();
if ( root_widget )
@ -306,7 +305,7 @@ void FMessageBox::adjustSize()
//----------------------------------------------------------------------
void FMessageBox::cb_processClick (FWidget*, data_ptr data)
{
int* reply = static_cast<int*>(data);
FDialog::DialogCode* reply = static_cast<FDialog::DialogCode*>(data);
done (*reply);
}
@ -350,7 +349,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{
button[0] = new FButton (this);
button[0]->setText(button_text[button0]);
button[0]->setPos(3, getHeight() - 4, false);
button[0]->setPos(3, int(getHeight()) - 4, false);
button[0]->setWidth(1, false);
button[0]->setHeight(1, false);
button[0]->setFocus();
@ -359,7 +358,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{
button[1] = new FButton(this);
button[1]->setText(button_text[button1]);
button[1]->setPos(17, getHeight() - 4, false);
button[1]->setPos(17, int(getHeight()) - 4, false);
button[1]->setWidth(0, false);
button[1]->setHeight(1, false);
}
@ -368,7 +367,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{
button[2] = new FButton(this);
button[2]->setText(button_text[button2]);
button[2]->setPos(32, getHeight() - 4, false);
button[2]->setPos(32, int(getHeight()) - 4, false);
button[2]->setWidth(0, false);
button[2]->setHeight(1, false);
}
@ -424,8 +423,9 @@ inline void FMessageBox::initCallbacks()
//----------------------------------------------------------------------
void FMessageBox::calculateDimensions()
{
int x, y, w, h;
int headline_height = 0;
int x, y;
std::size_t w, h;
std::size_t headline_height = 0;
FWidget* parent_widget = getParentWidget();
text_split = text.split("\n");
text_num_lines = uInt(text_split.size());
@ -437,14 +437,14 @@ void FMessageBox::calculateDimensions()
for (uInt i = 0; i < text_num_lines; i++)
{
uInt len = text_components[i].getLength();
std::size_t len = text_components[i].getLength();
if ( len > max_line_width )
max_line_width = len;
}
h = int(text_num_lines) + 8 + headline_height;
w = int(max_line_width + 4);
h = text_num_lines + 8 + headline_height;
w = max_line_width + 4;
if ( w < 20 )
w = 20;
@ -468,7 +468,7 @@ void FMessageBox::draw()
int head_offset = 0;
int center_x = 0;
// center the whole block
int msg_x = int((getWidth() - int(max_line_width)) / 2);
int msg_x = int((getWidth() - max_line_width) / 2);
if ( isMonochron() )
setReverse(true);
@ -476,7 +476,7 @@ void FMessageBox::draw()
if ( ! headline_text.isNull() )
{
setColor(emphasis_color, getBackgroundColor());
uInt headline_length = headline_text.getLength();
std::size_t headline_length = headline_text.getLength();
if ( center_text ) // center one line
center_x = int((max_line_width - headline_length) / 2);
@ -490,7 +490,7 @@ void FMessageBox::draw()
for (int i = 0; i < int(text_num_lines); i++)
{
uInt line_length = text_components[i].getLength();
std::size_t line_length = text_components[i].getLength();
if ( center_text ) // center one line
center_x = int((max_line_width - line_length) / 2);
@ -506,9 +506,9 @@ void FMessageBox::draw()
//----------------------------------------------------------------------
void FMessageBox::resizeButtons()
{
uInt len[3], max_size;
std::size_t len[3], max_size;
for (uInt n = 0; n < num_buttons; n++)
for (std::size_t n = 0; n < num_buttons; n++)
{
len[n] = button[n]->getText().getLength();
@ -530,17 +530,17 @@ void FMessageBox::resizeButtons()
if ( max_size < 7 )
max_size = 7;
for (uInt n = 0; n < num_buttons; n++)
button[n]->setWidth(int(max_size + 3), false);
for (std::size_t n = 0; n < num_buttons; n++)
button[n]->setWidth(max_size + 3, false);
}
//----------------------------------------------------------------------
void FMessageBox::adjustButtons()
{
static const int gap = 4;
int btn_width = 0;
static const std::size_t gap = 4;
std::size_t btn_width = 0;
for (uInt n = 0; n < num_buttons; n++)
for (std::size_t n = 0; n < num_buttons; n++)
{
if ( n == num_buttons - 1 )
btn_width += button[n]->getWidth();
@ -550,7 +550,7 @@ void FMessageBox::adjustButtons()
if ( btn_width >= getWidth() - 4 )
{
int max_width;
std::size_t max_width;
FWidget* root_widget = getRootWidget();
setWidth(btn_width + 5);
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
@ -559,14 +559,14 @@ void FMessageBox::adjustButtons()
int btn_x = int((getWidth() - btn_width) / 2);
for (uInt n = 0; n < num_buttons; n++)
for (std::size_t n = 0; n < num_buttons; n++)
{
if ( n == 0 )
button[n]->setX(btn_x);
else
{
int btn_size = button[n]->getWidth();
button[n]->setX( btn_x + int(n) * (btn_size + gap) );
int btn_size = int(button[n]->getWidth());
button[n]->setX(btn_x + int(n) * (btn_size + int(gap)));
}
}
}

View File

@ -270,7 +270,7 @@ bool FMouseGPM::hasData()
}
//----------------------------------------------------------------------
void FMouseGPM::setRawData (char[], int)
void FMouseGPM::setRawData (FKeyboard::keybuffer&)
{ }
//----------------------------------------------------------------------
@ -490,12 +490,13 @@ bool FMouseX11::hasData()
}
//----------------------------------------------------------------------
void FMouseX11::setRawData (char fifo_buf[], int fifo_buf_size)
void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
{
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
static const int len = 6;
int n;
static const std::size_t len = 6;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t n;
x11_mouse[0] = fifo_buf[3];
x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5];
@ -691,14 +692,15 @@ bool FMouseSGR::hasData()
}
//----------------------------------------------------------------------
void FMouseSGR::setRawData (char fifo_buf[], int fifo_buf_size)
void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
{
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
int len = int(std::strlen(fifo_buf));
int n = 3;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t len = std::strlen(fifo_buf);
std::size_t n = 3;
while ( n < len && n < fifo_buf_size )
while ( n < len && n <= MOUSE_BUF_SIZE + 1 )
{
sgr_mouse[n - 3] = fifo_buf[n];
n++;
@ -944,14 +946,15 @@ bool FMouseUrxvt::hasData()
}
//----------------------------------------------------------------------
void FMouseUrxvt::setRawData (char fifo_buf[], int fifo_buf_size)
void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
{
// Import the X11 xterm mouse protocol (Urxvt-Mode) raw mouse data
int len = int(std::strlen(fifo_buf));
int n = 2;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t len = std::strlen(fifo_buf);
std::size_t n = 2;
while ( n < len && n < fifo_buf_size )
while ( n < len && n <= MOUSE_BUF_SIZE )
{
urxvt_mouse[n - 2] = fifo_buf[n];
n++;
@ -1487,13 +1490,11 @@ bool FMouseControl::isGpmMouseEnabled()
return false;
#ifdef F_HAVE_LIBGPM
FMouse* mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
return gpm_mouse->isGpmMouseEnabled();
#endif // F_HAVE_LIBGPM
return false;
@ -1537,13 +1538,12 @@ void FMouseControl::disable()
//----------------------------------------------------------------------
void FMouseControl::setRawData ( FMouse::mouse_type mt
, char fifo_buf[]
, int fifo_buf_size )
, FKeyboard::keybuffer& fifo_buf)
{
FMouse* mouse = mouse_protocol[mt];
if ( mouse )
mouse->setRawData (fifo_buf, fifo_buf_size);
mouse->setRawData (fifo_buf);
}
//----------------------------------------------------------------------

View File

@ -102,7 +102,7 @@ void FOptiMove::setTabStop (int t)
}
//----------------------------------------------------------------------
void FOptiMove::setTermSize (int w, int h)
void FOptiMove::setTermSize (std::size_t w, std::size_t h)
{
assert ( w > 0 );
assert ( h > 0 );
@ -493,10 +493,10 @@ void FOptiMove::set_clr_eol (char cap[])
void FOptiMove::check_boundaries ( int& xold, int& yold
, int& xnew, int& ynew )
{
if ( xold < 0 || xold >= screen_width )
if ( xold < 0 || xold >= int(screen_width) )
xold = -1;
if ( yold < 0 || yold >= screen_height )
if ( yold < 0 || yold >= int(screen_height) )
yold = -1;
if ( xnew < 0 )
@ -505,11 +505,11 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
if ( ynew < 0 )
ynew = 0;
if ( xnew >= screen_width )
xnew = screen_width - 1;
if ( xnew >= int(screen_width) )
xnew = int(screen_width) - 1;
if ( ynew >= screen_height )
ynew = screen_height - 1;
if ( ynew >= int(screen_height) )
ynew = int(screen_height) - 1;
}
//----------------------------------------------------------------------
@ -962,7 +962,7 @@ inline bool FOptiMove::isWideMove ( int xold, int yold
, int xnew, int ynew )
{
return bool ( xnew > MOVE_LIMIT
&& xnew < screen_width - 1 - MOVE_LIMIT
&& xnew < int(screen_width) - 1 - MOVE_LIMIT
&& std::abs(xnew - xold) + std::abs(ynew - yold)
> MOVE_LIMIT );
}
@ -1066,7 +1066,7 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
char null_result[BUF_SIZE];
char* null_ptr = null_result;
int new_time = relativeMove ( null_ptr
, 0, screen_height - 1
, 0, int(screen_height) - 1
, xnew, ynew );
if ( new_time < LONG_DURATION
@ -1094,7 +1094,7 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
char null_result[BUF_SIZE];
char* null_ptr = null_result;
int new_time = relativeMove ( null_ptr
, screen_width - 1, yold - 1
, int(screen_width) - 1, yold - 1
, xnew, ynew );
if ( new_time < LONG_DURATION
@ -1145,7 +1145,7 @@ void FOptiMove::moveByMethod ( int method
std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE - 1);
move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += F_cursor_to_ll.length;
relativeMove (move_ptr, 0, screen_height - 1, xnew, ynew);
relativeMove (move_ptr, 0, int(screen_height) - 1, xnew, ynew);
break;
case 5:
@ -1154,14 +1154,14 @@ void FOptiMove::moveByMethod ( int method
if ( xold >= 0 )
std::strncat ( move_ptr
, F_carriage_return.cap
, BUF_SIZE - std::strlen(move_ptr) );
, BUF_SIZE - std::strlen(move_ptr) - 1 );
std::strncat ( move_ptr
, F_cursor_left.cap
, BUF_SIZE - std::strlen(move_ptr) );
, BUF_SIZE - std::strlen(move_ptr) - 1);
move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += std::strlen(move_buf);
relativeMove (move_ptr, screen_width - 1, yold - 1, xnew, ynew);
relativeMove (move_ptr, int(screen_width) - 1, yold - 1, xnew, ynew);
break;
default:

View File

@ -33,7 +33,7 @@ namespace finalcut
//----------------------------------------------------------------------
FProgressbar::FProgressbar(FWidget* parent)
: FWidget(parent)
, percentage(-1)
, percentage(NOT_SET)
, bar_length(getWidth())
{
unsetFocusable();
@ -47,15 +47,14 @@ FProgressbar::~FProgressbar() // destructor
// public methods of FProgressbar
//----------------------------------------------------------------------
void FProgressbar::setPercentage (int percentage_value)
void FProgressbar::setPercentage (std::size_t percentage_value)
{
if ( percentage_value <= percentage )
return;
if ( percentage_value > 100 )
if ( percentage_value == NOT_SET )
percentage = NOT_SET;
else if ( percentage_value > 100 )
percentage = 100;
else if ( percentage_value < 0 )
percentage = 0;
else if ( percentage_value <= percentage && percentage != NOT_SET )
return;
else
percentage = percentage_value;
@ -69,7 +68,7 @@ void FProgressbar::setPercentage (int percentage_value)
}
//----------------------------------------------------------------------
void FProgressbar::setGeometry (int x, int y, int w, int h, bool adjust)
void FProgressbar::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Set the progress bar geometry
@ -99,9 +98,8 @@ bool FProgressbar::setShadow (bool on)
//----------------------------------------------------------------------
void FProgressbar::hide()
{
int s, size;
std::size_t s, size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
@ -121,37 +119,26 @@ void FProgressbar::hide()
s = hasShadow() ? 1 : 0;
size = getWidth() + s;
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getHeight() + s; y++)
for (std::size_t y = 0; y < getHeight() + s; y++)
{
setPrintPos (1, 1 + y);
setPrintPos (1, 1 + int(y));
print (blank);
}
delete[] blank;
setPrintPos (getWidth() - 4, 0);
destroyBlankArray (blank);
setPrintPos (int(getWidth()) - 4, 0);
print (" "); // hide percentage
}
//----------------------------------------------------------------------
void FProgressbar::reset()
{
percentage = -1;
percentage = NOT_SET;
if ( isVisible() )
{
@ -190,9 +177,9 @@ void FProgressbar::drawPercentage()
if ( isMonochron() )
setReverse(true);
setPrintPos (getWidth() - 3, 0);
setPrintPos (int(getWidth()) - 3, 0);
if ( percentage < 0 || percentage > 100 )
if ( percentage > 100 )
print ("--- %");
else
printf ("%3d %%", percentage);
@ -204,12 +191,17 @@ void FProgressbar::drawPercentage()
//----------------------------------------------------------------------
void FProgressbar::drawBar()
{
int i = 0;
double length = double(bar_length * percentage) / 100;
std::size_t i = 0;
double length;
setPrintPos (1,1);
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
if ( percentage == NOT_SET )
length = double(-0/100);
else
length = double(bar_length * percentage) / 100;
if ( isMonochron() )
setReverse(false);
@ -219,7 +211,7 @@ void FProgressbar::drawBar()
if ( isMonochron() )
setReverse(true);
if ( percentage > 0.0f && trunc(length) < bar_length )
if ( percentage > 0 && percentage <= 100 && trunc(length) < bar_length )
{
if ( round(length) > trunc(length) || getMaxColor() < 16 )
{

View File

@ -115,37 +115,40 @@ void FRect::setPos (const FPoint& p)
}
//----------------------------------------------------------------------
void FRect::setWidth (int w)
void FRect::setWidth (std::size_t w)
{
X2 = short(X1 + w - 1);
X2 = short(X1 + short(w) - 1);
}
//----------------------------------------------------------------------
void FRect::setHeight (int h)
void FRect::setHeight (std::size_t h)
{
Y2 = short(Y1 + h - 1);
Y2 = short(Y1 + short(h) - 1);
}
//----------------------------------------------------------------------
void FRect::setSize (int w, int h)
void FRect::setSize (std::size_t w, std::size_t h)
{
X2 = short(X1 + w - 1);
Y2 = short(Y1 + h - 1);
X2 = short(X1 + short(w) - 1);
Y2 = short(Y1 + short(h) - 1);
}
//----------------------------------------------------------------------
void FRect::setRect (const FRect& r)
{
setRect (r.X1, r.Y1, r.X2 - r.X1 + 1, r.Y2 - r.Y1 + 1);
setRect ( r.X1
, r.Y1
, std::size_t(r.X2 - r.X1 + 1)
, std::size_t(r.Y2 - r.Y1 + 1) );
}
//----------------------------------------------------------------------
void FRect::setRect (int x, int y, int width, int height)
void FRect::setRect (int x, int y, std::size_t width, std::size_t height)
{
X1 = short(x);
Y1 = short(y);
X2 = short(x + width - 1);
Y2 = short(y + height - 1);
X2 = short(x + int(width) - 1);
Y2 = short(y + int(height) - 1);
}
//----------------------------------------------------------------------
@ -248,8 +251,8 @@ FRect operator + (const FRect& r, const FPoint& p)
{
return FRect ( r.X1
, r.Y1
, r.X2 - r.X1 + 1 + p.getX()
, r.Y2 - r.Y1 + 1 + p.getY() );
, std::size_t(r.X2 - r.X1 + 1 + p.getX())
, std::size_t(r.Y2 - r.Y1 + 1 + p.getY()) );
}
//----------------------------------------------------------------------
@ -257,8 +260,8 @@ FRect operator - (const FRect& r, const FPoint& p)
{
return FRect ( r.X1
, r.Y1
, r.X2 - r.X1 + 1 - p.getX()
, r.Y2 - r.Y1 + 1 - p.getY() );
, std::size_t(r.X2 - r.X1 + 1 - p.getX())
, std::size_t(r.Y2 - r.Y1 + 1 - p.getY()) );
}
//----------------------------------------------------------------------

View File

@ -152,7 +152,7 @@ void FScrollbar::setPageSize (int document_size, int page_size)
//----------------------------------------------------------------------
void FScrollbar::setOrientation (int o)
{
int nf = 0;
std::size_t nf = 0;
length = ( getHeight() > getWidth() ) ? getHeight() : getWidth();
if ( o == fc::vertical && bar_orientation == fc::horizontal )
@ -174,13 +174,13 @@ void FScrollbar::setOrientation (int o)
}
//----------------------------------------------------------------------
void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust)
void FScrollbar::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Set the scrollbar geometry
FWidget::setGeometry (x, y, w, h, adjust);
int nf = 0;
std::size_t nf = 0;
length = ( h > w ) ? h : w;
if ( bar_orientation == fc::vertical )
@ -223,7 +223,7 @@ void FScrollbar::calculateSliderValues()
else
bar_length = length - 2;
slider_length = int(double(bar_length) / steps);
slider_length = std::size_t(double(bar_length) / steps);
if ( slider_length < 1 )
slider_length = 1;
@ -238,17 +238,18 @@ void FScrollbar::calculateSliderValues()
if ( val == max )
{
slider_pos = bar_length - slider_length;
slider_pos = int(bar_length - slider_length);
return;
}
slider_pos = int( round ( double((bar_length - slider_length) * val)
std::size_t v = std::size_t(val);
slider_pos = int( round ( double((bar_length - slider_length) * v)
/ double(max - min) ) );
if ( slider_pos < 0 )
slider_pos = 0;
else if ( slider_pos > bar_length - slider_length )
slider_pos = bar_length - slider_length;
else if ( slider_pos > int(bar_length - slider_length) )
slider_pos = int(bar_length - slider_length);
}
//----------------------------------------------------------------------
@ -280,7 +281,7 @@ void FScrollbar::drawVerticalBar()
if ( isMonochron() )
setReverse(false);
for (z = 1; z <= slider_length; z++)
for (z = 1; z <= int(slider_length); z++)
{
setPrintPos (1, 1 + slider_pos + z);
@ -295,7 +296,7 @@ void FScrollbar::drawVerticalBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z = slider_pos + slider_length + 1; z <= bar_length; z++)
for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
{
setPrintPos (1, 1 + z);
@ -343,16 +344,16 @@ void FScrollbar::drawHorizontalBar()
if ( isMonochron() )
setReverse(false);
for (z = 0; z < slider_length; z++)
for (z = 0; z < int(slider_length); z++)
print (' ');
if ( isMonochron() )
setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
z = slider_pos + slider_length + 1;
z = slider_pos + int(slider_length) + 1;
for (; z <= bar_length; z++)
for (; z <= int(bar_length); z++)
{
if ( isNewFont() && max_color > 8 )
print (fc::NF_border_line_upper); // ¯
@ -500,8 +501,8 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
}
}
if ( mouse_x < 1 || mouse_x > getWidth()
|| mouse_y < 1 || mouse_y > getHeight() )
if ( mouse_x < 1 || mouse_x > int(getWidth())
|| mouse_y < 1 || mouse_y > int(getHeight()) )
{
delOwnTimer();
}
@ -554,7 +555,7 @@ void FScrollbar::onTimer (FTimerEvent*)
|| ( scroll_type == FScrollbar::scrollPageForward
&& slider_pos == slider_click_stop_pos ) )
{
int max_slider_pos = bar_length - slider_length;
int max_slider_pos = int(bar_length - slider_length);
if ( scroll_type == FScrollbar::scrollPageBackward
&& slider_pos == 0 )
@ -610,7 +611,7 @@ void FScrollbar::drawButtons()
{
print (fc::NF_rev_up_arrow1);
print (fc::NF_rev_up_arrow2);
setPrintPos (1, length);
setPrintPos (1, int(length));
print (fc::NF_rev_down_arrow1);
print (fc::NF_rev_down_arrow2);
}
@ -618,7 +619,7 @@ void FScrollbar::drawButtons()
{
print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2);
setPrintPos (length - 1, 1);
setPrintPos (int(length) - 1, 1);
print (fc::NF_rev_right_arrow1);
print (fc::NF_rev_right_arrow2);
}
@ -633,13 +634,13 @@ void FScrollbar::drawButtons()
if ( bar_orientation == fc::vertical )
{
print (fc::BlackUpPointingTriangle); // ▲
setPrintPos (1, length);
setPrintPos (1, int(length));
print (fc::BlackDownPointingTriangle); // ▼
}
else // horizontal
{
print (fc::BlackLeftPointingPointer); // ◄
setPrintPos (length, 1);
setPrintPos (int(length), 1);
print (fc::BlackRightPointingPointer); // ►
}
@ -672,11 +673,11 @@ FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y)
{
return FScrollbar::scrollPageBackward; // before slider
}
else if ( y > slider_pos + slider_length + 1 && y < getHeight() )
else if ( y > slider_pos + int(slider_length) + 1 && y < int(getHeight()) )
{
return FScrollbar::scrollPageForward; // after slider
}
else if ( y == getHeight() )
else if ( y == int(getHeight()) )
{
return FScrollbar::scrollStepForward; // increment button
}
@ -697,11 +698,11 @@ FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x)
{
return FScrollbar::scrollPageBackward; // before slider
}
else if ( x > slider_pos + slider_length + 2 && x < getWidth() - 1 )
else if ( x > slider_pos + int(slider_length) + 2 && x < int(getWidth()) - 1 )
{
return FScrollbar::scrollPageForward; // after slider
}
else if ( x == getWidth() - 1 || x == getWidth() )
else if ( x == int(getWidth()) - 1 || x == int(getWidth()) )
{
return FScrollbar::scrollStepForward; // increment button
}
@ -718,11 +719,11 @@ FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x)
{
return FScrollbar::scrollPageBackward; // before slider
}
else if ( x > slider_pos + slider_length + 1 && x < getWidth() )
else if ( x > slider_pos + int(slider_length) + 1 && x < int(getWidth()) )
{
return FScrollbar::scrollPageForward; // after slider
}
else if ( x == getWidth() )
else if ( x == int(getWidth()) )
{
return FScrollbar::scrollStepForward; // increment button
}
@ -739,7 +740,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
if ( bar_orientation == fc::vertical )
{
if ( mouse_y > slider_pos + 1
&& mouse_y <= slider_pos + slider_length + 1 )
&& mouse_y <= slider_pos + int(slider_length) + 1 )
return mouse_y; // on slider
}
else // horizontal bar orientation
@ -747,13 +748,13 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
if ( isNewFont() )
{
if ( mouse_x > slider_pos + 2
&& mouse_x <= slider_pos + slider_length + 2 )
&& mouse_x <= slider_pos + int(slider_length) + 2 )
return mouse_x; // on slider
}
else
{
if ( mouse_x > slider_pos + 1
&& mouse_x <= slider_pos + slider_length + 1 )
&& mouse_x <= slider_pos + int(slider_length) + 1 )
return mouse_x; // on slider
}
}
@ -768,7 +769,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
if ( bar_orientation == fc::vertical )
{
if ( y >1 && y < getHeight() )
if ( y >1 && y < int(getHeight()) )
{
new_val = int( round ( double(max - min) * (y - 2.0 - (slider_length/2))
/ double(bar_length - slider_length) ) );
@ -780,7 +781,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
{
int nf = isNewFont() ? 1 : 0;
if ( x > 1 + nf && x < getWidth() - nf )
if ( x > 1 + nf && x < int(getWidth()) - nf )
{
new_val = int( round ( double(max - min) * (x - 2.0 - nf - (slider_length/2))
/ double(bar_length - slider_length) ) );

View File

@ -62,7 +62,7 @@ FScrollView::~FScrollView() // destructor
// public methods of FScrollView
//----------------------------------------------------------------------
void FScrollView::setScrollWidth (int width)
void FScrollView::setScrollWidth (std::size_t width)
{
if ( width < getViewportWidth() )
width = getViewportWidth();
@ -83,14 +83,14 @@ void FScrollView::setScrollWidth (int width)
child_print_area = viewport;
}
hbar->setMaximum (width - getViewportWidth());
hbar->setPageSize (width, getViewportWidth());
hbar->setMaximum (int(width - getViewportWidth()));
hbar->setPageSize (int(width), int(getViewportWidth()));
hbar->calculateSliderValues();
setHorizontalScrollBarVisibility();
}
//----------------------------------------------------------------------
void FScrollView::setScrollHeight (int height)
void FScrollView::setScrollHeight (std::size_t height)
{
if ( height < getViewportHeight() )
height = getViewportHeight();
@ -110,14 +110,14 @@ void FScrollView::setScrollHeight (int height)
child_print_area = viewport;
}
vbar->setMaximum (height - getViewportHeight());
vbar->setPageSize (height, getViewportHeight());
vbar->setMaximum (int(height - getViewportHeight()));
vbar->setPageSize (int(height), int(getViewportHeight()));
vbar->calculateSliderValues();
setVerticalScrollBarVisibility();
}
//----------------------------------------------------------------------
void FScrollView::setScrollSize (int width, int height)
void FScrollView::setScrollSize (std::size_t width, std::size_t height)
{
int xoffset_end
, yoffset_end;
@ -143,20 +143,20 @@ void FScrollView::setScrollSize (int width, int height)
child_print_area = viewport;
}
xoffset_end = getScrollWidth() - getViewportWidth();
yoffset_end = getScrollHeight() - getViewportHeight();
xoffset_end = int(getScrollWidth() - getViewportWidth());
yoffset_end = int(getScrollHeight() - getViewportHeight());
setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
setRightPadding (1 - (xoffset_end - getScrollX()) + int(nf_offset));
hbar->setMaximum (width - getViewportWidth());
hbar->setPageSize (width, getViewportWidth());
hbar->setMaximum (int(width - getViewportWidth()));
hbar->setPageSize (int(width), int(getViewportWidth()));
hbar->calculateSliderValues();
setHorizontalScrollBarVisibility();
vbar->setMaximum (height - getViewportHeight());
vbar->setPageSize (height, getViewportHeight());
vbar->setMaximum (int(height - getViewportHeight()));
vbar->setPageSize (int(height), int(getViewportHeight()));
vbar->calculateSliderValues();
setVerticalScrollBarVisibility();
}
@ -213,7 +213,7 @@ void FScrollView::setPos (int x, int y, bool adjust)
}
//----------------------------------------------------------------------
void FScrollView::setWidth (int w, bool adjust)
void FScrollView::setWidth (std::size_t w, bool adjust)
{
FWidget::setWidth (w, adjust);
viewport_geometry.setWidth(w - vertical_border_spacing - nf_offset);
@ -224,7 +224,7 @@ void FScrollView::setWidth (int w, bool adjust)
}
//----------------------------------------------------------------------
void FScrollView::setHeight (int h, bool adjust)
void FScrollView::setHeight (std::size_t h, bool adjust)
{
FWidget::setHeight (h, adjust);
viewport_geometry.setHeight(h - horizontal_border_spacing);
@ -235,7 +235,7 @@ void FScrollView::setHeight (int h, bool adjust)
}
//----------------------------------------------------------------------
void FScrollView::setSize (int w, int h, bool adjust)
void FScrollView::setSize (std::size_t w, std::size_t h, bool adjust)
{
FWidget::setSize (w, h, adjust);
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
@ -248,7 +248,9 @@ void FScrollView::setSize (int w, int h, bool adjust)
}
//----------------------------------------------------------------------
void FScrollView::setGeometry (int x, int y, int w, int h, bool adjust)
void FScrollView::setGeometry ( int x, int y
, std::size_t w, std::size_t h
, bool adjust )
{
// Set the scroll view geometry
@ -337,8 +339,8 @@ void FScrollView::scrollTo (int x, int y)
short yoffset_before = yoffset;
short xoffset_end = short(getScrollWidth() - getViewportWidth());
short yoffset_end = short(getScrollHeight() - getViewportHeight());
int save_width = viewport_geometry.getWidth();
int save_height = viewport_geometry.getHeight();
std::size_t save_width = viewport_geometry.getWidth();
std::size_t save_height = viewport_geometry.getHeight();
bool changeX = false;
bool changeY = false;
x--;
@ -372,7 +374,7 @@ void FScrollView::scrollTo (int x, int y)
{
viewport_geometry.setWidth(save_width);
setLeftPadding (1 - xoffset);
setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
setRightPadding (1 - (xoffset_end - xoffset) + short(nf_offset));
if ( update_scrollbar )
{
@ -421,7 +423,7 @@ void FScrollView::draw()
if ( border )
{
if ( isNewFont() )
drawBorder (1, 1, getWidth() - 1, getHeight());
drawBorder (1, 1, int(getWidth()) - 1, int(getHeight()));
else
drawBorder();
}
@ -463,12 +465,12 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_ppage:
scrollBy (0, -getViewportHeight());
scrollBy (0, int(-getViewportHeight()));
ev->accept();
break;
case fc::Fkey_npage:
scrollBy (0, getViewportHeight());
scrollBy (0, int(getViewportHeight()));
ev->accept();
break;
@ -558,12 +560,12 @@ void FScrollView::onChildFocusIn (FFocusEvent*)
, wy = widget_geometry.getY();
if ( wx > vx )
x = widget_geometry.getX2() - vp_geometry.getWidth() + 1;
x = widget_geometry.getX2() - int(vp_geometry.getWidth()) + 1;
else
x = wx;
if ( wy > vy )
y = widget_geometry.getY2() - vp_geometry.getHeight() + 1;
y = widget_geometry.getY2() - int(vp_geometry.getHeight()) + 1;
else
y = wy;
@ -622,10 +624,10 @@ FVTerm::term_area* FScrollView::getPrintArea()
void FScrollView::adjustSize()
{
FWidget::adjustSize();
int width = getWidth()
, height = getHeight()
, xoffset = viewport_geometry.getX()
, yoffset = viewport_geometry.getY();
std::size_t width = getWidth();
std::size_t height = getHeight();
int xoffset = viewport_geometry.getX();
int yoffset = viewport_geometry.getY();
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
, getTermY() + getTopPadding() - 1 );
@ -636,17 +638,17 @@ void FScrollView::adjustSize()
viewport->offset_top = scroll_geometry.getY();
}
hbar->setMaximum (getScrollWidth() - getViewportWidth());
hbar->setPageSize (getScrollWidth(), getViewportWidth());
hbar->setY (height);
hbar->setMaximum (int(getScrollWidth() - getViewportWidth()));
hbar->setPageSize (int(getScrollWidth()), int(getViewportWidth()));
hbar->setY (int(height));
hbar->setWidth (width - 2, false);
hbar->setValue (xoffset);
hbar->resize();
setHorizontalScrollBarVisibility();
vbar->setMaximum (getScrollHeight() - getViewportHeight());
vbar->setPageSize (getScrollHeight(), getViewportHeight());
vbar->setX (width);
vbar->setMaximum (int(getScrollHeight() - getViewportHeight()));
vbar->setPageSize (int(getScrollHeight()), int(getViewportHeight()));
vbar->setX (int(width));
vbar->setHeight (height - 2, false);
vbar->setValue (yoffset);
vbar->resize();
@ -671,8 +673,8 @@ void FScrollView::copy2area()
, ay = getTermY() - print_area->offset_top
, dx = viewport_geometry.getX()
, dy = viewport_geometry.getY()
, y_end = getViewportHeight()
, x_end = getViewportWidth();
, y_end = int(getViewportHeight())
, x_end = int(getViewportWidth());
// viewport width does not fit into the print_area
if ( print_area->width <= ax + x_end )
@ -737,8 +739,10 @@ void FScrollView::init (FWidget* parent)
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
init_scrollbar();
xoffset_end = getScrollWidth() - getViewportWidth();
yoffset_end = getScrollHeight() - getViewportHeight();
setGeometry (1, 1, 4, 4);
setMinimumSize (4, 4);
xoffset_end = int(getScrollWidth() - getViewportWidth());
yoffset_end = int(getScrollHeight() - getViewportHeight());
nf_offset = isNewFont() ? 1 : 0;
setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX());
@ -746,8 +750,8 @@ void FScrollView::init (FWidget* parent)
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
FPoint no_shadow(0,0);
int w = getViewportWidth();
int h = getViewportHeight();
std::size_t w = getViewportWidth();
std::size_t h = getViewportHeight();
if ( w < 1 )
w = 1;
@ -803,18 +807,18 @@ void FScrollView::init_scrollbar()
//----------------------------------------------------------------------
void FScrollView::calculateScrollbarPos()
{
int width = getWidth();
int height = getHeight();
std::size_t width = getWidth();
std::size_t height = getHeight();
if ( isNewFont() )
{
vbar->setGeometry (width, 2, 2, height - 2);
hbar->setGeometry (1, height, width - 2, 1);
vbar->setGeometry (int(width), 2, 2, height - 2);
hbar->setGeometry (1, int(height), width - 2, 1);
}
else
{
vbar->setGeometry (width, 2, 1, height - 2);
hbar->setGeometry (2, height, width - 2, 1);
vbar->setGeometry (int(width), 2, 1, height - 2);
hbar->setGeometry (2, int(height), width - 2, 1);
}
vbar->resize();

View File

@ -197,38 +197,22 @@ bool FStatusBar::hasActivatedKey()
void FStatusBar::hide()
{
short fg, bg;
char* blank;
FWindow::hide();
fg = wc.term_fg;
bg = wc.term_bg;
setColor (fg, bg);
screenWidth = getDesktopWidth();
if ( screenWidth < 0 )
return;
try
{
blank = new char[uInt(screenWidth) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
std::memset(blank, ' ', uLong(screenWidth));
blank[screenWidth] = '\0';
char* blank = createBlankArray(screenWidth + 1);
setPrintPos (1, 1);
print (blank);
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
void FStatusBar::drawMessage()
{
int termWidth, space_offset;
std::size_t termWidth;
int space_offset;
bool isLastActiveFocus, hasKeys;
if ( ! (isVisible() ) )
@ -260,7 +244,7 @@ void FStatusBar::drawMessage()
if ( isMonochron() )
setReverse(true);
if ( x + space_offset + 3 < termWidth )
if ( x + space_offset + 3 < int(termWidth) )
{
if ( text )
{
@ -277,21 +261,21 @@ void FStatusBar::drawMessage()
print (' ');
}
int msg_length = int(getMessage().getLength());
x += msg_length;
std::size_t msg_length = getMessage().getLength();
x += int(msg_length);
if ( x - 1 <= termWidth )
if ( x - 1 <= int(termWidth) )
print (getMessage());
else
{
// Print ellipsis
print ( getMessage().left(uInt(msg_length + termWidth - x - 1)) );
print ( getMessage().left(msg_length + termWidth - uInt(x) - 1) );
print ("..");
}
}
}
for (int i = x; i <= termWidth; i++)
for (int i = x; i <= int(termWidth); i++)
print (' ');
if ( isMonochron() )
@ -355,7 +339,7 @@ void FStatusBar::clear()
//----------------------------------------------------------------------
void FStatusBar::adjustSize()
{
setGeometry (1, getDesktopHeight(), getDesktopWidth(), 1, false);
setGeometry (1, int(getDesktopHeight()), getDesktopWidth(), 1, false);
}
//----------------------------------------------------------------------
@ -554,8 +538,8 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, data_ptr)
void FStatusBar::init()
{
FWidget* r = getRootWidget();
int w = r->getWidth();
int h = r->getHeight();
std::size_t w = r->getWidth();
int h = int(r->getHeight());
// initialize geometry values
setGeometry (1, h, w, 1, false);
setAlwaysOnTop();
@ -604,7 +588,7 @@ void FStatusBar::drawKeys()
{
keyname_len = int(getKeyName((*iter)->getKey()).getLength());
if ( x + keyname_len + 2 < screenWidth )
if ( x + keyname_len + 2 < int(screenWidth) )
{
if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() )
drawActiveKey (iter);
@ -615,7 +599,7 @@ void FStatusBar::drawKeys()
{
setColor (wc.statusbar_fg, wc.statusbar_bg);
for (; x <= screenWidth; x++)
for (; x <= int(screenWidth); x++)
print (' ');
}
@ -633,7 +617,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
{
// Draw not active key
int txt_length;
std::size_t txt_length;
FStatusKey* item = *iter;
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
@ -644,23 +628,23 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
setColor (wc.statusbar_fg, wc.statusbar_bg);
x++;
print ('-');
txt_length = int(item->getText().getLength());
x += txt_length;
txt_length = item->getText().getLength();
x += int(txt_length);
if ( x - 1 <= screenWidth )
if ( x - 1 <= int(screenWidth) )
print (item->getText());
else
{
// Print ellipsis
print ( item->getText()
.left(uInt(txt_length + screenWidth - x - 1)) );
.left(txt_length + screenWidth - std::size_t(x) - 1) );
print ("..");
}
if ( iter + 1 != key_list.end()
&& ( (*(iter + 1))->isActivated() || (*(iter + 1))->hasMouseFocus() )
&& x + int(getKeyName((*(iter + 1))->getKey()).getLength()) + 3
< screenWidth )
< int(screenWidth) )
{
// Next element is active
if ( isMonochron() )
@ -679,7 +663,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
if ( isMonochron() )
setReverse(true);
}
else if ( iter + 1 != key_list.end() && x < screenWidth )
else if ( iter + 1 != key_list.end() && x < int(screenWidth) )
{
// Not the last element
setColor (wc.statusbar_separator_fg, wc.statusbar_bg);
@ -693,7 +677,7 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
{
// Draw active key
int txt_length;
std::size_t txt_length;
FStatusKey* item = *iter;
if ( isMonochron() )
@ -708,10 +692,10 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++;
print ('-');
txt_length = int(item->getText().getLength());
x += txt_length;
txt_length = item->getText().getLength();
x += int(txt_length);
if ( x <= screenWidth )
if ( x <= int(screenWidth) )
{
print (item->getText());
x++;
@ -721,7 +705,7 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
{
// Print ellipsis
print ( item->getText()
.left(uInt(txt_length + screenWidth - x - 1)) );
.left(txt_length + screenWidth - std::size_t(x) - 1) );
print ("..");
}

View File

@ -53,13 +53,13 @@ FString::FString (int len)
, c_string(0)
{
if ( len > 0 )
initLength(uInt(len));
initLength(std::size_t(len));
else
initLength(0);
}
//----------------------------------------------------------------------
FString::FString (uInt len)
FString::FString (std::size_t len)
: string(0)
, length(0)
, bufsize(0)
@ -69,20 +69,7 @@ FString::FString (uInt len)
}
//----------------------------------------------------------------------
FString::FString (int len, wchar_t c)
: string(0)
, length(0)
, bufsize(0)
, c_string(0)
{
if ( len > 0 )
_assign ( FString(uInt(len), c).string );
else
initLength(0);
}
//----------------------------------------------------------------------
FString::FString (uInt len, wchar_t c)
FString::FString (std::size_t len, wchar_t c)
: string(0)
, length(0)
, bufsize(0)
@ -100,25 +87,7 @@ FString::FString (uInt len, wchar_t c)
}
//----------------------------------------------------------------------
FString::FString (int len, char c)
: string(0)
, length(0)
, bufsize(0)
, c_string(0)
{
string = 0;
length = 0;
bufsize = 0;
c_string = 0;
if ( len > 0 )
_assign ( FString(uInt(len), c).string );
else
initLength(0);
}
//----------------------------------------------------------------------
FString::FString (uInt len, char c)
FString::FString (std::size_t len, char c)
: string(0)
, length(0)
, bufsize(0)
@ -474,25 +443,6 @@ const FString& FString::operator >> (float& num)
return *this;
}
//----------------------------------------------------------------------
wchar_t& FString::operator [] (int pos)
{
if ( pos < 0 )
throw std::out_of_range(""); // Invalid index position
FString& s = *this;
return s[uInt(pos)];
}
//----------------------------------------------------------------------
wchar_t& FString::operator [] (uInt pos)
{
if ( pos >= length )
throw std::out_of_range(""); // Invalid index position
return string[pos];
}
//----------------------------------------------------------------------
const FString& FString::operator () ()
{
@ -502,9 +452,9 @@ const FString& FString::operator () ()
// public methods of FString
//----------------------------------------------------------------------
uInt FString::getUTF8length() const
std::size_t FString::getUTF8length() const
{
uInt len;
std::size_t len;
const char* s;
if ( ! string )
@ -514,7 +464,7 @@ uInt FString::getUTF8length() const
s = c_str();
while ( *s )
len += uInt((*s++ & 0xc0) != 0x80);
len += std::size_t((*s++ & 0xc0) != 0x80);
return len;
}
@ -902,16 +852,7 @@ FString FString::trim() const
}
//----------------------------------------------------------------------
FString FString::left (int len) const
{
if ( len > 0 )
return left (uInt(len));
else
return left (uInt(0));
}
//----------------------------------------------------------------------
FString FString::left (uInt len) const
FString FString::left (std::size_t len) const
{
wchar_t* p;
FString s(string);
@ -930,16 +871,7 @@ FString FString::left (uInt len) const
}
//----------------------------------------------------------------------
FString FString::right (int len) const
{
if ( len > 0 )
return right (uInt(len));
else
return right (uInt(0));
}
//----------------------------------------------------------------------
FString FString::right (uInt len) const
FString FString::right (std::size_t len) const
{
wchar_t* p;
FString s(string);
@ -957,21 +889,7 @@ FString FString::right (uInt len) const
}
//----------------------------------------------------------------------
FString FString::mid (int pos, int len) const
{
if ( pos > 0 )
{
if ( len > 0 )
return mid (uInt(pos), uInt(len));
else
return mid (uInt(pos), uInt(0));
}
else
return mid (uInt(0), uInt(0));
}
//----------------------------------------------------------------------
FString FString::mid (uInt pos, uInt len) const
FString FString::mid (std::size_t pos, std::size_t len) const
{
wchar_t* p;
wchar_t* first;
@ -1282,7 +1200,7 @@ const FString& FString::insert (const FString& s, int pos)
}
//----------------------------------------------------------------------
const FString& FString::insert (const FString& s, uInt pos)
const FString& FString::insert (const FString& s, std::size_t pos)
{
if ( pos > length )
throw std::out_of_range("");
@ -1295,7 +1213,7 @@ const FString& FString::insert (const FString& s, uInt pos)
FString FString::replace (const FString& from, const FString& to)
{
wchar_t* p;
uInt from_length, to_length, pos;
std::size_t from_length, to_length, pos;
FString s(string);
// handle NULL and empty string
@ -1380,10 +1298,11 @@ FString FString::expandTabs (int tabstop) const
tab_split = instr.split("\t");
last = tab_split.size();
for (uInt i = 0; i < last; i++)
for (std::size_t i = 0; i < last; i++)
{
uInt len = tab_split[i].getLength();
uInt tab_len = uInt(tabstop);
std::size_t len = tab_split[i].getLength();
std::size_t tab_len = std::size_t(tabstop);
if ( i == last - 1 )
outstr += tab_split[i];
else
@ -1471,11 +1390,11 @@ const FString& FString::overwrite (const FString& s, int pos)
if ( pos < 0 )
return overwrite (s, 0);
return overwrite (s, uInt(pos));
return overwrite (s, std::size_t(pos));
}
//----------------------------------------------------------------------
const FString& FString::overwrite (const FString& s, uInt pos)
const FString& FString::overwrite (const FString& s, std::size_t pos)
{
if ( pos > length )
pos = length;
@ -1494,16 +1413,7 @@ const FString& FString::overwrite (const FString& s, uInt pos)
}
//----------------------------------------------------------------------
const FString& FString::remove (int pos, uInt len)
{
if ( pos < 0 || len < 1 )
return *this;
return remove (uInt(pos), len);
}
//----------------------------------------------------------------------
const FString& FString::remove (uInt pos, uInt len)
const FString& FString::remove (std::size_t pos, std::size_t len)
{
if ( pos > length )
return *this;
@ -1531,7 +1441,7 @@ bool FString::includes (const FString& s) const
// private methods of FString
//----------------------------------------------------------------------
inline void FString::initLength (uInt len)
inline void FString::initLength (std::size_t len)
{
if ( len == 0 )
return;
@ -1588,7 +1498,7 @@ inline void FString::_assign (const wchar_t s[])
}
//----------------------------------------------------------------------
inline void FString::_insert (uInt len, const wchar_t s[])
inline void FString::_insert (std::size_t len, const wchar_t s[])
{
if ( len == 0 ) // String s is a null or a empty string
return;
@ -1614,7 +1524,9 @@ inline void FString::_insert (uInt len, const wchar_t s[])
}
//----------------------------------------------------------------------
inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
inline void FString::_insert ( std::size_t pos
, std::size_t len
, const wchar_t s[] )
{
if ( len == 0 ) // String s is a null or a empty string
return;
@ -1625,7 +1537,7 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
}
else
{
uInt x;
std::size_t x;
if ( (length + len + 1) <= bufsize )
{
@ -1654,7 +1566,7 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
return;
}
uInt y = 0;
std::size_t y = 0;
for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x];
@ -1673,12 +1585,12 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
}
//----------------------------------------------------------------------
inline void FString::_remove (uInt pos, uInt len)
inline void FString::_remove (std::size_t pos, std::size_t len)
{
if ( (bufsize - length - 1 + len) <= FWDBUFFER )
{
// shifting left side to pos
for (uInt i = pos; i + len < length + 1; i++)
for (std::size_t i = pos; i + len < length + 1; i++)
string[i] = string[i + len];
length -= len;
@ -1698,7 +1610,7 @@ inline void FString::_remove (uInt pos, uInt len)
return;
}
uInt x, y = 0;
std::size_t x, y = 0;
for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x];
@ -1750,7 +1662,7 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
try
{
c_string = new char[uInt(dest_size)]();
c_string = new char[std::size_t(dest_size)]();
// pre-initialiaze the whole string with '\0'
std::memset (c_string, '\0', std::size_t(dest_size));
@ -1761,7 +1673,7 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
return 0;
}
mblength = int(std::wcsrtombs (c_string, &src, uLong(dest_size), &state));
mblength = int(std::wcsrtombs (c_string, &src, std::size_t(dest_size), &state));
if ( mblength == -1 && errno != EILSEQ )
{
@ -1807,7 +1719,7 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
try
{
dest = new wchar_t[uInt(size)]();
dest = new wchar_t[std::size_t(size)]();
// pre-initialiaze the whole string with '\0'
std::wmemset (dest, L'\0', std::size_t(size));
}
@ -1817,7 +1729,7 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
return 0;
}
wclength = int(std::mbsrtowcs (dest, &src, uLong(dest_size), &state));
wclength = int(std::mbsrtowcs (dest, &src, std::size_t(dest_size), &state));
if ( wclength == -1 )
{

View File

@ -45,7 +45,7 @@ FSwitch::FSwitch (const FString& txt, FWidget* parent)
, switch_offset_pos(0)
, button_pressed(false)
{
switch_offset_pos = int(txt.getLength()) + 1;
switch_offset_pos = txt.getLength() + 1;
button_width = 11;
}
@ -59,7 +59,7 @@ FSwitch::~FSwitch() // destructor
void FSwitch::setText (const FString& txt)
{
FToggleButton::setText(txt);
switch_offset_pos = int(txt.getLength()) + 1;
switch_offset_pos = txt.getLength() + 1;
}
//----------------------------------------------------------------------
@ -131,7 +131,7 @@ void FSwitch::drawCheckButton()
if ( ! isVisible() )
return;
setPrintPos (1 + switch_offset_pos, 1);
setPrintPos (1 + int(switch_offset_pos), 1);
if ( checked )
drawChecked();
@ -185,7 +185,7 @@ void FSwitch::drawChecked()
if ( isMonochron() )
setReverse(false);
setCursorPos (3 + switch_offset_pos, 1);
setCursorPos (3 + int(switch_offset_pos), 1);
}
//----------------------------------------------------------------------
@ -232,7 +232,7 @@ void FSwitch::drawUnchecked()
if ( isMonochron() || getMaxColor() < 16 )
setBold(false);
setCursorPos (7 + switch_offset_pos, 1);
setCursorPos (7 + int(switch_offset_pos), 1);
}
} // namespace finalcut

View File

@ -53,13 +53,9 @@ FMouseControl* FTerm::mouse = 0;
#if defined(__linux__)
FTermLinux* FTerm::linux = 0;
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
FTermFreeBSD* FTerm::freebsd = 0;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
FTermOpenBSD* FTerm::openbsd = 0;
#endif
@ -86,7 +82,7 @@ FTerm::~FTerm() // destructor
// public methods of FTerm
//----------------------------------------------------------------------
int FTerm::getLineNumber()
std::size_t FTerm::getLineNumber()
{
FRect& term_geometry = data->getTermGeometry();
@ -97,7 +93,7 @@ int FTerm::getLineNumber()
}
//----------------------------------------------------------------------
int FTerm::getColumnNumber()
std::size_t FTerm::getColumnNumber()
{
FRect& term_geometry = data->getTermGeometry();
@ -170,15 +166,9 @@ bool FTerm::setVGAFont()
if ( data->isVGAFont() )
return data->isVGAFont();
if ( isGnomeTerminal()
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
if ( hasNoFontSettingOption() )
return false;
if ( isXTerminal() || isScreenTerm()
|| isUrxvtTerminal() || FTermcap::osc_support )
{
@ -219,12 +209,7 @@ bool FTerm::setNewFont()
if ( isNewFont() )
return true;
if ( isGnomeTerminal()
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
if ( hasNoFontSettingOption() )
return false;
if ( isXTerminal() || isScreenTerm()
@ -431,7 +416,7 @@ char* FTerm::enableCursor()
// Restore the last used Linux console cursor style
char* cstyle;
cstyle = linux->restoreCursorStyle();
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str));
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
}
#endif // defined(__linux__)
@ -489,10 +474,10 @@ void FTerm::detectTermSize()
term_geometry.setPos(1,1);
// Use COLUMNS or fallback to the xterm default width of 80 characters
str = std::getenv("COLUMNS");
term_geometry.setWidth(str ? std::atoi(str) : 80);
term_geometry.setWidth(str ? std::size_t(std::atoi(str)) : 80);
// Use LINES or fallback to the xterm default height of 24 characters
str = std::getenv("LINES");
term_geometry.setHeight(str ? std::atoi(str) : 24);
term_geometry.setHeight(str ? std::size_t(std::atoi(str)) : 24);
}
else
{
@ -507,7 +492,7 @@ void FTerm::detectTermSize()
}
//----------------------------------------------------------------------
void FTerm::setTermSize (int width, int height)
void FTerm::setTermSize (std::size_t width, std::size_t height)
{
// Set xterm size to {width} x {height}
@ -840,9 +825,7 @@ void FTerm::initScreenSettings()
linux->initCharMap (fc::character);
data->supportShadowCharacter (linux->hasShadowCharacter());
data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter());
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->initCharMap (fc::character);
#endif
@ -1091,269 +1074,32 @@ void FTerm::init_keyboard()
}
//----------------------------------------------------------------------
/* Terminal capability data base
* -----------------------------
* Info under: man 5 terminfo
*
* Importent shell commands:
* captoinfo - convert all termcap descriptions into terminfo descriptions
* infocmp - print out terminfo description from the current terminal
*/
void FTerm::init_termcap()
{
std::vector<std::string> terminals;
std::vector<std::string>::iterator iter;
static const int success = 1;
static const int uninitialized = -2;
static char term_buffer[2048];
static char string_buf[2048];
char* buffer = string_buf;
int status = uninitialized;
bool color256 = term_detection->canDisplay256Colors();
// Initialize the terminal capabilities
FTermcap termcap;
termcap.setTermData(data);
termcap.setFTermDetection(term_detection);
termcap.init();
// Share the terminal capabilities
tcap = FTermcap::getTermcapMap();
// Open termcap file
const char* termtype = data->getTermType();
terminals.push_back(termtype); // available terminal type
if ( color256 ) // 1st fallback if not found
terminals.push_back("xterm-256color");
terminals.push_back("xterm"); // 2nd fallback if not found
terminals.push_back("ansi"); // 3rd fallback if not found
terminals.push_back("vt100"); // 4th fallback if not found
iter = terminals.begin();
while ( iter != terminals.end() )
{
data->setTermType(iter->c_str());
// Open the termcap file + load entry for termtype
status = tgetent(term_buffer, termtype);
if ( status == success || ! term_detection->hasTerminalDetection() )
break;
++iter;
}
if ( std::strncmp(termtype, "ansi", 4) == 0 )
term_detection->setAnsiTerminal (true);
init_termcap_error (status);
init_termcap_variables (buffer);
tcap = termcap.getTermcapMap();
}
//----------------------------------------------------------------------
void FTerm::init_termcap_error (int status)
void FTerm::init_quirks()
{
static const int no_entry = 0;
static const int db_not_found = -1;
static const int uninitialized = -2;
// Initialize terminal quirks
if ( status == no_entry || status == uninitialized )
{
const char* termtype = data->getTermType();
std::cerr << "Unknown terminal: " << termtype << "\n"
<< "Check the TERM environment variable\n"
<< "Also make sure that the terminal\n"
<< "is defined in the termcap/terminfo database.\n";
std::abort();
}
else if ( status == db_not_found )
{
std::cerr << "The termcap/terminfo database could not be found.\n";
std::abort();
}
}
//----------------------------------------------------------------------
void FTerm::init_termcap_variables (char*& buffer)
{
// Get termcap booleans
init_termcap_booleans();
// Get termcap numerics
init_termcap_numerics();
// Get termcap strings
init_termcap_strings(buffer);
// Terminal quirks
FTermcapQuirks quirks;
quirks.setTermData (data);
quirks.setFTermDetection (term_detection);
quirks.terminalFixup(); // Fix terminal quirks
// Get termcap keys
init_termcap_keys(buffer);
// Initialize cursor movement optimization
init_OptiMove();
// Initialize video attributes optimization
init_OptiAttr();
}
//----------------------------------------------------------------------
void FTerm::init_termcap_booleans()
{
// Get termcap booleans
// Screen erased with the background color
FTermcap::background_color_erase = tgetflag(C_STR("ut"));
// t_cursor_left wraps from column 0 to last column
FTermcap::automatic_left_margin = tgetflag(C_STR("bw"));
// Terminal has auto-matic margins
FTermcap::automatic_right_margin = tgetflag(C_STR("am"));
// NewLine ignored after 80 cols
FTermcap::eat_nl_glitch = tgetflag(C_STR("xn"));
// Terminal supports ANSI set default fg and bg color
FTermcap::ansi_default_color = tgetflag(C_STR("AX"));
// Terminal supports operating system commands (OSC)
// OSC = Esc + ']'
FTermcap::osc_support = tgetflag(C_STR("XT"));
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
FTermcap::no_utf8_acs_chars = bool(tgetnum(C_STR("U8")) != 0);
}
//----------------------------------------------------------------------
void FTerm::init_termcap_numerics()
{
// Get termcap numeric
// Maximum number of colors on screen
FTermcap::max_color = std::max( FTermcap::max_color
, tgetnum(C_STR("Co")) );
if ( getMaxColor() < 0 )
FTermcap::max_color = 1;
if ( getMaxColor() < 8 )
data->setMonochron(true);
else
data->setMonochron(false);
// Get initial spacing for hardware tab stop
FTermcap::tabstop = tgetnum(C_STR("it"));
// Get video attributes that cannot be used with colors
FTermcap::attr_without_color = tgetnum(C_STR("NC"));
}
//----------------------------------------------------------------------
void FTerm::init_termcap_strings (char*& buffer)
{
// Get termcap strings
// Read termcap output strings
for (int i = 0; tcap[i].tname[0] != 0; i++)
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
}
//----------------------------------------------------------------------
void FTerm::init_termcap_keys_vt100 (char*& buffer)
{
// Some terminals (e.g. PuTTY) send vt100 key codes for
// the arrow and function keys.
char* key_up_string = tgetstr(C_STR("ku"), &buffer);
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|| ( TCAP(fc::t_cursor_up)
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
{
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
{
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
}
}
}
//----------------------------------------------------------------------
void FTerm::init_termcap_keys (char*& buffer)
{
// Read termcap key strings
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
{
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
// Fallback for rxvt with TERM=xterm
if ( std::strncmp(fc::Fkey[i].tname, "khx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "7~"); // Home key
if ( std::strncmp(fc::Fkey[i].tname, "@7x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "8~"); // End key
if ( std::strncmp(fc::Fkey[i].tname, "k1x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "11~"); // F1
if ( std::strncmp(fc::Fkey[i].tname, "k2x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "12~"); // F2
if ( std::strncmp(fc::Fkey[i].tname, "k3x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "13~"); // F3
if ( std::strncmp(fc::Fkey[i].tname, "k4x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "14~"); // F4
// Fallback for TERM=ansi
if ( std::strncmp(fc::Fkey[i].tname, "@7X", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "K"); // End key
// Keypad keys
if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OM"); // Enter key
if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Oo"); // Keypad slash
if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk
if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign
if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
}
// VT100 key codes for the arrow and function keys
init_termcap_keys_vt100(buffer);
}
//----------------------------------------------------------------------
void FTerm::init_OptiMove()
void FTerm::init_optiMove()
{
// Duration precalculation of the cursor movement strings
@ -1388,7 +1134,7 @@ void FTerm::init_OptiMove()
}
//----------------------------------------------------------------------
void FTerm::init_OptiAttr()
void FTerm::init_optiAttr()
{
// Setting video attribute optimization
@ -1661,10 +1407,22 @@ void FTerm::init_captureFontAndTitle()
}
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
inline bool FTerm::hasNoFontSettingOption()
{
// Redefine the color palette
if ( isGnomeTerminal()
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
return true;
return false;
}
//----------------------------------------------------------------------
inline bool FTerm::canChangeColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
@ -1673,6 +1431,17 @@ void FTerm::redefineColorPalette()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
{
// Redefine the color palette
if ( ! canChangeColorPalette() )
return;
resetColorMap();
@ -1687,14 +1456,7 @@ void FTerm::redefineColorPalette()
//----------------------------------------------------------------------
void FTerm::restoreColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
if ( ! canChangeColorPalette() )
return;
// Reset screen settings
@ -1719,9 +1481,7 @@ void FTerm::setInsertCursorStyle()
, data->isCursorHidden() );
putstring (cstyle);
std::fflush(stdout);
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->setCursorStyle ( fc::destructive_cursor
, data->isCursorHidden() );
#endif
@ -1742,9 +1502,7 @@ void FTerm::setOverwriteCursorStyle()
, data->isCursorHidden() );
putstring (cstyle);
std::fflush(stdout);
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->setCursorStyle ( fc::normal_cursor
, data->isCursorHidden() );
#endif
@ -1756,6 +1514,11 @@ void FTerm::setOverwriteCursorStyle()
//----------------------------------------------------------------------
void FTerm::enableMouse()
{
// Enable the terminal mouse support
if ( ! init_values.mouse_support )
return;
bool gpm_mouse = false;
bool xterm_mouse = false;
@ -1783,12 +1546,68 @@ void FTerm::enableMouse()
}
//----------------------------------------------------------------------
void FTerm::disableMouse()
inline void FTerm::disableMouse()
{
// Disable the terminal mouse support
keyboard->disableMouseSequences();
mouse->disable();
}
//----------------------------------------------------------------------
inline void FTerm::enableKeypad()
{
// Enter 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_xmit) )
{
putstring (TCAP(fc::t_keypad_xmit));
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
inline void FTerm::disableKeypad()
{
// Leave 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_local) )
{
putstring (TCAP(fc::t_keypad_local));
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
inline void FTerm::enableAlternateCharset()
{
// Enable alternate charset
if ( TCAP(fc::t_enable_acs) )
{
putstring (TCAP(fc::t_enable_acs));
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
inline void FTerm::enableApplicationEscKey()
{
// switch to application escape key mode
if ( isMinttyTerm() )
FTerm::putstring (CSI "?7727h");
}
//----------------------------------------------------------------------
inline void FTerm::disableApplicationEscKey()
{
// Switch to normal escape key mode
if ( isMinttyTerm() )
putstring (CSI "?7727l");
}
//----------------------------------------------------------------------
void FTerm::useAlternateScreenBuffer()
{
@ -1846,13 +1665,9 @@ inline void FTerm::allocationValues()
#if defined(__linux__)
linux = new FTermLinux();
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd = new FTermFreeBSD();
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
openbsd = new FTermOpenBSD();
#endif
}
@ -1870,14 +1685,10 @@ inline void FTerm::deallocationValues()
#if defined(__NetBSD__) || defined(__OpenBSD__)
if ( openbsd )
delete openbsd;
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
if ( freebsd )
delete freebsd;
#endif
#if defined(__linux__)
#elif defined(__linux__)
if ( linux )
delete linux;
#endif
@ -1907,7 +1718,6 @@ inline void FTerm::deallocationValues()
//----------------------------------------------------------------------
void FTerm::init (bool disable_alt_screen)
{
int stdout_no = FTermios::getStdOut();
init_term_object = this;
// Initialize global values for all objects
@ -1927,11 +1737,7 @@ void FTerm::init (bool disable_alt_screen)
FTermios::storeTTYsettings();
// Get output baud rate
uInt baud = FTermios::getBaudRate();
data->setBaudrate(baud);
if ( isatty(stdout_no) )
opti_move->setBaudRate(int(baud));
initBaudRate();
// Terminal detection
term_detection->setTermData(data);
@ -1943,6 +1749,17 @@ void FTerm::init (bool disable_alt_screen)
// Initializes variables for the current terminal
init_termcap();
// Initialize terminal quirks
init_quirks();
// Initialize cursor movement optimization
init_optiMove();
// Initialize video attributes optimization
init_optiAttr();
// Initialize vt100 alternate character set
init_alt_charset();
// Pass the terminal capabilities to the keyboard object
@ -1958,7 +1775,6 @@ void FTerm::init (bool disable_alt_screen)
init_keyboard();
// Enable the terminal mouse support
if ( init_values.mouse_support )
enableMouse();
// Activate meta key sends escape
@ -1966,24 +1782,15 @@ void FTerm::init (bool disable_alt_screen)
xterm->metaSendsESC(true);
// switch to application escape key mode
if ( isMinttyTerm() )
FTerm::putstring (CSI "?7727h");
enableApplicationEscKey();
// Enter 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_xmit) )
{
putstring (TCAP(fc::t_keypad_xmit));
std::fflush(stdout);
}
enableKeypad();
useAlternateScreenBuffer();
// Enable alternate charset
if ( TCAP(fc::t_enable_acs) )
{
putstring (TCAP(fc::t_enable_acs));
std::fflush(stdout);
}
enableAlternateCharset();
// Save the used xterm font and window title
init_captureFontAndTitle();
@ -2043,9 +1850,7 @@ void FTerm::initOSspecifics()
freebsd->disableChangeCursorStyle();
freebsd->init(); // Initialize BSD console
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
if ( init_values.meta_sends_escape )
openbsd->enableMetaSendsEscape();
else
@ -2068,6 +1873,17 @@ void FTerm::initTermspecifics()
init_teraterm_charmap();
}
//----------------------------------------------------------------------
void FTerm::initBaudRate()
{
int stdout_no = FTermios::getStdOut();
uInt baud = FTermios::getBaudRate();
data->setBaudrate(baud);
if ( isatty(stdout_no) )
opti_move->setBaudRate(int(baud));
}
//----------------------------------------------------------------------
void FTerm::finish()
{
@ -2106,12 +1922,8 @@ void FTerm::finish()
if ( init_values.color_change )
restoreColorPalette();
if ( isMinttyTerm() )
{
// Switch to normal escape key mode
putstring (CSI "?7727l");
std::fflush(stdout);
}
disableApplicationEscKey();
finishOSspecifics1();
@ -2131,11 +1943,7 @@ void FTerm::finish()
useNormalScreenBuffer();
// leave 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_local) )
{
putstring (TCAP(fc::t_keypad_local));
std::fflush(stdout);
}
disableKeypad();
finish_encoding();
@ -2150,13 +1958,9 @@ void FTerm::finishOSspecifics1()
{
#if defined(__linux__)
linux->finish();
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->finish();
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
openbsd->finish();
#endif
}

View File

@ -27,6 +27,7 @@ namespace finalcut
// static class attributes
bool FTermcap::background_color_erase = false;
bool FTermcap::can_change_color_palette = false;
bool FTermcap::automatic_left_margin = false;
bool FTermcap::automatic_right_margin = false;
bool FTermcap::eat_nl_glitch = false;
@ -36,6 +37,8 @@ bool FTermcap::no_utf8_acs_chars = false;
int FTermcap::max_color = 1;
int FTermcap::tabstop = 8;
int FTermcap::attr_without_color = 0;
FTermData* FTermcap::fterm_data = 0;
FTermDetection* FTermcap::term_detection = 0;
//----------------------------------------------------------------------
@ -51,6 +54,283 @@ FTermcap::FTermcap()
FTermcap::~FTermcap() // destructor
{ }
/* Terminal capability data base
* -----------------------------
* Info under: man 5 terminfo
*
* Importent shell commands:
* captoinfo - convert all termcap descriptions into terminfo descriptions
* infocmp - print out terminfo description from the current terminal
*/
// public methods of FTermcap
//----------------------------------------------------------------------
void FTermcap::setTermData (FTermData* data)
{
fterm_data = data;
}
//----------------------------------------------------------------------
void FTermcap::setFTermDetection (FTermDetection* td)
{
term_detection = td;
}
//----------------------------------------------------------------------
void FTermcap::init()
{
termcap();
}
// private methods of FTermcap
//----------------------------------------------------------------------
void FTermcap::termcap()
{
std::vector<std::string> terminals;
std::vector<std::string>::iterator iter;
static const int success = 1;
static const int uninitialized = -2;
static char term_buffer[2048];
static char string_buf[2048];
char* buffer = string_buf;
int status = uninitialized;
bool color256 = term_detection->canDisplay256Colors();
// Open termcap file
#if defined(__sun) && defined(__SVR4)
char* termtype = fterm_data->getTermType();
#else
const char* termtype = fterm_data->getTermType();
#endif
terminals.push_back(termtype); // available terminal type
if ( color256 ) // 1st fallback if not found
terminals.push_back("xterm-256color");
terminals.push_back("xterm"); // 2nd fallback if not found
terminals.push_back("ansi"); // 3rd fallback if not found
terminals.push_back("vt100"); // 4th fallback if not found
iter = terminals.begin();
while ( iter != terminals.end() )
{
fterm_data->setTermType(iter->c_str());
// Open the termcap file + load entry for termtype
status = tgetent(term_buffer, termtype);
if ( status == success || ! term_detection->hasTerminalDetection() )
break;
++iter;
}
if ( std::strncmp(termtype, "ansi", 4) == 0 )
term_detection->setAnsiTerminal (true);
termcapError (status);
termcapVariables (buffer);
}
//----------------------------------------------------------------------
void FTermcap::termcapError (int status)
{
static const int no_entry = 0;
static const int db_not_found = -1;
static const int uninitialized = -2;
if ( status == no_entry || status == uninitialized )
{
const char* termtype = fterm_data->getTermType();
std::cerr << "Unknown terminal: " << termtype << "\n"
<< "Check the TERM environment variable\n"
<< "Also make sure that the terminal\n"
<< "is defined in the termcap/terminfo database.\n";
std::abort();
}
else if ( status == db_not_found )
{
std::cerr << "The termcap/terminfo database could not be found.\n";
std::abort();
}
}
//----------------------------------------------------------------------
void FTermcap::termcapVariables (char*& buffer)
{
// Get termcap booleans
termcapBoleans();
// Get termcap numerics
termcapNumerics();
// Get termcap strings
termcapStrings (buffer);
// Get termcap keys
termcapKeys (buffer);
}
//----------------------------------------------------------------------
void FTermcap::termcapBoleans()
{
// Get termcap booleans
// Screen erased with the background color
background_color_erase = tgetflag(C_STR("ut"));
// Terminal is able to redefine existing colors
can_change_color_palette = tgetflag(C_STR("cc"));
// t_cursor_left wraps from column 0 to last column
automatic_left_margin = tgetflag(C_STR("bw"));
// Terminal has auto-matic margins
automatic_right_margin = tgetflag(C_STR("am"));
// NewLine ignored after 80 cols
eat_nl_glitch = tgetflag(C_STR("xn"));
// Terminal supports ANSI set default fg and bg color
ansi_default_color = tgetflag(C_STR("AX"));
// Terminal supports operating system commands (OSC)
// OSC = Esc + ']'
osc_support = tgetflag(C_STR("XT"));
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
no_utf8_acs_chars = bool(tgetnum(C_STR("U8")) != 0);
}
//----------------------------------------------------------------------
void FTermcap::termcapNumerics()
{
// Get termcap numeric
// Maximum number of colors on screen
max_color = std::max(max_color, tgetnum(C_STR("Co")));
if ( max_color < 0 )
max_color = 1;
if ( max_color < 8 )
fterm_data->setMonochron(true);
else
fterm_data->setMonochron(false);
// Get initial spacing for hardware tab stop
tabstop = tgetnum(C_STR("it"));
// Get video attributes that cannot be used with colors
attr_without_color = tgetnum(C_STR("NC"));
}
//----------------------------------------------------------------------
void FTermcap::termcapStrings (char*& buffer)
{
// Get termcap strings
// Read termcap output strings
for (int i = 0; tcap[i].tname[0] != 0; i++)
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
}
//----------------------------------------------------------------------
void FTermcap::termcapKeys (char*& buffer)
{
// Read termcap key strings
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
{
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
// Fallback for rxvt with TERM=xterm
if ( std::strncmp(fc::Fkey[i].tname, "khx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "7~"); // Home key
if ( std::strncmp(fc::Fkey[i].tname, "@7x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "8~"); // End key
if ( std::strncmp(fc::Fkey[i].tname, "k1x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "11~"); // F1
if ( std::strncmp(fc::Fkey[i].tname, "k2x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "12~"); // F2
if ( std::strncmp(fc::Fkey[i].tname, "k3x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "13~"); // F3
if ( std::strncmp(fc::Fkey[i].tname, "k4x", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "14~"); // F4
// Fallback for TERM=ansi
if ( std::strncmp(fc::Fkey[i].tname, "@7X", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "K"); // End key
// Keypad keys
if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OM"); // Enter key
if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Oo"); // Keypad slash
if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Oj"); // Keypad asterisk
if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Om"); // Keypad minus sign
if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
}
// VT100 key codes for the arrow and function keys
termcapKeysVt100 (buffer);
}
//----------------------------------------------------------------------
void FTermcap::termcapKeysVt100 (char*& buffer)
{
// Some terminals (e.g. PuTTY) send vt100 key codes for
// the arrow and function keys.
char* key_up_string = tgetstr(C_STR("ku"), &buffer);
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|| ( TCAP(fc::t_cursor_up)
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
{
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
{
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
}
}
}
// private Data Member of FTermcap - termcap capabilities
//----------------------------------------------------------------------

View File

@ -69,54 +69,54 @@ void FTermcapQuirks::terminalFixup()
if ( td->isCygwinTerminal() )
{
init_termcap_cygwin_quirks();
cygwin();
}
else if ( td->isLinuxTerm() )
{
init_termcap_linux_quirks();
linux();
}
else if ( td->isRxvtTerminal() )
{
init_termcap_rxvt_quirks();
rxvt();
}
else if ( td->isGnomeTerminal() )
{
init_termcap_vte_quirks();
vte();
}
else if ( td->isTeraTerm() )
{
init_termcap_teraterm_quirks();
teraterm();
}
else if ( td->isSunTerminal() )
{
init_termcap_sun_quirks();
sunConsole();
}
else if ( td->isPuttyTerminal() )
{
init_termcap_putty_quirks();
putty();
}
else if ( td->isScreenTerm() )
{
init_termcap_screen_quirks();
screen();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
else if ( td->isFreeBSDTerm() )
{
init_termcap_freebsd_quirks();
freebsd();
}
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
// xterm and compatible terminals
if ( td->isXTerminal() && ! td->isPuttyTerminal() )
init_termcap_xterm_quirks();
xterm();
// Fixes general quirks
init_termcap_general_quirks();
general();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_freebsd_quirks()
void FTermcapQuirks::freebsd()
{
// FreeBSD console fixes
@ -142,7 +142,7 @@ void FTermcapQuirks::init_termcap_freebsd_quirks()
#endif // defined(__FreeBSD__) || defined(__DragonFly__)
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_cygwin_quirks()
void FTermcapQuirks::cygwin()
{
// Set invisible cursor for cygwin terminal
if ( ! TCAP(fc::t_cursor_invisible) )
@ -168,11 +168,11 @@ void FTermcapQuirks::init_termcap_cygwin_quirks()
FTermcap::background_color_erase = true;
// Include the Linux console quirks
init_termcap_linux_quirks();
linux();
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_linux_quirks()
void FTermcapQuirks::linux()
{
/* Same settings are used by cygwin */
@ -223,7 +223,7 @@ void FTermcapQuirks::init_termcap_linux_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_xterm_quirks()
void FTermcapQuirks::xterm()
{
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
@ -247,7 +247,7 @@ void FTermcapQuirks::init_termcap_xterm_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_rxvt_quirks()
void FTermcapQuirks::rxvt()
{
// Set enter/exit alternative charset mode for rxvt terminal
const char* termtype = fterm_data->getTermType();
@ -271,7 +271,7 @@ void FTermcapQuirks::init_termcap_rxvt_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_vte_quirks()
void FTermcapQuirks::vte()
{
// gnome-terminal has NC=16 however, it can use the dim attribute
FTermcap::attr_without_color = 0;
@ -282,7 +282,7 @@ void FTermcapQuirks::init_termcap_vte_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_putty_quirks()
void FTermcapQuirks::putty()
{
FTermcap::background_color_erase = true;
FTermcap::osc_support = true;
@ -368,7 +368,7 @@ void FTermcapQuirks::init_termcap_putty_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_teraterm_quirks()
void FTermcapQuirks::teraterm()
{
// Tera Term eat_nl_glitch fix
FTermcap::eat_nl_glitch = true;
@ -385,14 +385,14 @@ void FTermcapQuirks::init_termcap_teraterm_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_sun_quirks()
void FTermcapQuirks::sunConsole()
{
// Sun Microsystems workstation console eat_nl_glitch fix
FTermcap::eat_nl_glitch = true;
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_screen_quirks()
void FTermcapQuirks::screen()
{
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
@ -417,7 +417,7 @@ void FTermcapQuirks::init_termcap_screen_quirks()
}
//----------------------------------------------------------------------
void FTermcapQuirks::init_termcap_general_quirks()
void FTermcapQuirks::general()
{
static const int not_available = -1;

View File

@ -750,7 +750,12 @@ char* FTermDetection::secDA_Analysis (char current_termtype[])
case 41: // DEC VT420
case 61: // DEC VT510
case 64: // DEC VT520
break;
case 65: // DEC VT525
new_termtype = secDA_Analysis_65(current_termtype);
break;
case 67: // Cygwin
new_termtype = secDA_Analysis_67(current_termtype);
break;
@ -780,7 +785,9 @@ char* FTermDetection::secDA_Analysis (char current_termtype[])
}
// Correct false assumptions
if ( isGnomeTerminal() && secondary_da.terminal_id_type != 1 )
if ( isGnomeTerminal()
&& secondary_da.terminal_id_type != 1
&& secondary_da.terminal_id_type != 65 )
terminal_type.gnome_terminal = false;
if ( isKdeTerminal() && secondary_da.terminal_id_type != 0 )
@ -815,20 +822,7 @@ inline char* FTermDetection::secDA_Analysis_1 (char current_termtype[])
// Terminal ID 1 - DEC VT220
char* new_termtype = current_termtype;
if ( secondary_da.terminal_id_version > 1000 )
{
terminal_type.gnome_terminal = true;
// Each gnome-terminal should be able to use 256 colors
color256 = true;
new_termtype = C_STR("gnome-256color");
gnome_terminal_id = secondary_da.terminal_id_version;
// VTE 0.40.0 or higher and gnome-terminal 3.16 or higher
if ( gnome_terminal_id >= 4000 )
decscusr_support = true;
}
new_termtype = secDA_Analysis_vte(new_termtype);
return new_termtype;
}
@ -870,6 +864,16 @@ inline char* FTermDetection::secDA_Analysis_32 (char[])
return new_termtype;
}
//----------------------------------------------------------------------
inline char* FTermDetection::secDA_Analysis_65 (char current_termtype[])
{
// Terminal ID 65 - DEC VT525
char* new_termtype = current_termtype;
new_termtype = secDA_Analysis_vte(new_termtype);
return new_termtype;
}
//----------------------------------------------------------------------
inline char* FTermDetection::secDA_Analysis_67 (char[])
{
@ -955,4 +959,28 @@ inline char* FTermDetection::secDA_Analysis_85 (char current_termtype[])
return new_termtype;
}
//----------------------------------------------------------------------
inline char* FTermDetection::secDA_Analysis_vte (char current_termtype[])
{
// VTE terminal library
// (Since VTE ) the terminal ID has changed from 1 to 65)
char* new_termtype = current_termtype;
if ( secondary_da.terminal_id_version > 1000 )
{
terminal_type.gnome_terminal = true;
// Each gnome-terminal should be able to use 256 colors
color256 = true;
new_termtype = C_STR("gnome-256color");
gnome_terminal_id = secondary_da.terminal_id_version;
// VTE 0.40.0 or higher and gnome-terminal 3.16 or higher
if ( gnome_terminal_id >= 4000 )
decscusr_support = true;
}
return new_termtype;
}
} // namespace finalcut

View File

@ -577,19 +577,14 @@ bool FTermLinux::getUnicodeMap()
if ( ret != 0 )
{
int count;
std::size_t count = screen_unicode_map.entry_ct;
if ( errno != ENOMEM || screen_unicode_map.entry_ct == 0 )
return false;
count = screen_unicode_map.entry_ct;
if ( count <= 0 )
if ( errno != ENOMEM || count == 0 )
return false;
try
{
screen_unicode_map.entries = new struct unipair[uInt(count)]();
screen_unicode_map.entries = new struct unipair[count]();
}
catch (const std::bad_alloc& ex)
{

View File

@ -31,8 +31,8 @@ namespace finalcut
bool FTermXTerminal::mouse_support;
bool FTermXTerminal::meta_sends_esc;
bool FTermXTerminal::xterm_default_colors;
int FTermXTerminal::term_width = 80;
int FTermXTerminal::term_height = 24;
std::size_t FTermXTerminal::term_width = 80;
std::size_t FTermXTerminal::term_height = 24;
const FString* FTermXTerminal::xterm_font = 0;
const FString* FTermXTerminal::xterm_title = 0;
const FString* FTermXTerminal::foreground_color = 0;
@ -126,7 +126,7 @@ void FTermXTerminal::setTitle (const FString& title)
}
//----------------------------------------------------------------------
void FTermXTerminal::setTermSize (int width, int height)
void FTermXTerminal::setTermSize (std::size_t width, std::size_t height)
{
// Set xterm size to {term_width} x {term_height}
@ -417,7 +417,9 @@ void FTermXTerminal::setXTermSize()
{
if ( term_detection->isXTerminal() )
{
FTerm::putstringf (CSI "8;%d;%dt", term_height, term_width);
FTerm::putstringf ( CSI "8;%lu;%lut"
, uLong(term_height)
, uLong(term_width) );
std::fflush(stdout);
}
}

View File

@ -59,7 +59,7 @@ FTextView::~FTextView() // destructor
//----------------------------------------------------------------------
const FString FTextView::getText() const
{
uInt len, rows, idx;
std::size_t len, rows, idx;
if ( data.empty() )
return FString("");
@ -67,13 +67,13 @@ const FString FTextView::getText() const
len = 0;
rows = getRows();
for (uInt i = 0 ; i < rows; i++)
for (std::size_t i = 0 ; i < rows; i++)
len += data[i].getLength() + 1;
FString s(len + 1);
idx = 0;
for (uInt i = 0 ; i < rows; i++)
for (std::size_t i = 0 ; i < rows; i++)
{
const wchar_t* p = data[i].wc_str();
@ -93,23 +93,23 @@ const FString FTextView::getText() const
}
//----------------------------------------------------------------------
void FTextView::setGeometry (int x, int y, int w, int h, bool adjust)
void FTextView::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Set the text view geometry
FWidget::setGeometry(x, y, w, h, adjust);
int width = getWidth();
int height = getHeight();
std::size_t width = getWidth();
std::size_t height = getHeight();
if ( isNewFont() )
{
vbar->setGeometry (width, 1, 2, height - 1);
hbar->setGeometry (1, height, width - 2, 1);
vbar->setGeometry (int(width), 1, 2, height - 1);
hbar->setGeometry (1, int(height), width - 2, 1);
}
else
{
vbar->setGeometry (width, 2, 1, height - 2);
hbar->setGeometry (2, height, width - 2, 1);
vbar->setGeometry (int(width), 2, 1, height - 2);
hbar->setGeometry (2, int(height), width - 2, 1);
}
vbar->resize();
@ -152,7 +152,7 @@ void FTextView::scrollTo (int x, int y)
if ( xoffset != x )
{
int xoffset_end = int(maxLineWidth) - getTextWidth();
int xoffset_end = int(maxLineWidth - getTextWidth());
xoffset = x;
if ( xoffset < 0 )
@ -170,7 +170,7 @@ void FTextView::scrollTo (int x, int y)
if ( yoffset != y )
{
int yoffset_end = int(getRows()) - getTextHeight();
int yoffset_end = int(getRows() - getTextHeight());
yoffset = y;
if ( yoffset < 0 )
@ -193,9 +193,8 @@ void FTextView::scrollTo (int x, int y)
//----------------------------------------------------------------------
void FTextView::hide()
{
int n, size;
std::size_t n, size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
@ -215,29 +214,18 @@ void FTextView::hide()
n = isNewFont() ? 1 : 0;
size = getWidth() + n;
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getHeight(); y++)
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (1, 1 + y);
setPrintPos (1, 1 + int(y));
print (blank);
}
delete[] blank;
destroyBlankArray (blank);
flush_out();
}
@ -253,7 +241,7 @@ void FTextView::insert (const FString& str, int pos)
FStringList::iterator iter;
FStringList text_split;
FString s;
uLong num;
std::size_t num;
if ( pos < 0 || pos >= int(getRows()) )
pos = int(getRows());
@ -267,9 +255,9 @@ void FTextView::insert (const FString& str, int pos)
text_split = s.split("\r\n");
num = text_split.size();
for (uInt i = 0; i < num; i++)
for (std::size_t i = 0; i < num; i++)
{
uInt len;
std::size_t len;
text_split[i] = text_split[i].removeBackspaces()
.removeDel()
.replaceControlCodes()
@ -280,10 +268,10 @@ void FTextView::insert (const FString& str, int pos)
{
maxLineWidth = len;
if ( len > uInt(getTextWidth()) )
if ( len > getTextWidth() )
{
hbar->setMaximum (int(maxLineWidth) - getTextWidth());
hbar->setPageSize (int(maxLineWidth), getTextWidth());
hbar->setMaximum (int(maxLineWidth) - int(getTextWidth()));
hbar->setPageSize (int(maxLineWidth), int(getTextWidth()));
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
@ -293,14 +281,14 @@ void FTextView::insert (const FString& str, int pos)
}
data.insert (iter + pos, text_split.begin(), text_split.end());
vbar->setMaximum (int(getRows()) - getTextHeight());
vbar->setPageSize (int(getRows()), getTextHeight());
vbar->setMaximum (int(getRows()) - int(getTextHeight()));
vbar->setPageSize (int(getRows()), int(getTextHeight()));
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && int(getRows()) > getTextHeight() )
if ( ! vbar->isVisible() && getRows() > getTextHeight() )
vbar->setVisible();
if ( vbar->isVisible() && int(getRows()) <= getTextHeight() )
if ( vbar->isVisible() && getRows() <= getTextHeight() )
vbar->hide();
processChanged();
@ -311,13 +299,7 @@ void FTextView::replaceRange (const FString& str, int from, int to)
{
FStringList::iterator iter;
if ( from > to )
return;
if ( from < 0 || from >= int(getRows()) )
return;
if ( to < 0 || to >= int(getRows()) )
if ( from > to || from >= int(getRows()) || to >= int(getRows()) )
return;
iter = data.begin();
@ -330,9 +312,7 @@ void FTextView::replaceRange (const FString& str, int from, int to)
//----------------------------------------------------------------------
void FTextView::clear()
{
int size;
char* blank;
std::size_t size;
data.clear();
xoffset = 0;
yoffset = 0;
@ -350,29 +330,18 @@ void FTextView::clear()
setColor();
size = getWidth() - 2;
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
char* blank = createBlankArray(size + 1);
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y = 0; y < getTextHeight(); y++)
for (int y = 0; y < int(getTextHeight()); y++)
{
setPrintPos (2, 2 - nf_offset + y);
print (blank);
}
delete[] blank;
destroyBlankArray (blank);
processChanged();
}
@ -402,12 +371,12 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_ppage:
scrollBy (0, -getTextHeight());
scrollBy (0, int(-getTextHeight()));
ev->accept();
break;
case fc::Fkey_npage:
scrollBy (0, getTextHeight());
scrollBy (0, int(getTextHeight()));
ev->accept();
break;
@ -417,7 +386,7 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_end:
scrollToY (int(getRows()) - getTextHeight());
scrollToY (int(getRows() - getTextHeight()));
ev->accept();
break;
@ -592,43 +561,43 @@ void FTextView::onFocusOut (FFocusEvent*)
void FTextView::adjustSize()
{
FWidget::adjustSize();
int width = getWidth()
, height = getHeight()
, last_line = int(getRows())
, max_width = int(maxLineWidth);
std::size_t width = getWidth();
std::size_t height = getHeight();
int last_line = int(getRows());
int max_width = int(maxLineWidth);
if ( xoffset >= max_width - width - nf_offset )
xoffset = max_width - width - nf_offset - 1;
if ( xoffset >= max_width - int(width) - nf_offset )
xoffset = max_width - int(width) - nf_offset - 1;
if ( xoffset < 0 )
xoffset = 0;
if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2;
if ( yoffset > last_line - int(height) - nf_offset + 2 )
yoffset = last_line - int(height) - nf_offset + 2;
if ( yoffset < 0 )
yoffset = 0;
vbar->setMaximum (last_line - height + 2 - nf_offset);
vbar->setPageSize (last_line, height - 2 + nf_offset);
vbar->setX (width);
vbar->setHeight (height - 2 + nf_offset, false);
vbar->setMaximum (last_line - int(height) + 2 - nf_offset);
vbar->setPageSize (last_line, int(height) - 2 + nf_offset);
vbar->setX (int(width));
vbar->setHeight (height - 2 + std::size_t(nf_offset), false);
vbar->setValue (yoffset);
vbar->resize();
hbar->setMaximum (max_width - width + nf_offset + 2);
hbar->setPageSize (max_width, width - nf_offset - 2);
hbar->setY (height);
hbar->setMaximum (max_width - int(width) + nf_offset + 2);
hbar->setPageSize (max_width, int(width) - nf_offset - 2);
hbar->setY (int(height));
hbar->setWidth (width - 2, false);
hbar->setValue (xoffset);
hbar->resize();
if ( last_line < height + nf_offset - 1 )
if ( last_line < int(height) + nf_offset - 1 )
vbar->hide();
else
vbar->setVisible();
if ( max_width < width - nf_offset - 1 )
if ( max_width < int(width) - nf_offset - 1 )
hbar->hide();
else
hbar->setVisible();
@ -637,15 +606,15 @@ void FTextView::adjustSize()
// private methods of FTextView
//----------------------------------------------------------------------
int FTextView::getTextHeight()
std::size_t FTextView::getTextHeight()
{
return getHeight() - 2 + nf_offset;
return getHeight() - 2 + std::size_t(nf_offset);
}
//----------------------------------------------------------------------
int FTextView::getTextWidth()
std::size_t FTextView::getTextWidth()
{
return getWidth() - 2 - nf_offset;
return getWidth() - 2 - std::size_t(nf_offset);
}
//----------------------------------------------------------------------
@ -740,7 +709,7 @@ void FTextView::draw()
}
}
setCursorPos (getWidth(), getHeight());
setCursorPos (int(getWidth()), int(getHeight()));
updateTerminal();
flush_out();
}
@ -748,12 +717,10 @@ void FTextView::draw()
//----------------------------------------------------------------------
void FTextView::drawText()
{
uInt num;
if ( data.empty() || getHeight() <= 2 || getWidth() <= 2 )
return;
num = uInt(getTextHeight());
std::size_t num = getTextHeight();
if ( num > getRows() )
num = getRows();
@ -763,14 +730,14 @@ void FTextView::drawText()
if ( isMonochron() )
setReverse(true);
for (uInt y = 0; y < num; y++)
for (std::size_t y = 0; y < num; y++)
{
uInt i, len;
std::size_t i, len;
FString line;
const wchar_t* line_str;
setPrintPos (2, 2 - nf_offset + int(y));
line = data[y + uInt(yoffset)].mid ( uInt(1 + xoffset)
, uInt(getTextWidth()) );
line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset)
, getTextWidth() );
line_str = line.wc_str();
len = line.getLength();
@ -790,7 +757,7 @@ void FTextView::drawText()
print ('.');
}
for (; i < uInt(getTextWidth()); i++)
for (; i < getTextWidth(); i++)
print (' ');
}
@ -841,14 +808,14 @@ void FTextView::cb_VBarChange (FWidget*, data_ptr)
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
distance = int(getClientHeight());
// fall through
case FScrollbar::scrollStepBackward:
scrollBy (0, -distance);
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
distance = int(getClientHeight());
// fall through
case FScrollbar::scrollStepForward:
scrollBy (0, distance);
@ -897,14 +864,14 @@ void FTextView::cb_HBarChange (FWidget*, data_ptr)
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth();
distance = int(getClientWidth());
// fall through
case FScrollbar::scrollStepBackward:
scrollBy (-distance, 0);
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth();
distance = int(getClientWidth());
// fall through
case FScrollbar::scrollStepForward:
scrollBy (distance, 0);

View File

@ -88,12 +88,12 @@ FToggleButton::~FToggleButton() // destructor
// public methods of FToggleButton
//----------------------------------------------------------------------
void FToggleButton::setGeometry (int x, int y, int w, int h, bool adjust)
void FToggleButton::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Set the toggle button geometry
int hotkey_mark = ( getHotkey() ) ? 1 : 0;
int min_width = button_width + int(text.getLength()) - hotkey_mark;
std::size_t hotkey_mark = ( getHotkey() ) ? 1 : 0;
std::size_t min_width = button_width + text.getLength() - hotkey_mark;
if ( w < min_width )
w = min_width;
@ -203,9 +203,9 @@ bool FToggleButton::setChecked (bool on)
void FToggleButton::setText (const FString& txt)
{
text = txt;
int hotkey_mark = ( getHotkey() ) ? 1 : 0;
std::size_t hotkey_mark = ( getHotkey() ) ? 1 : 0;
setWidth(button_width + int(text.getLength()) - hotkey_mark);
setWidth(button_width + text.getLength() - hotkey_mark);
if ( isEnabled() )
{
@ -217,11 +217,9 @@ void FToggleButton::setText (const FString& txt)
//----------------------------------------------------------------------
void FToggleButton::hide()
{
int size;
std::size_t size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide();
if ( parent_widget )
@ -238,24 +236,13 @@ void FToggleButton::hide()
setColor (fg, bg);
size = getWidth();
if ( size < 0 )
if ( size == 0 )
return;
try
{
blank = new char[uInt(size) + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
std::memset(blank, ' ', uLong(size));
blank[size] = '\0';
char* blank = createBlankArray(size + 1);
setPrintPos (1, 1);
print (blank);
delete[] blank;
destroyBlankArray (blank);
}
//----------------------------------------------------------------------
@ -420,14 +407,12 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
//----------------------------------------------------------------------
uChar FToggleButton::getHotkey()
{
uInt length;
if ( text.isEmpty() )
return 0;
length = text.getLength();
std::size_t length = text.getLength();
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
try
{
@ -502,7 +487,7 @@ void FToggleButton::draw()
void FToggleButton::drawLabel()
{
wchar_t* LabelText;
int hotkeypos;
std::size_t hotkeypos;
if ( ! isVisible() )
return;
@ -510,7 +495,7 @@ void FToggleButton::drawLabel()
if ( text.isNull() || text.isEmpty() )
return;
uInt length = text.getLength();
std::size_t length = text.getLength();
try
{
@ -525,12 +510,12 @@ void FToggleButton::drawLabel()
FString txt = text;
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText);
hotkeypos = getHotkeyPos(src, dest, uInt(length));
hotkeypos = getHotkeyPos(src, dest, length);
if ( hotkeypos != -1 )
if ( hotkeypos != NOT_SET )
length--;
setPrintPos (1 + label_offset_pos, 1);
setPrintPos (1 + int(label_offset_pos), 1);
drawText (LabelText, hotkeypos, length);
delete[] LabelText;
}
@ -638,18 +623,20 @@ void FToggleButton::init()
}
//----------------------------------------------------------------------
int FToggleButton::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
std::size_t FToggleButton::getHotkeyPos ( wchar_t src[]
, wchar_t dest[]
, std::size_t length )
{
// find hotkey position in string
// + generate a new string without the '&'-sign
int pos = -1;
std::size_t pos = NOT_SET;
wchar_t* txt = src;
for (uInt i = 0; i < length; i++)
for (std::size_t i = 0; i < length; i++)
{
if ( i < length && txt[i] == L'&' && pos == -1 )
if ( i < length && txt[i] == L'&' && pos == NOT_SET )
{
pos = int(i);
pos = i;
i++;
src++;
}
@ -661,7 +648,9 @@ int FToggleButton::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
}
//----------------------------------------------------------------------
void FToggleButton::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
void FToggleButton::drawText ( wchar_t LabelText[]
, std::size_t hotkeypos
, std::size_t length )
{
bool isActive = ((flags & fc::active) != 0);
bool isNoUnderline = ((flags & fc::no_underline) != 0);
@ -674,7 +663,7 @@ void FToggleButton::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
else
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
for (int z = 0; z < int(length); z++)
for (std::size_t z = 0; z < length; z++)
{
if ( (z == hotkeypos) && isActive )
{

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2016-2017 Markus Gans *
* Copyright 2016-2018 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -143,23 +143,24 @@ void FToolTip::init()
//----------------------------------------------------------------------
void FToolTip::calculateDimensions()
{
int x, y, w, h;
int x, y;
std::size_t w, h;
FWidget* r = getRootWidget();
text_split = text.split("\n");
text_num_lines = uInt(text_split.size());
text_components = &text_split[0];
max_line_width = 0;
for (uInt i = 0; i < text_num_lines; i++)
for (std::size_t i = 0; i < text_num_lines; i++)
{
uInt len = text_components[i].getLength();
std::size_t len = text_components[i].getLength();
if ( len > max_line_width )
max_line_width = len;
}
h = int(text_num_lines) + 2;
w = int(max_line_width + 4);
h = text_num_lines + 2;
w = max_line_width + 4;
if ( r )
{

View File

@ -110,8 +110,8 @@ void FVTerm::setTermXY (int x, int y)
if ( term_pos->getX() == x && term_pos->getY() == y )
return;
term_width = getColumnNumber();
term_height = getLineNumber();
term_width = int(getColumnNumber());
term_height = int(getLineNumber());
if ( x >= term_width )
{
@ -597,8 +597,8 @@ void FVTerm::createArea ( const FRect& r
{
createArea ( r.getX()
, r.getY()
, r.getWidth()
, r.getHeight()
, int(r.getWidth())
, int(r.getHeight())
, p.getX()
, p.getY()
, area );
@ -633,8 +633,8 @@ void FVTerm::resizeArea ( const FRect& r
{
resizeArea ( r.getX()
, r.getY()
, r.getWidth()
, r.getHeight()
, int(r.getWidth())
, int(r.getHeight())
, p.getX()
, p.getY()
, area );
@ -653,7 +653,7 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
assert ( height > 0 );
assert ( rsw >= 0 );
assert ( bsh >= 0 );
int area_size;
std::size_t area_size;
bool realloc_success = false;
if ( ! area )
@ -673,11 +673,13 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
return;
}
area_size = (width + rsw) * (height + bsh);
area_size = std::size_t((width + rsw) * (height + bsh));
if ( area->height + area->bottom_shadow != height + bsh )
{
realloc_success = reallocateTextArea (area, height + bsh, area_size);
realloc_success = reallocateTextArea ( area
, std::size_t(height + bsh)
, area_size );
}
else if ( area->width + area->right_shadow != width + rsw )
{
@ -727,12 +729,9 @@ inline void FVTerm::setTextToDefault ( term_area* area
//----------------------------------------------------------------------
inline bool FVTerm::reallocateTextArea ( term_area* area
, int height
, int size )
, std::size_t height
, std::size_t size )
{
assert ( height > 0 );
assert ( size > 0 );
if ( area->changes != 0 )
delete[] area->changes;
@ -741,8 +740,8 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
try
{
area->changes = new line_changes[uInt(height)];
area->text = new charData[uInt(size)];
area->changes = new line_changes[height];
area->text = new charData[size];
}
catch (const std::bad_alloc& ex)
{
@ -754,16 +753,14 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
}
//----------------------------------------------------------------------
inline bool FVTerm::reallocateTextArea (term_area* area, int size)
inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size)
{
assert ( size > 0 );
if ( area->text != 0 )
delete[] area->text;
try
{
area->text = new charData[uInt(size)];
area->text = new charData[size];
}
catch (const std::bad_alloc& ex)
{
@ -803,8 +800,8 @@ void FVTerm::restoreVTerm (const FRect& box)
{
restoreVTerm ( box.getX()
, box.getY()
, box.getWidth()
, box.getHeight() );
, int(box.getWidth())
, int(box.getHeight()) );
}
//----------------------------------------------------------------------
@ -904,8 +901,8 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
int win_y = win->offset_top;
FRect geometry ( win_x
, win_y
, win->width + win->right_shadow
, win->height + win->bottom_shadow );
, std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) );
if ( found && geometry.contains(x, y) )
{
@ -1309,10 +1306,9 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area)
{
// Check whether the coordinates are within the area
int ax = 0
, ay = 0
, aw = area->width
, ah = area->height;
int ax = 0, ay = 0;
std::size_t aw = std::size_t(area->width);
std::size_t ah = std::size_t(area->height);
FRect area_geometry(ax, ay, aw, ah);
if ( area_geometry.contains(x, y) )
@ -1392,8 +1388,8 @@ void FVTerm::getArea (const FRect& box, term_area* area)
{
getArea ( box.getX()
, box.getY()
, box.getWidth()
, box.getHeight()
, int(box.getWidth())
, int(box.getHeight())
, area );
}
@ -1744,8 +1740,8 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
int win_y = win->offset_top;
FRect geometry ( win_x
, win_y
, win->width + win->right_shadow
, win->height + win->bottom_shadow );
, std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) );
// Window is visible and contains current character
if ( geometry.contains(x, y) )
@ -1860,8 +1856,8 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
FRect geometry ( win->offset_left
, win->offset_top
, win->width + win->right_shadow
, win->height + win->bottom_shadow );
, std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) );
// Window visible and contains current character
if ( geometry.contains(x, y) )
@ -2191,7 +2187,7 @@ bool FVTerm::clearTerm (int fillchar)
{
term_pos->setPoint(-1, -1);
for (int i = 0; i < getLineNumber(); i++)
for (int i = 0; i < int(getLineNumber()); i++)
{
setTermXY (0, i);
appendOutputBuffer (cb);
@ -2878,8 +2874,8 @@ int FVTerm::appendLowerRight (charData*& screen_char)
char* ip = TCAP(fc::t_insert_padding);
char* ic = TCAP(fc::t_insert_character);
x = getColumnNumber() - 2;
y = getLineNumber() - 1;
x = int(getColumnNumber()) - 2;
y = int(getLineNumber()) - 1;
setTermXY (x, y);
appendChar (screen_char);
term_pos->x_ref()++;

View File

@ -34,8 +34,6 @@ namespace finalcut
static FWidget* rootObject = 0;
// static class attributes
uInt FWidget::modal_dialogs;
FStatusBar* FWidget::statusbar = 0;
FMenuBar* FWidget::menubar = 0;
FWidget* FWidget::show_root_widget = 0;
@ -47,6 +45,7 @@ FWidget::widgetList* FWidget::close_widget = 0;
FWidgetColors FWidget::wc;
bool FWidget::init_desktop;
bool FWidget::hideable;
uInt FWidget::modal_dialogs;
//----------------------------------------------------------------------
@ -106,10 +105,10 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
{
visible_cursor = ! hideable;
offset = parent->client_offset;
double_flatline_mask.top.resize (uLong(getWidth()), false);
double_flatline_mask.right.resize (uLong(getHeight()), false);
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false);
}
}
@ -175,20 +174,6 @@ FWidget* FWidget::getParentWidget() const
return 0;
}
//----------------------------------------------------------------------
FWidget* FWidget::getMainWidget()
{
FWidget* main_widget = static_cast<FWidget*>(FApplication::main_widget);
return main_widget;
}
//----------------------------------------------------------------------
FWidget* FWidget::getFocusWidget() const
{
FWidget* focus_widget = static_cast<FWidget*>(FApplication::focus_widget);
return focus_widget;
}
//----------------------------------------------------------------------
FWidget* FWidget::getFirstFocusableWidget (FObjectList list)
{
@ -242,44 +227,6 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
return 0;
}
//----------------------------------------------------------------------
FWidget* FWidget::getClickedWidget()
{
FWidget* clicked_widget = static_cast<FWidget*>(FApplication::clicked_widget);
return clicked_widget;
}
//----------------------------------------------------------------------
FWidget* FWidget::getMoveSizeWidget()
{
return FApplication::move_size_widget;
}
//----------------------------------------------------------------------
FWidget* FWidget::getOpenMenu()
{
FWidget* open_menu = static_cast<FWidget*>(FApplication::open_menu);
return open_menu;
}
//----------------------------------------------------------------------
FMenuBar* FWidget::getMenuBar()
{
if ( menubar )
return menubar;
else
return 0;
}
//----------------------------------------------------------------------
FStatusBar* FWidget::getStatusBar()
{
if ( statusbar )
return statusbar;
else
return 0;
}
//----------------------------------------------------------------------
FPoint FWidget::getPrintPos()
{
@ -319,38 +266,11 @@ std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
//----------------------------------------------------------------------
void FWidget::setMainWidget (FWidget* obj)
{
FApplication* fapp = static_cast<FApplication*>(rootObject);
fapp->setMainWidget(obj);
}
main_widget = obj;
FWidget* app_object = FApplication::getApplicationObject();
//----------------------------------------------------------------------
void FWidget::setFocusWidget (FWidget* obj)
{
FApplication::focus_widget = obj;
}
//----------------------------------------------------------------------
void FWidget::setClickedWidget (FWidget* obj)
{
FApplication::clicked_widget = obj;
}
//----------------------------------------------------------------------
void FWidget::setMoveSizeWidget (FWidget* obj)
{
FApplication::move_size_widget = obj;
}
//----------------------------------------------------------------------
void FWidget::setOpenMenu (FWidget* obj)
{
FApplication::open_menu = obj;
}
//----------------------------------------------------------------------
void FWidget::setStatusbarMessage (const FString& msg)
{
statusbar_message = msg;
if ( obj && app_object && ! getFocusWidget() )
app_object->focusFirstChild();
}
//----------------------------------------------------------------------
@ -482,7 +402,7 @@ void FWidget::setPos (int x, int y, bool adjust)
}
//----------------------------------------------------------------------
void FWidget::setWidth (int width, bool adjust)
void FWidget::setWidth (std::size_t width, bool adjust)
{
width = std::min (width, size_hints.max_width);
width = std::max (width, size_hints.min_width);
@ -499,12 +419,12 @@ void FWidget::setWidth (int width, bool adjust)
if ( adjust )
adjustSize();
double_flatline_mask.top.resize (uLong(getWidth()), false);
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
}
//----------------------------------------------------------------------
void FWidget::setHeight (int height, bool adjust)
void FWidget::setHeight (std::size_t height, bool adjust)
{
height = std::min (height, size_hints.max_height);
height = std::max (height, size_hints.min_height);
@ -521,12 +441,12 @@ void FWidget::setHeight (int height, bool adjust)
if ( adjust )
adjustSize();
double_flatline_mask.right.resize (uLong(getHeight()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.left.resize (getHeight(), false);
}
//----------------------------------------------------------------------
void FWidget::setSize (int width, int height, bool adjust)
void FWidget::setSize (std::size_t width, std::size_t height, bool adjust)
{
width = std::min (width, size_hints.max_width);
width = std::max (width, size_hints.min_width);
@ -551,10 +471,10 @@ void FWidget::setSize (int width, int height, bool adjust)
if ( adjust )
adjustSize();
double_flatline_mask.top.resize (uLong(getWidth()), false);
double_flatline_mask.right.resize (uLong(getHeight()), false);
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false);
}
//----------------------------------------------------------------------
@ -612,7 +532,7 @@ void FWidget::setBottomPadding (int bottom, bool adjust)
if ( isRootWidget() )
{
FWidget* r = rootObject;
r->client_offset.setY2 (r->getHeight() - 1 - r->padding.bottom);
r->client_offset.setY2 (int(r->getHeight()) - 1 - r->padding.bottom);
adjustSizeGlobal();
}
else
@ -633,7 +553,7 @@ void FWidget::setRightPadding (int right, bool adjust)
if ( isRootWidget() )
{
FWidget* r = rootObject;
r->client_offset.setX2 (r->getWidth() - 1 - r->padding.right);
r->client_offset.setX2 (int(r->getWidth()) - 1 - r->padding.right);
adjustSizeGlobal();
}
else
@ -654,8 +574,8 @@ void FWidget::setParentOffset()
void FWidget::setTermOffset()
{
FWidget* r = getRootWidget();
int w = r->getWidth();
int h = r->getHeight();
int w = int(r->getWidth());
int h = int(r->getHeight());
offset.setCoordinates (0, 0, w - 1, h - 1);
}
@ -665,14 +585,15 @@ void FWidget::setTermOffsetWithPadding()
FWidget* r = getRootWidget();
offset.setCoordinates ( r->getLeftPadding()
, r->getTopPadding()
, r->getWidth() - 1 - r->getRightPadding()
, r->getHeight() - 1 - r->getBottomPadding() );
, int(r->getWidth()) - 1 - r->getRightPadding()
, int(r->getHeight()) - 1 - r->getBottomPadding() );
}
//----------------------------------------------------------------------
void FWidget::setTermSize (int w, int h)
void FWidget::setTermSize (std::size_t w, std::size_t h)
{
// Set xterm size to w x h
if ( isXTerminal() )
{
rootObject->wsize.setRect(1, 1, w, h);
@ -683,12 +604,11 @@ void FWidget::setTermSize (int w, int h)
}
//----------------------------------------------------------------------
void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
void FWidget::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Sets the geometry of the widget relative to its parent
int term_x
, term_y;
int term_x, term_y;
w = std::min (w, size_hints.max_width);
w = std::max (w, size_hints.min_width);
@ -718,13 +638,13 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
client_offset.setCoordinates ( term_x - 1 + padding.left
, term_y - 1 + padding.top
, term_x - 2 + getWidth() - padding.right
, term_y - 2 + getHeight() - padding.bottom );
, term_x - 2 + int(getWidth()) - padding.right
, term_y - 2 + int(getHeight()) - padding.bottom );
double_flatline_mask.top.resize (uLong(getWidth()), false);
double_flatline_mask.right.resize (uLong(getHeight()), false);
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false);
if ( adjust )
adjustSize();
@ -1148,10 +1068,10 @@ void FWidget::resize()
adjustSize();
// resize the four double-flatline-masks
double_flatline_mask.top.resize (uLong(getWidth()), false);
double_flatline_mask.right.resize (uLong(getHeight()), false);
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false);
}
//----------------------------------------------------------------------
@ -1329,8 +1249,8 @@ void FWidget::detectTermSize()
(
r->padding.left,
r->padding.top,
getDesktopWidth() - 1 - r->padding.right,
getDesktopHeight() - 1 - r->padding.bottom
int(getDesktopWidth()) - 1 - r->padding.right,
int(getDesktopHeight()) - 1 - r->padding.bottom
);
}
@ -1357,9 +1277,9 @@ void FWidget::drawShadow()
}
int x1 = 1
, x2 = getWidth()
, x2 = int(getWidth())
, y1 = 1
, y2 = getHeight();
, y2 = int(getHeight());
if ( trans_shadow )
{
@ -1379,8 +1299,8 @@ void FWidget::clearShadow()
if ( isMonochron() )
return;
int w = getWidth()
, h = getHeight();
int w = int(getWidth());
int h = int(getHeight());
if ( isWindowWidget() )
{
@ -1392,7 +1312,7 @@ void FWidget::clearShadow()
if ( w <= offset.getX2() )
{
for (int i = 1; i <= getHeight(); i++)
for (int i = 1; i <= int(getHeight()); i++)
{
setPrintPos (w + 1, i);
print (' '); // clear █
@ -1403,7 +1323,7 @@ void FWidget::clearShadow()
{
setPrintPos (2, h + 1);
for (int i = 1; i <= getWidth(); i++)
for (std::size_t i = 1; i <= getWidth(); i++)
print (' '); // clear ▀
}
@ -1418,16 +1338,16 @@ void FWidget::drawFlatBorder()
return;
int x1 = 1
, x2 = getWidth() + 1
, x2 = int(getWidth()) + 1
, y1 = 0
, y2 = getHeight() + 1;
, y2 = int(getHeight()) + 1;
if ( FWidget* p = getParentWidget() )
setColor (wc.dialog_fg, p->getBackgroundColor());
else
setColor (wc.dialog_fg, wc.dialog_bg);
for (int y = 0; y < getHeight(); y++)
for (int y = 0; y < int(getHeight()); y++)
{
setPrintPos (x1 - 1, y1 + y + 1);
@ -1441,7 +1361,7 @@ void FWidget::drawFlatBorder()
setPrintPos (x2, y1 + 1);
for (int y = 0; y < getHeight(); y++)
for (int y = 0; y < int(getHeight()); y++)
{
if ( double_flatline_mask.right[uLong(y)] )
// left+right line (on right side)
@ -1455,7 +1375,7 @@ void FWidget::drawFlatBorder()
setPrintPos (x1, y1);
for (int x = 0; x < getWidth(); x++)
for (int x = 0; x < int(getWidth()); x++)
{
if ( double_flatline_mask.top[uLong(x)] )
// top+bottom line (at top)
@ -1467,7 +1387,7 @@ void FWidget::drawFlatBorder()
setPrintPos (x1, y2);
for (int x = 0; x < getWidth(); x++)
for (int x = 0; x < int(getWidth()); x++)
{
if ( double_flatline_mask.bottom[uLong(x)] )
// top+bottom line (at bottom)
@ -1485,9 +1405,9 @@ void FWidget::clearFlatBorder()
return;
int x1 = 1
, x2 = getWidth() + 1
, x2 = int(getWidth()) + 1
, y1 = 0
, y2 = getHeight() + 1;
, y2 = int(getHeight()) + 1;
if ( FWidget* p = getParentWidget() )
setColor (wc.dialog_fg, p->getBackgroundColor());
@ -1495,7 +1415,7 @@ void FWidget::clearFlatBorder()
setColor (wc.dialog_fg, wc.dialog_bg);
// clear on left side
for (int y = 0; y < getHeight(); y++)
for (int y = 0; y < int(getHeight()); y++)
{
setPrintPos (x1 - 1, y1 + y + 1);
@ -1506,7 +1426,7 @@ void FWidget::clearFlatBorder()
}
// clear on right side
for (int y = 0; y < getHeight(); y++)
for (int y = 0; y < int(getHeight()); y++)
{
setPrintPos (x2, y1 + y + 1);
@ -1519,7 +1439,7 @@ void FWidget::clearFlatBorder()
// clear at top
setPrintPos (x1, y1);
for (int x = 0; x < getWidth(); x++)
for (int x = 0; x < int(getWidth()); x++)
{
if ( double_flatline_mask.top[uLong(x)] )
print (fc::NF_border_line_upper);
@ -1530,7 +1450,7 @@ void FWidget::clearFlatBorder()
// clear at bottom
setPrintPos (x1, y2);
for (int x = 0; x < getWidth(); x++)
for (int x = 0; x < int(getWidth()); x++)
{
if ( double_flatline_mask.bottom[uLong(x)] )
print (fc::NF_border_line_bottom);
@ -1554,11 +1474,11 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
if ( y1 < 1 )
y1 = 1;
if ( x2 > getWidth() )
x2 = getWidth();
if ( x2 > int(getWidth()) )
x2 = int(getWidth());
if ( y2 > getHeight() )
y2 = getHeight();
if ( y2 > int(getHeight()) )
y2 = int(getHeight());
if ( isNewFont() )
drawNewFontBox (x1, y1, x2, y2);
@ -1569,7 +1489,8 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
//----------------------------------------------------------------------
void FWidget::quit()
{
FApplication* fapp = static_cast<FApplication*>(rootObject);
FWidget* app_object = FApplication::getApplicationObject();
FApplication* fapp = static_cast<FApplication*>(app_object);
fapp->exit(0);
}
@ -1683,8 +1604,8 @@ void FWidget::adjustSize()
{
offset.setCoordinates ( p->getTermX() - 1
, p->getTermY() - 1
, p->getTermX() + p->getWidth() - 2
, p->getTermY() + p->getHeight() - 2 );
, p->getTermX() + int(p->getWidth()) - 2
, p->getTermY() + int(p->getHeight()) - 2 );
}
else if ( p )
offset = p->client_offset;
@ -1700,8 +1621,8 @@ void FWidget::adjustSize()
(
getTermX() - 1 + padding.left,
getTermY() - 1 + padding.top,
getTermX() - 2 + getWidth() - padding.right,
getTermY() - 2 + getHeight() - padding.bottom
getTermX() - 2 + int(getWidth()) - padding.right,
getTermY() - 2 + int(getHeight()) - padding.bottom
);
if ( hasChildren() )
@ -2069,10 +1990,10 @@ void FWidget::init()
offset.setRect(0, 0, getDesktopWidth(), getDesktopHeight());
client_offset = offset;
double_flatline_mask.top.resize (uLong(getWidth()), false);
double_flatline_mask.right.resize (uLong(getHeight()), false);
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
double_flatline_mask.left.resize (uLong(getHeight()), false);
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false);
// Initialize default widget colors
setColorTheme();
@ -2132,7 +2053,7 @@ inline void FWidget::insufficientSpaceAdjust()
return;
// move left if not enough space
while ( getTermX() + getWidth() - padding.right > offset.getX2() + 2 )
while ( getTermX() + int(getWidth()) - padding.right > offset.getX2() + 2 )
{
adjust_wsize.x1_ref()--;
adjust_wsize.x2_ref()--;
@ -2142,7 +2063,7 @@ inline void FWidget::insufficientSpaceAdjust()
}
// move up if not enough space
while ( getTermY() + getHeight() - padding.bottom > offset.getY2() + 2 )
while ( getTermY() + int(getHeight()) - padding.bottom > offset.getY2() + 2 )
{
adjust_wsize.y1_ref()--;
adjust_wsize.y2_ref()--;
@ -2152,17 +2073,17 @@ inline void FWidget::insufficientSpaceAdjust()
}
// reduce the width if not enough space
while ( offset.getX1() + getWidth() - 1 > offset.getX2() )
while ( offset.getX1() + int(getWidth()) - 1 > offset.getX2() )
adjust_wsize.x2_ref()--;
if ( getWidth() < size_hints.min_width )
adjust_wsize.setWidth(size_hints.min_width);
if ( getWidth() <= 0 )
if ( getWidth() == 0 )
adjust_wsize.setWidth(1);
// reduce the height if not enough space
while ( offset.getY1() + getHeight() - 1 > offset.getY2() )
while ( offset.getY1() + int(getHeight()) - 1 > offset.getY2() )
adjust_wsize.y2_ref()--;
if ( getHeight() < size_hints.min_height )
@ -2343,7 +2264,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (int i = 1; i < getHeight(); i++)
for (int i = 1; i < int(getHeight()); i++)
{
setPrintPos (x2 + 1, y1 + i);
print (" ");
@ -2358,7 +2279,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (int i = 2; i <= getWidth() + 1; i++)
for (std::size_t i = 2; i <= getWidth() + 1; i++)
print (' ');
unsetTransShadow();
@ -2392,7 +2313,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() )
unsetInheritBackground();
for (int i = 1; i < getHeight(); i++)
for (int i = 1; i < int(getHeight()); i++)
{
setPrintPos (x2 + 1, y1 + i);
print (block); // █
@ -2403,7 +2324,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() )
setInheritBackground();
for (int i = 1; i <= getWidth(); i++)
for (std::size_t i = 1; i <= getWidth(); i++)
print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() )

View File

@ -80,14 +80,6 @@ FWindow::~FWindow() // destructor
// public methods of FWindow
//----------------------------------------------------------------------
FWindow* FWindow::getActiveWindow()
{
// returns the active FWindow object
FWindow* active_window = static_cast<FWindow*>(FApplication::active_window);
return active_window;
}
//----------------------------------------------------------------------
FWidget* FWindow::getWindowFocusWidget() const
{
@ -170,7 +162,7 @@ bool FWindow::activateWindow (bool on)
// activate/deactivate this window
if ( on )
{
FApplication::active_window = this;
FWidget::setActiveWindow (this);
active_area = getVWin();
}
@ -181,7 +173,7 @@ bool FWindow::activateWindow (bool on)
void FWindow::unsetActiveWindow()
{
// unset the active FWindow object
FApplication::active_window = 0;
FWidget::setActiveWindow (0);
}
//----------------------------------------------------------------------
@ -278,9 +270,9 @@ void FWindow::drawBorder()
if ( isNewFont() )
{
int x1 = 1
, x2 = 1 + getWidth() - 1
, x2 = 1 + int(getWidth()) - 1
, y1 = 1
, y2 = 1 + getHeight() - 1;
, y2 = 1 + int(getHeight()) - 1;
setPrintPos (x1, y1);
print (fc::NF_border_corner_upper_left); // ⎡
@ -304,7 +296,7 @@ void FWindow::drawBorder()
// lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
for (int x = 2; x < getWidth(); x++) // low line _
for (std::size_t x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom);
setPrintPos (x2, y2);
@ -372,9 +364,9 @@ void FWindow::setPos (int x, int y, bool adjust)
}
//----------------------------------------------------------------------
void FWindow::setWidth (int w, bool adjust)
void FWindow::setWidth (std::size_t w, bool adjust)
{
int old_width = getWidth();
std::size_t old_width = getWidth();
FWidget::setWidth (w, adjust);
if ( isVirtualWindow() && getWidth() != old_width )
@ -386,9 +378,9 @@ void FWindow::setWidth (int w, bool adjust)
}
//----------------------------------------------------------------------
void FWindow::setHeight (int h, bool adjust)
void FWindow::setHeight (std::size_t h, bool adjust)
{
int old_height = getHeight();
std::size_t old_height = getHeight();
FWidget::setHeight (h, adjust);
if ( isVirtualWindow() && getHeight() != old_height )
@ -400,10 +392,10 @@ void FWindow::setHeight (int h, bool adjust)
}
//----------------------------------------------------------------------
void FWindow::setSize (int w, int h, bool adjust)
void FWindow::setSize (std::size_t w, std::size_t h, bool adjust)
{
int old_width = getWidth();
int old_height = getHeight();
std::size_t old_width = getWidth();
std::size_t old_height = getHeight();
FWidget::setSize (w, h, adjust);
if ( isVirtualWindow()
@ -416,14 +408,14 @@ void FWindow::setSize (int w, int h, bool adjust)
}
//----------------------------------------------------------------------
void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
void FWindow::setGeometry (int x, int y, std::size_t w, std::size_t h, bool adjust)
{
// Sets the geometry of the widget
int old_x = getX()
, old_y = getY()
, old_width = getWidth()
, old_height = getHeight();
int old_x = getX();
int old_y = getY();
std::size_t old_width = getWidth();
std::size_t old_height = getHeight();
if ( y < 1 )
y = 1;
@ -728,7 +720,7 @@ void FWindow::switchToPrevWindow()
updateTerminal (FVTerm::stop_refresh);
bool is_activated = activatePrevWindow();
FWindow* active_window = getActiveWindow();
FWindow* active_window = static_cast<FWindow*>(getActiveWindow());
if ( ! is_activated )
{

View File

@ -38,6 +38,10 @@ namespace fc
//----------------------------------------------------------------------
// class emptyFString
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class emptyFString
{
public:
@ -58,6 +62,7 @@ private:
// Data Member
static const FString* empty_string;
};
#pragma pack(pop)
// emptyFString inline functions
//----------------------------------------------------------------------

View File

@ -92,11 +92,7 @@ class FApplication : public FWidget
const char* getClassName() const;
int getArgc() const;
char** getArgv() const;
FWidget* getMainWidget() const;
virtual FWidget* getFocusWidget() const;
// Mutator
void setMainWidget (FWidget*);
static FWidget* getApplicationObject();
// Inquiry
static bool isQuit();
@ -193,28 +189,6 @@ class FApplication : public FWidget
static bool process_timer_event;
static FKeyboard* keyboard;
static FWidget* keyboard_widget;
static FWidget* move_size_widget;
static FWidget* main_widget;
static FWidget* active_window;
static FWidget* focus_widget;
static FWidget* clicked_widget;
static FWidget* open_menu;
// Friend functions from FWidget
friend FWidget* FWidget::getMainWidget();
friend FWidget* FWidget::getFocusWidget() const;
friend void FWidget::setFocusWidget (FWidget*);
friend FWidget* FWidget::getClickedWidget();
friend void FWidget::setClickedWidget (FWidget*);
friend FWidget* FWidget::getMoveSizeWidget();
friend void FWidget::setMoveSizeWidget (FWidget*);
friend FWidget* FWidget::getOpenMenu();
friend void FWidget::setOpenMenu (FWidget*);
// Friend functions from FWindow
friend bool FWindow::activateWindow (bool);
friend FWindow* FWindow::getActiveWindow();
friend void FWindow::unsetActiveWindow();
};
#pragma pack(pop)
@ -232,14 +206,6 @@ inline int FApplication::getArgc() const
inline char** FApplication::getArgv() const
{ return app_argv; }
//----------------------------------------------------------------------
inline FWidget* FApplication::getMainWidget() const
{ return main_widget; }
//----------------------------------------------------------------------
inline FWidget* FApplication::getFocusWidget() const
{ return focus_widget; }
//----------------------------------------------------------------------
inline void FApplication::cb_exitApp (FWidget*, data_ptr)
{ close(); }

View File

@ -130,6 +130,9 @@ class FButton : public FWidget
virtual void onFocusOut (FFocusEvent*);
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Disable copy constructor
FButton (const FButton&);
@ -142,8 +145,8 @@ class FButton : public FWidget
uChar getHotkey();
void setHotkeyAccelerator();
void detectHotkey();
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
int clickAnimationIndent (FWidget*);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
std::size_t clickAnimationIndent (FWidget*);
void clearRightMargin (FWidget*);
void drawMarginLeft();
void drawMarginRight();
@ -159,12 +162,12 @@ class FButton : public FWidget
bool button_down;
bool click_animation;
int click_time;
int indent;
int space;
int center_offset;
int vcenter_offset;
int txtlength;
int hotkeypos;
int space_char;
std::size_t hotkeypos;
std::size_t indent;
std::size_t center_offset;
std::size_t vcenter_offset;
std::size_t txtlength;
short button_fg;
short button_bg;
short button_hotkey_fg;

View File

@ -83,7 +83,7 @@ class FButtonGroup : public FScrollView
FToggleButton* getFirstButton();
FToggleButton* getLastButton();
FToggleButton* getButton (int) const;
uInt getCount() const;
std::size_t getCount() const;
FString& getText();
// Mutator
@ -125,6 +125,9 @@ class FButtonGroup : public FScrollView
void drawLabel();
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Disable copy constructor
FButtonGroup (const FButtonGroup&);
@ -136,8 +139,8 @@ class FButtonGroup : public FScrollView
// Methods
void init();
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
void drawText (wchar_t[], int, uInt);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
void drawText (wchar_t[], std::size_t, std::size_t);
void directFocus();
// Data Members
@ -165,8 +168,8 @@ inline bool FButtonGroup::setDisable()
{ return setEnable(false); }
//----------------------------------------------------------------------
inline uInt FButtonGroup::getCount() const
{ return uInt(buttonlist.size()); }
inline std::size_t FButtonGroup::getCount() const
{ return buttonlist.size(); }
//----------------------------------------------------------------------
inline FString& FButtonGroup::getText()

View File

@ -117,14 +117,14 @@ class FDialog : public FWindow
// Methods
virtual void show();
virtual void hide();
int exec();
DialogCode exec();
virtual void setPos (int, int, bool = true);
virtual void move (int, int);
bool moveUp (int);
bool moveDown (int);
bool moveLeft (int);
bool moveRight (int);
virtual void setSize (int, int, bool = true);
virtual void setSize (std::size_t, std::size_t, bool = true);
bool reduceHeight (int);
bool expandHeight (int);
bool reduceWidth (int);
@ -145,7 +145,7 @@ class FDialog : public FWindow
protected:
// Methods
virtual void done (int);
virtual void done (DialogCode);
virtual void draw();
void drawDialogShadow();
@ -161,12 +161,12 @@ class FDialog : public FWindow
int mouse_x;
int mouse_y;
FPoint termPos;
int zoom_btn;
std::size_t zoom_btn;
bool mouse_over_menu;
} mouseStates;
// Constant
static const int MENU_BTN = 3;
static const std::size_t MENU_BTN = 3;
static const bool PRINT_WIN_NUMBER = false; // Only for debug
// Using-declaration
@ -197,7 +197,7 @@ class FDialog : public FWindow
void openMenu();
void selectFirstMenuItem();
void setZoomItem();
int getZoomButtonWidth();
std::size_t getZoomButtonWidth();
void activateZoomButton (mouseStates&);
void deactivateZoomButton();
void leaveZoomButton (mouseStates&);
@ -223,7 +223,7 @@ class FDialog : public FWindow
// Data Members
FString tb_text; // title bar text
int result_code;
DialogCode result_code;
bool zoom_button_pressed;
bool zoom_button_active;
bool setPos_error;

View File

@ -83,6 +83,12 @@ class FKeyboardCommand
class FKeyboard
{
public:
// Constants
static const std::size_t FIFO_BUF_SIZE = 512;
// Typedef
typedef char keybuffer[FIFO_BUF_SIZE];
// Constructor
FKeyboard();
@ -93,8 +99,7 @@ class FKeyboard
virtual const char* getClassName() const;
int getKey();
const FString getKeyName (int);
char* getKeyBuffer();
int getKeyBufferSize();
keybuffer& getKeyBuffer();
timeval* getKeyPressedTime();
// Mutators
@ -127,6 +132,7 @@ class FKeyboard
private:
// Constants
static const int NEED_MORE_DATA = -1;
static const std::size_t READ_BUF_SIZE = 1024;
// Disable copy constructor
FKeyboard (const FKeyboard&);
@ -161,11 +167,10 @@ class FKeyboard
// Data Members
int key;
char k_buf[1024];
char fifo_buf[512];
char read_buf[READ_BUF_SIZE];
char fifo_buf[FIFO_BUF_SIZE];
int fifo_offset;
bool fifo_in_use;
int fifo_buf_size;
int stdin_status_flags;
static long key_timeout;
bool input_data_pending;
@ -195,12 +200,9 @@ inline const char* FKeyboard::getClassName() const
inline int FKeyboard::getKey()
{ return key; }
inline char* FKeyboard::getKeyBuffer()
{ return fifo_buf; }
//----------------------------------------------------------------------
inline int FKeyboard::getKeyBufferSize()
{ return fifo_buf_size; }
inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
{ return fifo_buf; }
//----------------------------------------------------------------------
inline timeval* FKeyboard::getKeyPressedTime()

View File

@ -131,6 +131,9 @@ class FLabel : public FWidget
void cb_accel_widget_destroyed (FWidget*, data_ptr);
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Disable copy constructor
FLabel (const FLabel&);
@ -140,13 +143,14 @@ class FLabel : public FWidget
// Methods
void init();
uChar getHotkey();
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
void setHotkeyAccelerator();
int getAlignOffset (int);
std::size_t getAlignOffset (std::size_t);
virtual void draw();
void drawMultiLine();
void drawSingleLine();
void printLine (wchar_t[], uInt, int, int = 0);
void printLine ( wchar_t[], std::size_t
, std::size_t, std::size_t = 0 );
// Data Members
FStringList multiline_text;

View File

@ -178,8 +178,8 @@ class FLineEdit : public FWidget
bool scroll_timer;
int scroll_repeat;
bool insert_mode;
int cursor_pos;
int text_offset;
std::size_t cursor_pos;
std::size_t text_offset;
};
#pragma pack(pop)

View File

@ -147,9 +147,9 @@ class FListBox : public FWidget
// Constructor
explicit FListBox (FWidget* = 0);
template <class Iterator, class InsertConverter>
template <typename Iterator, typename InsertConverter>
FListBox (Iterator, Iterator, InsertConverter, FWidget* = 0);
template <class Container, class LazyConverter>
template <typename Container, typename LazyConverter>
FListBox (Container, LazyConverter, FWidget* = 0);
// Destructor
@ -157,23 +157,23 @@ class FListBox : public FWidget
// Accessors
const char* getClassName() const;
uInt getCount() const;
FListBoxItem getItem (int);
std::size_t getCount() const;
FListBoxItem getItem (std::size_t);
FListBoxItem getItem (listBoxItems::iterator) const;
int currentItem() const;
std::size_t currentItem() const;
FString& getText();
// Mutators
void setCurrentItem (int);
void setCurrentItem (std::size_t);
void setCurrentItem (listBoxItems::iterator);
void selectItem (int);
void selectItem (std::size_t);
void selectItem (listBoxItems::iterator);
void unselectItem (int);
void unselectItem (std::size_t);
void unselectItem (listBoxItems::iterator);
void showInsideBrackets (int, fc::brackets_type);
void showNoBrackets (int);
void showInsideBrackets (std::size_t, fc::brackets_type);
void showNoBrackets (std::size_t);
void showNoBrackets (listBoxItems::iterator);
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
void setMultiSelection (bool);
void setMultiSelection ();
void unsetMultiSelection ();
@ -184,17 +184,17 @@ class FListBox : public FWidget
void setText (const FString&);
// Inquiries
bool isSelected (int);
bool isSelected (std::size_t);
bool isSelected (listBoxItems::iterator) const;
bool isMultiSelection() const;
bool hasBrackets (int);
bool hasBrackets (std::size_t);
bool hasBrackets (listBoxItems::iterator) const;
// Methods
virtual void hide();
template <class Iterator, class InsertConverter>
template <typename Iterator, typename InsertConverter>
void insert (Iterator, Iterator, InsertConverter);
template <class Container, class LazyConverter>
template <typename Container, typename LazyConverter>
void insert (Container, LazyConverter);
void insert (FListBoxItem);
void insert ( const FString&
@ -205,7 +205,7 @@ class FListBox : public FWidget
, fc::brackets_type = fc::NoBrackets
, bool = false
, data_ptr = 0 );
void remove (int);
void remove (std::size_t);
void clear();
// Event handlers
@ -254,11 +254,11 @@ class FListBox : public FWidget
void setLineAttributes (int, bool, bool, bool&);
void unsetAttributes();
void updateDrawing (bool, bool);
void recalculateHorizontalBar (int, bool);
void recalculateVerticalBar (int);
void recalculateHorizontalBar (std::size_t, bool);
void recalculateVerticalBar (std::size_t);
void getWidgetFocus();
void multiSelection (int);
void multiSelectionUpTo (int);
void multiSelection (std::size_t);
void multiSelectionUpTo (std::size_t);
void wheelUp (int);
void wheelDown (int);
bool dragScrollUp();
@ -290,7 +290,7 @@ class FListBox : public FWidget
void processSelect();
void processChanged();
void lazyConvert (listBoxItems::iterator, int);
listBoxItems::iterator index2iterator (int);
listBoxItems::iterator index2iterator (std::size_t);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
@ -315,21 +315,21 @@ class FListBox : public FWidget
bool scroll_timer;
int scroll_repeat;
int scroll_distance;
int current;
std::size_t current;
int last_current;
int secect_from_item;
int xoffset;
int yoffset;
int last_yoffset;
int nf_offset;
int max_line_width;
std::size_t nf_offset;
std::size_t max_line_width;
};
#pragma pack(pop)
// FListBox inline functions
//----------------------------------------------------------------------
template <class Iterator, class InsertConverter>
template <typename Iterator, typename InsertConverter>
inline FListBox::FListBox ( Iterator first
, Iterator last
, InsertConverter convert
@ -368,7 +368,7 @@ inline FListBox::FListBox ( Iterator first
}
//----------------------------------------------------------------------
template <class Container, class LazyConverter>
template <typename Container, typename LazyConverter>
inline FListBox::FListBox ( Container container
, LazyConverter convert
, FWidget* parent )
@ -405,11 +405,11 @@ inline const char* FListBox::getClassName() const
{ return "FListBox"; }
//----------------------------------------------------------------------
inline uInt FListBox::getCount() const
{ return uInt(itemlist.size()); }
inline std::size_t FListBox::getCount() const
{ return itemlist.size(); }
//----------------------------------------------------------------------
inline FListBoxItem FListBox::getItem (int index)
inline FListBoxItem FListBox::getItem (std::size_t index)
{
listBoxItems::iterator iter = index2iterator(index - 1);
return *iter;
@ -420,7 +420,7 @@ inline FListBoxItem FListBox::getItem (listBoxItems::iterator iter) const
{ return *iter; }
//----------------------------------------------------------------------
inline int FListBox::currentItem() const
inline std::size_t FListBox::currentItem() const
{ return current; }
//----------------------------------------------------------------------
@ -428,7 +428,7 @@ inline FString& FListBox::getText()
{ return text; }
//----------------------------------------------------------------------
inline void FListBox::selectItem (int index)
inline void FListBox::selectItem (std::size_t index)
{ index2iterator(index - 1)->selected = true; }
//----------------------------------------------------------------------
@ -436,7 +436,7 @@ inline void FListBox::selectItem (listBoxItems::iterator iter)
{ iter->selected = true; }
//----------------------------------------------------------------------
inline void FListBox::unselectItem (int index)
inline void FListBox::unselectItem (std::size_t index)
{ index2iterator(index - 1)->selected = false; }
//----------------------------------------------------------------------
@ -444,7 +444,7 @@ inline void FListBox::unselectItem (listBoxItems::iterator iter)
{ iter->selected = false; }
//----------------------------------------------------------------------
inline void FListBox::showNoBrackets (int index)
inline void FListBox::showNoBrackets (std::size_t index)
{ index2iterator(index - 1)->brackets = fc::NoBrackets; }
//----------------------------------------------------------------------
@ -476,7 +476,7 @@ inline bool FListBox::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FListBox::isSelected (int index)
inline bool FListBox::isSelected (std::size_t index)
{ return index2iterator(index - 1)->selected; }
//----------------------------------------------------------------------
@ -488,7 +488,7 @@ inline bool FListBox::isMultiSelection() const
{ return multi_select; }
//----------------------------------------------------------------------
inline bool FListBox::hasBrackets(int index)
inline bool FListBox::hasBrackets(std::size_t index)
{ return bool(index2iterator(index - 1)->brackets > 0); }
//----------------------------------------------------------------------
@ -496,7 +496,7 @@ inline bool FListBox::hasBrackets(listBoxItems::iterator iter) const
{ return bool(iter->brackets > 0); }
//----------------------------------------------------------------------
template <class Iterator, class InsertConverter>
template <typename Iterator, typename InsertConverter>
inline void FListBox::insert ( Iterator first
, Iterator last
, InsertConverter convert )
@ -511,7 +511,7 @@ inline void FListBox::insert ( Iterator first
}
//----------------------------------------------------------------------
template <class Container, class LazyConverter>
template <typename Container, typename LazyConverter>
void FListBox::insert (Container container, LazyConverter convert)
{
conv_type = lazy_convert;
@ -522,11 +522,11 @@ void FListBox::insert (Container container, LazyConverter convert)
if ( size > 0 )
itemlist.resize(size);
recalculateVerticalBar(int(size));
recalculateVerticalBar(size);
}
//----------------------------------------------------------------------
inline FListBox::listBoxItems::iterator FListBox::index2iterator (int index)
inline FListBox::listBoxItems::iterator FListBox::index2iterator (std::size_t index)
{
listBoxItems::iterator iter = itemlist.begin();
std::advance (iter, index);

View File

@ -119,14 +119,14 @@ class FListViewItem : public FObject
void sort (Compare);
FObjectIterator appendItem (FListViewItem*);
void replaceControlCodes();
int getVisibleLines();
std::size_t getVisibleLines();
void resetVisibleLineCounter();
// Data Members
FStringList column_list;
FWidget::data_ptr data_pointer;
FObjectIterator root;
int visible_lines;
std::size_t visible_lines;
bool expandable;
bool is_expand;
@ -260,7 +260,7 @@ class FListView : public FWidget
// Accessors
const char* getClassName() const;
uInt getCount();
std::size_t getCount();
fc::text_alignment getColumnAlignment (int) const;
FString getColumnText (int) const;
fc::sorting_type getColumnSortType (int) const;
@ -269,7 +269,7 @@ class FListView : public FWidget
FListViewItem* getCurrentItem();
// Mutators
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
void setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&);
void setColumnSortType (int,fc::sorting_type \
@ -344,13 +344,15 @@ class FListView : public FWidget
void init();
template <typename Compare>
void sort (Compare);
uInt getAlignOffset (fc::text_alignment, uInt, uInt);
std::size_t getAlignOffset ( fc::text_alignment
, std::size_t
, std::size_t );
virtual void draw();
void drawColumnLabels();
void drawList();
void drawListLine (const FListViewItem*, bool, bool);
void setLineAttributes (bool, bool);
FString getLinePrefix (const FListViewItem*, uInt);
FString getLinePrefix (const FListViewItem*, std::size_t);
void drawColumnText (headerItems::const_iterator&);
void drawColumnEllipsis ( headerItems::const_iterator&
, const FString& );

View File

@ -124,6 +124,9 @@ class FMenu : public FWindow, public FMenuList
void cb_menuitem_toggled (FWidget*, data_ptr);
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Typedef
typedef struct
{
@ -139,8 +142,8 @@ class FMenu : public FWindow, public FMenuList
typedef struct
{
wchar_t* text;
int length;
int hotkeypos;
std::size_t length;
std::size_t hotkeypos;
bool no_underline;
} menuText;
@ -199,16 +202,16 @@ class FMenu : public FWindow, public FMenuList
bool selectPrevItem();
void keypressMenuBar (FKeyEvent*);
bool hotkeyMenu (FKeyEvent*);
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
virtual void draw();
void drawItems();
void drawSeparator (int);
void drawMenuLine (FMenuItem*, int);
void drawCheckMarkPrefix (FMenuItem*);
void drawMenuText (menuText&);
void drawSubMenuIndicator (int&);
void drawAcceleratorKey (int&, int);
void drawTrailingSpaces (int);
void drawSubMenuIndicator (std::size_t&);
void drawAcceleratorKey (std::size_t&, int);
void drawTrailingSpaces (std::size_t);
void setLineAttributes (FMenuItem*, int);
void setCursorToHotkeyPosition (FMenuItem*);
void keyUp();
@ -232,8 +235,8 @@ class FMenu : public FWindow, public FMenuList
FWidget* super_menu;
FMenu* opened_sub_menu;
FMenu* shown_sub_menu;
uInt max_item_width;
int hotkeypos;
std::size_t max_item_width;
std::size_t hotkeypos;
bool mouse_down;
bool has_checkable_items;
};

View File

@ -101,13 +101,16 @@ class FMenuBar : public FWindow, public FMenuList
void cb_item_deactivated (FWidget*, data_ptr);
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Typedef
typedef struct
{
wchar_t* text;
int length;
int startpos;
int hotkeypos;
std::size_t length;
std::size_t startpos;
std::size_t hotkeypos;
bool no_underline;
} menuText;
@ -126,15 +129,15 @@ class FMenuBar : public FWindow, public FMenuList
bool selectNextItem();
bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
virtual void draw();
void drawItems();
void drawItem (FMenuItem*, int&);
void drawItem (FMenuItem*, std::size_t&);
void setLineAttributes (FMenuItem*);
void drawMenuText (menuText&);
void drawEllipsis (menuText&, int);
void drawLeadingSpace (int&);
void drawTrailingSpace (int&);
void drawEllipsis (menuText&, std::size_t);
void drawLeadingSpace (std::size_t&);
void drawTrailingSpace (std::size_t&);
void adjustItems();
bool activateMenu (FMenuItem*);
bool clickItem (FMenuItem*);
@ -154,7 +157,7 @@ class FMenuBar : public FWindow, public FMenuList
bool mouse_down;
bool drop_down;
bool focus_changed;
int screenWidth;
std::size_t screenWidth;
};
#pragma pack(pop)

View File

@ -93,7 +93,7 @@ class FMenuItem : public FWidget
const char* getClassName() const;
int getHotkey() const;
FMenu* getMenu() const;
uInt getTextLength() const;
std::size_t getTextLength() const;
FString getText() const;
// Mutators
@ -152,7 +152,7 @@ class FMenuItem : public FWidget
bool checked;
bool radio_button;
bool dialog_index;
uInt text_length;
std::size_t text_length;
int hotkey;
int accel_key;
FMenu* menu;
@ -166,13 +166,16 @@ class FMenuItem : public FWidget
// Disable assignment operator (=)
FMenuItem& operator = (const FMenuItem&);
// Accessor
FMenuList* getFMenuList (FWidget&);
// Methods
void init (FWidget*);
uChar hotKey();
void processActivate();
void processDeactivate();
void createDialogList (FMenu*);
template<class T>
template <typename T>
void passMouseEvent (T, FMouseEvent*, fc::events);
// Callback methods
@ -204,7 +207,7 @@ inline FMenu* FMenuItem::getMenu() const
{ return menu; }
//----------------------------------------------------------------------
inline uInt FMenuItem::getTextLength() const
inline std::size_t FMenuItem::getTextLength() const
{ return text_length; }
//----------------------------------------------------------------------

View File

@ -69,7 +69,7 @@ class FMenuList
// Accessors
virtual const char* getClassName() const;
uInt getCount() const;
std::size_t getCount() const;
FMenuItem* getItem (int) const;
FMenuItem* getSelectedItem() const;
@ -110,8 +110,8 @@ inline const char* FMenuList::getClassName() const
{ return "FMenuList"; }
//----------------------------------------------------------------------
inline uInt FMenuList::getCount() const
{ return uInt(item_list.size()); }
inline std::size_t FMenuList::getCount() const
{ return item_list.size(); }
//----------------------------------------------------------------------
inline FMenuItem* FMenuList::getItem (int index) const

View File

@ -82,7 +82,7 @@ class FMessageBox : public FDialog
{
public:
// Enumeration
enum
enum ButtonType
{
Reject = 0,
Ok = 1,
@ -163,7 +163,7 @@ class FMessageBox : public FDialog
FString text;
FString* text_components;
FStringList text_split;
uInt max_line_width;
std::size_t max_line_width;
bool center_text;
short emphasis_color;
uInt num_buttons;

View File

@ -64,6 +64,7 @@
#include <map>
#include "final/fconfig.h"
#include "final/fkeyboard.h"
#include "final/fpoint.h"
#include "final/ftypes.h"
@ -73,7 +74,6 @@
#ifdef F_HAVE_LIBGPM
#include <gpm.h>
#undef buttons // from term.h
#endif
namespace finalcut
@ -136,7 +136,7 @@ class FMouse
// Methods
static FMouse* createMouseObject (mouse_type);
virtual void setRawData (char[], int) = 0;
virtual void setRawData (FKeyboard::keybuffer&) = 0;
virtual void processEvent (struct timeval*) = 0;
protected:
@ -212,7 +212,7 @@ class FMouseGPM : public FMouse
bool isGpmMouseEnabled();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
bool gpmMouse (bool);
bool enableGpmMouse();
@ -277,7 +277,7 @@ class FMouseX11 : public FMouse
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
private:
@ -340,7 +340,7 @@ class FMouseSGR : public FMouse
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
private:
@ -403,7 +403,7 @@ class FMouseUrxvt : public FMouse
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
private:
@ -493,8 +493,8 @@ class FMouseControl
// Methods
void enable();
void disable();
virtual void setRawData (FMouse::mouse_type, char[], int);
virtual void setRawData ( FMouse::mouse_type
, FKeyboard::keybuffer& );
virtual void processEvent (struct timeval* time);
bool getGpmKeyPressed (bool);
void drawGpmPointer();

View File

@ -138,7 +138,7 @@ class FOptiMove
// Mutators
void setBaudRate (int);
void setTabStop (int);
void setTermSize (int, int);
void setTermSize (std::size_t, std::size_t);
void setTermEnvironment (termEnv&);
void set_cursor_home (char[]);
void set_cursor_to_ll (char[]);
@ -237,8 +237,8 @@ class FOptiMove
int char_duration;
int baudrate;
int tabstop;
int screen_width;
int screen_height;
std::size_t screen_width;
std::size_t screen_height;
};
#pragma pack(pop)

View File

@ -63,11 +63,11 @@ class FPoint
FPoint& operator += (const FPoint&);
FPoint& operator -= (const FPoint&);
friend inline bool operator == (const FPoint&, const FPoint&);
friend inline bool operator != (const FPoint&, const FPoint&);
friend inline FPoint operator + (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&);
friend bool operator == (const FPoint&, const FPoint&);
friend bool operator != (const FPoint&, const FPoint&);
friend FPoint operator + (const FPoint&, const FPoint&);
friend FPoint operator - (const FPoint&, const FPoint&);
friend FPoint operator - (const FPoint&);
friend std::ostream& operator << (std::ostream&, const FPoint&);
friend std::istream& operator >> (std::istream&, FPoint&);

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2014-2017 Markus Gans *
* Copyright 2014-2018 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -78,11 +78,11 @@ class FProgressbar : public FWidget
// Accessors
const char* getClassName() const;
int getPercentage();
std::size_t getPercentage();
// Mutators
void setPercentage (int);
virtual void setGeometry (int, int, int, int, bool = true);
void setPercentage (std::size_t);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
bool setShadow (bool);
bool setShadow();
bool unsetShadow();
@ -95,14 +95,17 @@ class FProgressbar : public FWidget
void reset();
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Methods
virtual void draw();
void drawPercentage();
void drawBar();
// Data Members
int percentage;
int bar_length;
std::size_t percentage;
std::size_t bar_length;
};
#pragma pack(pop)
@ -113,7 +116,7 @@ inline const char* FProgressbar::getClassName() const
{ return "FProgressbar"; }
//----------------------------------------------------------------------
inline int FProgressbar::getPercentage()
inline std::size_t FProgressbar::getPercentage()
{ return percentage; }
//----------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ class FRect
// Constructors
FRect ();
FRect (const FRect&); // copy constructor
FRect (int, int, int, int);
FRect (int, int, std::size_t, std::size_t);
FRect (const FPoint&, const FPoint&);
// Destructor
@ -83,8 +83,8 @@ class FRect
FPoint getUpperRightPos() const;
FPoint getLowerLeftPos() const;
FPoint getLowerRightPos() const;
int getWidth() const;
int getHeight() const;
std::size_t getWidth() const;
std::size_t getHeight() const;
// Mutators
void setX1 (int);
@ -95,11 +95,11 @@ class FRect
void setY (int);
void setPos (int, int);
void setPos (const FPoint&);
void setWidth (int);
void setHeight (int);
void setSize (int, int);
void setWidth (std::size_t);
void setHeight (std::size_t);
void setSize (std::size_t, std::size_t);
void setRect (const FRect&);
void setRect (int, int, int, int);
void setRect (int, int, std::size_t, std::size_t);
void setCoordinates (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int);
@ -150,11 +150,11 @@ inline FRect::FRect (const FRect& r) // copy constructor
{ }
//----------------------------------------------------------------------
inline FRect::FRect (int x, int y, int width, int height)
inline FRect::FRect (int x, int y, std::size_t width, std::size_t height)
: X1(short(x))
, Y1(short(y))
, X2(short(x + width - 1))
, Y2(short(y + height - 1))
, X2(short(x + short(width) - 1))
, Y2(short(y + short(height) - 1))
{ }
//----------------------------------------------------------------------
@ -206,12 +206,18 @@ inline FPoint FRect::getLowerRightPos() const
{ return FPoint(X2, Y2); }
//----------------------------------------------------------------------
inline int FRect::getWidth() const
{ return short(X2 - X1 + 1); }
inline std::size_t FRect::getWidth() const
{
short w = X2 - X1 + 1;
return ( w < 0 ) ? 0 : std::size_t(w);
}
//----------------------------------------------------------------------
inline int FRect::getHeight() const
{ return short(Y2 - Y1 + 1); }
inline std::size_t FRect::getHeight() const
{
short h = Y2 - Y1 + 1;
return ( h < 0 ) ? 0 : std::size_t(h);
}
//----------------------------------------------------------------------
inline short& FRect::x1_ref()

View File

@ -103,7 +103,7 @@ class FScrollbar : public FWidget
void setSteps (double);
void setPageSize (int, int);
void setOrientation (int);
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
// Methods
virtual void resize();
@ -149,14 +149,14 @@ class FScrollbar : public FWidget
int slider_click_stop_pos;
int current_slider_pos;
int slider_pos;
int slider_length;
int bar_length;
std::size_t slider_length;
std::size_t bar_length;
int val;
int min;
int max;
double steps;
int pagesize;
int length;
std::size_t length;
int bar_orientation;
int max_color;
};

View File

@ -82,25 +82,25 @@ class FScrollView : public FWidget
// Accessors
const char* getClassName() const;
int getViewportWidth() const;
int getViewportHeight() const;
int getScrollWidth() const;
int getScrollHeight() const;
std::size_t getViewportWidth() const;
std::size_t getViewportHeight() const;
std::size_t getScrollWidth() const;
std::size_t getScrollHeight() const;
const FPoint getScrollPos() const;
int getScrollX() const;
int getScrollY() const;
// Mutator
virtual void setScrollWidth (int);
virtual void setScrollHeight (int);
virtual void setScrollSize (int, int);
virtual void setScrollWidth (std::size_t);
virtual void setScrollHeight (std::size_t);
virtual void setScrollSize (std::size_t, std::size_t);
virtual void setX (int, bool = true);
virtual void setY (int, bool = true);
virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setWidth (std::size_t, bool = true);
virtual void setHeight (std::size_t, bool = true);
virtual void setSize (std::size_t, std::size_t, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
void setCursorPos (int, int);
void setPrintPos (int, int);
bool setViewportPrint (bool);
@ -179,7 +179,7 @@ class FScrollView : public FWidget
term_area* viewport; // virtual scroll content
FScrollbar* vbar;
FScrollbar* hbar;
int nf_offset;
uInt8 nf_offset;
bool border;
bool use_own_print_area;
bool update_scrollbar;
@ -195,19 +195,19 @@ inline const char* FScrollView::getClassName() const
{ return "FScrollView"; }
//----------------------------------------------------------------------
inline int FScrollView::getViewportWidth() const
{ return getWidth() - vertical_border_spacing - nf_offset; }
inline std::size_t FScrollView::getViewportWidth() const
{ return getWidth() - vertical_border_spacing - std::size_t(nf_offset); }
//----------------------------------------------------------------------
inline int FScrollView::getViewportHeight() const
inline std::size_t FScrollView::getViewportHeight() const
{ return getHeight() - horizontal_border_spacing; }
//----------------------------------------------------------------------
inline int FScrollView::getScrollWidth() const
inline std::size_t FScrollView::getScrollWidth() const
{ return scroll_geometry.getWidth(); }
//----------------------------------------------------------------------
inline int FScrollView::getScrollHeight() const
inline std::size_t FScrollView::getScrollHeight() const
{ return scroll_geometry.getHeight(); }
//----------------------------------------------------------------------

View File

@ -203,7 +203,7 @@ class FStatusBar : public FWindow
virtual const char* getClassName() const;
FStatusKey* getStatusKey (int) const;
FString getMessage() const;
uInt getCount() const;
std::size_t getCount() const;
// Mutators
void activateKey (int);
@ -253,7 +253,7 @@ class FStatusBar : public FWindow
keyList key_list;
FString text;
bool mouse_down;
int screenWidth;
std::size_t screenWidth;
int keyname_len;
int x;
int x_msg;
@ -271,8 +271,8 @@ inline FStatusKey* FStatusBar::getStatusKey (int index) const
{ return key_list[uInt(index - 1)]; }
//----------------------------------------------------------------------
inline uInt FStatusBar::getCount() const
{ return uInt(key_list.size()); }
inline std::size_t FStatusBar::getCount() const
{ return key_list.size(); }
//----------------------------------------------------------------------
inline void FStatusBar::activateKey (int index)

View File

@ -71,6 +71,9 @@ typedef std::vector<FString> FStringList;
// class FString
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FString
{
public:
@ -80,11 +83,9 @@ class FString
// Constructors
FString ();
explicit FString (int);
explicit FString (uInt);
FString (int, wchar_t);
FString (uInt, wchar_t);
FString (int, char);
FString (uInt, char);
explicit FString (std::size_t);
FString (std::size_t, wchar_t);
FString (std::size_t, char);
FString (const FString&); // implicit conversion copy constructor
FString (const std::wstring&); // implicit conversion constructor
FString (const wchar_t[]); // implicit conversion constructor
@ -132,8 +133,10 @@ class FString
const FString& operator >> (double&);
const FString& operator >> (float&);
wchar_t& operator [] (int);
wchar_t& operator [] (uInt);
template <typename IndexT>
wchar_t& operator [] (IndexT);
template <typename IndexT>
const wchar_t& operator [] (IndexT) const;
const FString& operator () ();
bool operator < (const FString&) const;
@ -181,8 +184,8 @@ class FString
bool isEmpty() const;
// Methods
uInt getLength() const;
uInt getUTF8length() const;
std::size_t getLength() const;
std::size_t getUTF8length() const;
iterator begin() const;
iterator end() const;
@ -214,12 +217,9 @@ class FString
FString rtrim() const;
FString trim() const;
FString left (int) const;
FString left (uInt) const;
FString right (int) const;
FString right (uInt) const;
FString mid (int, int) const;
FString mid (uInt, uInt) const;
FString left (std::size_t) const;
FString right (std::size_t) const;
FString mid (std::size_t, std::size_t) const;
FStringList split (const FString&);
FString& setString (const FString&);
@ -242,7 +242,7 @@ class FString
FString& setFormatedNumber (uLong, char = nl_langinfo(THOUSEP)[0]);
const FString& insert (const FString&, int);
const FString& insert (const FString&, uInt);
const FString& insert (const FString&, std::size_t);
FString replace (const FString&, const FString&);
@ -252,10 +252,9 @@ class FString
FString removeBackspaces() const;
const FString& overwrite (const FString&, int);
const FString& overwrite (const FString&, uInt = 0);
const FString& overwrite (const FString&, std::size_t = 0);
const FString& remove (int, uInt);
const FString& remove (uInt, uInt);
const FString& remove (std::size_t, std::size_t);
bool includes (const FString&) const;
private:
@ -266,22 +265,22 @@ class FString
static const char* const bad_alloc_str;
// Methods
void initLength (uInt);
void initLength (std::size_t);
void _assign (const wchar_t[]);
void _insert (uInt, const wchar_t[]);
void _insert (uInt, uInt, const wchar_t[]);
void _remove (uInt, uInt);
void _insert (std::size_t, const wchar_t[]);
void _insert (std::size_t, std::size_t, const wchar_t[]);
void _remove (std::size_t, std::size_t);
char* wc_to_c_str (const wchar_t[]) const;
wchar_t* c_to_wc_str (const char[]) const;
wchar_t* extractToken (wchar_t*[], const wchar_t[], const wchar_t[]);
// Data Members
wchar_t* string;
uInt length;
uInt bufsize;
std::size_t length;
std::size_t bufsize;
mutable char* c_string;
};
#pragma pack(pop)
// FString inline functions
//----------------------------------------------------------------------
@ -289,7 +288,27 @@ inline const char* FString::getClassName()
{ return "FString"; }
//----------------------------------------------------------------------
template <class CharT>
template <typename IndexT>
inline wchar_t& FString::operator [] (IndexT pos)
{
if ( pos < 0 || pos >= IndexT(length) )
throw std::out_of_range(""); // Invalid index position
return string[std::size_t(pos)];
}
//----------------------------------------------------------------------
template <typename IndexT>
inline const wchar_t& FString::operator [] (IndexT pos) const
{
if ( pos < 0 || pos >= IndexT(length) )
throw std::out_of_range(""); // Invalid index position
return string[std::size_t(pos)];
}
//----------------------------------------------------------------------
template <typename CharT>
inline bool FString::operator < (CharT& s) const
{
const FString tmp(s);
@ -297,7 +316,7 @@ inline bool FString::operator < (CharT& s) const
}
//----------------------------------------------------------------------
template <class CharT>
template <typename CharT>
inline bool FString::operator <= (CharT& s) const
{
const FString tmp(s);
@ -305,7 +324,7 @@ inline bool FString::operator <= (CharT& s) const
}
//----------------------------------------------------------------------
template <class CharT>
template <typename CharT>
inline bool FString::operator == (CharT& s) const
{
const FString tmp(s);
@ -313,7 +332,7 @@ inline bool FString::operator == (CharT& s) const
}
//----------------------------------------------------------------------
template <class CharT>
template <typename CharT>
inline bool FString::operator != (CharT& s) const
{
const FString tmp(s);
@ -321,7 +340,7 @@ inline bool FString::operator != (CharT& s) const
}
//----------------------------------------------------------------------
template <class CharT>
template <typename CharT>
inline bool FString::operator >= (CharT& s) const
{
const FString tmp(s);
@ -329,7 +348,7 @@ inline bool FString::operator >= (CharT& s) const
}
//----------------------------------------------------------------------
template <class CharT>
template <typename CharT>
inline bool FString::operator > (CharT& s) const
{
const FString tmp(s);
@ -345,7 +364,7 @@ inline bool FString::isEmpty() const
{ return ( ! string ) || ( ! *string ); }
//----------------------------------------------------------------------
inline uInt FString::getLength() const
inline std::size_t FString::getLength() const
{ return length; }
//----------------------------------------------------------------------

View File

@ -104,7 +104,7 @@ class FSwitch : public FToggleButton
void drawUnchecked();
// Data Members
int switch_offset_pos;
std::size_t switch_offset_pos;
bool button_pressed;
};
#pragma pack(pop)

View File

@ -103,26 +103,6 @@
#include <fcntl.h>
#include <langinfo.h>
#if defined(__sun) && defined(__SVR4)
#include <termio.h>
typedef struct termio SGTTY;
typedef struct termios SGTTYS;
#ifdef _LP64
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif // _LP64
#include <term.h> // termcap
#else
#include <term.h> // termcap
#endif // defined(__sun) && defined(__SVR4)
#ifdef F_HAVE_LIBGPM
#undef buttons // from term.h
#endif
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
#include <ttyent.h>
#endif
@ -151,13 +131,9 @@
#if defined(__linux__)
#include "final/ftermlinux.h"
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#include "final/ftermfreebsd.h"
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
#include "final/ftermopenbsd.h"
#endif
@ -190,8 +166,8 @@ class FTerm
virtual const char* getClassName() const;
static FKeyboard* getKeyboard();
static FMouseControl* getMouseControl();
static int getLineNumber();
static int getColumnNumber();
static std::size_t getLineNumber();
static std::size_t getColumnNumber();
static const FString getKeyName (int);
static int getTTYFileDescriptor();
@ -260,7 +236,7 @@ class FTerm
static char* enableCursor();
static char* disableCursor();
static void detectTermSize();
static void setTermSize (int, int);
static void setTermSize (std::size_t, std::size_t);
static void setTermTitle(const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap();
@ -336,9 +312,7 @@ class FTerm
#if defined(__FreeBSD__) || defined(__DragonFly__)
meta_sends_escape = true;
change_cursorstyle = true;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
meta_sends_escape = true;
#endif
}
@ -356,9 +330,7 @@ class FTerm
uInt8 meta_sends_escape : 1;
uInt8 change_cursorstyle : 1;
uInt8 : 6; // padding bits
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
uInt8 meta_sends_escape : 1;
uInt8 : 7; // padding bits
#endif
@ -382,15 +354,9 @@ class FTerm
static void init_fixed_max_color();
static void init_keyboard();
static void init_termcap();
static void init_termcap_error (int);
static void init_termcap_variables(char*&);
static void init_termcap_booleans();
static void init_termcap_numerics();
static void init_termcap_strings (char*&);
static void init_termcap_keys_vt100 (char*&);
static void init_termcap_keys (char*&);
static void init_OptiMove();
static void init_OptiAttr();
static void init_quirks();
static void init_optiMove();
static void init_optiAttr();
static void init_font();
static void init_locale();
static void init_encoding();
@ -401,12 +367,19 @@ class FTerm
static void init_utf8_without_alt_charset();
static void init_tab_quirks();
static void init_captureFontAndTitle();
static bool hasNoFontSettingOption();
static bool canChangeColorPalette();
static void redefineColorPalette();
static void restoreColorPalette();
static void setInsertCursorStyle();
static void setOverwriteCursorStyle();
static void enableMouse();
static void disableMouse();
static void enableApplicationEscKey();
static void disableApplicationEscKey();
static void enableKeypad();
static void disableKeypad();
static void enableAlternateCharset();
static void useAlternateScreenBuffer();
static void useNormalScreenBuffer();
void allocationValues();
@ -414,6 +387,7 @@ class FTerm
void init (bool);
void initOSspecifics();
void initTermspecifics();
void initBaudRate();
void finish();
void finishOSspecifics1();
void finish_encoding();
@ -435,13 +409,9 @@ class FTerm
#if defined(__linux__)
#undef linux
static FTermLinux* linux;
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
static FTermFreeBSD* freebsd;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
static FTermOpenBSD* openbsd;
#endif
};

View File

@ -65,14 +65,15 @@ class FTermBuffer
virtual ~FTermBuffer();
// Overloaded operators
template<class type> FTermBuffer& operator << (const type&);
template <typename type>
FTermBuffer& operator << (const type&);
// Non-member operators
friend std::vector<charData>& operator << ( std::vector<charData>&
, const FTermBuffer& );
// Accessors
virtual const char* getClassName() const;
int getLength() const;
std::size_t getLength() const;
// Inquiry
bool isEmpty() const;
@ -93,7 +94,7 @@ class FTermBuffer
// FTermBuffer inline functions
//----------------------------------------------------------------------
template<class type>
template <typename type>
inline FTermBuffer& FTermBuffer::operator << (const type& s)
{
std::wostringstream outstream;
@ -107,8 +108,8 @@ inline const char* FTermBuffer::getClassName() const
{ return "FTermBuffer"; }
//----------------------------------------------------------------------
inline int FTermBuffer::getLength() const
{ return int(data.size()); }
inline std::size_t FTermBuffer::getLength() const
{ return data.size(); }
//----------------------------------------------------------------------
inline bool FTermBuffer::isEmpty() const

View File

@ -35,10 +35,36 @@
#error "Only <final/final.h> can be included directly."
#endif
// FTermcap string macro
#define TCAP(s) tcap[(s)].string
#if defined(__sun) && defined(__SVR4)
#include <termio.h>
typedef struct termio SGTTY;
typedef struct termios SGTTYS;
#ifdef _LP64
typedef unsigned int chtype;
#else
typedef unsigned long chtype;
#endif // _LP64
#include <term.h> // termcap
#else
#include <term.h> // termcap
#endif // defined(__sun) && defined(__SVR4)
#ifdef F_HAVE_LIBGPM
#undef buttons // from term.h
#endif
#include <string>
#include <vector>
#include "final/emptyfstring.h"
#include "final/fkey_map.h"
#include "final/ftermdetection.h"
// FTermcap string macro
#define TCAP(s) tcap[(s)].string
namespace finalcut
{
@ -74,8 +100,16 @@ class FTermcap
return tcap;
}
// Mutator
static void setTermData (FTermData*);
static void setFTermDetection (FTermDetection*);
// Methods
static void init();
// Data Members
static bool background_color_erase;
static bool can_change_color_palette;
static bool automatic_left_margin;
static bool automatic_right_margin;
static bool eat_nl_glitch;
@ -87,8 +121,20 @@ class FTermcap
static int attr_without_color;
private:
// Methods
static void termcap();
static void termcapError (int);
static void termcapVariables (char*&);
static void termcapBoleans();
static void termcapNumerics();
static void termcapStrings (char*&);
static void termcapKeys (char*&);
static void termcapKeysVt100 (char*&);
// Data Member
static tcap_map tcap[];
static FTermData* fterm_data;
static FTermDetection* term_detection;
};
#pragma pack(pop)

View File

@ -73,18 +73,18 @@ class FTermcapQuirks
private:
// Methods
#if defined(__FreeBSD__) || defined(__DragonFly__)
static void init_termcap_freebsd_quirks();
static void freebsd();
#endif
static void init_termcap_cygwin_quirks();
static void init_termcap_linux_quirks();
static void init_termcap_xterm_quirks();
static void init_termcap_rxvt_quirks();
static void init_termcap_vte_quirks();
static void init_termcap_putty_quirks();
static void init_termcap_teraterm_quirks();
static void init_termcap_sun_quirks();
static void init_termcap_screen_quirks();
static void init_termcap_general_quirks();
static void cygwin();
static void linux();
static void xterm();
static void rxvt();
static void vte();
static void putty();
static void teraterm();
static void sunConsole();
static void screen();
static void general();
// Data Members
static FTermcap::tcap_map* tcap;

View File

@ -190,12 +190,14 @@ class FTermDetection
static char* secDA_Analysis_1 (char[]);
static char* secDA_Analysis_24 (char[]);
static char* secDA_Analysis_32 (char[]);
static char* secDA_Analysis_65 (char[]);
static char* secDA_Analysis_67 (char[]);
static char* secDA_Analysis_77 (char[]);
static char* secDA_Analysis_82 (char[]);
static char* secDA_Analysis_83 (char[]);
static char* secDA_Analysis_84 (char[]);
static char* secDA_Analysis_85 (char[]);
static char* secDA_Analysis_vte (char[]);
// Data Members
static char termtype[256];

View File

@ -65,7 +65,7 @@ class FTermXTerminal
static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&);
static void setTitle (const FString&);
static void setTermSize (int, int);
static void setTermSize (std::size_t, std::size_t);
static void setForeground (const FString&);
static void setBackground (const FString&);
static void setCursorColor (const FString&);
@ -139,8 +139,8 @@ class FTermXTerminal
static bool mouse_support;
static bool meta_sends_esc;
static bool xterm_default_colors;
static int term_width;
static int term_height;
static std::size_t term_width;
static std::size_t term_height;
static const FString* xterm_font;
static const FString* xterm_title;
static const FString* foreground_color;

View File

@ -84,13 +84,13 @@ class FTextView : public FWidget
// Accessors
const char* getClassName() const;
uInt getColumns() const;
uInt getRows() const;
std::size_t getColumns() const;
std::size_t getRows() const;
const FString getText() const;
const FStringList& getLines() const;
// Mutators
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
void setText (const FString&);
void scrollToX (int);
void scrollToY (int);
@ -128,8 +128,8 @@ class FTextView : public FWidget
FTextView& operator = (const FTextView&);
// Accessors
int getTextHeight();
int getTextWidth();
std::size_t getTextHeight();
std::size_t getTextWidth();
// Methods
void init();
@ -151,7 +151,7 @@ class FTextView : public FWidget
int xoffset;
int yoffset;
int nf_offset;
uInt maxLineWidth;
std::size_t maxLineWidth;
};
#pragma pack(pop)
@ -162,12 +162,12 @@ inline const char* FTextView::getClassName() const
{ return "FTextView"; }
//----------------------------------------------------------------------
inline uInt FTextView::getColumns() const
inline std::size_t FTextView::getColumns() const
{ return maxLineWidth; }
//----------------------------------------------------------------------
inline uInt FTextView::getRows() const
{ return uInt(data.size()); }
inline std::size_t FTextView::getRows() const
{ return std::size_t(data.size()); }
//----------------------------------------------------------------------
inline const FStringList& FTextView::getLines() const

View File

@ -85,7 +85,7 @@ class FToggleButton : public FWidget
FString& getText();
// Mutators
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
bool setNoUnderline (bool);
bool setNoUnderline();
bool unsetNoUnderline();
@ -139,10 +139,13 @@ class FToggleButton : public FWidget
// Data Members
bool checked;
int label_offset_pos;
int button_width; // plus margin spaces
std::size_t label_offset_pos;
std::size_t button_width; // plus margin spaces
private:
// Constants
static const std::size_t NOT_SET = static_cast<std::size_t>(-1);
// Disable copy constructor
FToggleButton (const FToggleButton&);
@ -154,8 +157,8 @@ class FToggleButton : public FWidget
// Methods
void init();
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
void drawText (wchar_t[], int, uInt);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
void drawText (wchar_t[], std::size_t , std::size_t);
// Friend classes
friend class FButtonGroup;

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2016-2017 Markus Gans *
* Copyright 2016-2018 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -112,8 +112,8 @@ class FToolTip : public FWindow
FString text;
FString* text_components;
FStringList text_split;
uInt max_line_width;
uInt text_num_lines;
std::size_t max_line_width;
std::size_t text_num_lines;
};
#pragma pack(pop)

View File

@ -56,6 +56,7 @@
#include "final/fterm.h"
// Preprocessing handler macro
#define F_PREPROC_HANDLER(i,h) \
static_cast<FVTerm*>((i)) \
@ -119,7 +120,8 @@ class FVTerm : public FTerm
virtual ~FVTerm();
// Overloaded operators
template<class type> FVTerm& operator << (const type&);
template <typename type>
FVTerm& operator << (const type&);
FVTerm& operator << (const std::vector<charData>&);
// Accessors
@ -283,8 +285,8 @@ class FVTerm : public FTerm
static void restoreVTerm (const FRect&);
static void restoreVTerm (int, int, int, int);
static void setTextToDefault (term_area*, int, int);
static bool reallocateTextArea (term_area*, int, int);
static bool reallocateTextArea (term_area*, int);
static bool reallocateTextArea (term_area*, std::size_t, std::size_t);
static bool reallocateTextArea (term_area*, std::size_t);
static covered_state isCovered ( const FPoint&
, term_area* );
@ -417,7 +419,6 @@ class FVTerm : public FTerm
#endif
static int appendOutputBuffer (int);
// Data Members
static std::queue<int>* output_buffer;
static charData term_attribute;
@ -503,7 +504,7 @@ struct FVTerm::term_area // define virtual terminal character properties
// FVTerm inline functions
//----------------------------------------------------------------------
template<class type>
template <typename type>
inline FVTerm& FVTerm::operator << (const type& s)
{
std::wostringstream outstream;

View File

@ -152,13 +152,14 @@ class FWidget : public FVTerm, public FObject
const char* getClassName() const;
FWidget* getRootWidget() const;
FWidget* getParentWidget() const;
static FWidget* getMainWidget();
virtual FWidget* getFocusWidget() const;
static FWidget*& getMainWidget();
static FWidget*& getActiveWindow();
static FWidget*& getFocusWidget();
static FWidget*& getClickedWidget();
static FWidget*& getOpenMenu();
static FWidget*& getMoveSizeWidget();
virtual FWidget* getFirstFocusableWidget (FObjectList);
virtual FWidget* getLastFocusableWidget (FObjectList);
static FWidget* getClickedWidget();
static FWidget* getMoveSizeWidget();
static FWidget* getOpenMenu();
static FMenuBar* getMenuBar();
static FStatusBar* getStatusBar();
FString getStatusbarMessage() const;
@ -170,23 +171,23 @@ class FWidget : public FVTerm, public FObject
int getTermX() const;
int getTermY() const;
const FPoint getTermPos() const;
int getWidth() const;
int getHeight() const;
std::size_t getWidth() const;
std::size_t getHeight() const;
int getTopPadding() const;
int getLeftPadding() const;
int getBottomPadding() const;
int getRightPadding() const;
int getClientWidth() const;
int getClientHeight() const;
int getMaxWidth() const;
int getMaxHeight() const;
std::size_t getClientWidth() const;
std::size_t getClientHeight() const;
std::size_t getMaxWidth() const;
std::size_t getMaxHeight() const;
const FPoint& getShadow() const;
const FRect& getGeometry() const;
const FRect& getGeometryWithShadow();
const FRect& getTermGeometry();
const FRect& getTermGeometryWithShadow();
int getDesktopWidth();
int getDesktopHeight();
std::size_t getDesktopWidth();
std::size_t getDesktopHeight();
int getFlags() const;
FPoint getCursorPos();
FPoint getPrintPos();
@ -194,9 +195,10 @@ class FWidget : public FVTerm, public FObject
// Mutators
static void setMainWidget (FWidget*);
virtual void setFocusWidget (FWidget*);
static void setFocusWidget (FWidget*);
static void setClickedWidget (FWidget*);
static void setMoveSizeWidget (FWidget*);
static void setActiveWindow (FWidget*);
static void setOpenMenu (FWidget*);
virtual void setStatusbarMessage (const FString&);
bool setVisible();
@ -222,9 +224,9 @@ class FWidget : public FVTerm, public FObject
virtual void setY (int, bool = true);
virtual void setPos (const FPoint&, bool = true);
virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true);
virtual void setWidth (std::size_t, bool = true);
virtual void setHeight (std::size_t, bool = true);
virtual void setSize (std::size_t, std::size_t, bool = true);
void setTopPadding (int, bool = true);
void setLeftPadding (int, bool = true);
void setBottomPadding (int, bool = true);
@ -232,17 +234,17 @@ class FWidget : public FVTerm, public FObject
void setParentOffset();
void setTermOffset();
void setTermOffsetWithPadding();
void setTermSize (int, int);
void setTermSize (std::size_t, std::size_t);
virtual void setGeometry (const FRect&, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, std::size_t, std::size_t, bool = true);
virtual void setShadowSize (int, int);
void setMinimumWidth (int);
void setMinimumHeight (int);
void setMinimumSize (int, int);
void setMaximumWidth (int);
void setMaximumHeight (int);
void setMaximumSize (int, int);
void setFixedSize (int, int);
void setMinimumWidth (std::size_t);
void setMinimumHeight (std::size_t);
void setMinimumSize (std::size_t, std::size_t);
void setMaximumWidth (std::size_t);
void setMaximumHeight (std::size_t);
void setMaximumSize (std::size_t, std::size_t);
void setFixedSize (std::size_t, std::size_t);
bool setCursorPos (const FPoint&);
bool setCursorPos (int, int);
void unsetCursorPos();
@ -414,8 +416,8 @@ class FWidget : public FVTerm, public FObject
struct widget_size_hints
{
widget_size_hints()
: min_width (INT_MIN)
, min_height (INT_MIN)
: min_width (0)
, min_height (0)
, max_width (INT_MAX)
, max_height (INT_MAX)
{ }
@ -423,22 +425,22 @@ class FWidget : public FVTerm, public FObject
~widget_size_hints()
{ }
void setMinimum (int w, int h)
void setMinimum (std::size_t w, std::size_t h)
{
min_width = w;
min_height = h;
}
void setMaximum (int w, int h)
void setMaximum (std::size_t w, std::size_t h)
{
max_width = w;
max_height = h;
}
int min_width;
int min_height;
int max_width;
int max_height;
std::size_t min_width;
std::size_t min_height;
std::size_t max_width;
std::size_t max_height;
} size_hints;
struct dbl_line_mask
@ -491,6 +493,12 @@ class FWidget : public FVTerm, public FObject
FString statusbar_message;
static FStatusBar* statusbar;
static FMenuBar* menubar;
static FWidget* main_widget;
static FWidget* active_window;
static FWidget* focus_widget;
static FWidget* clicked_widget;
static FWidget* open_menu;
static FWidget* move_size_widget;
static FWidget* show_root_widget;
static FWidget* redraw_root_widget;
static bool init_desktop;
@ -508,6 +516,38 @@ class FWidget : public FVTerm, public FObject
inline const char* FWidget::getClassName() const
{ return "FWidget"; }
//----------------------------------------------------------------------
inline FWidget*& FWidget::getMainWidget()
{ return main_widget; }
//----------------------------------------------------------------------
inline FWidget*& FWidget::getActiveWindow() // returns active FWindow object
{ return active_window; }
//----------------------------------------------------------------------
inline FWidget*& FWidget::getFocusWidget()
{ return focus_widget; }
//----------------------------------------------------------------------
inline FWidget*& FWidget::getClickedWidget()
{ return clicked_widget; }
//----------------------------------------------------------------------
inline FWidget*& FWidget::getOpenMenu()
{ return open_menu; }
//----------------------------------------------------------------------
inline FWidget*& FWidget::getMoveSizeWidget()
{ return move_size_widget; }
//----------------------------------------------------------------------
inline FMenuBar* FWidget::getMenuBar()
{ return menubar; }
//----------------------------------------------------------------------
inline FStatusBar* FWidget::getStatusBar()
{ return statusbar; }
//----------------------------------------------------------------------
inline FString FWidget::getStatusbarMessage() const
{ return statusbar_message; }
@ -545,11 +585,11 @@ inline const FPoint FWidget::getTermPos() const // position on terminal
{ return FPoint(getTermX(), getTermY()); }
//----------------------------------------------------------------------
inline int FWidget::getWidth() const
inline std::size_t FWidget::getWidth() const
{ return adjust_wsize.getWidth(); }
//----------------------------------------------------------------------
inline int FWidget::getHeight() const
inline std::size_t FWidget::getHeight() const
{ return adjust_wsize.getHeight(); }
//----------------------------------------------------------------------
@ -569,19 +609,19 @@ inline int FWidget::getRightPadding() const
{ return padding.right; }
//----------------------------------------------------------------------
inline int FWidget::getClientWidth() const
inline std::size_t FWidget::getClientWidth() const
{ return client_offset.getWidth(); }
//----------------------------------------------------------------------
inline int FWidget::getClientHeight() const
inline std::size_t FWidget::getClientHeight() const
{ return client_offset.getHeight(); }
//----------------------------------------------------------------------
inline int FWidget::getMaxWidth() const
inline std::size_t FWidget::getMaxWidth() const
{ return offset.getWidth(); }
//----------------------------------------------------------------------
inline int FWidget::getMaxHeight() const
inline std::size_t FWidget::getMaxHeight() const
{ return offset.getHeight(); }
//----------------------------------------------------------------------
@ -635,11 +675,11 @@ inline const FRect& FWidget::getTermGeometryWithShadow()
}
//----------------------------------------------------------------------
inline int FWidget::getDesktopWidth()
inline std::size_t FWidget::getDesktopWidth()
{ return getColumnNumber(); }
//----------------------------------------------------------------------
inline int FWidget::getDesktopHeight()
inline std::size_t FWidget::getDesktopHeight()
{ return getLineNumber(); }
//----------------------------------------------------------------------
@ -650,6 +690,30 @@ inline int FWidget::getFlags() const
inline FPoint FWidget::getCursorPos()
{ return widget_cursor_position; }
//----------------------------------------------------------------------
inline void FWidget::setActiveWindow (FWidget* obj)
{ active_window = obj; }
//----------------------------------------------------------------------
inline void FWidget::setFocusWidget (FWidget* obj)
{ focus_widget = obj; }
//----------------------------------------------------------------------
inline void FWidget::setClickedWidget (FWidget* obj)
{ clicked_widget = obj; }
//----------------------------------------------------------------------
inline void FWidget::setOpenMenu (FWidget* obj)
{ open_menu = obj; }
//----------------------------------------------------------------------
inline void FWidget::setMoveSizeWidget (FWidget* obj)
{ move_size_widget = obj; }
//----------------------------------------------------------------------
inline void FWidget::setStatusbarMessage (const FString& msg)
{ statusbar_message = msg; }
//----------------------------------------------------------------------
inline bool FWidget::setVisible()
{ return visible = true; }
@ -731,8 +795,8 @@ inline void FWidget::setGeometry (const FRect& box, bool adjust)
{
setGeometry ( box.getX()
, box.getY()
, box.getWidth()
, box.getHeight()
, std::size_t(box.getWidth())
, std::size_t(box.getHeight())
, adjust );
}
@ -741,31 +805,31 @@ inline void FWidget::setShadowSize (int right, int bottom)
{ wshadow.setPoint (right, bottom); }
//----------------------------------------------------------------------
inline void FWidget::setMinimumWidth (int min_width)
inline void FWidget::setMinimumWidth (std::size_t min_width)
{ size_hints.setMinimum (min_width, size_hints.min_height); }
//----------------------------------------------------------------------
inline void FWidget::setMinimumHeight (int min_height)
inline void FWidget::setMinimumHeight (std::size_t min_height)
{ size_hints.setMinimum (size_hints.min_width, min_height); }
//----------------------------------------------------------------------
inline void FWidget::setMinimumSize (int min_width, int min_height)
inline void FWidget::setMinimumSize (std::size_t min_width, std::size_t min_height)
{ size_hints.setMinimum (min_width, min_height); }
//----------------------------------------------------------------------
inline void FWidget::setMaximumWidth (int max_width)
inline void FWidget::setMaximumWidth (std::size_t max_width)
{ size_hints.setMaximum (max_width, size_hints.max_height); }
//----------------------------------------------------------------------
inline void FWidget::setMaximumHeight (int max_height)
inline void FWidget::setMaximumHeight (std::size_t max_height)
{ size_hints.setMaximum (size_hints.max_width, max_height); }
//----------------------------------------------------------------------
inline void FWidget::setMaximumSize (int max_width, int max_height)
inline void FWidget::setMaximumSize (std::size_t max_width, std::size_t max_height)
{ size_hints.setMaximum (max_width, max_height); }
//----------------------------------------------------------------------
inline void FWidget::setFixedSize (int width, int height)
inline void FWidget::setFixedSize (std::size_t width, std::size_t height)
{
size_hints.setMinimum (width, height);
size_hints.setMaximum (width, height);
@ -864,7 +928,7 @@ inline void FWidget::move (const FPoint& pos)
//----------------------------------------------------------------------
inline void FWidget::drawBorder()
{ drawBorder (1, 1, getWidth(), getHeight()); }
{ drawBorder (1, 1, int(getWidth()), int(getHeight())); }
//----------------------------------------------------------------------
inline void FWidget::processDestroy()
@ -932,6 +996,33 @@ const wchar_t CHECKED_RADIO_BUTTON[4] =
'\0'
};
// non-member functions
//----------------------------------------------------------------------
inline char* createBlankArray (std::size_t size)
{
char* blank;
try
{
blank = new char[size + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return 0;
}
std::memset(blank, ' ', size);
blank[size] = '\0';
return blank;
}
//----------------------------------------------------------------------
inline void destroyBlankArray (char blank[])
{
delete[] blank;
}
} // namespace finalcut
#endif // FWIDGET_H

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2017 Markus Gans *
* Copyright 2015-2018 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -91,7 +91,6 @@ class FWindow : public FWidget
const char* getClassName() const;
static FWindow* getWindowWidget (const FWidget*);
static int getWindowLayer (const FWidget*);
static FWindow* getActiveWindow();
FWidget* getWindowFocusWidget() const;
// Mutators
@ -133,10 +132,10 @@ class FWindow : public FWidget
virtual void setX (int, bool = true);
virtual void setY (int, bool = true);
virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true);
void setGeometry (int, int, int, int, bool = true);
virtual void setWidth (std::size_t, bool = true);
virtual void setHeight (std::size_t, bool = true);
virtual void setSize (std::size_t, std::size_t, bool = true);
void setGeometry (int, int, std::size_t, std::size_t, bool = true);
virtual void move (int, int);
static FWindow* getWindowWidgetAt (const FPoint&);
static FWindow* getWindowWidgetAt (int, int);

View File

@ -310,14 +310,14 @@ void FKeyboardTest::classNameTest()
void FKeyboardTest::noArgumentTest()
{
CPPUNIT_ASSERT ( keyboard->getKey() == 0 );
char* buffer = keyboard->getKeyBuffer();
int size = keyboard->getKeyBufferSize();
finalcut::FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
std::size_t size = sizeof(buffer);
CPPUNIT_ASSERT ( size == 512 );
CPPUNIT_ASSERT ( size == finalcut::FKeyboard::FIFO_BUF_SIZE );
CPPUNIT_ASSERT ( buffer[0] == 0 );
int sum = 0;
for (int i = 0; i < size; i++)
for (std::size_t i = 0; i < size; i++)
sum += int(buffer[i]);
CPPUNIT_ASSERT ( sum == 0 );
@ -2763,7 +2763,7 @@ void FKeyboardTest::utf8Test()
keyboard->disableUTF8();
input("\360\220\200\200");
processInput();
CPPUNIT_ASSERT ( key_released == 0200 );
CPPUNIT_ASSERT ( key_released == 128 );
clear();
}

View File

@ -44,7 +44,7 @@ class FMouse_protected : public finalcut::FMouse
virtual bool hasData()
{ return true; }
virtual void setRawData (char[], int)
virtual void setRawData (finalcut::FKeyboard::keybuffer&)
{ }
virtual void processEvent (struct timeval*)
@ -263,8 +263,9 @@ void FMouseTest::x11MouseTest()
finalcut::FMouseX11 x11_mouse;
CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
char rawdata1[] = { 0x1b, '[', 'M', 0x23, 0x50, 0x32, 0x40, 0x40 };
x11_mouse.setRawData (rawdata1, sizeof(rawdata1));
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', 'M', 0x23, 0x50, 0x32, 0x40, 0x40 };
x11_mouse.setRawData (rawdata1);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
@ -290,14 +291,16 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// The same input again
char raw[] = { 0x1b, '[', 'M', 0x23, 0x50, 0x32 };
x11_mouse.setRawData ( raw, sizeof(raw));
finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', 'M', 0x23, 0x50, 0x32 };
x11_mouse.setRawData (raw);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasEvent() );
// Left mouse button pressed
char rawdata2[] = { 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
x11_mouse.processEvent (&tv);
@ -319,8 +322,9 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// Left mouse button released
char rawdata3[] = { 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata3, sizeof(rawdata3));
finalcut::FKeyboard::keybuffer rawdata3 = \
{ 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata3);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
@ -343,8 +347,9 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// Left mouse button pressed again (double click)
char rawdata4[] = { 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata4);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
@ -369,9 +374,10 @@ void FMouseTest::x11MouseTest()
// Middle mouse button
char rawdata5[] = { 0x1b, '[', 'M', 0x21, 0x21, 0x21
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', 'M', 0x21, 0x21, 0x21
, 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata5, sizeof(rawdata5));
x11_mouse.setRawData (rawdata5);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -394,16 +400,17 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata5, sizeof(rawdata5));
x11_mouse.setRawData (rawdata5);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! x11_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isMiddleButtonReleased() );
// Right mouse button
char rawdata6[] = { 0x1b, '[', 'M', 0x22, 0x21, 0x21
finalcut::FKeyboard::keybuffer rawdata6 = \
{ 0x1b, '[', 'M', 0x22, 0x21, 0x21
, 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata6, sizeof(rawdata6));
x11_mouse.setRawData (rawdata6);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -426,16 +433,17 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata6, sizeof(rawdata6));
x11_mouse.setRawData (rawdata6);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! x11_mouse.isRightButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isRightButtonReleased() );
// Mouse wheel
char rawdata7[] = { 0x1b, '[', 'M', 0x60, 0x70, 0x39
finalcut::FKeyboard::keybuffer rawdata7 = \
{ 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
x11_mouse.setRawData (rawdata7, sizeof(rawdata7));
x11_mouse.setRawData (rawdata7);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -458,16 +466,17 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata7, sizeof(rawdata7));
x11_mouse.setRawData (rawdata7);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( x11_mouse.isWheelDown() );
// Mouse move
char rawdata8[] = { 0x1b, '[', 'M', 0x20, 0x21, 0x21
finalcut::FKeyboard::keybuffer rawdata8 = \
{ 0x1b, '[', 'M', 0x20, 0x21, 0x21
, 0x1b, '[', 'M', 0x40, 0x23, 0x25
, 0x1b, '[', 'M', 0x23, 0x23, 0x25 };
x11_mouse.setRawData (rawdata8, sizeof(rawdata8));
x11_mouse.setRawData (rawdata8);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -490,22 +499,23 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata8, sizeof(rawdata8));
x11_mouse.setRawData (rawdata8);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) );
CPPUNIT_ASSERT ( x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata8, sizeof(rawdata8));
x11_mouse.setRawData (rawdata8);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// Mouse + keyboard modifier key
char rawdata9[] = { 0x1b, '[', 'M', 0x24, 0x30, 0x40
finalcut::FKeyboard::keybuffer rawdata9 = \
{ 0x1b, '[', 'M', 0x24, 0x30, 0x40
, 0x1b, '[', 'M', 0x28, 0x30, 0x40
, 0x1b, '[', 'M', 0x30, 0x30, 0x40
, 0x1b, '[', 'M', 0x3c, 0x30, 0x40 };
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -528,21 +538,21 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isMetaKeyPressed() );
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isMetaKeyPressed() );
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isShiftKeyPressed() );
@ -550,8 +560,9 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.isMetaKeyPressed() );
// Clear event test
char rawdata10[] = { 0x1b, '[', 'M', 0x20, 0x7f, 0x3f };
x11_mouse.setRawData (rawdata10, sizeof(rawdata10));
finalcut::FKeyboard::keybuffer rawdata10 = \
{ 0x1b, '[', 'M', 0x20, 0x7f, 0x3f };
x11_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -566,9 +577,10 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
// Left mouse button pressed
char rawdata1[] = { 0x1b, '[', '<', '0', ';', '7'
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', '<', '0', ';', '7'
, '3', ';', '4', 'M', '@', '@' };
sgr_mouse.setRawData (rawdata1, sizeof(rawdata1));
sgr_mouse.setRawData (rawdata1);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
@ -594,14 +606,16 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// The same input again
char raw[] = { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData ( raw, sizeof(raw));
finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (raw);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
// Left mouse button released
char rawdata2[] = { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
@ -624,8 +638,9 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// Left mouse button pressed again (double click)
char rawdata4[] = { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (rawdata4);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
@ -649,9 +664,10 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// Middle mouse button
char rawdata5[] = { 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
sgr_mouse.setRawData (rawdata5, sizeof(rawdata5));
sgr_mouse.setRawData (rawdata5);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -674,16 +690,17 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata5, sizeof(rawdata5));
sgr_mouse.setRawData (rawdata5);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isMiddleButtonReleased() );
// Right mouse button
char rawdata6[] = { 0x1b, '[', '<', '2', ';', '3', ';', '3', 'M'
finalcut::FKeyboard::keybuffer rawdata6 = \
{ 0x1b, '[', '<', '2', ';', '3', ';', '3', 'M'
, 0x1b, '[', '<', '2', ';', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata6, sizeof(rawdata6));
sgr_mouse.setRawData (rawdata6);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -706,7 +723,7 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata6, sizeof(rawdata6));
sgr_mouse.setRawData (rawdata6);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
@ -714,9 +731,10 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.isRightButtonReleased() );
// Mouse wheel
char rawdata7[] = { 0x1b, '[', '<', '6', '4', ';', '4', ';', '9', 'M'
finalcut::FKeyboard::keybuffer rawdata7 = \
{ 0x1b, '[', '<', '6', '4', ';', '4', ';', '9', 'M'
, 0x1b, '[', '<', '6', '5', ';', '4', ';', '9', 'M' };
sgr_mouse.setRawData (rawdata7, sizeof(rawdata7));
sgr_mouse.setRawData (rawdata7);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -739,16 +757,17 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata7, sizeof(rawdata7));
sgr_mouse.setRawData (rawdata7);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( sgr_mouse.isWheelDown() );
// Mouse move
char rawdata8[] = { 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
finalcut::FKeyboard::keybuffer rawdata8 = \
{ 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata8, sizeof(rawdata8));
sgr_mouse.setRawData (rawdata8);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -771,22 +790,23 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata8, sizeof(rawdata8));
sgr_mouse.setRawData (rawdata8);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata8, sizeof(rawdata8));
sgr_mouse.setRawData (rawdata8);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// Mouse + keyboard modifier key
char rawdata9[] = { 0x1b, '[', '<', '4', ';', '5', ';', '5', 'M'
finalcut::FKeyboard::keybuffer rawdata9 = \
{ 0x1b, '[', '<', '4', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '8', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '1', '6', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '2', '8', ';', '5', ';', '5', 'M' };
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -809,21 +829,21 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isMetaKeyPressed() );
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMetaKeyPressed() );
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isShiftKeyPressed() );
@ -831,8 +851,9 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.isMetaKeyPressed() );
// Clear event test
char rawdata10[] = { 0x1b, '[', '<', '2', ';', '1', ';', '1', 'M' };
sgr_mouse.setRawData (rawdata10, sizeof(rawdata10));
finalcut::FKeyboard::keybuffer rawdata10 = \
{ 0x1b, '[', '<', '2', ';', '1', ';', '1', 'M' };
sgr_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -840,20 +861,21 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
// Wrong mouse data
char rawdata11[] = { 0x1b, '[', '<', '2', 'O', ';', '2', ';', '2', 'M'
finalcut::FKeyboard::keybuffer rawdata11 = \
{ 0x1b, '[', '<', '2', 'O', ';', '2', ';', '2', 'M'
, 0x1b, '[', '<', '1', ';', 'x', ';', '3', 'M'
, 0x1b, '[', '<', '6', ';', '5', ';', '@', 'M', '@' };
sgr_mouse.setRawData (rawdata11, sizeof(rawdata11));
sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
sgr_mouse.setRawData (rawdata11, sizeof(rawdata11));
sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
sgr_mouse.setRawData (rawdata11, sizeof(rawdata11));
sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
@ -869,9 +891,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
// Left mouse button pressed
char rawdata1[] = { 0x1b, '[', '3', '2', ';', '4'
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', '3', '2', ';', '4'
, '9', ';', '6', 'M', '@', '@' };
urxvt_mouse.setRawData (rawdata1, sizeof(rawdata1));
urxvt_mouse.setRawData (rawdata1);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
@ -896,14 +919,16 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// The same input again
char raw[] = { 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData ( raw, sizeof(raw));
finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (raw);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
// Left mouse button released
char rawdata2[] = { 0x1b, '[', '3', '5', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '3', '5', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
@ -926,8 +951,9 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// Left mouse button pressed again (double click)
char rawdata4[] = { 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata4);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
@ -951,9 +977,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// Middle mouse button
char rawdata5[] = { 0x1b, '[', '3', '3', ';', '1', ';', '1', 'M'
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', '3', '3', ';', '1', ';', '1', 'M'
, 0x1b, '[', '3', '5', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata5, sizeof(rawdata5));
urxvt_mouse.setRawData (rawdata5);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -976,16 +1003,17 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata5, sizeof(rawdata5));
urxvt_mouse.setRawData (rawdata5);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isMiddleButtonReleased() );
// Right mouse button
char rawdata6[] = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
finalcut::FKeyboard::keybuffer rawdata6 = \
{ 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
urxvt_mouse.setRawData (rawdata6, sizeof(rawdata6));
urxvt_mouse.setRawData (rawdata6);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1008,7 +1036,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata6, sizeof(rawdata6));
urxvt_mouse.setRawData (rawdata6);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
@ -1016,9 +1044,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.isRightButtonReleased() );
// Mouse wheel
char rawdata7[] = { 0x1b, '[', '9', '6', ';', '4', ';', '9', 'M'
finalcut::FKeyboard::keybuffer rawdata7 = \
{ 0x1b, '[', '9', '6', ';', '4', ';', '9', 'M'
, 0x1b, '[', '9', '7', ';', '4', ';', '9', 'M' };
urxvt_mouse.setRawData (rawdata7, sizeof(rawdata7));
urxvt_mouse.setRawData (rawdata7);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1041,16 +1070,17 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata7, sizeof(rawdata7));
urxvt_mouse.setRawData (rawdata7);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( urxvt_mouse.isWheelDown() );
// Mouse move
char rawdata8[] = { 0x1b, '[', '3', '2', ';', '1', ';', '2', 'M'
finalcut::FKeyboard::keybuffer rawdata8 = \
{ 0x1b, '[', '3', '2', ';', '1', ';', '2', 'M'
, 0x1b, '[', '6', '4', ';', '2', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
urxvt_mouse.setRawData (rawdata8, sizeof(rawdata8));
urxvt_mouse.setRawData (rawdata8);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1073,22 +1103,23 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata8, sizeof(rawdata8));
urxvt_mouse.setRawData (rawdata8);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata8, sizeof(rawdata8));
urxvt_mouse.setRawData (rawdata8);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// Mouse + keyboard modifier key
char rawdata9[] = { 0x1b, '[', '3', '6', ';', '5', ';', '5', 'M'
finalcut::FKeyboard::keybuffer rawdata9 = \
{ 0x1b, '[', '3', '6', ';', '5', ';', '5', 'M'
, 0x1b, '[', '4', '0', ';', '5', ';', '5', 'M'
, 0x1b, '[', '4', '8', ';', '5', ';', '5', 'M'
, 0x1b, '[', '6', '0', ';', '5', ';', '5', 'M' };
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1111,21 +1142,21 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isMetaKeyPressed() );
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMetaKeyPressed() );
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isShiftKeyPressed() );
@ -1133,8 +1164,9 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.isMetaKeyPressed() );
// Clear event test
char rawdata10[] = { 0x1b, '[', '3', '2', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata10, sizeof(rawdata10));
finalcut::FKeyboard::keybuffer rawdata10 = \
{ 0x1b, '[', '3', '2', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1142,20 +1174,21 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
// Wrong mouse data
char rawdata11[] = { 0x1b, '[', '3', 'O', ';', '2', ';', '2', 'M'
finalcut::FKeyboard::keybuffer rawdata11 = \
{ 0x1b, '[', '3', 'O', ';', '2', ';', '2', 'M'
, 0x1b, '[', '3', '3', ';', 'x', ';', '3', 'M'
, 0x1b, '[', '3', '4', ';', '5', ';', '@', 'M', '@' };
urxvt_mouse.setRawData (rawdata11, sizeof(rawdata11));
urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata11, sizeof(rawdata11));
urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata11, sizeof(rawdata11));
urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
@ -1164,9 +1197,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( std::strcmp(rawdata11, "@") == 0 );
// Negative values
char rawdata12[] = { 0x1b, '[', '3', '2', ';', '-', '5', ';', '5', 'M'
finalcut::FKeyboard::keybuffer rawdata12 = \
{ 0x1b, '[', '3', '2', ';', '-', '5', ';', '5', 'M'
, 0x1b, '[', '3', '2', ';', '3', ';', '-', '3', 'M' };
urxvt_mouse.setRawData (rawdata12, sizeof(rawdata12));
urxvt_mouse.setRawData (rawdata12);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
urxvt_mouse.processEvent (&tv);
@ -1175,7 +1209,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 5) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata12, sizeof(rawdata12));
urxvt_mouse.setRawData (rawdata12);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
@ -1186,8 +1220,9 @@ void FMouseTest::urxvtMouseTest()
// Oversize values
urxvt_mouse.setMaxWidth(40);
urxvt_mouse.setMaxHeight(20);
char rawdata13[] = { 0x1b, '[', '3', '2', ';', '7', '0', ';', '2', '5', 'M' };
urxvt_mouse.setRawData (rawdata13, sizeof(rawdata13));
finalcut::FKeyboard::keybuffer rawdata13 = \
{ 0x1b, '[', '3', '2', ';', '7', '0', ';', '2', '5', 'M' };
urxvt_mouse.setRawData (rawdata13);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
@ -1233,9 +1268,10 @@ void FMouseTest::mouseControlTest()
}
// Left mouse button pressed on an X11 mouse
char rawdata1[] = { 0x1b, '[', 'M', 0x20, 0x25, 0x28
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', 'M', 0x20, 0x25, 0x28
, 0x1b, '[', 'M', 0x23, 0x25, 0x28 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1, sizeof(rawdata1));
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
@ -1260,7 +1296,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1, sizeof(rawdata1));
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() );
@ -1268,9 +1304,10 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonDoubleClick() );
// Middle mouse button on an SGR mouse
char rawdata2[] = { 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2, sizeof(rawdata2));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1292,16 +1329,16 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2, sizeof(rawdata2));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( mouse_control.isMiddleButtonReleased() );
// Right mouse button on a urxvt mouse
char rawdata3[] = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
finalcut::FKeyboard::keybuffer rawdata3 = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3, sizeof(rawdata3));
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1323,7 +1360,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3, sizeof(rawdata3));
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
@ -1331,9 +1368,10 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( mouse_control.isRightButtonReleased() );
// Mouse wheel on an X11 mouse
char rawdata4[] = { 0x1b, '[', 'M', 0x60, 0x70, 0x39
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4, sizeof(rawdata4));
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1355,16 +1393,17 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4, sizeof(rawdata4));
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
CPPUNIT_ASSERT ( mouse_control.isWheelDown() );
// Mouse move on an SGR mouse
char rawdata5[] = { 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5, sizeof(rawdata5));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1386,12 +1425,12 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5, sizeof(rawdata5));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5, sizeof(rawdata5));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );

View File

@ -131,6 +131,7 @@ void FObjectTest::classNameTest()
void FObjectTest::noArgumentTest()
{
finalcut::FObject o1;
finalcut::FObject o2;
CPPUNIT_ASSERT ( ! o1.hasParent() );
CPPUNIT_ASSERT ( o1.getParent() == 0 );
CPPUNIT_ASSERT ( ! o1.hasChildren() );
@ -142,8 +143,8 @@ void FObjectTest::noArgumentTest()
CPPUNIT_ASSERT ( children_list.begin() == o1.end() );
CPPUNIT_ASSERT ( children_list.end() == o1.begin() );
CPPUNIT_ASSERT ( children_list.end() == o1.end() );
CPPUNIT_ASSERT ( ! o1.isChild(&o1) );
CPPUNIT_ASSERT ( ! o1.isDirectChild(&o1) );
CPPUNIT_ASSERT ( ! o1.isChild(&o2) );
CPPUNIT_ASSERT ( ! o1.isDirectChild(&o2) );
CPPUNIT_ASSERT ( ! o1.isWidget() );
CPPUNIT_ASSERT ( o1.isInstanceOf("FObject") );
CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() );
@ -176,6 +177,7 @@ void FObjectTest::childObjectTest()
finalcut::FObject* c4 = new finalcut::FObject(&obj);
finalcut::FObject* c5 = new finalcut::FObject(c1);
finalcut::FObject* c6 = new finalcut::FObject(c5);
finalcut::FObject* c7 = new finalcut::FObject();
CPPUNIT_ASSERT ( obj.hasChildren() );
CPPUNIT_ASSERT ( obj.getChild(0) == 0 );
@ -213,7 +215,7 @@ void FObjectTest::childObjectTest()
CPPUNIT_ASSERT ( children_list2.begin() != c1->end() );
CPPUNIT_ASSERT ( children_list2.end() != c1->begin() );
CPPUNIT_ASSERT ( children_list2.end() == c1->end() );
CPPUNIT_ASSERT ( ! c1->isDirectChild(c1) );
CPPUNIT_ASSERT ( ! c1->isDirectChild(c7) );
CPPUNIT_ASSERT ( ! c1->isWidget() );
CPPUNIT_ASSERT ( c1->isInstanceOf("FObject") );
CPPUNIT_ASSERT ( ! c1->isTimerInUpdating() );

View File

@ -219,8 +219,10 @@ void FPointTest::equalTest()
CPPUNIT_ASSERT ( p1 == p2 );
CPPUNIT_ASSERT ( finalcut::FPoint(1,2) == p2 );
CPPUNIT_ASSERT ( p1 == finalcut::FPoint(1,2) );
CPPUNIT_ASSERT ( finalcut::FPoint() == finalcut::FPoint() );
CPPUNIT_ASSERT ( finalcut::FPoint() == -finalcut::FPoint() );
const finalcut::FPoint p3;
const finalcut::FPoint p4;
CPPUNIT_ASSERT ( p3 == p4 );
CPPUNIT_ASSERT ( p3 == -p4 );
}
//----------------------------------------------------------------------

View File

@ -299,7 +299,9 @@ void FRectTest::equalTest()
CPPUNIT_ASSERT ( r1 == r2 );
CPPUNIT_ASSERT ( finalcut::FRect(1, 2, 10, 20) == r2 );
CPPUNIT_ASSERT ( r1 == finalcut::FRect(1, 2, 10, 20) );
CPPUNIT_ASSERT ( finalcut::FRect() == finalcut::FRect() );
const finalcut::FRect r3;
const finalcut::FRect r4;
CPPUNIT_ASSERT ( r3 == r4 );
}
//----------------------------------------------------------------------

View File

@ -221,7 +221,7 @@ void FStringTest::initLengthTest()
CPPUNIT_ASSERT ( s1.isEmpty() );
const int x1 = 10;
const uInt x2 = 10;
const std::size_t x2 = 10;
const finalcut::FString s2(x1);
CPPUNIT_ASSERT ( s2.getLength() == 10 );
CPPUNIT_ASSERT ( ! s2.isNull() );
@ -1261,7 +1261,8 @@ void FStringTest::subStringTest()
CPPUNIT_ASSERT ( str1.left(int(11)) == L"Look behind" );
CPPUNIT_ASSERT ( str1.left(999)
== L"Look behind you, a three-headed monkey!" );
CPPUNIT_ASSERT ( str1.left(-5) == L"" );
CPPUNIT_ASSERT ( str1.left(-5)
== L"Look behind you, a three-headed monkey!" );
CPPUNIT_ASSERT ( str1.left(0) == L"" );
CPPUNIT_ASSERT ( str1.left(0).isEmpty() );
CPPUNIT_ASSERT ( ! str1.left(0).isNull() );
@ -1273,7 +1274,8 @@ void FStringTest::subStringTest()
CPPUNIT_ASSERT ( str1.right(int(7)) == L"monkey!" );
CPPUNIT_ASSERT ( str1.right(999)
== L"Look behind you, a three-headed monkey!" );
CPPUNIT_ASSERT ( str1.right(-5) == L"" );
CPPUNIT_ASSERT ( str1.right(-5)
== L"Look behind you, a three-headed monkey!" );
CPPUNIT_ASSERT ( str1.right(0) == L"" );
CPPUNIT_ASSERT ( str1.right(0).isEmpty() );
CPPUNIT_ASSERT ( ! str1.right(0).isNull() );
@ -1290,7 +1292,7 @@ void FStringTest::subStringTest()
CPPUNIT_ASSERT ( str1.mid(5, 0) == L"" );
CPPUNIT_ASSERT ( str1.mid(-5, 2) == L"" );
CPPUNIT_ASSERT ( str1.mid(0, 0) == L"" );
CPPUNIT_ASSERT ( str1.mid(0, 5) == L"" );
CPPUNIT_ASSERT ( str1.mid(0, 5) == L"Look " );
CPPUNIT_ASSERT ( str1.mid(0, 0).isEmpty() );
CPPUNIT_ASSERT ( ! str1.mid(0, 0).isNull() );
CPPUNIT_ASSERT ( finalcut::FString().mid(5, 0).isNull() );

Some files were not shown because too many files have changed in this diff Show More