The Final Cut can now also be compiled under Cygwin

This commit is contained in:
Markus Gans 2018-01-21 16:21:41 +01:00
parent 91023e3a76
commit ec63b0039e
14 changed files with 474 additions and 335 deletions

View File

@ -1,3 +1,12 @@
2017-01-21 Markus Gans <guru.mail@muenster.de>
* The Final Cut can now also be compiled under Cygwin
* Fixed bug in FScrollView::scrollTo
* Refactoring FStatusBar::drawKeys
* Refactoring FListView::drawListLine
2017-01-17 Markus Gans <guru.mail@muenster.de>
* Small array optimizations in the examples
2017-01-14 Markus Gans <guru.mail@muenster.de> 2017-01-14 Markus Gans <guru.mail@muenster.de>
* Mouse functions are now in a separate class * Mouse functions are now in a separate class

View File

@ -23,6 +23,7 @@
* NetBSD * NetBSD
* OpenBSD * OpenBSD
* macOS * macOS
* Cygwin
* Solaris * Solaris
The Final Cut The Final Cut

View File

@ -47,6 +47,14 @@ class Menu : public FDialog
Menu& operator = (const Menu&); Menu& operator = (const Menu&);
// Methods // Methods
void createFileMenuItems (FMenu*);
void createEditMenuItems (FMenu*);
void createChoiceMenuItems (FMenu*);
void createColorMenuItems (FMenu*);
void createStyleMenuItems (FMenu*);
void createBorderMenuItems (FMenu*);
void createBorderColorMenuItems (FMenu*);
void createBorderStyleMenuItems (FMenu*);
void defaultCallback (FMenuList*); void defaultCallback (FMenuList*);
void adjustSize(); void adjustSize();
@ -62,10 +70,10 @@ class Menu : public FDialog
Menu::Menu (FWidget* parent) Menu::Menu (FWidget* parent)
: FDialog(parent) : FDialog(parent)
{ {
// menu bar // Menu bar
FMenuBar* Menubar = new FMenuBar (this); FMenuBar* Menubar = new FMenuBar (this);
// menu bar items // Menu bar items
FMenu* File = new FMenu ("&File", Menubar); FMenu* File = new FMenu ("&File", Menubar);
File->setStatusbarMessage ("File management commands"); File->setStatusbarMessage ("File management commands");
FMenu* Edit = new FMenu ("&Edit", Menubar); FMenu* Edit = new FMenu ("&Edit", Menubar);
@ -77,118 +85,14 @@ Menu::Menu (FWidget* parent)
FMenuItem* Help = new FMenuItem ("&Help", Menubar); FMenuItem* Help = new FMenuItem ("&Help", Menubar);
Help->setStatusbarMessage ("Show version and copyright information"); Help->setStatusbarMessage ("Show version and copyright information");
// "File" menu items // Menu items
FMenuItem* New = new FMenuItem ("&New", File); createFileMenuItems (File);
New->addAccelerator (fc::Fckey_n); // Ctrl + N createEditMenuItems (Edit);
New->setStatusbarMessage ("Create a new file"); createChoiceMenuItems (Choice);
FMenuItem* Open = new FMenuItem ("&Open...", File);
Open->addAccelerator (fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file");
FMenuItem* Save = new FMenuItem ("&Save", File);
Save->addAccelerator (fc::Fckey_s); // Ctrl + S
Save->setStatusbarMessage ("Save the file");
FMenuItem* SaveAs = new FMenuItem ("&Save as...", File);
SaveAs->setStatusbarMessage ("Save the current file under a different name");
FMenuItem* Close = new FMenuItem ("&Close", File);
Close->addAccelerator (fc::Fckey_w); // Ctrl + W
Close->setStatusbarMessage ("Close the current file");
FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator();
FMenuItem* Print = new FMenuItem ("&Print", File);
Print->addAccelerator (fc::Fckey_p); // Ctrl + P
Print->setStatusbarMessage ("Print the current file");
FMenuItem* Line2 = new FMenuItem (File);
Line2->setSeparator();
FMenuItem* Quit = new FMenuItem ("&Quit", File);
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program");
// "Edit" menu items
FMenuItem* Undo = new FMenuItem (fc::Fckey_z, "&Undo", Edit);
Undo->setStatusbarMessage ("Undo the previous operation");
FMenuItem* Redo = new FMenuItem (fc::Fckey_y, "&Redo", Edit);
Redo->setDisable();
FMenuItem* Line3 = new FMenuItem (Edit);
Line3->setSeparator();
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ( "Remove the input text "
"and put it in the clipboard" );
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
Paste->setStatusbarMessage ("Insert text form clipboard");
FMenuItem* Line4 = new FMenuItem (Edit);
Line4->setSeparator();
FMenuItem* Search = new FMenuItem (fc::Fckey_f, "&Search", Edit);
Search->setStatusbarMessage ("Search for text");
FMenuItem* Next = new FMenuItem (fc::Fkey_f3, "Search &next", Edit);
Next->setStatusbarMessage ("Repeat the last search command");
FMenuItem* Line5 = new FMenuItem (Edit);
Line5->setSeparator();
FMenuItem* SelectAll = new FMenuItem (fc::Fckey_a, "Select &all", Edit);
SelectAll->setStatusbarMessage ("Select the whole text");
// "Choice" menu items
FMenu* Color = new FMenu ("&Color", Choice);
Color->setStatusbarMessage ("Choose a color");
FMenu* Style = new FMenu ("&Style", Choice);
Style->setStatusbarMessage ("Choose a Style");
FMenu* Border = new FMenu ("&Border", Choice);
Border->setStatusbarMessage ("Choose Border");
// "Color" menu items
FRadioMenuItem* Color1 = new FRadioMenuItem ("Red", Color);
Color1->setStatusbarMessage ("Set text red");
FRadioMenuItem* Color2 = new FRadioMenuItem ("Green", Color);
Color2->setStatusbarMessage ("Set text green");
FRadioMenuItem* Color3 = new FRadioMenuItem ("Yellow", Color);
Color3->setStatusbarMessage ("Set text yellow");
FRadioMenuItem* Color4 = new FRadioMenuItem ("Brue", Color);
Color4->setStatusbarMessage ("Set text brue");
FRadioMenuItem* Color5 = new FRadioMenuItem ("Black", Color);
Color5->setStatusbarMessage ("Set text black");
Color5->setChecked();
// "Style" menu items
FCheckMenuItem* Bold = new FCheckMenuItem ("Bold", Style);
Bold->setStatusbarMessage ("Set text bold");
FCheckMenuItem* Italic = new FCheckMenuItem ("Italic", Style);
Italic->setStatusbarMessage ("Set text italic");
// "Border" menu items
FMenu* BColor = new FMenu ("&Color", Border);
BColor->setStatusbarMessage ("Choose the border color");
FMenu* BStyle = new FMenu ("&Style", Border);
BStyle->setStatusbarMessage ("Choose the border Style");
// "BColor" menu items
FRadioMenuItem* BColor1 = new FRadioMenuItem ("Red", BColor);
BColor1->setStatusbarMessage ("Set red border");
FRadioMenuItem* BColor2 = new FRadioMenuItem ("Blue", BColor);
BColor2->setStatusbarMessage ("Set blue border");
// "BStyle" menu items
FString line(13, wchar_t(fc::BoxDrawingsHorizontal));
FRadioMenuItem* BStyle1 = new FRadioMenuItem (line, BStyle);
BStyle1->setChecked();
BStyle1->setStatusbarMessage ("Set border 1");
FRadioMenuItem* BStyle2 = new FRadioMenuItem ("-------------", BStyle);
BStyle2->setStatusbarMessage ("Set border 2");
FRadioMenuItem* BStyle3 = new FRadioMenuItem ("- - - - - - -", BStyle);
BStyle3->setStatusbarMessage ("Set border 3");
FRadioMenuItem* BStyle4 = new FRadioMenuItem ("- - - - -", BStyle);
BStyle4->setStatusbarMessage ("Set border 4");
// Add default menu item callback // Add default menu item callback
defaultCallback (Menubar); defaultCallback (Menubar);
// Add quit menu item callback
Quit->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &FApplication::cb_exitApp)
);
// Statusbar at the bottom // Statusbar at the bottom
FStatusBar* statusbar = new FStatusBar (this); FStatusBar* statusbar = new FStatusBar (this);
statusbar->setMessage("Status bar message"); statusbar->setMessage("Status bar message");
@ -215,6 +119,154 @@ Menu::Menu (FWidget* parent)
Menu::~Menu() Menu::~Menu()
{ } { }
//----------------------------------------------------------------------
void Menu::createFileMenuItems (FMenu* File)
{
// "File" menu items
FMenuItem* New = new FMenuItem ("&New", File);
New->addAccelerator (fc::Fckey_n); // Ctrl + N
New->setStatusbarMessage ("Create a new file");
FMenuItem* Open = new FMenuItem ("&Open...", File);
Open->addAccelerator (fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file");
FMenuItem* Save = new FMenuItem ("&Save", File);
Save->addAccelerator (fc::Fckey_s); // Ctrl + S
Save->setStatusbarMessage ("Save the file");
FMenuItem* SaveAs = new FMenuItem ("&Save as...", File);
SaveAs->setStatusbarMessage ("Save the current file under a different name");
FMenuItem* Close = new FMenuItem ("&Close", File);
Close->addAccelerator (fc::Fckey_w); // Ctrl + W
Close->setStatusbarMessage ("Close the current file");
FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator();
FMenuItem* Print = new FMenuItem ("&Print", File);
Print->addAccelerator (fc::Fckey_p); // Ctrl + P
Print->setStatusbarMessage ("Print the current file");
FMenuItem* Line2 = new FMenuItem (File);
Line2->setSeparator();
FMenuItem* Quit = new FMenuItem ("&Quit", File);
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program");
// Add quit menu item callback
Quit->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &FApplication::cb_exitApp)
);
}
//----------------------------------------------------------------------
void Menu::createEditMenuItems (FMenu* Edit)
{
// "Edit" menu items
FMenuItem* Undo = new FMenuItem (fc::Fckey_z, "&Undo", Edit);
Undo->setStatusbarMessage ("Undo the previous operation");
FMenuItem* Redo = new FMenuItem (fc::Fckey_y, "&Redo", Edit);
Redo->setDisable();
FMenuItem* Line3 = new FMenuItem (Edit);
Line3->setSeparator();
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ( "Remove the input text "
"and put it in the clipboard" );
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
Paste->setStatusbarMessage ("Insert text form clipboard");
FMenuItem* Line4 = new FMenuItem (Edit);
Line4->setSeparator();
FMenuItem* Search = new FMenuItem (fc::Fckey_f, "&Search", Edit);
Search->setStatusbarMessage ("Search for text");
FMenuItem* Next = new FMenuItem (fc::Fkey_f3, "Search &next", Edit);
Next->setStatusbarMessage ("Repeat the last search command");
FMenuItem* Line5 = new FMenuItem (Edit);
Line5->setSeparator();
FMenuItem* SelectAll = new FMenuItem (fc::Fckey_a, "Select &all", Edit);
SelectAll->setStatusbarMessage ("Select the whole text");
}
//----------------------------------------------------------------------
void Menu::createChoiceMenuItems (FMenu* Choice)
{
// "Choice" menu items
FMenu* Color = new FMenu ("&Color", Choice);
Color->setStatusbarMessage ("Choose a color");
FMenu* Style = new FMenu ("&Style", Choice);
Style->setStatusbarMessage ("Choose a Style");
FMenu* Border = new FMenu ("&Border", Choice);
Border->setStatusbarMessage ("Choose Border");
createColorMenuItems (Color);
createStyleMenuItems (Style);
createBorderMenuItems (Border);
}
//----------------------------------------------------------------------
void Menu::createColorMenuItems (FMenu* Color)
{
// "Color" menu items
FRadioMenuItem* Color1 = new FRadioMenuItem ("Red", Color);
Color1->setStatusbarMessage ("Set text red");
FRadioMenuItem* Color2 = new FRadioMenuItem ("Green", Color);
Color2->setStatusbarMessage ("Set text green");
FRadioMenuItem* Color3 = new FRadioMenuItem ("Yellow", Color);
Color3->setStatusbarMessage ("Set text yellow");
FRadioMenuItem* Color4 = new FRadioMenuItem ("Brue", Color);
Color4->setStatusbarMessage ("Set text brue");
FRadioMenuItem* Color5 = new FRadioMenuItem ("Black", Color);
Color5->setStatusbarMessage ("Set text black");
Color5->setChecked();
}
//----------------------------------------------------------------------
void Menu::createStyleMenuItems (FMenu* Style)
{
// "Style" menu items
FCheckMenuItem* Bold = new FCheckMenuItem ("Bold", Style);
Bold->setStatusbarMessage ("Set text bold");
FCheckMenuItem* Italic = new FCheckMenuItem ("Italic", Style);
Italic->setStatusbarMessage ("Set text italic");
}
//----------------------------------------------------------------------
void Menu::createBorderMenuItems (FMenu* Border)
{
// "Border" menu items
FMenu* BColor = new FMenu ("&Color", Border);
BColor->setStatusbarMessage ("Choose the border color");
FMenu* BStyle = new FMenu ("&Style", Border);
BStyle->setStatusbarMessage ("Choose the border Style");
createBorderColorMenuItems (BColor);
createBorderStyleMenuItems (BStyle);
}
//----------------------------------------------------------------------
void Menu::createBorderColorMenuItems (FMenu* BColor)
{
// "BColor" menu items
FRadioMenuItem* BColor1 = new FRadioMenuItem ("Red", BColor);
BColor1->setStatusbarMessage ("Set red border");
FRadioMenuItem* BColor2 = new FRadioMenuItem ("Blue", BColor);
BColor2->setStatusbarMessage ("Set blue border");
}
//----------------------------------------------------------------------
void Menu::createBorderStyleMenuItems (FMenu* BStyle)
{
// "BStyle" menu items
FString line(13, wchar_t(fc::BoxDrawingsHorizontal));
FRadioMenuItem* BStyle1 = new FRadioMenuItem (line, BStyle);
BStyle1->setChecked();
BStyle1->setStatusbarMessage ("Set border 1");
FRadioMenuItem* BStyle2 = new FRadioMenuItem ("-------------", BStyle);
BStyle2->setStatusbarMessage ("Set border 2");
FRadioMenuItem* BStyle3 = new FRadioMenuItem ("- - - - - - -", BStyle);
BStyle3->setStatusbarMessage ("Set border 3");
FRadioMenuItem* BStyle4 = new FRadioMenuItem ("- - - - -", BStyle);
BStyle4->setStatusbarMessage ("Set border 4");
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Menu::defaultCallback (FMenuList* mb) void Menu::defaultCallback (FMenuList* mb)
{ {

View File

@ -178,6 +178,7 @@ class FDialog : public FWindow
// Methods // Methods
void init(); void init();
void initDialogMenu();
virtual void drawBorder(); virtual void drawBorder();
void drawTitleBar(); void drawTitleBar();
void drawBarButton(); void drawBarButton();

View File

@ -321,6 +321,8 @@ class FListView : public FWidget
void drawColumnLabels(); void drawColumnLabels();
void drawList(); void drawList();
void drawListLine (const FListViewItem*, bool, bool); void drawListLine (const FListViewItem*, bool, bool);
void setLineAttributes (bool, bool);
FString getLinePrefix (const FListViewItem*, uInt);
void updateDrawing (bool, bool); void updateDrawing (bool, bool);
void recalculateHorizontalBar (int); void recalculateHorizontalBar (int);
void recalculateVerticalBar (int); void recalculateVerticalBar (int);

View File

@ -247,11 +247,15 @@ class FStatusBar : public FWindow
void init(); void init();
void draw(); void draw();
void drawKeys(); void drawKeys();
void drawKey (keyList::const_iterator);
void drawActiveKey (keyList::const_iterator);
// Data Members // Data Members
keyList key_list; keyList key_list;
FString text; FString text;
bool mouse_down; bool mouse_down;
int screenWidth;
int keyname_len;
int x; int x;
int x_msg; int x_msg;
}; };

View File

@ -477,6 +477,8 @@ class FWidget : public FVTerm, public FObject
void KeyDownEvent (FKeyEvent*); void KeyDownEvent (FKeyEvent*);
void processDestroy(); void processDestroy();
virtual void draw(); virtual void draw();
void drawTransparentShadow (int, int, int, int);
void drawBlockShadow (int, int, int, int);
static void setColorTheme(); static void setColorTheme();
static void set8ColorTheme(); static void set8ColorTheme();
static void set16ColorTheme(); static void set16ColorTheme();

View File

@ -929,6 +929,14 @@ void FDialog::init()
} }
// Add the dialog menu // Add the dialog menu
initDialogMenu();
}
//----------------------------------------------------------------------
void FDialog::initDialogMenu()
{
// Create the dialog Menu (access via Shift-F10 or Ctrl-^)
try try
{ {
dialog_menu = new FMenu ("-", this); dialog_menu = new FMenu ("-", this);

View File

@ -1523,64 +1523,13 @@ void FListView::drawListLine ( const FListViewItem* item
{ {
uInt indent = item->getDepth() << 1; // indent = 2 * depth uInt indent = item->getDepth() << 1; // indent = 2 * depth
setColor (wc.list_fg, wc.list_bg); // Set line color and attributes
setLineAttributes (is_current, is_focus);
if ( is_current ) // Print the entry
{ FString line = getLinePrefix (item, indent);
if ( is_focus && getMaxColor() < 16 )
setBold();
if ( isMonochron() ) // Print columns
unsetBold();
if ( is_focus )
{
setColor ( wc.current_element_focus_fg
, wc.current_element_focus_bg );
}
else
setColor ( wc.current_element_fg
, wc.current_element_bg );
if ( isMonochron() )
setReverse(false);
}
else
{
if ( isMonochron() )
setReverse(true);
else if ( is_focus && getMaxColor() < 16 )
unsetBold();
}
// print the entry
FString line;
if ( tree_view )
{
if ( indent > 0 )
line = FString(indent, L' ');
if ( item->expandable )
{
if ( item->is_expand )
{
line += wchar_t(fc::BlackDownPointingTriangle); // ▼
line += L' ';
}
else
{
line += wchar_t(fc::BlackRightPointingPointer); // ►
line += L' ';
}
}
else
line += L" ";
}
else
line = L" ";
// print columns
if ( ! item->column_list.empty() ) if ( ! item->column_list.empty() )
{ {
for (uInt i = 0; i < item->column_list.size(); ) for (uInt i = 0; i < item->column_list.size(); )
@ -1643,6 +1592,74 @@ void FListView::drawListLine ( const FListViewItem* item
print (' '); print (' ');
} }
//----------------------------------------------------------------------
inline void FListView::setLineAttributes ( bool is_current
, bool is_focus )
{
setColor (wc.list_fg, wc.list_bg);
if ( is_current )
{
if ( is_focus && getMaxColor() < 16 )
setBold();
if ( isMonochron() )
unsetBold();
if ( is_focus )
{
setColor ( wc.current_element_focus_fg
, wc.current_element_focus_bg );
}
else
setColor ( wc.current_element_fg
, wc.current_element_bg );
if ( isMonochron() )
setReverse(false);
}
else
{
if ( isMonochron() )
setReverse(true);
else if ( is_focus && getMaxColor() < 16 )
unsetBold();
}
}
//----------------------------------------------------------------------
inline FString FListView::getLinePrefix ( const FListViewItem* item
, uInt indent )
{
FString line = "";
if ( tree_view )
{
if ( indent > 0 )
line = FString(indent, L' ');
if ( item->expandable )
{
if ( item->is_expand )
{
line += wchar_t(fc::BlackDownPointingTriangle); // ▼
line += L' ';
}
else
{
line += wchar_t(fc::BlackRightPointingPointer); // ►
line += L' ';
}
}
else
line += L" ";
}
else
line = L" ";
return line;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::updateDrawing (bool draw_vbar, bool draw_hbar) void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
{ {

View File

@ -1234,18 +1234,21 @@ void FMouseControl::clearEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#ifdef F_HAVE_LIBGPM
void FMouseControl::setStdinNo (int file_descriptor) void FMouseControl::setStdinNo (int file_descriptor)
{ {
#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 )
gpm_mouse->setStdinNo(file_descriptor); gpm_mouse->setStdinNo(file_descriptor);
#endif
} }
#else
void FMouseControl::setStdinNo (int)
{ }
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setMaxWidth (short x_max) void FMouseControl::setMaxWidth (short x_max)
@ -1565,19 +1568,23 @@ void FMouseControl::processEvent (struct timeval* time)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#ifdef F_HAVE_LIBGPM
bool FMouseControl::getGpmKeyPressed (bool pending) bool FMouseControl::getGpmKeyPressed (bool pending)
#else
bool FMouseControl::getGpmKeyPressed (bool)
#endif
{ {
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
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->getGpmKeyPressed(pending); return gpm_mouse->getGpmKeyPressed(pending);
#endif #endif
return false; return false;

View File

@ -369,8 +369,8 @@ void FScrollView::scrollTo (int x, int y)
if ( changeX ) if ( changeX )
{ {
viewport_geometry.setWidth(save_width); viewport_geometry.setWidth(save_width);
setTopPadding (1 - yoffset); setLeftPadding (1 - xoffset);
setBottomPadding (1 - (yoffset_end - yoffset)); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
if ( update_scrollbar ) if ( update_scrollbar )
{ {
@ -382,8 +382,8 @@ void FScrollView::scrollTo (int x, int y)
if ( changeY ) if ( changeY )
{ {
viewport_geometry.setHeight(save_height); viewport_geometry.setHeight(save_height);
setLeftPadding (1 - xoffset); setTopPadding (1 - yoffset);
setRightPadding (1 - (xoffset_end - xoffset) + nf_offset); setBottomPadding (1 - (yoffset_end - yoffset));
if ( update_scrollbar ) if ( update_scrollbar )
{ {

View File

@ -134,6 +134,8 @@ FStatusBar::FStatusBar(FWidget* parent)
, key_list() , key_list()
, text("") , text("")
, mouse_down() , mouse_down()
, screenWidth(80)
, keyname_len(0)
, x(-1) , x(-1)
, x_msg(-1) , x_msg(-1)
{ {
@ -578,8 +580,7 @@ void FStatusBar::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::drawKeys() void FStatusBar::drawKeys()
{ {
std::vector<FStatusKey*>::const_iterator iter, last; keyList::const_iterator iter, last;
int screenWidth;
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
x = 1; x = 1;
@ -600,67 +601,57 @@ void FStatusBar::drawKeys()
while ( iter != last ) while ( iter != last )
{ {
int kname_len = int(getKeyName((*iter)->getKey()).getLength()); keyname_len = int(getKeyName((*iter)->getKey()).getLength());
if ( x + kname_len + 2 < screenWidth ) if ( x + keyname_len + 2 < screenWidth )
{ {
if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() ) if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() )
drawActiveKey (iter);
else
drawKey (iter);
}
else
{ {
int txt_length; setColor (wc.statusbar_fg, wc.statusbar_bg);
for (; x <= screenWidth; x++)
print (' ');
}
++iter;
}
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setColor ( wc.statusbar_active_hotkey_fg x_msg = x;
, wc.statusbar_active_hotkey_bg );
x++;
print (' ');
x += kname_len;
print (getKeyName((*iter)->getKey()));
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++;
print ('-');
txt_length = int((*iter)->getText().getLength());
x += txt_length;
if ( x <= screenWidth )
{
print ((*iter)->getText());
x++;
print (fc::RightHalfBlock); // ▌
}
else
{
// Print ellipsis
print ( (*iter)->getText()
.left(uInt(txt_length + screenWidth - x - 1)) );
print ("..");
} }
if ( isMonochron() ) //----------------------------------------------------------------------
setReverse(true); void FStatusBar::drawKey (keyList::const_iterator iter)
}
else
{ {
// Draw not active key
int txt_length; int txt_length;
FStatusKey* item = *iter;
// not active
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg); setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
x++; x++;
print (' '); print (' ');
x += kname_len; x += keyname_len;
print (getKeyName((*iter)->getKey())); print (getKeyName(item->getKey()));
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
x++; x++;
print ('-'); print ('-');
txt_length = int((*iter)->getText().getLength()); txt_length = int(item->getText().getLength());
x += txt_length; x += txt_length;
if ( x - 1 <= screenWidth ) if ( x - 1 <= screenWidth )
print ((*iter)->getText()); print (item->getText());
else else
{ {
// Print ellipsis // Print ellipsis
print ( (*iter)->getText() print ( item->getText()
.left(uInt(txt_length + screenWidth - x - 1)) ); .left(uInt(txt_length + screenWidth - x - 1)) );
print (".."); print ("..");
} }
@ -670,7 +661,7 @@ void FStatusBar::drawKeys()
&& x + int(getKeyName((*(iter + 1))->getKey()).getLength()) + 3 && x + int(getKeyName((*(iter + 1))->getKey()).getLength()) + 3
< screenWidth ) < screenWidth )
{ {
// next element is active // Next element is active
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -689,24 +680,51 @@ void FStatusBar::drawKeys()
} }
else if ( iter + 1 != key_list.end() && x < screenWidth ) else if ( iter + 1 != key_list.end() && x < 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);
x++; x++;
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
} }
} }
}
else
{
setColor (wc.statusbar_fg, wc.statusbar_bg);
for (; x <= screenWidth; x++) //----------------------------------------------------------------------
print (' '); void FStatusBar::drawActiveKey (keyList::const_iterator iter)
} {
++iter; // Draw active key
}
int txt_length;
FStatusKey* item = *iter;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
x_msg = x; setColor ( wc.statusbar_active_hotkey_fg
, wc.statusbar_active_hotkey_bg );
x++;
print (' ');
x += keyname_len;
print (getKeyName(item->getKey()));
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++;
print ('-');
txt_length = int(item->getText().getLength());
x += txt_length;
if ( x <= screenWidth )
{
print (item->getText());
x++;
print (fc::RightHalfBlock); // ▌
} }
else
{
// Print ellipsis
print ( item->getText()
.left(uInt(txt_length + screenWidth - x - 1)) );
print ("..");
}
if ( isMonochron() )
setReverse(true);
}

View File

@ -1505,7 +1505,11 @@ const FString FTerm::getSecDA()
struct timeval tv; struct timeval tv;
// Get the secondary device attributes // Get the secondary device attributes
#if defined(__CYGWIN__)
puts (SECDA);
#else
putstring (SECDA); putstring (SECDA);
#endif
std::fflush(stdout); std::fflush(stdout);
FD_ZERO(&ifds); FD_ZERO(&ifds);

View File

@ -1426,77 +1426,12 @@ void FWidget::drawShadow()
if ( trans_shadow ) if ( trans_shadow )
{ {
// transparent shadow // transparent shadow
setPrintPos (x2 + 1, y1); drawTransparentShadow (x1, y1, x2, y2);
setTransparent();
print (" ");
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (int i = 1; i < getHeight(); i++)
{
setPrintPos (x2 + 1, y1 + i);
print (" ");
}
unsetTransShadow();
setPrintPos (x1, y2 + 1);
setTransparent();
print (" ");
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (int i = 2; i <= getWidth() + 1; i++)
print (' ');
unsetTransShadow();
if ( isMonochron() )
setReverse(false);
} }
else else
{ {
// non-transparent shadow // non-transparent shadow
int block; drawBlockShadow (x1, y1, x2, y2);
if ( no_shadow_character )
return;
setPrintPos (x2 + 1, y1);
if ( isWindowWidget() )
{
setColor (wc.shadow_fg, wc.shadow_bg);
setInheritBackground(); // current background color will be ignored
}
else if ( FWidget* p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor());
block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄
if ( isWindowWidget() )
unsetInheritBackground();
for (int i = 1; i < getHeight(); i++)
{
setPrintPos (x2 + 1, y1 + i);
print (block); // █
}
setPrintPos (x1 + 1, y2 + 1);
if ( isWindowWidget() )
setInheritBackground();
for (int i = 1; i <= getWidth(); i++)
print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() )
unsetInheritBackground();
} }
} }
@ -2469,6 +2404,85 @@ void FWidget::KeyDownEvent (FKeyEvent* kev)
void FWidget::draw() void FWidget::draw()
{ } { }
//----------------------------------------------------------------------
void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
{
// transparent shadow
setPrintPos (x2 + 1, y1);
setTransparent();
print (" ");
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (int i = 1; i < getHeight(); i++)
{
setPrintPos (x2 + 1, y1 + i);
print (" ");
}
unsetTransShadow();
setPrintPos (x1, y2 + 1);
setTransparent();
print (" ");
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow();
for (int i = 2; i <= getWidth() + 1; i++)
print (' ');
unsetTransShadow();
if ( isMonochron() )
setReverse(false);
}
//----------------------------------------------------------------------
void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
{
// non-transparent shadow
int block;
if ( no_shadow_character )
return;
setPrintPos (x2 + 1, y1);
if ( isWindowWidget() )
{
setColor (wc.shadow_fg, wc.shadow_bg);
setInheritBackground(); // current background color will be ignored
}
else if ( FWidget* p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor());
block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄
if ( isWindowWidget() )
unsetInheritBackground();
for (int i = 1; i < getHeight(); i++)
{
setPrintPos (x2 + 1, y1 + i);
print (block); // █
}
setPrintPos (x1 + 1, y2 + 1);
if ( isWindowWidget() )
setInheritBackground();
for (int i = 1; i <= getWidth(); i++)
print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() )
unsetInheritBackground();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setColorTheme() void FWidget::setColorTheme()
{ {