Completed functionality - you should now be able to test pretty much everything
with respect to look/feel/flags. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15270 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
aecd5eefaf
commit
7ae647775e
@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
@ -20,31 +21,46 @@
|
||||
const uint32 kMsgUpdateLook = 'uplk';
|
||||
const uint32 kMsgUpdateFlags = 'upfl';
|
||||
|
||||
const uint32 kMsgAddWindow = 'adwn';
|
||||
const uint32 kMsgAddSubsetWindow = 'adsw';
|
||||
|
||||
|
||||
int32 gNormalWindowCount = 0;
|
||||
|
||||
|
||||
class Window : public BWindow {
|
||||
public:
|
||||
Window();
|
||||
Window(BRect frame, window_look look, window_feel feel);
|
||||
virtual ~Window();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
|
||||
private:
|
||||
BMessage* AddWindowMessage(window_look look, window_feel feel);
|
||||
const char* TitleForFeel(window_feel feel);
|
||||
void _UpdateFlagsMenuLabel();
|
||||
|
||||
BMenuField* fFlagsField;
|
||||
};
|
||||
|
||||
|
||||
Window::Window()
|
||||
: BWindow(BRect(100, 100, 400, 400), "Look&Feel-Test",
|
||||
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||
Window::Window(BRect frame, window_look look, window_feel feel)
|
||||
: BWindow(frame, NULL, look, feel,
|
||||
B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
BRect rect(Bounds());
|
||||
BView *view = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(view);
|
||||
|
||||
BString title = "Look&Feel - ";
|
||||
title += TitleForFeel(feel);
|
||||
SetTitle(title.String());
|
||||
|
||||
if (!IsModal() && !IsFloating())
|
||||
gNormalWindowCount++;
|
||||
|
||||
BPopUpMenu* menu = new BPopUpMenu("looks");
|
||||
const struct { const char* name; int32 look; } looks[] = {
|
||||
{"Titled", B_TITLED_WINDOW_LOOK}, {"Document", B_DOCUMENT_WINDOW_LOOK},
|
||||
@ -91,6 +107,61 @@ Window::Window()
|
||||
fFlagsField->ResizeToPreferred();
|
||||
fFlagsField->SetDivider(fFlagsField->StringWidth(fFlagsField->Label()) + 5.0f);
|
||||
view->AddChild(fFlagsField);
|
||||
|
||||
// normal
|
||||
|
||||
rect.OffsetBy(0, menuField->Bounds().Height() + 10);
|
||||
BButton* button = new BButton(rect, "normal", "Add Normal Window",
|
||||
AddWindowMessage(B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL));
|
||||
float width, height;
|
||||
button->GetPreferredSize(&width, &height);
|
||||
button->ResizeTo(rect.Width(), height);
|
||||
view->AddChild(button);
|
||||
|
||||
// modal
|
||||
|
||||
rect = button->Frame();
|
||||
rect.OffsetBy(0, rect.Height() + 5);
|
||||
button = new BButton(rect, "modal_subset", "Add Modal Subset",
|
||||
AddWindowMessage(B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL));
|
||||
view->AddChild(button);
|
||||
|
||||
rect.OffsetBy(0, rect.Height() + 5);
|
||||
button = new BButton(rect, "app_modal", "Add Application Modal",
|
||||
AddWindowMessage(B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL));
|
||||
view->AddChild(button);
|
||||
|
||||
rect.OffsetBy(0, rect.Height() + 5);
|
||||
button = new BButton(rect, "all_modal", "Add All Modal",
|
||||
AddWindowMessage(B_MODAL_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL));
|
||||
view->AddChild(button);
|
||||
|
||||
// floating
|
||||
|
||||
rect = button->Frame();
|
||||
rect.OffsetBy(0, rect.Height() + 5);
|
||||
button = new BButton(rect, "floating_subset", "Add Floating Subset",
|
||||
AddWindowMessage(B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL));
|
||||
view->AddChild(button);
|
||||
|
||||
rect.OffsetBy(0, rect.Height() + 5);
|
||||
button = new BButton(rect, "app_floating", "Add Application Floating",
|
||||
AddWindowMessage(B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL));
|
||||
view->AddChild(button);
|
||||
|
||||
rect.OffsetBy(0, rect.Height() + 5);
|
||||
button = new BButton(rect, "all_floating", "Add All Floating",
|
||||
AddWindowMessage(B_FLOATING_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL));
|
||||
view->AddChild(button);
|
||||
|
||||
// close
|
||||
|
||||
rect.OffsetBy(0, rect.Height() + 15);
|
||||
button = new BButton(rect, "close", "Close Window",
|
||||
new BMessage(B_QUIT_REQUESTED));
|
||||
button->ResizeToPreferred();
|
||||
button->MoveTo((rect.Width() - button->Bounds().Width()) / 2, rect.top);
|
||||
view->AddChild(button);
|
||||
}
|
||||
|
||||
|
||||
@ -136,6 +207,24 @@ Window::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgAddWindow:
|
||||
case kMsgAddSubsetWindow:
|
||||
{
|
||||
int32 look, feel;
|
||||
if (message->FindInt32("look", &look) != B_OK
|
||||
|| message->FindInt32("feel", &feel) != B_OK)
|
||||
break;
|
||||
|
||||
BWindow* window = new Window(Frame().OffsetByCopy(20, 20),
|
||||
(window_look)look, (window_feel)feel);
|
||||
|
||||
if (message->what == kMsgAddSubsetWindow)
|
||||
window->AddToSubset(this);
|
||||
|
||||
window->Show();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
@ -145,11 +234,58 @@ Window::MessageReceived(BMessage* message)
|
||||
bool
|
||||
Window::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
if (!IsModal() && !IsFloating())
|
||||
gNormalWindowCount--;
|
||||
|
||||
if (gNormalWindowCount < 2)
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BMessage*
|
||||
Window::AddWindowMessage(window_look look, window_feel feel)
|
||||
{
|
||||
BMessage* message = new BMessage(kMsgAddWindow);
|
||||
|
||||
if (feel == B_FLOATING_SUBSET_WINDOW_FEEL
|
||||
|| feel == B_MODAL_SUBSET_WINDOW_FEEL)
|
||||
message->what = kMsgAddSubsetWindow;
|
||||
|
||||
message->AddInt32("look", look);
|
||||
message->AddInt32("feel", feel);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
Window::TitleForFeel(window_feel feel)
|
||||
{
|
||||
switch (feel) {
|
||||
case B_NORMAL_WINDOW_FEEL:
|
||||
return "Normal";
|
||||
|
||||
case B_MODAL_SUBSET_WINDOW_FEEL:
|
||||
return "Modal Subset";
|
||||
case B_MODAL_APP_WINDOW_FEEL:
|
||||
return "Application Modal";
|
||||
case B_MODAL_ALL_WINDOW_FEEL:
|
||||
return "All Modal";
|
||||
|
||||
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
||||
return "Floating Subset";
|
||||
case B_FLOATING_APP_WINDOW_FEEL:
|
||||
return "Application Floating";
|
||||
case B_FLOATING_ALL_WINDOW_FEEL:
|
||||
return "All Floating";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Window::_UpdateFlagsMenuLabel()
|
||||
{
|
||||
@ -193,7 +329,8 @@ Application::Application()
|
||||
void
|
||||
Application::ReadyToRun()
|
||||
{
|
||||
Window *window = new Window();
|
||||
Window *window = new Window(BRect(100, 100, 400, 420),
|
||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL);
|
||||
window->Show();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user