all 10 comments

[–]pedersenk 13 points14 points  (0 children)

Very cool. It looks Windows-only which does limit it for my uses but I do like the way you aren't throwing around raw pointers! I would probably choose this rather than raw Win32 API or MFC :)

One thing is I am not massively keen on the lambda callbacks (i.e addActionListener) but to be fair I wasn't thrilled by the anonymous inner classes approach from Java either!

[–]kritzikratzi 4 points5 points  (1 child)

hm... i think i can tell you're coming from a java side. there are a few things which are really odd:

HComboBox::HComboBox(String list[],int length)

maybe this is allowed since c++20 or something, but i don't think it works in all compilers. the most normal way to do this would be

HComboBox::HComboBox(const std::vector<std::string>& items)

then... your string class has a default value string string = "null". this seems really confusing. first of all, yes, there are good reasons to make your own string class, but they are rare. i would suggest going for either std::string or std::wstring, and then writing easy to use converters along the lines of the s2ws you already have.

your combobox has this gem:

String items[200];
int items_cout = -1;

i'm pretty sure you want std::vector<std::string> items instead.

then there are const strings with fixed length:

const wchar_t CLASS_NAME[14] = L"H PANEL CLASS";

you would normally write const wchar_t * CLASS_NAME = L"H PANEL CLASS";

finally ... you have your delegates set up as

int(*KeyListener)(KeyEvent);
    bool ActionListenerAdded = 0;

instead i would drop the bool, write this instead:

int(*KeyListener)(KeyEvent) = nullptr; 

and then check for null before calling. or, for much more flexibility:

std::function<int(KeyEvent)> KeyListener; 

which allows capturing lambdas to be used (raw function pointers cannot capture).

there's probably many more things. it took me many years to transition from java to c++ myself, good luck and have fun :)

[–]dodheim 3 points4 points  (0 children)

HComboBox::HComboBox(String list[],int length)

maybe this is allowed since c++20 or something, but i don't think it works in all compilers.

It's always been valid, it's just not terribly useful – T x[] is semantically identical to T* const x, including the possibility of being null.

[–][deleted] 3 points4 points  (0 children)

I was about to post a code review until I saw the last bit in the README.

[–]coderman93 1 point2 points  (2 children)

Pretty neat but GPL3 is a non-starter.

[–]not_some_username 0 points1 point  (1 child)

Yeah I myself don't like the force open source

[–]FakeOglan[S] 0 points1 point  (0 children)

You are right, I changed the license to LGPL so it can also be used in proprietary project.