34EVT_MOUSE_EVENTS(GribGrabberWin::OnMouseEvent)
35EVT_PAINT(GribGrabberWin::OnPaint)
44void GribGrabberWin::OnMouseEvent(wxMouseEvent& event) {
45 if (event.RightDown()) {
46 wxMouseEvent evt(event);
47 ((wxEvtHandler*)GetParent())->ProcessEvent(evt);
51 static wxPoint s_gspt;
54 event.GetPosition(&x, &y);
55 wxPoint spt = ClientToScreen(wxPoint(x, y));
58 if (!m_bLeftDown && event.LeftIsDown()) {
61 if (!HasCapture()) CaptureMouse();
62 }
else if (m_bLeftDown && !event.LeftIsDown()) {
65 if (HasCapture()) ReleaseMouse();
69 if (event.LeftDown()) {
76 if (HasCapture()) ReleaseMouse();
80 if (event.Dragging()) {
81 wxPoint par_pos_old = GetParent()->GetPosition();
83 wxPoint par_pos = par_pos_old;
84 par_pos.x += spt.x - s_gspt.x;
85 par_pos.y += spt.y - s_gspt.y;
88 wxPoint pos_in_parent_old =
92 if (pos_in_parent.x < pos_in_parent_old.x) {
93 if (pos_in_parent.x < 10) {
96 }
else if (pos_in_parent.x > pos_in_parent_old.x) {
99 if (pos_in_parent.x > (max_right - 10)) {
100 pos_in_parent.x = max_right;
105 if (pos_in_parent.y < pos_in_parent_old.y) {
106 if (pos_in_parent.y < 10) {
109 }
else if (pos_in_parent.y > pos_in_parent_old.y) {
112 if (pos_in_parent.y > (max_down - 10)) {
113 pos_in_parent.y = max_down;
119 GetParent()->Move(final_pos);
125void GribGrabberWin::OnPaint(wxPaintEvent& event) {
127 dc.DrawBitmap(m_bitmap, 0, 1,
true);
130void GribGrabberWin::Size() {
131 wxBitmap bitmap = (wxBitmap(grabber));
132 int height = GetParent()->GetSize().y - 2;
133 int width = height / 2;
135 wxImage scaled_image = bitmap.ConvertToImage();
136 m_bitmap = wxBitmap(scaled_image.Scale(width, height, wxIMAGE_QUALITY_HIGH));
138 SetSize(wxSize(width, height));
139 SetMinSize(wxSize(width, height));
GRIB Dialog Grabber Control Interface.
wxWindow * GetOCPNCanvasWindow()
Gets OpenCPN's main canvas window.