* 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:
@@ -384,6 +384,10 @@ AttributeWindow::MessageReceived(BMessage* message)
|
|||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,10 @@ ExtensionWindow::MessageReceived(BMessage* message)
|
|||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "FileTypeWindow.h"
|
#include "FileTypeWindow.h"
|
||||||
#include "IconView.h"
|
#include "IconView.h"
|
||||||
#include "PreferredAppMenu.h"
|
#include "PreferredAppMenu.h"
|
||||||
|
#include "TypeListWindow.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
|
|
||||||
const uint32 kMsgTypeEntered = 'type';
|
const uint32 kMsgTypeEntered = 'type';
|
||||||
const uint32 kMsgSelectType = 'sltp';
|
const uint32 kMsgSelectType = 'sltp';
|
||||||
|
const uint32 kMsgTypeSelected = 'tpsd';
|
||||||
const uint32 kMsgSameTypeAs = 'stpa';
|
const uint32 kMsgSameTypeAs = 'stpa';
|
||||||
const uint32 kMsgSameTypeAsOpened = 'stpO';
|
const uint32 kMsgSameTypeAsOpened = 'stpO';
|
||||||
|
|
||||||
@@ -366,6 +368,24 @@ FileTypeWindow::MessageReceived(BMessage* message)
|
|||||||
_AdoptType();
|
_AdoptType();
|
||||||
break;
|
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:
|
case kMsgSameTypeAs:
|
||||||
{
|
{
|
||||||
BMessage panel(kMsgOpenFilePanel);
|
BMessage panel(kMsgOpenFilePanel);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Preference FileTypes :
|
|||||||
AttributeWindow.cpp
|
AttributeWindow.cpp
|
||||||
ExtensionWindow.cpp
|
ExtensionWindow.cpp
|
||||||
FileTypeWindow.cpp
|
FileTypeWindow.cpp
|
||||||
|
TypeListWindow.cpp
|
||||||
IconView.cpp
|
IconView.cpp
|
||||||
PreferredAppMenu.cpp
|
PreferredAppMenu.cpp
|
||||||
StringView.cpp
|
StringView.cpp
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ NewFileTypeWindow::MessageReceived(BMessage* message)
|
|||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Axel Dörfler, [email protected]. 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, [email protected]. 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
|
||||||
Reference in New Issue
Block a user