Alma Retes
2014-01-31 16:02:13 UTC
Hi
I think I found a bug in wxGTK 2.8.12 (Ubuntu 12.04 LTS libwxgtk2.8-0 2.8.12.1-6ubuntu2 )
If I create a wxDialog *without* caption (non-modal version), and then try to move it with EVT_MOTION it stays centered, nothing happens.
Example code parts:
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
EVT_LEFT_DOWN(MyDialog::OnLeftDown)
EVT_LEFT_UP(MyDialog::OnLeftUp)
EVT_MOTION(MyDialog::OnMouseMove)
END_EVENT_TABLE()
bool MyApp::OnInit()
{
this->dialog = new MyDialog(_("test"), wxPoint(0, 0), wxSize(748, 300));
// Center the dialog when first shown
this->dialog->Centre();
// Show it and tell the application that it's our main window
this->dialog->Show(TRUE);
this->SetTopWindow(this->dialog);
}
// Dialog constructor
MyDialog::MyDialog(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxDialog((wxDialog *)NULL, -1, title, pos, size, ~wxCAPTION)
{
}
void MyDialog::OnLeftDown(wxMouseEvent& evt)
{
CaptureMouse();
//printf("Mouse captured\n");
wxPoint pos = ClientToScreen(evt.GetPosition());
wxPoint origin = GetPosition();
int dx = pos.x - origin.x;
int dy = pos .y - origin.y;
m_delta = wxPoint(dx, dy);
// wxMessageOutputStderr err;
// err.Printf(_T("Origin: %i, %i; Delta: %i, %i\n"), origin.x, origin.y, dx, dy);
}
void MyDialog::OnLeftUp(wxMouseEvent& WXUNUSED(evt))
{
if (HasCapture())
{
ReleaseMouse();
//printf("Mouse released\n");
}
}
void MyDialog::OnMouseMove(wxMouseEvent& evt)
{
wxPoint pt = evt.GetPosition();
if (evt.Dragging() && evt.LeftIsDown())
{
wxPoint pos = ClientToScreen(pt);
this->Move( wxPoint(pos.x - m_delta.x, pos.y - m_delta.y) );
wxMessageOutputStderr err;
err.Printf(_T("Move: x= %i, y= %i\n"), pos.x - m_delta.x, pos.y - m_delta.y);
}
}
Has/had anyone similar problem?
I've tried "shaped" from samples, it works, but shaped using wxFrame not wxDialog.
thanks
Attila
I think I found a bug in wxGTK 2.8.12 (Ubuntu 12.04 LTS libwxgtk2.8-0 2.8.12.1-6ubuntu2 )
If I create a wxDialog *without* caption (non-modal version), and then try to move it with EVT_MOTION it stays centered, nothing happens.
Example code parts:
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
EVT_LEFT_DOWN(MyDialog::OnLeftDown)
EVT_LEFT_UP(MyDialog::OnLeftUp)
EVT_MOTION(MyDialog::OnMouseMove)
END_EVENT_TABLE()
bool MyApp::OnInit()
{
this->dialog = new MyDialog(_("test"), wxPoint(0, 0), wxSize(748, 300));
// Center the dialog when first shown
this->dialog->Centre();
// Show it and tell the application that it's our main window
this->dialog->Show(TRUE);
this->SetTopWindow(this->dialog);
}
// Dialog constructor
MyDialog::MyDialog(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxDialog((wxDialog *)NULL, -1, title, pos, size, ~wxCAPTION)
{
}
void MyDialog::OnLeftDown(wxMouseEvent& evt)
{
CaptureMouse();
//printf("Mouse captured\n");
wxPoint pos = ClientToScreen(evt.GetPosition());
wxPoint origin = GetPosition();
int dx = pos.x - origin.x;
int dy = pos .y - origin.y;
m_delta = wxPoint(dx, dy);
// wxMessageOutputStderr err;
// err.Printf(_T("Origin: %i, %i; Delta: %i, %i\n"), origin.x, origin.y, dx, dy);
}
void MyDialog::OnLeftUp(wxMouseEvent& WXUNUSED(evt))
{
if (HasCapture())
{
ReleaseMouse();
//printf("Mouse released\n");
}
}
void MyDialog::OnMouseMove(wxMouseEvent& evt)
{
wxPoint pt = evt.GetPosition();
if (evt.Dragging() && evt.LeftIsDown())
{
wxPoint pos = ClientToScreen(pt);
this->Move( wxPoint(pos.x - m_delta.x, pos.y - m_delta.y) );
wxMessageOutputStderr err;
err.Printf(_T("Move: x= %i, y= %i\n"), pos.x - m_delta.x, pos.y - m_delta.y);
}
}
Has/had anyone similar problem?
I've tried "shaped" from samples, it works, but shaped using wxFrame not wxDialog.
thanks
Attila
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users