add vmenubar

This commit is contained in:
Markus Gans 2015-08-09 23:44:11 +02:00
parent d37619b5be
commit b1c8c70391
5 changed files with 73 additions and 5 deletions

View File

@ -6,7 +6,8 @@ Missing Features
~~~~~~~~~~~~~~~~
- application menu
- FMenuBar()
- FPopupMenu()
- FMenu()
- FMenuItem()
- list/tree view with Columns
- FListView()

View File

@ -677,8 +677,8 @@ void FDialog::move (int x, int y)
dx = xpos - x;
dy = ypos - y;
old_x = xpos;
old_y = ypos;
old_x = getGlobalX();
old_y = getGlobalY();
short& rsw = shadow.x_ref(); // right shadow width;
short& bsh = shadow.y_ref(); // bottom shadow height
oldGeometry = getGeometryShadow();

View File

@ -3,6 +3,7 @@
#include "fapp.h"
#include "fstatusbar.h"
#include "fmenubar.h"
#include "fwidget.h"
#include "fwindow.h"
@ -13,6 +14,7 @@ static FWidget* rootObject = 0;
uInt FWidget::modal_dialogs;
FStatusBar* FWidget::statusbar = 0;
FMenuBar* FWidget::menubar = 0;
FWidget* FWidget::show_root_widget = 0;
FWidget* FWidget::redraw_root_widget = 0;
FWidget::widgetList* FWidget::window_list = 0;
@ -233,6 +235,14 @@ void FWidget::setColorTheme()
wc.titlebar_inactive_bg = fc::DarkGray;
wc.titlebar_button_fg = fc::Black;
wc.titlebar_button_bg = fc::LightGray;
wc.menu_active_focus_fg = fc::White;
wc.menu_active_focus_bg = fc::Blue;
wc.menu_active_fg = fc::Black;
wc.menu_active_bg = fc::White;
wc.menu_inactive_fg = fc::LightGray;
wc.menu_inactive_bg = fc::White;
wc.menu_hotkey_fg = fc::Red;
wc.menu_hotkey_bg = fc::White;
wc.statusbar_fg = fc::White;
wc.statusbar_bg = fc::Blue;
wc.statusbar_hotkey_fg = fc::LightRed;
@ -311,6 +321,14 @@ void FWidget::setColorTheme()
wc.titlebar_inactive_bg = fc::LightGray;
wc.titlebar_button_fg = fc::Black;
wc.titlebar_button_bg = fc::LightGray;
wc.menu_active_focus_fg = fc::LightGray;
wc.menu_active_focus_bg = fc::Blue;
wc.menu_active_fg = fc::Black;
wc.menu_active_bg = fc::LightGray;
wc.menu_inactive_fg = fc::DarkGray;
wc.menu_inactive_bg = fc::LightGray;
wc.menu_hotkey_fg = fc::Red;
wc.menu_hotkey_bg = fc::LightGray;
wc.statusbar_fg = fc::LightGray;
wc.statusbar_bg = fc::Blue;
wc.statusbar_hotkey_fg = fc::Red;
@ -435,6 +453,17 @@ void FWidget::setStatusBar (FStatusBar* sbar)
statusbar = sbar;
}
//----------------------------------------------------------------------
void FWidget::setMenuBar (FMenuBar* mbar)
{
if ( ! mbar || menubar == mbar )
return;
if ( menubar )
delete menubar;
menubar = mbar;
}
//----------------------------------------------------------------------
bool FWidget::event (FEvent* ev)
{
@ -900,6 +929,15 @@ FStatusBar* FWidget::statusBar()
return 0;
}
//----------------------------------------------------------------------
FMenuBar* FWidget::menuBar()
{
if ( menubar )
return menubar;
else
return 0;
}
//----------------------------------------------------------------------
void FWidget::addCallback ( FString cb_signal,
FWidget::FCallback cb_handler,
@ -1104,6 +1142,13 @@ void FWidget::redraw()
++iter;
}
}
if ( menubar && vmenubar )
{
int w = vmenubar->width;
int h = vmenubar->height;
std::fill_n (vmenubar->text, w * h, default_char);
menubar->redraw();
}
if ( statusbar && vstatusbar )
{
int w = vstatusbar->width;
@ -1154,6 +1199,12 @@ void FWidget::resize()
closeConsole();
resizeVTerm();
resizeArea (vdesktop);
if ( menubar )
{
menubar->setGeometry(1, 1, width, 1, false);
if ( vmenubar )
resizeArea(vmenubar);
}
if ( statusbar )
{
statusbar->setGeometry(1, height, width, 1, false);
@ -1530,8 +1581,8 @@ void FWidget::getTermGeometry()
rootObject->ymin = 1;
rootObject->xmax = rootObject->width;
rootObject->ymax = rootObject->height;
rootObject->client_xmin = 1;
rootObject->client_ymin = 1;
rootObject->client_xmin = 1 + rootObject->left_padding;
rootObject->client_ymin = 1 + rootObject->top_padding;
rootObject->client_xmax = rootObject->width;
rootObject->client_ymax = rootObject->height;
}

View File

@ -18,6 +18,7 @@
#define NO_UNDERLINE 0x00000100
class FStatusBar;
class FMenuBar;
//----------------------------------------------------------------------
// class FWidget
@ -123,6 +124,14 @@ class FWidget : public FObject, public FTerm
uChar titlebar_inactive_bg;
uChar titlebar_button_fg;
uChar titlebar_button_bg;
uChar menu_active_focus_fg;
uChar menu_active_focus_bg;
uChar menu_active_fg;
uChar menu_active_bg;
uChar menu_inactive_fg;
uChar menu_inactive_bg;
uChar menu_hotkey_fg;
uChar menu_hotkey_bg;
uChar statusbar_fg;
uChar statusbar_bg;
uChar statusbar_hotkey_fg;
@ -190,6 +199,7 @@ class FWidget : public FObject, public FTerm
FString statusbar_message;
static FStatusBar* statusbar;
static FMenuBar* menubar;
static FWidget* show_root_widget;
static FWidget* redraw_root_widget;
friend class FApplication;
@ -207,6 +217,7 @@ class FWidget : public FObject, public FTerm
protected:
virtual void adjustSize();
virtual void setStatusBar (FStatusBar*);
virtual void setMenuBar (FMenuBar*);
// Event handlers
bool event (FEvent*);
virtual void onKeyPress (FKeyEvent*);
@ -248,6 +259,7 @@ class FWidget : public FObject, public FTerm
virtual bool close();
static FStatusBar* statusBar();
static FMenuBar* menuBar();
void setStatusbarMessage (FString);
void clearStatusbarMessage();
FString getStatusbarMessage();

View File

@ -2,6 +2,7 @@
// class FWindow
#include "fapp.h"
#include "fmenubar.h"
#include "fstatusbar.h"
#include "fwindow.h"
@ -82,6 +83,9 @@ FWindow* FWindow::windowWidgetAt(int x, int y)
if ( statusBar() && statusBar()->getGeometryGlobal().contains(x,y) )
return statusBar();
if ( menuBar() && menuBar()->getGeometryGlobal().contains(x,y) )
return menuBar();
if ( window_list && ! window_list->empty() )
{
widgetList::const_iterator iter, begin;