* Added a version box to the application types views.
* StringView didn't initialize fEnabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16417 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
#include <TextView.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
#include <VolumeRoster.h>
|
#include <VolumeRoster.h>
|
||||||
|
|
||||||
@@ -36,6 +37,31 @@ const uint32 kMsgTypeSelected = 'typs';
|
|||||||
const uint32 kMsgRemoveUninstalled = 'runs';
|
const uint32 kMsgRemoveUninstalled = 'runs';
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
variety_to_text(uint32 variety)
|
||||||
|
{
|
||||||
|
switch (variety) {
|
||||||
|
case B_DEVELOPMENT_VERSION:
|
||||||
|
return "Development";
|
||||||
|
case B_ALPHA_VERSION:
|
||||||
|
return "Alpha";
|
||||||
|
case B_BETA_VERSION:
|
||||||
|
return "Beta";
|
||||||
|
case B_GAMMA_VERSION:
|
||||||
|
return "Gamma";
|
||||||
|
case B_GOLDEN_MASTER_VERSION:
|
||||||
|
return "Golden Master";
|
||||||
|
case B_FINAL_VERSION:
|
||||||
|
return "Final";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
ApplicationTypesWindow::ApplicationTypesWindow(BRect frame)
|
ApplicationTypesWindow::ApplicationTypesWindow(BRect frame)
|
||||||
: BWindow(frame, "Application Types", B_TITLED_WINDOW,
|
: BWindow(frame, "Application Types", B_TITLED_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||||
@@ -66,10 +92,9 @@ ApplicationTypesWindow::ApplicationTypesWindow(BRect frame)
|
|||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
|
||||||
topView->AddChild(scrollView);
|
topView->AddChild(scrollView);
|
||||||
|
|
||||||
// "Description" group
|
// "Information" group
|
||||||
|
|
||||||
BFont font(be_bold_font);
|
BFont font(be_bold_font);
|
||||||
float labelWidth = font.StringWidth("Icon");
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
font.GetHeight(&fontHeight);
|
font.GetHeight(&fontHeight);
|
||||||
|
|
||||||
@@ -78,11 +103,11 @@ ApplicationTypesWindow::ApplicationTypesWindow(BRect frame)
|
|||||||
rect.right = topView->Bounds().Width() - 8.0f;
|
rect.right = topView->Bounds().Width() - 8.0f;
|
||||||
rect.bottom = rect.top + ceilf(fontHeight.ascent) + 24.0f;
|
rect.bottom = rect.top + ceilf(fontHeight.ascent) + 24.0f;
|
||||||
BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
|
BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
|
||||||
box->SetLabel("Description");
|
box->SetLabel("Information");
|
||||||
topView->AddChild(box);
|
topView->AddChild(box);
|
||||||
|
|
||||||
BRect innerRect = box->Bounds().InsetByCopy(8.0f, 6.0f);
|
BRect innerRect = box->Bounds().InsetByCopy(8.0f, 6.0f);
|
||||||
labelWidth = topView->StringWidth("Signature:") + 4.0f;
|
float labelWidth = topView->StringWidth("Description:") + 4.0f;
|
||||||
|
|
||||||
innerRect.right = box->Bounds().Width() - 8.0f;
|
innerRect.right = box->Bounds().Width() - 8.0f;
|
||||||
innerRect.top += ceilf(fontHeight.ascent);
|
innerRect.top += ceilf(fontHeight.ascent);
|
||||||
@@ -106,6 +131,39 @@ ApplicationTypesWindow::ApplicationTypesWindow(BRect frame)
|
|||||||
fPathView->SetDivider(labelWidth);
|
fPathView->SetDivider(labelWidth);
|
||||||
box->AddChild(fPathView);
|
box->AddChild(fPathView);
|
||||||
|
|
||||||
|
// "Version" group
|
||||||
|
|
||||||
|
rect.top = box->Frame().bottom + 8.0f;
|
||||||
|
rect.bottom = rect.top + ceilf(fontHeight.ascent)
|
||||||
|
+ fNameView->Bounds().Height() * 4.0f + 20.0f;
|
||||||
|
box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
|
||||||
|
box->SetLabel("Version");
|
||||||
|
topView->AddChild(box);
|
||||||
|
|
||||||
|
innerRect = fNameView->Frame();
|
||||||
|
fVersionView = new StringView(innerRect, "version", "Version:", NULL,
|
||||||
|
B_FOLLOW_LEFT_RIGHT);
|
||||||
|
fVersionView->SetDivider(labelWidth);
|
||||||
|
box->AddChild(fVersionView);
|
||||||
|
|
||||||
|
innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f);
|
||||||
|
innerRect.right = innerRect.left + labelWidth;
|
||||||
|
fDescriptionLabel = new StringView(innerRect, "description", "Description:", NULL);
|
||||||
|
fDescriptionLabel->SetDivider(labelWidth);
|
||||||
|
box->AddChild(fDescriptionLabel);
|
||||||
|
|
||||||
|
innerRect.left = innerRect.right + 3.0f;
|
||||||
|
innerRect.top += 2.0f;
|
||||||
|
innerRect.right = box->Bounds().Width() - 8.0f;
|
||||||
|
innerRect.bottom += fNameView->Bounds().Height() * 2.0f;
|
||||||
|
fDescriptionView = new BTextView(innerRect, "description",
|
||||||
|
innerRect.OffsetToCopy(B_ORIGIN), B_FOLLOW_LEFT_RIGHT,
|
||||||
|
B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
|
fDescriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
fDescriptionView->SetLowColor(fDescriptionView->ViewColor());
|
||||||
|
fDescriptionView->MakeEditable(false);
|
||||||
|
box->AddChild(fDescriptionView);
|
||||||
|
|
||||||
// Launch and Tracker buttons
|
// Launch and Tracker buttons
|
||||||
|
|
||||||
rect = box->Frame();
|
rect = box->Frame();
|
||||||
@@ -244,10 +302,11 @@ ApplicationTypesWindow::_SetType(BMimeType* type, int32 forceUpdate)
|
|||||||
|
|
||||||
// Set "Open In Tracker" message
|
// Set "Open In Tracker" message
|
||||||
BEntry entry(path.Path());
|
BEntry entry(path.Path());
|
||||||
if (entry.GetRef(&ref) == B_OK) {
|
entry_ref directoryRef;
|
||||||
|
if (entry.GetRef(&directoryRef) == B_OK) {
|
||||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||||
message = new BMessage(B_REFS_RECEIVED);
|
message = new BMessage(B_REFS_RECEIVED);
|
||||||
message->AddRef("refs", &ref);
|
message->AddRef("refs", &directoryRef);
|
||||||
|
|
||||||
fTrackerButton->SetMessage(message);
|
fTrackerButton->SetMessage(message);
|
||||||
fTrackerButton->SetTarget(tracker);
|
fTrackerButton->SetTarget(tracker);
|
||||||
@@ -256,21 +315,58 @@ ApplicationTypesWindow::_SetType(BMimeType* type, int32 forceUpdate)
|
|||||||
appFound = false;
|
appFound = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (forceUpdate == B_EVERYTHING_CHANGED) {
|
||||||
|
// update version information
|
||||||
|
|
||||||
|
BFile file(&ref, B_READ_ONLY);
|
||||||
|
if (file.InitCheck() == B_OK) {
|
||||||
|
BAppFileInfo appInfo(&file);
|
||||||
|
version_info versionInfo;
|
||||||
|
if (appInfo.InitCheck() == B_OK
|
||||||
|
&& appInfo.GetVersionInfo(&versionInfo, B_APP_VERSION_KIND) == B_OK) {
|
||||||
|
char version[256];
|
||||||
|
snprintf(version, sizeof(version), "%lu.%lu.%lu, %s/%lu",
|
||||||
|
versionInfo.major, versionInfo.middle, versionInfo.minor,
|
||||||
|
variety_to_text(versionInfo.variety), versionInfo.internal);
|
||||||
|
fVersionView->SetText(version);
|
||||||
|
fDescriptionView->SetText(versionInfo.long_info);
|
||||||
|
} else {
|
||||||
|
fVersionView->SetText(NULL);
|
||||||
|
fDescriptionView->SetText(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fNameView->SetText(NULL);
|
fNameView->SetText(NULL);
|
||||||
fNameView->SetText(NULL);
|
fNameView->SetText(NULL);
|
||||||
fPathView->SetText(NULL);
|
fPathView->SetText(NULL);
|
||||||
|
|
||||||
|
fVersionView->SetText(NULL);
|
||||||
|
fDescriptionView->SetText(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
fNameView->SetEnabled(enabled);
|
fNameView->SetEnabled(enabled);
|
||||||
fSignatureView->SetEnabled(enabled);
|
fSignatureView->SetEnabled(enabled);
|
||||||
fPathView->SetEnabled(enabled);
|
fPathView->SetEnabled(enabled);
|
||||||
|
|
||||||
|
fVersionView->SetEnabled(enabled);
|
||||||
|
fDescriptionLabel->SetEnabled(enabled);
|
||||||
|
|
||||||
fTrackerButton->SetEnabled(enabled && appFound);
|
fTrackerButton->SetEnabled(enabled && appFound);
|
||||||
fLaunchButton->SetEnabled(enabled && appFound);
|
fLaunchButton->SetEnabled(enabled && appFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ApplicationTypesWindow::FrameResized(float width, float height)
|
||||||
|
{
|
||||||
|
// This works around a flaw of BTextView
|
||||||
|
fDescriptionView->SetTextRect(fDescriptionView->Bounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ApplicationTypesWindow::MessageReceived(BMessage* message)
|
ApplicationTypesWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class BMenuField;
|
|||||||
class BMimeType;
|
class BMimeType;
|
||||||
class BOutlineListView;
|
class BOutlineListView;
|
||||||
class BStringView;
|
class BStringView;
|
||||||
|
class BTextView;
|
||||||
|
|
||||||
class MimeTypeListView;
|
class MimeTypeListView;
|
||||||
class StringView;
|
class StringView;
|
||||||
@@ -26,6 +27,7 @@ class ApplicationTypesWindow : public BWindow {
|
|||||||
ApplicationTypesWindow(BRect frame);
|
ApplicationTypesWindow(BRect frame);
|
||||||
virtual ~ApplicationTypesWindow();
|
virtual ~ApplicationTypesWindow();
|
||||||
|
|
||||||
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
@@ -44,6 +46,10 @@ class ApplicationTypesWindow : public BWindow {
|
|||||||
StringView* fSignatureView;
|
StringView* fSignatureView;
|
||||||
StringView* fPathView;
|
StringView* fPathView;
|
||||||
|
|
||||||
|
StringView* fVersionView;
|
||||||
|
StringView* fDescriptionLabel;
|
||||||
|
BTextView* fDescriptionView;
|
||||||
|
|
||||||
BButton* fTrackerButton;
|
BButton* fTrackerButton;
|
||||||
BButton* fLaunchButton;
|
BButton* fLaunchButton;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ StringView::StringView(BRect frame, const char* name, const char* label,
|
|||||||
fLabel(label),
|
fLabel(label),
|
||||||
fText(text),
|
fText(text),
|
||||||
fLabelAlignment(B_ALIGN_RIGHT),
|
fLabelAlignment(B_ALIGN_RIGHT),
|
||||||
fTextAlignment(B_ALIGN_LEFT)
|
fTextAlignment(B_ALIGN_LEFT),
|
||||||
|
fEnabled(true)
|
||||||
{
|
{
|
||||||
fDivider = StringWidth(label) + 4.0f;
|
fDivider = StringWidth(label) + 4.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user