2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
13 #include <ToolTipManager.h>
22 BToolTip::BToolTip(BMessage
* archive
)
27 if (archive
->FindBool("sticky", &sticky
) == B_OK
)
40 BToolTip::Archive(BMessage
* archive
, bool deep
) const
42 status_t status
= BArchivable::Archive(archive
, deep
);
45 status
= archive
->AddBool("sticky", fIsSticky
);
53 BToolTip::SetSticky(bool enable
)
60 BToolTip::IsSticky() const
67 BToolTip::SetMouseRelativeLocation(BPoint location
)
69 fRelativeLocation
= location
;
74 BToolTip::MouseRelativeLocation() const
76 return fRelativeLocation
;
81 BToolTip::SetAlignment(BAlignment alignment
)
83 fAlignment
= alignment
;
88 BToolTip::Alignment() const
95 BToolTip::AttachedToWindow()
101 BToolTip::DetachedFromWindow()
111 lockedLooper
= View()->LockLooper();
113 BToolTipManager
* manager
= BToolTipManager::Manager();
116 if (View()->Window() != NULL
) {
124 fLockedLooper
= lockedLooper
;
133 View()->UnlockLooper();
135 BToolTipManager::Manager()->Unlock();
140 BToolTip::_InitData()
143 fRelativeLocation
= BPoint(20, 20);
144 fAlignment
= BAlignment(B_ALIGN_RIGHT
, B_ALIGN_BOTTOM
);
151 BTextToolTip::BTextToolTip(const char* text
)
157 BTextToolTip::BTextToolTip(BMessage
* archive
)
163 BTextToolTip::~BTextToolTip()
169 /*static*/ BTextToolTip
*
170 BTextToolTip::Instantiate(BMessage
* archive
)
172 if (!validate_instantiation(archive
, "BTextToolTip"))
175 return new(std::nothrow
) BTextToolTip(archive
);
180 BTextToolTip::Archive(BMessage
* archive
, bool deep
) const
182 status_t status
= BToolTip::Archive(archive
, deep
);
190 BTextToolTip::View() const
197 BTextToolTip::Text() const
199 return fTextView
->Text();
204 BTextToolTip::SetText(const char* text
)
209 fTextView
->SetText(text
);
210 fTextView
->InvalidateLayout();
217 BTextToolTip::_InitData(const char* text
)
219 fTextView
= new BTextView("tool tip text");
220 fTextView
->SetText(text
);
221 fTextView
->MakeEditable(false);
222 fTextView
->SetViewColor(ui_color(B_TOOL_TIP_BACKGROUND_COLOR
));
223 rgb_color color
= ui_color(B_TOOL_TIP_TEXT_COLOR
);
224 fTextView
->SetFontAndColor(NULL
, 0, &color
);
225 fTextView
->SetWordWrap(false);