2 * Copyright 2006-2008 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
6 * Ithamar R. Adema <ithamar@unet.nl>
8 * Stephan Aßmus <superstippi@gmx.de>
10 #ifndef PARTITIONLIST_H
11 #define PARTITIONLIST_H
14 #include <ColumnListView.h>
15 #include <ColumnTypes.h>
16 #include <Partition.h>
22 // A field type displaying both a bitmap and a string so that the
23 // tree display looks nicer (both text and bitmap are indented)
24 class BBitmapStringField
: public BStringField
{
25 typedef BStringField Inherited
;
27 BBitmapStringField(BBitmap
* bitmap
,
29 virtual ~BBitmapStringField();
31 void SetBitmap(BBitmap
* bitmap
);
32 const BBitmap
* Bitmap() const
40 // BColumn for PartitionListView which knows how to render
41 // a BBitmapStringField
42 class PartitionColumn
: public BTitledColumn
{
43 typedef BTitledColumn Inherited
;
45 PartitionColumn(const char* title
,
46 float width
, float minWidth
,
47 float maxWidth
, uint32 truncateMode
,
48 alignment align
= B_ALIGN_LEFT
);
50 virtual void DrawField(BField
* field
, BRect rect
,
52 virtual float GetPreferredWidth(BField
* field
, BView
* parent
) const;
54 virtual bool AcceptsField(const BField
* field
) const;
56 static void InitTextMargin(BView
* parent
);
60 static float sTextMargin
;
64 // BRow for the PartitionListView
65 class PartitionListRow
: public BRow
{
66 typedef BRow Inherited
;
68 PartitionListRow(BPartition
* partition
);
69 PartitionListRow(partition_id parentID
,
70 partition_id id
, off_t offset
, off_t size
);
72 partition_id
ID() const
73 { return fPartitionID
; }
74 partition_id
ParentID() const
81 const char* DevicePath();
84 partition_id fPartitionID
;
85 partition_id fParentID
;
91 class PartitionListView
: public BColumnListView
{
92 typedef BColumnListView Inherited
;
94 PartitionListView(const BRect
& frame
,
97 virtual void AttachedToWindow();
99 virtual bool InitiateDrag(BPoint rowPoint
, bool wasSelected
);
100 virtual void ExpandOrCollapse(BRow
* row
, bool expand
);
102 PartitionListRow
* FindRow(partition_id id
,
103 PartitionListRow
* parent
= NULL
);
104 PartitionListRow
* AddPartition(BPartition
* partition
);
105 PartitionListRow
* AddSpace(partition_id parent
,
106 partition_id id
, off_t offset
, off_t size
);
108 virtual BSize
PreferredSize();
111 int32
_InsertIndexForOffset(PartitionListRow
* parent
,
116 #endif // PARTITIONLIST_H