This source file includes following definitions.
- Load
- Draw
- Action_Friend_NewCursor
- MessageReceived
- FrameResized
- OnMouseDown
- OnMouseUp
- OnKeyDown
- DrawPanel
- PrepareKeysMenu
- PrepareCmdLine
- PrepareTopMenuItem
- LoadImage
1
2
3
4
5
6
7
8
9
10
11
12 #include <TranslationUtils.h>
13 #include "BF_GUI_ImagePanel.h"
14 #include "BL_Tools.h"
15
16
17
18 BF_GUI_ImagePanel_Viewer::BF_GUI_ImagePanel_Viewer()
19 {
20
21 }
22
23 void
24 BF_GUI_ImagePanel_Viewer::Load(BL_String & s_NodePath)
25 {
26 sNodePath = s_NodePath;
27 mpBitmap = BTranslationUtils::GetBitmapFile(sNodePath.String());
28
29 }
30
31 void
32 BF_GUI_ImagePanel_Viewer::Draw(BView *po_Render,const BRect & o_Rect)
33 {
34
35 if (mpBitmap)
36 {
37 if (!po_Render) return;
38 po_Render->SetDrawingMode(B_OP_COPY);
39 po_Render->DrawBitmap(mpBitmap, o_Rect, o_Rect);
40 po_Render->SetDrawingMode(B_OP_ALPHA);
41 po_Render->FillRect(o_Rect);
42 }
43 else
44 {
45 BPoint oPoint(o_Rect.left,o_Rect.top + o_Rect.Height()/2 - poSysSetup->oFontNode.fAscent);
46 po_Render->SetFont(&poSysSetup->oFontNode.oFont);
47 po_Render->SetHighColor(SYS_COLOR(BF_COLOR_NODE));
48 po_Render->DrawString(sNodePath.String(),oPoint);
49 }
50 }
51
52
53
54 BF_GUI_ImagePanel::BF_GUI_ImagePanel(
55 const BRect& o_Rect,
56 const char* pc_FirstName,
57 bool b_WinPos_OnLeft
58 ):BF_GUI_Panel(o_Rect,pc_FirstName,b_WinPos_OnLeft)
59 {
60
61 SetHeader("ImageViewer");
62 }
63
64 void
65 BF_GUI_ImagePanel::Action_Friend_NewCursor(const char *pc_NodePath,const char *pc_NodeName,int32 i_NodeType)
66 {
67 BL_String s;
68 ASSERT(pc_NodePath && pc_NodeName);
69 s<<pc_NodePath;
70 s<<"/";
71 s<<pc_NodeName;
72 LoadImage(s.String());
73 }
74
75 void
76 BF_GUI_ImagePanel::MessageReceived(BMessage* po_Message)
77 {
78 switch(po_Message->what){
79 default:
80 BF_GUI_Panel::MessageReceived(po_Message);
81 }
82 }
83
84 void
85 BF_GUI_ImagePanel::FrameResized(float width, float height)
86 {
87 BF_GUI_Panel::FrameResized(width,height);
88
89 }
90
91 bool
92 BF_GUI_ImagePanel::OnMouseDown(BPoint & o_Point)
93 {
94
95 return BF_GUI_Panel::OnMouseDown(o_Point);
96 }
97
98 bool
99 BF_GUI_ImagePanel::OnMouseUp(BPoint & o_Point)
100 {
101
102 return BF_GUI_Panel::OnMouseUp(o_Point);
103 }
104
105 bool
106 BF_GUI_ImagePanel::OnKeyDown(const char *bytes, int32 numBytes)
107 {
108
109 return BF_GUI_Panel::OnKeyDown(bytes,numBytes);
110 }
111
112 void
113 BF_GUI_ImagePanel::DrawPanel(BRect & o_Rect)
114 {
115 BF_GUI_Panel::DrawPanel(o_Rect);
116 DrawBottom("",true);
117
118 oViewer.Draw(poRender,ClientRect());
119 }
120
121 void
122 BF_GUI_ImagePanel::PrepareKeysMenu()
123 {
124 BF_GUI_Panel::PrepareKeysMenu();
125
126 }
127
128 void
129 BF_GUI_ImagePanel::PrepareCmdLine()
130 {
131 BF_GUI_Panel::PrepareCmdLine();
132
133 }
134
135 void
136 BF_GUI_ImagePanel::PrepareTopMenuItem(BF_GUI_TopMenu_HItem *po_HItem)
137 {
138 BF_GUI_Panel::PrepareTopMenuItem(po_HItem);
139
140 }
141
142 void
143 BF_GUI_ImagePanel::LoadImage(const char *pc_NodePath)
144 {
145 ASSERT(pc_NodePath);
146 sNodePath = pc_NodePath;
147
148 oViewer.Load(sNodePath);
149 Draw(Bounds());