Opened 14 years ago
Last modified 8 years ago
#6015 assigned enhancement
BTextView in manual layout does not reformat its text when resized
Reported by: | Trezker | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Kits/Interface Kit | Version: | R1/alpha2 |
Keywords: | BTextView | Cc: | |
Blocked By: | Blocking: | ||
Platform: | All |
Description (last modified by )
The textRect isn't resized when the BTextView instance is.
I looked through TextView.cpp and found that it should work properly if _ResetTextRect() is called in BTextView::FrameResized.
BTextView::FrameResized(float width, float height) { BView::FrameResized(width, height); + _ResetTextRect(); _UpdateScrollbars(); }
Change History (9)
follow-up: 8 comment:1 by , 14 years ago
Description: | modified (diff) |
---|
comment:2 by , 14 years ago
It disturbs me a bit that I can't trivially make a textview reformat on resize. Either I'd like to have a option to do .ReformatOnResize(true) that would activate this behaviour.
Or, since I think subclassing textview may be common when you this behaviour is wanted. Make _ResetTextRect() public so you can get the behaviour easily in your override of FrameResized().
comment:3 by , 14 years ago
Do you use the new layout management when building the interface? I was meaning to say that it is intended to work to your expectations when you do that. If not, it's a bug.
comment:4 by , 14 years ago
No I'm not. Since I didn't find the documentation for the layout management I wasn't aware of it before reporting this.
I still think it would be a good idea if this behaviour was available even without layout management. If it is added through introducing a new option in the class it won't interfere with any old software.
comment:5 by , 14 years ago
Ok, now I've tested using layout management and that doesn't do reformatting either. Here's the code I used to create the layout.
textview = new BTextView(BRect(0, 0, 200, 100), NULL, BRect(10, 10, 180, 80), B_FOLLOW_ALL_SIDES); SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder()
.Add(textview)
);
Still, I have not found any documentation on layout management and the information I did find suggests it will not even be publicly available for quite some time...
comment:6 by , 14 years ago
This is not using the layout management properly. You need to use the constructor that does not take the frame BRect, since then the flags will include B_SUPPORTS_LAYOUT in the BView base class. You also do not need to call SetLayout() at all. I suggest looking at one of the many Haiku apps that already use layouting. IIRC Icon-O-Matic, or MidiPlayer as a minimal example.
About your other comment, yes I can see how that would be useful. On the other hand, manual layout should just be discouraged completely... :-)
comment:7 by , 14 years ago
Summary: | BTextView does not reformat its text when resized → BTextView in manual layout does not reformat its text when resized |
---|---|
Type: | bug → enhancement |
I see, now it works. I was wondering about the logic of the constructor I was using in a layout managed textview, but the new constructors aren't in the BeBook.
Since this works in layout manage mode, and the non reformatting behaviour of manually layouted textviews seems to be standard for old applications sake. I change this ticket to be an enhancement suggestion to add an function that makes a textview reformat on resize.
comment:8 by , 14 years ago
Replying to stippi:
This cannot be changed for backwards compatibility reasons. Orginial BeOS software will override BTextView::FrameResized() and manually call SetTextRect().
So where is the problem? They either do override it (and would then duplicate functionality), or they don't - in which case the extra code shouldn't harm. The only remaining question is if we should put any effort in improving the non-layout implementation of the BViews, as that is likely going to be phased out, anyway.
comment:9 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
This cannot be changed for backwards compatibility reasons. Orginial BeOS software will override BTextView::FrameResized() and manually call SetTextRect(). When you use a BTextControl in nay layout managed code, it's supposed to work automatically. I suppose it happens in DoLayout(), but I am not sure off the top of my head.