Fixed setPos in FWidget
This commit is contained in:
parent
69e30eae49
commit
15379c61fe
|
@ -13,7 +13,6 @@ FMenu::FMenu(FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, item(0)
|
, item(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
, next_item_pos(1,1)
|
|
||||||
, maxItemWidth(0)
|
, maxItemWidth(0)
|
||||||
, current(0)
|
, current(0)
|
||||||
, mouse_down(false)
|
, mouse_down(false)
|
||||||
|
@ -26,7 +25,6 @@ FMenu::FMenu (FString& txt, FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, item(0)
|
, item(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
, next_item_pos(1,1)
|
|
||||||
, maxItemWidth(0)
|
, maxItemWidth(0)
|
||||||
, current(0)
|
, current(0)
|
||||||
, mouse_down(false)
|
, mouse_down(false)
|
||||||
|
@ -40,7 +38,6 @@ FMenu::FMenu (const std::string& txt, FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, item(0)
|
, item(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
, next_item_pos(1,1)
|
|
||||||
, maxItemWidth(0)
|
, maxItemWidth(0)
|
||||||
, current(0)
|
, current(0)
|
||||||
, mouse_down(false)
|
, mouse_down(false)
|
||||||
|
@ -54,7 +51,6 @@ FMenu::FMenu (const char* txt, FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, item(0)
|
, item(0)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
, next_item_pos(1,1)
|
|
||||||
, maxItemWidth(0)
|
, maxItemWidth(0)
|
||||||
, current(0)
|
, current(0)
|
||||||
, mouse_down(false)
|
, mouse_down(false)
|
||||||
|
@ -122,6 +118,7 @@ void FMenu::init()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::menu_dimension()
|
void FMenu::menu_dimension()
|
||||||
{
|
{
|
||||||
|
int item_X, item_Y;
|
||||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||||
iter = itemlist.begin();
|
iter = itemlist.begin();
|
||||||
end = itemlist.end();
|
end = itemlist.end();
|
||||||
|
@ -130,18 +127,29 @@ void FMenu::menu_dimension()
|
||||||
// find the max item width
|
// find the max item width
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
FString item_text = (*iter)->getText();
|
uInt item_width = (*iter)->getTextLength() + 2;
|
||||||
uInt len = item_text.getLength();
|
|
||||||
|
|
||||||
if ( item_text.includes(L'&') ) // item has a hotkey '&'
|
if ( item_width > maxItemWidth )
|
||||||
len--;
|
maxItemWidth = item_width;
|
||||||
|
|
||||||
if ( len > maxItemWidth )
|
|
||||||
maxItemWidth = len;
|
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
setGeometry (xpos, ypos, int(maxItemWidth + 4), int(count() + 2));
|
// set widget geometry
|
||||||
|
setGeometry (xpos, ypos, int(maxItemWidth + 2), int(count() + 2));
|
||||||
|
|
||||||
|
// set geometry of all items
|
||||||
|
iter = itemlist.begin();
|
||||||
|
item_X = 1;
|
||||||
|
item_Y = 1;
|
||||||
|
|
||||||
|
while ( iter != end )
|
||||||
|
{
|
||||||
|
(*iter)->setGeometry (item_X, item_Y, maxItemWidth, 1);
|
||||||
|
item_Y++;
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -350,7 +358,7 @@ void FMenu::drawItems()
|
||||||
|
|
||||||
if ( is_Selected )
|
if ( is_Selected )
|
||||||
{
|
{
|
||||||
for (uInt i=uInt(to_char); i <= maxItemWidth; i++)
|
for (uInt i=uInt(to_char); i < maxItemWidth-1; i++)
|
||||||
print (' ');
|
print (' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ class FMenu : public FWindow, public FMenuList
|
||||||
private:
|
private:
|
||||||
FMenuItem* item;
|
FMenuItem* item;
|
||||||
FMenuList* super_menu;
|
FMenuList* super_menu;
|
||||||
FPoint next_item_pos;
|
|
||||||
uInt maxItemWidth;
|
uInt maxItemWidth;
|
||||||
int current;
|
int current;
|
||||||
bool mouse_down;
|
bool mouse_down;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Provides: class FMenuBar
|
// Provides: class FMenuBar
|
||||||
|
|
||||||
#include "fmenubar.h"
|
#include "fmenubar.h"
|
||||||
|
#include "fmessagebox.h"
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// class FMenuBar
|
// class FMenuBar
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
FMenuBar::FMenuBar(FWidget* parent)
|
FMenuBar::FMenuBar(FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, mouse_down(false)
|
, mouse_down(false)
|
||||||
, next_item_pos(1,1)
|
|
||||||
, x(-1)
|
, x(-1)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -53,6 +52,34 @@ void FMenuBar::init()
|
||||||
unsetFocusable();
|
unsetFocusable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FMenuBar::menu_dimension()
|
||||||
|
{
|
||||||
|
int item_X = 1;
|
||||||
|
int item_Y = 1;
|
||||||
|
std::vector<FMenuItem*>::const_iterator begin, end, iter;
|
||||||
|
iter = itemlist.begin();
|
||||||
|
end = itemlist.end();
|
||||||
|
|
||||||
|
// find the max item width
|
||||||
|
while ( iter != end )
|
||||||
|
{
|
||||||
|
uInt len = (*iter)->getTextLength();
|
||||||
|
int item_width = int(len + 2);
|
||||||
|
|
||||||
|
// set item geometry
|
||||||
|
(*iter)->setGeometry (item_X, item_Y, item_width, 1, false);
|
||||||
|
|
||||||
|
// set menu position
|
||||||
|
if ( (*iter)->hasMenu() )
|
||||||
|
(*iter)->getMenu()->setPos (item_X, item_Y, false);
|
||||||
|
|
||||||
|
item_X += item_width;
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenuBar::isMenu (FMenuItem* mi) const
|
bool FMenuBar::isMenu (FMenuItem* mi) const
|
||||||
{
|
{
|
||||||
|
@ -86,6 +113,9 @@ void FMenuBar::draw()
|
||||||
xmin = ymin = 1;
|
xmin = ymin = 1;
|
||||||
height = 1;
|
height = 1;
|
||||||
xpos = 1;
|
xpos = 1;
|
||||||
|
|
||||||
|
menu_dimension();
|
||||||
|
|
||||||
drawItems();
|
drawItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +151,7 @@ void FMenuBar::drawItems()
|
||||||
uInt txt_length;
|
uInt txt_length;
|
||||||
int hotkeypos, to_char;
|
int hotkeypos, to_char;
|
||||||
|
|
||||||
|
|
||||||
is_Active = (*iter)->isActivated();
|
is_Active = (*iter)->isActivated();
|
||||||
is_Selected = (*iter)->isSelected();
|
is_Selected = (*iter)->isSelected();
|
||||||
is_NoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0);
|
is_NoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0);
|
||||||
|
@ -255,18 +286,17 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
||||||
|
|
||||||
iter = itemlist.begin();
|
iter = itemlist.begin();
|
||||||
end = itemlist.end();
|
end = itemlist.end();
|
||||||
|
//FMessageBox::info (this, "Info", FString().sprintf("local(%d,%d) global(%d,%d)", ev->getX(),ev->getY(),ev->getGlobalX(), ev->getGlobalY())); // + #include
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1, x2, mouse_x, mouse_y, txt_length;
|
int x1, x2, mouse_x, mouse_y, txt_length;
|
||||||
|
|
||||||
x1 = X;
|
x1 = X;
|
||||||
txt_length = int((*iter)->getText().getLength());
|
txt_length = int((*iter)->getTextLength());
|
||||||
if ( (*iter)->hasHotkey() )
|
|
||||||
txt_length--;
|
x2 = x1 + txt_length + 1;
|
||||||
x2 = x1 + txt_length;
|
mouse_x = ev->getGlobalX();
|
||||||
mouse_x = ev->getX();
|
mouse_y = ev->getGlobalY();
|
||||||
mouse_y = ev->getY();
|
|
||||||
|
|
||||||
if ( mouse_x >= x1
|
if ( mouse_x >= x1
|
||||||
&& mouse_x <= x2
|
&& mouse_x <= x2
|
||||||
|
@ -306,16 +336,16 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
|
||||||
|
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1 = X;
|
int x1, x2, txt_length;
|
||||||
int txt_length = int((*iter)->getText().getLength());
|
|
||||||
if ( (*iter)->hasHotkey() )
|
x1 = X;
|
||||||
txt_length--;
|
txt_length = int((*iter)->getTextLength());
|
||||||
int x2 = x1 + txt_length;
|
x2 = x1 + txt_length + 1;
|
||||||
|
|
||||||
if ( (*iter)->isSelected() )
|
if ( (*iter)->isSelected() )
|
||||||
{
|
{
|
||||||
int mouse_x = ev->getX();
|
int mouse_x = ev->getGlobalX();
|
||||||
int mouse_y = ev->getY();
|
int mouse_y = ev->getGlobalY();
|
||||||
if ( mouse_x < x1 || mouse_x > x2 || mouse_y != 1 )
|
if ( mouse_x < x1 || mouse_x > x2 || mouse_y != 1 )
|
||||||
(*iter)->unsetSelected();
|
(*iter)->unsetSelected();
|
||||||
else
|
else
|
||||||
|
@ -348,14 +378,14 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||||
|
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1 = X;
|
int x1, x2, txt_length;
|
||||||
int txt_length = int((*iter)->getText().getLength());
|
|
||||||
if ( (*iter)->hasHotkey() )
|
|
||||||
txt_length--;
|
|
||||||
int x2 = x1 + txt_length;
|
|
||||||
|
|
||||||
int mouse_x = ev->getX();
|
x1 = X;
|
||||||
int mouse_y = ev->getY();
|
txt_length = int((*iter)->getTextLength());
|
||||||
|
x2 = x1 + txt_length + 1;
|
||||||
|
|
||||||
|
int mouse_x = ev->getGlobalX();
|
||||||
|
int mouse_y = ev->getGlobalY();
|
||||||
if ( mouse_x >= x1
|
if ( mouse_x >= x1
|
||||||
&& mouse_x <= x2
|
&& mouse_x <= x2
|
||||||
&& mouse_y == 1 )
|
&& mouse_y == 1 )
|
||||||
|
|
|
@ -30,8 +30,9 @@
|
||||||
#ifndef _FMENUBAR_H
|
#ifndef _FMENUBAR_H
|
||||||
#define _FMENUBAR_H
|
#define _FMENUBAR_H
|
||||||
|
|
||||||
#include "fwindow.h"
|
|
||||||
#include "fmenulist.h"
|
#include "fmenulist.h"
|
||||||
|
#include "fmenu.h"
|
||||||
|
#include "fwindow.h"
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -45,13 +46,13 @@ class FMenuBar : public FWindow, public FMenuList
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool mouse_down;
|
bool mouse_down;
|
||||||
FPoint next_item_pos;
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FMenuBar (const FMenuBar&);
|
FMenuBar (const FMenuBar&);
|
||||||
FMenuBar& operator = (const FMenuBar&);
|
FMenuBar& operator = (const FMenuBar&);
|
||||||
void init();
|
void init();
|
||||||
|
void menu_dimension();
|
||||||
bool isMenu (FMenuItem*) const;
|
bool isMenu (FMenuItem*) const;
|
||||||
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
|
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
|
||||||
void draw();
|
void draw();
|
||||||
|
@ -71,6 +72,9 @@ class FMenuBar : public FWindow, public FMenuList
|
||||||
using FWidget::setGeometry;
|
using FWidget::setGeometry;
|
||||||
void setGeometry (int, int, int, int, bool = true);
|
void setGeometry (int, int, int, int, bool = true);
|
||||||
void cb_item_activated (FWidget*, void*);
|
void cb_item_activated (FWidget*, void*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class FMenuItem;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ void FMenuItem::init (FWidget* parent)
|
||||||
hotkey = getHotkey();
|
hotkey = getHotkey();
|
||||||
if ( hotkey )
|
if ( hotkey )
|
||||||
text_length--;
|
text_length--;
|
||||||
setGeometry (1,1,text_length+2,1);
|
setGeometry (1,1,text_length+2,1, false);
|
||||||
|
|
||||||
if ( parent )
|
if ( parent )
|
||||||
{
|
{
|
||||||
|
@ -100,19 +100,21 @@ void FMenuItem::init (FWidget* parent)
|
||||||
{
|
{
|
||||||
setSuperMenu( dynamic_cast<FMenuList*>(parent) );
|
setSuperMenu( dynamic_cast<FMenuList*>(parent) );
|
||||||
superMenu()->insert(this);
|
superMenu()->insert(this);
|
||||||
|
dynamic_cast<FMenuBar*>(parent)->menu_dimension();
|
||||||
|
|
||||||
//addAccelerator (item->getKey(), item);
|
//addAccelerator (item->getKey(), item);
|
||||||
|
|
||||||
this->addCallback
|
this->addCallback
|
||||||
(
|
(
|
||||||
"activate",
|
"activate",
|
||||||
_METHOD_CALLBACK (superMenu(), &FMenu::cb_menuitem_activated)
|
_METHOD_CALLBACK (superMenu(), &FMenuBar::cb_item_activated)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( isMenu(parent) ) // Parent is menu
|
else if ( isMenu(parent) ) // Parent is menu
|
||||||
{
|
{
|
||||||
setSuperMenu( dynamic_cast<FMenuList*>(parent) );
|
setSuperMenu( dynamic_cast<FMenuList*>(parent) );
|
||||||
superMenu()->insert(this);
|
superMenu()->insert(this);
|
||||||
|
|
||||||
|
|
||||||
//addAccelerator (item->getKey(), item);
|
//addAccelerator (item->getKey(), item);
|
||||||
|
|
||||||
|
@ -141,6 +143,12 @@ uChar FMenuItem::getHotkey()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FMenuItem::isMenuBar (FMenuList* ml) const
|
||||||
|
{
|
||||||
|
return isMenuBar (dynamic_cast<FWidget*>(ml));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenuItem::isMenuBar (FWidget* w) const
|
bool FMenuItem::isMenuBar (FWidget* w) const
|
||||||
{
|
{
|
||||||
|
@ -148,6 +156,12 @@ bool FMenuItem::isMenuBar (FWidget* w) const
|
||||||
, const_cast<char*>("FMenuBar") ) == 0 );
|
, const_cast<char*>("FMenuBar") ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FMenuItem::isMenu (FMenuList* ml) const
|
||||||
|
{
|
||||||
|
return isMenu (dynamic_cast<FWidget*>(ml));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenuItem::isMenu (FWidget* w) const
|
bool FMenuItem::isMenu (FWidget* w) const
|
||||||
{
|
{
|
||||||
|
@ -193,6 +207,63 @@ 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 ( isMenu(super_menu) )
|
||||||
|
dynamic_cast<FMenu*>(super_menu)->onMouseDown(ev);
|
||||||
|
|
||||||
|
if ( isMenuBar(super_menu) )
|
||||||
|
dynamic_cast<FMenuBar*>(super_menu)->onMouseDown(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 ( isMenu(super_menu) )
|
||||||
|
dynamic_cast<FMenu*>(super_menu)->onMouseUp(ev);
|
||||||
|
|
||||||
|
if ( isMenuBar(super_menu) )
|
||||||
|
dynamic_cast<FMenuBar*>(super_menu)->onMouseUp(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 ( isMenu(super_menu) )
|
||||||
|
dynamic_cast<FMenu*>(super_menu)->onMouseMove(ev);
|
||||||
|
|
||||||
|
if ( isMenuBar(super_menu) )
|
||||||
|
dynamic_cast<FMenuBar*>(super_menu)->onMouseMove(ev);
|
||||||
|
|
||||||
|
delete ev;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenuItem::setSelected()
|
void FMenuItem::setSelected()
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,7 +59,9 @@ class FMenuItem : public FWidget
|
||||||
FMenuItem& operator = (const FMenuItem&);
|
FMenuItem& operator = (const FMenuItem&);
|
||||||
void init (FWidget*);
|
void init (FWidget*);
|
||||||
uChar getHotkey();
|
uChar getHotkey();
|
||||||
|
bool isMenuBar (FMenuList*) const;
|
||||||
bool isMenuBar (FWidget*) const;
|
bool isMenuBar (FWidget*) const;
|
||||||
|
bool isMenu (FMenuList*) const;
|
||||||
bool isMenu (FWidget*) const;
|
bool isMenu (FWidget*) const;
|
||||||
FMenuList* superMenu() const;
|
FMenuList* superMenu() const;
|
||||||
void setSuperMenu (FMenuList*);
|
void setSuperMenu (FMenuList*);
|
||||||
|
@ -74,6 +76,9 @@ class FMenuItem : public FWidget
|
||||||
virtual ~FMenuItem();
|
virtual ~FMenuItem();
|
||||||
|
|
||||||
void onAccel (FAccelEvent*);
|
void onAccel (FAccelEvent*);
|
||||||
|
void onMouseDown (FMouseEvent*);
|
||||||
|
void onMouseUp (FMouseEvent*);
|
||||||
|
void onMouseMove (FMouseEvent*);
|
||||||
FString getText() const;
|
FString getText() const;
|
||||||
void setActive();
|
void setActive();
|
||||||
void unsetActive();
|
void unsetActive();
|
||||||
|
@ -88,8 +93,10 @@ class FMenuItem : public FWidget
|
||||||
void unsetChecked();
|
void unsetChecked();
|
||||||
bool isChecked() const;
|
bool isChecked() const;
|
||||||
bool hasHotkey() const;
|
bool hasHotkey() const;
|
||||||
|
FMenu* getMenu() const;
|
||||||
void setMenu(FMenu*);
|
void setMenu(FMenu*);
|
||||||
bool hasMenu() const;
|
bool hasMenu() const;
|
||||||
|
uInt getTextLength() const;
|
||||||
void setText (FString&);
|
void setText (FString&);
|
||||||
void setText (const std::string&);
|
void setText (const std::string&);
|
||||||
void setText (const char*);
|
void setText (const char*);
|
||||||
|
@ -154,6 +161,10 @@ inline bool FMenuItem::isChecked() const
|
||||||
inline bool FMenuItem::hasHotkey() const
|
inline bool FMenuItem::hasHotkey() const
|
||||||
{ return bool(hotkey != 0); }
|
{ return bool(hotkey != 0); }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline FMenu* FMenuItem::getMenu() const
|
||||||
|
{ return menu; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenuItem::setMenu(FMenu* m)
|
inline void FMenuItem::setMenu(FMenu* m)
|
||||||
{ menu = m; }
|
{ menu = m; }
|
||||||
|
@ -162,5 +173,8 @@ inline void FMenuItem::setMenu(FMenu* m)
|
||||||
inline bool FMenuItem::hasMenu() const
|
inline bool FMenuItem::hasMenu() const
|
||||||
{ return bool(menu != 0); }
|
{ return bool(menu != 0); }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline uInt FMenuItem::getTextLength() const
|
||||||
|
{ return text_length; }
|
||||||
|
|
||||||
#endif // _FMENUITEM_H
|
#endif // _FMENUITEM_H
|
||||||
|
|
|
@ -16,12 +16,6 @@
|
||||||
#include "fwidget.h"
|
#include "fwidget.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- FMenuBar muß die x + y Positionen des nächsten
|
|
||||||
einzufügenden FMenuItem kennen
|
|
||||||
|
|
||||||
- FMenu muß die x + y Positionen des nächsten
|
|
||||||
einzufügenden FMenuItem kennen
|
|
||||||
|
|
||||||
┌─────────┐ ┌──────────┐
|
┌─────────┐ ┌──────────┐
|
||||||
│ FWindow │◄───┐ ┌───┤ FMenuBar │
|
│ FWindow │◄───┐ ┌───┤ FMenuBar │
|
||||||
└─────────┘ │ │ └──────────┘
|
└─────────┘ │ │ └──────────┘
|
||||||
|
|
|
@ -425,16 +425,19 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
|
||||||
|
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1 = X;
|
int x1, x2, kname_len, txt_length;
|
||||||
int kname_len = int(getKeyName((*iter)->getKey()).getLength());
|
|
||||||
int txt_length = int((*iter)->getText().getLength());
|
x1 = X;
|
||||||
int x2 = x1 + kname_len + txt_length + 1;
|
kname_len = int(getKeyName((*iter)->getKey()).getLength());
|
||||||
|
txt_length = int((*iter)->getText().getLength());
|
||||||
|
x2 = x1 + kname_len + txt_length + 1;
|
||||||
|
|
||||||
if ( (*iter)->hasMouseFocus() )
|
if ( (*iter)->hasMouseFocus() )
|
||||||
{
|
{
|
||||||
|
int mouse_x, mouse_y;
|
||||||
(*iter)->unsetMouseFocus();
|
(*iter)->unsetMouseFocus();
|
||||||
int mouse_x = ev->getX();
|
mouse_x = ev->getX();
|
||||||
int mouse_y = ev->getY();
|
mouse_y = ev->getY();
|
||||||
if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 )
|
if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 )
|
||||||
(*iter)->setActive();
|
(*iter)->setActive();
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -465,13 +468,15 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
|
||||||
|
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1 = X;
|
int x1, x2, mouse_x, mouse_y, kname_len, txt_length;
|
||||||
int kname_len = int(getKeyName((*iter)->getKey()).getLength());
|
|
||||||
int txt_length = int((*iter)->getText().getLength());
|
|
||||||
int x2 = x1 + kname_len + txt_length + 1;
|
|
||||||
|
|
||||||
int mouse_x = ev->getX();
|
x1 = X;
|
||||||
int mouse_y = ev->getY();
|
kname_len = int(getKeyName((*iter)->getKey()).getLength());
|
||||||
|
txt_length = int((*iter)->getText().getLength());
|
||||||
|
x2 = x1 + kname_len + txt_length + 1;
|
||||||
|
|
||||||
|
mouse_x = ev->getX();
|
||||||
|
mouse_y = ev->getY();
|
||||||
if ( mouse_x >= x1
|
if ( mouse_x >= x1
|
||||||
&& mouse_x <= x2
|
&& mouse_x <= x2
|
||||||
&& mouse_y == 1 )
|
&& mouse_y == 1 )
|
||||||
|
|
|
@ -1492,10 +1492,11 @@ void FWidget::setPos (const FPoint& p, bool adjust)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::setPos (int x, int y, bool adjust)
|
void FWidget::setPos (int x, int y, bool adjust)
|
||||||
{
|
{
|
||||||
if ( xpos == x && widgetSize.getX() == x )
|
if ( xpos == x && widgetSize.getX() == x
|
||||||
return;
|
&& ypos == y && widgetSize.getY() == y )
|
||||||
if ( ypos == y && widgetSize.getY() == y )
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isWindow() )
|
if ( ! isWindow() )
|
||||||
{
|
{
|
||||||
|
@ -1675,8 +1676,9 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
|
||||||
adjustWidgetSize.setRect(xpos, ypos, width, height);
|
adjustWidgetSize.setRect(xpos, ypos, width, height);
|
||||||
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
||||||
adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1
|
adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1
|
||||||
, ypos + ymin - 1,
|
, ypos + ymin - 1
|
||||||
width, height );
|
, width
|
||||||
|
, height );
|
||||||
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
||||||
|
|
||||||
if ( adjust )
|
if ( adjust )
|
||||||
|
|
Loading…
Reference in New Issue