Add the new class FDialogListMenu to switch between dialog menus

This commit is contained in:
Markus Gans 2016-07-03 20:08:39 +02:00
parent 0c4b3a3a14
commit 71b5b16865
34 changed files with 375 additions and 171 deletions

View File

@ -1,5 +1,10 @@
2016-07-03 Markus Gans <guru.mail@muenster.de>
* Add the new class FDialogListMenu to switch between dialog menus
* More consistent method names:
rename parentWidget() to getParentWidget()
2016-06-27 Markus Gans <guru.mail@muenster.de>
* Fix the use after free bug for previous_widget
* Fix the use-after-free bug for previous_widget
2016-06-26 Markus Gans <guru.mail@muenster.de>
* Bug fix for FWindow::activatePrevWindow()

View File

@ -23,7 +23,6 @@ Missing Features
- FDialog title button [▲] and [▼] should maximized or restore
the window size on a resizeable dialog
- A possibility to change the window size dynamically with the mouse
- Add a window switcher on the right side of the status bar
- Add a scrolling area with on-demand scroll bars for FButtonGroup
- Adding for flexible layouts a FGrid widget container that organizes
its child widgets in rows and columns

View File

@ -24,6 +24,7 @@ libfinal_la_SOURCES = \
flabel.cpp \
flistbox.cpp \
fmenu.cpp \
fdialoglistmenu.cpp \
fmenubar.cpp \
fmenuitem.cpp \
fradiomenuitem.cpp \
@ -65,6 +66,7 @@ finalcutinclude_HEADERS = \
flineedit.h \
flistbox.h \
fmenu.h \
fdialoglistmenu.h \
fmenubar.h \
fmenuitem.h \
fradiomenuitem.h \

View File

@ -21,6 +21,7 @@ INCLUDE_HEADERS = \
flineedit.h \
flistbox.h \
fmenu.h \
fdialoglistmenu.h \
fmenubar.h \
fradiomenuitem.h \
fcheckmenuitem.h \
@ -67,6 +68,7 @@ OBJS = \
flabel.o \
flistbox.o \
fmenu.o \
fdialoglistmenu.o \
fmenubar.o \
fmenuitem.o \
fradiomenuitem.o \

View File

@ -21,6 +21,7 @@ INCLUDE_HEADERS = \
flineedit.h \
flistbox.h \
fmenu.h \
fdialoglistmenu.h \
fmenubar.h \
fradiomenuitem.h \
fcheckmenuitem.h \
@ -67,6 +68,7 @@ OBJS = \
flabel.o \
flistbox.o \
fmenu.o \
fdialoglistmenu.o \
fmenubar.o \
fmenuitem.o \
fradiomenuitem.o \

View File

@ -131,11 +131,11 @@ libfinal_la_LIBADD =
am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \
fprogressbar.lo flineedit.lo fbutton.lo fbuttongroup.lo \
ftogglebutton.lo fradiobutton.lo fcheckbox.lo fswitch.lo \
flabel.lo flistbox.lo fmenu.lo fmenubar.lo fmenuitem.lo \
fradiomenuitem.lo fcheckmenuitem.lo fmenulist.lo fdialog.lo \
fwindow.lo fmessagebox.lo ffiledialog.lo ftextview.lo \
fstatusbar.lo fterm.lo fevent.lo foptiattr.lo foptimove.lo \
fapp.lo fwidget.lo fobject.lo
flabel.lo flistbox.lo fmenu.lo fdialoglistmenu.lo fmenubar.lo \
fmenuitem.lo fradiomenuitem.lo fcheckmenuitem.lo fmenulist.lo \
fdialog.lo fwindow.lo fmessagebox.lo ffiledialog.lo \
ftextview.lo fstatusbar.lo fterm.lo fevent.lo foptiattr.lo \
foptimove.lo fapp.lo fwidget.lo fobject.lo
libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -388,6 +388,7 @@ libfinal_la_SOURCES = \
flabel.cpp \
flistbox.cpp \
fmenu.cpp \
fdialoglistmenu.cpp \
fmenubar.cpp \
fmenuitem.cpp \
fradiomenuitem.cpp \
@ -427,6 +428,7 @@ finalcutinclude_HEADERS = \
flineedit.h \
flistbox.h \
fmenu.h \
fdialoglistmenu.h \
fmenubar.h \
fmenuitem.h \
fradiomenuitem.h \
@ -535,6 +537,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcheckbox.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcheckmenuitem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdialog.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdialoglistmenu.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fevent.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffiledialog.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flabel.Plo@am__quote@

View File

@ -168,8 +168,8 @@ void FButton::draw()
if ( is_Flat )
clearFlatBorder();
clearShadow();
setColor ( parentWidget()->getForegroundColor()
, parentWidget()->getBackgroundColor() );
setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() );
for (int y=1; y <= height; y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-2+y);
@ -232,7 +232,7 @@ void FButton::draw()
}
else if ( ! isMonochron() )
{
setColor (button_bg, parentWidget()->getBackgroundColor());
setColor (button_bg, getParentWidget()->getBackgroundColor());
gotoxy (xpos+xmin-1+d, ypos+ymin-1);
for (int y=1; y <= height; y++)
{
@ -252,8 +252,8 @@ void FButton::draw()
&& (is_Flat || ! hasShadow() || isMonochron()) )
{
// clear the right █ from button down
setColor ( parentWidget()->getForegroundColor()
, parentWidget()->getBackgroundColor() );
setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() );
for (int y=1; y <= height; y++)
{
if ( isMonochron() )
@ -341,8 +341,8 @@ void FButton::draw()
if ( is_NonFlatShadow && ! button_down )
{
setColor ( parentWidget()->getForegroundColor()
, parentWidget()->getBackgroundColor() );
setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() );
print(' '); // restore background after button down
drawShadow();
}
@ -462,8 +462,8 @@ void FButton::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
s = hasShadow() ? 1 : 0;

View File

@ -280,8 +280,8 @@ void FButtonGroup::hide()
}
}
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
size = width;

View File

@ -55,7 +55,7 @@ FDialog::~FDialog() // destructor
const FRect& geometry = getGeometryGlobalShadow();
restoreVTerm (geometry);
parentWidget()->redraw();
getParentWidget()->redraw();
}
if ( window_list && ! window_list->empty() )
@ -164,7 +164,7 @@ void FDialog::drawBorder()
{
short fg;
if ( ! isRootWidget() )
fg = parentWidget()->getForegroundColor();
fg = getParentWidget()->getForegroundColor();
else
fg = wc.term_fg;
for (int y=y1; y <= y2; y++)

55
src/fdialoglistmenu.cpp Normal file
View File

@ -0,0 +1,55 @@
// File: fdialoglistmenu.cpp
// Provides: class FDialogListMenu
#include "fdialoglistmenu.h"
//----------------------------------------------------------------------
// class FDialogListMenu
//----------------------------------------------------------------------
// constructor and destructor
//----------------------------------------------------------------------
FDialogListMenu::FDialogListMenu(FWidget* parent)
: FMenu(parent)
{
init();
}
//----------------------------------------------------------------------
FDialogListMenu::FDialogListMenu (FString& txt, FWidget* parent)
: FMenu(txt, parent)
{
init();
}
//----------------------------------------------------------------------
FDialogListMenu::FDialogListMenu (const std::string& txt, FWidget* parent)
: FMenu(txt, parent)
{
init();
}
//----------------------------------------------------------------------
FDialogListMenu::FDialogListMenu (const char* txt, FWidget* parent)
: FMenu(txt, parent)
{
init();
}
//----------------------------------------------------------------------
FDialogListMenu::~FDialogListMenu()
{ }
// private methods of FMenu
//----------------------------------------------------------------------
void FDialogListMenu::init()
{
FMenuItem* menuitem = getItem();
if ( menuitem )
menuitem->dialog_list = true;
}

71
src/fdialoglistmenu.h Normal file
View File

@ -0,0 +1,71 @@
// File: fdialoglistmenu.h
// Provides: class FDialogListMenu
//
// Inheritance diagram
// ═══════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │
// └─────┬─────┘
// │
// ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FWidget ▏
// ▕▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FWindow ▏ ▕ FMenuList ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │
// └─────┬─────┘
// │
// ▕▔▔▔▔▔▔▔▏
// ▕ FMenu ▏
// ▕▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FDialogListMenu ▏- - - - - -▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏1 1▕▁▁▁▁▁▁▁▁▁▁▁▏
#ifndef _FDIALOGLISTMENU_H
#define _FDIALOGLISTMENU_H
#include "fmenu.h"
//----------------------------------------------------------------------
// class FDialogListMenu
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FDialogListMenu : public FMenu
{
private:
FDialogListMenu (const FDialogListMenu&);
FDialogListMenu& operator = (const FDialogListMenu&);
void init();
public:
explicit FDialogListMenu (FWidget* = 0); // constructor
FDialogListMenu (FString&, FWidget* = 0);
FDialogListMenu (const std::string&, FWidget* = 0);
FDialogListMenu (const char*, FWidget* = 0);
virtual ~FDialogListMenu(); // destructor
virtual const char* getClassName() const;
};
#pragma pack(pop)
// FDialogListMenu inline functions
//----------------------------------------------------------------------
inline const char* FDialogListMenu::getClassName() const
{ return "FDialogListMenu"; }
#endif // _FDIALOGLISTMENU_H

View File

@ -46,7 +46,7 @@ FFileDialog::FFileDialog(FWidget* parent)
//----------------------------------------------------------------------
FFileDialog::FFileDialog (const FFileDialog& fdlg)
: FDialog(fdlg.parentWidget())
: FDialog(fdlg.getParentWidget())
, directory_stream(0)
, dir_entries()
, directory(fdlg.directory)
@ -110,8 +110,8 @@ void FFileDialog::init()
width = 15;
if ( width < 20 )
width = 20;
x = 1 + int((parentWidget()->getWidth()-width)/2);
y = 1 + int((parentWidget()->getHeight()-height)/3);
x = 1 + int((getParentWidget()->getWidth()-width)/2);
y = 1 + int((getParentWidget()->getHeight()-height)/3);
if ( dlg_type == FFileDialog::Save )
FDialog::setText("Save file");
@ -476,7 +476,7 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
delete filename;
clear();
fdlg.parentWidget()->addChild (this);
fdlg.getParentWidget()->addChild (this);
directory = fdlg.directory;
filter_pattern = fdlg.filter_pattern;

View File

@ -20,6 +20,7 @@
#include "ftextview.h"
#include "flineedit.h"
#include "fmenu.h"
#include "fdialoglistmenu.h"
#include "fmenubar.h"
#include "fmenuitem.h"
#include "fcheckmenuitem.h"

View File

@ -60,8 +60,8 @@ void FLabel::init()
unsetFocusable();
foregroundColor = parentWidget()->getForegroundColor();
backgroundColor = parentWidget()->getBackgroundColor();
foregroundColor = getParentWidget()->getForegroundColor();
backgroundColor = getParentWidget()->getBackgroundColor();
}
//----------------------------------------------------------------------
@ -321,8 +321,8 @@ void FLabel::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
blank = new char[width+1];

View File

@ -280,8 +280,8 @@ void FLineEdit::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
size = width + s;

View File

@ -540,8 +540,8 @@ void FListBox::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
n = isNewFont() ? 1 : 0;

View File

@ -106,7 +106,7 @@ void FMenu::init(FWidget* parent)
bottom_padding = 1;
right_padding = 1;
createArea (vwin);
setGeometry (1, 1 , 10, 2, false); // initialize geometry values
setGeometry (1, 1, 10, 2, false); // initialize geometry values
setTransparentShadow();
window_object = true;
menu_object = true;

View File

@ -581,9 +581,10 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth();
if ( mouse_y == 1 )
{
if ( mouse_x >= x1
&& mouse_x < x2
&& mouse_y == 1 )
&& mouse_x < x2 )
{
// Mouse pointer over item
if ( (*iter)->isEnabled() && ! (*iter)->isSelected() )
@ -611,11 +612,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
}
}
}
else
{
if ( mouse_y == 1
&& (*iter)->isEnabled()
&& (*iter)->isSelected() )
else if ( (*iter)->isEnabled() && (*iter)->isSelected() )
{
(*iter)->unsetSelected();
if ( getSelectedItem() == *iter )
@ -625,8 +622,10 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
}
++iter;
}
if ( statusBar() )
statusBar()->drawMessage();
if ( focus_changed )
{
redraw();
@ -661,9 +660,10 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth();
if ( mouse_y == 1 )
{
if ( mouse_x >= x1
&& mouse_x < x2
&& mouse_y == 1
&& (*iter)->isEnabled()
&& (*iter)->isSelected() )
{
@ -698,20 +698,16 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
}
}
}
else
{
if ( mouse_y == 1
&& (*iter)->isEnabled()
&& (*iter)->isSelected() )
else if ( (*iter)->isEnabled() && (*iter)->isSelected() )
{
(*iter)->unsetSelected();
if ( getSelectedItem() == *iter )
setSelectedItem(0);
redraw();
}
}
++iter;
}
}
if ( ! hasSelectedItem() )
leaveMenuBar();
}
@ -901,3 +897,4 @@ void FMenuBar::cb_item_deactivated (FWidget* widget, void*)
menu->hideSubMenus();
}
}

View File

@ -22,12 +22,13 @@ FMenuItem::FMenuItem (FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(0)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -40,12 +41,13 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(0)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -58,12 +60,13 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(0)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -76,12 +79,13 @@ FMenuItem::FMenuItem (const char* txt, FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(0)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -94,12 +98,13 @@ FMenuItem::FMenuItem (int k, FString& txt, FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(k)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -112,12 +117,13 @@ FMenuItem::FMenuItem (int k, const std::string& txt, FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(k)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -130,12 +136,13 @@ FMenuItem::FMenuItem (int k, const char* txt, FWidget* parent)
, separator(false)
, checkable(false)
, checked(false)
, radio_button(false)
, dialog_list(false)
, text_length(0)
, hotkey(0)
, accel_key(k)
, menu(0)
, super_menu(0)
, radio_button(false)
{
init (parent);
}
@ -239,6 +246,53 @@ void FMenuItem::processDeactivate()
emitCallback("deactivate");
}
//----------------------------------------------------------------------
void FMenuItem::createDialogList (FMenu* winmenu)
{
winmenu->clear();
if ( window_list && ! window_list->empty() )
{
widgetList::const_iterator iter, begin;
iter = window_list->end();
begin = window_list->begin();
do
{
--iter;
if ( (*iter)->isDialog() )
{
FDialog* win = dynamic_cast<FDialog*>(*iter);
FString win_title = win->getText();
FMenuItem* win_item = new FMenuItem (win_title, winmenu);
win_item->addCallback
(
"clicked",
_METHOD_CALLBACK (this, &FMenuItem::cb_switchToDialog),
dynamic_cast<FWidget::data_ptr>(win)
);
}
}
while ( iter != begin );
}
winmenu->menu_dimension();
}
//----------------------------------------------------------------------
void FMenuItem::cb_switchToDialog (FWidget*, void* data_ptr)
{
FDialog* win = static_cast<FDialog*>(data_ptr);
if ( win && ! win->isHiddenWindow() && ! win->isActiveWindow() )
{
FWindow::setActiveWindow(win);
FWidget* focus_widget = win->getFocusWidget();
FWindow::raiseWindow (win);
if ( focus_widget )
focus_widget->setFocus();
win->redraw();
}
}
//----------------------------------------------------------------------
void FMenuItem::processClicked()
{
@ -256,15 +310,18 @@ bool FMenuItem::isWindowsMenu (FWidget* w) const
//----------------------------------------------------------------------
bool FMenuItem::isMenuBar (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
return bool( strcmp ( w->getClassName()
, const_cast<char*>("FMenuBar") ) == 0 );
}
//----------------------------------------------------------------------
bool FMenuItem::isMenu (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
bool m1 = ( strcmp ( w->getClassName()
, const_cast<char*>("FMenu") ) == 0 );
bool m2 = ( strcmp ( w->getClassName()
, const_cast<char*>("FDialogListMenu") ) == 0 );
return bool( m1 || m2 );
}
@ -279,7 +336,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
while ( super && strncmp ( super->getClassName()
, const_cast<char*>("FMenu"), 5) == 0 )
{
super = super->parentWidget();
super = super->getParentWidget();
}
if ( super )
@ -314,7 +371,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
while ( super && strncmp ( super->getClassName()
, const_cast<char*>("FMenu"), 5) == 0 )
{
super = super->parentWidget();
super = super->getParentWidget();
}
if ( super )
@ -754,6 +811,8 @@ void FMenuItem::openMenu()
open_menu->hide();
open_menu->hideSubMenus();
}
if ( dialog_list )
createDialogList (dd_menu);
setOpenMenu(dd_menu);
dd_menu->setVisible();

View File

@ -48,12 +48,13 @@ class FMenuItem : public FWidget
bool separator;
bool checkable;
bool checked;
bool radio_button;
bool dialog_list;
uInt text_length;
int hotkey;
int accel_key;
FMenu* menu;
FWidget* super_menu;
bool radio_button;
private:
FMenuItem (const FMenuItem&);
@ -62,6 +63,8 @@ class FMenuItem : public FWidget
uChar hotKey();
void processActivate();
void processDeactivate();
void createDialogList (FMenu*);
void cb_switchToDialog (FWidget*, void*);
virtual void processClicked();
protected:
@ -124,6 +127,7 @@ class FMenuItem : public FWidget
void setText (const char*);
private:
friend class FDialogListMenu;
friend class FMenuList;
friend class FMenuBar;
friend class FMenu;

View File

@ -44,7 +44,7 @@ FMessageBox::FMessageBox(FWidget* parent)
//----------------------------------------------------------------------
FMessageBox::FMessageBox (const FMessageBox& mbox)
: FDialog(mbox.parentWidget())
: FDialog(mbox.getParentWidget())
, headline_text(mbox.headline_text)
, text(mbox.text)
, text_components(mbox.text_components)
@ -208,8 +208,8 @@ void FMessageBox::msg_dimension()
w = int(maxLineWidth + 4);
if ( w < 20 )
w = 20;
x = 1 + int((parentWidget()->getWidth()-w)/2);
y = 1 + int((parentWidget()->getHeight()-h)/3);
x = 1 + int((getParentWidget()->getWidth()-w)/2);
y = 1 + int((getParentWidget()->getHeight()-h)/3);
setGeometry (x, y, w, h);
}
@ -354,7 +354,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
delete button_digit[1];
delete button_digit[0];
mbox.parentWidget()->addChild (this);
mbox.getParentWidget()->addChild (this);
headline_text = mbox.headline_text;
text = mbox.text;

View File

@ -25,8 +25,8 @@ FProgressbar::~FProgressbar()
//----------------------------------------------------------------------
void FProgressbar::drawPercentage()
{
setColor ( parentWidget()->getForegroundColor()
, parentWidget()->getBackgroundColor() );
setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() );
if ( isMonochron() )
setReverse(true);
gotoxy (xpos+xmin+width-5, ypos+ymin-2);
@ -68,10 +68,10 @@ void FProgressbar::drawBar()
if ( round(length) >= 1)
setColor ( wc.progressbar_fg
, parentWidget()->getBackgroundColor() );
, getParentWidget()->getBackgroundColor() );
else
setColor ( wc.progressbar_bg
, parentWidget()->getBackgroundColor() );
, getParentWidget()->getBackgroundColor() );
if ( ! isMonochron() && getMaxColor() >= 16 )
{
@ -160,8 +160,8 @@ void FProgressbar::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
s = hasShadow() ? 1 : 0;

View File

@ -196,8 +196,8 @@ void FTextView::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
n = isNewFont() ? 1 : 0;

View File

@ -352,8 +352,8 @@ void FToggleButton::hide()
FWidget::hide();
fg = parentWidget()->getForegroundColor();
bg = parentWidget()->getBackgroundColor();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
size = width;

View File

@ -170,6 +170,7 @@ void FWidget::init()
void FWidget::finish()
{
delete accelerator_list;
accelerator_list = 0;
if ( close_widget )
{
@ -401,19 +402,19 @@ void FWidget::adjustSize()
}
else if ( ignore_padding )
{
xmin = parentWidget()->xpos + parentWidget()->xmin - 1;
ymin = parentWidget()->ypos + parentWidget()->ymin - 1;
xmax = parentWidget()->xpos + parentWidget()->xmin - 2
+ parentWidget()->width;
ymax = parentWidget()->ypos + parentWidget()->ymin - 2
+ parentWidget()->height;
xmin = getParentWidget()->xpos + getParentWidget()->xmin - 1;
ymin = getParentWidget()->ypos + getParentWidget()->ymin - 1;
xmax = getParentWidget()->xpos + getParentWidget()->xmin - 2
+ getParentWidget()->width;
ymax = getParentWidget()->ypos + getParentWidget()->ymin - 2
+ getParentWidget()->height;
}
else
{
xmin = parentWidget()->client_xmin;
ymin = parentWidget()->client_ymin;
xmax = parentWidget()->client_xmax;
ymax = parentWidget()->client_ymax;
xmin = getParentWidget()->client_xmin;
ymin = getParentWidget()->client_ymin;
xmax = getParentWidget()->client_xmax;
ymax = getParentWidget()->client_ymax;
}
xpos = widgetSize.getX();
ypos = widgetSize.getY();
@ -569,7 +570,7 @@ bool FWidget::event (FEvent* ev)
}
if ( kev->isAccepted() || widget->isRootWidget() )
break;
widget = widget->parentWidget();
widget = widget->getParentWidget();
}
}
break;
@ -587,7 +588,7 @@ bool FWidget::event (FEvent* ev)
widget->onKeyDown(kev);
if ( kev->isAccepted() || widget->isRootWidget() )
break;
widget = widget->parentWidget();
widget = widget->getParentWidget();
}
}
break;
@ -845,12 +846,12 @@ bool FWidget::focusPrevChild()
FWidget* FWidget::getRootWidget() const
{
FWidget* obj = const_cast<FWidget*>(this);
FWidget* p_obj = parentWidget();
FWidget* p_obj = getParentWidget();
while ( ! obj->isRootWidget() && p_obj )
{
obj = p_obj;
p_obj = p_obj->parentWidget();
p_obj = p_obj->getParentWidget();
}
return obj;
}
@ -1119,7 +1120,7 @@ void FWidget::addAccelerator (int key, FWidget* obj)
if ( ! window )
window = getRootWidget();
if ( window == statusbar || window == menubar )
window = FWindow::getWindowWidget(parentWidget());
window = FWindow::getWindowWidget(getParentWidget());
if ( window && window->accelerator_list )
window->accelerator_list->push_back(accel);
}
@ -1132,7 +1133,7 @@ void FWidget::delAccelerator (FWidget* obj)
if ( ! window )
window = getRootWidget();
if ( window == statusbar || window == menubar )
window = FWindow::getWindowWidget(parentWidget());
window = FWindow::getWindowWidget(getParentWidget());
if ( window
&& window->accelerator_list
&& ! window->accelerator_list->empty() )
@ -1351,7 +1352,7 @@ void FWidget::hide()
if ( ! focusPrevChild() )
{
FWidget::getFocusWidget()->unsetFocus();
FWidget::setFocusWidget(parentWidget());
FWidget::setFocusWidget(getParentWidget());
}
}
FHideEvent hide_ev (fc::Hide_Event);

View File

@ -329,7 +329,7 @@ class FWidget : public FObject, public FTerm
static FWidget* getOpenMenu();
static void setOpenMenu(FWidget*);
int numOfFocusableChildren();
FWidget* parentWidget() const;
FWidget* getParentWidget() const;
bool isRootWidget() const;
bool isWindow() const;
bool isDialog() const;
@ -543,7 +543,7 @@ inline FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos)
{ return childWidgetAt (p, pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline FWidget* FWidget::parentWidget() const
inline FWidget* FWidget::getParentWidget() const
{ return static_cast<FWidget*>(getParent()); }
//----------------------------------------------------------------------

View File

@ -157,11 +157,11 @@ void FWindow::delWindow (FWidget* obj)
FWindow* FWindow::getWindowWidget (FWidget* obj)
{
// returns the window object to the given widget obj
FWidget* p_obj = obj->parentWidget();
FWidget* p_obj = obj->getParentWidget();
while ( ! obj->isWindow() && p_obj )
{
obj = p_obj;
p_obj = p_obj->parentWidget();
p_obj = p_obj->getParentWidget();
}
if ( obj->isWindow() )
return static_cast<FWindow*>(obj);

View File

@ -41,7 +41,7 @@ Button::Button (FWidget* parent)
{ }
//----------------------------------------------------------------------
void Button::setChecked(bool on)
void Button::setChecked (bool on)
{
if ( checked != on )
{
@ -948,8 +948,8 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
//----------------------------------------------------------------------
void Calc::adjustSize()
{
int pw = parentWidget()->getWidth();
int ph = parentWidget()->getHeight();
int pw = getParentWidget()->getWidth();
int ph = getParentWidget()->getHeight();
setX (1 + (pw - getWidth()) / 2, false);
setY (1 + (ph - getHeight()) / 2, false);
FDialog::adjustSize();

View File

@ -114,8 +114,8 @@ void Mandelbrot::onClose (FCloseEvent* ev)
//----------------------------------------------------------------------
void Mandelbrot::adjustSize()
{
int h = parentWidget()->getHeight() - 1;
int w = parentWidget()->getWidth() - 10;
int h = getParentWidget()->getHeight() - 1;
int w = getParentWidget()->getWidth() - 10;
setGeometry(6, 1, w, h, false);
FDialog::adjustSize();
}

View File

@ -251,8 +251,8 @@ void Menu::cb_exitApp (FWidget*, void*)
//----------------------------------------------------------------------
void Menu::adjustSize()
{
int pw = parentWidget()->getWidth();
int ph = parentWidget()->getHeight();
int pw = getParentWidget()->getWidth();
int ph = getParentWidget()->getHeight();
setX (1 + (pw - getWidth()) / 2, false);
setY (1 + (ph - getHeight()) / 4, false);
FDialog::adjustSize();

View File

@ -133,8 +133,8 @@ void AttribDlg::cb_back (FWidget*, void*)
//----------------------------------------------------------------------
void AttribDlg::adjustSize()
{
int x = ((parentWidget()->getWidth() - getWidth()) / 2 );
int y = ((parentWidget()->getHeight() - getHeight()) / 2 ) + 1;
int x = ((getParentWidget()->getWidth() - getWidth()) / 2 );
int y = ((getParentWidget()->getHeight() - getHeight()) / 2 ) + 1;
if ( x < 1 )
x = 1;
if ( y < 1 )
@ -170,7 +170,7 @@ class AttribDemo : public FWidget
{ }
void onWheel (FWheelEvent* ev)
{
AttribDlg* p = dynamic_cast<AttribDlg*>(parentWidget());
AttribDlg* p = dynamic_cast<AttribDlg*>(getParentWidget());
if ( p )
p->onWheel(ev);
}
@ -236,7 +236,7 @@ void AttribDemo::draw()
// test alternate character set
printAltCharset();
for (int y=0; y < parentWidget()->getHeight()-7; y++)
for (int y=0; y < getParentWidget()->getHeight()-7; y++)
{
gotoxy ( xpos + xmin - 1,
ypos + ymin + y );

View File

@ -45,7 +45,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
, more()
, quit()
{
setGeometry (int((this->parentWidget()->getWidth()-40)/2), 7, 40, 10);
setGeometry (int((this->getParentWidget()->getWidth()-40)/2), 7, 40, 10);
setText("Progress bar");
setTransparentShadow();
//setModal();
@ -220,6 +220,8 @@ MyDialog::MyDialog (FWidget* parent)
FMenuItem* Options = new FMenuItem ("&Options", Menubar);
Options->setStatusbarMessage ("Set program defaults");
Options->setDisable();
FDialogListMenu* Window = new FDialogListMenu ("&Window", Menubar);
Window->setStatusbarMessage ("List of all the active dialogs");
FMenuItem* Help = new FMenuItem ("&Help", Menubar);
Help->setStatusbarMessage ("Show version and copyright information");
@ -740,7 +742,8 @@ void MyDialog::cb_view (FWidget*, void* data_ptr)
return;
FDialog* view = new FDialog(this);
view->setText ("Viewer");
FString filename(basename(const_cast<char*>(file.c_str())));
view->setText ("Viewer: " + filename);
view->setGeometry (1+int((getRootWidget()->getWidth()-60)/2),
int(getRootWidget()->getHeight()/6),
60,
@ -790,9 +793,9 @@ void MyDialog::cb_exitApp (FWidget*, void*)
//----------------------------------------------------------------------
void MyDialog::adjustSize()
{
int h = parentWidget()->getHeight() - 4;
int h = getParentWidget()->getHeight() - 4;
setHeight (h, false);
int X = int((parentWidget()->getWidth() - getWidth()) / 2);
int X = int((getParentWidget()->getWidth() - getWidth()) / 2);
if ( X < 1 )
X = 1;
setX (X, false);

View File

@ -56,7 +56,7 @@ watch::watch (FWidget* parent)
{
setText ("Watch");
setShadow();
int pw = parentWidget()->getWidth();
int pw = getParentWidget()->getWidth();
setGeometry (1+(pw-22)/2, 3, 22, 13);
// Create labels
@ -191,7 +191,7 @@ void watch::cb_exitApp (FWidget*, void*)
//----------------------------------------------------------------------
void watch::adjustSize()
{
int pw = parentWidget()->getWidth();
int pw = getParentWidget()->getWidth();
setX (1+(pw-22)/2, false);
FDialog::adjustSize();
}