33EVT_MOUSE_EVENTS(GribGrabberWin::OnMouseEvent)
34EVT_PAINT(GribGrabberWin::OnPaint)
43void GribGrabberWin::OnMouseEvent(wxMouseEvent& event) {
44 if (event.RightDown()) {
45 wxMouseEvent evt(event);
46 ((wxEvtHandler*)GetParent())->ProcessEvent(evt);
50 static wxPoint s_gspt;
53 event.GetPosition(&x, &y);
54 wxPoint spt = ClientToScreen(wxPoint(x, y));
57 if (!m_bLeftDown && event.LeftIsDown()) {
60 if (!HasCapture()) CaptureMouse();
61 }
else if (m_bLeftDown && !event.LeftIsDown()) {
64 if (HasCapture()) ReleaseMouse();
68 if (event.LeftDown()) {
75 if (HasCapture()) ReleaseMouse();
79 if (event.Dragging()) {
80 wxPoint par_pos_old = GetParent()->GetPosition();
82 wxPoint par_pos = par_pos_old;
83 par_pos.x += spt.x - s_gspt.x;
84 par_pos.y += spt.y - s_gspt.y;
86 wxPoint pos_in_parent = GetOCPNCanvasWindow()->ScreenToClient(par_pos);
87 wxPoint pos_in_parent_old =
88 GetOCPNCanvasWindow()->ScreenToClient(par_pos_old);
91 if (pos_in_parent.x < pos_in_parent_old.x) {
92 if (pos_in_parent.x < 10) {
95 }
else if (pos_in_parent.x > pos_in_parent_old.x) {
97 GetOCPNCanvasWindow()->GetClientSize().x - GetParent()->GetSize().x;
98 if (pos_in_parent.x > (max_right - 10)) {
99 pos_in_parent.x = max_right;
104 if (pos_in_parent.y < pos_in_parent_old.y) {
105 if (pos_in_parent.y < 10) {
108 }
else if (pos_in_parent.y > pos_in_parent_old.y) {
110 GetOCPNCanvasWindow()->GetClientSize().y - GetParent()->GetSize().y;
111 if (pos_in_parent.y > (max_down - 10)) {
112 pos_in_parent.y = max_down;
116 wxPoint final_pos = GetOCPNCanvasWindow()->ClientToScreen(pos_in_parent);
118 GetParent()->Move(final_pos);
124void GribGrabberWin::OnPaint(wxPaintEvent& event) {
126 dc.DrawBitmap(m_bitmap, 0, 1,
true);
129void GribGrabberWin::Size() {
130 wxBitmap bitmap = (wxBitmap(grabber));
131 int height = GetParent()->GetSize().y - 2;
132 int width = height / 2;
134 wxImage scaled_image = bitmap.ConvertToImage();
135 m_bitmap = wxBitmap(scaled_image.Scale(width, height, wxIMAGE_QUALITY_HIGH));
137 SetSize(wxSize(width, height));
138 SetMinSize(wxSize(width, height));
GRIB Dialog Grabber Control Interface.