How do you replace HBox/VBox with Box/Grid - gtkmm

The documentation for HBox and VBox includes the statement:
Deprecated: Use Box instead, which is a very quick and easy change.
But we recommend switching to Grid, since Box will go away eventually.
However, it isn't obvious what the "quick and easy change" should be.
How do you use Box and/or Grid to achieve the functionality of VBox or HBox?

One of the big changes in gtkmm3:
Gtk::Box, Gtk::ButtonBox, Gtk::IconView, Gtk::Paned, Gtk::ProgressBar,
Gtk::ScaleButton, Gtk::ScrollBar and Gtk::Separator now derive from
Gtk::Orientable, allowing their orientation (vertical or horizontal)
to be specified without requiring the use of a derived class such as
Gtk::HBox.
Although Grid isn't mentioned above, both containers now have a method set_orientation; Box can also take it in the constructor. So for Box, set the orientation and use your usual pack_start, pack_end.
With Grid, if you scrutinize the documentation, you'll see this line:
Grid can be used like a Box by just using Gtk::Container::add(), which
will place children next to each other in the direction determined by
the orientation property.
So, it should be as simple as setting the orientation and then add your child widgets.

Related

Display static map with VueLayers

I tried
:controls="false" on vl-map
The buttons disappear but you can still zoom with trackpad or mouse and move the map
then I tried setting min-view and max-view on vl-view but this has no effect on zoom
then I set the extent on vl-view and that partially works: I cannot move the map but can still zoom
How do you make the map completely static ?
Though i'm not familiar with the Vue-library, Several of the interactions you mention are derived from the "interaction" module, and not the "controls" module. See for example:
https://openlayers.org/en/latest/apidoc/module-ol_interaction_DragRotateAndZoom-DragRotateAndZoom.html
https://openlayers.org/en/latest/apidoc/module-ol_interaction_MouseWheelZoom-MouseWheelZoom.html
I would check if it's possible to remove these interactions the way you removed the controls. Alternatively you can call your map object and use removeInteraction(interaction):
https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#removeInteraction

How to expand wxTextCtrl in wxToolbar?

There is a tool button and a textctrl in the toolbar. I'm trying to expand the textctrl in the horizontal direction to fill all the remaining space.
wxSizer maybe a good choice but it seems not suitable with toolbar because I can't add tool button directly in a sizer.
There is no built in support for this, you will need to handle wxEVT_SIZE (either in the toolbar itself or in the frame containing it, as the size of the toolbar only changes when the size of the frame does), compute the available size (which is going to be tricky, there is no function to find this out neither so I expect you'd have to do some kind of binary search using wxToolBar::FindToolForPosition()) and resize your text control.
It would definitely be much simpler to put both the toolbar and the text in a sizer instead. But it's true that it wouldn't appear quite the same, so if you really want to have the text-inside-toolbar appearance, you would have to do the above. Good luck!

How do I use an indeterminate status indicator as the image for an NSStatusItem?

I have an application that is an NSStatusItem.
It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen.
I want to use the -setImage: method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X.
Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator?) or must I manually display an animation by cycling through a set of images?
In either case, how would I implement?
In order to have it be animated (and not just a static image), you'll probably need to use -setView: and give it a custom view (which then animates itself). You might be able to get away with using a suitably-configured standard NSProgressIndicator (i.e. set to NSProgressIndicatorSpinningStyle style, etc.) as that "custom view".
But, if the NSProgressIndicator standard sizes don't work well, then you can check out my YRKSpinningProgressIndicator (BSD-licensed), which is a clone of the spinning NSProgressIndicator that can be set to arbitrary size and colors.

Changing how IKImageBrowserView indicates the drop position

I can make a single row IKImageBrowserView by setting the
[imageBrowser setContentResizingMask:NSViewWidthSizable];
but in this case while i drag an image inside image browser to rearrange it, the drop place highlights with horizontal line(vertical line expected).
how can this be changed?
Many thanks.
There is no defined way to do what you want.
You may be better off writing your own custom view where you can control every detail of how things are drawn. In general, Apple's controls are "as-is" and unless they provide an explicit way to control behavior or mention that you can custom an object in some way, don't count on being able to do it easily (if at all).
I would also suggest heading to http://bugreport.apple.com and making the enhancement request - it would be best if you attached a sample application demonstrating the behavior.
EDIT: You could also try out the NSCollectionView to see if it might work for you.

Draw Lines on gtk.TextView

I'm trying to show the "selection" of a certain sub-string in a
gtk.TextView by drawing a border around the word. The only way to mark
text in a TextView that I've found so far is by placing TextTags with
modified properties. This does not seem to offer a way to draw a border,
though, DOES GTK SUPPORT THIS OR IS THIS A PROBLEM WITH ONLT PYGTK
I figured out how to draw on a text view !!!
To begin with lets assume the reference to your gtk.TextView is in a variable called viewer, Inside one of ur classes
Also the draw function has to be called with an event called expose-event else the drawings will be refreshed and will not stay on the screen
The next part is the gtk.TextView consists of 7 types of gtk.gdk.windows on which u can draw
gtk.TEXT_WINDOW_WIDGET
gtk.TEXT_WINDOW_TEXT
gtk.TEXT_WINDOW_LEFT - not displayed by default
gtk.TEXT_WINDOW_RIGHT - not displayed by default
gtk.TEXT_WINDOW_TOP - not displayed by default
gtk.TEXT_WINDOW_BOTTOM
gtk.TEXT_WINDOW_PRIVATE
For the drawing to appear on gtk.TextView We have to draw on gtk.TEXT_WINDOW_TEXT
An Example Code is as shown Below
if(viewer!=None):
viewer.connect("expose-event", expose_view)
self.drawable=viewer.get_window(gtk.TEXT_WINDOW_TEXT)
def expose_view(self,window,event):
if(self.drawable!=None):
self.drawable.draw_line(self.drawable.new_gc(),1,1,30,30)
# (1,1) and (30,30) are the coordinates and u can give the values accordingly
In a gtk.TextBuffer tags are used to set one or more pre-defined text attributes. Without subclassing, this is limited to the properties of a gtk.TextTag, and doesn't include anything akin to a border or outline property. There is no difference between PyGTK and plain GTK+ in this regard.
While somewhat hacky, the easiest way to do what you want to do is to connect to the expose-event of your gtk.TextView, get the coordinates of your string and draw on event.window, which is the gdk.Window of the event provided in the expose callback.
(Note that you don't have to get and store the gtk.TEXT_WINDOW_TEXT window, you just need to check what window the expose event is for in the callback, probably ignoring the expose if it's not for the text window.)
Instead, you could presumably subclass one or more of TextBuffer/TextView/TextTag to add a border tag, but whether it's reasonable to do so is another question.