Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / preferences / printers / PrinterListView.h
blob03a846b0e429f85764cb96e4ef243b22ab0442f4
1 /*
2 * Copyright 2001-2010, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer
7 */
8 #ifndef _PRINTERS_LISTVIEW_H
9 #define _PRINTERS_LISTVIEW_H
12 #include <Directory.h>
13 #include <Entry.h>
14 #include <Messenger.h>
15 #include <ListView.h>
16 #include <String.h>
18 #include "FolderWatcher.h"
21 class SpoolFolder;
22 class PrinterItem;
23 class PrinterListView;
24 class BBitmap;
25 class PrintersWindow;
28 struct PrinterListLayoutData
30 float fLeftColumnMaximumWidth;
31 float fRightColumnMaximumWidth;
36 class PrinterListView : public BListView, public FolderListener {
37 public:
38 PrinterListView(BRect frame);
39 ~PrinterListView();
41 void AttachedToWindow();
42 bool QuitRequested();
44 void BuildPrinterList();
45 PrinterItem* SelectedItem() const;
46 void UpdateItem(PrinterItem* item);
48 PrinterItem* ActivePrinter() const;
49 void SetActivePrinter(PrinterItem* item);
51 private:
52 typedef BListView Inherited;
54 void _AddPrinter(BDirectory& printer, bool calculateLayout);
55 void _LayoutPrinterItems();
56 PrinterItem* _FindItem(node_ref* node) const;
58 void EntryCreated(node_ref* node,
59 entry_ref* entry);
60 void EntryRemoved(node_ref* node);
61 void AttributeChanged(node_ref* node);
63 FolderWatcher* fFolder;
64 PrinterItem* fActivePrinter;
65 PrinterListLayoutData fLayoutData;
69 class PrinterItem : public BListItem {
70 public:
71 PrinterItem(PrintersWindow* window,
72 const BDirectory& node,
73 PrinterListLayoutData& layoutData);
74 ~PrinterItem();
76 void GetColumnWidth(BView* view, float& leftColumn,
77 float& rightColumn);
79 void DrawItem(BView* owner, BRect bounds,
80 bool complete);
81 void Update(BView* owner, const BFont* font);
83 bool Remove(BListView* view);
84 bool IsActivePrinter() const;
85 bool HasPendingJobs() const;
87 const char* Name() const { return fName.String(); }
88 const char* Driver() const { return fDriverName.String(); }
89 const char* Transport() const { return fTransport.String(); }
90 const char* TransportAddress() const
91 { return fTransportAddress.String(); }
93 SpoolFolder* Folder() const;
94 BDirectory* Node();
95 void UpdatePendingJobs();
97 private:
98 void _GetStringProperty(const char* propName,
99 BString& outString);
100 BBitmap* _LoadVectorIcon(const char* resourceName,
101 float iconSize);
103 SpoolFolder* fFolder;
104 BDirectory fNode;
105 BString fComments;
106 BString fTransport;
107 BString fTransportAddress;
108 BString fDriverName;
109 BString fName;
110 BString fPendingJobs;
111 PrinterListLayoutData& fLayoutData;
113 static BBitmap* sIcon;
114 static BBitmap* sSelectedIcon;
117 #endif // _PRINTERS_LISTVIEW_H