scripting in BApplication is mostly fixed
BLooper had a be-handler named suite BWindow is now exposing Active scripting to BViews isn't working yet git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17797 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+110
-89
@@ -644,13 +644,7 @@ BWindow::EndViewTransaction()
|
||||
bool
|
||||
BWindow::IsFront() const
|
||||
{
|
||||
if (IsActive())
|
||||
return true;
|
||||
|
||||
if (IsModal())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return (IsActive() || IsModal());
|
||||
}
|
||||
|
||||
|
||||
@@ -669,111 +663,138 @@ BWindow::MessageReceived(BMessage *msg)
|
||||
|
||||
switch (msg->what) {
|
||||
case B_GET_PROPERTY:
|
||||
case B_SET_PROPERTY: {
|
||||
case B_SET_PROPERTY:
|
||||
case B_CREATE_PROPERTY:
|
||||
case B_DELETE_PROPERTY:
|
||||
case B_COUNT_PROPERTIES:
|
||||
case B_EXECUTE_PROPERTY:
|
||||
case B_GET_SUPPORTED_SUITES: {
|
||||
BMessage specifier;
|
||||
int32 what;
|
||||
const char *prop;
|
||||
int32 index;
|
||||
|
||||
if (msg->GetCurrentSpecifier(&index, &specifier, &what, &prop) != B_OK)
|
||||
break;
|
||||
|
||||
if (!strcmp(prop, "Feel")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32("result", (uint32)Feel());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newFeel;
|
||||
if (msg->FindInt32("data", (int32 *)&newFeel) == B_OK) {
|
||||
SetFeel((window_feel)newFeel);
|
||||
return BLooper::MessageReceived(msg);
|
||||
|
||||
BPropertyInfo propertyInfo(sWindowPropInfo);
|
||||
switch (propertyInfo.FindMatch(msg, index, &specifier, what, prop)) {
|
||||
case 0:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddBool("result", IsActive());
|
||||
handled = true;
|
||||
} else if (msg->what == B_SET_PROPERTY) {
|
||||
bool newActive;
|
||||
if (msg->FindBool("data", &newActive) == B_OK) {
|
||||
Activate(newActive);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Flags")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32("result", Flags());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newFlags;
|
||||
if (msg->FindInt32("data", (int32 *)&newFlags) == B_OK) {
|
||||
SetFlags(newFlags);
|
||||
break;
|
||||
case 1:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32("result", (uint32)Feel());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newFeel;
|
||||
if (msg->FindInt32("data", (int32 *)&newFeel) == B_OK) {
|
||||
SetFeel((window_feel)newFeel);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Frame")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddRect("result", Frame());
|
||||
handled = true;
|
||||
} else {
|
||||
BRect newFrame;
|
||||
if (msg->FindRect("data", &newFrame) == B_OK) {
|
||||
MoveTo(newFrame.LeftTop());
|
||||
ResizeTo(newFrame.Width(), newFrame.Height());
|
||||
break;
|
||||
case 2:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32("result", Flags());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newFlags;
|
||||
if (msg->FindInt32("data", (int32 *)&newFlags) == B_OK) {
|
||||
SetFlags(newFlags);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Hidden")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddBool("result", IsHidden());
|
||||
handled = true;
|
||||
} else {
|
||||
bool hide;
|
||||
if (msg->FindBool("data", &hide) == B_OK) {
|
||||
if (hide) {
|
||||
if (!IsHidden())
|
||||
Hide();
|
||||
} else if (IsHidden())
|
||||
Show();
|
||||
|
||||
break;
|
||||
case 3:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddRect("result", Frame());
|
||||
handled = true;
|
||||
} else {
|
||||
BRect newFrame;
|
||||
if (msg->FindRect("data", &newFrame) == B_OK) {
|
||||
MoveTo(newFrame.LeftTop());
|
||||
ResizeTo(newFrame.Width(), newFrame.Height());
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Look")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32("result", (uint32)Look());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newLook;
|
||||
if (msg->FindInt32("data", (int32 *)&newLook) == B_OK) {
|
||||
SetLook((window_look)newLook);
|
||||
break;
|
||||
case 4:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddBool("result", IsHidden());
|
||||
handled = true;
|
||||
} else {
|
||||
bool hide;
|
||||
if (msg->FindBool("data", &hide) == B_OK) {
|
||||
if (hide) {
|
||||
if (!IsHidden())
|
||||
Hide();
|
||||
} else if (IsHidden())
|
||||
Show();
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Title")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddString("result", Title());
|
||||
handled = true;
|
||||
} else {
|
||||
const char *newTitle = NULL;
|
||||
if (msg->FindString("data", &newTitle) == B_OK) {
|
||||
SetTitle(newTitle);
|
||||
break;
|
||||
case 5:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32("result", (uint32)Look());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newLook;
|
||||
if (msg->FindInt32("data", (int32 *)&newLook) == B_OK) {
|
||||
SetLook((window_look)newLook);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Workspaces")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32( "result", Workspaces());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newWorkspaces;
|
||||
if (msg->FindInt32("data", (int32 *)&newWorkspaces) == B_OK) {
|
||||
SetWorkspaces(newWorkspaces);
|
||||
break;
|
||||
case 6:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddString("result", Title());
|
||||
handled = true;
|
||||
} else {
|
||||
const char *newTitle = NULL;
|
||||
if (msg->FindString("data", &newTitle) == B_OK) {
|
||||
SetTitle(newTitle);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(prop, "Minimize")) {
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddBool("result", IsMinimized());
|
||||
handled = true;
|
||||
} else {
|
||||
bool minimize;
|
||||
if (msg->FindBool("data", &minimize) == B_OK) {
|
||||
Minimize(minimize);
|
||||
break;
|
||||
case 7:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddInt32( "result", Workspaces());
|
||||
handled = true;
|
||||
} else {
|
||||
uint32 newWorkspaces;
|
||||
if (msg->FindInt32("data", (int32 *)&newWorkspaces) == B_OK) {
|
||||
SetWorkspaces(newWorkspaces);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
if (msg->what == B_GET_PROPERTY) {
|
||||
replyMsg.AddBool("result", IsMinimized());
|
||||
handled = true;
|
||||
} else {
|
||||
bool minimize;
|
||||
if (msg->FindBool("data", &minimize) == B_OK) {
|
||||
Minimize(minimize);
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return BLooper::MessageReceived(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user