Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you pass xpm data into wxStyledTextCtrl MarkerDefinePixmap call? #1186

Open
greatwolf opened this issue Sep 10, 2024 · 2 comments
Open

Comments

@greatwolf
Copy link

greatwolf commented Sep 10, 2024

I'm not sure whether to ask this on here or on wxLua. I'm trying to change the way the breakpoint icon looks on the left margin gutter of the editor and it looks like SCI_MARKERDEFINEPIXMAP is what I'm after.

The corresponding wxlua binding is here https://github.com/pkulchenko/wxlua/blob/4d83c8d44eeccf88683ca0146a13b16d0b0d4264/wxLua/bindings/wxwidgets/wxstc_override.hpp#L86.

What's unclear to me is how to actually pass in that xpm data as const char ** from the lua side. Been banging my head against the wall trying to figure this out. I looked at https://github.com/pkulchenko/wxlua/blob/master/wxLua/docs/binding.md and https://github.com/pkulchenko/wxlua/blob/master/wxLua/docs/wxlua.md. Closest thing I could find is this section:

userdata : A pointer to a C/C++ object.

A metatable (see Lua documentation) may be assigned to it to allow it to act as a table or be called as a function, among other things.
wxLua uses userdata types to wrap the wxWidgets C++ objects to make them useable in a Lua program.

I also looked at some of the wxlua samples like https://github.com/pkulchenko/wxlua/blob/4d83c8d44eeccf88683ca0146a13b16d0b0d4264/wxLua/samples/calculator.wx.lua#L242 and https://github.com/pkulchenko/wxlua/blob/4d83c8d44eeccf88683ca0146a13b16d0b0d4264/wxLua/samples/catch.lua#L601 hoping for some usage hints.

Those examples turn xpm, represented as a table from the lua side, into a wxBitmap and then wxIcon. But using wxBitmap and wxIcon is not a suitable userdata because MarkerDefinePixmap wants to turn it into a const char* const*. I've tried passing it in as a plain lua string, as a lua table, wxBitmap, wxIcon. None of it seems to work.

It feels like I'm missing something simple but what actually is the suitable userdata I should be using here?

@pkulchenko
Copy link
Owner

I suspect you may be right, as it looks like a direct translation of the API without a good way to provide that parameter. In fact, other interface files have comments to the effect that wxlua doesn't handle const char* const* parameters.

Would using MarkerDefineRGBAImage or MarkerDefineBitmap work (the latter is not available with wxwidgets 3.1.3+)?

I think it will be better to change MarkerDefinePixmap(int markerNumber, const char* const* xpmData); to MarkerDefinePixmap(int markerNumber, const char* xpmData); to allow passing a string with xpmData content.

@greatwolf
Copy link
Author

I'll have to take a look at MarkerDefineRGBAImage and MarkerDefineBitmap -- those could probably work. I was looking at MarkerDefinePixmap because scintilla provides some icons https://www.scintilla.org/Icons.html and they're in xpm format.

That said, the current MarkerDefinePixmap does seem like a design defect if there isn't a convenient way to use it from lua side. Changing it to accept either a lua string or lua table seems to make sense to me.

@greatwolf greatwolf changed the title How do you past xpm data into wxStyledTextCtrl MarkerDefinePixmap call? How do you pass xpm data into wxStyledTextCtrl MarkerDefinePixmap call? Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants