Last active
March 30, 2020 19:47
-
-
Save lighth7015/51987fc010b5efb03ee4f79a62e080fc to your computer and use it in GitHub Desktop.
Dialog designer?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DesignerForm: public wxPanel { | |
DECLARE_DYNAMIC_CLASS( DesignerForm ) | |
DECLARE_EVENT_TABLE() | |
auto Designable(wxControl* instance) { | |
auto handler = [this, instance]( wxMouseEvent& cursor ) { | |
wxControl& control(*instance); | |
wxPrintf ( "Mouse event. ID = %d\n", control.GetId()); | |
}; | |
instance->Bind(wxEVT_LEFT_DOWN, handler); | |
instance->Bind(wxEVT_LEFT_UP, handler); | |
/** | |
* For some reason, the supplied control | |
* can't tell if it is being dragged. | |
*/ | |
instance->Bind(wxEVT_MOTION, handler); | |
return instance; | |
} | |
void OnMouseEvent( wxMouseEvent& cursor ) { | |
if (cursor.Dragging()) { | |
puts( "Dragging event." ); | |
} | |
} | |
protected: | |
static wxColor background; | |
wxControl *active; | |
public: | |
bool Create( wxWindow* parent ) { | |
bool success = false; | |
if (( success = wxPanel::Create( parent, wxID_ANY, wxPoint( 10, 10 ), wxSize( 100, 100 )))) { | |
SetBackgroundColour(background); | |
Designable(new wxButton( this, wxID_ANY )); | |
} | |
return success; | |
} | |
}; | |
IMPLEMENT_CLASS( DesignerForm, wxPanel ) | |
/* | |
* Designer event table definition | |
*/ | |
BEGIN_EVENT_TABLE( DesignerForm, wxPanel ) | |
EVT_MOUSE_EVENTS( DesignerForm::OnMouseEvent ) | |
END_EVENT_TABLE() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment