Deactivate status bar key automatically
This commit is contained in:
parent
a20f3e6ab5
commit
6a92b4a956
|
@ -1,3 +1,7 @@
|
|||
2015-10-10 Markus Gans <guru.mail@muenster.de>
|
||||
* Deactivate a key from the status bar automatically
|
||||
after getting back from the callback.
|
||||
|
||||
2015-10-09 Markus Gans <guru.mail@muenster.de>
|
||||
* Eliminate duplicate code
|
||||
|
||||
|
|
149
src/fapp.cpp
149
src/fapp.cpp
|
@ -345,10 +345,10 @@ void FApplication::processKeyboardEvent()
|
|||
}
|
||||
else
|
||||
{
|
||||
FKeyEvent k_down_ev(KeyDown_Event, key);
|
||||
sendEvent(widget, &k_down_ev);
|
||||
FKeyEvent k_press_ev(KeyPress_Event, key);
|
||||
sendEvent(widget, &k_press_ev);
|
||||
FKeyEvent k_down_ev (KeyDown_Event, key);
|
||||
sendEvent (widget, &k_down_ev);
|
||||
FKeyEvent k_press_ev (KeyPress_Event, key);
|
||||
sendEvent (widget, &k_press_ev);
|
||||
|
||||
if ( ! k_press_ev.isAccepted() && ! k_down_ev.isAccepted() )
|
||||
{
|
||||
|
@ -370,8 +370,8 @@ void FApplication::processKeyboardEvent()
|
|||
break;
|
||||
if ( iter->key == key )
|
||||
{
|
||||
FAccelEvent a_ev(Accelerator_Event, focus_widget);
|
||||
sendEvent(iter->object, &a_ev);
|
||||
FAccelEvent a_ev (Accelerator_Event, focus_widget);
|
||||
sendEvent (iter->object, &a_ev);
|
||||
break;
|
||||
};
|
||||
++iter;
|
||||
|
@ -382,8 +382,8 @@ void FApplication::processKeyboardEvent()
|
|||
}
|
||||
fifo_offset = int(strlen(fifo_buf));
|
||||
}
|
||||
FKeyEvent k_up_ev(KeyUp_Event, key);
|
||||
sendEvent(widget, &k_up_ev);
|
||||
FKeyEvent k_up_ev (KeyUp_Event, key);
|
||||
sendEvent (widget, &k_up_ev);
|
||||
key = 0;
|
||||
}
|
||||
std::fill_n (k_buf, sizeof(k_buf), '\0');
|
||||
|
@ -395,8 +395,8 @@ void FApplication::processKeyboardEvent()
|
|||
&& fifo_buf[1] == 0x00
|
||||
&& isKeyTimeout(&time_keypressed, key_timeout) )
|
||||
{
|
||||
FKeyEvent k_press_ev(KeyPress_Event, fc::Fkey_escape);
|
||||
sendEvent(widget, &k_press_ev);
|
||||
FKeyEvent k_press_ev (KeyPress_Event, fc::Fkey_escape);
|
||||
sendEvent (widget, &k_press_ev);
|
||||
input_data_pending = false;
|
||||
}
|
||||
}
|
||||
|
@ -948,16 +948,17 @@ void FApplication::processMouseEvent()
|
|||
|| b_state.wheel_up == Pressed
|
||||
|| b_state.wheel_down == Pressed ) )
|
||||
{
|
||||
FWidget* window = FWindow::windowWidgetAt ( mouse->getX(),
|
||||
mouse->getY() );
|
||||
FWidget* window = FWindow::windowWidgetAt ( mouse->getX()
|
||||
, mouse->getY() );
|
||||
if ( window )
|
||||
{
|
||||
FWidget* child = childWidgetAt ( window,
|
||||
mouse->getX(),
|
||||
mouse->getY() );
|
||||
FWidget* child = childWidgetAt ( window
|
||||
, mouse->getX()
|
||||
, mouse->getY() );
|
||||
clicked_widget = (child != 0) ? child : window;
|
||||
}
|
||||
}
|
||||
|
||||
if ( clicked_widget )
|
||||
{
|
||||
FPoint localMousePos;
|
||||
|
@ -976,118 +977,118 @@ void FApplication::processMouseEvent()
|
|||
{
|
||||
if ( b_state.left_button == Pressed )
|
||||
{
|
||||
FMouseEvent m_down_ev (MouseMove_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
LeftButton | key_state);
|
||||
sendEvent(clicked_widget, &m_down_ev);
|
||||
FMouseEvent m_down_ev ( MouseMove_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, LeftButton | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
if ( b_state.right_button == Pressed )
|
||||
{
|
||||
FMouseEvent m_down_ev (MouseMove_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
RightButton | key_state);
|
||||
sendEvent(clicked_widget, &m_down_ev);
|
||||
FMouseEvent m_down_ev ( MouseMove_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, RightButton | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
if ( b_state.middle_button == Pressed )
|
||||
{
|
||||
FMouseEvent m_down_ev (MouseMove_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
MiddleButton | key_state);
|
||||
sendEvent(clicked_widget, &m_down_ev);
|
||||
FMouseEvent m_down_ev ( MouseMove_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, MiddleButton | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( b_state.left_button == DoubleClick )
|
||||
{
|
||||
FMouseEvent m_dblclick_ev (MouseDoubleClick_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
LeftButton | key_state);
|
||||
sendEvent(clicked_widget, &m_dblclick_ev);
|
||||
FMouseEvent m_dblclick_ev ( MouseDoubleClick_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, LeftButton | key_state );
|
||||
sendEvent (clicked_widget, &m_dblclick_ev);
|
||||
}
|
||||
else if ( b_state.left_button == Pressed )
|
||||
{
|
||||
FMouseEvent m_down_ev (MouseDown_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
LeftButton | key_state);
|
||||
sendEvent(clicked_widget, &m_down_ev);
|
||||
FMouseEvent m_down_ev ( MouseDown_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, LeftButton | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
else if ( b_state.left_button == Released )
|
||||
{
|
||||
FMouseEvent m_up_ev (MouseUp_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
LeftButton | key_state);
|
||||
FMouseEvent m_up_ev ( MouseUp_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, LeftButton | key_state );
|
||||
FWidget* released_widget = clicked_widget;
|
||||
clicked_widget = 0;
|
||||
sendEvent(released_widget, &m_up_ev);
|
||||
sendEvent (released_widget, &m_up_ev);
|
||||
}
|
||||
|
||||
if ( b_state.right_button == Pressed )
|
||||
{
|
||||
FMouseEvent m_down_ev (MouseDown_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
RightButton | key_state);
|
||||
sendEvent(clicked_widget, &m_down_ev);
|
||||
FMouseEvent m_down_ev ( MouseDown_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, RightButton | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
else if ( b_state.right_button == Released )
|
||||
{
|
||||
FMouseEvent m_up_ev (MouseUp_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
RightButton | key_state);
|
||||
FMouseEvent m_up_ev ( MouseUp_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, RightButton | key_state );
|
||||
FWidget* released_widget = clicked_widget;
|
||||
clicked_widget = 0;
|
||||
sendEvent(released_widget, &m_up_ev);
|
||||
sendEvent (released_widget, &m_up_ev);
|
||||
}
|
||||
|
||||
if ( b_state.middle_button == Pressed )
|
||||
{
|
||||
FMouseEvent m_down_ev (MouseDown_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
MiddleButton | key_state);
|
||||
sendEvent(clicked_widget, &m_down_ev);
|
||||
FMouseEvent m_down_ev ( MouseDown_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, MiddleButton | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
// gnome-terminal sends no released on middle click
|
||||
if ( gnome_terminal )
|
||||
clicked_widget = 0;
|
||||
}
|
||||
else if ( b_state.middle_button == Released )
|
||||
{
|
||||
FMouseEvent m_up_ev (MouseUp_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
MiddleButton | key_state);
|
||||
FMouseEvent m_up_ev ( MouseUp_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, MiddleButton | key_state );
|
||||
FWidget* released_widget = clicked_widget;
|
||||
clicked_widget = 0;
|
||||
sendEvent(released_widget, &m_up_ev);
|
||||
sendEvent (released_widget, &m_up_ev);
|
||||
}
|
||||
}
|
||||
if ( b_state.wheel_up == Pressed )
|
||||
{
|
||||
FWheelEvent wheel_ev (MouseWheel_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
WheelUp);
|
||||
FWheelEvent wheel_ev ( MouseWheel_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, WheelUp );
|
||||
FWidget* scroll_over_widget = clicked_widget;
|
||||
clicked_widget = 0;
|
||||
sendEvent(scroll_over_widget, &wheel_ev);
|
||||
}
|
||||
if ( b_state.wheel_down == Pressed )
|
||||
{
|
||||
FWheelEvent wheel_ev (MouseWheel_Event,
|
||||
localMousePos,
|
||||
*mouse,
|
||||
WheelDown);
|
||||
FWheelEvent wheel_ev ( MouseWheel_Event
|
||||
, localMousePos
|
||||
, *mouse
|
||||
, WheelDown );
|
||||
FWidget* scroll_over_widget = clicked_widget;
|
||||
clicked_widget = 0;
|
||||
sendEvent(scroll_over_widget, &wheel_ev);
|
||||
sendEvent (scroll_over_widget, &wheel_ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,9 +137,9 @@ class FApplication : public FWidget
|
|||
void processResizeEvent();
|
||||
int processTimerEvent();
|
||||
bool processNextEvent();
|
||||
friend class FDialog;
|
||||
friend class FWidget;
|
||||
friend class FWindow;
|
||||
friend class FDialog;
|
||||
|
||||
public:
|
||||
FApplication (int &argc, char* argv[]); // constructor
|
||||
|
|
109
src/fmenu.cpp
109
src/fmenu.cpp
|
@ -2,6 +2,7 @@
|
|||
// Provides: class FMenu
|
||||
|
||||
#include "fmenu.h"
|
||||
#include "fmessagebox.h" // <----- remove later
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FMenu
|
||||
|
@ -17,7 +18,7 @@ FMenu::FMenu(FWidget* parent)
|
|||
, maxItemWidth(0)
|
||||
, mouse_down(false)
|
||||
{
|
||||
init();
|
||||
init(parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -30,7 +31,7 @@ FMenu::FMenu (FString& txt, FWidget* parent)
|
|||
, mouse_down(false)
|
||||
{
|
||||
item = new FMenuItem(txt, parent);
|
||||
init();
|
||||
init(parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -43,7 +44,7 @@ FMenu::FMenu (const std::string& txt, FWidget* parent)
|
|||
, mouse_down(false)
|
||||
{
|
||||
item = new FMenuItem(txt, parent);
|
||||
init();
|
||||
init(parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -56,7 +57,7 @@ FMenu::FMenu (const char* txt, FWidget* parent)
|
|||
, mouse_down(false)
|
||||
{
|
||||
item = new FMenuItem(txt, parent);
|
||||
init();
|
||||
init(parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -81,7 +82,7 @@ FMenu::~FMenu()
|
|||
|
||||
// private methods of FMenu
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::init()
|
||||
void FMenu::init(FWidget* parent)
|
||||
{
|
||||
width = 10;
|
||||
height = 2;
|
||||
|
@ -107,6 +108,9 @@ void FMenu::init()
|
|||
backgroundColor = wc.menu_active_bg;
|
||||
|
||||
item->setMenu(this);
|
||||
|
||||
if ( parent )
|
||||
setSuperMenu(parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -154,13 +158,20 @@ bool FMenu::isMenuBar (FWidget* w) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMenuList* FMenu::superMenu() const
|
||||
bool FMenu::isMenu (FWidget* w) const
|
||||
{
|
||||
return bool ( strcmp ( w->getClassName()
|
||||
, const_cast<char*>("FMenu") ) == 0 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FMenu::getSuperMenu() const
|
||||
{
|
||||
return super_menu;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::setSuperMenu (FMenuList* smenu)
|
||||
void FMenu::setSuperMenu (FWidget* smenu)
|
||||
{
|
||||
super_menu = smenu;
|
||||
}
|
||||
|
@ -195,6 +206,8 @@ void FMenu::draw()
|
|||
clrscr();
|
||||
drawBorder();
|
||||
drawItems();
|
||||
//if ( (flags & SHADOW) != 0 )
|
||||
// drawMenuShadow();
|
||||
setUpdateVTerm(true);
|
||||
}
|
||||
|
||||
|
@ -365,6 +378,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
|||
if ( ev->getButton() != LeftButton )
|
||||
{
|
||||
mouse_down = false;
|
||||
|
||||
if ( ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
|
@ -374,24 +388,33 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
|||
while ( iter != end )
|
||||
{
|
||||
(*iter)->unsetSelected();
|
||||
selectedListItem = 0;
|
||||
if ( selectedListItem == *iter )
|
||||
selectedListItem = 0;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mouse_down )
|
||||
return;
|
||||
|
||||
if ( ! isActiveWindow() )
|
||||
setActiveWindow(this);
|
||||
|
||||
mouse_down = true;
|
||||
|
||||
if ( ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
bool focus_changed = false;
|
||||
FPoint mouse_pos;
|
||||
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
mouse_pos = ev->getPos();
|
||||
mouse_pos -= FPoint(getRightPadding(),getTopPadding());
|
||||
|
||||
while ( iter != end )
|
||||
{
|
||||
|
@ -400,8 +423,8 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
|||
x1 = (*iter)->getX();
|
||||
x2 = (*iter)->getX() + (*iter)->getWidth() - 1;
|
||||
y = (*iter)->getY();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
mouse_x = mouse_pos.getX();
|
||||
mouse_y = mouse_pos.getY();
|
||||
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x <= x2
|
||||
|
@ -410,6 +433,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
|||
{
|
||||
if ( hasSelectedListItem() )
|
||||
unselectItemInList();
|
||||
|
||||
(*iter)->setSelected();
|
||||
selectedListItem = *iter;
|
||||
focus_changed = true;
|
||||
|
@ -434,9 +458,12 @@ void FMenu::onMouseUp (FMouseEvent* ev)
|
|||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
bool focus_changed = false;
|
||||
FPoint mouse_pos;
|
||||
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
mouse_pos = ev->getPos();
|
||||
mouse_pos -= FPoint(getRightPadding(),getTopPadding());
|
||||
|
||||
while ( iter != end )
|
||||
{
|
||||
|
@ -448,8 +475,8 @@ void FMenu::onMouseUp (FMouseEvent* ev)
|
|||
|
||||
if ( (*iter)->isSelected() )
|
||||
{
|
||||
int mouse_x = ev->getX();
|
||||
int mouse_y = ev->getY();
|
||||
int mouse_x = mouse_pos.getX();
|
||||
int mouse_y = mouse_pos.getY();
|
||||
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x <= x2
|
||||
|
@ -473,13 +500,19 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
|||
if ( ev->getButton() != LeftButton )
|
||||
return;
|
||||
|
||||
if ( ! isActiveWindow() )
|
||||
setActiveWindow(this);
|
||||
|
||||
if ( mouse_down && ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
bool focus_changed = false;
|
||||
FPoint mouse_pos;
|
||||
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
mouse_pos = ev->getPos();
|
||||
mouse_pos -= FPoint(getRightPadding(),getTopPadding());
|
||||
|
||||
while ( iter != end )
|
||||
{
|
||||
|
@ -488,22 +521,54 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
|||
x1 = (*iter)->getX();
|
||||
x2 = (*iter)->getX() + (*iter)->getWidth() - 1;
|
||||
y = (*iter)->getY();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
|
||||
mouse_x = mouse_pos.getX();
|
||||
mouse_y = mouse_pos.getY();
|
||||
/*
|
||||
FMessageBox::info (this, "Info", FString().sprintf("local(%d,%d) global(%d,%d)\n"
|
||||
"iter x1=%d, x2=%d, y=%d"
|
||||
, ev->getX(),ev->getY(),ev->getGlobalX(), ev->getGlobalY()
|
||||
, x1, x2, y) );*/
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x <= x2
|
||||
&& mouse_y == y
|
||||
&& ! (*iter)->isSelected() )
|
||||
&& mouse_y == y )
|
||||
{
|
||||
if ( hasSelectedListItem() )
|
||||
unselectItemInList();
|
||||
(*iter)->setSelected();
|
||||
selectedListItem = *iter;
|
||||
focus_changed = true;
|
||||
if ( (*iter)->isActivated() && ! (*iter)->isSelected() )
|
||||
{
|
||||
(*iter)->setSelected();
|
||||
selectedListItem = *iter;
|
||||
focus_changed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getGeometryGlobal().contains(ev->getGlobalPos())
|
||||
&& (*iter)->isActivated()
|
||||
&& (*iter)->isSelected() )
|
||||
{
|
||||
(*iter)->unsetSelected();
|
||||
if ( selectedListItem == *iter )
|
||||
selectedListItem = 0;
|
||||
focus_changed = true;
|
||||
}
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
|
||||
FWidget* menubar = getSuperMenu();
|
||||
if ( menubar
|
||||
&& isMenuBar(menubar)
|
||||
&& menubar->getGeometryGlobal().contains(ev->getGlobalPos()) )
|
||||
{
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
const FPoint& p = menubar->globalToLocalPos(g);
|
||||
int b = ev->getButton();
|
||||
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||
setClickedWidget(menubar);
|
||||
FMenuBar* sm = reinterpret_cast<FMenuBar*>(menubar);
|
||||
sm->onMouseMove(ev);
|
||||
delete ev;
|
||||
}
|
||||
|
||||
if ( focus_changed )
|
||||
redraw();
|
||||
}
|
||||
|
|
10
src/fmenu.h
10
src/fmenu.h
|
@ -31,6 +31,7 @@
|
|||
#define _FMENU_H
|
||||
|
||||
#include "fwindow.h"
|
||||
#include "fmenubar.h"
|
||||
#include "fmenulist.h"
|
||||
#include "fmenuitem.h"
|
||||
|
||||
|
@ -47,18 +48,19 @@ class FMenu : public FWindow, public FMenuList
|
|||
private:
|
||||
FMenuItem* item;
|
||||
FMenuItem* selectedListItem;
|
||||
FMenuList* super_menu;
|
||||
FWidget* super_menu;
|
||||
uInt maxItemWidth;
|
||||
bool mouse_down;
|
||||
|
||||
private:
|
||||
FMenu (const FMenu&);
|
||||
FMenu& operator = (const FMenu&);
|
||||
void init();
|
||||
void init(FWidget*);
|
||||
void menu_dimension();
|
||||
bool isMenuBar (FWidget*) const;
|
||||
FMenuList* superMenu() const;
|
||||
void setSuperMenu (FMenuList*);
|
||||
bool isMenu (FWidget*) const;
|
||||
FWidget* getSuperMenu() const;
|
||||
void setSuperMenu (FWidget*);
|
||||
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
|
||||
void draw();
|
||||
void drawBorder();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// File: fmenubar.cpp
|
||||
// Provides: class FMenuBar
|
||||
|
||||
#include "fapp.h"
|
||||
#include "fmenubar.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -12,6 +13,7 @@
|
|||
FMenuBar::FMenuBar(FWidget* parent)
|
||||
: FWindow(parent)
|
||||
, mouse_down(false)
|
||||
, selectedMenuItem()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -254,6 +256,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
|||
if ( ev->getButton() != LeftButton )
|
||||
{
|
||||
mouse_down = false;
|
||||
|
||||
if ( ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
|
@ -263,41 +266,50 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
|||
while ( iter != end )
|
||||
{
|
||||
(*iter)->unsetSelected();
|
||||
if ( selectedMenuItem == *iter )
|
||||
selectedMenuItem = 0;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mouse_down )
|
||||
return;
|
||||
|
||||
mouse_down = true;
|
||||
|
||||
if ( ! isActiveWindow() )
|
||||
setActiveWindow(this);
|
||||
|
||||
if ( ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
int mouse_x, mouse_y;
|
||||
bool focus_changed = false;
|
||||
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
//FMessageBox::info (this, "Info", FString().sprintf("local(%d,%d) global(%d,%d)", ev->getX(),ev->getY(),ev->getGlobalX(), ev->getGlobalY()));
|
||||
// #include "fmessagebox.h"
|
||||
while ( iter != end )
|
||||
{
|
||||
int x1, x2, mouse_x, mouse_y;
|
||||
int x1, x2;
|
||||
|
||||
x1 = (*iter)->getX();
|
||||
x2 = (*iter)->getX() + (*iter)->getWidth() - 1;
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x <= x2
|
||||
&& mouse_y == 1 )
|
||||
{
|
||||
if ( ! (*iter)->isSelected() )
|
||||
if ( (*iter)->isActivated() && ! (*iter)->isSelected() )
|
||||
{
|
||||
(*iter)->setSelected();
|
||||
selectedMenuItem = *iter;
|
||||
focus_changed = true;
|
||||
}
|
||||
if ( (*iter)->hasMenu() )
|
||||
|
@ -312,9 +324,13 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( mouse_y == 1 && (*iter)->isSelected() )
|
||||
if ( mouse_y == 1
|
||||
&& (*iter)->isActivated()
|
||||
&& (*iter)->isSelected() )
|
||||
{
|
||||
(*iter)->unsetSelected();
|
||||
if ( selectedMenuItem == *iter )
|
||||
selectedMenuItem = 0;
|
||||
focus_changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -337,22 +353,24 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
|
|||
if ( ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
|
||||
while ( iter != end )
|
||||
{
|
||||
int x1, x2, mouse_x, mouse_y;
|
||||
int x1, x2;
|
||||
|
||||
x1 = (*iter)->getX();
|
||||
x2 = (*iter)->getX() + (*iter)->getWidth() - 1;
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x <= x2
|
||||
&& mouse_y == 1
|
||||
&& (*iter)->isActivated()
|
||||
&& (*iter)->isSelected() )
|
||||
{
|
||||
if ( (*iter)->hasMenu() )
|
||||
|
@ -367,6 +385,8 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
|
|||
else
|
||||
{
|
||||
(*iter)->unsetSelected();
|
||||
if ( selectedMenuItem == *iter )
|
||||
selectedMenuItem = 0;
|
||||
redraw();
|
||||
(*iter)->processClicked();
|
||||
}
|
||||
|
@ -383,30 +403,35 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
|||
if ( ev->getButton() != LeftButton )
|
||||
return;
|
||||
|
||||
if ( ! isActiveWindow() )
|
||||
setActiveWindow(this);
|
||||
|
||||
if ( mouse_down && ! itemlist.empty() )
|
||||
{
|
||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||
int mouse_x, mouse_y;
|
||||
bool focus_changed = false;
|
||||
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
|
||||
while ( iter != end )
|
||||
{
|
||||
int x1, x2, mouse_x, mouse_y;
|
||||
int x1, x2;
|
||||
|
||||
x1 = (*iter)->getX();
|
||||
x2 = (*iter)->getX() + (*iter)->getWidth() - 1;
|
||||
mouse_x = ev->getX();
|
||||
mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x >= x1
|
||||
&& mouse_x <= x2
|
||||
&& mouse_y == 1 )
|
||||
{
|
||||
if ( ! (*iter)->isSelected() )
|
||||
if ( (*iter)->isActivated() && ! (*iter)->isSelected() )
|
||||
{
|
||||
(*iter)->setSelected();
|
||||
(*iter)->setSelected();
|
||||
selectedMenuItem = *iter;
|
||||
focus_changed = true;
|
||||
}
|
||||
if ( (*iter)->hasMenu() )
|
||||
|
@ -421,11 +446,30 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( mouse_y == 1 && (*iter)->isSelected() )
|
||||
if ( getGeometryGlobal().contains(ev->getGlobalPos())
|
||||
&& (*iter)->isActivated()
|
||||
&& (*iter)->isSelected() )
|
||||
{
|
||||
(*iter)->unsetSelected();
|
||||
if ( selectedMenuItem == *iter )
|
||||
selectedMenuItem = 0;
|
||||
focus_changed = true;
|
||||
}
|
||||
else if ( hasSelectedMenuItem() && selectedMenuItem->hasMenu() )
|
||||
{
|
||||
FMenu* menu = selectedMenuItem->getMenu();
|
||||
const FRect& menu_geometry = menu->getGeometryGlobal();
|
||||
|
||||
if ( menu_geometry.contains(ev->getGlobalPos()) )
|
||||
{
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
const FPoint& p = menu->globalToLocalPos(g);
|
||||
int b = ev->getButton();
|
||||
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||
setClickedWidget(menu);
|
||||
menu->onMouseDown(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
|
@ -473,7 +517,6 @@ void FMenuBar::cb_item_activated (FWidget* widget, void*)
|
|||
|
||||
if ( menuitem->hasMenu() )
|
||||
{
|
||||
//beep();
|
||||
FMenu* menu = menuitem->getMenu();
|
||||
if ( ! menu->isVisible() )
|
||||
{
|
||||
|
@ -495,7 +538,6 @@ void FMenuBar::cb_item_deactivated (FWidget* widget, void*)
|
|||
|
||||
if ( menuitem->hasMenu() )
|
||||
{
|
||||
//beep();
|
||||
FMenu* menu = menuitem->getMenu();
|
||||
if ( menu->isVisible() )
|
||||
menu->hide();
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#ifndef _FMENUBAR_H
|
||||
#define _FMENUBAR_H
|
||||
|
||||
#include "fmenulist.h"
|
||||
#include "fmenu.h"
|
||||
#include "fmenulist.h"
|
||||
#include "fwindow.h"
|
||||
|
||||
|
||||
|
@ -46,6 +46,7 @@ class FMenuBar : public FWindow, public FMenuList
|
|||
{
|
||||
private:
|
||||
bool mouse_down;
|
||||
FMenuItem* selectedMenuItem;
|
||||
|
||||
private:
|
||||
FMenuBar (const FMenuBar&);
|
||||
|
@ -67,6 +68,7 @@ class FMenuBar : public FWindow, public FMenuList
|
|||
void onMouseUp (FMouseEvent*);
|
||||
void onMouseMove (FMouseEvent*);
|
||||
void hide();
|
||||
bool hasSelectedMenuItem() const;
|
||||
// make every setGeometry from FWidget available
|
||||
using FWidget::setGeometry;
|
||||
void setGeometry (int, int, int, int, bool = true);
|
||||
|
@ -84,4 +86,8 @@ class FMenuBar : public FWindow, public FMenuList
|
|||
inline const char* FMenuBar::getClassName() const
|
||||
{ return "FMenuBar"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenuBar::hasSelectedMenuItem() const
|
||||
{ return selectedMenuItem; }
|
||||
|
||||
#endif // _FMENUBAR_H
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "fmenu.h"
|
||||
#include "fmenubar.h"
|
||||
#include "fmenuitem.h"
|
||||
#include "fmenulist.h"
|
||||
#include "fmenuitem.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FMenuItem
|
||||
|
@ -96,12 +96,10 @@ void FMenuItem::init (FWidget* parent)
|
|||
|
||||
if ( parent )
|
||||
{
|
||||
setSuperMenu(parent);
|
||||
FMenuList* sm_list = dynamic_cast<FMenuList*>(parent);
|
||||
if ( sm_list )
|
||||
{
|
||||
setSuperMenu(sm_list);
|
||||
sm_list->insert(this);
|
||||
}
|
||||
|
||||
if ( isMenuBar(parent) ) // Parent is menubar
|
||||
{
|
||||
|
@ -114,12 +112,12 @@ void FMenuItem::init (FWidget* parent)
|
|||
this->addCallback
|
||||
(
|
||||
"activate",
|
||||
_METHOD_CALLBACK (superMenu(), &FMenuBar::cb_item_activated)
|
||||
_METHOD_CALLBACK (getSuperMenu(), &FMenuBar::cb_item_activated)
|
||||
);
|
||||
this->addCallback
|
||||
(
|
||||
"deactivate",
|
||||
_METHOD_CALLBACK (superMenu(), &FMenuBar::cb_item_deactivated)
|
||||
_METHOD_CALLBACK (getSuperMenu(), &FMenuBar::cb_item_deactivated)
|
||||
);
|
||||
}
|
||||
else if ( isMenu(parent) ) // Parent is menu
|
||||
|
@ -133,12 +131,12 @@ void FMenuItem::init (FWidget* parent)
|
|||
this->addCallback
|
||||
(
|
||||
"activate",
|
||||
_METHOD_CALLBACK (superMenu(), &FMenu::cb_menuitem_activated)
|
||||
_METHOD_CALLBACK (getSuperMenu(), &FMenu::cb_menuitem_activated)
|
||||
);
|
||||
this->addCallback
|
||||
(
|
||||
"deactivate",
|
||||
_METHOD_CALLBACK (superMenu(), &FMenu::cb_menuitem_deactivated)
|
||||
_METHOD_CALLBACK (getSuperMenu(), &FMenu::cb_menuitem_deactivated)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -169,17 +167,6 @@ uChar FMenuItem::getHotkey()
|
|||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuItem::isMenuBar (FMenuList* ml) const
|
||||
{
|
||||
FWidget* menubar_ptr = dynamic_cast<FWidget*>(ml);
|
||||
|
||||
if ( menubar_ptr )
|
||||
return isMenuBar(menubar_ptr);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuItem::isMenuBar (FWidget* w) const
|
||||
{
|
||||
|
@ -187,17 +174,6 @@ bool FMenuItem::isMenuBar (FWidget* w) const
|
|||
, const_cast<char*>("FMenuBar") ) == 0 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuItem::isMenu (FMenuList* ml) const
|
||||
{
|
||||
FWidget* super_menu_ptr = dynamic_cast<FWidget*>(ml);
|
||||
|
||||
if ( super_menu_ptr )
|
||||
return isMenu(super_menu_ptr);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuItem::isMenu (FWidget* w) const
|
||||
{
|
||||
|
@ -206,13 +182,13 @@ bool FMenuItem::isMenu (FWidget* w) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMenuList* FMenuItem::superMenu() const
|
||||
FWidget* FMenuItem::getSuperMenu() const
|
||||
{
|
||||
return super_menu;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::setSuperMenu (FMenuList* smenu)
|
||||
void FMenuItem::setSuperMenu (FWidget* smenu)
|
||||
{
|
||||
super_menu = smenu;
|
||||
}
|
||||
|
@ -242,7 +218,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
|||
if ( isSelected() )
|
||||
{
|
||||
unsetSelected();
|
||||
FWidget* w = reinterpret_cast<FWidget*>(superMenu());
|
||||
FWidget* w = reinterpret_cast<FWidget*>(getSuperMenu());
|
||||
if ( w && isMenuBar(w) )
|
||||
w->redraw();
|
||||
ev->accept();
|
||||
|
@ -252,91 +228,106 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
|||
//----------------------------------------------------------------------
|
||||
void FMenuItem::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
const FPoint& p1 = ev->getPos();
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
FPoint p2(p1);
|
||||
int b = ev->getButton();
|
||||
p2 = p1 + getPos() - FPoint(1,1);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
|
||||
if ( super_menu )
|
||||
{
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* sm = dynamic_cast<FMenu*>(super_menu);
|
||||
if ( sm )
|
||||
{
|
||||
const FPoint& p2 = sm->globalToLocalPos(g);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
sm->onMouseDown(ev);
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mb = dynamic_cast<FMenuBar*>(super_menu);
|
||||
if ( mb )
|
||||
{
|
||||
const FPoint& p2 = mb->globalToLocalPos(g);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
mb->onMouseDown(ev);
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
const FPoint& p1 = ev->getPos();
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
FPoint p2(p1);
|
||||
int b = ev->getButton();
|
||||
p2 = p1 + getPos() - FPoint(1,1);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
|
||||
if ( super_menu )
|
||||
{
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* sm = dynamic_cast<FMenu*>(super_menu);
|
||||
if ( sm )
|
||||
{
|
||||
const FPoint& p2 = sm->globalToLocalPos(g);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
sm->onMouseUp(ev);
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mb = dynamic_cast<FMenuBar*>(super_menu);
|
||||
if ( mb )
|
||||
{
|
||||
const FPoint& p2 = mb->globalToLocalPos(g);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
mb->onMouseUp(ev);
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
const FPoint& p1 = ev->getPos();
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
FPoint p2(p1);
|
||||
int b = ev->getButton();
|
||||
p2 = p1 + getPos() - FPoint(1,1);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
|
||||
if ( super_menu )
|
||||
{
|
||||
const FPoint& g = ev->getGlobalPos();
|
||||
int b = ev->getButton();
|
||||
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* sm = dynamic_cast<FMenu*>(super_menu);
|
||||
if ( sm )
|
||||
{
|
||||
const FPoint& p2 = sm->globalToLocalPos(g);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
sm->onMouseMove(ev);
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mb = dynamic_cast<FMenuBar*>(super_menu);
|
||||
if ( mb )
|
||||
{
|
||||
const FPoint& p2 = mb->globalToLocalPos(g);
|
||||
ev = new FMouseEvent (MouseMove_Event, p2, g, b);
|
||||
mb->onMouseMove(ev);
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete ev;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -52,19 +52,17 @@ class FMenuItem : public FWidget
|
|||
int hotkey;
|
||||
//int accel_key;
|
||||
FMenu* menu;
|
||||
FMenuList* super_menu;
|
||||
FWidget* super_menu;
|
||||
|
||||
private:
|
||||
FMenuItem (const FMenuItem&);
|
||||
FMenuItem& operator = (const FMenuItem&);
|
||||
void init (FWidget*);
|
||||
uChar getHotkey();
|
||||
bool isMenuBar (FMenuList*) const;
|
||||
bool isMenuBar (FWidget*) const;
|
||||
bool isMenu (FMenuList*) const;
|
||||
bool isMenu (FWidget*) const;
|
||||
FMenuList* superMenu() const;
|
||||
void setSuperMenu (FMenuList*);
|
||||
FWidget* getSuperMenu() const;
|
||||
void setSuperMenu (FWidget*);
|
||||
void processActivate();
|
||||
void processDeactivate();
|
||||
void processClicked();
|
||||
|
|
|
@ -94,6 +94,9 @@ void FStatusKey::onAccel (FAccelEvent* ev)
|
|||
setActive();
|
||||
statusbar()->redraw();
|
||||
ev->accept();
|
||||
// unset after get back from callback
|
||||
unsetActive();
|
||||
statusbar()->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,6 +443,8 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
|
|||
mouse_y = ev->getY();
|
||||
if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 )
|
||||
(*iter)->setActive();
|
||||
// unset after get back from callback
|
||||
(*iter)->unsetActive();
|
||||
redraw();
|
||||
}
|
||||
X = x2 + 2;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// Provides: class FWidget
|
||||
|
||||
#include "fapp.h"
|
||||
#include "fstatusbar.h"
|
||||
#include "fmenubar.h"
|
||||
#include "fstatusbar.h"
|
||||
#include "fwidget.h"
|
||||
#include "fwindow.h"
|
||||
|
||||
|
|
101
test/ui.cpp
101
test/ui.cpp
|
@ -1,4 +1,4 @@
|
|||
// ui.cpp
|
||||
// File: ui.cpp
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
@ -25,7 +25,7 @@ class ProgressDialog : public FDialog
|
|||
FProgressbar* progressBar;
|
||||
|
||||
public:
|
||||
explicit ProgressDialog (FWidget* parent=0); // constructor
|
||||
explicit ProgressDialog (FWidget* = 0); // constructor
|
||||
~ProgressDialog(); // destructor
|
||||
|
||||
void onShow (FShowEvent*);
|
||||
|
@ -167,7 +167,7 @@ class MyDialog : public FDialog
|
|||
MyDialog& operator = (const MyDialog&); // and operator '='
|
||||
|
||||
public:
|
||||
explicit MyDialog (FWidget* parent=0); // constructor
|
||||
explicit MyDialog (FWidget* = 0); // constructor
|
||||
~MyDialog(); // destructor
|
||||
void onClose (FCloseEvent*);
|
||||
void cb_noFunctionMsg (FWidget*, void*);
|
||||
|
@ -191,25 +191,77 @@ MyDialog::MyDialog (FWidget* parent)
|
|||
: FDialog(parent)
|
||||
, myList()
|
||||
{
|
||||
/* This Code is working in progress...
|
||||
|
||||
FMenuBar* menubar = new FMenuBar(this);
|
||||
FMenu* file = new FMenu("&File", menubar);
|
||||
FMenu* edit = new FMenu("&Edit", menubar);
|
||||
/* .--------------------------------------------. */
|
||||
/* v This Code is working in progress v * /
|
||||
|
||||
FMenuItem* open = new FMenuItem("&Open", file);
|
||||
FMenuItem* quit = new FMenuItem("&Quit", file);
|
||||
FMenuBar* Menubar = new FMenuBar(this);
|
||||
|
||||
FMenuItem* cut = new FMenuItem("Cu&t", edit);
|
||||
FMenuItem* copy = new FMenuItem("&Copy", edit);
|
||||
FMenuItem* paste = new FMenuItem("&Paste", edit);
|
||||
FMenu* File = new FMenu("&File", Menubar);
|
||||
FMenu* Edit = new FMenu("&Edit", Menubar);
|
||||
FMenu* View = new FMenu("&View", Menubar);
|
||||
FMenuItem* Options = new FMenuItem("&Options", Menubar);
|
||||
Options->unsetActive();
|
||||
FMenuItem* Help = new FMenuItem("&Help", Menubar);
|
||||
|
||||
quit->addCallback
|
||||
FMenuItem* Open = new FMenuItem("&Open...", File);
|
||||
FMenuItem* Quit = new FMenuItem("&Quit", File);
|
||||
|
||||
FMenuItem* Cut = new FMenuItem("Cu&t", Edit);
|
||||
FMenuItem* Copy = new FMenuItem("&Copy", Edit);
|
||||
FMenuItem* Paste = new FMenuItem("&Paste", Edit);
|
||||
|
||||
FMenuItem* Env = new FMenuItem("&Terminal info...", View);
|
||||
FMenuItem* Drive = new FMenuItem("&Drive symbols...", View);
|
||||
|
||||
Open->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_view)
|
||||
);
|
||||
Quit->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp)
|
||||
);
|
||||
*/
|
||||
Cut->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
||||
);
|
||||
Copy->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
||||
);
|
||||
Paste->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
||||
);
|
||||
Env->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_info)
|
||||
);
|
||||
Drive->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_info)
|
||||
);
|
||||
Options->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp)
|
||||
);
|
||||
Help->addCallback
|
||||
(
|
||||
"clicked",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_about)
|
||||
);
|
||||
|
||||
/ * ^ This Code is working in progress ^ */
|
||||
/* '--------------------------------------------' */
|
||||
|
||||
FButton* MyButton1 = new FButton(this);
|
||||
MyButton1->setGeometry(3, 3, 5, 1);
|
||||
MyButton1->setText(L"&SIN");
|
||||
|
@ -413,8 +465,7 @@ MyDialog::MyDialog (FWidget* parent)
|
|||
key_F3->addCallback
|
||||
(
|
||||
"activate",
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp),
|
||||
key_F3
|
||||
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -447,10 +498,9 @@ void MyDialog::cb_noFunctionMsg (FWidget* widget, void*)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_about (FWidget* widget, void*)
|
||||
void MyDialog::cb_about (FWidget*, void*)
|
||||
{
|
||||
const char ver[] = F_VERSION;
|
||||
FStatusKey* skey = static_cast<FStatusKey*>(widget);
|
||||
FString line(2, wchar_t(fc::BoxDrawingsHorizontal));
|
||||
|
||||
FMessageBox info ( "About"
|
||||
|
@ -460,7 +510,6 @@ void MyDialog::cb_about (FWidget* widget, void*)
|
|||
, FMessageBox::Ok, 0, 0, this );
|
||||
info.setCenterText();
|
||||
info.show();
|
||||
skey->unsetActive();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -571,15 +620,11 @@ void MyDialog::cb_activateButton (FWidget* widget, void* data_ptr)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_view (FWidget* widget, void*)
|
||||
void MyDialog::cb_view (FWidget*, void*)
|
||||
{
|
||||
FStatusKey* skey = static_cast<FStatusKey*>(widget);
|
||||
FString file = FFileDialog::fileOpenChooser (this);
|
||||
if ( file.isNull() )
|
||||
{
|
||||
skey->unsetActive();
|
||||
return;
|
||||
}
|
||||
|
||||
FDialog* view = new FDialog(this);
|
||||
view->setText ("viewer");
|
||||
|
@ -612,7 +657,6 @@ void MyDialog::cb_view (FWidget* widget, void*)
|
|||
if ( infile.is_open() )
|
||||
infile.close();
|
||||
view->show();
|
||||
skey->unsetActive();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -625,12 +669,9 @@ void MyDialog::cb_setInput (FWidget* widget, void* data_ptr)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_exitApp (FWidget*, void* data_ptr)
|
||||
void MyDialog::cb_exitApp (FWidget*, void*)
|
||||
{
|
||||
FStatusKey* skey = static_cast<FStatusKey*>(data_ptr);
|
||||
close();
|
||||
if ( skey )
|
||||
skey->unsetActive();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue