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