How can i type cast gtkmm window object to gtkmm container
You don't have to - Gtk::Window inherits from Gtk::Container, so you can use any container method on a window.
Some functions in gtkmm do not return an object, but a pointer. So, you have to use RefPtr (https://developer.gnome.org/gtkmm-tutorial/stable/sec-refptr-casting.html.en).
Glib::RefPtr<Gtk::Container> contaier_var =
Glib::RefPtr<Gtk::Window>::cast_dynamic(window_var);
Related
Is it possible to initialize a property of a companion object with some value read from application.properties?
I tried
// #Value("\${my.property.value}") ...doesn't work
val myProp: Duration by lazy { Duration.ofMinutes(#Value("\${my.property.value}")) }
but IntelliJ complains: Expecting an element.
Okay Duration.ofMinutes() requires a Long not a String but how can I achieve this using a configurable value in application.properties?
I solved it by using the #Value annotation in a service class now.
My intention was to have this value read in into a single place near the entity.
The documentation for NSPopUpButton states:
An NSPopUpButton object uses an NSPopUpButtonCell object to implement its user interface.
I derived a new class from NSPopUpButtonCell which implements drawBorderAndBackgroundWithFrame:inView: to achieve custom drawing. In addition, I derived a new class from NSPopUpButton and use cellClass to use my derived class for it. (i.e. I am not working via interface builder.)
With the advent of macOS 10.14 beta however, this routine is not called anymore, and I observe the "normal" (i.e. non-customized) drawing.
Thanks to #Marc T.'s answer, I (think I) was able to localize the problem to the fact that the cell apparently calls drawBorderAndBackgroundWithFrame:inView: only if drawInteriorWithFrame:inView: is implemented in the derived cell.
I could not find solid documentation on this. Is there any?
If there would be such a change in macOS 10.14 I assume Apple would have announced this on WWDC 2018. A quick check in Interface Builder showed me that nothing has changed so far. Creating a subclass of NSPopUpButtonCell to use it as the class for the popup button cell is still working as expected.
What I have to mention is that drawBorderAndBackground is only called if drawInterior is implemented as well. Since I was never using drawBorderAndBackground before, I can not say if this is a change from previous versions to 10.14 or not.
class Cell: NSPopUpButtonCell {
override func drawInterior(withFrame cellFrame: NSRect, in controlView: NSView) {
super.drawInterior(withFrame: cellFrame, in: controlView)
print("drawInterior")
}
override func drawBorderAndBackground(withFrame cellFrame: NSRect, in controlView: NSView) {
super.drawBorderAndBackground(withFrame: cellFrame, in: controlView)
print("drawBorderAndBackground")
}
}
Hope this helps.
I try to do the following:
var properties = ["height" , "width"];
for (var prop in properties){
div.style[prop] = otherdiv.style[prop];
}
But dart doesn't seem to accept this bracket notation, is there any other way to access a property using a string in dart ?
You can use the getPropertyValue and setProperty methods like
div.style.setProperty(prop, otherdiv.style.getPropertyValue(prop));
I am trying to do
property double Real;
and then
double Data::ComplexNumber::Real::get() {
return _real;
}
But it is giving error. How do you go about declaring the methods in the header file and then actually implementing them? Do you use this approach in c++/cli, or you'll go the c#/vb.net way of declaring the classes and implementing right there everything?
OK, this seems to work:
Put the following in the property definition:
property double Real { double get(); void set(double value); }
For a simple property with get and set, you can just put this in the class definition on its own:
property double Real;
and the compiler will sort out the backing store and accessors for you.
How can I hide a Gtk# window that I created in MonoDevelop? I tried the following but it doesn't work:
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build();
this.HideAll();
this.Visible = false;
}
Solution
Calling HideAll() outside the constructor, as tomlog suggested, works. If you want to do some work before showing the window you can
Add an event handler to Window.Shown before calling Build()
Do the work before calling Build() (probably the better alternative in most cases)
I don't think you can call HideAll in the constructor, because the form is not fully initialized and therefore not visible yet.