* Added "Select..." functionality to the file type window, ie. you can now

choose the file type from a list, too.
* Several windows did not forward unknown messages to their parent, and thus
  scripting did not work properly for them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16623 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-03-07 12:09:13 +00:00
parent 678a32a0ae
commit 91d4f7a30a
7 changed files with 163 additions and 0 deletions
@@ -384,6 +384,10 @@ AttributeWindow::MessageReceived(BMessage* message)
PostMessage(B_QUIT_REQUESTED);
break;
}
default:
BWindow::MessageReceived(message);
break;
}
}
@@ -176,6 +176,10 @@ ExtensionWindow::MessageReceived(BMessage* message)
PostMessage(B_QUIT_REQUESTED);
break;
}
default:
BWindow::MessageReceived(message);
break;
}
}
@@ -8,6 +8,7 @@
#include "FileTypeWindow.h"
#include "IconView.h"
#include "PreferredAppMenu.h"
#include "TypeListWindow.h"
#include <Application.h>
#include <Bitmap.h>
@@ -26,6 +27,7 @@
const uint32 kMsgTypeEntered = 'type';
const uint32 kMsgSelectType = 'sltp';
const uint32 kMsgTypeSelected = 'tpsd';
const uint32 kMsgSameTypeAs = 'stpa';
const uint32 kMsgSameTypeAsOpened = 'stpO';
@@ -366,6 +368,24 @@ FileTypeWindow::MessageReceived(BMessage* message)
_AdoptType();
break;
case kMsgSelectType:
{
BWindow* window = new TypeListWindow(fCommonType.String(),
kMsgTypeSelected, this);
window->Show();
break;
}
case kMsgTypeSelected:
{
const char* type;
if (message->FindString("type", &type) == B_OK) {
fCommonType = type;
fTypeControl->SetText(type);
_AdoptType();
}
break;
}
case kMsgSameTypeAs:
{
BMessage panel(kMsgOpenFilePanel);
+1
View File
@@ -16,6 +16,7 @@ Preference FileTypes :
AttributeWindow.cpp
ExtensionWindow.cpp
FileTypeWindow.cpp
TypeListWindow.cpp
IconView.cpp
PreferredAppMenu.cpp
StringView.cpp
@@ -181,6 +181,10 @@ NewFileTypeWindow::MessageReceived(BMessage* message)
PostMessage(B_QUIT_REQUESTED);
break;
}
default:
BWindow::MessageReceived(message);
break;
}
}
@@ -0,0 +1,97 @@
/*
* Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "MimeTypeListView.h"
#include "TypeListWindow.h"
#include <Button.h>
#include <ScrollView.h>
#include <string.h>
const uint32 kMsgTypeSelected = 'tpsl';
const uint32 kMsgSelected = 'seld';
TypeListWindow::TypeListWindow(const char* currentType, uint32 what, BWindow* target)
: BWindow(BRect(100, 100, 360, 440), "Choose Type", B_MODAL_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
fTarget(target),
fWhat(what)
{
BRect rect = Bounds();
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
fSelectButton = new BButton(rect, "select", "Done",
new BMessage(kMsgSelected), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fSelectButton->ResizeToPreferred();
fSelectButton->MoveTo(topView->Bounds().right - 8.0f - fSelectButton->Bounds().Width(),
topView->Bounds().bottom - 8.0f - fSelectButton->Bounds().Height());
fSelectButton->SetEnabled(false);
topView->AddChild(fSelectButton);
fSelectButton->MakeDefault(true);
BButton* button = new BButton(fSelectButton->Frame(), "cancel", "Cancel",
new BMessage(B_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
button->ResizeToPreferred();
button->MoveBy(-button->Bounds().Width() - 8.0f, 0.0f);
topView->AddChild(button);
rect.bottom = button->Frame().top - 10.0f;
rect.top = 10.0f;
rect.left = 10.0f;
rect.right -= 10.0f + B_V_SCROLL_BAR_WIDTH;
fListView = new MimeTypeListView(rect, "typeview", NULL, true, false,
B_FOLLOW_ALL);
fListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
fListView->SetInvocationMessage(new BMessage(kMsgSelected));
BScrollView* scrollView = new BScrollView("scrollview", fListView,
B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
topView->AddChild(scrollView);
MoveTo(target->Frame().LeftTop() + BPoint(15.0f, 15.0f));
}
TypeListWindow::~TypeListWindow()
{
}
void
TypeListWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgTypeSelected:
fSelectButton->SetEnabled(fListView->CurrentSelection() >= 0);
break;
case kMsgSelected:
{
MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(fListView->ItemAt(
fListView->CurrentSelection()));
if (item != NULL) {
BMessage select(fWhat);
select.AddString("type", item->Type());
fTarget.SendMessage(&select);
}
// supposed to fall through
}
case B_CANCEL:
PostMessage(B_QUIT_REQUESTED);
break;
default:
BWindow::MessageReceived(message);
break;
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef TYPE_LIST_WINDOW_H
#define TYPE_LIST_WINDOW_H
#include <Messenger.h>
#include <Window.h>
class BButton;
class BMenu;
class BTextControl;
class MimeTypeListView;
class TypeListWindow : public BWindow {
public:
TypeListWindow(const char* currentType, uint32 what, BWindow* target);
virtual ~TypeListWindow();
virtual void MessageReceived(BMessage* message);
private:
BMessenger fTarget;
uint32 fWhat;
MimeTypeListView* fListView;
BButton* fSelectButton;
};
#endif // TYPE_LIST_WINDOW_H