2 * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
13 LinkView::LinkView(const char* name
, const char* string
, BMessage
* message
)
15 BStringView(name
, string
),
16 BInvoker(message
, NULL
),
20 SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED
, B_SIZE_UNSET
));
21 SetExplicitMinSize(BSize(120, B_SIZE_UNSET
));
26 LinkView::AttachedToWindow()
33 LinkView::MouseMoved(BPoint where
, uint32 transit
, const BMessage
* dragMessage
)
35 // TODO: Check that no buttons are pressed, don't indicate clickable
36 // link if a button is held.
37 if (transit
== B_ENTERED_VIEW
) {
40 } else if (transit
== B_EXITED_VIEW
) {
48 LinkView::MouseDown(BPoint where
)
56 LinkView::Draw(BRect updateRect
)
61 SetDrawingMode(B_OP_ALPHA
);
63 font_height fontHeight
;
64 GetFontHeight(&fontHeight
);
66 BRect bounds
= Bounds();
68 float y
= (bounds
.top
+ bounds
.bottom
- ceilf(fontHeight
.ascent
)
69 - ceilf(fontHeight
.descent
)) / 2.0 + ceilf(fontHeight
.ascent
);
73 TruncateString(&text
, B_TRUNCATE_END
, bounds
.Width());
74 DrawString(text
, BPoint(x
, y
));
79 LinkView::SetEnabled(bool enabled
)
81 if (fEnabled
!= enabled
) {
89 LinkView::MessageReceived(BMessage
* message
)
91 if (message
->what
== B_COLORS_UPDATED
)
94 BStringView::MessageReceived(message
);
99 LinkView::_UpdateLinkColor()
101 BCursorID cursorID
= B_CURSOR_ID_SYSTEM_DEFAULT
;
103 float tint
= B_DARKEN_1_TINT
;
108 cursorID
= B_CURSOR_ID_FOLLOW_LINK
;
109 SetHighUIColor(B_LINK_HOVER_COLOR
, tint
);
111 SetHighUIColor(B_LINK_TEXT_COLOR
, tint
);
113 SetHighColor(disable_color(ui_color(B_LINK_TEXT_COLOR
), ViewColor()));
115 BCursor
cursor(cursorID
);
116 SetViewCursor(&cursor
, true);