hrev48527 adds 3 changesets to branch 'master' old head: ca7c20e8d7bba09a5ccfc86eb936f925321c7205 new head: d78a330deb227907f899e0b0d63a136a40716e01 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=d78a330+%5Eca7c20e ---------------------------------------------------------------------------- 95faf2c: Minor doc changes f466445: Changes to BTextControl for docs. Also remove the non-ControlLook drawing code. d78a330: Add BTextControl docs [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 5 files changed, 835 insertions(+), 352 deletions(-) docs/user/app/Handler.dox | 2 +- docs/user/interface/TextControl.dox | 546 ++++++++++++++++++++++++++++ docs/user/interface/View.dox | 13 +- headers/os/interface/TextControl.h | 10 +- src/kits/interface/TextControl.cpp | 616 ++++++++++++++------------------ ############################################################################ Commit: 95faf2ce54246ed1b276602aa85753ce536df948 URL: http://cgit.haiku-os.org/haiku/commit/?id=95faf2c Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Dec 19 01:45:25 2014 UTC Minor doc changes ---------------------------------------------------------------------------- diff --git a/docs/user/app/Handler.dox b/docs/user/app/Handler.dox index 2096211..220e352 100644 --- a/docs/user/app/Handler.dox +++ b/docs/user/app/Handler.dox @@ -528,7 +528,7 @@ ShowImageApp::MessageReceived(BMessage *message) /*! \fn status_t BHandler::GetSupportedSuites(BMessage* data) \brief Reports the suites of messages and specifiers that derived classes - understand. + understand. \since BeOS R3 */ diff --git a/docs/user/interface/View.dox b/docs/user/interface/View.dox index 91f9e8c..3d5c350 100644 --- a/docs/user/interface/View.dox +++ b/docs/user/interface/View.dox @@ -778,7 +778,7 @@ SetViewColor(Parent()->ViewColor()); \fn status_t BView::AllUnarchived(const BMessage* from) \brief Hook method called when all views have been unarchived. - \since Haiku R1 + \since BeOS R3 */ @@ -786,7 +786,7 @@ SetViewColor(Parent()->ViewColor()); \fn status_t BView::AllArchived(BMessage* into) const \brief Hook method called when all views have been archived. - \since Haiku R1 + \since BeOS R3 */ @@ -866,8 +866,8 @@ SetViewColor(Parent()->ViewColor()); \fn void BView::FrameResized(float newWidth, float newHeight) \brief Hook method called when the view is resized. - \param newWidth The new \a width of the view. - \param newHeight The new \a height of the view. + \param newWidth The new width of the view. + \param newHeight The new height of the view. \since BeOS R3 */ @@ -3908,10 +3908,7 @@ SetViewColor(Parent()->ViewColor()); /*! \fn status_t BView::GetSupportedSuites(BMessage* data) - \brief Reports the suites of messages and specifiers understood by the - view. - - \copydetails BHandler::GetSupportedSuites() + \copydoc BHandler::GetSupportedSuites() */ ############################################################################ Commit: f466445917801c4badeec8827f0eacb0673f6e72 URL: http://cgit.haiku-os.org/haiku/commit/?id=f466445 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Dec 19 01:45:44 2014 UTC Changes to BTextControl for docs. Also remove the non-ControlLook drawing code. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/TextControl.h b/headers/os/interface/TextControl.h index 95906b3..a99e91a 100644 --- a/headers/os/interface/TextControl.h +++ b/headers/os/interface/TextControl.h @@ -21,7 +21,7 @@ public: BTextControl(BRect frame, const char* name, const char* label, const char* initialText, BMessage* message, - uint32 resizeMode + uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BTextControl(const char* name, @@ -60,7 +60,7 @@ public: virtual void MouseDown(BPoint where); virtual void AttachedToWindow(); virtual void MakeFocus(bool focus = true); - virtual void SetEnabled(bool enabled); + virtual void SetEnabled(bool enable); virtual void FrameMoved(BPoint newPosition); virtual void FrameResized(float newWidth, float newHeight); virtual void WindowActivated(bool active); @@ -74,8 +74,8 @@ public: int32 index, BMessage* specifier, int32 what, const char* property); - virtual void MouseUp(BPoint point); - virtual void MouseMoved(BPoint point, uint32 transit, + virtual void MouseUp(BPoint where); + virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage); virtual void DetachedFromWindow(); @@ -122,7 +122,7 @@ private: friend class TextViewLayoutItem; void _CommitValue(); - void _UpdateTextViewColors(bool enabled); + void _UpdateTextViewColors(bool enable); void _InitData(const char* label, const BMessage* archive = NULL); void _InitText(const char* initialText, diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index fac0166..5065acc 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -156,9 +156,9 @@ static const int32 kLabelInputSpacing = 3; BTextControl::BTextControl(BRect frame, const char* name, const char* label, - const char* text, BMessage* message, uint32 mask, uint32 flags) + const char* text, BMessage* message, uint32 resizeMask, uint32 flags) : - BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS) + BControl(frame, name, label, message, resizeMask, flags | B_FRAME_EVENTS) { _InitData(label); _InitText(text); @@ -167,7 +167,7 @@ BTextControl::BTextControl(BRect frame, const char* name, const char* label, BTextControl::BTextControl(const char* name, const char* label, - const char* text, BMessage* message, uint32 flags) + const char* text, BMessage* message, uint32 flags) : BControl(name, label, message, flags | B_FRAME_EVENTS) { @@ -178,7 +178,7 @@ BTextControl::BTextControl(const char* name, const char* label, BTextControl::BTextControl(const char* label, const char* text, - BMessage* message) + BMessage* message) : BControl(NULL, label, message, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS) @@ -196,6 +196,9 @@ BTextControl::~BTextControl() } +// #pragma mark - Archiving + + BTextControl::BTextControl(BMessage* archive) : BControl(BUnarchiver::PrepareArchive(archive)) @@ -232,25 +235,29 @@ BTextControl::Instantiate(BMessage* archive) status_t -BTextControl::Archive(BMessage *data, bool deep) const +BTextControl::Archive(BMessage* data, bool deep) const { BArchiver archiver(data); - status_t ret = BControl::Archive(data, deep); - alignment labelAlignment, textAlignment; + status_t result = BControl::Archive(data, deep); + + alignment labelAlignment; + alignment textAlignment; + if (result == B_OK) + GetAlignment(&labelAlignment, &textAlignment); + + if (result == B_OK) + result = data->AddInt32("_a_label", labelAlignment); - GetAlignment(&labelAlignment, &textAlignment); + if (result == B_OK) + result = data->AddInt32("_a_text", textAlignment); - if (ret == B_OK) - ret = data->AddInt32("_a_label", labelAlignment); - if (ret == B_OK) - ret = data->AddInt32("_a_text", textAlignment); - if (ret == B_OK) - ret = data->AddFloat("_divide", Divider()); + if (result == B_OK) + result = data->AddFloat("_divide", Divider()); - if (ModificationMessage() && (ret == B_OK)) - ret = data->AddMessage("_mod_msg", ModificationMessage()); + if (result == B_OK && ModificationMessage() != NULL) + result = data->AddMessage("_mod_msg", ModificationMessage()); - return archiver.Finish(ret); + return archiver.Finish(result); } @@ -307,8 +314,235 @@ BTextControl::AllUnarchived(const BMessage* from) } +// #pragma mark - Hook methods + + +void +BTextControl::AllAttached() +{ + BControl::AllAttached(); +} + + +void +BTextControl::AllDetached() +{ + BControl::AllDetached(); +} + + void -BTextControl::SetText(const char *text) +BTextControl::AttachedToWindow() +{ + BControl::AttachedToWindow(); + + _UpdateTextViewColors(IsEnabled()); + fText->MakeEditable(IsEnabled()); +} + + +void +BTextControl::DetachedFromWindow() +{ + BControl::DetachedFromWindow(); +} + + +void +BTextControl::Draw(BRect updateRect) +{ + bool enabled = IsEnabled(); + bool active = fText->IsFocus() && Window()->IsActive(); + + BRect rect = fText->Frame(); + rect.InsetBy(-2, -2); + + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + uint32 flags = fLook; + if (!enabled) + flags |= BControlLook::B_DISABLED; + + if (active) + flags |= BControlLook::B_FOCUSED; + + be_control_look->DrawTextControlBorder(this, rect, updateRect, base, + flags); + + if (Label() != NULL) { + if (fLayoutData->label_layout_item != NULL) { + rect = fLayoutData->label_layout_item->FrameInParent(); + } else { + rect = Bounds(); + rect.right = fDivider - kLabelInputSpacing; + } + + be_control_look->DrawLabel(this, Label(), rect, updateRect, + base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); + } +} + + +void +BTextControl::FrameMoved(BPoint newPosition) +{ + BControl::FrameMoved(newPosition); +} + + +void +BTextControl::FrameResized(float width, float height) +{ + CALLED(); + + BControl::FrameResized(width, height); + + // TODO: this causes flickering still... + + // changes in width + + BRect bounds = Bounds(); + + if (bounds.Width() > fLayoutData->previous_width) { + // invalidate the region between the old and the new right border + BRect rect = bounds; + rect.left += fLayoutData->previous_width - kFrameMargin; + rect.right--; + Invalidate(rect); + } else if (bounds.Width() < fLayoutData->previous_width) { + // invalidate the region of the new right border + BRect rect = bounds; + rect.left = rect.right - kFrameMargin; + Invalidate(rect); + } + + // changes in height + + if (bounds.Height() > fLayoutData->previous_height) { + // invalidate the region between the old and the new bottom border + BRect rect = bounds; + rect.top += fLayoutData->previous_height - kFrameMargin; + rect.bottom--; + Invalidate(rect); + // invalidate label area + rect = bounds; + rect.right = fDivider; + Invalidate(rect); + } else if (bounds.Height() < fLayoutData->previous_height) { + // invalidate the region of the new bottom border + BRect rect = bounds; + rect.top = rect.bottom - kFrameMargin; + Invalidate(rect); + // invalidate label area + rect = bounds; + rect.right = fDivider; + Invalidate(rect); + } + + fLayoutData->previous_width = bounds.Width(); + fLayoutData->previous_height = bounds.Height(); + + TRACE("width: %.2f, height: %.2f\n", bounds.Width(), bounds.Height()); +} + + +status_t +BTextControl::Invoke(BMessage* message) +{ + return BControl::Invoke(message); +} + + +void +BTextControl::LayoutInvalidated(bool descendants) +{ + CALLED(); + + fLayoutData->valid = false; +} + + +void +BTextControl::MessageReceived(BMessage* message) +{ + if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) { + BMessage reply(B_REPLY); + bool handled = false; + + BMessage specifier; + int32 index; + int32 form; + const char* property; + if (message->GetCurrentSpecifier(&index, &specifier, &form, &property) == B_OK) { + if (strcmp(property, "Value") == 0) { + if (message->what == B_GET_PROPERTY) { + reply.AddString("result", fText->Text()); + handled = true; + } else { + const char* value = NULL; + // B_SET_PROPERTY + if (message->FindString("data", &value) == B_OK) { + fText->SetText(value); + reply.AddInt32("error", B_OK); + handled = true; + } + } + } + } + + if (handled) { + message->SendReply(&reply); + return; + } + } + + BControl::MessageReceived(message); +} + + +void +BTextControl::MouseDown(BPoint where) +{ + if (!fText->IsFocus()) + fText->MakeFocus(true); +} + + +void +BTextControl::MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage) +{ + BControl::MouseMoved(where, transit, dragMessage); +} + + +void +BTextControl::MouseUp(BPoint where) +{ + BControl::MouseUp(where); +} + + +void +BTextControl::WindowActivated(bool active) +{ + if (fText->IsFocus()) { + // invalidate to remove/show focus indication + BRect rect = fText->Frame(); + rect.InsetBy(-1, -1); + Invalidate(rect); + + // help out embedded text view which doesn't + // get notified of this + fText->Invalidate(); + } +} + + +// #pragma mark - Getters and Setters + + +void +BTextControl::SetText(const char* text) { if (InvokeKind() != B_CONTROL_INVOKED) return; @@ -326,7 +560,7 @@ BTextControl::SetText(const char *text) } -const char * +const char* BTextControl::Text() const { return fText->Text(); @@ -355,13 +589,6 @@ BTextControl::SetValue(int32 value) } -status_t -BTextControl::Invoke(BMessage *message) -{ - return BControl::Invoke(message); -} - - BTextView* BTextControl::TextView() const { @@ -370,14 +597,14 @@ BTextControl::TextView() const void -BTextControl::SetModificationMessage(BMessage *message) +BTextControl::SetModificationMessage(BMessage* message) { delete fModificationMessage; fModificationMessage = message; } -BMessage * +BMessage* BTextControl::ModificationMessage() const { return fModificationMessage; @@ -409,9 +636,9 @@ BTextControl::GetAlignment(alignment* _label, alignment* _text) const void -BTextControl::SetDivider(float dividingLine) +BTextControl::SetDivider(float position) { - fDivider = floorf(dividingLine + 0.5); + fDivider = floorf(position + 0.5); _LayoutTextView(); @@ -430,143 +657,6 @@ BTextControl::Divider() const void -BTextControl::Draw(BRect updateRect) -{ - bool enabled = IsEnabled(); - bool active = fText->IsFocus() && Window()->IsActive(); - - BRect rect = fText->Frame(); - rect.InsetBy(-2, -2); - - if (be_control_look != NULL) { - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); - uint32 flags = fLook; - if (!enabled) - flags |= BControlLook::B_DISABLED; - if (active) - flags |= BControlLook::B_FOCUSED; - be_control_look->DrawTextControlBorder(this, rect, updateRect, base, - flags); - - if (Label() != NULL) { - if (fLayoutData->label_layout_item != NULL) { - rect = fLayoutData->label_layout_item->FrameInParent(); - } else { - rect = Bounds(); - rect.right = fDivider - kLabelInputSpacing; - } - - be_control_look->DrawLabel(this, Label(), rect, updateRect, - base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); - } - return; - } - - // outer bevel - - rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR); - rgb_color lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT); - rgb_color lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT); - rgb_color darken1 = tint_color(noTint, B_DARKEN_1_TINT); - rgb_color darken2 = tint_color(noTint, B_DARKEN_2_TINT); - rgb_color darken4 = tint_color(noTint, B_DARKEN_4_TINT); - rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); - - if (enabled) - SetHighColor(darken1); - else - SetHighColor(noTint); - - StrokeLine(rect.LeftBottom(), rect.LeftTop()); - StrokeLine(rect.RightTop()); - - if (enabled) - SetHighColor(lighten2); - else - SetHighColor(lighten1); - - StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom()); - StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom()); - - // inner bevel - - rect.InsetBy(1.0f, 1.0f); - - if (active) { - SetHighColor(navigationColor); - StrokeRect(rect); - } else { - if (enabled) - SetHighColor(darken4); - else - SetHighColor(darken2); - - StrokeLine(rect.LeftTop(), rect.LeftBottom()); - StrokeLine(rect.LeftTop(), rect.RightTop()); - - SetHighColor(noTint); - StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom()); - StrokeLine(BPoint(rect.right, rect.top + 1.0f)); - } - - // label - - if (Label()) { - _ValidateLayoutData(); - font_height& fontHeight = fLayoutData->font_info; - - float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent - - fontHeight.descent) / 2 + fontHeight.ascent; - float x; - - float labelWidth = StringWidth(Label()); - switch (fLabelAlign) { - case B_ALIGN_RIGHT: - x = fDivider - labelWidth - kLabelInputSpacing; - break; - - case B_ALIGN_CENTER: - x = fDivider - labelWidth / 2.0; - break; - - default: - x = 0.0; - break; - } - - BRect labelArea(x, Bounds().top, x + labelWidth, Bounds().bottom); - if (x < fDivider && updateRect.Intersects(labelArea)) { - labelArea.right = fText->Frame().left - kLabelInputSpacing; - - BRegion clipRegion(labelArea); - ConstrainClippingRegion(&clipRegion); - SetHighColor(IsEnabled() ? ui_color(B_CONTROL_TEXT_COLOR) - : tint_color(noTint, B_DISABLED_LABEL_TINT)); - DrawString(Label(), BPoint(x, y)); - } - } -} - - -void -BTextControl::MouseDown(BPoint where) -{ - if (!fText->IsFocus()) - fText->MakeFocus(true); -} - - -void -BTextControl::AttachedToWindow() -{ - BControl::AttachedToWindow(); - - _UpdateTextViewColors(IsEnabled()); - fText->MakeEditable(IsEnabled()); -} - - -void BTextControl::MakeFocus(bool state) { if (state != fText->IsFocus()) { @@ -579,30 +669,30 @@ BTextControl::MakeFocus(bool state) void -BTextControl::SetEnabled(bool enabled) +BTextControl::SetEnabled(bool enable) { - if (IsEnabled() == enabled) + if (IsEnabled() == enable) return; - if (Window()) { - fText->MakeEditable(enabled); - if (enabled) + if (Window() != NULL) { + fText->MakeEditable(enable); + if (enable) fText->SetFlags(fText->Flags() | B_NAVIGABLE); else fText->SetFlags(fText->Flags() & ~B_NAVIGABLE); - _UpdateTextViewColors(enabled); + _UpdateTextViewColors(enable); fText->Invalidate(); Window()->UpdateIfNeeded(); } - BControl::SetEnabled(enabled); + BControl::SetEnabled(enable); } void -BTextControl::GetPreferredSize(float *_width, float *_height) +BTextControl::GetPreferredSize(float* _width, float* _height) { CALLED(); @@ -658,42 +748,7 @@ BTextControl::SetFlags(uint32 flags) } -void -BTextControl::MessageReceived(BMessage *message) -{ - if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) { - BMessage reply(B_REPLY); - bool handled = false; - - BMessage specifier; - int32 index; - int32 form; - const char *property; - if (message->GetCurrentSpecifier(&index, &specifier, &form, &property) == B_OK) { - if (strcmp(property, "Value") == 0) { - if (message->what == B_GET_PROPERTY) { - reply.AddString("result", fText->Text()); - handled = true; - } else { - const char* value = NULL; - // B_SET_PROPERTY - if (message->FindString("data", &value) == B_OK) { - fText->SetText(value); - reply.AddInt32("error", B_OK); - handled = true; - } - } - } - } - - if (handled) { - message->SendReply(&reply); - return; - } - } - - BControl::MessageReceived(message); -} +// #pragma mark - Scripting BHandler* @@ -717,119 +772,7 @@ BTextControl::GetSupportedSuites(BMessage* data) } -void -BTextControl::MouseUp(BPoint point) -{ - BControl::MouseUp(point); -} - - -void -BTextControl::MouseMoved(BPoint point, uint32 transit, - const BMessage* dragMessage) -{ - BControl::MouseMoved(point, transit, dragMessage); -} - - -void -BTextControl::DetachedFromWindow() -{ - BControl::DetachedFromWindow(); -} - - -void -BTextControl::AllAttached() -{ - BControl::AllAttached(); -} - - -void -BTextControl::AllDetached() -{ - BControl::AllDetached(); -} - - -void -BTextControl::FrameMoved(BPoint newPosition) -{ - BControl::FrameMoved(newPosition); -} - - -void -BTextControl::FrameResized(float width, float height) -{ - CALLED(); - - BControl::FrameResized(width, height); - - // TODO: this causes flickering still... - - // changes in width - - BRect bounds = Bounds(); - - if (bounds.Width() > fLayoutData->previous_width) { - // invalidate the region between the old and the new right border - BRect rect = bounds; - rect.left += fLayoutData->previous_width - kFrameMargin; - rect.right--; - Invalidate(rect); - } else if (bounds.Width() < fLayoutData->previous_width) { - // invalidate the region of the new right border - BRect rect = bounds; - rect.left = rect.right - kFrameMargin; - Invalidate(rect); - } - - // changes in height - - if (bounds.Height() > fLayoutData->previous_height) { - // invalidate the region between the old and the new bottom border - BRect rect = bounds; - rect.top += fLayoutData->previous_height - kFrameMargin; - rect.bottom--; - Invalidate(rect); - // invalidate label area - rect = bounds; - rect.right = fDivider; - Invalidate(rect); - } else if (bounds.Height() < fLayoutData->previous_height) { - // invalidate the region of the new bottom border - BRect rect = bounds; - rect.top = rect.bottom - kFrameMargin; - Invalidate(rect); - // invalidate label area - rect = bounds; - rect.right = fDivider; - Invalidate(rect); - } - - fLayoutData->previous_width = bounds.Width(); - fLayoutData->previous_height = bounds.Height(); - - TRACE("width: %.2f, height: %.2f\n", bounds.Width(), bounds.Height()); -} - - -void -BTextControl::WindowActivated(bool active) -{ - if (fText->IsFocus()) { - // invalidate to remove/show focus indication - BRect rect = fText->Frame(); - rect.InsetBy(-1, -1); - Invalidate(rect); - - // help out embedded text view which doesn't - // get notified of this - fText->Invalidate(); - } -} +// #pragma mark - Layout BSize @@ -898,15 +841,6 @@ BTextControl::CreateTextViewLayoutItem() void -BTextControl::LayoutInvalidated(bool descendants) -{ - CALLED(); - - fLayoutData->valid = false; -} - - -void BTextControl::DoLayout() { // Bail out, if we shan't do layout. @@ -966,6 +900,9 @@ BTextControl::DoLayout() } +// #pragma mark - protected methods + + status_t BTextControl::SetIcon(const BBitmap* icon, uint32 flags) { @@ -973,7 +910,7 @@ BTextControl::SetIcon(const BBitmap* icon, uint32 flags) } -// #pragma mark - BTextControl private methods +// #pragma mark - private methods status_t @@ -1062,6 +999,9 @@ BTextControl::Perform(perform_code code, void* _data) } +// #pragma mark - FBC padding + + void BTextControl::_ReservedTextControl1() {} void BTextControl::_ReservedTextControl2() {} void BTextControl::_ReservedTextControl3() {} @@ -1076,7 +1016,7 @@ BTextControl::operator=(const BTextControl&) void -BTextControl::_UpdateTextViewColors(bool enabled) +BTextControl::_UpdateTextViewColors(bool enable) { rgb_color textColor; rgb_color color; @@ -1084,7 +1024,7 @@ BTextControl::_UpdateTextViewColors(bool enabled) fText->GetFontAndColor(0, &font); - if (enabled) + if (enable) textColor = ui_color(B_DOCUMENT_TEXT_COLOR); else { textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), @@ -1093,7 +1033,7 @@ BTextControl::_UpdateTextViewColors(bool enabled) fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); - if (enabled) + if (enable) color = ui_color(B_DOCUMENT_BACKGROUND_COLOR); else { color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), @@ -1135,7 +1075,7 @@ BTextControl::_InitData(const char* label, const BMessage* archive) if (flags != 0) SetFont(&font, flags); - if (label) + if (label != NULL) fDivider = floorf(bounds.Width() / 2.0f); fLook = 0; ############################################################################ Revision: hrev48527 Commit: d78a330deb227907f899e0b0d63a136a40716e01 URL: http://cgit.haiku-os.org/haiku/commit/?id=d78a330 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Dec 19 01:46:30 2014 UTC Add BTextControl docs ---------------------------------------------------------------------------- diff --git a/docs/user/interface/TextControl.dox b/docs/user/interface/TextControl.dox new file mode 100644 index 0000000..6906d07 --- /dev/null +++ b/docs/user/interface/TextControl.dox @@ -0,0 +1,546 @@ +/* + * Copyright 2001-2014 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * John Scipione, jscipione@xxxxxxxxx + * + * Corresponds to: + * headers/os/interface/TextControl.h hrev48527 + * src/kits/interface/TextControl.cpp hrev48527 + */ + + +/*! + \file TextControl.h + \ingroup interface + \ingroup libbe + \brief Provides the BTextControl class. +*/ + + +/*! + \class BTextControl + \ingroup interface + \ingroup libbe + \brief Displays a labeled text view control. + + \since BeOS R3 +*/ + + +/*! + \fn BTextControl::BTextControl(BRect frame, const char* name, const char* label, + const char* text, BMessage* message, uint32 resizeMask, uint32 flags) + \brief Creates a new BTextControl object. + + \param frame The frame rectangle of the control. + \param name The (internal) name of the control. + \param label The control's \a label text. + \param text The initial \a text content of the control. + \param message The \a message to send to the control's target in response + to a change. + \param resizeMask Resizing mask, passed to BView. + \param flags \a flags passed to BView. + + \since BeOS R3 +*/ + + +/*! + \fn BTextControl::BTextControl(const char* name, const char* label, + const char* text, BMessage* message, uint32 flags) + \brief Creates a new BTextControl object for use in a BLayout. + + \param name The name of the object. + \param label The control's \a label text. + \param text The initial \a text content of the control. + \param message The \a message to send to the control's target in response + to a change. + \param flags \a flags passed to BView. + + \since Haiku R1 +*/ + + +/*! + \fn BTextControl::BTextControl(const char* label, const char* text, + BMessage* message) + \brief Creates a new BTextControl object, dynamic layout version. + + \param label The control's \a label text. + \param text The initial \a text content of the control. + \param message The \a message to send to the control's target in response + to a change. + + \since Haiku R1 +*/ + + +/*! + \fn BTextControl::BTextControl(BMessage* archive) + \brief Creates a BTextControl object from the passed in \a archive. + + \param archive The BMessage object from which the object is created. + + \since BeOS R3 +*/ + + +/*! + \fn BTextControl::~BTextControl() + \brief Frees the memory allocated and destroys the object. + + \since BeOS R3 +*/ + + +/*! + \name Archiving +*/ + + +//! @{ + + +/*! + \fn BArchivable* BTextControl::Instantiate(BMessage* archive) + \brief Instantiates a BTextControl object from the passed in \a archive. + + \param archive The BMessage object that the object is created from. + + \return A new BTextControl object as a BArchivable. + + \since BeOS R3 +*/ + + +/*! + \fn status_t BTextControl::Archive(BMessage* data, bool deep) const + \brief Archives the object into the \a data message. + + - The label is stored in \c _a_label + - The text is stored in \c _a_text + - The current divider position is stored in \c _divide + (ignored in the BLayout version) + - The modification message is stored in \c _mod_msg + + \param data A pointer to the BMessage object to archive the object into. + \param deep Whether or not to archive child controls as well. + + \return A status code, \c B_OK if everything went well or an error code + otherwise. + \retval B_OK The object was archived. + \retval B_NO_MEMORY Ran out of memory while archiving the object. + + \since BeOS R3 +*/ + + +/*! + \fn status_t BTextControl::AllArchived(BMessage* into) const + \brief Hook method called when all views have been archived. + + \copydetails BView::AllArchived() +*/ + + +/*! + \fn status_t BTextControl::AllUnarchived(const BMessage* from) + \copydetails BView::AllUnarchived() +*/ + + +//! @} + + +/*! + \name Hook Methods +*/ + + +//! @{ + + +/*! + \fn void BTextControl::AllAttached() + \brief Similar to AttachedToWindow() but this method is triggered after + all child views have already been attached to a window. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::AllDetached() + \brief Similar to AttachedToWindow() but this method is triggered after + all child views have already been detached from a window. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::AttachedToWindow() + \brief Sets the font color to \c B_DOCUMENT_TEXT_COLOR and the view and + low colors to \c B_DOCUMENT_BACKGROUND_COLOR. + + If the control is disabled, the font, view, and low colors are set to + \c B_PANEL_BACKGROUND_COLOR is tinted to show a disabled text color and + background instead. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::DetachedFromWindow() + \brief Hook method called when the object is detached from a window. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::Draw(BRect updateRect) + \brief Hook method called to draw the contents of the text control. + + \param updateRect The rectangular area to draw. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::FrameMoved(BPoint newPosition) + \brief Hook method called when the control position is moved. + + \param newPosition The point of the top left corner of the frame + that the view has been moved to. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::FrameResized(float newWidth, float newHeight) + \brief Hook method that is called when the control position is resized. + + This method updates only the parts of the frame that changed. + + \param newWidth The new width of the control. + \param newHeight The new height of the control. + + \since BeOS R3 +*/ + + +/*! + \fn status_t BTextControl::Invoke(BMessage* message) + \brief Sends a copy of the model \a message to the designated target. + + \copydetails BControl::Invoke() +*/ + + +/*! + \fn void BTextControl::LayoutInvalidated(bool descendants) + \brief Hook method called when the layout is invalidated. + + \param descendants Whether or not child views have also been invalidated. + + \since Haiku R1 +*/ + + +/*! + \fn void BTextControl::MessageReceived(BMessage* message) + \brief Handle \a message received by the associated looper. + + \copydetails BView::MessageReceived() +*/ + + +/*! + \fn void BTextControl::MouseDown(BPoint where) + \brief Hook method that is called when a mouse text control is pushed down while + the cursor is contained in the control. + + Focuses the text control. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::MouseMoved(BPoint where, uint32 code, + const BMessage* dragMessage) + \brief Hook method called when the mouse is moved. + + \copydetails BControl::MouseMoved() +*/ + + +/*! + \fn void BTextControl::MouseUp(BPoint where) + \brief Hook method called when a mouse button is released. + + \copydetails BControl::MouseUp() +*/ + + +/*! + \fn void BTextControl::WindowActivated(bool active) + \brief Hook method that is called when the window becomes the active window + or gives up that status. + + Redraw focus indicator and notify the text view. + + \copydetails BView::WindowActivated() +*/ + + +//! @} + + +/*! + \fn void BTextControl::SetText(const char* text) + \brief Sets the text displayed by the BTextControl. + + \since BeOS R3 +*/ + + +/*! + \fn const char* BTextControl::Text() const + \brief Returns the text displayed by the BTextControl. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::MarkAsInvalid(bool invalid) + \brief Sets or removes the invalid flag. + + \since Haiku R1 +*/ + + +/*! + \fn void BTextControl::SetValue(int32 value) + \brief Calls BControl::SetValue(). This isn't particularly useful. + + \copydetails BControl::SetValue() +*/ + + +/*! + \fn BTextView* BTextControl::TextView() const + \brief Returns a pointer to the TextView object. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::SetModificationMessage(BMessage* message) + \brief Assigns \a message to the control, freeing the previously + assigned message. + + Passing NULL deletes the current modification message without replacing it. + + \since BeOS R3 +*/ + + +/*! + \fn BMessage* BTextControl::ModificationMessage() const + \brief Returns the control's modification message. +*/ + + +/*! + \fn void BTextControl::SetAlignment(alignment labelAlignment, + alignment textAlignment) + \brief Set the alignment of the label and the text within the control. + + The default is \c B_ALIGN_LEFT for both label and text. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::GetAlignment(alignment* _label, + alignment* _text) const + \brief Fills out the label and text alignments into \a _label and \a text. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::SetDivider(float position) + \brief Sets the horizontal \a position of the divider that separates the + label from the text view. + + \remark It is not recommended to use this method for text control that are + part of a BLayout. Instead split the label and text view into + separate layout items using CreateLabelLayoutItem() and + CreateTextViewLayoutItem(). This allows you to have better control + over the position of the label and text view portions of your + text control. + + \param position The divider \a position to set, should be an integral value. + + \since BeOS R3 +*/ + + +/*! + \fn float BTextControl::Divider() const + \brief Returns the current divider position. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::MakeFocus(bool focus) + \brief Passes MakeFocus() to the child BTextView. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::SetEnabled(bool enable) + \brief Enables or disables the text control. + + \param enable \c true to enable the control, \c false to disable it. + + \since R3 +*/ + + +/*! + \fn void BTextControl::GetPreferredSize(float* _width, float* _height) + \brief Fills out \a _width and \a _height with the optimal width and + height of the text control to display the label and the text + respectively. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::ResizeToPreferred() + \brief Resizes the text control to its preferred size, keeping its left + and top sides constant while adjusting the width and height of + the text view. + + \warning It is not recommended to use this method for text control that + are part of a BLayout. + + \since BeOS R3 +*/ + + +/*! + \fn void BTextControl::SetFlags(uint32 flags) + \brief Sets the control flags according to the \a flags mask. + + Passes the \c B_NAVIGABLE to the BTextView. + + \since Haiku R1 +*/ + + +/*! + \fn BHandler* BTextControl::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) + \copydoc BHandler::ResolveSpecifier() +*/ + + +/*! + \fn status_t BTextControl::GetSupportedSuites(BMessage* data) + \copydoc BHandler::GetSupportedSuites() +*/ + + +/*! + \fn BSize BTextControl::MinSize() + \brief Returns the text control's minimum size. + + \return The text control's minimum size as a BSize. + + \since Haiku R1 +*/ + + +/*! + \fn BSize BTextControl::MaxSize() + \brief Returns the text control's maximum size. + + \return The text control's maximum size as a BSize. + + \since Haiku R1 +*/ + + +/*! + \fn BSize BTextControl::PreferredSize() + \brief Returns the text control's preferred size. + + \return The text control's preferred size as a BSize. + + \since Haiku R1 +*/ + + +/*! + \fn BAlignment BTextControl::LayoutAlignment() + \brief Returns the alignment used by this control in a layout. + + \since Haiku R1 +*/ + + + +/*! + \fn BLayoutItem* BTextControl::CreateLabelLayoutItem() + \brief Creates a label layout item and returns a pointer to it. + (Layout constructor only) + + \sa CreateTextViewLayoutItem() + + \since Haiku R1 +*/ + + +/*! + \fn BLayoutItem* BTextControl::CreateTextViewLayoutItem() + \brief Creates a text view layout item and returns a pointer to it. + + \sa CreateLabelLayoutItem() + + \since Haiku R1 +*/ + + +/*! + \fn void BTextControl::DoLayout() + \brief Layout view within the layout context. + + \remark This is only meaningful if the view is part of a BLayout. + + \since Haiku R1 +*/ + + +/*! + status_t BTextControl::SetIcon(const BBitmap* icon, uint32 flags) + \copydoc BControl::SetIcon() +*/ \ No newline at end of file