I have a question about layout with TPanels and TcxSplitter from DevExpress.
panellayout http://pp.kpnet.fi/bengtsson/temp/layout.png
The main form has some panels A to G. A - F is collected in one panel ABCDEF.
ABCDEF contains 3 panels:
AB, CDE and F.
Panel CDE contains panel CD.
Between all limits between panels there are a TcxSplitter from DevExpress.
The problem is that the user can take the splitter between ABCDEF and G and move it to left so it reach panel AB and cover panel CDE. I don't want to allow that.
Instead I want panel CDE have a minimum width of say 5 pixels. Then the width of panel AB should be shrinked. Hopefully I explained good enough :)
I have tried to set a constraint.minwidth = 5 on panel CDE but the panel can still be hided. Maybe Devexpress have some nice solution for this ?
Regards
cxSplitter has MinSize property, from what I see in a test app, it is respected when resizing. Since there is only 1 MinSize property, it is checked for panels on either side of splitter, so you can't specify say 50 pixels minimum for one side and 100 for the panel on the other side of the splitter. Make sure the AutoSnap property is false though.
But there is also a OnCanResize event on the splitter, so you can prevent resize there as well.
Also, since you're using devex I would suggest you use either dockSite/dockPanel or LayoutControl v2 instead of plain Delphi TPanel.
Try this property
cxSplitter1.ResizeUpdate:=True;
Related
I use Borland C++ Builder 2009 (yet I assume the issue and solution is the same for Delphi) and right now I assume the answer I'm looking for is the same for both TListView items and TTreeView items. I may be wrong !?
I have noticed, on a smaller Win 8.1 laptop with Display setting 'Change the size of all items' set to 125% . That the items in both TreeView and ListView get closer to each other.
I haven't tested 150% yet, I assume it will be worse.
I would like to adjust for that if possible.
I assume the same logic goes for when a larger sized font is chosen to display these items ?
How would you test if the height of the items is 'too' big and the items need a bit more space between them ?
And how would you increase the spacing between them ? Taking in account that my ListView implementation is virtual (ListView->OwnerData = true ;) !
TForm has Scaled property. If it is true, all components on a form should be resized automatically accordingly to font size. I cannot check right now if this works for TListView and TTreeView, but you should check this property anyway.
As i show a form i display it where it was last time using TForm.Left property i saved on ini file.
I'd like to add support for multiple monitors, because in case of 2 monitors Left can be 2500, so the 2 monitors are seen a a single very wide monitor.
I'd like to save to ini file the monitor number (TForm.Monitor.MonitorNum) but to save the relative Left.
Is there a property that tells Left according to monitor?
e.g. i have 2 1024x768 monitors, one on the right (main) and one on the left (secondary/extended), if i move a form on the right monitor 2 pixels from the left the Left property is 1026. I'd like to say "this is monitor 2 and left is 2".
Thanks.
There's no property of TForm that tells its relative position to the monitor it's on. You have to subtract: Left - Monitor.Left . In your example that would be 1026 - 1024.
Regardless, I don't see any advantage to this approach compared to storing/setting only the left of the form (i.e. 1026). You can use MakeFullyVisible if your concern is monitor arrangement may change between sessions.
In the documentation for TAlignLayout, a type which addresses visual alignment settings for FireMonkey controls, I'm trying to figure out the difference between the alTop and alMostTop constants, the only difference is that the definition of alMostTop contains the phrase "set to be the topmost".
(The same goes for the constants alMostLeft, alMostRight and alMostBottom, which are distinguished from alLeft, alRight and alBottom with similar phrases using the words
"leftmost", "rightmost" and "bottommost".)
I don't know what "set to be the topmost" means, and none of the guesses I make seem to fit with observed FireMonkey behaviour:
If it means displaying that control on top (at the front of the display) relative to its siblings, then what does leftmost mean?
If "leftmost" means it is the sibling shown furthest to the left, out of all siblings that have a alLeft alignment, then why does the CustomListBox demo use a layout with two elements that have a alMostLeft alignment? How does it decide to place the two elements that particular way round?
The Embarcadero forums don't shed any light on this either.
[Update]
To be clear, experiments do indeed suggest that with two components aligned to the top, you can choose which one is to be further up the screen by setting that one to have alMostTop, and the other to alTop.
However, I thought of another possibility: suppose you have two child components, one to be aligned at the left, another aligned at the top. Then they will fight for ownership of the top-left corner. Experiments seem to suggest that some influence can be obtained by choosing between alTop and alMostLeft alignments for the two controls vs alMostTop and alLeft alignments. I can't see exactly what is going on here, and it's not clear in the documentation. It's also not clear what should/might happen if two child controls are both set to alMostTop.
When you have 2 (or more) controls aligned to top, the alMostTop will be on the top of all others. Same wise with alMostRight, alMostLeft, and alMostBottom.
Moving from TBX to SpTBX. I used in the past TTbxDockablePanel which has such props:
DockedWidth
DockedHeight
FloatingWidth
FloatingHeight
I can't find such properties in SpTBX panels, so how should I change my code to use such props? ie. i need to get/set SpTBX panel's docked width/height and floating width/height.
DockedWidth and DockedHeight
A TSpTBXDockablePanel now has a property DefaultDockedSize. A docked panel is docked to either a vertical or horizontal dock, so it only needs one size, which specifies the width (in a vertical dock) or height (in a horizontal dock.) The length of the other axis is a result of either the dock size or the other panels in the same dock. If there are other panels, the size it becomes is the width of the other panels in the dock. If there aren't, it will use either the previous size (if DefaultDockedSize is 0) or try to use DefaultDockedSize.
See TSpTBXCustomDockablePanel.SetParent for the code. You'll be interested in the two branches beginning if ToDock then... and if ToFloating then.... There are some comments there that I've tried to interpret to write the above.
From memory, when I converted from TBX to SpTBX years ago, this was the hardest area to get behaving exactly the same. However, you can get it to behave 'okay', ie with behaviour that makes sense, easily.
FloatingWidth and FloatingHeight
Replaced by FloatingClientWidth and FloatingClientHeight. Note that these are the client sizes not window sizes, but in general they should be direct replacements.
In addition
There is a comment at the top of the SpTBXDkPanels.pas file,
// - To handle the size constraints use GetMinMaxSize when the DP is floating,
// and ConstrainedResize when is Docked (explicitly check if it's docked).
You might find that useful too.
There are a reasonable number of comments scattered through the code. The SpTBX library doesn't have very good documentation, but it does come with high-quality source... Use the source, Luke :)
Please have a look at this screenshot
alt text http://www.maclife.com/files/u18/Yep3-big.jpg
I think these are the main features of such a 'tag panel':
1) Each tag on the panel is a standalone control and can be clicked
2) Auto line wrapping when there is not enough space to show the next tag in the current line.
3) Rounded corner rectangle border for each tag is a nice-to-have feature.
I want to implement the similar function in Delphi, Is there an existing control to do this? If not, what's the best way to implement such a control?
Thank you.
When you are on a recent Delphi version use a TFlowPanel and some appropriate controls for the tags. A simple TButton or a TLinkLabel should do for that.
Each clickable tag doesn't necessarily have to be its own control. It just has to be a region that you can detect being clicked.
Suppose you represent each area as a Windows region. You can figure out how wide each one should be based on its text with the TCanvas.TextExtent function. Then create a region with a function like CreateRectRgn. For rounded corners, try CreateRoundRectRgn instead. You can test for mouse events in each region with the PtInRegion function. You can paint borders around them with FrameRgn. The last obstacle is to draw them on the screen so they'll all fit. You're creating the regions and you know their widths, so assign tags to a row until you run out of space, and then start the next line.
There are two possible solutions to custom alignment in Delphi 7. You can make your own flowpanel by deriving from TCustomPanel and override the AlignControls( )-method, or you can set alignment to alCustom and handle the OnAlignPosition-event.
I guess I would have gone for the TCustomPanel-derivative option. TFlowPanel in form Delphi 2007 uses that option- I have to admit, though, that I have never tried either my self...