Corrected swapped top and left offset variables in the class FVTerm

This commit is contained in:
Markus Gans 2017-02-25 15:18:29 +01:00
parent 34961037f8
commit bd06df8987
9 changed files with 139 additions and 97 deletions

View File

@ -1,3 +1,7 @@
2017-02-24 Markus Gans <guru.mail@muenster.de>
* Corrected swapped top and left offset variables
in the class FVTerm
2017-02-24 Markus Gans <guru.mail@muenster.de> 2017-02-24 Markus Gans <guru.mail@muenster.de>
* FListBox gets the option to save a data pointer for * FListBox gets the option to save a data pointer for
every FListBoxItem element every FListBoxItem element

View File

@ -21,6 +21,14 @@ FListBoxItem::FListBoxItem()
, selected(false) , selected(false)
{ } { }
//----------------------------------------------------------------------
FListBoxItem::FListBoxItem (const FListBoxItem& item)
: text(item.text)
, data_pointer(item.data_pointer)
, brackets(item.brackets)
, selected(item.selected)
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListBoxItem::FListBoxItem (FString& txt, FWidget::data_ptr data) FListBoxItem::FListBoxItem (FString& txt, FWidget::data_ptr data)
: text(txt) : text(txt)
@ -49,6 +57,24 @@ FListBoxItem::FListBoxItem (const char* txt, FWidget::data_ptr data)
FListBoxItem::~FListBoxItem() FListBoxItem::~FListBoxItem()
{ } { }
// public methods of FListBoxItem
//----------------------------------------------------------------------
FListBoxItem& FListBoxItem::operator = (const FListBoxItem& item)
{
if ( &item == this )
{
return *this;
}
else
{
text = item.text;
data_pointer = item.data_pointer;
brackets = item.brackets;
selected = item.selected;
return *this;
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FListBox // class FListBox
@ -56,7 +82,7 @@ FListBoxItem::~FListBoxItem()
// constructor and destructor // constructor and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListBox::FListBox(FWidget* parent) FListBox::FListBox (FWidget* parent)
: FWidget(parent) : FWidget(parent)
, data() , data()
, vbar(0) , vbar(0)
@ -92,7 +118,7 @@ FListBox::~FListBox() // destructor
// public methods of FListBox // public methods of FListBox
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::setCurrentItem(int index) void FListBox::setCurrentItem (int index)
{ {
int element_count; int element_count;

View File

@ -47,6 +47,7 @@ class FListBoxItem
public: public:
// Constructors // Constructors
FListBoxItem (); FListBoxItem ();
FListBoxItem (const FListBoxItem&); // copy constructor
explicit FListBoxItem (FString&, FWidget::data_ptr = 0); explicit FListBoxItem (FString&, FWidget::data_ptr = 0);
explicit FListBoxItem (const std::string&, FWidget::data_ptr = 0); explicit FListBoxItem (const std::string&, FWidget::data_ptr = 0);
explicit FListBoxItem (const char*, FWidget::data_ptr = 0); explicit FListBoxItem (const char*, FWidget::data_ptr = 0);
@ -54,6 +55,9 @@ class FListBoxItem
// Destructor // Destructor
virtual ~FListBoxItem(); virtual ~FListBoxItem();
// Assignment operator (=)
FListBoxItem& operator = (const FListBoxItem&);
// Accessors // Accessors
virtual FString getText() const; virtual FString getText() const;
virtual FWidget::data_ptr getData() const; virtual FWidget::data_ptr getData() const;

View File

@ -11,6 +11,7 @@
#ifndef _FOBJECT_H #ifndef _FOBJECT_H
#define _FOBJECT_H #define _FOBJECT_H
#include <stdint.h>
#include <sys/time.h> // need for gettimeofday #include <sys/time.h> // need for gettimeofday
#include <cstdlib> #include <cstdlib>
#include <list> #include <list>
@ -24,16 +25,16 @@
typedef unsigned char uChar; typedef unsigned char uChar;
typedef unsigned int uInt; typedef unsigned int uInt;
typedef unsigned long uLong; typedef unsigned long uLong;
typedef unsigned char uInt8; typedef uint8_t uInt8;
typedef unsigned short uInt16; typedef uint16_t uInt16;
typedef unsigned int uInt32; typedef uint32_t uInt32;
typedef u_int64_t uInt64; typedef uint64_t uInt64;
typedef signed int sInt; typedef signed int sInt;
typedef signed long sLong; typedef signed long sLong;
typedef signed char sInt8; typedef int8_t sInt8;
typedef signed short sInt16; typedef int16_t sInt16;
typedef signed int sInt32; typedef int32_t sInt32;
typedef int64_t sInt64; typedef int64_t sInt64;
typedef long double lDouble; typedef long double lDouble;

View File

@ -143,8 +143,8 @@ void FScrollView::setX (int x, bool adjust)
if ( viewport ) if ( viewport )
{ {
viewport->offset_top = scroll_geometry.getX(); viewport->offset_left = scroll_geometry.getX();
viewport->offset_left = scroll_geometry.getY(); viewport->offset_top = scroll_geometry.getY();
} }
} }
} }
@ -160,8 +160,8 @@ void FScrollView::setY (int y, bool adjust)
if ( viewport ) if ( viewport )
{ {
viewport->offset_top = scroll_geometry.getX(); viewport->offset_left = scroll_geometry.getX();
viewport->offset_left = scroll_geometry.getY(); viewport->offset_top = scroll_geometry.getY();
} }
} }
} }
@ -177,8 +177,8 @@ void FScrollView::setPos (int x, int y, bool adjust)
{ {
if ( viewport ) if ( viewport )
{ {
viewport->offset_top = scroll_geometry.getX(); viewport->offset_left = scroll_geometry.getX();
viewport->offset_left = scroll_geometry.getY(); viewport->offset_top = scroll_geometry.getY();
} }
} }
} }
@ -235,8 +235,8 @@ void FScrollView::setGeometry (int x, int y, int w, int h, bool adjust)
} }
else if ( ! adjust && viewport ) else if ( ! adjust && viewport )
{ {
viewport->offset_top = scroll_geometry.getX(); viewport->offset_left = scroll_geometry.getX();
viewport->offset_left = scroll_geometry.getY(); viewport->offset_top = scroll_geometry.getY();
} }
} }
@ -662,8 +662,8 @@ void FScrollView::adjustSize()
if ( viewport ) if ( viewport )
{ {
viewport->offset_top = scroll_geometry.getX(); viewport->offset_left = scroll_geometry.getX();
viewport->offset_left = scroll_geometry.getY(); viewport->offset_top = scroll_geometry.getY();
} }
hbar->setMaximum (getScrollWidth() - getViewportWidth()); hbar->setMaximum (getScrollWidth() - getViewportWidth());
@ -701,8 +701,8 @@ void FScrollView::copy2area()
if ( ! viewport->has_changes ) if ( ! viewport->has_changes )
return; return;
ax = getTermX() - print_area->offset_top; ax = getTermX() - print_area->offset_left;
ay = getTermY() - print_area->offset_left; 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 = getViewportHeight();

View File

@ -37,16 +37,16 @@
typedef unsigned char uChar; typedef unsigned char uChar;
typedef unsigned int uInt; typedef unsigned int uInt;
typedef unsigned long uLong; typedef unsigned long uLong;
typedef unsigned char uInt8; typedef uint8_t uInt8;
typedef unsigned short uInt16; typedef uint16_t uInt16;
typedef unsigned int uInt32; typedef uint32_t uInt32;
typedef u_int64_t uInt64; typedef uint64_t uInt64;
typedef signed int sInt; typedef signed int sInt;
typedef signed long sLong; typedef signed long sLong;
typedef signed char sInt8; typedef int8_t sInt8;
typedef signed short sInt16; typedef int16_t sInt16;
typedef signed int sInt32; typedef int32_t sInt32;
typedef int64_t sInt64; typedef int64_t sInt64;
typedef long double lDouble; typedef long double lDouble;

View File

@ -64,8 +64,8 @@ FPoint FVTerm::getPrintCursor()
term_area* win = getPrintArea(); term_area* win = getPrintArea();
if ( win ) if ( win )
return FPoint ( win->offset_top + win->cursor_x return FPoint ( win->offset_left + win->cursor_x
, win->offset_left + win->cursor_y ); , win->offset_top + win->cursor_y );
return FPoint(0,0); return FPoint(0,0);
} }
@ -150,8 +150,8 @@ void FVTerm::setPrintCursor (register int x, register int y)
if ( win ) if ( win )
{ {
win->cursor_x = x - win->offset_top; win->cursor_x = x - win->offset_left;
win->cursor_y = y - win->offset_left; win->cursor_y = y - win->offset_top;
} }
} }
@ -704,7 +704,7 @@ void FVTerm::createArea ( const FRect& r
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createArea ( int offset_top, int offset_left void FVTerm::createArea ( int offset_left, int offset_top
, int width, int height , int width, int height
, int rsw, int bsh , int rsw, int bsh
, term_area*& area ) , term_area*& area )
@ -713,7 +713,7 @@ void FVTerm::createArea ( int offset_top, int offset_left
area = new term_area; area = new term_area;
area->widget = static_cast<FWidget*>(this); area->widget = static_cast<FWidget*>(this);
resizeArea (offset_top, offset_left, width, height, rsw, bsh, area); resizeArea (offset_left, offset_top, width, height, rsw, bsh, area);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -731,13 +731,12 @@ void FVTerm::resizeArea ( const FRect& r
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::resizeArea ( int offset_top, int offset_left void FVTerm::resizeArea ( int offset_left, int offset_top
, int width, int height , int width, int height
, int rsw, int bsh , int rsw, int bsh
, term_area* area ) , term_area* area )
{ {
assert ( offset_top >= 0 ); assert ( offset_top >= 0 );
assert ( offset_left >= 0 );
assert ( width > 0 ); assert ( width > 0 );
assert ( height > 0 ); assert ( height > 0 );
assert ( rsw >= 0 ); assert ( rsw >= 0 );
@ -772,8 +771,8 @@ void FVTerm::resizeArea ( int offset_top, int offset_left
else else
return; return;
area->offset_top = offset_top;
area->offset_left = offset_left; area->offset_left = offset_left;
area->offset_top = offset_top;
area->width = width; area->width = width;
area->height = height; area->height = height;
area->right_shadow = rsw; area->right_shadow = rsw;
@ -901,8 +900,8 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
if ( ! win->visible ) if ( ! win->visible )
continue; continue;
int win_x = win->offset_top; int win_x = win->offset_left;
int win_y = win->offset_left; int win_y = win->offset_top;
FRect geometry ( win_x FRect geometry ( win_x
, win_y , win_y
, win->width + win->right_shadow , win->width + win->right_shadow
@ -1000,8 +999,8 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
if ( ! win->visible ) if ( ! win->visible )
continue; continue;
int win_x = win->offset_top; int win_x = win->offset_left;
int win_y = win->offset_left; int win_y = win->offset_top;
FRect geometry ( win_x FRect geometry ( win_x
, win_y , win_y
, win->width + win->right_shadow , win->width + win->right_shadow
@ -1120,8 +1119,8 @@ void FVTerm::updateVTerm (term_area* area)
} }
} }
ax = area->offset_top; ax = area->offset_left;
ay = area->offset_left; ay = area->offset_top;
aw = area->width; aw = area->width;
ah = area->height; ah = area->height;
rsh = area->right_shadow; rsh = area->right_shadow;
@ -1298,8 +1297,8 @@ bool FVTerm::updateVTermCursor (term_area* area)
{ {
int cx, cy, ax, ay, x, y; int cx, cy, ax, ay, x, y;
// area offset // area offset
ax = area->offset_top; ax = area->offset_left;
ay = area->offset_left; ay = area->offset_top;
// area cursor position // area cursor position
cx = area->input_cursor_x; cx = area->input_cursor_x;
cy = area->input_cursor_y; cy = area->input_cursor_y;
@ -1426,8 +1425,8 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
if ( ! area ) if ( ! area )
return; return;
dx = x - area->offset_top + 1; dx = x - area->offset_left + 1;
dy = y - area->offset_left + 1; dy = y - area->offset_top + 1;
if ( x < 0 || y < 0 ) if ( x < 0 || y < 0 )
return; return;
@ -1871,8 +1870,8 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
if ( ! win->visible ) if ( ! win->visible )
continue; continue;
int win_x = win->offset_top; int win_x = win->offset_left;
int win_y = win->offset_left; int win_y = win->offset_top;
FRect geometry ( win_x FRect geometry ( win_x
, win_y , win_y
, win->width + win->right_shadow , win->width + win->right_shadow

View File

@ -66,11 +66,13 @@ class FVTerm : public FObject, public FTerm
typedef std::vector<vterm_preprocessing> FPreprocessing; typedef std::vector<vterm_preprocessing> FPreprocessing;
// define virtual terminal character properties
struct term_area struct term_area
{ {
public:
term_area() term_area()
: offset_top (0) : offset_left (0)
, offset_left (0) , offset_top (0)
, width (-1) , width (-1)
, height (-1) , height (-1)
, right_shadow (0) , right_shadow (0)
@ -91,8 +93,8 @@ class FVTerm : public FObject, public FTerm
~term_area() ~term_area()
{ } { }
int offset_top; // Distance from top of the terminal
int offset_left; // Distance from left terminal side int offset_left; // Distance from left terminal side
int offset_top; // Distance from top of the terminal
int width; // Window width int width; // Window width
int height; // Window height int height; // Window height
int right_shadow; // Right window shadow int right_shadow; // Right window shadow
@ -108,6 +110,12 @@ class FVTerm : public FObject, public FTerm
bool input_cursor_visible; bool input_cursor_visible;
bool has_changes; bool has_changes;
bool visible; bool visible;
private:
// Disable copy constructor
term_area (const term_area&);
// Disable assignment operator (=)
term_area& operator = (const term_area&);
}; };
enum covered_state enum covered_state

View File

@ -308,7 +308,7 @@ void FWindow::setX (int x, bool adjust)
FWidget::setX (x, adjust); FWidget::setX (x, adjust);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
vwin->offset_top = getTermX() - 1; vwin->offset_left = getTermX() - 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -320,7 +320,7 @@ void FWindow::setY (int y, bool adjust)
FWidget::setY (y, adjust); FWidget::setY (y, adjust);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
vwin->offset_left = getTermY() - 1; vwin->offset_top = getTermY() - 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -333,8 +333,8 @@ void FWindow::setPos (int x, int y, bool adjust)
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
vwin->offset_top = getTermX() - 1; vwin->offset_left = getTermX() - 1;
vwin->offset_left = getTermY() - 1; vwin->offset_top = getTermY() - 1;
} }
} }
@ -406,10 +406,10 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
else else
{ {
if ( getX() != old_x ) if ( getX() != old_x )
vwin->offset_top = getTermX() - 1; vwin->offset_left = getTermX() - 1;
if ( getY() != old_y ) if ( getY() != old_y )
vwin->offset_left = getTermY() - 1; vwin->offset_top = getTermY() - 1;
} }
} }
@ -420,8 +420,8 @@ void FWindow::move (int dx, int dy)
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
vwin->offset_top = getTermX() - 1; vwin->offset_left = getTermX() - 1;
vwin->offset_left = getTermY() - 1; vwin->offset_top = getTermY() - 1;
} }
} }
@ -788,10 +788,10 @@ void FWindow::adjustSize()
else if ( isVirtualWindow() ) else if ( isVirtualWindow() )
{ {
if ( getX() != old_x ) if ( getX() != old_x )
vwin->offset_top = getTermX() - 1; vwin->offset_left = getTermX() - 1;
if ( getY() != old_y ) if ( getY() != old_y )
vwin->offset_left = getTermY() - 1; vwin->offset_top = getTermY() - 1;
} }
} }