3 static const float kWidth
= 80;
4 static const float kHeight
= 30;
6 static const float kPageWidth
= 16;
7 static const float kPageHeight
= 16;
9 static const float kPageHorizontalIndent
= 7;
10 static const float kPageVerticalIndent
= 5;
12 PagesView::PagesView(BRect frame
, const char* name
, uint32 resizeMask
, uint32 flags
)
13 : BView(frame
, name
, resizeMask
, flags
),
17 SetViewColor(B_TRANSPARENT_COLOR
);
20 void PagesView::GetPreferredSize(float *width
, float *height
)
26 void PagesView::Draw(BRect rect
)
28 rgb_color backgroundColor
= {255, 255, 255};
29 // inherit view color from parent if available
30 if (Parent() != NULL
) {
31 backgroundColor
= Parent()->ViewColor();
33 SetHighColor(backgroundColor
);
36 BFont
font(be_plain_font
);
40 BPoint
position(3, 3);
42 BPoint
next(kPageWidth
+ kPageHorizontalIndent
* 2 + 10, 0);
43 _DrawPages(position
, 1, 3);
45 _DrawPages(position
, 1, 3);
47 BPoint
next(kPageWidth
+ kPageHorizontalIndent
* 1 + 10, 0);
48 for (int i
= 1; i
<= 3; i
++) {
49 int page
= fReverse
? 4 - i
: i
;
50 _DrawPages(position
, page
, 2);
56 void PagesView::_DrawPages(BPoint position
, int number
, int count
)
58 position
.x
+= kPageHorizontalIndent
* (count
- 1);
59 BPoint
next(-kPageHorizontalIndent
, kPageVerticalIndent
);
61 for (int i
= 0; i
< count
; i
++) {
68 _DrawPage(position
, page
);
72 for (int i
= 0; i
< count
; i
++) {
73 _DrawPage(position
, number
);
79 void PagesView::_DrawPage(BPoint position
, int number
)
81 const rgb_color pageBackgroundColor
= {255, 255, 255};
82 const rgb_color pageBorderColor
= {0, 0, 0};
83 const rgb_color pageNumberColor
= {0, 0, 0};
86 page
[0].x
= position
.x
+ 3;
87 page
[0].y
= position
.y
;
88 page
[4].x
= position
.x
;
89 page
[4].y
= position
.y
+ 3;
90 page
[1].x
= position
.x
+ kPageWidth
- 1;
91 page
[1].y
= position
.y
;
92 page
[2].x
= position
.x
+ kPageWidth
- 1;
93 page
[2].y
= position
.y
+ kPageHeight
- 1;
94 page
[3].x
= position
.x
;
95 page
[3].y
= position
.y
+ kPageHeight
- 1;
97 SetHighColor(pageBackgroundColor
);
100 SetHighColor(pageBorderColor
);
101 StrokePolygon(page
, 5);
102 StrokeLine(position
+ BPoint(3, 1), position
+ BPoint(3, 3));
103 StrokeLine(position
+ BPoint(3, 3), position
+ BPoint(1, 3));
105 SetHighColor(pageNumberColor
);
106 SetLowColor(pageBackgroundColor
);
107 DrawChar('0' + number
,
109 BPoint(kPageWidth
- kPageHorizontalIndent
+ 1, kPageHeight
- 2));
112 void PagesView::SetCollate(bool collate
)
118 void PagesView::SetReverse(bool reverse
)