This commit was manufactured by cvs2svn to create branch
'WX_2_4_BRANCH'. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19871 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
7
samples/shaped/.cvsignore
Normal file
7
samples/shaped/.cvsignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
shapedM5.mcp
|
||||||
|
shapedM*Data
|
||||||
|
*Classic?Debug*
|
||||||
|
*Classic?Release*
|
||||||
|
*Carbon?Debug*
|
||||||
|
*Carbon?Release*
|
||||||
|
shaped
|
16
samples/shaped/Makefile.in
Normal file
16
samples/shaped/Makefile.in
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Purpose: makefile for shaped example (UNIX).
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
top_srcdir = @top_srcdir@/..
|
||||||
|
top_builddir = ../..
|
||||||
|
program_dir = samples/shaped
|
||||||
|
|
||||||
|
DATAFILES=star.png
|
||||||
|
PROGRAM=shaped
|
||||||
|
|
||||||
|
OBJECTS =$(PROGRAM).o
|
||||||
|
DEPFILES=$(PROGRAM).d
|
||||||
|
|
||||||
|
include ../../src/makeprog.env
|
||||||
|
|
||||||
|
@IF_GNU_MAKE@-include $(DEPFILES)
|
47
samples/shaped/descrip.mms
Normal file
47
samples/shaped/descrip.mms
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#*****************************************************************************
|
||||||
|
# *
|
||||||
|
# Make file for VMS *
|
||||||
|
# Author : J.Jansen (joukj@hrem.stm.tudelft.nl) *
|
||||||
|
# Date : 4 October 2000 *
|
||||||
|
# *
|
||||||
|
#*****************************************************************************
|
||||||
|
.first
|
||||||
|
define wx [--.include.wx]
|
||||||
|
|
||||||
|
.ifdef __WXMOTIF__
|
||||||
|
CXX_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)\
|
||||||
|
/assume=(nostdnew,noglobal_array_new)
|
||||||
|
.else
|
||||||
|
.ifdef __WXGTK__
|
||||||
|
CXX_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/ieee=denorm\
|
||||||
|
/assume=(nostdnew,noglobal_array_new)
|
||||||
|
.else
|
||||||
|
CXX_DEFINE =
|
||||||
|
.endif
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.suffixes : .cpp
|
||||||
|
|
||||||
|
.cpp.obj :
|
||||||
|
cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp
|
||||||
|
|
||||||
|
all :
|
||||||
|
.ifdef __WXMOTIF__
|
||||||
|
$(MMS)$(MMSQUALIFIERS) shaped.exe
|
||||||
|
.else
|
||||||
|
.ifdef __WXGTK__
|
||||||
|
$(MMS)$(MMSQUALIFIERS) shaped_gtk.exe
|
||||||
|
.endif
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.ifdef __WXMOTIF__
|
||||||
|
shaped.exe : shaped.obj
|
||||||
|
cxxlink shaped,[--.lib]vms/opt
|
||||||
|
.else
|
||||||
|
.ifdef __WXGTK__
|
||||||
|
shaped_gtk.exe : shaped.obj
|
||||||
|
cxxlink/exec=shaped_gtk.exe shaped,[--.lib]vms_gtk/opt
|
||||||
|
.endif
|
||||||
|
.endif
|
||||||
|
|
||||||
|
shaped.obj : shaped.cpp
|
10
samples/shaped/makefile.b32
Normal file
10
samples/shaped/makefile.b32
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Purpose: makefile for shaped example (BC++ 32bit)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
WXDIR = $(WXWIN)
|
||||||
|
|
||||||
|
TARGET=shaped
|
||||||
|
OBJECTS = $(TARGET).obj
|
||||||
|
|
||||||
|
!include $(WXDIR)\src\makeprog.b32
|
||||||
|
|
14
samples/shaped/makefile.bcc
Normal file
14
samples/shaped/makefile.bcc
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Purpose: makefile for shaped example (BC++ 16bit)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
!if "$(WXWIN)" == ""
|
||||||
|
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||||
|
!endif
|
||||||
|
|
||||||
|
WXDIR = $(WXWIN)
|
||||||
|
|
||||||
|
TARGET=shaped
|
||||||
|
OBJECTS=$(TARGET).obj
|
||||||
|
|
||||||
|
!include $(WXDIR)\src\makeprog.bcc
|
||||||
|
|
10
samples/shaped/makefile.dos
Normal file
10
samples/shaped/makefile.dos
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Purpose: makefile for shaped example (VC++ 1.5x)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
WXDIR = $(WXWIN)
|
||||||
|
|
||||||
|
TARGET=shaped
|
||||||
|
OBJECTS=$(TARGET).obj
|
||||||
|
|
||||||
|
!include $(WXDIR)\src\makeprog.msc
|
||||||
|
|
10
samples/shaped/makefile.g95
Normal file
10
samples/shaped/makefile.g95
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Purpose: makefile for shaped example (Cygwin/Mingw32)
|
||||||
|
# Created: #03.01.00
|
||||||
|
|
||||||
|
WXDIR = ../..
|
||||||
|
|
||||||
|
TARGET=shaped
|
||||||
|
OBJECTS = $(TARGET).o
|
||||||
|
|
||||||
|
include $(WXDIR)/src/makeprog.g95
|
||||||
|
|
37
samples/shaped/makefile.sc
Normal file
37
samples/shaped/makefile.sc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Purpose: makefile for shaped example (Symantec C++)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
WXDIR = $(WXWIN)
|
||||||
|
WXLIB = $(WXDIR)\lib\wx.lib
|
||||||
|
INCDIR = $(WXDIR)\include
|
||||||
|
INCLUDE=$(INCDIR)
|
||||||
|
TARGET=shaped
|
||||||
|
|
||||||
|
include $(WXDIR)\src\makesc.env
|
||||||
|
|
||||||
|
shaped.exe: shaped.obj $(DEFFILE) shaped.res
|
||||||
|
*$(CC) $(LDFLAGS) -o$@ $** $(LIBS)
|
||||||
|
*$(RC) -k shaped.res
|
||||||
|
|
||||||
|
sc32.def:
|
||||||
|
echo EXETYPE NT > sc32.def
|
||||||
|
echo SUBSYSTEM WINDOWS >> sc32.def
|
||||||
|
|
||||||
|
sc16.def:
|
||||||
|
echo NAME $(TARGET) > sc16.def
|
||||||
|
echo EXETYPE WINDOWS >> sc16.def
|
||||||
|
echo STUB 'WINSTUB.EXE' >> sc16.def
|
||||||
|
echo CODE PRELOAD MOVEABLE DISCARDABLE >> sc16.def
|
||||||
|
echo DATA PRELOAD MOVEABLE MULTIPLE >> sc16.def
|
||||||
|
echo HEAPSIZE 1024 >> sc16.def
|
||||||
|
echo STACKSIZE 8192 >> sc16.def
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-del *.obj
|
||||||
|
-del *.exe
|
||||||
|
-del *.res
|
||||||
|
-del *.map
|
||||||
|
-del *.rws
|
||||||
|
-del sc32.def
|
||||||
|
-del sc16.def
|
||||||
|
|
14
samples/shaped/makefile.sl
Normal file
14
samples/shaped/makefile.sl
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Purpose: makefile for shaped example (Salford C++)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
PROGRAM = shaped
|
||||||
|
OBJECTS = $(PROGRAM).obj
|
||||||
|
|
||||||
|
include ..\..\src\makeprog.sl
|
||||||
|
|
||||||
|
all: wx $(TARGET)
|
||||||
|
|
||||||
|
wx:
|
||||||
|
cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all
|
||||||
|
cd $(WXDIR)\samples\shaped
|
||||||
|
|
35
samples/shaped/makefile.twn
Normal file
35
samples/shaped/makefile.twn
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Purpose: makefile for shaped example (TWIN)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
WXDIR = ../..
|
||||||
|
|
||||||
|
# All common UNIX compiler flags and options are now in
|
||||||
|
# this central makefile.
|
||||||
|
include $(WXDIR)/src/maketwin.env
|
||||||
|
|
||||||
|
OBJECTS = $(OBJDIR)/shaped.$(OBJSUFF) $(OBJDIR)/shaped.$(OBJSUFF)
|
||||||
|
|
||||||
|
all: $(OBJDIR) shaped$(GUISUFFIX)$(EXESUFF)
|
||||||
|
|
||||||
|
wx:
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
shaped$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
|
||||||
|
$(CC) $(LDFLAGS) -o shaped$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
|
||||||
|
|
||||||
|
$(OBJDIR)/shaped.$(OBJSUFF): shaped.$(SRCSUFF)
|
||||||
|
$(CC) -c $(CPPFLAGS) -o $@ shaped.$(SRCSUFF)
|
||||||
|
|
||||||
|
shaped.c: shaped.rc
|
||||||
|
$(RESCOMP) $(RCINPUTSWITCH) shaped.rc $(RCOUTPUTSWITCH) shaped.c $(RESFLAGS)
|
||||||
|
|
||||||
|
$(OBJDIR)/shaped.$(OBJSUFF): shaped.c
|
||||||
|
$(CC) -c $(CPPFLAGS) -o $@ shaped.c
|
||||||
|
|
||||||
|
#$(OBJDIR)/shaped.o: shaped.rc
|
||||||
|
# $(RESCOMP) $(RCINPUTSWITCH) shaped.rc $(RCOUTPUTSWITCH) $(OBJDIR)/shaped.o $(RESFLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJECTS) shaped$(GUISUFFIX).exe core *.rsc *.res
|
23
samples/shaped/makefile.unx
Normal file
23
samples/shaped/makefile.unx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Purpose: makefile for shaped example (Unix)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
CXX = $(shell wx-config --cxx)
|
||||||
|
|
||||||
|
PROGRAM = shaped
|
||||||
|
|
||||||
|
OBJECTS = $(PROGRAM).o
|
||||||
|
|
||||||
|
# implementation
|
||||||
|
|
||||||
|
.SUFFIXES: .o .cpp
|
||||||
|
|
||||||
|
.cpp.o :
|
||||||
|
$(CXX) -c `wx-config --cxxflags` -o $@ $<
|
||||||
|
|
||||||
|
all: $(PROGRAM)
|
||||||
|
|
||||||
|
$(PROGRAM): $(OBJECTS)
|
||||||
|
$(CXX) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o $(PROGRAM)
|
11
samples/shaped/makefile.vc
Normal file
11
samples/shaped/makefile.vc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Purpose: makefile for shaped example (VC++ 32bit)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
# Set WXDIR for your system
|
||||||
|
WXDIR = $(WXWIN)
|
||||||
|
|
||||||
|
PROGRAM=shaped
|
||||||
|
OBJECTS = $(PROGRAM).obj
|
||||||
|
|
||||||
|
!include $(WXDIR)\src\makeprog.vc
|
||||||
|
|
11
samples/shaped/makefile.wat
Normal file
11
samples/shaped/makefile.wat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Purpose: makefile for shaped example (Watcom)
|
||||||
|
# Created: 2000-01-03
|
||||||
|
|
||||||
|
WXDIR = $(%WXWIN)
|
||||||
|
|
||||||
|
PROGRAM = shaped
|
||||||
|
OBJECTS = $(PROGRAM).obj
|
||||||
|
|
||||||
|
!include $(WXDIR)\src\makeprog.wat
|
||||||
|
|
||||||
|
|
224
samples/shaped/shaped.cpp
Normal file
224
samples/shaped/shaped.cpp
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: shaped.cpp
|
||||||
|
// Purpose: Shaped Window sample
|
||||||
|
// Author: Robin Dunn
|
||||||
|
// Modified by:
|
||||||
|
// Created: 28-Mar-2003
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Robin Dunn
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||||
|
#pragma implementation "shaped.cpp"
|
||||||
|
#pragma interface "shaped.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// for all others, include the necessary headers
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/app.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/frame.h"
|
||||||
|
#include "wx/panel.h"
|
||||||
|
#include "wx/stattext.h"
|
||||||
|
#include "wx/menu.h"
|
||||||
|
#include "wx/layout.h"
|
||||||
|
#include "wx/msgdlg.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/dcclient.h"
|
||||||
|
#include "wx/image.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Define a new application type, each program should derive a class from wxApp
|
||||||
|
class MyApp : public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// override base class virtuals
|
||||||
|
// ----------------------------
|
||||||
|
|
||||||
|
// this one is called on application startup and is a good place for the app
|
||||||
|
// initialization (doing it here and not in the ctor allows to have an error
|
||||||
|
// return: if OnInit() returns false, the application terminates)
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Define a new frame type: this is going to be our main frame
|
||||||
|
class ShapedFrame : public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctor(s)
|
||||||
|
ShapedFrame();
|
||||||
|
void SetWindowShape();
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnDoubleClick(wxMouseEvent& evt);
|
||||||
|
void OnLeftDown(wxMouseEvent& evt);
|
||||||
|
void OnLeftUp(wxMouseEvent& evt);
|
||||||
|
void OnMouseMove(wxMouseEvent& evt);
|
||||||
|
void OnExit(wxMouseEvent& evt);
|
||||||
|
void OnPaint(wxPaintEvent& evt);
|
||||||
|
void OnWindowCreate(wxWindowCreateEvent& evt);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_hasShape;
|
||||||
|
wxBitmap m_bmp;
|
||||||
|
wxPoint m_delta;
|
||||||
|
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// event tables and other macros for wxWindows
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// the event tables connect the wxWindows events with the functions (event
|
||||||
|
// handlers) which process them. It can be also done at run-time, but for the
|
||||||
|
// simple menu events like this the static method is much simpler.
|
||||||
|
BEGIN_EVENT_TABLE(ShapedFrame, wxFrame)
|
||||||
|
EVT_LEFT_DCLICK(ShapedFrame::OnDoubleClick)
|
||||||
|
EVT_LEFT_DOWN(ShapedFrame::OnLeftDown)
|
||||||
|
EVT_LEFT_UP(ShapedFrame::OnLeftUp)
|
||||||
|
EVT_MOTION(ShapedFrame::OnMouseMove)
|
||||||
|
EVT_RIGHT_UP(ShapedFrame::OnExit)
|
||||||
|
|
||||||
|
EVT_PAINT(ShapedFrame::OnPaint)
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
EVT_WINDOW_CREATE(ShapedFrame::OnWindowCreate)
|
||||||
|
#endif
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
|
// the application object during program execution (it's better than using a
|
||||||
|
// static object for many reasons) and also declares the accessor function
|
||||||
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
||||||
|
// not wxApp)
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// the application class
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// `Main program' equivalent: the program execution "starts" here
|
||||||
|
bool MyApp::OnInit()
|
||||||
|
{
|
||||||
|
wxInitAllImageHandlers();
|
||||||
|
|
||||||
|
// Create the main application window
|
||||||
|
ShapedFrame *frame = new ShapedFrame();
|
||||||
|
frame->Show(TRUE);
|
||||||
|
|
||||||
|
// success: wxApp::OnRun() will be called which will enter the main message
|
||||||
|
// loop and the application will run. If we returned FALSE here, the
|
||||||
|
// application would exit immediately.
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// main frame
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
ShapedFrame::ShapedFrame()
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, wxEmptyString,
|
||||||
|
wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR)
|
||||||
|
{
|
||||||
|
m_hasShape = FALSE;
|
||||||
|
m_bmp = wxBitmap("star.png", wxBITMAP_TYPE_PNG);
|
||||||
|
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
|
||||||
|
SetToolTip(wxT("Right-click to exit"));
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// 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.
|
||||||
|
SetWindowShape();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::SetWindowShape()
|
||||||
|
{
|
||||||
|
wxRegion region(m_bmp, *wxWHITE);
|
||||||
|
m_hasShape = SetShape(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnDoubleClick(wxMouseEvent& evt)
|
||||||
|
{
|
||||||
|
if (m_hasShape)
|
||||||
|
{
|
||||||
|
wxRegion region;
|
||||||
|
SetShape(region);
|
||||||
|
m_hasShape = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetWindowShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnLeftDown(wxMouseEvent& evt)
|
||||||
|
{
|
||||||
|
CaptureMouse();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnLeftUp(wxMouseEvent& evt)
|
||||||
|
{
|
||||||
|
if (HasCapture())
|
||||||
|
ReleaseMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnMouseMove(wxMouseEvent& evt)
|
||||||
|
{
|
||||||
|
if (evt.Dragging() && evt.LeftIsDown())
|
||||||
|
{
|
||||||
|
wxPoint pos = ClientToScreen(evt.GetPosition());
|
||||||
|
Move(wxPoint(pos.x - m_delta.x, pos.y - m_delta.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnExit(wxMouseEvent& evt)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnPaint(wxPaintEvent& evt)
|
||||||
|
{
|
||||||
|
wxPaintDC dc(this);
|
||||||
|
dc.DrawBitmap(m_bmp, 0, 0, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapedFrame::OnWindowCreate(wxWindowCreateEvent& evt)
|
||||||
|
{
|
||||||
|
SetWindowShape();
|
||||||
|
}
|
||||||
|
|
154
samples/shaped/shaped.dsp
Normal file
154
samples/shaped/shaped.dsp
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
# Microsoft Developer Studio Project File - Name="shaped" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||||
|
|
||||||
|
CFG=shaped - Win32 Debug
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "shaped.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "shaped.mak" CFG="shaped - Win32 Debug"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "shaped - Win32 Release DLL" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "shaped - Win32 Debug DLL" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "shaped - Win32 Release" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "shaped - Win32 Debug" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
MTL=midl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "shaped - Win32 Release DLL"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "ReleaseDll"
|
||||||
|
# PROP BASE Intermediate_Dir "ReleaseDll"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "ReleaseDll"
|
||||||
|
# PROP Intermediate_Dir "ReleaseDll"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MD /D WXUSINGDLL /I..\..\lib\mswdll
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG" /I "../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG" /I "../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386 ..\..\lib\wxmsw250.lib
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "shaped - Win32 Debug DLL"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "DebugDll"
|
||||||
|
# PROP BASE Intermediate_Dir "DebugDll"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "DebugDll"
|
||||||
|
# PROP Intermediate_Dir "DebugDll"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /Zi /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MDd /D "__WXDEBUG__" /D "WXDEBUG=1" /D WXUSINGDLL /I..\..\lib\mswdlld
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG" /I "../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG" /I "../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept ..\..\lib\wxmsw250d.lib
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "shaped - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MD /I..\..\lib\msw
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG" /I "../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG" /I "../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /machine:I386 ..\..\lib\zlib.lib ..\..\lib\regex.lib ..\..\lib\png.lib ..\..\lib\jpeg.lib ..\..\lib\tiff.lib ..\..\lib\wxmsw.lib
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "shaped - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W4 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W4 /Zi /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D WINVER=0x400 /D WIN32 /D WINVER=0x400 /D _MT /D wxUSE_GUI=1 /YX /FD /c /MDd /D "__WXDEBUG__" /D "WXDEBUG=1" /I..\..\lib\mswd
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG" /I "../../include"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG" /I "../../include"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept ..\..\lib\zlibd.lib ..\..\lib\regexd.lib ..\..\lib\pngd.lib ..\..\lib\jpegd.lib ..\..\lib\tiffd.lib ..\..\lib\wxmswd.lib
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "shaped - Win32 Release DLL"
|
||||||
|
# Name "shaped - Win32 Debug DLL"
|
||||||
|
# Name "shaped - Win32 Release"
|
||||||
|
# Name "shaped - Win32 Debug"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\shaped.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\shaped.rc
|
||||||
|
# End Source File
|
||||||
|
# End Target
|
||||||
|
# End Project
|
2
samples/shaped/shaped.rc
Normal file
2
samples/shaped/shaped.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
3685
samples/shaped/shapedM5.xml
Normal file
3685
samples/shaped/shapedM5.xml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
samples/shaped/star.png
Normal file
BIN
samples/shaped/star.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
119
src/common/rgncmn.cpp
Normal file
119
src/common/rgncmn.cpp
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: rgncmn.cpp
|
||||||
|
// Purpose: Methods of wxRegion that have a generic implementation
|
||||||
|
// Author: Robin Dunn
|
||||||
|
// Modified by:
|
||||||
|
// Created: 27-Mar-2003
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Robin Dunn
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "rgncmn.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/region.h"
|
||||||
|
#include "wx/bitmap.h"
|
||||||
|
#include "wx/image.h"
|
||||||
|
#include "wx/dcmemory.h"
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxBitmap wxRegion::ConvertToBitmap() const
|
||||||
|
{
|
||||||
|
wxRect box = GetBox();
|
||||||
|
wxBitmap bmp(box.GetRight(), box.GetBottom());
|
||||||
|
wxMemoryDC dc;
|
||||||
|
dc.SelectObject(bmp);
|
||||||
|
dc.SetBackground(*wxWHITE_BRUSH);
|
||||||
|
dc.Clear();
|
||||||
|
dc.SetClippingRegion(*this);
|
||||||
|
dc.SetBackground(*wxBLACK_BRUSH);
|
||||||
|
dc.Clear();
|
||||||
|
dc.SelectObject(wxNullBitmap);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxRegion::Union(const wxBitmap& bmp,
|
||||||
|
const wxColour& transColour,
|
||||||
|
int tolerance)
|
||||||
|
{
|
||||||
|
unsigned char loR, loG, loB;
|
||||||
|
unsigned char hiR, hiG, hiB;
|
||||||
|
|
||||||
|
wxCHECK_MSG((bmp.GetMask() != NULL) || transColour.Ok(),
|
||||||
|
FALSE,
|
||||||
|
wxT("Either the bitmap should have a mask or a colour should be given."));
|
||||||
|
|
||||||
|
wxImage image = bmp.ConvertToImage();
|
||||||
|
|
||||||
|
if (image.HasMask())
|
||||||
|
{
|
||||||
|
loR = image.GetMaskRed();
|
||||||
|
loG = image.GetMaskGreen();
|
||||||
|
loB = image.GetMaskBlue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loR = transColour.Red();
|
||||||
|
loG = transColour.Green();
|
||||||
|
loB = transColour.Blue();
|
||||||
|
}
|
||||||
|
|
||||||
|
hiR = wxMin(0xFF, loR + tolerance);
|
||||||
|
hiG = wxMin(0xFF, loG + tolerance);
|
||||||
|
hiB = wxMin(0xFF, loB + tolerance);
|
||||||
|
|
||||||
|
// Loop through the image row by row, pixel by pixel, building up
|
||||||
|
// rectangles to add to the region.
|
||||||
|
int width = image.GetWidth();
|
||||||
|
int height = image.GetHeight();
|
||||||
|
for (int y=0; y < height; y++)
|
||||||
|
{
|
||||||
|
wxRect rect;
|
||||||
|
rect.y = y;
|
||||||
|
rect.height = 1;
|
||||||
|
|
||||||
|
for (int x=0; x < width; x++)
|
||||||
|
{
|
||||||
|
// search for a continuous range of non-transparent pixels
|
||||||
|
int x0 = x;
|
||||||
|
while ( x < width)
|
||||||
|
{
|
||||||
|
unsigned char R = image.GetRed(x,y);
|
||||||
|
unsigned char G = image.GetGreen(x,y);
|
||||||
|
unsigned char B = image.GetBlue(x,y);
|
||||||
|
if (( R >= loR && R <= hiR) &&
|
||||||
|
( G >= loG && G <= hiG) &&
|
||||||
|
( B >= loB && B <= hiB)) // It's transparent
|
||||||
|
break;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the run of non-transparent pixels (if any) to the region
|
||||||
|
if (x > x0) {
|
||||||
|
rect.x = x0;
|
||||||
|
rect.width = x - x0;
|
||||||
|
Union(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
Reference in New Issue
Block a user