Is there a way to put GTK+ widgets in a stack? I.e. put a button over label so that button covers a part of label.
You can use GtkFixed as the layout. This will allow you to control exact locations of the child widgets, and they can overlap.
You'd have to use a Canvas control to explicitly set the positions of the controls - GTK+ works hard to not do what you're describing :)
Packing inside a GtkTable appears to allow this, though I didn't test very far - just juggled it in glade a little.
I'm curious what you're looking to use this to achieve.
Related
I am building a simple interface using a 3 row GtkVbox. Inside middle row, I'd like to show a centered image and a small config panel. If config panel is shown, it must appear over the image. How could I simulate a layered panel where the config panel appers in an upper level than the image. Any ideas?
Regards
Overlaying widgets on top of each other isn't really what GTK is built for - you might be using the wrong tool for the job. Maybe you should check out Clutter?
I believe you can use GtkOverlay to put the panel over the image.
This sounds like a pretty simple thing to do but I havent been able to find an easy way to do this. How do I create a panel with a title and a border which can contain my widgets? I have seen the SectionStack class which provides this. But I dont want to create a section stack.
Window can be added to a layout and drawn. But is it the only way or is there a container class that I am missing?
Also, how does one center things? Say a textfield and a button at the center of the page. How is this achieved?
If you are using a DynamicForm, you can give it a border and title with
form.setIsGroup(true);
form.setGroupTitle(title);
This actually works for Canvas, too (which is the superclass of most widgets and layouts in SmartGWT).
(I just had the same problem, and found this question, as well as the thread Is there a "titled Border" on the SmartGWT Forums, which gave this answer. I tried and it seems to work.)
To do form-related tasks, look into DynamicForm. To set the inputs in the form, you use setItems(Item...). A text field is a TextItem. You set it's title to control the label that SmartGWT will build. To get a title for the form, the best I've come up with is to use a container canvas that will contain both the title (probably a Label element) and the DynamicForm. To center the inputs, I believe you'd need to use setAlignment on the DynamicForm.
You could create an object that is actually a VLayout that contains a Label (the tile), has a border as you need and includes a Canvas (the generic stuff you want included).
In my experience, I noticed that very often I have a DynamicForm visible, so I just add a BlurbItem control to diplay the tile and a small explanation.
I have a project in which I need a way to display essentially a list of tabs, each with their own content pages, down the left side of the page. I'm using TabLayoutPanels elsewhere to good effect, but after looking at how they are constructed it seems like it would be quite a bit of work to undo Google's carefully constructed layout and get it to work in any other orientation than top-aligned.
This doesn't seem like it would be an uncommon layout, so does anyone know of a successful implementation of this kind of container?
Best you can do is use DeckPanel, and make your custom tab controls to switch visible widget in that DeckPanel.
I'm building a GWT app where I want to be able to detect when a user releases a scroll bar on one of my ScrollPanels.
My use case is that the horizontal scroll bar represents time. Since it's impossible to represent the full range of scrollable time I want to just represent a small window of time with the scroll bar. When the user moves and releases the scroll bar I want to do a smooth recentering where the new center is the release point.
I can work out how to do this by building a custom scroll bar widget, but I wanted to check if I was missing some way to do it using a "native" scroll bar first.
You might be able to do it with a ScrollPanel and implementing your own ScrollHandler. Just use the addScrollHandler() method and you should be able to override whatever functionality you need.
However, I would suggest that you re-think your approach. What you seem to really want is a slider control for time, that kind of looks like a scroll bar. You should check out the Composite class and the Widget Gallery to see if there is some combination of Widgets that would suit what you need more. Failing that, I'd also look at SmartGWT. They have a very extensive library of GUI Widgets available, and you may find something you can use already there.
Is there a way to create a "standalone" scrollbar in SWT? I would like to have a scrollbar which I have full control over myself and use it to control the contents of another widget in a way which isn't possible with the "built-in" scrollbars in the Table widget, for example.
I agree that you probably can't get a scrollbar alone, but I've worked around that with using a Canvas ( or ScrolledComposite ) and then set the content of that composite to exactly the same size as the ScrolledComposite.getClientArea(). That may require a bit fine tuning and you have to make sure that the content component resizes together with the ScrolledComposite, but should be possible.
You can then get the Scrollbars of the ScrolledComposite and use them independently of the ScrolledComposite.
You can use the SWT Slider widget for this purpose.
SWT Snippet number 17 for code Example: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet17.java
No, I don't think so. If you look at the jni call for the table, you'll see that it's just a flag into the native call. I'm pretty sure that you can't do what you ask. You could however use Draw2D to get this done fairly quickly. Create a FigueCanvas with eith an XYLayout or a ColumnLayout (I think that's what it's called) and off you go.
There is a better solution!
If you use a ScrolledComposite and use the ScrollBars, the setLocation(int,int) function is called of the internal control to adjust it to the scrollbar position.
If you override this function to really set the location to (0,0), the internal control will not be scrolled anymore.