Programming in Haiku - help wanted!

I have a few question and I would be glad if someone helped me.

  1. Is it possible to send an update message directly to a Replicant? (Now I fake this by having a BMessegeRunner that loads a flattened BMessage from disk).

  2. Is it possible to resize a BWindow automatically to the content of the BListView? (I am using the LayoutBuilder, some ListItems are very wide for instance.)

  3. Is it possible to resise the Replicant in the same manner as/if its possible to resize the window?

Thanks!

  1. Sending a message to a replicant is possible, it is just a regular BView which means it is a BHandler. The difficult part is locating the replicant view. If there isn’t a better way, this can be done using “scripting” (sending messages to the replicant host - DeskBar or Tracker) and asking it to enumerate it’s windows, then views, etc, until you find the one you need. I don’t understand what you did with BMessageRunner and a flattened BMessage, once you have an handle to the replicant, a BMessenger is all you need to send messages to it.

  2. If your window has B_AUTO_UPDATE_SIZE_LIMITS in its flags, it should resize on its own. But there are several things at play here: BListView does its own layouting (the children are not BViews themselves), so first make sure the list itself knows what the right size is. If your BListView is inside a BScrollView as is often the case, the scrollview will say “it’s ok, I don’t need to resize myself, I can scroll instead”, so you need to handle things at that level as well. Sorry for not giving much details here, without trying and debugging the code it’s difficult to say more.

  3. A replicant is more like a view than a window. The APIs to resize are there (ResizeTo, IIRC?), but it is up to you to trigger them. You may also need to notify the host application that your size has changed, as for example Tracker will store the rectangle in the Desktop attributes to restore it at next boot.

2 Likes
  1. I use it as a timer that loads the settings on an intervall. The way you suggested doesnt seem that straightforward as I hoped it would, do you know if there is any example code for this?

2, 3 Thanks. Ill might ignore auto updating UI for this version

Thanks PulkoMandy!

Ok, instead of a timer you could at least use the node monitor to get notified when the file is changed. If you need to store the settings to a file anyways, this may end up being the simplest way.

The other solution is indeed not that straightforward, I’ll see if I can find an example of if.

1 Like

Excellent, I’ve been away for to long, of course I could use node monitoring. Thanks!