Changed GUI of configuration window a little (bitmaps will be designed by CDT).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1843 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -36,7 +36,10 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
#include <Resources.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
@@ -108,3 +111,42 @@ bool AddFields(BMessage* to, const BMessage* from) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BBitmap* LoadBitmap(const char* name, uint32 type_code = B_TRANSLATOR_BITMAP) {
|
||||||
|
if (type_code == B_TRANSLATOR_BITMAP) {
|
||||||
|
return BTranslationUtils::GetBitmap(type_code, name);
|
||||||
|
} else {
|
||||||
|
BResources *res = BApplication::AppResources();
|
||||||
|
if (res != NULL) {
|
||||||
|
BMessage m;
|
||||||
|
size_t length;
|
||||||
|
const void *bits = res->LoadResource(type_code, name, &length);
|
||||||
|
if (bits && m.Unflatten((char*)bits) == B_OK) {
|
||||||
|
return (BBitmap*)BBitmap::Instantiate(&m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BPicture *BitmapToPicture(BView* view, BBitmap *bitmap) {
|
||||||
|
if (bitmap) {
|
||||||
|
view->BeginPicture(new BPicture());
|
||||||
|
view->DrawBitmap(bitmap);
|
||||||
|
return view->EndPicture();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BPicture *BitmapToGrayedPicture(BView* view, BBitmap *bitmap) {
|
||||||
|
if (bitmap) {
|
||||||
|
BRect rect(bitmap->Bounds());
|
||||||
|
view->BeginPicture(new BPicture());
|
||||||
|
view->DrawBitmap(bitmap);
|
||||||
|
view->SetHighColor(255, 255, 255, 128);
|
||||||
|
view->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
view->FillRect(rect);
|
||||||
|
return view->EndPicture();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,6 +42,10 @@
|
|||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <Picture.h>
|
||||||
|
#include <PictureButton.h>
|
||||||
|
#include <TranslatorFormats.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
status_t TestForAddonExistence(const char* name, directory_which which,
|
status_t TestForAddonExistence(const char* name, directory_which which,
|
||||||
const char* section, BPath& outPath);
|
const char* section, BPath& outPath);
|
||||||
@@ -86,6 +90,12 @@ public:
|
|||||||
|
|
||||||
// mimetype from sender
|
// mimetype from sender
|
||||||
bool MimeTypeForSender(BMessage* sender, BString& mime);
|
bool MimeTypeForSender(BMessage* sender, BString& mime);
|
||||||
|
// adds fields to message or replaces existing fields
|
||||||
bool AddFields(BMessage* to, const BMessage* from);
|
bool AddFields(BMessage* to, const BMessage* from);
|
||||||
|
// load bitmap from application resources
|
||||||
|
BBitmap* LoadBitmap(const char* name, uint32 type_code = B_TRANSLATOR_BITMAP);
|
||||||
|
// convert bitmap to picture; view must be attached to a window!
|
||||||
|
// returns NULL if bitmap is NULL
|
||||||
|
BPicture *BitmapToPicture(BView* view, BBitmap *bitmap);
|
||||||
|
BPicture *BitmapToGrayedPicture(BView* view, BBitmap *bitmap);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -64,8 +64,9 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
|
|
||||||
AddChild(panel);
|
AddChild(panel);
|
||||||
|
|
||||||
float left = 10, top = 5, width;
|
float left = 10, top = 5;
|
||||||
BRect r(left, top, 160, 15);
|
BRect r(left, top, 160, 15);
|
||||||
|
BStringView* string;
|
||||||
|
|
||||||
// print selection popup menu
|
// print selection popup menu
|
||||||
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
BPopUpMenu* menu = new BPopUpMenu("Select a Printer");
|
||||||
@@ -75,25 +76,24 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
fPrinters->SetDivider(40);
|
fPrinters->SetDivider(40);
|
||||||
panel->AddChild(fPrinters);
|
panel->AddChild(fPrinters);
|
||||||
top += fPrinters->Bounds().Height() + 10;
|
top += fPrinters->Bounds().Height() + 10;
|
||||||
width = fPrinters->Bounds().Width();
|
|
||||||
|
|
||||||
// page format button
|
// page format button
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
fPageSetup = new BButton(r, "Page Format", "Page Format", new BMessage(MSG_PAGE_SETUP));
|
fPageSetup = AddPictureButton(panel, r, "Page Format", "PAGE_SETUP_ON", "PAGE_SETUP_OFF", MSG_PAGE_SETUP);
|
||||||
panel->AddChild(fPageSetup);
|
// add description to button
|
||||||
fPageSetup->ResizeToPreferred();
|
r.OffsetTo(left + fPageSetup->Bounds().Width() + 5, top + fPageSetup->Bounds().Height()/2-5);
|
||||||
|
AddStringView(panel, r, "Setup page format");
|
||||||
top += fPageSetup->Bounds().Height() + 5;
|
top += fPageSetup->Bounds().Height() + 5;
|
||||||
if (fPageSetup->Bounds().Width() > width) width = fPageSetup->Bounds().Width();
|
|
||||||
|
|
||||||
// page selection button
|
// page selection button
|
||||||
fJobSetup = NULL;
|
fJobSetup = NULL;
|
||||||
if (kind == kJobSetup) {
|
if (kind == kJobSetup) {
|
||||||
r.OffsetTo(left, top);
|
r.OffsetTo(left, top);
|
||||||
fJobSetup = new BButton(r, "Page Selection", "Page Selection", new BMessage(MSG_JOB_SETUP));
|
fJobSetup = AddPictureButton(panel, r, "Page Selection", "JOB_SETUP_ON", "JOB_SETUP_OFF", MSG_JOB_SETUP);
|
||||||
panel->AddChild(fJobSetup);
|
// add description to button
|
||||||
fJobSetup->ResizeToPreferred();
|
r.OffsetTo(left + fJobSetup->Bounds().Width() + 5, top + fJobSetup->Bounds().Width()/2-5);
|
||||||
|
AddStringView(panel, r, "Setup print job");
|
||||||
top += fJobSetup->Bounds().Height() + 5;
|
top += fJobSetup->Bounds().Height() + 5;
|
||||||
if (fJobSetup->Bounds().Width() > width) width = fJobSetup->Bounds().Width();
|
|
||||||
}
|
}
|
||||||
top += 5;
|
top += 5;
|
||||||
|
|
||||||
@@ -117,11 +117,6 @@ ConfigWindow::ConfigWindow(config_setup_kind kind, Printer* defaultPrinter, BMes
|
|||||||
panel->AddChild(fOk);
|
panel->AddChild(fOk);
|
||||||
fOk->ResizeToPreferred();
|
fOk->ResizeToPreferred();
|
||||||
top += fOk->Bounds().Height() + 10;
|
top += fOk->Bounds().Height() + 10;
|
||||||
|
|
||||||
// resize buttons to equal width
|
|
||||||
float height = fOk->Bounds().Height();
|
|
||||||
fPageSetup->ResizeTo(width, height);
|
|
||||||
if (fJobSetup) fJobSetup->ResizeTo(width, height);
|
|
||||||
|
|
||||||
// resize window
|
// resize window
|
||||||
ResizeTo(fOk->Frame().right + 10, top);
|
ResizeTo(fOk->Frame().right + 10, top);
|
||||||
@@ -239,6 +234,45 @@ void ConfigWindow::SetWindowFrame(BRect r) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BPictureButton* ConfigWindow::AddPictureButton(BView* panel, BRect frame, const char* name, const char* on, const char* off, uint32 what) {
|
||||||
|
BBitmap* onBM = LoadBitmap(on);
|
||||||
|
BBitmap* offBM = LoadBitmap(off);
|
||||||
|
|
||||||
|
BPicture* onPict = BitmapToPicture(panel, onBM);
|
||||||
|
BPicture* offPict = BitmapToPicture(panel, offBM);
|
||||||
|
|
||||||
|
BPictureButton* button = NULL;
|
||||||
|
|
||||||
|
if (onPict != NULL && offPict != NULL) {
|
||||||
|
button = new BPictureButton(frame, name, onPict, offPict, new BMessage(what));
|
||||||
|
button->SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
|
panel->AddChild(button);
|
||||||
|
onBM->Lock();
|
||||||
|
button->ResizeTo(onBM->Bounds().Width(), onBM->Bounds().Height());
|
||||||
|
onBM->Unlock();
|
||||||
|
|
||||||
|
BPicture* disabled = BitmapToGrayedPicture(panel, offBM);
|
||||||
|
button->SetDisabledOn(disabled);
|
||||||
|
delete disabled;
|
||||||
|
|
||||||
|
disabled = BitmapToGrayedPicture(panel, onBM);
|
||||||
|
button->SetDisabledOff(disabled);
|
||||||
|
delete disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete onPict; delete offPict;
|
||||||
|
delete onBM; delete offBM;
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigWindow::AddStringView(BView* panel, BRect frame, const char* text) {
|
||||||
|
BStringView* string = new BStringView(frame, "", text);
|
||||||
|
string->SetViewColor(panel->ViewColor());
|
||||||
|
string->SetLowColor(panel->ViewColor());
|
||||||
|
panel->AddChild(string);
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigWindow::PrinterForMimeType() {
|
void ConfigWindow::PrinterForMimeType() {
|
||||||
BAutolock lock(gLock);
|
BAutolock lock(gLock);
|
||||||
if (fCurrentPrinter) {
|
if (fCurrentPrinter) {
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public:
|
|||||||
static void SetWindowFrame(BRect frame);
|
static void SetWindowFrame(BRect frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BPictureButton* AddPictureButton(BView* panel, BRect frame, const char* name, const char* on, const char* off, uint32 what);
|
||||||
|
void AddStringView(BView* panel, BRect frame, const char* text);
|
||||||
void PrinterForMimeType();
|
void PrinterForMimeType();
|
||||||
void SetupPrintersMenu(BMenu* menu);
|
void SetupPrintersMenu(BMenu* menu);
|
||||||
void UpdateAppSettings(const char* mime, const char* printer);
|
void UpdateAppSettings(const char* mime, const char* printer);
|
||||||
@@ -85,8 +87,8 @@ private:
|
|||||||
sem_id fFinished;
|
sem_id fFinished;
|
||||||
|
|
||||||
BMenuField* fPrinters;
|
BMenuField* fPrinters;
|
||||||
BButton* fPageSetup;
|
BPictureButton* fPageSetup;
|
||||||
BButton* fJobSetup;
|
BPictureButton* fJobSetup;
|
||||||
BButton* fOk;
|
BButton* fOk;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,5 +28,6 @@ LinkSharedOSLibs
|
|||||||
print_server
|
print_server
|
||||||
:
|
:
|
||||||
be
|
be
|
||||||
root
|
root
|
||||||
|
translation
|
||||||
;
|
;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user