projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Misc doc fixes
[wxWidgets.git]
/
samples
/
shaped
/
shaped.cpp
diff --git
a/samples/shaped/shaped.cpp
b/samples/shaped/shaped.cpp
index dee29b4788dfccd2a7aa69e44e5e1bcc7711b1b3..a79b97abbfc1d2ff8bcdf1498e701b2d3869e483 100644
(file)
--- a/
samples/shaped/shaped.cpp
+++ b/
samples/shaped/shaped.cpp
@@
-39,6
+39,7
@@
#include "wx/menu.h"
#include "wx/layout.h"
#include "wx/msgdlg.h"
#include "wx/menu.h"
#include "wx/layout.h"
#include "wx/msgdlg.h"
+ #include "wx/image.h"
#endif
#include "wx/dcclient.h"
#endif
#include "wx/dcclient.h"
@@
-134,6
+135,7
@@
bool MyApp::OnInit()
// Create the main application window
ShapedFrame *frame = new ShapedFrame();
frame->Show(TRUE);
// Create the main application window
ShapedFrame *frame = new ShapedFrame();
frame->Show(TRUE);
+ SetTopWindow(frame);
// success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned FALSE here, the
// success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned FALSE here, the
@@
-148,19
+150,28
@@
bool MyApp::OnInit()
// frame constructor
ShapedFrame::ShapedFrame()
: wxFrame((wxFrame *)NULL, -1, wxEmptyString,
// frame constructor
ShapedFrame::ShapedFrame()
: wxFrame((wxFrame *)NULL, -1, wxEmptyString,
- wxDefaultPosition, wxDefaultSize,
- wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR)
+ wxDefaultPosition, wxSize(100, 100), //wxDefaultSize,
+ 0
+ | wxFRAME_SHAPED
+ | wxSIMPLE_BORDER
+ | wxFRAME_NO_TASKBAR
+ | wxSTAY_ON_TOP
+ )
{
m_hasShape = FALSE;
{
m_hasShape = FALSE;
- m_bmp = wxBitmap(
"star.png"
, wxBITMAP_TYPE_PNG);
+ m_bmp = wxBitmap(
_T("star.png")
, wxBITMAP_TYPE_PNG);
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
-#if wxUSE_TOOLTIP
+#ifndef __WXMAC__
+ // On wxMac the tooltip gets clipped by the window shape, YUCK!!
+#if wxUSE_TOOLTOP
SetToolTip(wxT("Right-click to exit"));
#endif
SetToolTip(wxT("Right-click to exit"));
#endif
-#ifdef __WXMSW__
+#endif
+#ifndef __WXGTK__
// On wxGTK we can't do this yet because the window hasn't been created
// On wxGTK we can't do this yet because the window hasn't been created
- // yet so we wait until the EVT_WINDOW_CREATE event happens. On wxMSW it
- // has been created so we set the shape now.
+ // yet so we wait until the EVT_WINDOW_CREATE event happens. On wxMSW and
+ // wxMac the window has been created at this point so we go ahead and set
+ // the shape now.
SetWindowShape();
#endif
}
SetWindowShape();
#endif
}
@@
-171,7
+182,7
@@
void ShapedFrame::SetWindowShape()
m_hasShape = SetShape(region);
}
m_hasShape = SetShape(region);
}
-void ShapedFrame::OnDoubleClick(wxMouseEvent&
evt
)
+void ShapedFrame::OnDoubleClick(wxMouseEvent&
WXUNUSED(evt)
)
{
if (m_hasShape)
{
{
if (m_hasShape)
{
@@
-186,6
+197,7
@@
void ShapedFrame::OnDoubleClick(wxMouseEvent& evt)
void ShapedFrame::OnLeftDown(wxMouseEvent& evt)
{
CaptureMouse();
void ShapedFrame::OnLeftDown(wxMouseEvent& evt)
{
CaptureMouse();
+ //printf("Mouse captured\n");
wxPoint pos = ClientToScreen(evt.GetPosition());
wxPoint origin = GetPosition();
int dx = pos.x - origin.x;
wxPoint pos = ClientToScreen(evt.GetPosition());
wxPoint origin = GetPosition();
int dx = pos.x - origin.x;
@@
-193,33
+205,38
@@
void ShapedFrame::OnLeftDown(wxMouseEvent& evt)
m_delta = wxPoint(dx, dy);
}
m_delta = wxPoint(dx, dy);
}
-void ShapedFrame::OnLeftUp(wxMouseEvent&
evt
)
+void ShapedFrame::OnLeftUp(wxMouseEvent&
WXUNUSED(evt)
)
{
if (HasCapture())
{
if (HasCapture())
+ {
ReleaseMouse();
ReleaseMouse();
+ //printf("Mouse released\n");
+ }
}
void ShapedFrame::OnMouseMove(wxMouseEvent& evt)
{
}
void ShapedFrame::OnMouseMove(wxMouseEvent& evt)
{
+ wxPoint pt = evt.GetPosition();
+ //printf("x:%d y:%d\n", pt.x, pt.y);
if (evt.Dragging() && evt.LeftIsDown())
{
if (evt.Dragging() && evt.LeftIsDown())
{
- wxPoint pos = ClientToScreen(
evt.GetPosition()
);
+ wxPoint pos = ClientToScreen(
pt
);
Move(wxPoint(pos.x - m_delta.x, pos.y - m_delta.y));
}
}
Move(wxPoint(pos.x - m_delta.x, pos.y - m_delta.y));
}
}
-void ShapedFrame::OnExit(wxMouseEvent&
evt
)
+void ShapedFrame::OnExit(wxMouseEvent&
WXUNUSED(evt)
)
{
Close();
}
{
Close();
}
-void ShapedFrame::OnPaint(wxPaintEvent&
evt
)
+void ShapedFrame::OnPaint(wxPaintEvent&
WXUNUSED(evt)
)
{
wxPaintDC dc(this);
dc.DrawBitmap(m_bmp, 0, 0, TRUE);
}
{
wxPaintDC dc(this);
dc.DrawBitmap(m_bmp, 0, 0, TRUE);
}
-void ShapedFrame::OnWindowCreate(wxWindowCreateEvent&
evt
)
+void ShapedFrame::OnWindowCreate(wxWindowCreateEvent&
WXUNUSED(evt)
)
{
SetWindowShape();
}
{
SetWindowShape();
}