more handler

This commit is contained in:
Nishi 2026-04-20 00:09:23 +09:00
commit 98624a9bfa
Signed by: nishi
GPG key ID: 27EF69B208EB9343
2 changed files with 30 additions and 0 deletions

View file

@ -27,6 +27,14 @@ namespace MwCXX {
void SetHasBorder(int value);
int GetInverted();
void SetInverted(int value);
virtual void OnColorChosen(MwRGB value) {};
virtual void OnFileChosen(MwCXX::String value) {};
virtual void OnDirectoryChosen(MwCXX::String value) {};
void (*ColorChosenHandler)(MwCXX::Window* widget, MwRGB value);
void (*FileChosenHandler)(MwCXX::Window* widget, MwCXX::String value);
void (*DirectoryChosenHandler)(MwCXX::Window* widget, MwCXX::String value);
};
}; // namespace MwCXX

View file

@ -62,5 +62,27 @@ void MwCXX::Window::SetInverted(int value) {
MwSetInteger(this->widget, MwNinverted, (int)value);
}
void MwCXX::Window::RegisterHandlers() {
static void __OnColorChosen(MwWidget handle, void* user, void* call) {
((MwCXX::Window*)user)->OnColorChosen(*(MwRGB*)call);
if(((MwCXX::Window*)user)->ColorChosenHandler != NULL) ((MwCXX::Window*)user)->ColorChosenHandler((MwCXX::Window*)user, *(MwRGB*)call);
}
static void __OnFileChosen(MwWidget handle, void* user, void* call) {
((MwCXX::Window*)user)->OnFileChosen((MwCXX::String)(char*)call);
if(((MwCXX::Window*)user)->FileChosenHandler != NULL) ((MwCXX::Window*)user)->FileChosenHandler((MwCXX::Window*)user, (MwCXX::String)(char*)call);
}
static void __OnDirectoryChosen(MwWidget handle, void* user, void* call) {
((MwCXX::Window*)user)->OnDirectoryChosen((MwCXX::String)(char*)call);
if(((MwCXX::Window*)user)->DirectoryChosenHandler != NULL) ((MwCXX::Window*)user)->DirectoryChosenHandler((MwCXX::Window*)user, (MwCXX::String)(char*)call);
}
void MwCXX::Window::RegisterHandlers() {
MwAddUserHandler(this->widget, MwNcolorChosenHandler, __OnColorChosen, (void*)this);
MwAddUserHandler(this->widget, MwNfileChosenHandler, __OnFileChosen, (void*)this);
MwAddUserHandler(this->widget, MwNdirectoryChosenHandler, __OnDirectoryChosen, (void*)this);
this->ColorChosenHandler = NULL;
this->FileChosenHandler = NULL;
this->DirectoryChosenHandler = NULL;
}