Improve adjustSize()
This commit is contained in:
parent
d40b5f22a4
commit
9df9eb5961
|
@ -89,12 +89,13 @@ FMenu::~FMenu()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::init(FWidget* parent)
|
void FMenu::init(FWidget* parent)
|
||||||
{
|
{
|
||||||
|
FWidget* rootObj = getRootWidget();
|
||||||
|
xmin = 1 + rootObj->getLeftPadding();
|
||||||
|
ymin = 1 + rootObj->getTopPadding();
|
||||||
|
xmax = rootObj->getWidth();
|
||||||
|
ymax = rootObj->getHeight();
|
||||||
width = 10;
|
width = 10;
|
||||||
height = 2;
|
height = 2;
|
||||||
xmin = 1;
|
|
||||||
ymin = 1;
|
|
||||||
xmax = width;
|
|
||||||
ymax = height;
|
|
||||||
client_xmin = 1;
|
client_xmin = 1;
|
||||||
client_ymin = 1;
|
client_ymin = 1;
|
||||||
client_xmax = width;
|
client_xmax = width;
|
||||||
|
@ -113,6 +114,7 @@ void FMenu::init(FWidget* parent)
|
||||||
foregroundColor = wc.menu_active_fg;
|
foregroundColor = wc.menu_active_fg;
|
||||||
backgroundColor = wc.menu_active_bg;
|
backgroundColor = wc.menu_active_bg;
|
||||||
|
|
||||||
|
if ( item )
|
||||||
item->setMenu(this);
|
item->setMenu(this);
|
||||||
|
|
||||||
if ( parent )
|
if ( parent )
|
||||||
|
|
|
@ -43,16 +43,17 @@ void FMenuBar::init()
|
||||||
ypos = 1;
|
ypos = 1;
|
||||||
createArea (vmenubar);
|
createArea (vmenubar);
|
||||||
vmenubar->visible = true;
|
vmenubar->visible = true;
|
||||||
|
window_object = true;
|
||||||
|
ignore_padding = true;
|
||||||
|
|
||||||
// initialize geometry values
|
// initialize geometry values
|
||||||
setGeometry (1, 1, getColumnNumber(), 1, false);
|
setGeometry (1, 1, getColumnNumber(), 1, false);
|
||||||
getRootWidget()->setTopPadding(1, true);
|
|
||||||
setMenuBar(this);
|
setMenuBar(this);
|
||||||
|
getRootWidget()->setTopPadding(1, true);
|
||||||
addAccelerator (fc::Fkey_f10);
|
addAccelerator (fc::Fkey_f10);
|
||||||
addAccelerator (fc::Fckey_space);
|
addAccelerator (fc::Fckey_space);
|
||||||
foregroundColor = wc.menu_active_fg;
|
foregroundColor = wc.menu_active_fg;
|
||||||
backgroundColor = wc.menu_active_bg;
|
backgroundColor = wc.menu_active_bg;
|
||||||
window_object = true;
|
|
||||||
ignore_padding = true;
|
|
||||||
unsetFocusable();
|
unsetFocusable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,16 +185,16 @@ void FStatusBar::init()
|
||||||
ypos = getLineNumber();
|
ypos = getLineNumber();
|
||||||
createArea (vstatusbar);
|
createArea (vstatusbar);
|
||||||
vstatusbar->visible = true;
|
vstatusbar->visible = true;
|
||||||
|
window_object = true;
|
||||||
|
ignore_padding = true;
|
||||||
|
mouse_down = false;
|
||||||
|
|
||||||
// initialize geometry values
|
// initialize geometry values
|
||||||
setGeometry (1, ypos, getColumnNumber(), 1, false);
|
setGeometry (1, ypos, getColumnNumber(), 1, false);
|
||||||
getRootWidget()->setBottomPadding(1, true);
|
|
||||||
setStatusBar(this);
|
setStatusBar(this);
|
||||||
|
getRootWidget()->setBottomPadding(1, true);
|
||||||
foregroundColor = wc.statusbar_fg;
|
foregroundColor = wc.statusbar_fg;
|
||||||
backgroundColor = wc.statusbar_bg;
|
backgroundColor = wc.statusbar_bg;
|
||||||
window_object = true;
|
|
||||||
mouse_down = false;
|
|
||||||
ignore_padding = true;
|
|
||||||
unsetFocusable();
|
unsetFocusable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,17 +338,6 @@ void FStatusBar::drawKeys()
|
||||||
x_msg = x;
|
x_msg = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FStatusBar::adjustSize()
|
|
||||||
{
|
|
||||||
xmin = ymin = 1;
|
|
||||||
height = 1;
|
|
||||||
xpos = 1;
|
|
||||||
width = getColumnNumber();
|
|
||||||
ypos = getLineNumber();
|
|
||||||
FWidget::adjustSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// public methods of FStatusBar
|
// public methods of FStatusBar
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -709,6 +698,16 @@ void FStatusBar::clear()
|
||||||
keylist.clear();
|
keylist.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FStatusBar::adjustSize()
|
||||||
|
{
|
||||||
|
xmin = ymin = 1;
|
||||||
|
height = 1;
|
||||||
|
xpos = 1;
|
||||||
|
width = getColumnNumber();
|
||||||
|
ypos = getLineNumber();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FStatusBar::cb_statuskey_activated (FWidget* widget, void*)
|
void FStatusBar::cb_statuskey_activated (FWidget* widget, void*)
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,7 +158,6 @@ class FStatusBar : public FWindow
|
||||||
void init();
|
void init();
|
||||||
void draw();
|
void draw();
|
||||||
void drawKeys();
|
void drawKeys();
|
||||||
void adjustSize();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FStatusBar (FWidget* = 0); // constructor
|
explicit FStatusBar (FWidget* = 0); // constructor
|
||||||
|
@ -192,6 +191,7 @@ class FStatusBar : public FWindow
|
||||||
void remove (int);
|
void remove (int);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void adjustSize();
|
||||||
void cb_statuskey_activated (FWidget*, void*);
|
void cb_statuskey_activated (FWidget*, void*);
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
|
@ -275,8 +275,17 @@ void FTerm::identifyTermType()
|
||||||
}
|
}
|
||||||
else if ( term_name )
|
else if ( term_name )
|
||||||
{
|
{
|
||||||
FILE *fp;
|
|
||||||
// fallback: look into /etc/ttytype or /etc/ttys
|
// fallback: look into /etc/ttytype or /etc/ttys
|
||||||
|
//
|
||||||
|
// file format:
|
||||||
|
// <terminal type> <whitespace> <tty name>
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// linux tty1
|
||||||
|
// vt100 ttys0
|
||||||
|
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
if ( (fp = fopen("/etc/ttytype", "r")) != 0
|
if ( (fp = fopen("/etc/ttytype", "r")) != 0
|
||||||
|| (fp = fopen("/etc/ttys", "r")) != 0 )
|
|| (fp = fopen("/etc/ttys", "r")) != 0 )
|
||||||
{
|
{
|
||||||
|
|
113
src/fwidget.cpp
113
src/fwidget.cpp
|
@ -484,6 +484,35 @@ void FWidget::adjustSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FWidget::adjustSizeGlobal()
|
||||||
|
{
|
||||||
|
if ( ! isRootWidget() )
|
||||||
|
{
|
||||||
|
getRootWidget()->adjustSizeGlobal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( menubar )
|
||||||
|
menubar->adjustSize();
|
||||||
|
|
||||||
|
if ( statusbar )
|
||||||
|
statusbar->adjustSize();
|
||||||
|
|
||||||
|
if ( window_list && ! window_list->empty() )
|
||||||
|
{
|
||||||
|
widgetList::const_iterator iter, end;
|
||||||
|
iter = window_list->begin();
|
||||||
|
end = window_list->end();
|
||||||
|
|
||||||
|
while ( iter != end )
|
||||||
|
{
|
||||||
|
(*iter)->adjustSize();
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::setStatusBar (FStatusBar* sbar)
|
void FWidget::setStatusBar (FStatusBar* sbar)
|
||||||
{
|
{
|
||||||
|
@ -1246,6 +1275,7 @@ void FWidget::resize()
|
||||||
statusbar->setGeometry(1, height, width, 1, false);
|
statusbar->setGeometry(1, height, width, 1, false);
|
||||||
if ( vstatusbar )
|
if ( vstatusbar )
|
||||||
resizeArea(vstatusbar);
|
resizeArea(vstatusbar);
|
||||||
|
statusbar->adjustSize();
|
||||||
}
|
}
|
||||||
if ( window_list && ! window_list->empty() )
|
if ( window_list && ! window_list->empty() )
|
||||||
{
|
{
|
||||||
|
@ -1597,9 +1627,20 @@ void FWidget::setTopPadding (int t, bool adjust)
|
||||||
{
|
{
|
||||||
if ( top_padding == t )
|
if ( top_padding == t )
|
||||||
return;
|
return;
|
||||||
(t > 0) ? top_padding = t : top_padding = 1;
|
|
||||||
|
(t > 0) ? top_padding = t : top_padding = 0;
|
||||||
|
|
||||||
if ( adjust )
|
if ( adjust )
|
||||||
|
{
|
||||||
|
if ( isRootWidget() )
|
||||||
|
{
|
||||||
|
FWidget* r_obj = rootObject;
|
||||||
|
r_obj->client_ymin = 1 + r_obj->top_padding;
|
||||||
|
adjustSizeGlobal();
|
||||||
|
}
|
||||||
|
else
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1607,9 +1648,20 @@ void FWidget::setLeftPadding (int l, bool adjust)
|
||||||
{
|
{
|
||||||
if ( left_padding == l )
|
if ( left_padding == l )
|
||||||
return;
|
return;
|
||||||
(l > 0) ? left_padding = l : left_padding = 1;
|
|
||||||
|
(l > 0) ? left_padding = l : left_padding = 0;
|
||||||
|
|
||||||
if ( adjust )
|
if ( adjust )
|
||||||
|
{
|
||||||
|
if ( isRootWidget() )
|
||||||
|
{
|
||||||
|
FWidget* r_obj = rootObject;
|
||||||
|
r_obj->client_xmin = 1 + r_obj->left_padding;
|
||||||
|
adjustSizeGlobal();
|
||||||
|
}
|
||||||
|
else
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1617,9 +1669,20 @@ void FWidget::setBottomPadding (int b, bool adjust)
|
||||||
{
|
{
|
||||||
if ( bottom_padding == b )
|
if ( bottom_padding == b )
|
||||||
return;
|
return;
|
||||||
(b > 0) ? bottom_padding = b : bottom_padding = 1;
|
|
||||||
|
(b > 0) ? bottom_padding = b : bottom_padding = 0;
|
||||||
|
|
||||||
if ( adjust )
|
if ( adjust )
|
||||||
|
{
|
||||||
|
if ( isRootWidget() )
|
||||||
|
{
|
||||||
|
FWidget* r_obj = rootObject;
|
||||||
|
r_obj->client_ymax = r_obj->height - r_obj->bottom_padding;
|
||||||
|
adjustSizeGlobal();
|
||||||
|
}
|
||||||
|
else
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1627,30 +1690,43 @@ void FWidget::setRightPadding (int r, bool adjust)
|
||||||
{
|
{
|
||||||
if ( right_padding == r )
|
if ( right_padding == r )
|
||||||
return;
|
return;
|
||||||
(r > 0) ? right_padding = r : right_padding = 1;
|
|
||||||
|
(r > 0) ? right_padding = r : right_padding = 0;
|
||||||
|
|
||||||
if ( adjust )
|
if ( adjust )
|
||||||
|
{
|
||||||
|
if ( isRootWidget() )
|
||||||
|
{
|
||||||
|
FWidget* r_obj = rootObject;
|
||||||
|
r_obj->client_xmax = r_obj->width - r_obj->right_padding;
|
||||||
|
adjustSizeGlobal();
|
||||||
|
}
|
||||||
|
else
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::getTermGeometry()
|
void FWidget::getTermGeometry()
|
||||||
{
|
{
|
||||||
|
FWidget* r_obj = rootObject;
|
||||||
|
|
||||||
if ( openConsole() == 0 )
|
if ( openConsole() == 0 )
|
||||||
{
|
{
|
||||||
getTermSize();
|
getTermSize();
|
||||||
closeConsole();
|
closeConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
rootObject->width = term->getWidth();
|
r_obj->width = term->getWidth();
|
||||||
rootObject->height = term->getHeight();
|
r_obj->height = term->getHeight();
|
||||||
rootObject->xmin = 1;
|
r_obj->xmin = 1;
|
||||||
rootObject->ymin = 1;
|
r_obj->ymin = 1;
|
||||||
rootObject->xmax = rootObject->width;
|
r_obj->xmax = r_obj->width;
|
||||||
rootObject->ymax = rootObject->height;
|
r_obj->ymax = r_obj->height;
|
||||||
rootObject->client_xmin = 1 + rootObject->left_padding;
|
r_obj->client_xmin = 1 + r_obj->left_padding;
|
||||||
rootObject->client_ymin = 1 + rootObject->top_padding;
|
r_obj->client_ymin = 1 + r_obj->top_padding;
|
||||||
rootObject->client_xmax = rootObject->width;
|
r_obj->client_xmax = r_obj->width - r_obj->right_padding;
|
||||||
rootObject->client_ymax = rootObject->height;
|
r_obj->client_ymax = r_obj->height - r_obj->bottom_padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1659,10 +1735,11 @@ void FWidget::setTermGeometry (int w, int h)
|
||||||
// Set xterm size to w x h
|
// Set xterm size to w x h
|
||||||
if ( xterm )
|
if ( xterm )
|
||||||
{
|
{
|
||||||
rootObject->xpos = 1;
|
FWidget* r_obj = rootObject;
|
||||||
rootObject->ypos = 1;
|
r_obj->xpos = 1;
|
||||||
rootObject->width = w; // columns
|
r_obj->ypos = 1;
|
||||||
rootObject->height = h; // lines
|
r_obj->width = w; // columns
|
||||||
|
r_obj->height = h; // lines
|
||||||
|
|
||||||
setTermSize (w, h);
|
setTermSize (w, h);
|
||||||
getTermGeometry();
|
getTermGeometry();
|
||||||
|
|
|
@ -286,6 +286,7 @@ class FWidget : public FObject, public FTerm
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void adjustSize();
|
virtual void adjustSize();
|
||||||
|
void adjustSizeGlobal();
|
||||||
virtual void setStatusBar (FStatusBar*);
|
virtual void setStatusBar (FStatusBar*);
|
||||||
virtual void setMenuBar (FMenuBar*);
|
virtual void setMenuBar (FMenuBar*);
|
||||||
// Event handlers
|
// Event handlers
|
||||||
|
|
|
@ -790,6 +790,7 @@ void MyDialog::adjustSize()
|
||||||
if ( X < 1 )
|
if ( X < 1 )
|
||||||
X = 1;
|
X = 1;
|
||||||
setX (X, false);
|
setX (X, false);
|
||||||
|
if ( myList )
|
||||||
myList->setHeight (getHeight() - 3, false);
|
myList->setHeight (getHeight() - 3, false);
|
||||||
FDialog::adjustSize();
|
FDialog::adjustSize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue