332_3_uppsrc.diff
uppsrc/CtrlLib/MenuBar.cpp 2012-10-04 11:43:09 +0400 | ||
---|---|---|
50 | 50 |
pullshift.y = -1; |
51 | 51 |
} |
52 | 52 |
|
53 |
class MenuBarEntity : public Moveable<MenuBarEntity> { |
|
54 |
private: |
|
55 |
MenuBar *menu; |
|
56 |
public: |
|
57 |
MenuBarEntity() : menu(NULL) { } |
|
58 |
~MenuBarEntity() { |
|
59 |
if(menu) { |
|
60 |
LLOG("MenuBarEntity: CloseMenu"); |
|
61 |
menu->CloseMenu(); |
|
62 |
} |
|
63 |
} |
|
64 |
void ClearMenu() { menu = NULL; } |
|
65 |
void SetMenu(MenuBar *bar) { menu = bar; } |
|
66 |
}; |
|
67 |
|
|
68 |
static One<MenuBarEntity> mbe; |
|
69 |
|
|
53 | 70 |
MenuBar::MenuBar() |
54 | 71 |
{ |
55 | 72 |
LLOG("MenuBar " << Name()); |
... | ... | |
556 | 573 |
|
557 | 574 |
void MenuBar::Execute(Ctrl *owner, Point p) |
558 | 575 |
{ |
559 |
static Vector<Ctrl *> ows; // Used to prevent another open local menu for single owner to be opened (repeated right-click) |
|
560 |
int level = ows.GetCount(); |
|
561 |
if(IsEmpty() || FindIndex(ows, owner) >= 0) |
|
576 |
if(IsEmpty()) |
|
562 | 577 |
return; |
563 |
ows.Add(owner);
|
|
578 |
mbe.Create().SetMenu(this);
|
|
564 | 579 |
PopUp(owner, p); |
565 | 580 |
EventLoop(this); |
566 |
CloseMenu(); |
|
567 |
ows.SetCount(level); |
|
568 | 581 |
} |
569 | 582 |
|
570 | 583 |
void MenuBar::Execute(Ctrl *owner, Callback1<Bar&> proc, Point p) |
... | ... | |
591 | 604 |
if(parentmenu) |
592 | 605 |
parentmenu->SetActiveSubmenu(NULL, NULL); |
593 | 606 |
LLOG("~MenuBar 1"); |
607 |
if(!mbe.IsEmpty()) |
|
608 |
mbe.Clear(); |
|
594 | 609 |
} |
595 | 610 |
|
596 | 611 |
END_UPP_NAMESPACE |