FColor fix
This commit is contained in:
parent
9b3f30f006
commit
e40a233d64
|
@ -316,8 +316,7 @@ Calc::Calc (FWidget* parent)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Calc::~Calc()
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::drawDispay()
|
||||
|
|
|
@ -40,8 +40,8 @@ class ColorChooser : public finalcut::FWidget
|
|||
~ColorChooser();
|
||||
|
||||
// Accessors
|
||||
short getForeground();
|
||||
short getBackground();
|
||||
FColor getForeground();
|
||||
FColor getBackground();
|
||||
|
||||
private:
|
||||
// Disable copy constructor
|
||||
|
@ -56,8 +56,8 @@ class ColorChooser : public finalcut::FWidget
|
|||
virtual void onMouseDown (finalcut::FMouseEvent*);
|
||||
|
||||
// Data Members
|
||||
short fg_color;
|
||||
short bg_color;
|
||||
FColor fg_color;
|
||||
FColor bg_color;
|
||||
finalcut::FLabel headline;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
@ -75,8 +75,8 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
|
|||
|
||||
if ( parent )
|
||||
{
|
||||
short fg = parent->getForegroundColor();
|
||||
short bg = parent->getBackgroundColor();
|
||||
FColor fg = parent->getForegroundColor();
|
||||
FColor bg = parent->getBackgroundColor();
|
||||
setForegroundColor(fg);
|
||||
setBackgroundColor(bg);
|
||||
headline.setForegroundColor(fg);
|
||||
|
@ -112,9 +112,9 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
|
|||
if ( mouse_x >= xmin && mouse_x <= xmax && mouse_y == y )
|
||||
{
|
||||
if ( ev->getButton() == finalcut::fc::LeftButton )
|
||||
bg_color = short(c);
|
||||
bg_color = FColor(c);
|
||||
else if ( ev->getButton() == finalcut::fc::RightButton )
|
||||
fg_color = short(c);
|
||||
fg_color = FColor(c);
|
||||
|
||||
redraw();
|
||||
emitCallback("clicked");
|
||||
|
@ -128,7 +128,7 @@ void ColorChooser::draw()
|
|||
setColor();
|
||||
finalcut::FWidget::drawBorder (1, 2, 8, 11);
|
||||
|
||||
for (short c = 0; c < 16; c++)
|
||||
for (FColor c = 0; c < 16; c++)
|
||||
{
|
||||
setPrintPos (2 + (c / 8) * 3, 3 + c % 8);
|
||||
|
||||
|
@ -151,13 +151,13 @@ void ColorChooser::draw()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline short ColorChooser::getForeground()
|
||||
inline FColor ColorChooser::getForeground()
|
||||
{
|
||||
return fg_color;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline short ColorChooser::getBackground()
|
||||
inline FColor ColorChooser::getBackground()
|
||||
{
|
||||
return bg_color;
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ class Brushes : public finalcut::FWidget
|
|||
wchar_t getBrush();
|
||||
|
||||
// Mutators
|
||||
void setForeground (short);
|
||||
void setBackground (short);
|
||||
void setForeground (FColor);
|
||||
void setBackground (FColor);
|
||||
|
||||
private:
|
||||
// Disable copy constructor
|
||||
|
@ -200,8 +200,8 @@ class Brushes : public finalcut::FWidget
|
|||
|
||||
// Data Members
|
||||
wchar_t brush;
|
||||
short fg_color;
|
||||
short bg_color;
|
||||
FColor fg_color;
|
||||
FColor bg_color;
|
||||
finalcut::FLabel headline;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
@ -220,8 +220,8 @@ Brushes::Brushes (finalcut::FWidget* parent)
|
|||
|
||||
if ( parent )
|
||||
{
|
||||
short fg = parent->getForegroundColor();
|
||||
short bg = parent->getBackgroundColor();
|
||||
FColor fg = parent->getForegroundColor();
|
||||
FColor bg = parent->getBackgroundColor();
|
||||
setForegroundColor(fg);
|
||||
setBackgroundColor(bg);
|
||||
headline.setForegroundColor(fg);
|
||||
|
@ -291,13 +291,13 @@ inline wchar_t Brushes::getBrush()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void Brushes::setForeground (short color)
|
||||
inline void Brushes::setForeground (FColor color)
|
||||
{
|
||||
fg_color = color;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void Brushes::setBackground (short color)
|
||||
inline void Brushes::setBackground (FColor color)
|
||||
{
|
||||
bg_color = color;
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ void AttribDemo::printColorLine()
|
|||
{
|
||||
AttribDlg* parent = static_cast<AttribDlg*>(getParent());
|
||||
|
||||
for (short color = 0; color < colors; color++)
|
||||
for (FColor color = 0; color < colors; color++)
|
||||
{
|
||||
setColor (color, parent->bgcolor);
|
||||
print (" # ");
|
||||
|
|
|
@ -75,7 +75,7 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
|
|||
if ( getPrintPos().getY() == int(getDesktopHeight()) )
|
||||
is_last_line = true;
|
||||
|
||||
setColor (short(1 + timer_id), finalcut::fc::Default);
|
||||
setColor (FColor(1 + timer_id), finalcut::fc::Default);
|
||||
print() << "Timer event, id " << timer_id << '\n';
|
||||
|
||||
if ( is_last_line )
|
||||
|
|
|
@ -28,6 +28,81 @@
|
|||
#include <final/final.h>
|
||||
|
||||
|
||||
// Function prototypes
|
||||
long StringToLong (const finalcut::FString&);
|
||||
bool sortAscending (const finalcut::FObject*, const finalcut::FObject*);
|
||||
bool sortDescending (const finalcut::FObject*, const finalcut::FObject*);
|
||||
|
||||
|
||||
// non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
long StringToLong (const finalcut::FString& str)
|
||||
{
|
||||
finalcut::FString NumString = str;
|
||||
NumString = NumString.replace(",", "");
|
||||
NumString = NumString.replace('.', "");
|
||||
long number = NumString.toLong();
|
||||
return number;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool sortAscending ( const finalcut::FObject* lhs
|
||||
, const finalcut::FObject* rhs )
|
||||
{
|
||||
const finalcut::FListViewItem* l_item = static_cast<const finalcut::FListViewItem*>(lhs);
|
||||
const finalcut::FListViewItem* r_item = static_cast<const finalcut::FListViewItem*>(rhs);
|
||||
const int column = l_item->getSortColumn();
|
||||
|
||||
switch ( column )
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
const long l_number = StringToLong(l_item->getText(column));
|
||||
const long r_number = StringToLong(r_item->getText(column));
|
||||
return bool( l_number < r_number ); // lhs < rhs
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
const double l_number = l_item->getText(column).toDouble();
|
||||
const double r_number = r_item->getText(column).toDouble();
|
||||
return bool( l_number < r_number ); // lhs < rhs
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool sortDescending ( const finalcut::FObject* lhs
|
||||
, const finalcut::FObject* rhs )
|
||||
{
|
||||
const finalcut::FListViewItem* l_item = static_cast<const finalcut::FListViewItem*>(lhs);
|
||||
const finalcut::FListViewItem* r_item = static_cast<const finalcut::FListViewItem*>(rhs);
|
||||
const int column = l_item->getSortColumn();
|
||||
|
||||
switch ( column )
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
const long l_number = StringToLong(l_item->getText(column));
|
||||
const long r_number = StringToLong(r_item->getText(column));
|
||||
return bool( l_number > r_number ); // lhs > rhs
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
const double l_number = l_item->getText(column).toDouble();
|
||||
const double r_number = r_item->getText(column).toDouble();
|
||||
return bool( l_number > r_number ); // lhs > rhs
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class Treeview
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -239,6 +314,13 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
|||
listView.setColumnAlignment (2, finalcut::fc::alignRight);
|
||||
listView.setColumnAlignment (3, finalcut::fc::alignRight);
|
||||
|
||||
// Set the type of sorting
|
||||
listView.setColumnSortType (1, finalcut::fc::by_name);
|
||||
listView.setColumnSortType (2, finalcut::fc::user_defined);
|
||||
listView.setColumnSortType (3, finalcut::fc::user_defined);
|
||||
listView.setUserAscendingCompare(sortAscending);
|
||||
listView.setUserDescendingCompare(sortDescending);
|
||||
|
||||
// Activate tree view
|
||||
listView.setTreeView();
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ void FButton::setText (const FString& txt)
|
|||
void FButton::hide()
|
||||
{
|
||||
std::size_t s, f, size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
FWidget::hide();
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ bool FButtonGroup::hasCheckedButton() const
|
|||
void FButtonGroup::hide()
|
||||
{
|
||||
std::size_t size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget::hide();
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ void FLabel::setText (const FString& txt)
|
|||
//----------------------------------------------------------------------
|
||||
void FLabel::hide()
|
||||
{
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
std::size_t size;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ void FLineEdit::setLabelOrientation(const label_o o)
|
|||
void FLineEdit::hide()
|
||||
{
|
||||
std::size_t s, size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
|
||||
FWidget::hide();
|
||||
|
|
|
@ -241,7 +241,7 @@ void FListBox::setText (const FString& txt)
|
|||
void FListBox::hide()
|
||||
{
|
||||
std::size_t n, size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
FWidget::hide();
|
||||
|
||||
|
|
|
@ -1057,12 +1057,13 @@ void FListView::onMouseDown (FMouseEvent* ev)
|
|||
, mouse_x = ev->getX()
|
||||
, mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth()) && mouse_y == 1 )
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth()) )
|
||||
{
|
||||
if ( mouse_y == 1 )
|
||||
{
|
||||
clicked_column_pos = ev->getPos();
|
||||
}
|
||||
else if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
else if ( mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
{
|
||||
int new_pos = first_visible_line.getPosition() + mouse_y - 2;
|
||||
|
||||
|
@ -1091,6 +1092,7 @@ void FListView::onMouseDown (FMouseEvent* ev)
|
|||
flush_out();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::onMouseUp (FMouseEvent* ev)
|
||||
|
@ -1103,19 +1105,20 @@ void FListView::onMouseUp (FMouseEvent* ev)
|
|||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||
&& mouse_y == 1 && clicked_column_pos == ev->getPos() )
|
||||
if ( mouse_x > 1 && mouse_x < int(getWidth()) )
|
||||
{
|
||||
if ( mouse_y == 1 && clicked_column_pos == ev->getPos() )
|
||||
{
|
||||
mouseColumnClicked();
|
||||
}
|
||||
else if ( mouse_x > 1 && mouse_x < int(getWidth())
|
||||
&& mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
else if ( mouse_y > 1 && mouse_y < int(getHeight()) )
|
||||
{
|
||||
if ( tree_view )
|
||||
{
|
||||
FListViewItem* item = getCurrentItem();
|
||||
|
||||
if ( item->isExpandable() && clicked_expander_pos == ev->getPos() )
|
||||
if ( item->isExpandable()
|
||||
&& clicked_expander_pos == ev->getPos() )
|
||||
{
|
||||
if ( item->isExpand() )
|
||||
item->collapse();
|
||||
|
@ -1132,6 +1135,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
|
|||
processChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clicked_expander_pos.setPoint(-1, -1);
|
||||
clicked_column_pos.setPoint(-1, -1);
|
||||
|
@ -1789,9 +1793,9 @@ inline void FListView::drawSortIndicator ( std::size_t& length
|
|||
length++;
|
||||
|
||||
if ( sort_order == fc::ascending )
|
||||
headerline << wchar_t(fc::BlackDownPointingTriangle); // ▼
|
||||
else if ( sort_order == fc::descending )
|
||||
headerline << wchar_t(fc::BlackUpPointingTriangle); // ▲
|
||||
else if ( sort_order == fc::descending )
|
||||
headerline << wchar_t(fc::BlackDownPointingTriangle); // ▼
|
||||
|
||||
if ( length < column_width )
|
||||
{
|
||||
|
@ -1819,7 +1823,7 @@ void FListView::drawColumnText (headerItems::const_iterator& iter)
|
|||
std::size_t txt_length = txt.getLength();
|
||||
std::size_t column_width = leading_space + width;
|
||||
headerItems::const_iterator first = header.begin();
|
||||
int column = std::distance(first, iter) + 1;
|
||||
int column = int(std::distance(first, iter)) + 1;
|
||||
bool has_sort_indicator = bool ( sort_column == column
|
||||
&& ! hide_sort_indicator );
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void FMenuBar::resetMenu()
|
|||
//----------------------------------------------------------------------
|
||||
void FMenuBar::hide()
|
||||
{
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWindow::hide();
|
||||
fg = wc.term_fg;
|
||||
bg = wc.term_bg;
|
||||
|
|
|
@ -578,7 +578,7 @@ FColor FOptiAttr::vga2ansi (FColor color)
|
|||
color = 0;
|
||||
else if ( color < 16 )
|
||||
{
|
||||
static const short lookup_table[] =
|
||||
static const FColor lookup_table[] =
|
||||
{
|
||||
0, 4, 2, 6, 1, 5, 3, 7,
|
||||
8, 12, 10, 14, 9, 13, 11, 15
|
||||
|
|
|
@ -99,7 +99,7 @@ bool FProgressbar::setShadow (bool on)
|
|||
void FProgressbar::hide()
|
||||
{
|
||||
std::size_t s, size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
|
||||
FWidget::hide();
|
||||
|
|
|
@ -196,7 +196,7 @@ bool FStatusBar::hasActivatedKey()
|
|||
//----------------------------------------------------------------------
|
||||
void FStatusBar::hide()
|
||||
{
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWindow::hide();
|
||||
fg = wc.term_fg;
|
||||
bg = wc.term_bg;
|
||||
|
|
|
@ -196,7 +196,7 @@ void FTextView::scrollTo (int x, int y)
|
|||
void FTextView::hide()
|
||||
{
|
||||
std::size_t n, size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
|
||||
FWidget::hide();
|
||||
|
|
|
@ -213,7 +213,7 @@ void FToggleButton::setText (const FString& txt)
|
|||
void FToggleButton::hide()
|
||||
{
|
||||
std::size_t size;
|
||||
short fg, bg;
|
||||
FColor fg, bg;
|
||||
FWidget* parent_widget = getParentWidget();
|
||||
FWidget::hide();
|
||||
|
||||
|
|
|
@ -164,16 +164,13 @@ void FVTerm::setPrintCursor (int x, int y)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FColor FVTerm::rgb2ColorIndex (short r, short g, short b)
|
||||
FColor FVTerm::rgb2ColorIndex (uInt8 r, uInt8 g, uInt8 b)
|
||||
{
|
||||
// Converts a 24-bit RGB color to a 256-color compatible approximation
|
||||
|
||||
if ( r < 0 || g < 0 || b < 0 || r > 0xff || g > 0xff || b > 0xff )
|
||||
return 0;
|
||||
|
||||
short ri = (((r * 5) + 127) / 255) * 36;
|
||||
short gi = (((g * 5) + 127) / 255) * 6;
|
||||
short bi = (((b * 5) + 127) / 255);
|
||||
FColor ri = (((r * 5) + 127) / 255) * 36;
|
||||
FColor gi = (((g * 5) + 127) / 255) * 6;
|
||||
FColor bi = (((b * 5) + 127) / 255);
|
||||
return 16 + ri + gi + bi;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,13 +168,13 @@ class FButton : public FWidget
|
|||
std::size_t center_offset;
|
||||
std::size_t vcenter_offset;
|
||||
std::size_t txtlength;
|
||||
short button_fg;
|
||||
short button_bg;
|
||||
short button_hotkey_fg;
|
||||
short button_focus_fg;
|
||||
short button_focus_bg;
|
||||
short button_inactive_fg;
|
||||
short button_inactive_bg;
|
||||
FColor button_fg;
|
||||
FColor button_bg;
|
||||
FColor button_hotkey_fg;
|
||||
FColor button_focus_fg;
|
||||
FColor button_focus_bg;
|
||||
FColor button_inactive_fg;
|
||||
FColor button_inactive_bg;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
|
|
@ -157,8 +157,8 @@ class FLabel : public FWidget
|
|||
bool multiline;
|
||||
FString text;
|
||||
fc::text_alignment alignment;
|
||||
short emphasis_color;
|
||||
short ellipsis_color;
|
||||
FColor emphasis_color;
|
||||
FColor ellipsis_color;
|
||||
bool emphasis;
|
||||
bool reverse_mode;
|
||||
FWidget* accel_widget;
|
||||
|
|
|
@ -165,7 +165,7 @@ class FMessageBox : public FDialog
|
|||
FStringList text_split;
|
||||
std::size_t max_line_width;
|
||||
bool center_text;
|
||||
short emphasis_color;
|
||||
FColor emphasis_color;
|
||||
uInt num_buttons;
|
||||
uInt text_num_lines;
|
||||
int button_digit[3];
|
||||
|
|
|
@ -129,8 +129,8 @@ class FVTerm
|
|||
|
||||
// Accessors
|
||||
virtual const char* getClassName() const;
|
||||
static short getTermForegroundColor();
|
||||
static short getTermBackgroundColor();
|
||||
static FColor getTermForegroundColor();
|
||||
static FColor getTermBackgroundColor();
|
||||
term_area* getVWin() const;
|
||||
FPoint getPrintCursor();
|
||||
static charData getAttribute();
|
||||
|
@ -153,7 +153,7 @@ class FVTerm
|
|||
void showCursor();
|
||||
void setPrintCursor (const FPoint&);
|
||||
void setPrintCursor (int, int);
|
||||
FColor rgb2ColorIndex (short, short, short);
|
||||
FColor rgb2ColorIndex (uInt8, uInt8, uInt8);
|
||||
void setColor (FColor, FColor);
|
||||
static void setNormal();
|
||||
|
||||
|
@ -605,11 +605,11 @@ inline const char* FVTerm::getClassName() const
|
|||
{ return "FVTerm"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline short FVTerm::getTermForegroundColor()
|
||||
inline FColor FVTerm::getTermForegroundColor()
|
||||
{ return next_attribute.fg_color; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline short FVTerm::getTermBackgroundColor()
|
||||
inline FColor FVTerm::getTermBackgroundColor()
|
||||
{ return next_attribute.bg_color; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -185,8 +185,8 @@ class FWidget : public FVTerm, public FObject
|
|||
static FMenuBar* getMenuBar();
|
||||
static FStatusBar* getStatusBar();
|
||||
FString getStatusbarMessage() const;
|
||||
short getForegroundColor() const; // get the primary
|
||||
short getBackgroundColor() const; // widget colors
|
||||
FColor getForegroundColor() const; // get the primary
|
||||
FColor getBackgroundColor() const; // widget colors
|
||||
int getX() const; // positioning
|
||||
int getY() const;
|
||||
const FPoint getPos() const;
|
||||
|
@ -571,11 +571,11 @@ inline FString FWidget::getStatusbarMessage() const
|
|||
{ return statusbar_message; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline short FWidget::getForegroundColor() const
|
||||
inline FColor FWidget::getForegroundColor() const
|
||||
{ return foreground_color; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline short FWidget::getBackgroundColor() const
|
||||
inline FColor FWidget::getBackgroundColor() const
|
||||
{ return background_color; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue