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> 2018-10-05 Markus Gans <guru.mail@muenster.de>
* Remove redundant program code from FString * Remove redundant program code from FString

View File

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

View File

@ -29,7 +29,7 @@ endif
all: $(OBJS) all: $(OBJS)
debug: 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: profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg" $(MAKE) $(MAKEFILE) PROFILE="-pg"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -247,12 +247,12 @@
y="93.333893" y="93.333893"
transform="scale(0.95126779,1.0512287)" transform="scale(0.95126779,1.0512287)"
id="text37-5" 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 <tspan
x="160.94762" x="160.94762"
y="93.333893" y="93.333893"
id="tspan3006-1" 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> </text>
<g <g
id="g23" id="g23"
@ -293,11 +293,11 @@
y="91.775856" y="91.775856"
transform="scale(0.95126779,1.0512287)" transform="scale(0.95126779,1.0512287)"
id="text37" 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 <tspan
x="158.56929" x="158.56929"
y="91.775856" y="91.775856"
id="tspan3006" 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> </text>
</svg> </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 # compiler parameter
CXX = clang++ 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 MAKEFILE = -f Makefile.clang
LDFLAGS = $(TERMCAP) -lgpm LDFLAGS = $(TERMCAP) -lgpm
INCLUDES = -Iinclude INCLUDES = -Iinclude
@ -148,7 +148,7 @@ all: dep $(OBJS)
$(LIB): all $(LIB): all
debug: 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: profile:
$(MAKE) $(MAKEFILE) PROFILE="-pg" $(MAKE) $(MAKEFILE) PROFILE="-pg"

View File

@ -62,7 +62,7 @@ INCLUDE_HEADERS = \
# compiler parameter # compiler parameter
CXX = g++ 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 MAKEFILE = -f Makefile.gcc
LDFLAGS = $(TERMCAP) -lgpm LDFLAGS = $(TERMCAP) -lgpm
INCLUDES = -Iinclude INCLUDES = -Iinclude

View File

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

View File

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

View File

@ -189,9 +189,8 @@ bool FButtonGroup::hasCheckedButton() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::hide() void FButtonGroup::hide()
{ {
int size; std::size_t size;
short fg, bg; short fg, bg;
char* blank;
FWidget::hide(); FWidget::hide();
FWidget* parent_widget = getParentWidget(); FWidget* parent_widget = getParentWidget();
@ -223,29 +222,18 @@ void FButtonGroup::hide()
setColor (fg, bg); setColor (fg, bg);
size = getWidth(); size = getWidth();
if ( size < 0 ) if ( size == 0 )
return; return;
try char* blank = createBlankArray(size + 1);
{
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)); for (int y = 0; y < int(getHeight()); y++)
blank[size] = '\0';
for (int y = 0; y < getHeight(); y++)
{ {
FWidget::setPrintPos (1, 1 + y); FWidget::setPrintPos (1, 1 + y);
print (blank); print (blank);
} }
delete[] blank; destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -443,14 +431,12 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uChar FButtonGroup::getHotkey() uChar FButtonGroup::getHotkey()
{ {
uInt length;
if ( text.isEmpty() ) if ( text.isEmpty() )
return 0; 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 try
{ {
@ -506,13 +492,13 @@ void FButtonGroup::draw()
void FButtonGroup::drawLabel() void FButtonGroup::drawLabel()
{ {
wchar_t* LabelText; wchar_t* LabelText;
int hotkeypos; std::size_t hotkeypos;
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
FString txt = " " + text + " "; FString txt = " " + text + " ";
uInt length = txt.getLength(); std::size_t length = txt.getLength();
try try
{ {
@ -527,9 +513,9 @@ void FButtonGroup::drawLabel()
wchar_t* src = const_cast<wchar_t*>(txt.wc_str()); wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText); wchar_t* dest = const_cast<wchar_t*>(LabelText);
unsetViewportPrint(); unsetViewportPrint();
hotkeypos = getHotkeyPos(src, dest, uInt(length)); hotkeypos = getHotkeyPos(src, dest, length);
if ( hotkeypos != -1 ) if ( hotkeypos != NOT_SET )
length--; length--;
if ( hasBorder() ) 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 // find hotkey position in string
// + generate a new string without the '&'-sign // + generate a new string without the '&'-sign
int pos = -1; std::size_t pos = NOT_SET;
wchar_t* txt = src; 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++; i++;
src++; 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 isActive = ((flags & fc::active) != 0);
bool isNoUnderline = ((flags & fc::no_underline) != 0); bool isNoUnderline = ((flags & fc::no_underline) != 0);
@ -603,7 +593,7 @@ void FButtonGroup::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
else else
setColor(wc.label_inactive_fg, wc.label_inactive_bg); 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 ) if ( (z == hotkeypos) && isActive )
{ {
@ -612,7 +602,7 @@ void FButtonGroup::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
if ( ! isNoUnderline ) if ( ! isNoUnderline )
setUnderline(); setUnderline();
print ( LabelText[z] ); print (LabelText[z]);
if ( ! isNoUnderline ) if ( ! isNoUnderline )
unsetUnderline(); unsetUnderline();
@ -620,7 +610,7 @@ void FButtonGroup::drawText (wchar_t LabelText[], int hotkeypos, uInt length)
setColor (wc.label_emphasis_fg, wc.label_bg); setColor (wc.label_emphasis_fg, wc.label_bg);
} }
else else
print ( LabelText[z] ); print (LabelText[z]);
} }
if ( isMonochron() ) if ( isMonochron() )

View File

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

View File

@ -54,9 +54,7 @@ FDialogListMenu::~FDialogListMenu()
void FDialogListMenu::init() void FDialogListMenu::init()
{ {
FMenuItem* menuitem = getItem(); FMenuItem* menuitem = getItem();
menuitem->dialog_index = true;
if ( menuitem )
menuitem->dialog_index = true;
} }
} // namespace finalcut } // namespace finalcut

View File

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

View File

@ -70,7 +70,6 @@ FKeyboard::FKeyboard()
: key(0) : key(0)
, fifo_offset(0) , fifo_offset(0)
, fifo_in_use(false) , fifo_in_use(false)
, fifo_buf_size(sizeof(fifo_buf))
, stdin_status_flags(0) , stdin_status_flags(0)
, input_data_pending(false) , input_data_pending(false)
, utf8_input(false) , utf8_input(false)
@ -92,8 +91,8 @@ FKeyboard::FKeyboard()
std::abort(); std::abort();
// Initialize arrays with '\0' // Initialize arrays with '\0'
std::fill_n (k_buf, sizeof(k_buf), '\0'); std::fill_n (read_buf, READ_BUF_SIZE, '\0');
std::fill_n (fifo_buf, fifo_buf_size, '\0'); std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -159,7 +158,7 @@ void FKeyboard::clearKeyBuffer()
fifo_offset = 0; fifo_offset = 0;
key = 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; fifo_in_use = false;
} }
@ -230,7 +229,7 @@ inline int FKeyboard::getTermcapKey()
{ {
// Looking for termcap key strings in the buffer // Looking for termcap key strings in the buffer
assert ( fifo_buf_size > 0 ); assert ( FIFO_BUF_SIZE > 0 );
if ( ! key_map ) if ( ! key_map )
return -1; return -1;
@ -239,16 +238,16 @@ inline int FKeyboard::getTermcapKey()
for (int i = 0; keymap[i].tname[0] != 0; i++) for (int i = 0; keymap[i].tname[0] != 0; i++)
{ {
char* k = keymap[i].string; 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]; 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'; fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\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 // 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++) for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++)
{ {
char* kmeta = fc::Fmetakey[i].string; // The string is never null 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' if ( len == 2 && ( fifo_buf[1] == 'O'
|| fifo_buf[1] == '[' || fifo_buf[1] == '['
@ -283,10 +282,10 @@ inline int FKeyboard::getMetaKey()
return NEED_MORE_DATA; 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]; 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'; fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\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 // Looking for single key code in the buffer
uChar firstchar = uChar(fifo_buf[0]); uChar firstchar = uChar(fifo_buf[0]);
int keycode, n, len; std::size_t n;
len = 1; std::size_t len = 1;
int keycode;
// Look for a utf-8 character // Look for a utf-8 character
if ( utf8_input && (firstchar & 0xc0) == 0xc0 ) if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
@ -318,7 +318,7 @@ inline int FKeyboard::getSingleKey()
else if ( (firstchar & 0xf8) == 0xf0 ) else if ( (firstchar & 0xf8) == 0xf0 )
len = 4; 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); utf8char[i] = char(fifo_buf[i] & 0xff);
keycode = UTF8decode(utf8char); keycode = UTF8decode(utf8char);
@ -326,10 +326,10 @@ inline int FKeyboard::getSingleKey()
else else
keycode = uChar(fifo_buf[0] & 0xff); 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]; 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'; fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
@ -424,7 +424,7 @@ inline ssize_t FKeyboard::readKey()
{ {
ssize_t bytes; ssize_t bytes;
setNonBlockingInput(); setNonBlockingInput();
bytes = read(FTermios::getStdIn(), &k_buf, sizeof(k_buf) - 1); bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
unsetNonBlockingInput(); unsetNonBlockingInput();
return bytes; return bytes;
} }
@ -437,11 +437,11 @@ void FKeyboard::parseKeyBuffer()
while ( (bytesread = readKey()) > 0 ) 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++) for (int i = 0; i < bytesread; i++)
{ {
fifo_buf[fifo_offset] = k_buf[i]; fifo_buf[fifo_offset] = read_buf[i];
fifo_offset++; fifo_offset++;
} }
@ -474,7 +474,7 @@ void FKeyboard::parseKeyBuffer()
key = 0; 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() void FLabel::hide()
{ {
short fg, bg; short fg, bg;
int size; std::size_t size;
char* blank;
FWidget* parent_widget = getParentWidget(); FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
@ -262,24 +261,13 @@ void FLabel::hide()
setColor (fg, bg); setColor (fg, bg);
size = getWidth(); size = getWidth();
if ( size < 0 ) if ( size == 0 )
return; return;
try char* blank = createBlankArray(size + 1);
{ setPrintPos (1, 1);
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';
setPrintPos (1,1);
print (blank); print (blank);
delete[] blank; destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -397,14 +385,12 @@ void FLabel::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uChar FLabel::getHotkey() uChar FLabel::getHotkey()
{ {
uInt length;
if ( text.isEmpty() ) if ( text.isEmpty() )
return 0; 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 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 // find hotkey position in string
// + generate a new string without the '&'-sign // + generate a new string without the '&'-sign
int hotkeypos = -1; std::size_t hotkeypos = NOT_SET;
wchar_t* txt = src; 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++; i++;
src++; src++;
} }
@ -446,7 +434,7 @@ int FLabel::getHotkeyPos (wchar_t src[], wchar_t dest[], uInt length)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::setHotkeyAccelerator() void FLabel::setHotkeyAccelerator()
{ {
int hotkey = getHotkey(); uChar hotkey = getHotkey();
if ( hotkey ) 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 ) switch ( alignment )
{ {
case fc::alignLeft: case fc::alignLeft:
return 0; return 0;
case fc::alignCenter: case fc::alignCenter:
if ( length < getWidth() ) if ( length < width )
return int((getWidth() - length) / 2); return (width - length) / 2;
else else
return 0; return 0;
case fc::alignRight: case fc::alignRight:
if ( length < getWidth() ) if ( length < width )
return getWidth() - length; return width - length;
else else
return 0; return 0;
} }
@ -522,15 +512,16 @@ void FLabel::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::drawMultiLine() void FLabel::drawMultiLine()
{ {
uInt y = 0; std::size_t y = 0;
uInt text_lines = uInt(multiline_text.size()); std::size_t text_lines = multiline_text.size();
bool hotkey_printed = false; bool hotkey_printed = false;
while ( y < text_lines && y < uInt(getHeight()) ) while ( y < text_lines && y < std::size_t(getHeight()) )
{ {
wchar_t* label_text; wchar_t* label_text;
int align_offset, hotkeypos = -1; std::size_t hotkeypos = NOT_SET;
uInt length = multiline_text[y].getLength(); std::size_t align_offset;
std::size_t length = multiline_text[y].getLength();
try try
{ {
@ -552,16 +543,16 @@ void FLabel::drawMultiLine()
setPrintPos (1, 1 + int(y)); 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); printLine (label_text, length - 1, hotkeypos, align_offset);
hotkey_printed = true; hotkey_printed = true;
} }
else else
{ {
align_offset = getAlignOffset (int(length)); align_offset = getAlignOffset(length);
printLine (label_text, length, -1, align_offset); printLine (label_text, length, NOT_SET, align_offset);
} }
y++; y++;
@ -573,8 +564,9 @@ void FLabel::drawMultiLine()
void FLabel::drawSingleLine() void FLabel::drawSingleLine()
{ {
wchar_t* label_text; wchar_t* label_text;
int hotkeypos = -1, align_offset; std::size_t hotkeypos = NOT_SET;
uInt length = text.getLength(); std::size_t align_offset;
std::size_t length = text.getLength();
try try
{ {
@ -588,22 +580,23 @@ void FLabel::drawSingleLine()
hotkeypos = getHotkeyPos (text.wc_str(), label_text, length); hotkeypos = getHotkeyPos (text.wc_str(), label_text, length);
if ( hotkeypos != -1 ) if ( hotkeypos != NOT_SET )
length--; length--;
setPrintPos (1,1); setPrintPos (1, 1);
align_offset = getAlignOffset (int(length)); align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset); printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text; delete[] label_text;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::printLine ( wchar_t line[] void FLabel::printLine ( wchar_t line[]
, uInt length , std::size_t length
, int hotkeypos , std::size_t hotkeypos
, int align_offset ) , std::size_t align_offset )
{ {
int to_char; std::size_t to_char;
std::size_t width = std::size_t(getWidth());
bool isActive, isNoUnderline; bool isActive, isNoUnderline;
isActive = ((flags & fc::active) != 0); isActive = ((flags & fc::active) != 0);
isNoUnderline = ((flags & fc::no_underline) != 0); isNoUnderline = ((flags & fc::no_underline) != 0);
@ -611,15 +604,15 @@ void FLabel::printLine ( wchar_t line[]
if ( align_offset > 0 ) if ( align_offset > 0 )
print (FString(align_offset, ' ')); // leading spaces print (FString(align_offset, ' ')); // leading spaces
if ( length <= uInt(getWidth()) ) if ( length <= width )
to_char = int(length); to_char = length;
else else
to_char = getWidth() - 2; to_char = width - 2;
if ( hasReverseMode() ) if ( hasReverseMode() )
setReverse(true); 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])) ) if ( ! std::iswprint(wint_t(line[z])) )
{ {
@ -630,14 +623,14 @@ void FLabel::printLine ( wchar_t line[]
} }
} }
if ( (z == hotkeypos) && isActive ) if ( z == hotkeypos && isActive )
{ {
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
if ( ! isNoUnderline ) if ( ! isNoUnderline )
setUnderline(); setUnderline();
print ( line[z] ); print (line[z]);
if ( ! isNoUnderline ) if ( ! isNoUnderline )
unsetUnderline(); unsetUnderline();
@ -648,20 +641,20 @@ void FLabel::printLine ( wchar_t line[]
setColor(); setColor();
} }
else else
print ( line[z] ); print (line[z]);
} }
if ( length > uInt(getWidth()) ) if ( length > width )
{ {
// Print ellipsis // Print ellipsis
setColor (ellipsis_color, getBackgroundColor()); setColor (ellipsis_color, getBackgroundColor());
print (".."); print ("..");
setColor(); setColor();
} }
else if ( align_offset + to_char < getWidth() ) else if ( align_offset + to_char < width )
{ {
// Print trailing spaces // Print trailing spaces
int len = getWidth() - align_offset - to_char; std::size_t len = width - align_offset - to_char;
print (FString(len, ' ')); print (FString(len, ' '));
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -159,9 +159,9 @@ void FMessageBox::setHeadline (const FString& headline)
setHeight(getHeight() + 2, true); setHeight(getHeight() + 2, true);
for (uInt n = 0; n < num_buttons; n++) 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 ) if ( len > max_line_width )
max_line_width = len; max_line_width = len;
@ -172,13 +172,13 @@ void FMessageBox::setText (const FString& txt)
{ {
text = txt; text = txt;
calculateDimensions(); calculateDimensions();
button[0]->setY (getHeight() - 4, false); button[0]->setY (int(getHeight()) - 4, false);
if ( button_digit[1] != 0 ) if ( button_digit[1] != 0 )
button[1]->setY (getHeight() - 4, false); button[1]->setY (int(getHeight()) - 4, false);
if ( button_digit[2] != 0 ) if ( button_digit[2] != 0 )
button[2]->setY (getHeight() - 4, false); button[2]->setY (int(getHeight()) - 4, false);
adjustButtons(); adjustButtons();
} }
@ -279,10 +279,9 @@ int FMessageBox::error ( FWidget* parent
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::adjustSize() void FMessageBox::adjustSize()
{ {
int X int X, Y;
, Y std::size_t max_width;
, max_width std::size_t max_height;
, max_height;
FWidget* root_widget = getRootWidget(); FWidget* root_widget = getRootWidget();
if ( root_widget ) if ( root_widget )
@ -306,7 +305,7 @@ void FMessageBox::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::cb_processClick (FWidget*, data_ptr data) void FMessageBox::cb_processClick (FWidget*, data_ptr data)
{ {
int* reply = static_cast<int*>(data); FDialog::DialogCode* reply = static_cast<FDialog::DialogCode*>(data);
done (*reply); done (*reply);
} }
@ -350,7 +349,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[0] = new FButton (this); button[0] = new FButton (this);
button[0]->setText(button_text[button0]); 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]->setWidth(1, false);
button[0]->setHeight(1, false); button[0]->setHeight(1, false);
button[0]->setFocus(); button[0]->setFocus();
@ -359,7 +358,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[1] = new FButton(this); button[1] = new FButton(this);
button[1]->setText(button_text[button1]); 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]->setWidth(0, false);
button[1]->setHeight(1, 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] = new FButton(this);
button[2]->setText(button_text[button2]); 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]->setWidth(0, false);
button[2]->setHeight(1, false); button[2]->setHeight(1, false);
} }
@ -424,8 +423,9 @@ inline void FMessageBox::initCallbacks()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::calculateDimensions() void FMessageBox::calculateDimensions()
{ {
int x, y, w, h; int x, y;
int headline_height = 0; std::size_t w, h;
std::size_t headline_height = 0;
FWidget* parent_widget = getParentWidget(); FWidget* parent_widget = getParentWidget();
text_split = text.split("\n"); text_split = text.split("\n");
text_num_lines = uInt(text_split.size()); text_num_lines = uInt(text_split.size());
@ -437,14 +437,14 @@ void FMessageBox::calculateDimensions()
for (uInt i = 0; i < text_num_lines; i++) 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 ) if ( len > max_line_width )
max_line_width = len; max_line_width = len;
} }
h = int(text_num_lines) + 8 + headline_height; h = text_num_lines + 8 + headline_height;
w = int(max_line_width + 4); w = max_line_width + 4;
if ( w < 20 ) if ( w < 20 )
w = 20; w = 20;
@ -468,7 +468,7 @@ void FMessageBox::draw()
int head_offset = 0; int head_offset = 0;
int center_x = 0; int center_x = 0;
// center the whole block // 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() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -476,7 +476,7 @@ void FMessageBox::draw()
if ( ! headline_text.isNull() ) if ( ! headline_text.isNull() )
{ {
setColor(emphasis_color, getBackgroundColor()); setColor(emphasis_color, getBackgroundColor());
uInt headline_length = headline_text.getLength(); std::size_t headline_length = headline_text.getLength();
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((max_line_width - headline_length) / 2); 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++) 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 if ( center_text ) // center one line
center_x = int((max_line_width - line_length) / 2); center_x = int((max_line_width - line_length) / 2);
@ -506,9 +506,9 @@ void FMessageBox::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::resizeButtons() 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(); len[n] = button[n]->getText().getLength();
@ -530,17 +530,17 @@ void FMessageBox::resizeButtons()
if ( max_size < 7 ) if ( max_size < 7 )
max_size = 7; max_size = 7;
for (uInt n = 0; n < num_buttons; n++) for (std::size_t n = 0; n < num_buttons; n++)
button[n]->setWidth(int(max_size + 3), false); button[n]->setWidth(max_size + 3, false);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::adjustButtons() void FMessageBox::adjustButtons()
{ {
static const int gap = 4; static const std::size_t gap = 4;
int btn_width = 0; 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 ) if ( n == num_buttons - 1 )
btn_width += button[n]->getWidth(); btn_width += button[n]->getWidth();
@ -550,7 +550,7 @@ void FMessageBox::adjustButtons()
if ( btn_width >= getWidth() - 4 ) if ( btn_width >= getWidth() - 4 )
{ {
int max_width; std::size_t max_width;
FWidget* root_widget = getRootWidget(); FWidget* root_widget = getRootWidget();
setWidth(btn_width + 5); setWidth(btn_width + 5);
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80; max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
@ -559,14 +559,14 @@ void FMessageBox::adjustButtons()
int btn_x = int((getWidth() - btn_width) / 2); 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 ) if ( n == 0 )
button[n]->setX(btn_x); button[n]->setX(btn_x);
else else
{ {
int btn_size = button[n]->getWidth(); int btn_size = int(button[n]->getWidth());
button[n]->setX( btn_x + int(n) * (btn_size + gap) ); 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 // Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
static const int len = 6; static const std::size_t len = 6;
int n; std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t n;
x11_mouse[0] = fifo_buf[3]; x11_mouse[0] = fifo_buf[3];
x11_mouse[1] = fifo_buf[4]; x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5]; 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 // Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
int len = int(std::strlen(fifo_buf)); std::size_t fifo_buf_size = sizeof(fifo_buf);
int n = 3; 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]; sgr_mouse[n - 3] = fifo_buf[n];
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 // Import the X11 xterm mouse protocol (Urxvt-Mode) raw mouse data
int len = int(std::strlen(fifo_buf)); std::size_t fifo_buf_size = sizeof(fifo_buf);
int n = 2; 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]; urxvt_mouse[n - 2] = fifo_buf[n];
n++; n++;
@ -1487,13 +1490,11 @@ bool FMouseControl::isGpmMouseEnabled()
return false; return false;
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
FMouse* mouse = mouse_protocol[FMouse::gpm]; FMouse* mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
return gpm_mouse->isGpmMouseEnabled(); return gpm_mouse->isGpmMouseEnabled();
#endif // F_HAVE_LIBGPM #endif // F_HAVE_LIBGPM
return false; return false;
@ -1537,13 +1538,12 @@ void FMouseControl::disable()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setRawData ( FMouse::mouse_type mt void FMouseControl::setRawData ( FMouse::mouse_type mt
, char fifo_buf[] , FKeyboard::keybuffer& fifo_buf)
, int fifo_buf_size )
{ {
FMouse* mouse = mouse_protocol[mt]; FMouse* mouse = mouse_protocol[mt];
if ( mouse ) 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 ( w > 0 );
assert ( h > 0 ); assert ( h > 0 );
@ -493,10 +493,10 @@ void FOptiMove::set_clr_eol (char cap[])
void FOptiMove::check_boundaries ( int& xold, int& yold void FOptiMove::check_boundaries ( int& xold, int& yold
, int& xnew, int& ynew ) , int& xnew, int& ynew )
{ {
if ( xold < 0 || xold >= screen_width ) if ( xold < 0 || xold >= int(screen_width) )
xold = -1; xold = -1;
if ( yold < 0 || yold >= screen_height ) if ( yold < 0 || yold >= int(screen_height) )
yold = -1; yold = -1;
if ( xnew < 0 ) if ( xnew < 0 )
@ -505,11 +505,11 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
if ( ynew < 0 ) if ( ynew < 0 )
ynew = 0; ynew = 0;
if ( xnew >= screen_width ) if ( xnew >= int(screen_width) )
xnew = screen_width - 1; xnew = int(screen_width) - 1;
if ( ynew >= screen_height ) if ( ynew >= int(screen_height) )
ynew = screen_height - 1; ynew = int(screen_height) - 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -962,7 +962,7 @@ inline bool FOptiMove::isWideMove ( int xold, int yold
, int xnew, int ynew ) , int xnew, int ynew )
{ {
return bool ( xnew > MOVE_LIMIT 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) && std::abs(xnew - xold) + std::abs(ynew - yold)
> MOVE_LIMIT ); > MOVE_LIMIT );
} }
@ -1066,7 +1066,7 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
char null_result[BUF_SIZE]; char null_result[BUF_SIZE];
char* null_ptr = null_result; char* null_ptr = null_result;
int new_time = relativeMove ( null_ptr int new_time = relativeMove ( null_ptr
, 0, screen_height - 1 , 0, int(screen_height) - 1
, xnew, ynew ); , xnew, ynew );
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
@ -1094,7 +1094,7 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
char null_result[BUF_SIZE]; char null_result[BUF_SIZE];
char* null_ptr = null_result; char* null_ptr = null_result;
int new_time = relativeMove ( null_ptr int new_time = relativeMove ( null_ptr
, screen_width - 1, yold - 1 , int(screen_width) - 1, yold - 1
, xnew, ynew ); , xnew, ynew );
if ( new_time < LONG_DURATION 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); std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE - 1);
move_ptr[BUF_SIZE - 1] ='\0'; move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += F_cursor_to_ll.length; 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; break;
case 5: case 5:
@ -1154,14 +1154,14 @@ void FOptiMove::moveByMethod ( int method
if ( xold >= 0 ) if ( xold >= 0 )
std::strncat ( move_ptr std::strncat ( move_ptr
, F_carriage_return.cap , F_carriage_return.cap
, BUF_SIZE - std::strlen(move_ptr) ); , BUF_SIZE - std::strlen(move_ptr) - 1 );
std::strncat ( move_ptr std::strncat ( move_ptr
, F_cursor_left.cap , 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[BUF_SIZE - 1] ='\0';
move_ptr += std::strlen(move_buf); 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; break;
default: default:

View File

@ -33,7 +33,7 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FProgressbar::FProgressbar(FWidget* parent) FProgressbar::FProgressbar(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, percentage(-1) , percentage(NOT_SET)
, bar_length(getWidth()) , bar_length(getWidth())
{ {
unsetFocusable(); unsetFocusable();
@ -47,15 +47,14 @@ FProgressbar::~FProgressbar() // destructor
// public methods of FProgressbar // public methods of FProgressbar
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::setPercentage (int percentage_value) void FProgressbar::setPercentage (std::size_t percentage_value)
{ {
if ( percentage_value <= percentage ) if ( percentage_value == NOT_SET )
return; percentage = NOT_SET;
else if ( percentage_value > 100 )
if ( percentage_value > 100 )
percentage = 100; percentage = 100;
else if ( percentage_value < 0 ) else if ( percentage_value <= percentage && percentage != NOT_SET )
percentage = 0; return;
else else
percentage = percentage_value; 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 // Set the progress bar geometry
@ -99,9 +98,8 @@ bool FProgressbar::setShadow (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::hide() void FProgressbar::hide()
{ {
int s, size; std::size_t s, size;
short fg, bg; short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget(); FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
@ -121,37 +119,26 @@ void FProgressbar::hide()
s = hasShadow() ? 1 : 0; s = hasShadow() ? 1 : 0;
size = getWidth() + s; size = getWidth() + s;
if ( size < 0 ) if ( size == 0 )
return; return;
try char* blank = createBlankArray(size + 1);
{
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)); for (std::size_t y = 0; y < getHeight() + s; y++)
blank[size] = '\0';
for (int y = 0; y < getHeight() + s; y++)
{ {
setPrintPos (1, 1 + y); setPrintPos (1, 1 + int(y));
print (blank); print (blank);
} }
delete[] blank; destroyBlankArray (blank);
setPrintPos (getWidth() - 4, 0); setPrintPos (int(getWidth()) - 4, 0);
print (" "); // hide percentage print (" "); // hide percentage
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::reset() void FProgressbar::reset()
{ {
percentage = -1; percentage = NOT_SET;
if ( isVisible() ) if ( isVisible() )
{ {
@ -190,9 +177,9 @@ void FProgressbar::drawPercentage()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setPrintPos (getWidth() - 3, 0); setPrintPos (int(getWidth()) - 3, 0);
if ( percentage < 0 || percentage > 100 ) if ( percentage > 100 )
print ("--- %"); print ("--- %");
else else
printf ("%3d %%", percentage); printf ("%3d %%", percentage);
@ -204,12 +191,17 @@ void FProgressbar::drawPercentage()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::drawBar() void FProgressbar::drawBar()
{ {
int i = 0; std::size_t i = 0;
double length = double(bar_length * percentage) / 100; double length;
setPrintPos (1,1); setPrintPos (1,1);
setColor ( wc.progressbar_bg setColor ( wc.progressbar_bg
, wc.progressbar_fg ); , wc.progressbar_fg );
if ( percentage == NOT_SET )
length = double(-0/100);
else
length = double(bar_length * percentage) / 100;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -219,7 +211,7 @@ void FProgressbar::drawBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); 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 ) 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); X2 = short(X1 + short(w) - 1);
Y2 = short(Y1 + h - 1); Y2 = short(Y1 + short(h) - 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRect::setRect (const FRect& r) 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); X1 = short(x);
Y1 = short(y); Y1 = short(y);
X2 = short(x + width - 1); X2 = short(x + int(width) - 1);
Y2 = short(y + height - 1); Y2 = short(y + int(height) - 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -248,8 +251,8 @@ FRect operator + (const FRect& r, const FPoint& p)
{ {
return FRect ( r.X1 return FRect ( r.X1
, r.Y1 , r.Y1
, r.X2 - r.X1 + 1 + p.getX() , std::size_t(r.X2 - r.X1 + 1 + p.getX())
, r.Y2 - r.Y1 + 1 + p.getY() ); , 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 return FRect ( r.X1
, r.Y1 , r.Y1
, r.X2 - r.X1 + 1 - p.getX() , std::size_t(r.X2 - r.X1 + 1 - p.getX())
, r.Y2 - r.Y1 + 1 - p.getY() ); , 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) void FScrollbar::setOrientation (int o)
{ {
int nf = 0; std::size_t nf = 0;
length = ( getHeight() > getWidth() ) ? getHeight() : getWidth(); length = ( getHeight() > getWidth() ) ? getHeight() : getWidth();
if ( o == fc::vertical && bar_orientation == fc::horizontal ) 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 // Set the scrollbar geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (x, y, w, h, adjust);
int nf = 0; std::size_t nf = 0;
length = ( h > w ) ? h : w; length = ( h > w ) ? h : w;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
@ -223,7 +223,7 @@ void FScrollbar::calculateSliderValues()
else else
bar_length = length - 2; bar_length = length - 2;
slider_length = int(double(bar_length) / steps); slider_length = std::size_t(double(bar_length) / steps);
if ( slider_length < 1 ) if ( slider_length < 1 )
slider_length = 1; slider_length = 1;
@ -238,17 +238,18 @@ void FScrollbar::calculateSliderValues()
if ( val == max ) if ( val == max )
{ {
slider_pos = bar_length - slider_length; slider_pos = int(bar_length - slider_length);
return; 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) ) ); / double(max - min) ) );
if ( slider_pos < 0 ) if ( slider_pos < 0 )
slider_pos = 0; slider_pos = 0;
else if ( slider_pos > bar_length - slider_length ) else if ( slider_pos > int(bar_length - slider_length) )
slider_pos = bar_length - slider_length; slider_pos = int(bar_length - slider_length);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -280,7 +281,7 @@ void FScrollbar::drawVerticalBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
for (z = 1; z <= slider_length; z++) for (z = 1; z <= int(slider_length); z++)
{ {
setPrintPos (1, 1 + slider_pos + z); setPrintPos (1, 1 + slider_pos + z);
@ -295,7 +296,7 @@ void FScrollbar::drawVerticalBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg); 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); setPrintPos (1, 1 + z);
@ -343,16 +344,16 @@ void FScrollbar::drawHorizontalBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
for (z = 0; z < slider_length; z++) for (z = 0; z < int(slider_length); z++)
print (' '); print (' ');
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg); 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 ) if ( isNewFont() && max_color > 8 )
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
@ -500,8 +501,8 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
} }
} }
if ( mouse_x < 1 || mouse_x > getWidth() if ( mouse_x < 1 || mouse_x > int(getWidth())
|| mouse_y < 1 || mouse_y > getHeight() ) || mouse_y < 1 || mouse_y > int(getHeight()) )
{ {
delOwnTimer(); delOwnTimer();
} }
@ -554,7 +555,7 @@ void FScrollbar::onTimer (FTimerEvent*)
|| ( scroll_type == FScrollbar::scrollPageForward || ( scroll_type == FScrollbar::scrollPageForward
&& slider_pos == slider_click_stop_pos ) ) && 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 if ( scroll_type == FScrollbar::scrollPageBackward
&& slider_pos == 0 ) && slider_pos == 0 )
@ -610,7 +611,7 @@ void FScrollbar::drawButtons()
{ {
print (fc::NF_rev_up_arrow1); print (fc::NF_rev_up_arrow1);
print (fc::NF_rev_up_arrow2); print (fc::NF_rev_up_arrow2);
setPrintPos (1, length); setPrintPos (1, int(length));
print (fc::NF_rev_down_arrow1); print (fc::NF_rev_down_arrow1);
print (fc::NF_rev_down_arrow2); print (fc::NF_rev_down_arrow2);
} }
@ -618,7 +619,7 @@ void FScrollbar::drawButtons()
{ {
print (fc::NF_rev_left_arrow1); print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2); 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_arrow1);
print (fc::NF_rev_right_arrow2); print (fc::NF_rev_right_arrow2);
} }
@ -633,13 +634,13 @@ void FScrollbar::drawButtons()
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
print (fc::BlackUpPointingTriangle); // ▲ print (fc::BlackUpPointingTriangle); // ▲
setPrintPos (1, length); setPrintPos (1, int(length));
print (fc::BlackDownPointingTriangle); // ▼ print (fc::BlackDownPointingTriangle); // ▼
} }
else // horizontal else // horizontal
{ {
print (fc::BlackLeftPointingPointer); // ◄ print (fc::BlackLeftPointingPointer); // ◄
setPrintPos (length, 1); setPrintPos (int(length), 1);
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
} }
@ -672,11 +673,11 @@ FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y)
{ {
return FScrollbar::scrollPageBackward; // before slider 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 return FScrollbar::scrollPageForward; // after slider
} }
else if ( y == getHeight() ) else if ( y == int(getHeight()) )
{ {
return FScrollbar::scrollStepForward; // increment button return FScrollbar::scrollStepForward; // increment button
} }
@ -697,11 +698,11 @@ FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x)
{ {
return FScrollbar::scrollPageBackward; // before slider 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 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 return FScrollbar::scrollStepForward; // increment button
} }
@ -718,11 +719,11 @@ FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x)
{ {
return FScrollbar::scrollPageBackward; // before slider 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 return FScrollbar::scrollPageForward; // after slider
} }
else if ( x == getWidth() ) else if ( x == int(getWidth()) )
{ {
return FScrollbar::scrollStepForward; // increment button return FScrollbar::scrollStepForward; // increment button
} }
@ -739,7 +740,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
if ( mouse_y > slider_pos + 1 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 return mouse_y; // on slider
} }
else // horizontal bar orientation else // horizontal bar orientation
@ -747,13 +748,13 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
if ( isNewFont() ) if ( isNewFont() )
{ {
if ( mouse_x > slider_pos + 2 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 return mouse_x; // on slider
} }
else else
{ {
if ( mouse_x > slider_pos + 1 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 return mouse_x; // on slider
} }
} }
@ -768,7 +769,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
if ( bar_orientation == fc::vertical ) 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)) new_val = int( round ( double(max - min) * (y - 2.0 - (slider_length/2))
/ double(bar_length - slider_length) ) ); / double(bar_length - slider_length) ) );
@ -780,7 +781,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
{ {
int nf = isNewFont() ? 1 : 0; 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)) new_val = int( round ( double(max - min) * (x - 2.0 - nf - (slider_length/2))
/ double(bar_length - slider_length) ) ); / double(bar_length - slider_length) ) );

View File

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

View File

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

View File

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

View File

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

View File

@ -53,13 +53,9 @@ FMouseControl* FTerm::mouse = 0;
#if defined(__linux__) #if defined(__linux__)
FTermLinux* FTerm::linux = 0; FTermLinux* FTerm::linux = 0;
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
FTermFreeBSD* FTerm::freebsd = 0; FTermFreeBSD* FTerm::freebsd = 0;
#endif #elif defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
FTermOpenBSD* FTerm::openbsd = 0; FTermOpenBSD* FTerm::openbsd = 0;
#endif #endif
@ -86,7 +82,7 @@ FTerm::~FTerm() // destructor
// public methods of FTerm // public methods of FTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTerm::getLineNumber() std::size_t FTerm::getLineNumber()
{ {
FRect& term_geometry = data->getTermGeometry(); 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(); FRect& term_geometry = data->getTermGeometry();
@ -170,15 +166,9 @@ bool FTerm::setVGAFont()
if ( data->isVGAFont() ) if ( data->isVGAFont() )
return data->isVGAFont(); return data->isVGAFont();
if ( isGnomeTerminal() if ( hasNoFontSettingOption() )
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
return false; return false;
if ( isXTerminal() || isScreenTerm() if ( isXTerminal() || isScreenTerm()
|| isUrxvtTerminal() || FTermcap::osc_support ) || isUrxvtTerminal() || FTermcap::osc_support )
{ {
@ -219,12 +209,7 @@ bool FTerm::setNewFont()
if ( isNewFont() ) if ( isNewFont() )
return true; return true;
if ( isGnomeTerminal() if ( hasNoFontSettingOption() )
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
return false; return false;
if ( isXTerminal() || isScreenTerm() if ( isXTerminal() || isScreenTerm()
@ -431,7 +416,7 @@ char* FTerm::enableCursor()
// Restore the last used Linux console cursor style // Restore the last used Linux console cursor style
char* cstyle; char* cstyle;
cstyle = linux->restoreCursorStyle(); 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__) #endif // defined(__linux__)
@ -489,10 +474,10 @@ void FTerm::detectTermSize()
term_geometry.setPos(1,1); term_geometry.setPos(1,1);
// Use COLUMNS or fallback to the xterm default width of 80 characters // Use COLUMNS or fallback to the xterm default width of 80 characters
str = std::getenv("COLUMNS"); 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 // Use LINES or fallback to the xterm default height of 24 characters
str = std::getenv("LINES"); str = std::getenv("LINES");
term_geometry.setHeight(str ? std::atoi(str) : 24); term_geometry.setHeight(str ? std::size_t(std::atoi(str)) : 24);
} }
else 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} // Set xterm size to {width} x {height}
@ -840,9 +825,7 @@ void FTerm::initScreenSettings()
linux->initCharMap (fc::character); linux->initCharMap (fc::character);
data->supportShadowCharacter (linux->hasShadowCharacter()); data->supportShadowCharacter (linux->hasShadowCharacter());
data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter()); data->supportHalfBlockCharacter (linux->hasHalfBlockCharacter());
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->initCharMap (fc::character); freebsd->initCharMap (fc::character);
#endif #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() void FTerm::init_termcap()
{ {
std::vector<std::string> terminals; // Initialize the terminal capabilities
std::vector<std::string>::iterator iter;
static const int success = 1; FTermcap termcap;
static const int uninitialized = -2; termcap.setTermData(data);
static char term_buffer[2048]; termcap.setFTermDetection(term_detection);
static char string_buf[2048]; termcap.init();
char* buffer = string_buf;
int status = uninitialized;
bool color256 = term_detection->canDisplay256Colors();
// Share the terminal capabilities // Share the terminal capabilities
tcap = FTermcap::getTermcapMap(); tcap = termcap.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);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_termcap_error (int status) void FTerm::init_quirks()
{ {
static const int no_entry = 0; // Initialize terminal quirks
static const int db_not_found = -1;
static const int uninitialized = -2;
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; FTermcapQuirks quirks;
quirks.setTermData (data); quirks.setTermData (data);
quirks.setFTermDetection (term_detection); quirks.setFTermDetection (term_detection);
quirks.terminalFixup(); // Fix terminal quirks 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() void FTerm::init_optiMove()
{
// 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()
{ {
// Duration precalculation of the cursor movement strings // 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 // 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() if ( isCygwinTerminal()
|| isKdeTerminal() || isKdeTerminal()
|| isTeraTerm() || isTeraTerm()
@ -1673,6 +1431,17 @@ void FTerm::redefineColorPalette()
|| isOpenBSDTerm() || isOpenBSDTerm()
|| isSunTerminal() || isSunTerminal()
|| isAnsiTerminal() ) || isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
{
// Redefine the color palette
if ( ! canChangeColorPalette() )
return; return;
resetColorMap(); resetColorMap();
@ -1687,14 +1456,7 @@ void FTerm::redefineColorPalette()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::restoreColorPalette() void FTerm::restoreColorPalette()
{ {
if ( isCygwinTerminal() if ( ! canChangeColorPalette() )
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return; return;
// Reset screen settings // Reset screen settings
@ -1719,9 +1481,7 @@ void FTerm::setInsertCursorStyle()
, data->isCursorHidden() ); , data->isCursorHidden() );
putstring (cstyle); putstring (cstyle);
std::fflush(stdout); std::fflush(stdout);
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->setCursorStyle ( fc::destructive_cursor freebsd->setCursorStyle ( fc::destructive_cursor
, data->isCursorHidden() ); , data->isCursorHidden() );
#endif #endif
@ -1742,9 +1502,7 @@ void FTerm::setOverwriteCursorStyle()
, data->isCursorHidden() ); , data->isCursorHidden() );
putstring (cstyle); putstring (cstyle);
std::fflush(stdout); std::fflush(stdout);
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->setCursorStyle ( fc::normal_cursor freebsd->setCursorStyle ( fc::normal_cursor
, data->isCursorHidden() ); , data->isCursorHidden() );
#endif #endif
@ -1756,6 +1514,11 @@ void FTerm::setOverwriteCursorStyle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::enableMouse() void FTerm::enableMouse()
{ {
// Enable the terminal mouse support
if ( ! init_values.mouse_support )
return;
bool gpm_mouse = false; bool gpm_mouse = false;
bool xterm_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(); keyboard->disableMouseSequences();
mouse->disable(); 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() void FTerm::useAlternateScreenBuffer()
{ {
@ -1846,13 +1665,9 @@ inline void FTerm::allocationValues()
#if defined(__linux__) #if defined(__linux__)
linux = new FTermLinux(); linux = new FTermLinux();
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
freebsd = new FTermFreeBSD(); freebsd = new FTermFreeBSD();
#endif #elif defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
openbsd = new FTermOpenBSD(); openbsd = new FTermOpenBSD();
#endif #endif
} }
@ -1870,14 +1685,10 @@ inline void FTerm::deallocationValues()
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__)
if ( openbsd ) if ( openbsd )
delete openbsd; delete openbsd;
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( freebsd ) if ( freebsd )
delete freebsd; delete freebsd;
#endif #elif defined(__linux__)
#if defined(__linux__)
if ( linux ) if ( linux )
delete linux; delete linux;
#endif #endif
@ -1907,7 +1718,6 @@ inline void FTerm::deallocationValues()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init (bool disable_alt_screen) void FTerm::init (bool disable_alt_screen)
{ {
int stdout_no = FTermios::getStdOut();
init_term_object = this; init_term_object = this;
// Initialize global values for all objects // Initialize global values for all objects
@ -1927,11 +1737,7 @@ void FTerm::init (bool disable_alt_screen)
FTermios::storeTTYsettings(); FTermios::storeTTYsettings();
// Get output baud rate // Get output baud rate
uInt baud = FTermios::getBaudRate(); initBaudRate();
data->setBaudrate(baud);
if ( isatty(stdout_no) )
opti_move->setBaudRate(int(baud));
// Terminal detection // Terminal detection
term_detection->setTermData(data); term_detection->setTermData(data);
@ -1943,6 +1749,17 @@ void FTerm::init (bool disable_alt_screen)
// Initializes variables for the current terminal // Initializes variables for the current terminal
init_termcap(); 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(); init_alt_charset();
// Pass the terminal capabilities to the keyboard object // Pass the terminal capabilities to the keyboard object
@ -1958,32 +1775,22 @@ void FTerm::init (bool disable_alt_screen)
init_keyboard(); init_keyboard();
// Enable the terminal mouse support // Enable the terminal mouse support
if ( init_values.mouse_support ) enableMouse();
enableMouse();
// Activate meta key sends escape // Activate meta key sends escape
if ( isXTerminal() ) if ( isXTerminal() )
xterm->metaSendsESC(true); xterm->metaSendsESC(true);
// switch to application escape key mode // switch to application escape key mode
if ( isMinttyTerm() ) enableApplicationEscKey();
FTerm::putstring (CSI "?7727h");
// Enter 'keyboard_transmit' mode // Enter 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_xmit) ) enableKeypad();
{
putstring (TCAP(fc::t_keypad_xmit));
std::fflush(stdout);
}
useAlternateScreenBuffer(); useAlternateScreenBuffer();
// Enable alternate charset // Enable alternate charset
if ( TCAP(fc::t_enable_acs) ) enableAlternateCharset();
{
putstring (TCAP(fc::t_enable_acs));
std::fflush(stdout);
}
// Save the used xterm font and window title // Save the used xterm font and window title
init_captureFontAndTitle(); init_captureFontAndTitle();
@ -2043,9 +1850,7 @@ void FTerm::initOSspecifics()
freebsd->disableChangeCursorStyle(); freebsd->disableChangeCursorStyle();
freebsd->init(); // Initialize BSD console freebsd->init(); // Initialize BSD console
#endif // defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
if ( init_values.meta_sends_escape ) if ( init_values.meta_sends_escape )
openbsd->enableMetaSendsEscape(); openbsd->enableMetaSendsEscape();
else else
@ -2068,6 +1873,17 @@ void FTerm::initTermspecifics()
init_teraterm_charmap(); 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() void FTerm::finish()
{ {
@ -2106,12 +1922,8 @@ void FTerm::finish()
if ( init_values.color_change ) if ( init_values.color_change )
restoreColorPalette(); restoreColorPalette();
if ( isMinttyTerm() ) // Switch to normal escape key mode
{ disableApplicationEscKey();
// Switch to normal escape key mode
putstring (CSI "?7727l");
std::fflush(stdout);
}
finishOSspecifics1(); finishOSspecifics1();
@ -2131,11 +1943,7 @@ void FTerm::finish()
useNormalScreenBuffer(); useNormalScreenBuffer();
// leave 'keyboard_transmit' mode // leave 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_local) ) disableKeypad();
{
putstring (TCAP(fc::t_keypad_local));
std::fflush(stdout);
}
finish_encoding(); finish_encoding();
@ -2150,13 +1958,9 @@ void FTerm::finishOSspecifics1()
{ {
#if defined(__linux__) #if defined(__linux__)
linux->finish(); linux->finish();
#endif #elif defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->finish(); freebsd->finish();
#endif #elif defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
openbsd->finish(); openbsd->finish();
#endif #endif
} }

View File

@ -26,16 +26,19 @@ namespace finalcut
{ {
// static class attributes // static class attributes
bool FTermcap::background_color_erase = false; bool FTermcap::background_color_erase = false;
bool FTermcap::automatic_left_margin = false; bool FTermcap::can_change_color_palette = false;
bool FTermcap::automatic_right_margin = false; bool FTermcap::automatic_left_margin = false;
bool FTermcap::eat_nl_glitch = false; bool FTermcap::automatic_right_margin = false;
bool FTermcap::ansi_default_color = false; bool FTermcap::eat_nl_glitch = false;
bool FTermcap::osc_support = false; bool FTermcap::ansi_default_color = false;
bool FTermcap::no_utf8_acs_chars = false; bool FTermcap::osc_support = false;
int FTermcap::max_color = 1; bool FTermcap::no_utf8_acs_chars = false;
int FTermcap::tabstop = 8; int FTermcap::max_color = 1;
int FTermcap::attr_without_color = 0; 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 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 // private Data Member of FTermcap - termcap capabilities
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

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

View File

@ -750,7 +750,12 @@ char* FTermDetection::secDA_Analysis (char current_termtype[])
case 41: // DEC VT420 case 41: // DEC VT420
case 61: // DEC VT510 case 61: // DEC VT510
case 64: // DEC VT520 case 64: // DEC VT520
break;
case 65: // DEC VT525 case 65: // DEC VT525
new_termtype = secDA_Analysis_65(current_termtype);
break;
case 67: // Cygwin case 67: // Cygwin
new_termtype = secDA_Analysis_67(current_termtype); new_termtype = secDA_Analysis_67(current_termtype);
break; break;
@ -780,7 +785,9 @@ char* FTermDetection::secDA_Analysis (char current_termtype[])
} }
// Correct false assumptions // 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; terminal_type.gnome_terminal = false;
if ( isKdeTerminal() && secondary_da.terminal_id_type != 0 ) 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 // Terminal ID 1 - DEC VT220
char* new_termtype = current_termtype; char* new_termtype = current_termtype;
new_termtype = secDA_Analysis_vte(new_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; return new_termtype;
} }
@ -870,6 +864,16 @@ inline char* FTermDetection::secDA_Analysis_32 (char[])
return new_termtype; 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[]) inline char* FTermDetection::secDA_Analysis_67 (char[])
{ {
@ -955,4 +959,28 @@ inline char* FTermDetection::secDA_Analysis_85 (char current_termtype[])
return new_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 } // namespace finalcut

View File

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

View File

@ -31,8 +31,8 @@ namespace finalcut
bool FTermXTerminal::mouse_support; bool FTermXTerminal::mouse_support;
bool FTermXTerminal::meta_sends_esc; bool FTermXTerminal::meta_sends_esc;
bool FTermXTerminal::xterm_default_colors; bool FTermXTerminal::xterm_default_colors;
int FTermXTerminal::term_width = 80; std::size_t FTermXTerminal::term_width = 80;
int FTermXTerminal::term_height = 24; std::size_t FTermXTerminal::term_height = 24;
const FString* FTermXTerminal::xterm_font = 0; const FString* FTermXTerminal::xterm_font = 0;
const FString* FTermXTerminal::xterm_title = 0; const FString* FTermXTerminal::xterm_title = 0;
const FString* FTermXTerminal::foreground_color = 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} // Set xterm size to {term_width} x {term_height}
@ -417,7 +417,9 @@ void FTermXTerminal::setXTermSize()
{ {
if ( term_detection->isXTerminal() ) 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); std::fflush(stdout);
} }
} }

View File

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

View File

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

View File

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

View File

@ -110,8 +110,8 @@ void FVTerm::setTermXY (int x, int y)
if ( term_pos->getX() == x && term_pos->getY() == y ) if ( term_pos->getX() == x && term_pos->getY() == y )
return; return;
term_width = getColumnNumber(); term_width = int(getColumnNumber());
term_height = getLineNumber(); term_height = int(getLineNumber());
if ( x >= term_width ) if ( x >= term_width )
{ {
@ -597,8 +597,8 @@ void FVTerm::createArea ( const FRect& r
{ {
createArea ( r.getX() createArea ( r.getX()
, r.getY() , r.getY()
, r.getWidth() , int(r.getWidth())
, r.getHeight() , int(r.getHeight())
, p.getX() , p.getX()
, p.getY() , p.getY()
, area ); , area );
@ -633,8 +633,8 @@ void FVTerm::resizeArea ( const FRect& r
{ {
resizeArea ( r.getX() resizeArea ( r.getX()
, r.getY() , r.getY()
, r.getWidth() , int(r.getWidth())
, r.getHeight() , int(r.getHeight())
, p.getX() , p.getX()
, p.getY() , p.getY()
, area ); , area );
@ -653,7 +653,7 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
assert ( height > 0 ); assert ( height > 0 );
assert ( rsw >= 0 ); assert ( rsw >= 0 );
assert ( bsh >= 0 ); assert ( bsh >= 0 );
int area_size; std::size_t area_size;
bool realloc_success = false; bool realloc_success = false;
if ( ! area ) if ( ! area )
@ -673,11 +673,13 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
return; return;
} }
area_size = (width + rsw) * (height + bsh); area_size = std::size_t((width + rsw) * (height + bsh));
if ( area->height + area->bottom_shadow != 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 ) 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 inline bool FVTerm::reallocateTextArea ( term_area* area
, int height , std::size_t height
, int size ) , std::size_t size )
{ {
assert ( height > 0 );
assert ( size > 0 );
if ( area->changes != 0 ) if ( area->changes != 0 )
delete[] area->changes; delete[] area->changes;
@ -741,8 +740,8 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
try try
{ {
area->changes = new line_changes[uInt(height)]; area->changes = new line_changes[height];
area->text = new charData[uInt(size)]; area->text = new charData[size];
} }
catch (const std::bad_alloc& ex) 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 ) if ( area->text != 0 )
delete[] area->text; delete[] area->text;
try try
{ {
area->text = new charData[uInt(size)]; area->text = new charData[size];
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -803,8 +800,8 @@ void FVTerm::restoreVTerm (const FRect& box)
{ {
restoreVTerm ( box.getX() restoreVTerm ( box.getX()
, box.getY() , box.getY()
, box.getWidth() , int(box.getWidth())
, box.getHeight() ); , int(box.getHeight()) );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -904,8 +901,8 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
int win_y = win->offset_top; int win_y = win->offset_top;
FRect geometry ( win_x FRect geometry ( win_x
, win_y , win_y
, win->width + win->right_shadow , std::size_t(win->width + win->right_shadow)
, win->height + win->bottom_shadow ); , std::size_t(win->height + win->bottom_shadow) );
if ( found && geometry.contains(x, y) ) 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 // Check whether the coordinates are within the area
int ax = 0 int ax = 0, ay = 0;
, ay = 0 std::size_t aw = std::size_t(area->width);
, aw = area->width std::size_t ah = std::size_t(area->height);
, ah = area->height;
FRect area_geometry(ax, ay, aw, ah); FRect area_geometry(ax, ay, aw, ah);
if ( area_geometry.contains(x, y) ) if ( area_geometry.contains(x, y) )
@ -1392,8 +1388,8 @@ void FVTerm::getArea (const FRect& box, term_area* area)
{ {
getArea ( box.getX() getArea ( box.getX()
, box.getY() , box.getY()
, box.getWidth() , int(box.getWidth())
, box.getHeight() , int(box.getHeight())
, area ); , area );
} }
@ -1722,7 +1718,7 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
// Generates characters for a given position considering all areas // Generates characters for a given position considering all areas
FWidget::widgetList::const_iterator iter, end; FWidget::widgetList::const_iterator iter, end;
charData* sc; // shown character charData* sc; // shown character
FWidget* widget; FWidget* widget;
widget = static_cast<FWidget*>(vterm->widget); widget = static_cast<FWidget*>(vterm->widget);
sc = &vdesktop->text[y * vdesktop->width + x]; sc = &vdesktop->text[y * vdesktop->width + x];
@ -1744,8 +1740,8 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
int win_y = win->offset_top; int win_y = win->offset_top;
FRect geometry ( win_x FRect geometry ( win_x
, win_y , win_y
, win->width + win->right_shadow , std::size_t(win->width + win->right_shadow)
, win->height + win->bottom_shadow ); , std::size_t(win->height + win->bottom_shadow) );
// Window is visible and contains current character // Window is visible and contains current character
if ( geometry.contains(x, y) ) if ( geometry.contains(x, y) )
@ -1860,8 +1856,8 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
FRect geometry ( win->offset_left FRect geometry ( win->offset_left
, win->offset_top , win->offset_top
, win->width + win->right_shadow , std::size_t(win->width + win->right_shadow)
, win->height + win->bottom_shadow ); , std::size_t(win->height + win->bottom_shadow) );
// Window visible and contains current character // Window visible and contains current character
if ( geometry.contains(x, y) ) if ( geometry.contains(x, y) )
@ -2191,7 +2187,7 @@ bool FVTerm::clearTerm (int fillchar)
{ {
term_pos->setPoint(-1, -1); term_pos->setPoint(-1, -1);
for (int i = 0; i < getLineNumber(); i++) for (int i = 0; i < int(getLineNumber()); i++)
{ {
setTermXY (0, i); setTermXY (0, i);
appendOutputBuffer (cb); appendOutputBuffer (cb);
@ -2878,8 +2874,8 @@ int FVTerm::appendLowerRight (charData*& screen_char)
char* ip = TCAP(fc::t_insert_padding); char* ip = TCAP(fc::t_insert_padding);
char* ic = TCAP(fc::t_insert_character); char* ic = TCAP(fc::t_insert_character);
x = getColumnNumber() - 2; x = int(getColumnNumber()) - 2;
y = getLineNumber() - 1; y = int(getLineNumber()) - 1;
setTermXY (x, y); setTermXY (x, y);
appendChar (screen_char); appendChar (screen_char);
term_pos->x_ref()++; term_pos->x_ref()++;

View File

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

View File

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

View File

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

View File

@ -92,11 +92,7 @@ class FApplication : public FWidget
const char* getClassName() const; const char* getClassName() const;
int getArgc() const; int getArgc() const;
char** getArgv() const; char** getArgv() const;
FWidget* getMainWidget() const; static FWidget* getApplicationObject();
virtual FWidget* getFocusWidget() const;
// Mutator
void setMainWidget (FWidget*);
// Inquiry // Inquiry
static bool isQuit(); static bool isQuit();
@ -193,28 +189,6 @@ class FApplication : public FWidget
static bool process_timer_event; static bool process_timer_event;
static FKeyboard* keyboard; static FKeyboard* keyboard;
static FWidget* keyboard_widget; 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) #pragma pack(pop)
@ -232,14 +206,6 @@ inline int FApplication::getArgc() const
inline char** FApplication::getArgv() const inline char** FApplication::getArgv() const
{ return app_argv; } { 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) inline void FApplication::cb_exitApp (FWidget*, data_ptr)
{ close(); } { close(); }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -115,18 +115,18 @@ class FListViewItem : public FObject
bool isExpandable() const; bool isExpandable() const;
// Methods // Methods
template<typename Compare> template <typename Compare>
void sort (Compare); void sort (Compare);
FObjectIterator appendItem (FListViewItem*); FObjectIterator appendItem (FListViewItem*);
void replaceControlCodes(); void replaceControlCodes();
int getVisibleLines(); std::size_t getVisibleLines();
void resetVisibleLineCounter(); void resetVisibleLineCounter();
// Data Members // Data Members
FStringList column_list; FStringList column_list;
FWidget::data_ptr data_pointer; FWidget::data_ptr data_pointer;
FObjectIterator root; FObjectIterator root;
int visible_lines; std::size_t visible_lines;
bool expandable; bool expandable;
bool is_expand; bool is_expand;
@ -260,7 +260,7 @@ class FListView : public FWidget
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
uInt getCount(); std::size_t getCount();
fc::text_alignment getColumnAlignment (int) const; fc::text_alignment getColumnAlignment (int) const;
FString getColumnText (int) const; FString getColumnText (int) const;
fc::sorting_type getColumnSortType (int) const; fc::sorting_type getColumnSortType (int) const;
@ -269,16 +269,16 @@ class FListView : public FWidget
FListViewItem* getCurrentItem(); FListViewItem* getCurrentItem();
// Mutators // 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 setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&); void setColumnText (int, const FString&);
void setColumnSortType (int,fc::sorting_type \ void setColumnSortType (int,fc::sorting_type \
= fc::by_name); = fc::by_name);
void setColumnSort (int, fc::sorting_order \ void setColumnSort (int, fc::sorting_order \
= fc::ascending); = fc::ascending);
template<typename Compare> template <typename Compare>
void setUserAscendingCompare (Compare); void setUserAscendingCompare (Compare);
template<typename Compare> template <typename Compare>
void setUserDescendingCompare (Compare); void setUserDescendingCompare (Compare);
bool setTreeView (bool); bool setTreeView (bool);
bool setTreeView(); bool setTreeView();
@ -342,15 +342,17 @@ class FListView : public FWidget
// Methods // Methods
void init(); void init();
template<typename Compare> template <typename Compare>
void sort (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(); virtual void draw();
void drawColumnLabels(); void drawColumnLabels();
void drawList(); void drawList();
void drawListLine (const FListViewItem*, bool, bool); void drawListLine (const FListViewItem*, bool, bool);
void setLineAttributes (bool, bool); void setLineAttributes (bool, bool);
FString getLinePrefix (const FListViewItem*, uInt); FString getLinePrefix (const FListViewItem*, std::size_t);
void drawColumnText (headerItems::const_iterator&); void drawColumnText (headerItems::const_iterator&);
void drawColumnEllipsis ( headerItems::const_iterator& void drawColumnEllipsis ( headerItems::const_iterator&
, const FString& ); , const FString& );
@ -463,12 +465,12 @@ inline FListViewItem* FListView::getCurrentItem()
{ return static_cast<FListViewItem*>(*current_iter); } { return static_cast<FListViewItem*>(*current_iter); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename Compare> template <typename Compare>
inline void FListView::setUserAscendingCompare (Compare cmp) inline void FListView::setUserAscendingCompare (Compare cmp)
{ user_defined_ascending = cmp; } { user_defined_ascending = cmp; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename Compare> template <typename Compare>
inline void FListView::setUserDescendingCompare (Compare cmp) inline void FListView::setUserDescendingCompare (Compare cmp)
{ user_defined_descending = cmp; } { user_defined_descending = cmp; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,7 +54,7 @@ class FRect
// Constructors // Constructors
FRect (); FRect ();
FRect (const FRect&); // copy constructor FRect (const FRect&); // copy constructor
FRect (int, int, int, int); FRect (int, int, std::size_t, std::size_t);
FRect (const FPoint&, const FPoint&); FRect (const FPoint&, const FPoint&);
// Destructor // Destructor
@ -72,55 +72,55 @@ class FRect
// Accessors // Accessors
virtual const char* getClassName(); virtual const char* getClassName();
int getX1() const; int getX1() const;
int getY1() const; int getY1() const;
int getX2() const; int getX2() const;
int getY2() const; int getY2() const;
int getX() const; int getX() const;
int getY() const; int getY() const;
FPoint getPos() const; FPoint getPos() const;
FPoint getUpperLeftPos() const; FPoint getUpperLeftPos() const;
FPoint getUpperRightPos() const; FPoint getUpperRightPos() const;
FPoint getLowerLeftPos() const; FPoint getLowerLeftPos() const;
FPoint getLowerRightPos() const; FPoint getLowerRightPos() const;
int getWidth() const; std::size_t getWidth() const;
int getHeight() const; std::size_t getHeight() const;
// Mutators // Mutators
void setX1 (int); void setX1 (int);
void setY1 (int); void setY1 (int);
void setX2 (int); void setX2 (int);
void setY2 (int); void setY2 (int);
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPos (int, int); void setPos (int, int);
void setPos (const FPoint&); void setPos (const FPoint&);
void setWidth (int); void setWidth (std::size_t);
void setHeight (int); void setHeight (std::size_t);
void setSize (int, int); void setSize (std::size_t, std::size_t);
void setRect (const FRect&); 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 (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int); void setCoordinates (int, int, int, int);
// Inquiry // Inquiry
bool isNull() const; bool isNull() const;
// Coordinate references // Coordinate references
short& x1_ref(); short& x1_ref();
short& y1_ref(); short& y1_ref();
short& x2_ref(); short& x2_ref();
short& y2_ref(); short& y2_ref();
// Methods // Methods
void move (int, int); void move (int, int);
void move (const FPoint&); void move (const FPoint&);
bool contains (int, int) const; bool contains (int, int) const;
bool contains (const FPoint&) const; bool contains (const FPoint&) const;
bool contains (const FRect&) const; bool contains (const FRect&) const;
bool overlap (const FRect&) const; bool overlap (const FRect&) const;
FRect intersect (const FRect&) const; FRect intersect (const FRect&) const;
FRect combined (const FRect&) const; FRect combined (const FRect&) const;
private: private:
// Data Members // Data Members
@ -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)) : X1(short(x))
, Y1(short(y)) , Y1(short(y))
, X2(short(x + width - 1)) , X2(short(x + short(width) - 1))
, Y2(short(y + height - 1)) , Y2(short(y + short(height) - 1))
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -206,12 +206,18 @@ inline FPoint FRect::getLowerRightPos() const
{ return FPoint(X2, Y2); } { return FPoint(X2, Y2); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FRect::getWidth() const inline std::size_t FRect::getWidth() const
{ return short(X2 - X1 + 1); } {
short w = X2 - X1 + 1;
return ( w < 0 ) ? 0 : std::size_t(w);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FRect::getHeight() const inline std::size_t FRect::getHeight() const
{ return short(Y2 - Y1 + 1); } {
short h = Y2 - Y1 + 1;
return ( h < 0 ) ? 0 : std::size_t(h);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline short& FRect::x1_ref() inline short& FRect::x1_ref()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,10 +35,36 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
// FTermcap string macro #if defined(__sun) && defined(__SVR4)
#define TCAP(s) tcap[(s)].string #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 <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 namespace finalcut
{ {
@ -74,8 +100,16 @@ class FTermcap
return tcap; return tcap;
} }
// Mutator
static void setTermData (FTermData*);
static void setFTermDetection (FTermDetection*);
// Methods
static void init();
// Data Members // Data Members
static bool background_color_erase; static bool background_color_erase;
static bool can_change_color_palette;
static bool automatic_left_margin; static bool automatic_left_margin;
static bool automatic_right_margin; static bool automatic_right_margin;
static bool eat_nl_glitch; static bool eat_nl_glitch;
@ -87,8 +121,20 @@ class FTermcap
static int attr_without_color; static int attr_without_color;
private: 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 // Data Member
static tcap_map tcap[]; static tcap_map tcap[];
static FTermData* fterm_data;
static FTermDetection* term_detection;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -219,8 +219,10 @@ void FPointTest::equalTest()
CPPUNIT_ASSERT ( p1 == p2 ); CPPUNIT_ASSERT ( p1 == p2 );
CPPUNIT_ASSERT ( finalcut::FPoint(1,2) == p2 ); CPPUNIT_ASSERT ( finalcut::FPoint(1,2) == p2 );
CPPUNIT_ASSERT ( p1 == finalcut::FPoint(1,2) ); CPPUNIT_ASSERT ( p1 == finalcut::FPoint(1,2) );
CPPUNIT_ASSERT ( finalcut::FPoint() == finalcut::FPoint() ); const finalcut::FPoint p3;
CPPUNIT_ASSERT ( finalcut::FPoint() == -finalcut::FPoint() ); 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 ( r1 == r2 );
CPPUNIT_ASSERT ( finalcut::FRect(1, 2, 10, 20) == r2 ); CPPUNIT_ASSERT ( finalcut::FRect(1, 2, 10, 20) == r2 );
CPPUNIT_ASSERT ( r1 == finalcut::FRect(1, 2, 10, 20) ); 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

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