* Style changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39198 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -28,30 +28,32 @@ private:
|
|||||||
|
|
||||||
class AddPrinterView : public BView {
|
class AddPrinterView : public BView {
|
||||||
public:
|
public:
|
||||||
AddPrinterView(BRect frame, PrinterData *printer_data, const PrinterCap *printer_cap);
|
AddPrinterView(BRect frame, PrinterData* printerData,
|
||||||
~AddPrinterView();
|
const PrinterCap* printerCap);
|
||||||
virtual void AttachedToWindow();
|
~AddPrinterView();
|
||||||
void FrameResized(float w, float h);
|
virtual void AttachedToWindow();
|
||||||
void MessageReceived(BMessage *msg);
|
void FrameResized(float w, float h);
|
||||||
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
void Save();
|
void Save();
|
||||||
private:
|
private:
|
||||||
ProtocolClassItem *CurrentSelection();
|
ProtocolClassItem* CurrentSelection();
|
||||||
|
|
||||||
PrinterData *fPrinterData;
|
PrinterData* fPrinterData;
|
||||||
const PrinterCap *fPrinterCap;
|
const PrinterCap* fPrinterCap;
|
||||||
|
|
||||||
BListView *fProtocolClassList;
|
BListView* fProtocolClassList;
|
||||||
BTextView *fDescription;
|
BTextView* fDescription;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AddPrinterDlg : public DialogWindow {
|
class AddPrinterDlg : public DialogWindow {
|
||||||
public:
|
public:
|
||||||
AddPrinterDlg(PrinterData *printerData, const PrinterCap *printerCap);
|
AddPrinterDlg(PrinterData *printerData,
|
||||||
void MessageReceived(BMessage *msg);
|
const PrinterCap *printerCap);
|
||||||
|
void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AddPrinterView *fAddPrinterView;
|
AddPrinterView* fAddPrinterView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -86,12 +86,14 @@ enum MSGS {
|
|||||||
kMsgProtocolClassChanged,
|
kMsgProtocolClassChanged,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ProtocolClassItem::ProtocolClassItem(const ProtocolClassCap* cap)
|
ProtocolClassItem::ProtocolClassItem(const ProtocolClassCap* cap)
|
||||||
: BStringItem(cap->fLabel.c_str())
|
: BStringItem(cap->fLabel.c_str())
|
||||||
, fProtocolClassCap(cap)
|
, fProtocolClassCap(cap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ProtocolClassItem::getProtocolClass()
|
ProtocolClassItem::getProtocolClass()
|
||||||
{
|
{
|
||||||
@@ -105,26 +107,33 @@ ProtocolClassItem::getDescription()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AddPrinterView::AddPrinterView(BRect frame, PrinterData *printer_data, const PrinterCap *printer_cap)
|
AddPrinterView::AddPrinterView(BRect frame, PrinterData* printerData,
|
||||||
: BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), fPrinterData(printer_data), fPrinterCap(printer_cap)
|
const PrinterCap* printerCap)
|
||||||
|
:
|
||||||
|
BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||||
|
fPrinterData(printerData),
|
||||||
|
fPrinterCap(printerCap)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AddPrinterView::~AddPrinterView()
|
AddPrinterView::~AddPrinterView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterView::AttachedToWindow()
|
AddPrinterView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
/* protocol class box */
|
// protocol class box
|
||||||
BBox *box;
|
BBox *box;
|
||||||
box = new BBox(PROTOCOL_CLASS_BOX_RECT, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
box = new BBox(PROTOCOL_CLASS_BOX_RECT, NULL,
|
||||||
|
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
box->SetLabel("Protocol Classes:");
|
box->SetLabel("Protocol Classes:");
|
||||||
AddChild(box);
|
AddChild(box);
|
||||||
|
|
||||||
/* protocol class */
|
// protocol class
|
||||||
fProtocolClassList = new BListView(
|
fProtocolClassList = new BListView(
|
||||||
PROTOCOL_CLASS_RECT,
|
PROTOCOL_CLASS_RECT,
|
||||||
"protocolClassList",
|
"protocolClassList",
|
||||||
@@ -137,11 +146,13 @@ AddPrinterView::AttachedToWindow()
|
|||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
true));
|
true));
|
||||||
fProtocolClassList->SetSelectionMessage(new BMessage(kMsgProtocolClassChanged));
|
fProtocolClassList->SetSelectionMessage(
|
||||||
|
new BMessage(kMsgProtocolClassChanged));
|
||||||
fProtocolClassList->SetTarget(this);
|
fProtocolClassList->SetTarget(this);
|
||||||
|
|
||||||
int count = fPrinterCap->countCap(PrinterCap::kProtocolClass);
|
int count = fPrinterCap->countCap(PrinterCap::kProtocolClass);
|
||||||
ProtocolClassCap **protocolClasses = (ProtocolClassCap **)fPrinterCap->enumCap(PrinterCap::kProtocolClass);
|
ProtocolClassCap **protocolClasses =
|
||||||
|
(ProtocolClassCap **)fPrinterCap->enumCap(PrinterCap::kProtocolClass);
|
||||||
while (count--) {
|
while (count--) {
|
||||||
const ProtocolClassCap *protocolClass = *protocolClasses;
|
const ProtocolClassCap *protocolClass = *protocolClasses;
|
||||||
|
|
||||||
@@ -154,28 +165,30 @@ AddPrinterView::AttachedToWindow()
|
|||||||
protocolClasses ++;
|
protocolClasses ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* description of protocol class box */
|
// description of protocol class box
|
||||||
box = new BBox(DESCRIPTION_BOX_RECT, NULL, B_FOLLOW_ALL_SIDES);
|
box = new BBox(DESCRIPTION_BOX_RECT, NULL, B_FOLLOW_ALL_SIDES);
|
||||||
box->SetLabel("Description:");
|
box->SetLabel("Description:");
|
||||||
AddChild(box);
|
AddChild(box);
|
||||||
|
|
||||||
/* description of protocol class */
|
// description of protocol class
|
||||||
BRect textRect(DESCRIPTION_RECT);
|
BRect textRect(DESCRIPTION_RECT);
|
||||||
textRect.OffsetTo(0, 0);
|
textRect.OffsetTo(0, 0);
|
||||||
fDescription = new BTextView(DESCRIPTION_RECT, "description", textRect, B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
fDescription = new BTextView(DESCRIPTION_RECT, "description", textRect,
|
||||||
|
B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
||||||
fDescription->SetViewColor(box->ViewColor());
|
fDescription->SetViewColor(box->ViewColor());
|
||||||
box->AddChild(new BScrollView("descriptionScroller", fDescription,
|
box->AddChild(new BScrollView("descriptionScroller", fDescription,
|
||||||
B_FOLLOW_ALL_SIDES, 0, false, true, B_NO_BORDER));
|
B_FOLLOW_ALL_SIDES, 0, false, true, B_NO_BORDER));
|
||||||
fDescription->MakeEditable(false);
|
fDescription->MakeEditable(false);
|
||||||
|
|
||||||
/* cancel */
|
// cancel
|
||||||
BButton *button;
|
BButton *button;
|
||||||
button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(kMsgCancel), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(kMsgCancel),
|
||||||
|
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
AddChild(button);
|
AddChild(button);
|
||||||
|
|
||||||
/* ok */
|
// ok
|
||||||
|
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(kMsgOK),
|
||||||
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(kMsgOK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
AddChild(button);
|
AddChild(button);
|
||||||
button->MakeDefault(true);
|
button->MakeDefault(true);
|
||||||
|
|
||||||
@@ -184,6 +197,7 @@ AddPrinterView::AttachedToWindow()
|
|||||||
MessageReceived(&updateDescription);
|
MessageReceived(&updateDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterView::FrameResized(float w, float h)
|
AddPrinterView::FrameResized(float w, float h)
|
||||||
{
|
{
|
||||||
@@ -194,7 +208,8 @@ AddPrinterView::FrameResized(float w, float h)
|
|||||||
fDescription->SetTextRect(rect);
|
fDescription->SetTextRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolClassItem *
|
|
||||||
|
ProtocolClassItem*
|
||||||
AddPrinterView::CurrentSelection()
|
AddPrinterView::CurrentSelection()
|
||||||
{
|
{
|
||||||
int selected = fProtocolClassList->CurrentSelection();
|
int selected = fProtocolClassList->CurrentSelection();
|
||||||
@@ -204,8 +219,9 @@ AddPrinterView::CurrentSelection()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterView::MessageReceived(BMessage *msg)
|
AddPrinterView::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
if (msg->what == kMsgProtocolClassChanged) {
|
if (msg->what == kMsgProtocolClassChanged) {
|
||||||
ProtocolClassItem *item = CurrentSelection();
|
ProtocolClassItem *item = CurrentSelection();
|
||||||
@@ -217,18 +233,22 @@ AddPrinterView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterView::Save()
|
AddPrinterView::Save()
|
||||||
{
|
{
|
||||||
ProtocolClassItem *item = CurrentSelection();
|
ProtocolClassItem* item = CurrentSelection();
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
fPrinterData->setProtocolClass(item->getProtocolClass());
|
fPrinterData->setProtocolClass(item->getProtocolClass());
|
||||||
fPrinterData->save();
|
fPrinterData->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddPrinterDlg::AddPrinterDlg(PrinterData *printerData, const PrinterCap *printerCap)
|
|
||||||
: DialogWindow(BRect(100, 100, 100 + DIALOG_WIDTH, 100 + DIALOG_HEIGHT),
|
AddPrinterDlg::AddPrinterDlg(PrinterData* printerData,
|
||||||
|
const PrinterCap *printerCap)
|
||||||
|
:
|
||||||
|
DialogWindow(BRect(100, 100, 100 + DIALOG_WIDTH, 100 + DIALOG_HEIGHT),
|
||||||
"Add Printer", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
"Add Printer", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
||||||
B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
@@ -245,22 +265,23 @@ AddPrinterDlg::AddPrinterDlg(PrinterData *printerData, const PrinterCap *printer
|
|||||||
AddChild(fAddPrinterView);
|
AddChild(fAddPrinterView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddPrinterDlg::MessageReceived(BMessage *msg)
|
AddPrinterDlg::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case kMsgOK:
|
case kMsgOK:
|
||||||
fAddPrinterView->Save();
|
fAddPrinterView->Save();
|
||||||
SetResult(B_NO_ERROR);
|
SetResult(B_NO_ERROR);
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgCancel:
|
case kMsgCancel:
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DialogWindow::MessageReceived(msg);
|
DialogWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user