Hi people i have some questions

he people,

i am running a project since a very long time, now its time to port it peace by peace into the Haiku environment.

i hope that i can publish my project during this year, maybe somewhere in the end.

now the questions:

  1. how can i put an icon to a menuitem, to a window, into a button?

  2. i need a component like a canvas to draw on it. which component is useable for that target and does haiku have onboard drawing commands or do i need an external lib for? i would wish using onboard command, instead of third-party libs.

  3. is there a component to edit mulltine-text onboard or do i need to code it by myself or need a third-party lib?

thanks :slight_smile:

Look here:
The Be Book (haiku-os.org)
The Haiku Book: Welcome to the Haiku Book (haiku-os.org)

hi lelldorin,

i know these sources. i need a bit code sample, because i not really found what i need. maybe i oversaw something. i need more specific information.

Iirc corectly this is not doable with the api

how to do it than? some default apps does have it

Sorry i am only a yab developer, c and cc++ not my world

ok, thanks a lot

You can take a look here:
Learning to Program with Haiku - Jon Yoder - Google Books
Programming With Haiku | Haiku Project (haiku-os.org)

I do not know if the author is descript canvas at all, but it is a good resource.

thank you very much

thanks again

Windows don’t have icons by themselves under Haiku, only applications do. The Application icon can be set in a resource file in rdef format. As an example how this looks like you can look at my app “Peggy” at https://github.com/andimachovec/Peggy . Icon-O-Matic can export in rdef format and I think WonderBrush too. As far as buttons are concerned you can use the BButton class and use a bitmap as icon via the SetIcon function or use the BPictureButton class which lets you specify a BPicture (a set of drawing instructions) as an icon. I don’t know if you can set icons on menu items, I don’t remember seeing it in any Haiku application I’ve used so far

Take a look at the BView class here The Haiku Book: BView Class Reference . Especially the section “Drawing Related”.

BTextView (The Haiku Book: BTextView Class Reference) has basic multiline capabilities.

Hope that gives you some starting points, feel free to ask if you need more specific help

Not that I have any experience with it, but you might try overriding MenuItem::DrawContents(). It looks to me like that’s what it’s for.

1 Like

You can put icons in menuitems but you will have to create your own subclass of BMenuItem and do your icon drawing yourself. You can find an example of this in the Vision IRC client.

Not quite, BPictureButton will draw only the BPicture with nothing around it. BButton::SetIcon is what you should use unless you don’t want your button to look like normal buttons at all.

Thanks for pointing that out. I´ve never used BPicturebutton myself, only looked at the API description. I always used BButton::SetIcon if i needed a button with an image.