mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Cosmetics
git-svn-id: svn://ultimatepp.org/upp/trunk@1718 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3146d40079
commit
84645fa442
1 changed files with 216 additions and 216 deletions
|
|
@ -1,216 +1,216 @@
|
||||||
#include "CtrlLib.h"
|
#include "CtrlLib.h"
|
||||||
|
|
||||||
namespace Upp {
|
namespace Upp {
|
||||||
|
|
||||||
CH_VALUE(TreeDropEdge, ChBorder(BlackBorder()));
|
CH_VALUE(TreeDropEdge, ChBorder(BlackBorder()));
|
||||||
|
|
||||||
CtrlFrame& TreeDropFrame()
|
CtrlFrame& TreeDropFrame()
|
||||||
{
|
{
|
||||||
static LookFrame m(TreeDropEdge);
|
static LookFrame m(TreeDropEdge);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
PopUpTree::PopUpTree() {
|
PopUpTree::PopUpTree() {
|
||||||
SetFrame(TreeDropFrame());
|
SetFrame(TreeDropFrame());
|
||||||
Accel();
|
Accel();
|
||||||
MouseMoveCursor();
|
MouseMoveCursor();
|
||||||
NoPopUpEx();
|
NoPopUpEx();
|
||||||
SetDropLines(16);
|
SetDropLines(16);
|
||||||
open = autosize = false;
|
open = autosize = false;
|
||||||
showpos = Null;
|
showpos = Null;
|
||||||
WhenOpen = WhenClose = THISBACK(OpenClose);
|
WhenOpen = WhenClose = THISBACK(OpenClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
PopUpTree::~PopUpTree() {}
|
PopUpTree::~PopUpTree() {}
|
||||||
|
|
||||||
void PopUpTree::CancelMode() {
|
void PopUpTree::CancelMode() {
|
||||||
if(open) {
|
if(open) {
|
||||||
DoClose();
|
DoClose();
|
||||||
WhenCancel();
|
WhenCancel();
|
||||||
}
|
}
|
||||||
TreeCtrl::CancelMode();
|
TreeCtrl::CancelMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::DoClose() {
|
void PopUpTree::DoClose() {
|
||||||
open = false;
|
open = false;
|
||||||
Ctrl::Close();
|
Ctrl::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::Deactivate() {
|
void PopUpTree::Deactivate() {
|
||||||
if(open) {
|
if(open) {
|
||||||
DoClose();
|
DoClose();
|
||||||
IgnoreMouseClick();
|
IgnoreMouseClick();
|
||||||
WhenCancel();
|
WhenCancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::Select() {
|
void PopUpTree::Select() {
|
||||||
if(IsCursor() && !GetData().IsVoid()) {
|
if(IsCursor() && !GetData().IsVoid()) {
|
||||||
DoClose();
|
DoClose();
|
||||||
WhenSelect();
|
WhenSelect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PopUpTree::Key(dword key, int n) {
|
bool PopUpTree::Key(dword key, int n) {
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
case K_ALT_DOWN:
|
case K_ALT_DOWN:
|
||||||
DoClose();
|
DoClose();
|
||||||
WhenSelect();
|
WhenSelect();
|
||||||
return true;
|
return true;
|
||||||
case K_ESCAPE:
|
case K_ESCAPE:
|
||||||
DoClose();
|
DoClose();
|
||||||
WhenCancel();
|
WhenCancel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return TreeCtrl::Key(key, n);
|
return TreeCtrl::Key(key, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::PopUp(Ctrl *owner, int x, int top, int bottom, int width) {
|
void PopUpTree::PopUp(Ctrl *owner, int x, int top, int bottom, int width) {
|
||||||
DoClose();
|
DoClose();
|
||||||
Rect area = Ctrl::GetWorkArea();
|
Rect area = Ctrl::GetWorkArea();
|
||||||
int mh = min(maxheight, area.bottom - bottom);
|
int mh = min(maxheight, area.bottom - bottom);
|
||||||
int h = AddFrameSize(width, maxheight).cy;
|
int h = AddFrameSize(width, maxheight).cy;
|
||||||
showpos.x = x;
|
showpos.x = x;
|
||||||
showpos.y = bottom;
|
showpos.y = bottom;
|
||||||
showwidth = width;
|
showwidth = width;
|
||||||
up = false;
|
up = false;
|
||||||
if(showpos.y + h > area.bottom) {
|
if(showpos.y + h > area.bottom) {
|
||||||
up = true;
|
up = true;
|
||||||
showpos.y = top;
|
showpos.y = top;
|
||||||
}
|
}
|
||||||
open = false;
|
open = false;
|
||||||
Ctrl popup;
|
Ctrl popup;
|
||||||
int ht = AddFrameSize(width, min(mh, autosize ? GetTreeSize().cy : INT_MAX)).cy;
|
int ht = AddFrameSize(width, min(mh, autosize ? GetTreeSize().cy : INT_MAX)).cy;
|
||||||
Rect rt = RectC(showpos.x, showpos.y - (up ? ht : 0), showwidth, ht);
|
Rect rt = RectC(showpos.x, showpos.y - (up ? ht : 0), showwidth, ht);
|
||||||
if(GUI_PopUpEffect()) {
|
if(GUI_PopUpEffect()) {
|
||||||
if(up) {
|
if(up) {
|
||||||
popup.SetRect(Rect(rt.left, rt.bottom - 1, rt.right, rt.bottom));
|
popup.SetRect(Rect(rt.left, rt.bottom - 1, rt.right, rt.bottom));
|
||||||
popup.Add(TopPos(0, rt.Height()).LeftPos(0, rt.Width()));
|
popup.Add(TopPos(0, rt.Height()).LeftPos(0, rt.Width()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
popup.SetRect(Rect(rt.left, rt.top, rt.right, rt.top + 1));
|
popup.SetRect(Rect(rt.left, rt.top, rt.right, rt.top + 1));
|
||||||
popup.Add(BottomPos(0, rt.Height()).LeftPos(0, rt.Width()));
|
popup.Add(BottomPos(0, rt.Height()).LeftPos(0, rt.Width()));
|
||||||
}
|
}
|
||||||
CenterCursor();
|
CenterCursor();
|
||||||
popup.PopUp(owner, true, true, GUI_DropShadows());
|
popup.PopUp(owner, true, true, GUI_DropShadows());
|
||||||
SetFocus();
|
SetFocus();
|
||||||
Ctrl::ProcessEvents();
|
Ctrl::ProcessEvents();
|
||||||
Animate(popup, rt, GUIEFFECT_SLIDE);
|
Animate(popup, rt, GUIEFFECT_SLIDE);
|
||||||
Ctrl::Remove();
|
Ctrl::Remove();
|
||||||
}
|
}
|
||||||
CenterCursor();
|
CenterCursor();
|
||||||
SetRect(rt);
|
SetRect(rt);
|
||||||
Ctrl::PopUp(owner, true, true, GUI_DropShadows());
|
Ctrl::PopUp(owner, true, true, GUI_DropShadows());
|
||||||
SetFocus();
|
SetFocus();
|
||||||
open = true;
|
open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::OpenClose(int)
|
void PopUpTree::OpenClose(int)
|
||||||
{
|
{
|
||||||
if(autosize) {
|
if(autosize) {
|
||||||
SyncTree();
|
SyncTree();
|
||||||
Rect area = Ctrl::GetWorkArea();
|
Rect area = Ctrl::GetWorkArea();
|
||||||
int mh = min(maxheight, area.bottom - showpos.y);
|
int mh = min(maxheight, area.bottom - showpos.y);
|
||||||
int ht = AddFrameSize(showwidth, min(mh, GetTreeSize().cy)).cy;
|
int ht = AddFrameSize(showwidth, min(mh, GetTreeSize().cy)).cy;
|
||||||
SetRect(RectC(showpos.x, showpos.y - (up ? ht : 0), showwidth, ht));
|
SetRect(RectC(showpos.x, showpos.y - (up ? ht : 0), showwidth, ht));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::PopUp(Ctrl *owner, int width)
|
void PopUpTree::PopUp(Ctrl *owner, int width)
|
||||||
{
|
{
|
||||||
Rect r = owner->GetScreenRect();
|
Rect r = owner->GetScreenRect();
|
||||||
r.right = r.left + width;
|
r.right = r.left + width;
|
||||||
PopUp(owner, r.left, r.top, r.bottom, width);
|
PopUp(owner, r.left, r.top, r.bottom, width);
|
||||||
if(IsNull(showpos))
|
if(IsNull(showpos))
|
||||||
showpos = r.TopLeft();
|
showpos = r.TopLeft();
|
||||||
OpenClose(0);
|
OpenClose(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopUpTree::PopUp(Ctrl *owner)
|
void PopUpTree::PopUp(Ctrl *owner)
|
||||||
{
|
{
|
||||||
Rect r = owner->GetScreenRect();
|
Rect r = owner->GetScreenRect();
|
||||||
PopUp(owner, r.left, r.top, r.bottom, r.Width());
|
PopUp(owner, r.left, r.top, r.bottom, r.Width());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropTree::Sync() {
|
void DropTree::Sync() {
|
||||||
Image icon;
|
Image icon;
|
||||||
if(tree.IsCursor())
|
if(tree.IsCursor())
|
||||||
icon = tree.GetNode(tree.GetCursor()).image;
|
icon = tree.GetNode(tree.GetCursor()).image;
|
||||||
icond.Set(valuedisplay ? *valuedisplay : tree.GetDisplay(tree.GetCursor()), icon);
|
icond.Set(valuedisplay ? *valuedisplay : tree.GetDisplay(tree.GetCursor()), icon);
|
||||||
MultiButton::SetDisplay(icond);
|
MultiButton::SetDisplay(icond);
|
||||||
Set(tree.GetValue());
|
Set(tree.GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DropTree::Key(dword k, int) {
|
bool DropTree::Key(dword k, int) {
|
||||||
if(IsReadOnly()) return false;
|
if(IsReadOnly()) return false;
|
||||||
if(k == K_ALT_DOWN) {
|
if(k == K_ALT_DOWN) {
|
||||||
Drop();
|
Drop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropTree::Drop() {
|
void DropTree::Drop() {
|
||||||
if(IsReadOnly()) return;
|
if(IsReadOnly()) return;
|
||||||
if(dropfocus)
|
if(dropfocus)
|
||||||
SetFocus();
|
SetFocus();
|
||||||
WhenDrop();
|
WhenDrop();
|
||||||
tree.PopUp(this, GetRect().GetWidth());
|
tree.PopUp(this, GetRect().GetWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropTree::Select() {
|
void DropTree::Select() {
|
||||||
if(dropfocus)
|
if(dropfocus)
|
||||||
SetFocus();
|
SetFocus();
|
||||||
Sync();
|
Sync();
|
||||||
UpdateAction();
|
UpdateAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropTree::Cancel() {
|
void DropTree::Cancel() {
|
||||||
if(dropfocus)
|
if(dropfocus)
|
||||||
SetFocus();
|
SetFocus();
|
||||||
Sync();
|
Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropTree::Clear() {
|
void DropTree::Clear() {
|
||||||
tree.Clear();
|
tree.Clear();
|
||||||
tree <<= Null;
|
tree <<= Null;
|
||||||
Sync();
|
Sync();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropTree::SetData(const Value& data)
|
void DropTree::SetData(const Value& data)
|
||||||
{
|
{
|
||||||
if(tree.Get() != data) {
|
if(tree.Get() != data) {
|
||||||
tree <<= data;
|
tree <<= data;
|
||||||
Update();
|
Update();
|
||||||
Sync();
|
Sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value DropTree::GetData() const
|
Value DropTree::GetData() const
|
||||||
{
|
{
|
||||||
return notnull && IsNull(tree.Get()) ? NotNullError() : tree.Get();
|
return notnull && IsNull(tree.Get()) ? NotNullError() : tree.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
DropTree& DropTree::ValueDisplay(const Display& d)
|
DropTree& DropTree::ValueDisplay(const Display& d)
|
||||||
{
|
{
|
||||||
valuedisplay = &d;
|
valuedisplay = &d;
|
||||||
Sync();
|
Sync();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
DropTree::DropTree()
|
DropTree::DropTree()
|
||||||
{
|
{
|
||||||
displayall = false;
|
displayall = false;
|
||||||
valuedisplay = NULL;
|
valuedisplay = NULL;
|
||||||
dropfocus = false;
|
dropfocus = false;
|
||||||
notnull = false;
|
notnull = false;
|
||||||
AddButton().Main().WhenPush = THISBACK(Drop);
|
AddButton().Main().WhenPush = THISBACK(Drop);
|
||||||
NoInitFocus();
|
NoInitFocus();
|
||||||
tree.WhenSelect = THISBACK(Select);
|
tree.WhenSelect = THISBACK(Select);
|
||||||
tree.WhenCancel = THISBACK(Cancel);
|
tree.WhenCancel = THISBACK(Cancel);
|
||||||
dropwidth = 0;
|
dropwidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue