2 * Copyright 2001-2010, Haiku.
3 * Distributed under the terms of the MIT License.
8 #ifndef _PRINTERS_LISTVIEW_H
9 #define _PRINTERS_LISTVIEW_H
12 #include <Directory.h>
14 #include <Messenger.h>
18 #include "FolderWatcher.h"
23 class PrinterListView
;
28 struct PrinterListLayoutData
30 float fLeftColumnMaximumWidth
;
31 float fRightColumnMaximumWidth
;
36 class PrinterListView
: public BListView
, public FolderListener
{
38 PrinterListView(BRect frame
);
41 void AttachedToWindow();
44 void BuildPrinterList();
45 PrinterItem
* SelectedItem() const;
46 void UpdateItem(PrinterItem
* item
);
48 PrinterItem
* ActivePrinter() const;
49 void SetActivePrinter(PrinterItem
* item
);
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
,
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
{
71 PrinterItem(PrintersWindow
* window
,
72 const BDirectory
& node
,
73 PrinterListLayoutData
& layoutData
);
76 void GetColumnWidth(BView
* view
, float& leftColumn
,
79 void DrawItem(BView
* owner
, BRect bounds
,
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;
95 void UpdatePendingJobs();
98 void _GetStringProperty(const char* propName
,
100 BBitmap
* _LoadVectorIcon(const char* resourceName
,
103 SpoolFolder
* fFolder
;
107 BString fTransportAddress
;
110 BString fPendingJobs
;
111 PrinterListLayoutData
& fLayoutData
;
113 static BBitmap
* sIcon
;
114 static BBitmap
* sSelectedIcon
;
117 #endif // _PRINTERS_LISTVIEW_H