win32: add wx, and preliminary 3d viewer work. i am not necessarily committed to wx yet, the bulk of the work is still refactoring in the core emulator. (also slow down release fastbuilds by improving gpu.cpp build speed)

This commit is contained in:
zeromus 2009-12-14 08:54:15 +00:00
parent 4f997b7dba
commit b8cbaf2828
746 changed files with 151584 additions and 602 deletions

View File

@ -1,4 +1,4 @@
0.9.5 -> 0.9.6 (r3075-r3107-r3xxx)
0.9.5 -> 0.9.6 (r3075-r3153-r3xxx)
General/Core:
bug: emulate keypad interrupt
@ -6,6 +6,7 @@ General/Core:
bug: fix rom close memory corruption
bug: fix div and sqrt busy flag bug
bug: fix vectest
bug: fix lid savestate desync
enh: support devkitpro argv
enh: add gbaslot-rom commandline
@ -15,8 +16,14 @@ Graphics:
Windows:
bug: fix 16bpp display
bug: more fixes to multi-gamepads
bug: cheat windows robustification
enh: add EPX and EPX1.5X resize filters
enh: add a japanese translation which will soon be stale like the others
enh: add fancy printscreen with emulator info on it
Linux/OSX:
bug: fix building for nosse2 systems
enh: add --nojoy=1 to fix laptops with accelerometers
0.9.4 -> 0.9.5 (r2437-r3075)

View File

@ -38,12 +38,12 @@
#include "NDSSystem.h"
#include "readwrite.h"
//#ifdef FASTBUILD
// #undef FORCEINLINE
// #define FORCEINLINE
// //compilation speed hack (cuts time exactly in half by cutting out permutations)
// #define DISABLE_MOSAIC
//#endif
#ifdef FASTBUILD
#undef FORCEINLINE
#define FORCEINLINE
//compilation speed hack (cuts time exactly in half by cutting out permutations)
#define DISABLE_MOSAIC
#endif
extern BOOL click;
NDS_Screen MainScreen;

View File

@ -8,7 +8,7 @@ SUBDIRS = . gdbstub $(UI_DIR)
else
SUBDIRS = . $(UI_DIR)
endif
DIST_SUBDIRS = . gdbstub cli cocoa gtk gtk-glade
DIST_SUBDIRS = . gdbstub cli cocoa gtk gtk-glade wxdlg
noinst_LIBRARIES = libdesmume.a
libdesmume_a_SOURCES = \
armcpu.cpp armcpu.h \
@ -18,7 +18,7 @@ libdesmume_a_SOURCES = \
bios.cpp bios.h bits.h cp15.cpp cp15.h \
commandline.h commandline.cpp \
common.cpp common.h \
debug.cpp debug.h driver.h \
debug.cpp debug.h driver.cpp driver.h \
Disassembler.cpp Disassembler.h \
emufile.h emufile.cpp fat.h FIFO.cpp FIFO.h \
firmware.cpp firmware.h GPU.cpp GPU.h \

View File

@ -683,7 +683,7 @@ static void BeginRenderPoly()
{
lastEnvMode = envMode;
int _envModes[4] = {0, 1, (2 + gfx3d.shading), 0};
int _envModes[4] = {0, 1, (2 + gfx3d.state.shading), 0};
glUniform1i(texBlendLoc, _envModes[envMode]);
}
}
@ -721,16 +721,16 @@ static void InstallPolygonAttrib(unsigned long val)
static void Control()
{
if(gfx3d.enableTexturing) glEnable (GL_TEXTURE_2D);
if(gfx3d.state.enableTexturing) glEnable (GL_TEXTURE_2D);
else glDisable (GL_TEXTURE_2D);
if(gfx3d.enableAlphaTest)
if(gfx3d.state.enableAlphaTest)
// FIXME: alpha test should pass gfx3d.alphaTestRef==poly->getAlpha
glAlphaFunc (GL_GREATER, gfx3d.alphaTestRef/31.f);
glAlphaFunc (GL_GREATER, gfx3d.state.alphaTestRef/31.f);
else
glAlphaFunc (GL_GREATER, 0);
if(gfx3d.enableAlphaBlending)
if(gfx3d.state.enableAlphaBlending)
{
glEnable (GL_BLEND);
}
@ -825,21 +825,23 @@ static void OGLRender()
//generate a 8888 toon table from the ds format one and store it in a texture
u32 rgbToonTable[32];
for(int i=0;i<32;i++) rgbToonTable[i] = RGB15TO32(gfx3d.u16ToonTable[i], 255);
for(int i=0;i<32;i++)
rgbToonTable[i] = RGB15TO32(gfx3d.state.u16ToonTable[i], 255);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbToonTable);
}
xglDepthMask(GL_TRUE);
float clearColor[4] = {
((float)(gfx3d.clearColor&0x1F))/31.0f,
((float)((gfx3d.clearColor>>5)&0x1F))/31.0f,
((float)((gfx3d.clearColor>>10)&0x1F))/31.0f,
((float)((gfx3d.clearColor>>16)&0x1F))/31.0f,
((float)(gfx3d.state.clearColor&0x1F))/31.0f,
((float)((gfx3d.state.clearColor>>5)&0x1F))/31.0f,
((float)((gfx3d.state.clearColor>>10)&0x1F))/31.0f,
((float)((gfx3d.state.clearColor>>16)&0x1F))/31.0f,
};
glClearColor(clearColor[0],clearColor[1],clearColor[2],clearColor[3]);
glClearDepth(gfx3d.clearDepth);
glClearStencil((gfx3d.clearColor >> 24) & 0x3F);
glClearDepth(gfx3d.state.clearDepth);
glClearStencil((gfx3d.state.clearColor >> 24) & 0x3F);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
@ -854,7 +856,7 @@ static void OGLRender()
// int lastProjIndex = -1;
for(int i=0;i<gfx3d.polylist->count;i++) {
POLY *poly = &gfx3d.polylist->list[gfx3d.indexlist[i]];
POLY *poly = &gfx3d.polylist->list[gfx3d.indexlist.list[i]];
int type = poly->type;
//a very macro-level state caching approach:

170
desmume/src/driver.cpp Normal file
View File

@ -0,0 +1,170 @@
/* driver.cpp
Copyright (C) 2009 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "types.h"
#include "driver.h"
#include "rasterize.h"
#include "gfx3d.h"
#ifdef _MSC_VER
#define USE_WX
#endif
#ifdef USE_WX
#include "wx/wxprec.h"
#include "wxdlg/wxdlg3dViewer.h"
const int kVewportWidth = 512;
static SoftRasterizerEngine engine;
static Fragment _screen[kVewportWidth*384];
static FragmentColor _screenColor[kVewportWidth*384];
extern void _HACK_Viewer_ExecUnit(SoftRasterizerEngine* engine);
class Mywxdlg3dViewer : public wxdlg3dViewer
{
public:
Mywxdlg3dViewer()
: wxdlg3dViewer(NULL)
{}
virtual void RepaintPanel()
{
Refresh(false);
Update();
}
void RedrawPanel(wxClientDC* dc)
{
//------------
//do the 3d work..
engine.polylist = &viewer3d_state.polylist;
engine.vertlist = &viewer3d_state.vertlist;
engine.indexlist = &viewer3d_state.indexlist;
engine.screen = _screen;
engine.screenColor = _screenColor;
engine.width = kVewportWidth;
engine.height = 384;
engine.updateFogTable();
engine.initFramebuffer(kVewportWidth,384,gfx3d.state.enableClearImage);
engine.updateToonTable();
engine.updateFloatColors();
engine.performClipping(checkMaterialInterpolate->IsChecked());
engine.performViewportTransforms<true>(kVewportWidth,384);
engine.performBackfaceTests();
engine.performCoordAdjustment(false);
engine.setupTextures(false);
_HACK_Viewer_ExecUnit(&engine);
//------------
//dc.SetBackground(*wxGREEN_BRUSH); dc.Clear();
u8 framebuffer[kVewportWidth*384*3];
for(int y=0,i=0;y<384;y++)
for(int x=0;x<kVewportWidth;x++,i++) {
framebuffer[i*3] = _screenColor[i].r<<2;
framebuffer[i*3+1] = _screenColor[i].g<<2;
framebuffer[i*3+2] = _screenColor[i].b<<2;
}
wxImage image(kVewportWidth,384,framebuffer,true);
wxBitmap bitmap(image);
dc->DrawBitmap(bitmap,0,0);
}
virtual void _OnPaintPanel( wxPaintEvent& event )
{
wxPaintDC dc(wxDynamicCast(event.GetEventObject(), wxWindow));
RedrawPanel(&dc);
}
};
class VIEW3D_Driver_WX : public VIEW3D_Driver
{
public:
VIEW3D_Driver_WX()
: viewer(NULL)
{}
~VIEW3D_Driver_WX()
{
delete viewer;
}
virtual bool IsRunning() { return viewer != NULL; }
virtual void Launch()
{
if(viewer) return;
delete viewer;
viewer = new Mywxdlg3dViewer();
viewer->Show(true);
}
void Close()
{
delete viewer;
viewer = NULL;
}
virtual void NewFrame()
{
if(!viewer) return;
if(!viewer->IsShown()) {
Close();
return;
}
viewer->RepaintPanel();
}
private:
Mywxdlg3dViewer *viewer;
};
#endif
static VIEW3D_Driver nullView3d;
BaseDriver::BaseDriver()
: view3d(NULL)
{
VIEW3D_Shutdown();
}
void BaseDriver::VIEW3D_Shutdown()
{
if(view3d != &nullView3d) delete view3d;
view3d = &nullView3d;
}
void BaseDriver::VIEW3D_Init()
{
VIEW3D_Shutdown();
#ifdef USE_WX
view3d = new VIEW3D_Driver_WX();
#endif
}
BaseDriver::~BaseDriver()
{
}

View File

@ -27,9 +27,20 @@
#include "debug.h"
#include <stdio.h>
class VIEW3D_Driver
{
public:
virtual void Launch() {}
virtual void NewFrame() {}
virtual bool IsRunning() { return false; }
};
//each platform needs to implement this, although it doesnt need to implement any functions
class BaseDriver {
public:
BaseDriver();
~BaseDriver();
virtual bool WIFI_Host_InitSystem() { return FALSE; }
virtual void WIFI_Host_ShutdownSystem() {}
@ -60,6 +71,10 @@ public:
};
virtual void DEBUG_UpdateIORegView(eDebug_IOReg category) { }
VIEW3D_Driver* view3d;
void VIEW3D_Shutdown();
void VIEW3D_Init();
};
extern BaseDriver* driver;

View File

@ -45,7 +45,6 @@
#include "readwrite.h"
#include "FIFO.h"
#include <queue>
//#include "movie.h"
/*
thoughts on flush timing:
@ -64,8 +63,6 @@ But since we're not sure how we'll eventually want this, I am leaving it sort of
in this function: */
static void gfx3d_doFlush();
#define TESTS_ENABLED 1
#define INVALID_COMMAND 0xFF
#define UNDEFINED_COMMAND 0xCC
static const u8 gfx3d_commandTypes[] = {
@ -261,6 +258,7 @@ using std::max;
using std::min;
GFX3D gfx3d;
Viewer3d_State viewer3d_state;
static GFX3D_Clipper boxtestClipper;
//tables that are provided to anyone
@ -381,8 +379,7 @@ static u32 lightColor[4] = {0,0,0,0};
static u32 lightDirection[4] = {0,0,0,0};
//material state:
static u16 dsDiffuse, dsAmbient, dsSpecular, dsEmission;
// Shininess
static float shininessTable[128] = {0};
//used for indexing the shininess table during parameters to shininess command
static int shininessInd = 0;
@ -565,7 +562,7 @@ void gfx3d_reset()
memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen));
gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(0x7FFF);
gfx3d.state.clearDepth = gfx3d_extendDepth_15_to_24(0x7FFF);
clInd2 = 0;
isSwapBuffers = FALSE;
@ -1147,7 +1144,7 @@ static void gfx3d_glNormal(u32 v)
if(dsSpecular & 0x8000)
{
int shininessIndex = (int)(shininessLevel * 128);
if(shininessIndex >= (int)ARRAY_SIZE(shininessTable)) {
if(shininessIndex >= (int)ARRAY_SIZE(gfx3d.state.shininessTable)) {
//we can't print this right now, because when a game triggers this it triggers it _A_LOT_
//so wait until we have per-frame diagnostics.
//this was tested using Princess Debut (US) after proceeding through the intro and getting the tiara.
@ -1159,7 +1156,7 @@ static void gfx3d_glNormal(u32 v)
//PROGINFO("ERROR: shininess table out of bounds.\n maybe an emulator error; maybe a non-unit normal; setting to 0\n");
shininessIndex = 0;
}
shininessLevel = shininessTable[shininessIndex];
shininessLevel = gfx3d.state.shininessTable[shininessIndex];
}
for(c = 0; c < 3; c++)
@ -1345,10 +1342,10 @@ static void gfx3d_glLightColor (u32 v)
static BOOL gfx3d_glShininess (u32 val)
{
shininessTable[shininessInd++] = ((val & 0xFF) / 256.0f);
shininessTable[shininessInd++] = (((val >> 8) & 0xFF) / 256.0f);
shininessTable[shininessInd++] = (((val >> 16) & 0xFF) / 256.0f);
shininessTable[shininessInd++] = (((val >> 24) & 0xFF) / 256.0f);
gfx3d.state.shininessTable[shininessInd++] = ((val & 0xFF) / 256.0f);
gfx3d.state.shininessTable[shininessInd++] = (((val >> 8) & 0xFF) / 256.0f);
gfx3d.state.shininessTable[shininessInd++] = (((val >> 16) & 0xFF) / 256.0f);
gfx3d.state.shininessTable[shininessInd++] = (((val >> 24) & 0xFF) / 256.0f);
if (shininessInd < 128) return FALSE;
shininessInd = 0;
@ -1450,8 +1447,8 @@ static BOOL gfx3d_glBoxTest(u32 v)
//setup the clipper
GFX3D_Clipper::TClippedPoly tempClippedPoly;
boxtestClipper.clippedPolyCounter = 0;
boxtestClipper.clippedPolys = &tempClippedPoly;
boxtestClipper.reset();
////-----------------------------
////awesome hack:
@ -1500,7 +1497,7 @@ static BOOL gfx3d_glBoxTest(u32 v)
&verts[poly->vertIndexes[3]]
};
boxtestClipper.clipPoly(poly,vertTable);
boxtestClipper.clipPoly<false>(poly,vertTable);
//if any portion of this poly was retained, then the test passes.
if(boxtestClipper.clippedPolyCounter>0) {
@ -1523,9 +1520,7 @@ static BOOL gfx3d_glPosTest(u32 v)
//this is apparently tested by transformers decepticons and ultimate spiderman
//printf("POSTEST\n");
#ifdef TESTS_ENABLED
MMU_new.gxstat.tb = 1;
#endif
PTcoords[PTind++] = float16table[v & 0xFFFF];
PTcoords[PTind++] = float16table[v >> 16];
@ -1584,23 +1579,23 @@ void VIEWPORT::decode(u32 v)
void gfx3d_glClearColor(u32 v)
{
gfx3d.clearColor = v;
gfx3d.state.clearColor = v;
}
void gfx3d_glFogColor(u32 v)
{
gfx3d.fogColor = v;
gfx3d.state.fogColor = v;
}
void gfx3d_glFogOffset (u32 v)
{
gfx3d.fogOffset = (v&0x7fff);
gfx3d.state.fogOffset = (v&0x7fff);
}
void gfx3d_glClearDepth(u32 v)
{
v &= 0x7FFF;
gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(v);
gfx3d.state.clearDepth = gfx3d_extendDepth_15_to_24(v);
}
// Ignored for now
@ -1622,14 +1617,14 @@ int gfx3d_GetNumVertex()
void gfx3d_UpdateToonTable(u8 offset, u16 val)
{
gfx3d.u16ToonTable[offset] = val;
gfx3d.state.u16ToonTable[offset] = val;
}
void gfx3d_UpdateToonTable(u8 offset, u32 val)
{
//C.O.P. sets toon table via this method
gfx3d.u16ToonTable[offset] = val & 0xFFFF;
gfx3d.u16ToonTable[offset+1] = val >> 16;
gfx3d.state.u16ToonTable[offset] = val & 0xFFFF;
gfx3d.state.u16ToonTable[offset+1] = val >> 16;
}
s32 gfx3d_GetClipMatrix (unsigned int index)
@ -1658,7 +1653,7 @@ void gfx3d_ClearStack()
void gfx3d_glAlphaFunc(u32 v)
{
gfx3d.alphaTestRef = v&31;
gfx3d.state.alphaTestRef = v&31;
}
unsigned int gfx3d_glGetPosRes(unsigned int index)
@ -1861,8 +1856,8 @@ void gfx3d_execute3D()
void gfx3d_glFlush(u32 v)
{
//printf("-------------FLUSH------------- (vcount=%d\n",nds.VCount);
gfx3d.sortmode = BIT0(v);
gfx3d.wbuffer = BIT1(v);
gfx3d.state.sortmode = BIT0(v);
gfx3d.state.wbuffer = BIT1(v);
#if 0
if (isSwapBuffers)
{
@ -1913,17 +1908,17 @@ static void gfx3d_doFlush()
gfx3d.vertlist = vertlist;
//and also our current render state
if(BIT1(control)) gfx3d.shading = GFX3D::HIGHLIGHT;
else gfx3d.shading = GFX3D::TOON;
gfx3d.enableTexturing = BIT0(control);
gfx3d.enableAlphaTest = BIT2(control);
gfx3d.enableAlphaBlending = BIT3(control);
gfx3d.enableAntialiasing = BIT4(control);
gfx3d.enableEdgeMarking = BIT5(control);
gfx3d.enableFogAlphaOnly = BIT6(control);
gfx3d.enableFog = BIT7(control);
gfx3d.enableClearImage = BIT14(control);
gfx3d.fogShift = (control>>8)&0xF;
if(BIT1(control)) gfx3d.state.shading = GFX3D_State::HIGHLIGHT;
else gfx3d.state.shading = GFX3D_State::TOON;
gfx3d.state.enableTexturing = BIT0(control);
gfx3d.state.enableAlphaTest = BIT2(control);
gfx3d.state.enableAlphaBlending = BIT3(control);
gfx3d.state.enableAntialiasing = BIT4(control);
gfx3d.state.enableEdgeMarking = BIT5(control);
gfx3d.state.enableFogAlphaOnly = BIT6(control);
gfx3d.state.enableFog = BIT7(control);
gfx3d.state.enableClearImage = BIT14(control);
gfx3d.state.fogShift = (control>>8)&0xF;
int polycount = polylist->count;
@ -1956,31 +1951,40 @@ static void gfx3d_doFlush()
for(int i=0;i<polycount;i++) {
POLY &poly = polylist->list[i];
if(!poly.isTranslucent())
gfx3d.indexlist[ctr++] = i;
gfx3d.indexlist.list[ctr++] = i;
}
int opaqueCount = ctr;
//then look for translucent polys
for(int i=0;i<polycount;i++) {
POLY &poly = polylist->list[i];
if(poly.isTranslucent())
gfx3d.indexlist[ctr++] = i;
gfx3d.indexlist.list[ctr++] = i;
}
//now we have to sort the opaque polys by y-value.
//(test case: harvest moon island of happiness character cretor UI)
//should this be done after clipping??
std::sort(gfx3d.indexlist, gfx3d.indexlist + opaqueCount, gfx3d_ysort_compare);
std::sort(gfx3d.indexlist.list, gfx3d.indexlist.list + opaqueCount, gfx3d_ysort_compare);
if(!gfx3d.sortmode)
if(!gfx3d.state.sortmode)
{
//if we are autosorting translucent polys, we need to do this also
//TODO - this is unverified behavior. need a test case
std::sort(gfx3d.indexlist + opaqueCount, gfx3d.indexlist + polycount, gfx3d_ysort_compare);
std::sort(gfx3d.indexlist.list + opaqueCount, gfx3d.indexlist.list + polycount, gfx3d_ysort_compare);
}
//switch to the new lists
twiddleLists();
if(driver->view3d->IsRunning())
{
viewer3d_state.state = gfx3d.state;
viewer3d_state.polylist = *gfx3d.polylist;
viewer3d_state.vertlist = *gfx3d.vertlist;
viewer3d_state.indexlist = gfx3d.indexlist;
driver->view3d->NewFrame();
}
drawPending = TRUE;
}
@ -2192,26 +2196,26 @@ SFORMAT SF_GFX3D[]={
{ "GMEM", 2, 1, &dsEmission},
{ "GFLP", 4, 1, &flushPending},
{ "GDRP", 4, 1, &drawPending},
{ "GSET", 4, 1, &gfx3d.enableTexturing},
{ "GSEA", 4, 1, &gfx3d.enableAlphaTest},
{ "GSEB", 4, 1, &gfx3d.enableAlphaBlending},
{ "GSEX", 4, 1, &gfx3d.enableAntialiasing},
{ "GSEE", 4, 1, &gfx3d.enableEdgeMarking},
{ "GSEC", 4, 1, &gfx3d.enableClearImage},
{ "GSEF", 4, 1, &gfx3d.enableFog},
{ "GSEO", 4, 1, &gfx3d.enableFogAlphaOnly},
{ "GFSH", 4, 1, &gfx3d.fogShift},
{ "GSSH", 4, 1, &gfx3d.shading},
{ "GSWB", 4, 1, &gfx3d.wbuffer},
{ "GSSM", 4, 1, &gfx3d.sortmode},
{ "GSAR", 1, 1, &gfx3d.alphaTestRef},
{ "GSET", 4, 1, &gfx3d.state.enableTexturing},
{ "GSEA", 4, 1, &gfx3d.state.enableAlphaTest},
{ "GSEB", 4, 1, &gfx3d.state.enableAlphaBlending},
{ "GSEX", 4, 1, &gfx3d.state.enableAntialiasing},
{ "GSEE", 4, 1, &gfx3d.state.enableEdgeMarking},
{ "GSEC", 4, 1, &gfx3d.state.enableClearImage},
{ "GSEF", 4, 1, &gfx3d.state.enableFog},
{ "GSEO", 4, 1, &gfx3d.state.enableFogAlphaOnly},
{ "GFSH", 4, 1, &gfx3d.state.fogShift},
{ "GSSH", 4, 1, &gfx3d.state.shading},
{ "GSWB", 4, 1, &gfx3d.state.wbuffer},
{ "GSSM", 4, 1, &gfx3d.state.sortmode},
{ "GSAR", 1, 1, &gfx3d.state.alphaTestRef},
{ "GSVP", 4, 1, &viewport},
{ "GSCC", 4, 1, &gfx3d.clearColor},
{ "GSCD", 4, 1, &gfx3d.clearDepth},
{ "GSFC", 4, 4, &gfx3d.fogColor},
{ "GSFO", 4, 1, &gfx3d.fogOffset},
{ "GST2", 2, 32, gfx3d.u16ToonTable},
{ "GSST", 4, 128, shininessTable},
{ "GSCC", 4, 1, &gfx3d.state.clearColor},
{ "GSCD", 4, 1, &gfx3d.state.clearDepth},
{ "GSFC", 4, 4, &gfx3d.state.fogColor},
{ "GSFO", 4, 1, &gfx3d.state.fogOffset},
{ "GST2", 2, 32, gfx3d.state.u16ToonTable},
{ "GSST", 4, 128, &gfx3d.state.shininessTable[0]},
{ "GSSI", 4, 1, &shininessInd},
//------------------------
{ "GTST", 4, 1, &triStripToggle},
@ -2328,7 +2332,7 @@ static T interpolate(const float ratio, const T& x0, const T& x1) {
//http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/as6/discussion.shtml
#ifdef OPTIMIZED_CLIPPING_METHOD
template<int coord, int which> static FORCEINLINE VERT clipPoint(VERT* inside, VERT* outside)
template<int coord, int which> static FORCEINLINE VERT clipPoint(bool hirez, VERT* inside, VERT* outside)
#else
static FORCEINLINE VERT clipPoint(VERT* inside, VERT* outside, int coord, int which)
#endif
@ -2355,7 +2359,8 @@ static FORCEINLINE VERT clipPoint(VERT* inside, VERT* outside, int coord, int wh
INTERP(coord[0]); INTERP(coord[1]); INTERP(coord[2]); INTERP(coord[3]);
INTERP(texcoord[0]); INTERP(texcoord[1]);
if(CommonSettings.GFX3D_HighResolutionInterpolateColor)
//if(CommonSettings.GFX3D_HighResolutionInterpolateColor)
if(hirez)
{
INTERP(fcolor[0]); INTERP(fcolor[1]); INTERP(fcolor[2]);
}
@ -2394,20 +2399,20 @@ public:
m_next.init(verts);
}
void clipVert(VERT* vert)
void clipVert(bool hirez, VERT* vert)
{
if(m_prevVert)
this->clipSegmentVsPlane(m_prevVert, vert);
this->clipSegmentVsPlane(hirez, m_prevVert, vert);
else
m_firstVert = vert;
m_prevVert = vert;
}
// closes the loop and returns the number of clipped output verts
int finish()
int finish(bool hirez)
{
this->clipVert(m_firstVert);
return m_next.finish();
this->clipVert(hirez, m_firstVert);
return m_next.finish(hirez);
}
private:
@ -2416,7 +2421,7 @@ private:
VERT* m_firstVert;
Next& m_next;
FORCEINLINE void clipSegmentVsPlane(VERT* vert0, VERT* vert1)
FORCEINLINE void clipSegmentVsPlane(bool hirez, VERT* vert0, VERT* vert1)
{
float* vert0coord = vert0->coord;
float* vert1coord = vert1->coord;
@ -2445,7 +2450,7 @@ private:
if(!out0 && !out1)
{
CLIPLOG(" both inside\n");
m_next.clipVert(vert1);
m_next.clipVert(hirez,vert1);
}
//exiting volume: insert the clipped point
@ -2453,17 +2458,17 @@ private:
{
CLIPLOG(" exiting\n");
assert((u32)numScratchClipVerts < MAX_SCRATCH_CLIP_VERTS);
scratchClipVerts[numScratchClipVerts] = clipPoint<coord, which>(vert0,vert1);
m_next.clipVert(&scratchClipVerts[numScratchClipVerts++]);
scratchClipVerts[numScratchClipVerts] = clipPoint<coord, which>(hirez,vert0,vert1);
m_next.clipVert(hirez,&scratchClipVerts[numScratchClipVerts++]);
}
//entering volume: insert clipped point and the next (interior) point
if(out0 && !out1) {
CLIPLOG(" entering\n");
assert((u32)numScratchClipVerts < MAX_SCRATCH_CLIP_VERTS);
scratchClipVerts[numScratchClipVerts] = clipPoint<coord, which>(vert1,vert0);
m_next.clipVert(&scratchClipVerts[numScratchClipVerts++]);
m_next.clipVert(vert1);
scratchClipVerts[numScratchClipVerts] = clipPoint<coord, which>(hirez,vert1,vert0);
m_next.clipVert(hirez,&scratchClipVerts[numScratchClipVerts++]);
m_next.clipVert(hirez,vert1);
}
}
};
@ -2476,13 +2481,13 @@ public:
m_nextDestVert = verts;
m_numVerts = 0;
}
void clipVert(VERT* vert)
void clipVert(bool hirez, VERT* vert)
{
assert((u32)m_numVerts < MAX_CLIPPED_VERTS);
*m_nextDestVert++ = *vert;
m_numVerts++;
}
int finish()
int finish(bool hirez)
{
return m_numVerts;
}
@ -2501,7 +2506,7 @@ typedef ClipperPlane<1,-1,Stage4> Stage3; static Stage3 clipper3 (clipper
typedef ClipperPlane<0, 1,Stage3> Stage2; static Stage2 clipper2 (clipper3); // right plane
typedef ClipperPlane<0,-1,Stage2> Stage1; static Stage1 clipper (clipper2); // left plane
void GFX3D_Clipper::clipPoly(POLY* poly, VERT** verts)
template<bool hirez> void GFX3D_Clipper::clipPoly(POLY* poly, VERT** verts)
{
CLIPLOG("==Begin poly==\n");
@ -2510,8 +2515,8 @@ void GFX3D_Clipper::clipPoly(POLY* poly, VERT** verts)
clipper.init(clippedPolys[clippedPolyCounter].clipVerts);
for(int i=0;i<type;i++)
clipper.clipVert(verts[i]);
int outType = clipper.finish();
clipper.clipVert(hirez,verts[i]);
int outType = clipper.finish(hirez);
assert((u32)outType < MAX_CLIPPED_VERTS);
if(outType < 3)
@ -2526,6 +2531,9 @@ void GFX3D_Clipper::clipPoly(POLY* poly, VERT** verts)
clippedPolyCounter++;
}
}
//these templates needed to be instantiated manually
template void GFX3D_Clipper::clipPoly<true>(POLY* poly, VERT** verts);
template void GFX3D_Clipper::clipPoly<false>(POLY* poly, VERT** verts);
void GFX3D_Clipper::clipSegmentVsPlane(VERT** verts, const int coord, int which)
{

View File

@ -251,6 +251,10 @@ struct VERTLIST {
int count;
};
struct INDEXLIST {
int list[POLYLIST_SIZE];
};
struct VIEWPORT {
int x, y, width, height;
@ -274,12 +278,13 @@ public:
};
//the entry point for poly clipping
void clipPoly(POLY* poly, VERT** verts);
template<bool hirez> void clipPoly(POLY* poly, VERT** verts);
//the output of clipping operations goes into here.
//be sure you init it before clipping!
TClippedPoly *clippedPolys;
int clippedPolyCounter;
void reset() { clippedPolyCounter=0; }
private:
TClippedPoly tempClippedPoly;
@ -289,9 +294,9 @@ private:
};
//used to communicate state to the renderer
struct GFX3D
struct GFX3D_State
{
GFX3D()
GFX3D_State()
: enableTexturing(true)
, enableAlphaTest(true)
, enableAlphaBlending(true)
@ -302,34 +307,26 @@ struct GFX3D
, enableFogAlphaOnly(false)
, fogShift(0)
, shading(TOON)
, polylist(0)
, vertlist(0)
, alphaTestRef(0)
, clearDepth(1)
, clearColor(0)
, fogColor(0)
, fogOffset(0)
, frameCtr(0)
, frameCtrRaw(0)
{
for(int i=0;i<ARRAY_SIZE(u16ToonTable);i++)
u16ToonTable[i] = 0;
for(int i=0;i<ARRAY_SIZE(shininessTable);i++)
shininessTable[i] = 0;
}
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending,
enableAntialiasing, enableEdgeMarking, enableClearImage, enableFog, enableFogAlphaOnly;
u32 fogShift;
static const u32 TOON = 0;
static const u32 HIGHLIGHT = 1;
u32 shading;
POLYLIST* polylist;
VERTLIST* vertlist;
int indexlist[POLYLIST_SIZE];
BOOL wbuffer, sortmode;
u8 alphaTestRef;
u32 clearDepth;
@ -341,14 +338,43 @@ struct GFX3D
};
#include "PACKED_END.h"
u32 fogOffset;
u32 fogShift;
u16 u16ToonTable[32];
float shininessTable[128];
};
struct Viewer3d_State
{
GFX3D_State state;
VERTLIST vertlist;
POLYLIST polylist;
INDEXLIST indexlist;
};
extern Viewer3d_State viewer3d_state;
struct GFX3D
{
GFX3D()
: frameCtr(0)
, frameCtrRaw(0)
, polylist(0)
, vertlist(0){
}
GFX3D_State state;
POLYLIST* polylist;
VERTLIST* vertlist;
INDEXLIST indexlist;
//ticks every time flush() is called
int frameCtr;
//you can use this to track how many real frames passed, for comparing to frameCtr;
int frameCtrRaw;
u16 u16ToonTable[32];
};
extern GFX3D gfx3d;

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,70 @@
#define _RASTERIZE_H_
#include "render3D.h"
#include "gfx3d.h"
extern GPU3DInterface gpu3DRasterize;
union FragmentColor
{
u32 color;
struct
{
u8 r,g,b,a;
};
};
struct Fragment
{
u32 depth;
struct
{
u8 opaque, translucent;
} polyid;
u8 stencil;
struct
{
u8 isTranslucentPoly:1;
u8 fogged:1;
};
};
class TexCacheItem;
class SoftRasterizerEngine
{
public:
SoftRasterizerEngine();
void initFramebuffer(const int width, const int height, const bool clearImage);
void framebufferProcess();
void updateToonTable();
void updateFogTable();
void updateFloatColors();
void performClipping(bool hirez);
template<bool CUSTOM> void performViewportTransforms(int width, int height);
void performCoordAdjustment(const bool skipBackfacing);
void performBackfaceTests();
void setupTextures(const bool skipBackfacing);
FragmentColor toonTable[32];
u8 fogTable[32768];
GFX3D_Clipper clipper;
GFX3D_Clipper::TClippedPoly *clippedPolys;
int clippedPolyCounter;
TexCacheItem* polyTexKeys[POLYLIST_SIZE];
bool polyVisible[POLYLIST_SIZE];
bool polyBackfacing[POLYLIST_SIZE];
Fragment *screen;
FragmentColor *screenColor;
POLYLIST* polylist;
VERTLIST* vertlist;
INDEXLIST* indexlist;
int width, height;
};
#endif

View File

@ -27,6 +27,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = C:\svn\desmume3\trunk\desmume\src\windows\CodeAnalyst\DeSmuME_2005.caw
AMDCaProjectFile = D:\svn\desmume3\trunk\desmume\src\windows\CodeAnalyst\DeSmuME_2005.caw
EndGlobalSection
EndGlobal

View File

@ -54,13 +54,15 @@
FavorSizeOrSpeed="0"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;_WIN32_WINNT=0x0501"
ExceptionHandling="1"
BasicRuntimeChecks="0"
RuntimeLibrary="1"
BufferSecurityCheck="true"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
RuntimeTypeInfo="false"
WarningLevel="1"
DebugInformationFormat="4"
CallingConvention="0"
@ -78,9 +80,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib glib-vc8-Win32.lib lua-vc8-Win32-debug.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\wpcap.lib"
AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib glib-vc8-Win32.lib lua-vc8-Win32-debug.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\wpcap.lib Rpcrt4.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories=".\zlib123;agg;.libs"
IgnoreDefaultLibraryNames="LIBCPMT"
DelayLoadDLLs="wpcap.dll"
GenerateDebugInformation="true"
GenerateMapFile="true"
@ -147,8 +150,8 @@
FavorSizeOrSpeed="0"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;_WIN32_WINNT=0x0501"
ExceptionHandling="1"
BasicRuntimeChecks="0"
BufferSecurityCheck="true"
@ -171,7 +174,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib lua-5.1.4-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\x64\wpcap.lib"
AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\x64\wpcap.lib"
OutputFile="$(OutDir)\$(ProjectName)_x64_debug.exe"
AdditionalLibraryDirectories=".\zlib123;agg;.libs"
DelayLoadDLLs="wpcap.dll"
@ -242,7 +245,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;NDEBUG;RELEASE;_WIN32_WINNT=0x0501"
StringPooling="true"
ExceptionHandling="1"
@ -269,7 +272,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\wpcap.lib"
AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\wpcap.lib Rpcrt4.lib"
OutputFile="$(OutDir)\$(ProjectName)_release.exe"
AdditionalLibraryDirectories=".\zlib123;agg;.libs"
DelayLoadDLLs="wpcap.dll"
@ -341,8 +344,8 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;NDEBUG;RELEASE"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;NDEBUG;RELEASE;_WIN32_WINNT=0x0501"
StringPooling="true"
ExceptionHandling="1"
BasicRuntimeChecks="0"
@ -440,7 +443,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;NDEBUG;RELEASE;_WIN32_WINNT=0x0501;FASTBUILD"
StringPooling="true"
ExceptionHandling="1"
@ -468,7 +471,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\wpcap.lib"
AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-Win32.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\wpcap.lib Rpcrt4.lib"
OutputFile="$(OutDir)\$(ProjectName)_releaseFastBuild.exe"
AdditionalLibraryDirectories=".\zlib123;agg;.libs"
DelayLoadDLLs="wpcap.dll"
@ -542,8 +545,8 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;NDEBUG;RELEASE;FASTBUILD"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;NDEBUG;RELEASE;FASTBUILD;_WIN32_WINNT=0x0501"
StringPooling="true"
ExceptionHandling="1"
BasicRuntimeChecks="0"
@ -570,7 +573,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib lua-5.1.4-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\x64\wpcap.lib"
AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua-vc8-x64.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib winpcap\x64\wpcap.lib"
OutputFile="$(OutDir)\$(ProjectName)_x64_releaseFastBuild.exe"
AdditionalLibraryDirectories=".\zlib123;agg;.libs"
DelayLoadDLLs="wpcap.dll"
@ -1202,6 +1205,70 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\wx\wx.7z"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release FastBuild|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release FastBuild|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
<Filter
@ -1486,6 +1553,18 @@
</File>
</Filter>
</Filter>
<Filter
Name="wxdlg"
>
<File
RelativePath="..\wxdlg\wxdlg3dViewer.cpp"
>
</File>
<File
RelativePath="..\wxdlg\wxdlg3dViewer.h"
>
</File>
</Filter>
<File
RelativePath="..\addons.cpp"
>
@ -1646,6 +1725,10 @@
RelativePath="..\Disassembler.h"
>
</File>
<File
RelativePath="..\driver.cpp"
>
</File>
<File
RelativePath="..\driver.h"
>
@ -1930,6 +2013,14 @@
RelativePath="..\version.h"
>
</File>
<File
RelativePath="..\view3d.cpp"
>
</File>
<File
RelativePath="..\view3d.h"
>
</File>
<File
RelativePath="..\wifi.cpp"
>

View File

@ -55,7 +55,7 @@
FavorSizeOrSpeed="0"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;&quot;lua\include&quot;;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;BETA_VERSION;NOMINMAX;HAVE_LIBZ"
ExceptionHandling="1"
BasicRuntimeChecks="3"
@ -144,7 +144,7 @@
FavorSizeOrSpeed="0"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;&quot;lua\include&quot;;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;BETA_VERSION;NOMINMAX;HAVE_LIBZ"
ExceptionHandling="1"
BasicRuntimeChecks="3"
@ -235,7 +235,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..;&quot;lua\include&quot;;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;RELEASE;NDEBUG"
StringPooling="true"
ExceptionHandling="1"
@ -329,7 +329,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories=".;..;&quot;lua\include&quot;;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;RELEASE;NDEBUG"
StringPooling="true"
ExceptionHandling="1"
@ -423,7 +423,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;&quot;lua\include&quot;;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;RELEASE;NDEBUG;FASTBUILD"
StringPooling="true"
ExceptionHandling="1"
@ -518,7 +518,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;&quot;lua\include&quot;;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples"
AdditionalIncludeDirectories=".;..;lua\include;&quot;glib-2.20.1\build&quot;;&quot;glib-2.20.1\build\glib&quot;;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples;.\wx\include"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;NOMINMAX;RELEASE;NDEBUG"
StringPooling="true"
ExceptionHandling="1"
@ -704,6 +704,10 @@
RelativePath="..\Disassembler.h"
>
</File>
<File
RelativePath="..\driver.cpp"
>
</File>
<File
RelativePath="..\driver.h"
>
@ -1208,6 +1212,18 @@
</File>
</Filter>
</Filter>
<Filter
Name="wxdlg"
>
<File
RelativePath="..\wxdlg\wxdlg3dViewer.cpp"
>
</File>
<File
RelativePath="..\wxdlg\wxdlg3dViewer.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Windows"
@ -1543,7 +1559,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\7z.tag"
/>
@ -1553,7 +1569,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\7z.tag"
/>
@ -1563,7 +1579,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\7z.tag"
/>
@ -1573,7 +1589,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\7z.tag"
/>
@ -1583,7 +1599,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\7z.tag"
/>
@ -1593,7 +1609,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*"
CommandLine="un7z_and_touch.bat 7z\7z.7z .libs\7z*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\7z.tag"
/>
@ -1607,7 +1623,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\directx.tag"
/>
@ -1617,7 +1633,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\directx.tag"
/>
@ -1627,7 +1643,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\directx.tag"
/>
@ -1637,7 +1653,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\directx.tag"
/>
@ -1647,7 +1663,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\directx.tag"
/>
@ -1657,7 +1673,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*"
CommandLine="un7z_and_touch.bat directx\directx.7z .libs\directx*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\directx.tag"
/>
@ -1671,7 +1687,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\glib-vc8.tag"
/>
@ -1681,7 +1697,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\glib-vc8.tag"
/>
@ -1691,7 +1707,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\glib-vc8.tag"
/>
@ -1701,7 +1717,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\glib-vc8.tag"
/>
@ -1711,7 +1727,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\glib-vc8.tag"
/>
@ -1721,7 +1737,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*"
CommandLine="un7z_and_touch.bat glib-2.20.1\glib-2.20.1.7z .libs\glib*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\glib-vc8.tag"
/>
@ -1735,7 +1751,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\lua.tag"
/>
@ -1745,7 +1761,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\lua.tag"
/>
@ -1755,7 +1771,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\lua.tag"
/>
@ -1765,7 +1781,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\lua.tag"
/>
@ -1775,7 +1791,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\lua.tag"
/>
@ -1785,12 +1801,76 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*"
CommandLine="un7z_and_touch.bat lua\lua.7z .libs\lua*&#x0D;&#x0A;"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\lua.tag"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\wx\wx.7z"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release FastBuild|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
<FileConfiguration
Name="Release FastBuild|x64"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="un7z_and_touch.bat wx\wx.7z .libs\wx*"
AdditionalDependencies="7z.exe;un7z_and_touch.bat"
Outputs=".libs\wx.tag"
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
</Files>

View File

@ -36,12 +36,12 @@ void RenderEPX (SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
uint32 *lpDst = (uint32*)Dst.Surface;
for(int j = 0; j < srcHeight; j++)
for(uint32 j = 0; j < srcHeight; j++)
{
uint32* SrcLine = lpSrc + srcPitch*j;
uint32* DstLine1 = lpDst + dstPitch*(j*2);
uint32* DstLine2 = lpDst + dstPitch*(j*2+1);
for(int i = 0; i < srcWidth; i++)
for(uint32 i = 0; i < srcWidth; i++)
{
uint32 L = *(SrcLine-1);
uint32 C = *(SrcLine);
@ -86,13 +86,13 @@ void RenderEPX_1Point5x (SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
u32 *lpDst = (u32*)Dst.Surface;
for(int yi=0, yo=0; yi < srcHeight; yi+=2, yo+=3)
for(uint32 yi=0, yo=0; yi < srcHeight; yi+=2, yo+=3)
{
u32* SrcLine = lpSrc + srcPitch*yi;
u32* DstLine1 = lpDst + dstPitch*(yo);
u32* DstLine2 = lpDst + dstPitch*(yo+1);
u32* DstLine3 = lpDst + dstPitch*(yo+2);
for(int xi=0; xi < srcWidth; xi+=2)
for(uint32 xi=0; xi < srcWidth; xi+=2)
{
u32 s10 = *(SrcLine-srcPitch), s20 = *(SrcLine-srcPitch+1), s30 = *(SrcLine-srcPitch+2);
u32 s01 = *(SrcLine-1), s11 = *(SrcLine), s21 = *(SrcLine+1), s31 = *(SrcLine+2);
@ -147,12 +147,12 @@ void RenderEPXPlus (SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
uint32 *lpDst = (uint32*)Dst.Surface;
for(int j = 0; j < srcHeight; j++)
for(uint32 j = 0; j < srcHeight; j++)
{
uint32* SrcLine = lpSrc + srcPitch*j;
uint32* DstLine1 = lpDst + dstPitch*(j*2);
uint32* DstLine2 = lpDst + dstPitch*(j*2+1);
for(int i = 0; i < srcWidth; i++)
for(uint32 i = 0; i < srcWidth; i++)
{
uint32 L = *(SrcLine-1);
uint32 C = *(SrcLine);
@ -185,13 +185,13 @@ void RenderEPXPlus_1Point5x (SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
u32 *lpDst = (u32*)Dst.Surface;
for(int yi=0, yo=0; yi < srcHeight; yi+=2, yo+=3)
for(uint32 yi=0, yo=0; yi < srcHeight; yi+=2, yo+=3)
{
u32* SrcLine = lpSrc + srcPitch*yi;
u32* DstLine1 = lpDst + dstPitch*(yo);
u32* DstLine2 = lpDst + dstPitch*(yo+1);
u32* DstLine3 = lpDst + dstPitch*(yo+2);
for(int xi=0; xi < srcWidth; xi+=2)
for(uint32 xi=0; xi < srcWidth; xi+=2)
{
u32 s10 = *(SrcLine-srcPitch), s20 = *(SrcLine-srcPitch+1), s30 = *(SrcLine-srcPitch+2);
u32 s01 = *(SrcLine-1), s11 = *(SrcLine), s21 = *(SrcLine+1), s31 = *(SrcLine+2);
@ -239,7 +239,7 @@ void RenderNearest_1Point5x (SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
uint32 *lpDst = (uint32*)Dst.Surface;
for(int yi = 0, yo = 0; yi < srcHeight; yi+=2, yo+=3)
for(uint32 yi = 0, yo = 0; yi < srcHeight; yi+=2, yo+=3)
{
u32* srcPix1 = lpSrc + srcPitch*(yi);
u32* srcPix2 = lpSrc + srcPitch*(yi+1);
@ -247,7 +247,7 @@ void RenderNearest_1Point5x (SSurface Src, SSurface Dst)
u32* dstPix2 = lpDst + dstPitch*(yo+1);
u32* dstPix3 = lpDst + dstPitch*(yo+2);
for(int xi = 0; xi < srcWidth; xi+=2)
for(uint32 xi = 0; xi < srcWidth; xi+=2)
{
*dstPix1++ = *srcPix1++;
*dstPix1++ = *srcPix1;
@ -280,7 +280,7 @@ void RenderNearestPlus_1Point5x (SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
uint32 *lpDst = (uint32*)Dst.Surface;
for(int j = 0, y = 0; j < srcHeight; j+=2, y+=3)
for(uint32 j = 0, y = 0; j < srcHeight; j+=2, y+=3)
{
u32* srcPix = lpSrc + srcPitch*j;
u32* dstPix = lpDst + dstPitch*y;
@ -289,7 +289,7 @@ void RenderNearestPlus_1Point5x (SSurface Src, SSurface Dst)
#define SET(dx,dy,val) *(dstPix+(dy)*dstPitch+(dx)) = (val)
#define BETTER(dx,dy,dx2,dy2) (GET(dx,dy) == GET(dx2,dy2) && GET(dx2,dy) != GET(dx,dy2))
for(int i = 0, x = 0; i < srcWidth; i+=2, x+=3, srcPix+=2, dstPix+=3)
for(uint32 i = 0, x = 0; i < srcWidth; i+=2, x+=3, srcPix+=2, dstPix+=3)
{
SET(0,0,GET(0,0));
SET(1,0,GET(1,0));

View File

@ -108,12 +108,30 @@ using namespace std;
VideoInfo video;
//#define WX_STUB
#define WX_STUB
#ifdef WX_STUB
// for compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef _M_X64
#ifdef __WXDEBUG__
#pragma comment(lib,"wxmsw28d_core-x64.lib")
#pragma comment(lib,"wxbase28d-x64.lib")
#else
#pragma comment(lib,"wxmsw28_core-x64.lib")
#pragma comment(lib,"wxbase28-x64.lib")
#endif
#else
#ifdef __WXDEBUG__
#pragma comment(lib,"wxmsw28d_core.lib")
#pragma comment(lib,"wxbase28d.lib")
#else
#pragma comment(lib,"wxmsw28_core.lib")
#pragma comment(lib,"wxbase28.lib")
#endif
#endif
#pragma comment(lib,"comctl32.lib")
#include "../wxdlg/wxdlg3dViewer.h"
class wxDesmumeApp : public wxApp
{
@ -130,17 +148,11 @@ public:
IMPLEMENT_APP_NO_MAIN( wxDesmumeApp )
class wxTestModeless : public wxFrame
{
public:
wxTestModeless(const wxChar *title, int x, int y)
: wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450))
{}
};
void wxTest() {
wxTestModeless *frame = new wxTestModeless(_T("Controls wxWidgets App"), 50, 50);
frame->Show(true);
//wxdlg3dViewer *viewer = new wxdlg3dViewer(NULL);
//viewer->Show(true);
//wxTestModeless *frame = new wxTestModeless(_T("Controls wxWidgets App"), 50, 50);
//frame->Show(true);
}
#endif
@ -2575,6 +2587,10 @@ int _main()
MainWindow->Show(SW_NORMAL);
//DEBUG TEST HACK
//driver->VIEW3D_Init();
//driver->view3d->Launch();
//---------
//------DO EVERYTHING
run();
@ -3395,7 +3411,7 @@ void ScreenshotToClipboard()
bool twolinever = strlen(nameandver) > 32;
HFONT hFont = CreateFont(14, 8, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, FIXED_PITCH, "Lucida Console");
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH, "Lucida Console");
HDC hScreenDC = GetDC(NULL);
HDC hMemDC = CreateCompatibleDC(hScreenDC);
@ -4594,6 +4610,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
OpenToolWindow(new CMemView());
return 0;
case IDM_VIEW3D:
driver->VIEW3D_Init();
driver->view3d->Launch();
return 0;
case IDM_SOUND_VIEW:
if(!SoundView_IsOpened()) SoundView_DlgOpen(HWND_DESKTOP);
return 0;
@ -4988,10 +5008,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case IDM_ABOUT:
{
#ifdef WX_STUB
wxTest();
return 0;
#endif
bool tpaused=false;
if (execute)
{

View File

@ -698,6 +698,7 @@
#define IDM_CHEATS_DISABLE 40062
#define IDM_CHEATS_SEARCH 40063
#define ID_RAMSEARCH_CAPTIONTEXT 40064
#define IDM_VIEW3D 40065
#define IDC_LABEL_UP 50000
#define IDC_LABEL_RIGHT 50001
#define IDC_LABEL_LEFT 50002
@ -793,7 +794,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40008
#define _APS_NEXT_COMMAND_VALUE 40010
#define _APS_NEXT_CONTROL_VALUE 1020
#define _APS_NEXT_SYMED_VALUE 101
#endif

Binary file not shown.

View File

@ -0,0 +1,249 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msvc/wx/msw/setup.h
// Purpose: wrapper around the real wx/setup.h for Visual C++
// Author: Vadim Zeitlin
// Modified by:
// Created: 2004-12-12
// RCS-ID: $Id: setup.h 43687 2006-11-27 15:03:59Z VZ $
// Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// VC++ IDE predefines _DEBUG and _UNICODE for the new projects itself, but
// the other symbols (WXUSINGDLL, __WXUNIVERSAL__, ...) should be defined
// explicitly!
#ifdef _MSC_VER
#ifdef _UNICODE
#ifdef WXUSINGDLL
#ifdef _DEBUG
#include "../../../lib/vc_dll/mswud/wx/setup.h"
#else
#include "../../../lib/vc_dll/mswu/wx/setup.h"
#endif
#else
#ifdef _DEBUG
#include "../../../lib/vc_lib/mswud/wx/setup.h"
#else
#include "../../../lib/vc_lib/mswu/wx/setup.h"
#endif
#endif
#ifdef _DEBUG
#pragma comment(lib,"wxbase28ud")
#pragma comment(lib,"wxbase28ud_net")
#pragma comment(lib,"wxbase28ud_xml")
#if wxUSE_REGEX
#pragma comment(lib,"wxregexud")
#endif
#if wxUSE_GUI
#if wxUSE_XML
#pragma comment(lib,"wxexpatd")
#endif
#if wxUSE_LIBJPEG
#pragma comment(lib,"wxjpegd")
#endif
#if wxUSE_LIBPNG
#pragma comment(lib,"wxpngd")
#endif
#if wxUSE_LIBTIFF
#pragma comment(lib,"wxtiffd")
#endif
#if wxUSE_ZLIB
#pragma comment(lib,"wxzlibd")
#endif
#pragma comment(lib,"wxmsw28ud_adv")
#pragma comment(lib,"wxmsw28ud_core")
#pragma comment(lib,"wxmsw28ud_html")
#if wxUSE_GLCANVAS
#pragma comment(lib,"wxmsw28ud_gl")
#endif
#if wxUSE_DEBUGREPORT
#pragma comment(lib,"wxmsw28ud_qa")
#endif
#if wxUSE_XRC
#pragma comment(lib,"wxmsw28ud_xrc")
#endif
#if wxUSE_AUI
#pragma comment(lib,"wxmsw28ud_aui")
#endif
#if wxUSE_RICHTEXT
#pragma comment(lib,"wxmsw28ud_richtext")
#endif
#if wxUSE_MEDIACTRL
#pragma comment(lib,"wxmsw28ud_media")
#endif
#if wxUSE_ODBC
#pragma comment(lib,"wxbase28ud_odbc")
#endif
#endif // wxUSE_GUI
#else // release
#pragma comment(lib,"wxbase28u")
#pragma comment(lib,"wxbase28u_net")
#pragma comment(lib,"wxbase28u_xml")
#if wxUSE_REGEX
#pragma comment(lib,"wxregexu")
#endif
#if wxUSE_GUI
#if wxUSE_XML
#pragma comment(lib,"wxexpat")
#endif
#if wxUSE_LIBJPEG
#pragma comment(lib,"wxjpeg")
#endif
#if wxUSE_LIBPNG
#pragma comment(lib,"wxpng")
#endif
#if wxUSE_LIBTIFF
#pragma comment(lib,"wxtiff")
#endif
#if wxUSE_ZLIB
#pragma comment(lib,"wxzlib")
#endif
#pragma comment(lib,"wxmsw28u_adv")
#pragma comment(lib,"wxmsw28u_core")
#pragma comment(lib,"wxmsw28u_html")
#if wxUSE_GLCANVAS
#pragma comment(lib,"wxmsw28u_gl")
#endif
#if wxUSE_DEBUGREPORT
#pragma comment(lib,"wxmsw28u_qa")
#endif
#if wxUSE_XRC
#pragma comment(lib,"wxmsw28u_xrc")
#endif
#if wxUSE_AUI
#pragma comment(lib,"wxmsw28u_aui")
#endif
#if wxUSE_RICHTEXT
#pragma comment(lib,"wxmsw28u_richtext")
#endif
#if wxUSE_MEDIACTRL
#pragma comment(lib,"wxmsw28u_media")
#endif
#if wxUSE_ODBC
#pragma comment(lib,"wxbase28u_odbc")
#endif
#endif // wxUSE_GUI
#endif // debug/release
#else // !_UNICODE
#ifdef WXUSINGDLL
#ifdef _DEBUG
#include "../../../lib/vc_dll/mswd/wx/setup.h"
#else
#include "../../../lib/vc_dll/msw/wx/setup.h"
#endif
#else // static lib
#ifdef _DEBUG
#include "../../../lib/vc_lib/mswd/wx/setup.h"
#else
#include "../../../lib/vc_lib/msw/wx/setup.h"
#endif
#endif // shared/static
#ifdef _DEBUG
#pragma comment(lib,"wxbase28d")
#pragma comment(lib,"wxbase28d_net")
#pragma comment(lib,"wxbase28d_xml")
#if wxUSE_REGEX
#pragma comment(lib,"wxregexd")
#endif
#if wxUSE_GUI
#if wxUSE_XML
#pragma comment(lib,"wxexpatd")
#endif
#if wxUSE_LIBJPEG
#pragma comment(lib,"wxjpegd")
#endif
#if wxUSE_LIBPNG
#pragma comment(lib,"wxpngd")
#endif
#if wxUSE_LIBTIFF
#pragma comment(lib,"wxtiffd")
#endif
#if wxUSE_ZLIB
#pragma comment(lib,"wxzlibd")
#endif
#pragma comment(lib,"wxmsw28d_adv")
#pragma comment(lib,"wxmsw28d_core")
#pragma comment(lib,"wxmsw28d_html")
#if wxUSE_GLCANVAS
#pragma comment(lib,"wxmsw28d_gl")
#endif
#if wxUSE_DEBUGREPORT
#pragma comment(lib,"wxmsw28d_qa")
#endif
#if wxUSE_XRC
#pragma comment(lib,"wxmsw28d_xrc")
#endif
#if wxUSE_AUI
#pragma comment(lib,"wxmsw28d_aui")
#endif
#if wxUSE_RICHTEXT
#pragma comment(lib,"wxmsw28d_richtext")
#endif
#if wxUSE_MEDIACTRL
#pragma comment(lib,"wxmsw28d_media")
#endif
#if wxUSE_ODBC
#pragma comment(lib,"wxbase28d_odbc")
#endif
#endif // wxUSE_GUI
#else // release
#pragma comment(lib,"wxbase28")
#pragma comment(lib,"wxbase28_net")
#pragma comment(lib,"wxbase28_xml")
#if wxUSE_REGEX
#pragma comment(lib,"wxregex")
#endif
#if wxUSE_GUI
#if wxUSE_XML
#pragma comment(lib,"wxexpat")
#endif
#if wxUSE_LIBJPEG
#pragma comment(lib,"wxjpeg")
#endif
#if wxUSE_LIBPNG
#pragma comment(lib,"wxpng")
#endif
#if wxUSE_LIBTIFF
#pragma comment(lib,"wxtiff")
#endif
#if wxUSE_ZLIB
#pragma comment(lib,"wxzlib")
#endif
#pragma comment(lib,"wxmsw28_adv")
#pragma comment(lib,"wxmsw28_core")
#pragma comment(lib,"wxmsw28_html")
#if wxUSE_GLCANVAS
#pragma comment(lib,"wxmsw28_gl")
#endif
#if wxUSE_DEBUGREPORT
#pragma comment(lib,"wxmsw28_qa")
#endif
#if wxUSE_XRC
#pragma comment(lib,"wxmsw28_xrc")
#endif
#if wxUSE_AUI
#pragma comment(lib,"wxmsw28_aui")
#endif
#if wxUSE_RICHTEXT
#pragma comment(lib,"wxmsw28_richtext")
#endif
#if wxUSE_MEDIACTRL
#pragma comment(lib,"wxmsw28_media")
#endif
#if wxUSE_ODBC
#pragma comment(lib,"wxbase28_odbc")
#endif
#endif // wxUSE_GUI
#endif // debug/release
#endif // _UNICODE/!_UNICODE
#else
#error "This file should only be included when using Microsoft Visual C++"
#endif

View File

@ -0,0 +1,161 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aboutdlg.h
// Purpose: declaration of wxAboutDialog class
// Author: Vadim Zeitlin
// Created: 2006-10-07
// RCS-ID: $Id: aboutdlg.h 58748 2009-02-08 09:46:03Z VZ $
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ABOUTDLG_H_
#define _WX_ABOUTDLG_H_
#include "wx/defs.h"
#if wxUSE_ABOUTDLG
#include "wx/app.h"
#include "wx/icon.h"
// ----------------------------------------------------------------------------
// wxAboutDialogInfo: information shown by the standard "About" dialog
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAboutDialogInfo
{
public:
// all fields are initially uninitialized
wxAboutDialogInfo() { }
// accessors for various simply fields
// -----------------------------------
// name of the program, if not used defaults wxApp::GetAppName()
void SetName(const wxString& name) { m_name = name; }
wxString GetName() const
{ return m_name.empty() ? wxTheApp->GetAppName() : m_name; }
// version of the program, in free format (but without "version" word)
void SetVersion(const wxString& version) { m_version = version; }
bool HasVersion() const { return !m_version.empty(); }
wxString GetVersion() const { return m_version; }
// brief, but possibly multiline, description of the program
void SetDescription(const wxString& desc) { m_description = desc; }
bool HasDescription() const { return !m_description.empty(); }
wxString GetDescription() const { return m_description; }
// short string containing the program copyright information
void SetCopyright(const wxString& copyright) { m_copyright = copyright; }
bool HasCopyright() const { return !m_copyright.empty(); }
wxString GetCopyright() const { return m_copyright; }
// long, multiline string containing the text of the program licence
void SetLicence(const wxString& licence) { m_licence = licence; }
void SetLicense(const wxString& licence) { m_licence = licence; }
bool HasLicence() const { return !m_licence.empty(); }
wxString GetLicence() const { return m_licence; }
// icon to be shown in the dialog, defaults to the main frame icon
void SetIcon(const wxIcon& icon) { m_icon = icon; }
bool HasIcon() const { return m_icon.Ok(); }
wxIcon GetIcon() const;
// web site for the program and its description (defaults to URL itself if
// empty)
void SetWebSite(const wxString& url, const wxString& desc = wxEmptyString)
{
m_url = url;
m_urlDesc = desc.empty() ? url : desc;
}
bool HasWebSite() const { return !m_url.empty(); }
wxString GetWebSiteURL() const { return m_url; }
wxString GetWebSiteDescription() const { return m_urlDesc; }
// accessors for the arrays
// ------------------------
// the list of developers of the program
void SetDevelopers(const wxArrayString& developers)
{ m_developers = developers; }
void AddDeveloper(const wxString& developer)
{ m_developers.push_back(developer); }
bool HasDevelopers() const { return !m_developers.empty(); }
const wxArrayString& GetDevelopers() const { return m_developers; }
// the list of documentation writers
void SetDocWriters(const wxArrayString& docwriters)
{ m_docwriters = docwriters; }
void AddDocWriter(const wxString& docwriter)
{ m_docwriters.push_back(docwriter); }
bool HasDocWriters() const { return !m_docwriters.empty(); }
const wxArrayString& GetDocWriters() const { return m_docwriters; }
// the list of artists for the program art
void SetArtists(const wxArrayString& artists)
{ m_artists = artists; }
void AddArtist(const wxString& artist)
{ m_artists.push_back(artist); }
bool HasArtists() const { return !m_artists.empty(); }
const wxArrayString& GetArtists() const { return m_artists; }
// the list of translators
void SetTranslators(const wxArrayString& translators)
{ m_translators = translators; }
void AddTranslator(const wxString& translator)
{ m_translators.push_back(translator); }
bool HasTranslators() const { return !m_translators.empty(); }
const wxArrayString& GetTranslators() const { return m_translators; }
// implementation only
// -------------------
// "simple" about dialog shows only textual information (with possibly
// default icon but without hyperlink nor any long texts such as the
// licence text)
bool IsSimple() const
{ return !HasWebSite() && !HasIcon() && !HasLicence(); }
// get the description and credits (i.e. all of developers, doc writers,
// artists and translators) as a one long multiline string
wxString GetDescriptionAndCredits() const;
#if wxABI_VERSION >= 20810
// returns the copyright with the (C) string substituted by the Unicode
// character U+00A9
wxString GetCopyrightToDisplay() const;
#endif // wx 2.8.10+
private:
wxString m_name,
m_version,
m_description,
m_copyright,
m_licence;
wxIcon m_icon;
wxString m_url,
m_urlDesc;
wxArrayString m_developers,
m_docwriters,
m_artists,
m_translators;
};
// functions to show the about dialog box
WXDLLIMPEXP_ADV void wxAboutBox(const wxAboutDialogInfo& info);
#endif // wxUSE_ABOUTDLG
#endif // _WX_ABOUTDLG_H_

View File

@ -0,0 +1,171 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/accel.h
// Purpose: wxAcceleratorEntry and wxAcceleratorTable classes
// Author: Julian Smart, Robert Roebling, Vadim Zeitlin
// Modified by:
// Created: 31.05.01 (extracted from other files)
// RCS-ID: $Id: accel.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCEL_H_BASE_
#define _WX_ACCEL_H_BASE_
#include "wx/defs.h"
#if wxUSE_ACCEL
#include "wx/object.h"
class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable;
class WXDLLIMPEXP_FWD_CORE wxMenuItem;
class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// wxAcceleratorEntry flags
enum
{
wxACCEL_NORMAL = 0x0000, // no modifiers
wxACCEL_ALT = 0x0001, // hold Alt key down
wxACCEL_CTRL = 0x0002, // hold Ctrl key down
wxACCEL_SHIFT = 0x0004, // hold Shift key down
#if defined(__WXMAC__) || defined(__WXCOCOA__)
wxACCEL_CMD = 0x0008 // Command key on OS X
#else
wxACCEL_CMD = wxACCEL_CTRL
#endif
};
// ----------------------------------------------------------------------------
// an entry in wxAcceleratorTable corresponds to one accelerator
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAcceleratorEntry
{
public:
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
wxMenuItem *item = NULL)
: m_flags(flags)
, m_keyCode(keyCode)
, m_command(cmd)
, m_item(item)
{ }
wxAcceleratorEntry(const wxAcceleratorEntry& entry)
: m_flags(entry.m_flags)
, m_keyCode(entry.m_keyCode)
, m_command(entry.m_command)
, m_item(entry.m_item)
{ }
// create accelerator corresponding to the specified string, return NULL if
// string couldn't be parsed or a pointer to be deleted by the caller
static wxAcceleratorEntry *Create(const wxString& str);
wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry)
{
Set(entry.m_flags, entry.m_keyCode, entry.m_command, entry.m_item);
return *this;
}
void Set(int flags, int keyCode, int cmd, wxMenuItem *item = NULL)
{
m_flags = flags;
m_keyCode = keyCode;
m_command = cmd;
m_item = item;
}
void SetMenuItem(wxMenuItem *item) { m_item = item; }
int GetFlags() const { return m_flags; }
int GetKeyCode() const { return m_keyCode; }
int GetCommand() const { return m_command; }
wxMenuItem *GetMenuItem() const { return m_item; }
bool operator==(const wxAcceleratorEntry& entry) const
{
return m_flags == entry.m_flags &&
m_keyCode == entry.m_keyCode &&
m_command == entry.m_command &&
m_item == entry.m_item;
}
bool operator!=(const wxAcceleratorEntry& entry) const
{ return !(*this == entry); }
#if defined(__WXMOTIF__)
// Implementation use only
bool MatchesEvent(const wxKeyEvent& event) const;
#endif
bool IsOk() const
{
return m_flags != 0 &&
m_keyCode != 0;
}
// string <-> wxAcceleratorEntry conversion
// ----------------------------------------
// returns a wxString for the this accelerator.
// this function formats it using the <flags>-<keycode> format
// where <flags> maybe a hyphen-separed list of "shift|alt|ctrl"
wxString ToString() const;
// returns true if the given string correctly initialized this object
// (i.e. if IsOk() returns true after this call)
bool FromString(const wxString& str);
private:
// common part of Create() and FromString()
static bool ParseAccel(const wxString& str, int *flags, int *keycode);
int m_flags; // combination of wxACCEL_XXX constants
int m_keyCode; // ASCII or virtual keycode
int m_command; // Command id to generate
// the menu item this entry corresponds to, may be NULL
wxMenuItem *m_item;
// for compatibility with old code, use accessors now!
friend class WXDLLIMPEXP_FWD_CORE wxMenu;
};
// ----------------------------------------------------------------------------
// include wxAcceleratorTable class declaration, it is only used by the library
// and so doesn't have any published user visible interface
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/generic/accel.h"
#elif defined(__WXMSW__)
#include "wx/msw/accel.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/accel.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/accel.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/accel.h"
#elif defined(__WXMAC__)
#include "wx/mac/accel.h"
#elif defined(__WXCOCOA__)
#include "wx/generic/accel.h"
#elif defined(__WXPM__)
#include "wx/os2/accel.h"
#endif
extern WXDLLEXPORT_DATA(wxAcceleratorTable) wxNullAcceleratorTable;
#endif // wxUSE_ACCEL
#endif
// _WX_ACCEL_H_BASE_

View File

@ -0,0 +1,377 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/access.h
// Purpose: Accessibility classes
// Author: Julian Smart
// Modified by:
// Created: 2003-02-12
// RCS-ID: $Id: access.h 51246 2008-01-16 12:56:37Z VZ $
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCESSBASE_H_
#define _WX_ACCESSBASE_H_
// ----------------------------------------------------------------------------
// headers we have to include here
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_ACCESSIBILITY
#include "wx/variant.h"
typedef enum
{
wxACC_FAIL,
wxACC_FALSE,
wxACC_OK,
wxACC_NOT_IMPLEMENTED,
wxACC_NOT_SUPPORTED
} wxAccStatus;
// Child ids are integer identifiers from 1 up.
// So zero represents 'this' object.
#define wxACC_SELF 0
// Navigation constants
typedef enum
{
wxNAVDIR_DOWN,
wxNAVDIR_FIRSTCHILD,
wxNAVDIR_LASTCHILD,
wxNAVDIR_LEFT,
wxNAVDIR_NEXT,
wxNAVDIR_PREVIOUS,
wxNAVDIR_RIGHT,
wxNAVDIR_UP
} wxNavDir;
// Role constants
typedef enum {
wxROLE_NONE,
wxROLE_SYSTEM_ALERT,
wxROLE_SYSTEM_ANIMATION,
wxROLE_SYSTEM_APPLICATION,
wxROLE_SYSTEM_BORDER,
wxROLE_SYSTEM_BUTTONDROPDOWN,
wxROLE_SYSTEM_BUTTONDROPDOWNGRID,
wxROLE_SYSTEM_BUTTONMENU,
wxROLE_SYSTEM_CARET,
wxROLE_SYSTEM_CELL,
wxROLE_SYSTEM_CHARACTER,
wxROLE_SYSTEM_CHART,
wxROLE_SYSTEM_CHECKBUTTON,
wxROLE_SYSTEM_CLIENT,
wxROLE_SYSTEM_CLOCK,
wxROLE_SYSTEM_COLUMN,
wxROLE_SYSTEM_COLUMNHEADER,
wxROLE_SYSTEM_COMBOBOX,
wxROLE_SYSTEM_CURSOR,
wxROLE_SYSTEM_DIAGRAM,
wxROLE_SYSTEM_DIAL,
wxROLE_SYSTEM_DIALOG,
wxROLE_SYSTEM_DOCUMENT,
wxROLE_SYSTEM_DROPLIST,
wxROLE_SYSTEM_EQUATION,
wxROLE_SYSTEM_GRAPHIC,
wxROLE_SYSTEM_GRIP,
wxROLE_SYSTEM_GROUPING,
wxROLE_SYSTEM_HELPBALLOON,
wxROLE_SYSTEM_HOTKEYFIELD,
wxROLE_SYSTEM_INDICATOR,
wxROLE_SYSTEM_LINK,
wxROLE_SYSTEM_LIST,
wxROLE_SYSTEM_LISTITEM,
wxROLE_SYSTEM_MENUBAR,
wxROLE_SYSTEM_MENUITEM,
wxROLE_SYSTEM_MENUPOPUP,
wxROLE_SYSTEM_OUTLINE,
wxROLE_SYSTEM_OUTLINEITEM,
wxROLE_SYSTEM_PAGETAB,
wxROLE_SYSTEM_PAGETABLIST,
wxROLE_SYSTEM_PANE,
wxROLE_SYSTEM_PROGRESSBAR,
wxROLE_SYSTEM_PROPERTYPAGE,
wxROLE_SYSTEM_PUSHBUTTON,
wxROLE_SYSTEM_RADIOBUTTON,
wxROLE_SYSTEM_ROW,
wxROLE_SYSTEM_ROWHEADER,
wxROLE_SYSTEM_SCROLLBAR,
wxROLE_SYSTEM_SEPARATOR,
wxROLE_SYSTEM_SLIDER,
wxROLE_SYSTEM_SOUND,
wxROLE_SYSTEM_SPINBUTTON,
wxROLE_SYSTEM_STATICTEXT,
wxROLE_SYSTEM_STATUSBAR,
wxROLE_SYSTEM_TABLE,
wxROLE_SYSTEM_TEXT,
wxROLE_SYSTEM_TITLEBAR,
wxROLE_SYSTEM_TOOLBAR,
wxROLE_SYSTEM_TOOLTIP,
wxROLE_SYSTEM_WHITESPACE,
wxROLE_SYSTEM_WINDOW
} wxAccRole;
// Object types
typedef enum {
wxOBJID_WINDOW = 0x00000000,
wxOBJID_SYSMENU = 0xFFFFFFFF,
wxOBJID_TITLEBAR = 0xFFFFFFFE,
wxOBJID_MENU = 0xFFFFFFFD,
wxOBJID_CLIENT = 0xFFFFFFFC,
wxOBJID_VSCROLL = 0xFFFFFFFB,
wxOBJID_HSCROLL = 0xFFFFFFFA,
wxOBJID_SIZEGRIP = 0xFFFFFFF9,
wxOBJID_CARET = 0xFFFFFFF8,
wxOBJID_CURSOR = 0xFFFFFFF7,
wxOBJID_ALERT = 0xFFFFFFF6,
wxOBJID_SOUND = 0xFFFFFFF5
} wxAccObject;
// Accessible states
#define wxACC_STATE_SYSTEM_ALERT_HIGH 0x00000001
#define wxACC_STATE_SYSTEM_ALERT_MEDIUM 0x00000002
#define wxACC_STATE_SYSTEM_ALERT_LOW 0x00000004
#define wxACC_STATE_SYSTEM_ANIMATED 0x00000008
#define wxACC_STATE_SYSTEM_BUSY 0x00000010
#define wxACC_STATE_SYSTEM_CHECKED 0x00000020
#define wxACC_STATE_SYSTEM_COLLAPSED 0x00000040
#define wxACC_STATE_SYSTEM_DEFAULT 0x00000080
#define wxACC_STATE_SYSTEM_EXPANDED 0x00000100
#define wxACC_STATE_SYSTEM_EXTSELECTABLE 0x00000200
#define wxACC_STATE_SYSTEM_FLOATING 0x00000400
#define wxACC_STATE_SYSTEM_FOCUSABLE 0x00000800
#define wxACC_STATE_SYSTEM_FOCUSED 0x00001000
#define wxACC_STATE_SYSTEM_HOTTRACKED 0x00002000
#define wxACC_STATE_SYSTEM_INVISIBLE 0x00004000
#define wxACC_STATE_SYSTEM_MARQUEED 0x00008000
#define wxACC_STATE_SYSTEM_MIXED 0x00010000
#define wxACC_STATE_SYSTEM_MULTISELECTABLE 0x00020000
#define wxACC_STATE_SYSTEM_OFFSCREEN 0x00040000
#define wxACC_STATE_SYSTEM_PRESSED 0x00080000
#define wxACC_STATE_SYSTEM_PROTECTED 0x00100000
#define wxACC_STATE_SYSTEM_READONLY 0x00200000
#define wxACC_STATE_SYSTEM_SELECTABLE 0x00400000
#define wxACC_STATE_SYSTEM_SELECTED 0x00800000
#define wxACC_STATE_SYSTEM_SELFVOICING 0x01000000
#define wxACC_STATE_SYSTEM_UNAVAILABLE 0x02000000
// Selection flag
typedef enum
{
wxACC_SEL_NONE = 0,
wxACC_SEL_TAKEFOCUS = 1,
wxACC_SEL_TAKESELECTION = 2,
wxACC_SEL_EXTENDSELECTION = 4,
wxACC_SEL_ADDSELECTION = 8,
wxACC_SEL_REMOVESELECTION = 16
} wxAccSelectionFlags;
// Accessibility event identifiers
#define wxACC_EVENT_SYSTEM_SOUND 0x0001
#define wxACC_EVENT_SYSTEM_ALERT 0x0002
#define wxACC_EVENT_SYSTEM_FOREGROUND 0x0003
#define wxACC_EVENT_SYSTEM_MENUSTART 0x0004
#define wxACC_EVENT_SYSTEM_MENUEND 0x0005
#define wxACC_EVENT_SYSTEM_MENUPOPUPSTART 0x0006
#define wxACC_EVENT_SYSTEM_MENUPOPUPEND 0x0007
#define wxACC_EVENT_SYSTEM_CAPTURESTART 0x0008
#define wxACC_EVENT_SYSTEM_CAPTUREEND 0x0009
#define wxACC_EVENT_SYSTEM_MOVESIZESTART 0x000A
#define wxACC_EVENT_SYSTEM_MOVESIZEEND 0x000B
#define wxACC_EVENT_SYSTEM_CONTEXTHELPSTART 0x000C
#define wxACC_EVENT_SYSTEM_CONTEXTHELPEND 0x000D
#define wxACC_EVENT_SYSTEM_DRAGDROPSTART 0x000E
#define wxACC_EVENT_SYSTEM_DRAGDROPEND 0x000F
#define wxACC_EVENT_SYSTEM_DIALOGSTART 0x0010
#define wxACC_EVENT_SYSTEM_DIALOGEND 0x0011
#define wxACC_EVENT_SYSTEM_SCROLLINGSTART 0x0012
#define wxACC_EVENT_SYSTEM_SCROLLINGEND 0x0013
#define wxACC_EVENT_SYSTEM_SWITCHSTART 0x0014
#define wxACC_EVENT_SYSTEM_SWITCHEND 0x0015
#define wxACC_EVENT_SYSTEM_MINIMIZESTART 0x0016
#define wxACC_EVENT_SYSTEM_MINIMIZEEND 0x0017
#define wxACC_EVENT_OBJECT_CREATE 0x8000
#define wxACC_EVENT_OBJECT_DESTROY 0x8001
#define wxACC_EVENT_OBJECT_SHOW 0x8002
#define wxACC_EVENT_OBJECT_HIDE 0x8003
#define wxACC_EVENT_OBJECT_REORDER 0x8004
#define wxACC_EVENT_OBJECT_FOCUS 0x8005
#define wxACC_EVENT_OBJECT_SELECTION 0x8006
#define wxACC_EVENT_OBJECT_SELECTIONADD 0x8007
#define wxACC_EVENT_OBJECT_SELECTIONREMOVE 0x8008
#define wxACC_EVENT_OBJECT_SELECTIONWITHIN 0x8009
#define wxACC_EVENT_OBJECT_STATECHANGE 0x800A
#define wxACC_EVENT_OBJECT_LOCATIONCHANGE 0x800B
#define wxACC_EVENT_OBJECT_NAMECHANGE 0x800C
#define wxACC_EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D
#define wxACC_EVENT_OBJECT_VALUECHANGE 0x800E
#define wxACC_EVENT_OBJECT_PARENTCHANGE 0x800F
#define wxACC_EVENT_OBJECT_HELPCHANGE 0x8010
#define wxACC_EVENT_OBJECT_DEFACTIONCHANGE 0x8011
#define wxACC_EVENT_OBJECT_ACCELERATORCHANGE 0x8012
// ----------------------------------------------------------------------------
// wxAccessible
// All functions return an indication of success, failure, or not implemented.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxAccessible;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxPoint;
class WXDLLIMPEXP_FWD_CORE wxRect;
class WXDLLEXPORT wxAccessibleBase : public wxObject
{
DECLARE_NO_COPY_CLASS(wxAccessibleBase)
public:
wxAccessibleBase(wxWindow* win): m_window(win) {}
virtual ~wxAccessibleBase() {}
// Overridables
// Can return either a child object, or an integer
// representing the child element, starting from 1.
// pt is in screen coordinates.
virtual wxAccStatus HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
virtual wxAccStatus GetLocation(wxRect& WXUNUSED(rect), int WXUNUSED(elementId))
{ return wxACC_NOT_IMPLEMENTED; }
// Navigates from fromId to toId/toObject.
virtual wxAccStatus Navigate(wxNavDir WXUNUSED(navDir), int WXUNUSED(fromId),
int* WXUNUSED(toId), wxAccessible** WXUNUSED(toObject))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the name of the specified object.
virtual wxAccStatus GetName(int WXUNUSED(childId), wxString* WXUNUSED(name))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the number of children.
virtual wxAccStatus GetChildCount(int* WXUNUSED(childCount))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the specified child (starting from 1).
// If *child is NULL and return value is wxACC_OK,
// this means that the child is a simple element and
// not an accessible object.
virtual wxAccStatus GetChild(int WXUNUSED(childId), wxAccessible** WXUNUSED(child))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the parent, or NULL.
virtual wxAccStatus GetParent(wxAccessible** WXUNUSED(parent))
{ return wxACC_NOT_IMPLEMENTED; }
// Performs the default action. childId is 0 (the action for this object)
// or > 0 (the action for a child).
// Return wxACC_NOT_SUPPORTED if there is no default action for this
// window (e.g. an edit control).
virtual wxAccStatus DoDefaultAction(int WXUNUSED(childId))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the default action for this object (0) or > 0 (the action for a child).
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
// string if there is no action.
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
virtual wxAccStatus GetDefaultAction(int WXUNUSED(childId), wxString* WXUNUSED(actionName))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns the description for this object or a child.
virtual wxAccStatus GetDescription(int WXUNUSED(childId), wxString* WXUNUSED(description))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns help text for this object or a child, similar to tooltip text.
virtual wxAccStatus GetHelpText(int WXUNUSED(childId), wxString* WXUNUSED(helpText))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns the keyboard shortcut for this object or child.
// Return e.g. ALT+K
virtual wxAccStatus GetKeyboardShortcut(int WXUNUSED(childId), wxString* WXUNUSED(shortcut))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns a role constant.
virtual wxAccStatus GetRole(int WXUNUSED(childId), wxAccRole* WXUNUSED(role))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns a state constant.
virtual wxAccStatus GetState(int WXUNUSED(childId), long* WXUNUSED(state))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns a localized string representing the value for the object
// or child.
virtual wxAccStatus GetValue(int WXUNUSED(childId), wxString* WXUNUSED(strValue))
{ return wxACC_NOT_IMPLEMENTED; }
// Selects the object or child.
virtual wxAccStatus Select(int WXUNUSED(childId), wxAccSelectionFlags WXUNUSED(selectFlags))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the window with the keyboard focus.
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
virtual wxAccStatus GetFocus(int* WXUNUSED(childId), wxAccessible** WXUNUSED(child))
{ return wxACC_NOT_IMPLEMENTED; }
#if wxUSE_VARIANT
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// - a null variant (IsNull() returns TRUE)
// - a list variant (GetType() == wxT("list"))
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long"))
// - a "void*" pointer to a wxAccessible child object
virtual wxAccStatus GetSelections(wxVariant* WXUNUSED(selections))
{ return wxACC_NOT_IMPLEMENTED; }
#endif // wxUSE_VARIANT
// Accessors
// Returns the window associated with this object.
wxWindow* GetWindow() { return m_window; }
// Sets the window associated with this object.
void SetWindow(wxWindow* window) { m_window = window; }
// Operations
// Each platform's implementation must define this
// static void NotifyEvent(int eventType, wxWindow* window, wxAccObject objectType,
// int objectId);
private:
// Data members
wxWindow* m_window;
};
// ----------------------------------------------------------------------------
// now include the declaration of the real class
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/access.h"
#endif
#endif // wxUSE_ACCESSIBILITY
#endif // _WX_ACCESSBASE_H_

View File

@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////
// Name: include/wx/afterstd.h
// Purpose: #include after STL headers
// Author: Vadim Zeitlin
// Modified by:
// Created: 07/07/03
// RCS-ID: $Id: afterstd.h 42906 2006-11-01 14:16:42Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/**
See the comments in beforestd.h.
*/
#if defined(__WXMSW__)
#include "wx/msw/winundef.h"
#endif
// undo what we did in wx/beforestd.h
#if defined(__VISUALC__) && __VISUALC__ <= 1201
// MSVC 5 does not have this
#if _MSC_VER > 1100
// don't restore this one for VC6, it gives it in each try/catch which is a
// bit annoying to say the least
#if _MSC_VER >= 0x1300
// unreachable code
#pragma warning(default:4702)
#endif // VC++ >= 7
#pragma warning(pop)
#else
// 'expression' : signed/unsigned mismatch
#pragma warning(default:4018)
// 'identifier' : unreferenced formal parameter
#pragma warning(default:4100)
// 'conversion' : conversion from 'type1' to 'type2',
// possible loss of data
#pragma warning(default:4244)
// C++ language change: to explicitly specialize class template
// 'identifier' use the following syntax
#pragma warning(default:4663)
#endif
#endif

View File

@ -0,0 +1,77 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/anidecod.h
// Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation
// Author: Francesco Montorsi
// CVS-ID: $Id: anidecod.h 45563 2007-04-21 18:17:50Z VZ $
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANIDECOD_H
#define _WX_ANIDECOD_H
#include "wx/defs.h"
#if wxUSE_STREAMS && wxUSE_ICO_CUR
#include "wx/stream.h"
#include "wx/image.h"
#include "wx/animdecod.h"
#include "wx/dynarray.h"
class /*WXDLLEXPORT*/ wxANIFrameInfo;
WX_DECLARE_EXPORTED_OBJARRAY(wxANIFrameInfo, wxANIFrameInfoArray);
WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray);
// --------------------------------------------------------------------------
// wxANIDecoder class
// --------------------------------------------------------------------------
class WXDLLEXPORT wxANIDecoder : public wxAnimationDecoder
{
public:
// constructor, destructor, etc.
wxANIDecoder();
~wxANIDecoder();
virtual wxSize GetFrameSize(unsigned int frame) const;
virtual wxPoint GetFramePosition(unsigned int frame) const;
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
virtual long GetDelay(unsigned int frame) const;
virtual wxColour GetTransparentColour(unsigned int frame) const;
// implementation of wxAnimationDecoder's pure virtuals
virtual bool CanRead( wxInputStream& stream ) const;
virtual bool Load( wxInputStream& stream );
bool ConvertToImage(unsigned int frame, wxImage *image) const;
wxAnimationDecoder *Clone() const
{ return new wxANIDecoder; }
wxAnimationType GetType() const
{ return wxANIMATION_TYPE_ANI; }
private:
// frames stored as wxImage(s): ANI files are meant to be used mostly for animated
// cursors and thus they do not use any optimization to encode differences between
// two frames: they are just a list of images to display sequentially.
wxImageArray m_images;
// the info about each image stored in m_images.
// NB: m_info.GetCount() may differ from m_images.GetCount()!
wxANIFrameInfoArray m_info;
// this is the wxCURHandler used to load the ICON chunk of the ANI files
static wxCURHandler sm_handler;
DECLARE_NO_COPY_CLASS(wxANIDecoder)
};
#endif // wxUSE_STREAM && wxUSE_ICO_CUR
#endif // _WX_ANIDECOD_H

View File

@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/animate.h
// Purpose: wxAnimation and wxAnimationCtrl
// Author: Julian Smart and Guillermo Rodriguez Garcia
// Modified by: Francesco Montorsi
// Created: 13/8/99
// RCS-ID: $Id: animate.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANIMATE_H_
#define _WX_ANIMATE_H_
#include "wx/defs.h"
#if wxUSE_ANIMATIONCTRL
#include "wx/animdecod.h"
#include "wx/control.h"
#include "wx/timer.h"
#include "wx/bitmap.h"
class WXDLLIMPEXP_FWD_ADV wxAnimation;
extern WXDLLIMPEXP_DATA_ADV(wxAnimation) wxNullAnimation;
extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxAnimationCtrlNameStr[];
// ----------------------------------------------------------------------------
// wxAnimationBase
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAnimationBase : public wxGDIObject
{
public:
wxAnimationBase() {}
virtual bool IsOk() const = 0;
// can be -1
virtual int GetDelay(unsigned int frame) const = 0;
virtual unsigned int GetFrameCount() const = 0;
virtual wxImage GetFrame(unsigned int frame) const = 0;
virtual wxSize GetSize() const = 0;
virtual bool LoadFile(const wxString& name,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
virtual bool Load(wxInputStream& stream,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
protected:
DECLARE_ABSTRACT_CLASS(wxAnimationBase)
};
// ----------------------------------------------------------------------------
// wxAnimationCtrlBase
// ----------------------------------------------------------------------------
// do not autoresize to the animation's size when SetAnimation() is called
#define wxAC_NO_AUTORESIZE (0x0010)
// default style does not include wxAC_NO_AUTORESIZE, that is, the control
// auto-resizes by default to fit the new animation when SetAnimation() is called
#define wxAC_DEFAULT_STYLE (wxNO_BORDER)
class WXDLLIMPEXP_ADV wxAnimationCtrlBase : public wxControl
{
public:
wxAnimationCtrlBase() { }
// public API
virtual bool LoadFile(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
virtual void SetAnimation(const wxAnimation &anim) = 0;
virtual wxAnimation GetAnimation() const = 0;
virtual bool Play() = 0;
virtual void Stop() = 0;
virtual bool IsPlaying() const = 0;
virtual void SetInactiveBitmap(const wxBitmap &bmp);
// always return the original bitmap set in this control
wxBitmap GetInactiveBitmap() const
{ return m_bmpStatic; }
protected:
// the inactive bitmap as it was set by the user
wxBitmap m_bmpStatic;
// the inactive bitmap currently shown in the control
// (may differ in the size from m_bmpStatic)
wxBitmap m_bmpStaticReal;
// updates m_bmpStaticReal from m_bmpStatic if needed
virtual void UpdateStaticImage();
// called by SetInactiveBitmap
virtual void DisplayStaticImage() = 0;
private:
DECLARE_ABSTRACT_CLASS(wxAnimationCtrlBase)
};
// ----------------------------------------------------------------------------
// include the platform-specific version of the wxAnimationCtrl class
// ----------------------------------------------------------------------------
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/animate.h"
#else
#include "wx/generic/animate.h"
#endif
#endif // wxUSE_ANIMATIONCTRL
#endif // _WX_ANIMATE_H_

View File

@ -0,0 +1,146 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/animdecod.h
// Purpose: wxAnimationDecoder
// Author: Francesco Montorsi
// CVS-ID: $Id: animdecod.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANIMDECOD_H
#define _WX_ANIMDECOD_H
#include "wx/defs.h"
#if wxUSE_STREAMS
#include "wx/colour.h"
#include "wx/gdicmn.h"
class WXDLLIMPEXP_FWD_BASE wxInputStream;
class WXDLLIMPEXP_FWD_CORE wxImage;
/*
Differences between a wxAnimationDecoder and a wxImageHandler:
1) wxImageHandlers always load an input stream directly into a given wxImage
object converting from the format-specific data representation to the
wxImage native format (RGB24).
wxAnimationDecoders always load an input stream using some optimized format
to store it which is format-depedent. This allows to store a (possibly big)
animation using a format which is a good compromise between required memory
and time required to blit in on the screen.
2) wxAnimationDecoders contain the animation data in some internal var.
That's why they derive from wxObjectRefData: they are data which can be shared.
3) wxAnimationDecoders can be used by a wxImageHandler to retrieve a frame
in wxImage format; the viceversa cannot be done.
4) wxAnimationDecoders are decoders only, thus do not support save features.
5) wxAnimationDecoders are directly used by wxAnimation (generic implementation)
as wxObjectRefData while they need to be 'wrapped' by a wxImageHandler for
wxImage uses.
*/
// --------------------------------------------------------------------------
// Constants
// --------------------------------------------------------------------------
// NB: the values of these enum items are not casual but coincide with the
// GIF disposal codes. Do not change them !!
enum wxAnimationDisposal
{
// No disposal specified. The decoder is not required to take any action.
wxANIM_UNSPECIFIED = -1,
// Do not dispose. The graphic is to be left in place.
wxANIM_DONOTREMOVE = 0,
// Restore to background color. The area used by the graphic must be
// restored to the background color.
wxANIM_TOBACKGROUND = 1,
// Restore to previous. The decoder is required to restore the area
// overwritten by the graphic with what was there prior to rendering the graphic.
wxANIM_TOPREVIOUS = 2
};
enum wxAnimationType
{
wxANIMATION_TYPE_INVALID,
wxANIMATION_TYPE_GIF,
wxANIMATION_TYPE_ANI,
wxANIMATION_TYPE_ANY
};
// --------------------------------------------------------------------------
// wxAnimationDecoder class
// --------------------------------------------------------------------------
class WXDLLEXPORT wxAnimationDecoder : public wxObjectRefData
{
public:
wxAnimationDecoder()
{
m_background = wxNullColour;
m_nFrames = 0;
}
virtual ~wxAnimationDecoder() { }
virtual bool Load( wxInputStream& stream ) = 0;
virtual bool CanRead( wxInputStream& stream ) const = 0;
virtual wxAnimationDecoder *Clone() const = 0;
virtual wxAnimationType GetType() const = 0;
// convert given frame to wxImage
virtual bool ConvertToImage(unsigned int frame, wxImage *image) const = 0;
// frame specific data getters
// not all frames may be of the same size; e.g. GIF allows to
// specify that between two frames only a smaller portion of the
// entire animation has changed.
virtual wxSize GetFrameSize(unsigned int frame) const = 0;
// the position of this frame in case it's not as big as m_szAnimation
// or wxPoint(0,0) otherwise.
virtual wxPoint GetFramePosition(unsigned int frame) const = 0;
// what should be done after displaying this frame.
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const = 0;
// the number of milliseconds this frame should be displayed.
// if returns -1 then the frame must be displayed forever.
virtual long GetDelay(unsigned int frame) const = 0;
// the transparent colour for this frame if any or wxNullColour.
virtual wxColour GetTransparentColour(unsigned int frame) const = 0;
// get global data
wxSize GetAnimationSize() const { return m_szAnimation; }
wxColour GetBackgroundColour() const { return m_background; }
unsigned int GetFrameCount() const { return m_nFrames; }
protected:
wxSize m_szAnimation;
unsigned int m_nFrames;
// this is the colour to use for the wxANIM_TOBACKGROUND disposal.
// if not specified by the animation, it's set to wxNullColour
wxColour m_background;
};
#endif // wxUSE_STREAM
#endif // _WX_ANIMDECOD_H

View File

@ -0,0 +1,708 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/app.h
// Purpose: wxAppBase class and macros used for declaration of wxApp
// derived class in the user code
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: app.h 51592 2008-02-08 08:17:41Z VZ $
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APP_H_BASE_
#define _WX_APP_H_BASE_
// ----------------------------------------------------------------------------
// headers we have to include here
// ----------------------------------------------------------------------------
#include "wx/event.h" // for the base class
#include "wx/build.h"
#include "wx/init.h" // we must declare wxEntry()
#include "wx/intl.h" // for wxLayoutDirection
class WXDLLIMPEXP_FWD_BASE wxAppConsole;
class WXDLLIMPEXP_FWD_BASE wxAppTraits;
class WXDLLIMPEXP_FWD_BASE wxCmdLineParser;
class WXDLLIMPEXP_FWD_BASE wxLog;
class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
#if wxUSE_GUI
class WXDLLIMPEXP_FWD_BASE wxEventLoop;
struct WXDLLIMPEXP_FWD_CORE wxVideoMode;
#endif
// ----------------------------------------------------------------------------
// typedefs
// ----------------------------------------------------------------------------
// the type of the function used to create a wxApp object on program start up
typedef wxAppConsole* (*wxAppInitializerFunction)();
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
enum
{
wxPRINT_WINDOWS = 1,
wxPRINT_POSTSCRIPT = 2
};
// ----------------------------------------------------------------------------
// wxAppConsole: wxApp for non-GUI applications
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
{
public:
// ctor and dtor
wxAppConsole();
virtual ~wxAppConsole();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// This is the very first function called for a newly created wxApp object,
// it is used by the library to do the global initialization. If, for some
// reason, you must override it (instead of just overriding OnInit(), as
// usual, for app-specific initializations), do not forget to call the base
// class version!
virtual bool Initialize(int& argc, wxChar **argv);
// This gives wxCocoa a chance to call OnInit() with a memory pool in place
virtual bool CallOnInit() { return OnInit(); }
// Called before OnRun(), this is a good place to do initialization -- if
// anything fails, return false from here to prevent the program from
// continuing. The command line is normally parsed here, call the base
// class OnInit() to do it.
virtual bool OnInit();
// this is here only temporary hopefully (FIXME)
virtual bool OnInitGui() { return true; }
// This is the replacement for the normal main(): all program work should
// be done here. When OnRun() returns, the programs starts shutting down.
virtual int OnRun() = 0;
// This is only called if OnInit() returned true so it's a good place to do
// any cleanup matching the initializations done there.
virtual int OnExit();
// This is the very last function called on wxApp object before it is
// destroyed. If you override it (instead of overriding OnExit() as usual)
// do not forget to call the base class version!
virtual void CleanUp();
// Called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core dump
// under Unix, application crash under Windows) to fatal program errors,
// however extreme care should be taken if you don't want this function to
// crash.
virtual void OnFatalException() { }
// Called from wxExit() function, should terminate the application a.s.a.p.
virtual void Exit();
// application info: name, description, vendor
// -------------------------------------------
// NB: all these should be set by the application itself, there are no
// reasonable default except for the application name which is taken to
// be argv[0]
// set/get the application name
wxString GetAppName() const
{
return m_appName.empty() ? m_className : m_appName;
}
void SetAppName(const wxString& name) { m_appName = name; }
// set/get the app class name
wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; }
// set/get the vendor name
const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; }
// cmd line parsing stuff
// ----------------------
// all of these methods may be overridden in the derived class to
// customize the command line parsing (by default only a few standard
// options are handled)
//
// you also need to call wxApp::OnInit() from YourApp::OnInit() for all
// this to work
#if wxUSE_CMDLINE_PARSER
// this one is called from OnInit() to add all supported options
// to the given parser (don't forget to call the base class version if you
// override it!)
virtual void OnInitCmdLine(wxCmdLineParser& parser);
// called after successfully parsing the command line, return true
// to continue and false to exit (don't forget to call the base class
// version if you override it!)
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// called if "--help" option was specified, return true to continue
// and false to exit
virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
// called if incorrect command line options were given, return
// false to abort and true to continue
virtual bool OnCmdLineError(wxCmdLineParser& parser);
#endif // wxUSE_CMDLINE_PARSER
// miscellaneous customization functions
// -------------------------------------
// create the app traits object to which we delegate for everything which
// either should be configurable by the user (then he can change the
// default behaviour simply by overriding CreateTraits() and returning his
// own traits object) or which is GUI/console dependent as then wxAppTraits
// allows us to abstract the differences behind the common façade
wxAppTraits *GetTraits();
// the functions below shouldn't be used now that we have wxAppTraits
#if WXWIN_COMPATIBILITY_2_4
#if wxUSE_LOG
// override this function to create default log target of arbitrary
// user-defined class (default implementation creates a wxLogGui
// object) -- this log object is used by default by all wxLogXXX()
// functions.
wxDEPRECATED( virtual wxLog *CreateLogTarget() );
#endif // wxUSE_LOG
// similar to CreateLogTarget() but for the global wxMessageOutput
// object
wxDEPRECATED( virtual wxMessageOutput *CreateMessageOutput() );
#endif // WXWIN_COMPATIBILITY_2_4
// event processing functions
// --------------------------
// this method allows to filter all the events processed by the program, so
// you should try to return quickly from it to avoid slowing down the
// program to the crawl
//
// return value should be -1 to continue with the normal event processing,
// or TRUE or FALSE to stop further processing and pretend that the event
// had been already processed or won't be processed at all, respectively
virtual int FilterEvent(wxEvent& event);
#if wxUSE_EXCEPTIONS
// call the specified handler on the given object with the given event
//
// this method only exists to allow catching the exceptions thrown by any
// event handler, it would lead to an extra (useless) virtual function call
// if the exceptions were not used, so it doesn't even exist in that case
virtual void HandleEvent(wxEvtHandler *handler,
wxEventFunction func,
wxEvent& event) const;
// Called when an unhandled C++ exception occurs inside OnRun(): note that
// the exception type is lost by now, so if you really want to handle the
// exception you should override OnRun() and put a try/catch around
// MainLoop() call there or use OnExceptionInMainLoop()
virtual void OnUnhandledException() { }
#endif // wxUSE_EXCEPTIONS
// process all events in the wxPendingEvents list -- it is necessary to
// call this function to process posted events. This happens during each
// event loop iteration in GUI mode but if there is no main loop, it may be
// also called directly.
virtual void ProcessPendingEvents();
// doesn't do anything in this class, just a hook for GUI wxApp
virtual bool Yield(bool WXUNUSED(onlyIfNeeded) = false) { return true; }
// make sure that idle events are sent again
virtual void WakeUpIdle() { }
// this is just a convenience: by providing its implementation here we
// avoid #ifdefs in the code using it
static bool IsMainLoopRunning() { return false; }
// debugging support
// -----------------
#ifdef __WXDEBUG__
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
//
// the arguments are the location of the failed assert (func may be empty
// if the compiler doesn't support C99 __FUNCTION__), the text of the
// assert itself and the user-specified message
virtual void OnAssertFailure(const wxChar *file,
int line,
const wxChar *func,
const wxChar *cond,
const wxChar *msg);
// old version of the function without func parameter, for compatibility
// only, override OnAssertFailure() in the new code
virtual void OnAssert(const wxChar *file,
int line,
const wxChar *cond,
const wxChar *msg);
#endif // __WXDEBUG__
// check that the wxBuildOptions object (constructed in the application
// itself, usually the one from IMPLEMENT_APP() macro) matches the build
// options of the library and abort if it doesn't
static bool CheckBuildOptions(const char *optionsSignature,
const char *componentName);
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED( static bool CheckBuildOptions(const wxBuildOptions& buildOptions) );
#endif
// implementation only from now on
// -------------------------------
// helpers for dynamic wxApp construction
static void SetInitializerFunction(wxAppInitializerFunction fn)
{ ms_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction()
{ return ms_appInitFn; }
// accessors for ms_appInstance field (external code might wish to modify
// it, this is why we provide a setter here as well, but you should really
// know what you're doing if you call it), wxTheApp is usually used instead
// of GetInstance()
static wxAppConsole *GetInstance() { return ms_appInstance; }
static void SetInstance(wxAppConsole *app) { ms_appInstance = app; }
// command line arguments (public for backwards compatibility)
int argc;
wxChar **argv;
protected:
// the function which creates the traits object when GetTraits() needs it
// for the first time
virtual wxAppTraits *CreateTraits();
// function used for dynamic wxApp creation
static wxAppInitializerFunction ms_appInitFn;
// the one and only global application object
static wxAppConsole *ms_appInstance;
// application info (must be set from the user code)
wxString m_vendorName, // vendor name (ACME Inc)
m_appName, // app name
m_className; // class name
// the class defining the application behaviour, NULL initially and created
// by GetTraits() when first needed
wxAppTraits *m_traits;
// the application object is a singleton anyhow, there is no sense in
// copying it
DECLARE_NO_COPY_CLASS(wxAppConsole)
};
// ----------------------------------------------------------------------------
// wxAppBase: the common part of wxApp implementations for all platforms
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class WXDLLIMPEXP_CORE wxAppBase : public wxAppConsole
{
public:
wxAppBase();
virtual ~wxAppBase();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// very first initialization function
//
// Override: very rarely
virtual bool Initialize(int& argc, wxChar **argv);
// a platform-dependent version of OnInit(): the code here is likely to
// depend on the toolkit. default version does nothing.
//
// Override: rarely.
virtual bool OnInitGui();
// called to start program execution - the default version just enters
// the main GUI loop in which events are received and processed until
// the last window is not deleted (if GetExitOnFrameDelete) or
// ExitMainLoop() is called. In console mode programs, the execution
// of the program really starts here
//
// Override: rarely in GUI applications, always in console ones.
virtual int OnRun();
// a matching function for OnInit()
virtual int OnExit();
// very last clean up function
//
// Override: very rarely
virtual void CleanUp();
// the worker functions - usually not used directly by the user code
// -----------------------------------------------------------------
// return true if we're running main loop, i.e. if the events can
// (already) be dispatched
static bool IsMainLoopRunning()
{
wxAppBase *app = wx_static_cast(wxAppBase *, GetInstance());
return app && app->m_mainLoop != NULL;
}
// execute the main GUI loop, the function returns when the loop ends
virtual int MainLoop();
// exit the main loop thus terminating the application
virtual void Exit();
// exit the main GUI loop during the next iteration (i.e. it does not
// stop the program immediately!)
virtual void ExitMainLoop();
// returns true if there are unprocessed events in the event queue
virtual bool Pending();
// process the first event in the event queue (blocks until an event
// appears if there are none currently, use Pending() if this is not
// wanted), returns false if the event loop should stop and true
// otherwise
virtual bool Dispatch();
// process all currently pending events right now
//
// it is an error to call Yield() recursively unless the value of
// onlyIfNeeded is true
//
// WARNING: this function is dangerous as it can lead to unexpected
// reentrancies (i.e. when called from an event handler it
// may result in calling the same event handler again), use
// with _extreme_ care or, better, don't use at all!
virtual bool Yield(bool onlyIfNeeded = false) = 0;
// this virtual function is called in the GUI mode when the application
// becomes idle and normally just sends wxIdleEvent to all interested
// parties
//
// it should return true if more idle events are needed, false if not
virtual bool ProcessIdle();
// Send idle event to window and all subwindows
// Returns true if more idle time is requested.
virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
#if wxUSE_EXCEPTIONS
// Function called if an uncaught exception is caught inside the main
// event loop: it may return true to continue running the event loop or
// false to stop it (in the latter case it may rethrow the exception as
// well)
virtual bool OnExceptionInMainLoop();
#endif // wxUSE_EXCEPTIONS
// top level window functions
// --------------------------
// return true if our app has focus
virtual bool IsActive() const { return m_isActive; }
// set the "main" top level window
void SetTopWindow(wxWindow *win) { m_topWindow = win; }
// return the "main" top level window (if it hadn't been set previously
// with SetTopWindow(), will return just some top level window and, if
// there are none, will return NULL)
virtual wxWindow *GetTopWindow() const;
// control the exit behaviour: by default, the program will exit the
// main loop (and so, usually, terminate) when the last top-level
// program window is deleted. Beware that if you disable this behaviour
// (with SetExitOnFrameDelete(false)), you'll have to call
// ExitMainLoop() explicitly from somewhere.
void SetExitOnFrameDelete(bool flag)
{ m_exitOnFrameDelete = flag ? Yes : No; }
bool GetExitOnFrameDelete() const
{ return m_exitOnFrameDelete == Yes; }
// display mode, visual, printing mode, ...
// ------------------------------------------------------------------------
// Get display mode that is used use. This is only used in framebuffer
// wxWin ports (such as wxMGL or wxDFB).
virtual wxVideoMode GetDisplayMode() const;
// Set display mode to use. This is only used in framebuffer wxWin
// ports (such as wxMGL or wxDFB). This method should be called from
// wxApp::OnInitGui
virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; }
// set use of best visual flag (see below)
void SetUseBestVisual( bool flag, bool forceTrueColour = false )
{ m_useBestVisual = flag; m_forceTrueColour = forceTrueColour; }
bool GetUseBestVisual() const { return m_useBestVisual; }
// set/get printing mode: see wxPRINT_XXX constants.
//
// default behaviour is the normal one for Unix: always use PostScript
// printing.
virtual void SetPrintMode(int WXUNUSED(mode)) { }
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
// Return the layout direction for the current locale or wxLayout_Default
// if it's unknown
virtual wxLayoutDirection GetLayoutDirection() const;
// command line parsing (GUI-specific)
// ------------------------------------------------------------------------
#if wxUSE_CMDLINE_PARSER
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
virtual void OnInitCmdLine(wxCmdLineParser& parser);
#endif
// miscellaneous other stuff
// ------------------------------------------------------------------------
// called by toolkit-specific code to set the app status: active (we have
// focus) or not and also the last window which had focus before we were
// deactivated
virtual void SetActive(bool isActive, wxWindow *lastFocus);
#if WXWIN_COMPATIBILITY_2_6
// OBSOLETE: don't use, always returns true
//
// returns true if the program is successfully initialized
wxDEPRECATED( bool Initialized() );
#endif // WXWIN_COMPATIBILITY_2_6
// perform standard OnIdle behaviour, ensure that this is always called
void OnIdle(wxIdleEvent& event);
protected:
// delete all objects in wxPendingDelete list
void DeletePendingObjects();
// override base class method to use GUI traits
virtual wxAppTraits *CreateTraits();
// the main event loop of the application (may be NULL if the loop hasn't
// been started yet or has already terminated)
wxEventLoop *m_mainLoop;
// the main top level window (may be NULL)
wxWindow *m_topWindow;
// if Yes, exit the main loop when the last top level window is deleted, if
// No don't do it and if Later -- only do it once we reach our OnRun()
//
// the explanation for using this strange scheme is given in appcmn.cpp
enum
{
Later = -1,
No,
Yes
} m_exitOnFrameDelete;
// true if the app wants to use the best visual on systems where
// more than one are available (Sun, SGI, XFree86 4.0 ?)
bool m_useBestVisual;
// force TrueColour just in case "best" isn't TrueColour
bool m_forceTrueColour;
// does any of our windows have focus?
bool m_isActive;
DECLARE_NO_COPY_CLASS(wxAppBase)
};
#if WXWIN_COMPATIBILITY_2_6
inline bool wxAppBase::Initialized() { return true; }
#endif // WXWIN_COMPATIBILITY_2_6
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// now include the declaration of the real class
// ----------------------------------------------------------------------------
#if wxUSE_GUI
#if defined(__WXPALMOS__)
#include "wx/palmos/app.h"
#elif defined(__WXMSW__)
#include "wx/msw/app.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/app.h"
#elif defined(__WXMGL__)
#include "wx/mgl/app.h"
#elif defined(__WXDFB__)
#include "wx/dfb/app.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/app.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/app.h"
#elif defined(__WXX11__)
#include "wx/x11/app.h"
#elif defined(__WXMAC__)
#include "wx/mac/app.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/app.h"
#elif defined(__WXPM__)
#include "wx/os2/app.h"
#endif
#else // !GUI
// allow using just wxApp (instead of wxAppConsole) in console programs
typedef wxAppConsole wxApp;
#endif // GUI/!GUI
// ----------------------------------------------------------------------------
// the global data
// ----------------------------------------------------------------------------
// for compatibility, we define this macro to access the global application
// object of type wxApp
//
// note that instead of using of wxTheApp in application code you should
// consider using DECLARE_APP() after which you may call wxGetApp() which will
// return the object of the correct type (i.e. MyApp and not wxApp)
//
// the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in
// console mode it does nothing at all
#define wxTheApp wx_static_cast(wxApp*, wxApp::GetInstance())
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
// event loop related functions only work in GUI programs
// ------------------------------------------------------
// Force an exit from main loop
extern void WXDLLIMPEXP_BASE wxExit();
// avoid redeclaring this function here if it had been already declated by
// wx/utils.h, this results in warnings from g++ with -Wredundant-decls
#ifndef wx_YIELD_DECLARED
#define wx_YIELD_DECLARED
// Yield to other apps/messages
extern bool WXDLLIMPEXP_BASE wxYield();
#endif // wx_YIELD_DECLARED
// Yield to other apps/messages
extern void WXDLLIMPEXP_BASE wxWakeUpIdle();
// ----------------------------------------------------------------------------
// macros for dynamic creation of the application object
// ----------------------------------------------------------------------------
// Having a global instance of this class allows wxApp to be aware of the app
// creator function. wxApp can then call this function to create a new app
// object. Convoluted, but necessary.
class WXDLLIMPEXP_BASE wxAppInitializer
{
public:
wxAppInitializer(wxAppInitializerFunction fn)
{ wxApp::SetInitializerFunction(fn); }
};
// the code below defines a IMPLEMENT_WXWIN_MAIN macro which you can use if
// your compiler really, really wants main() to be in your main program (e.g.
// hello.cpp). Now IMPLEMENT_APP should add this code if required.
#define IMPLEMENT_WXWIN_MAIN_CONSOLE \
int main(int argc, char **argv) { return wxEntry(argc, argv); }
// port-specific header could have defined it already in some special way
#ifndef IMPLEMENT_WXWIN_MAIN
#define IMPLEMENT_WXWIN_MAIN IMPLEMENT_WXWIN_MAIN_CONSOLE
#endif // defined(IMPLEMENT_WXWIN_MAIN)
#ifdef __WXUNIVERSAL__
#include "wx/univ/theme.h"
#ifdef wxUNIV_DEFAULT_THEME
#define IMPLEMENT_WX_THEME_SUPPORT \
WX_USE_THEME(wxUNIV_DEFAULT_THEME);
#else
#define IMPLEMENT_WX_THEME_SUPPORT
#endif
#else
#define IMPLEMENT_WX_THEME_SUPPORT
#endif
// Use this macro if you want to define your own main() or WinMain() function
// and call wxEntry() from there.
#define IMPLEMENT_APP_NO_MAIN(appname) \
wxAppConsole *wxCreateApp() \
{ \
wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
"your program"); \
return new appname; \
} \
wxAppInitializer \
wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
DECLARE_APP(appname) \
appname& wxGetApp() { return *wx_static_cast(appname*, wxApp::GetInstance()); }
// Same as IMPLEMENT_APP() normally but doesn't include themes support in
// wxUniversal builds
#define IMPLEMENT_APP_NO_THEMES(appname) \
IMPLEMENT_APP_NO_MAIN(appname) \
IMPLEMENT_WXWIN_MAIN
// Use this macro exactly once, the argument is the name of the wxApp-derived
// class which is the class of your application.
#define IMPLEMENT_APP(appname) \
IMPLEMENT_APP_NO_THEMES(appname) \
IMPLEMENT_WX_THEME_SUPPORT
// Same as IMPLEMENT_APP(), but for console applications.
#define IMPLEMENT_APP_CONSOLE(appname) \
IMPLEMENT_APP_NO_MAIN(appname) \
IMPLEMENT_WXWIN_MAIN_CONSOLE
// this macro can be used multiple times and just allows you to use wxGetApp()
// function
#define DECLARE_APP(appname) extern appname& wxGetApp();
// declare the stuff defined by IMPLEMENT_APP() macro, it's not really needed
// anywhere else but at the very least it suppresses icc warnings about
// defining extern symbols without prior declaration, and it shouldn't do any
// harm
extern wxAppConsole *wxCreateApp();
extern wxAppInitializer wxTheAppInitializer;
#endif // _WX_APP_H_BASE_

View File

@ -0,0 +1,272 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/apptrait.h
// Purpose: declaration of wxAppTraits and derived classes
// Author: Vadim Zeitlin
// Modified by:
// Created: 19.06.2003
// RCS-ID: $Id: apptrait.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APPTRAIT_H_
#define _WX_APPTRAIT_H_
#include "wx/string.h"
#include "wx/platinfo.h"
class WXDLLIMPEXP_FWD_BASE wxObject;
class WXDLLIMPEXP_FWD_BASE wxAppTraits;
#if wxUSE_FONTMAP
class WXDLLIMPEXP_FWD_CORE wxFontMapper;
#endif // wxUSE_FONTMAP
class WXDLLIMPEXP_FWD_BASE wxLog;
class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
class WXDLLIMPEXP_FWD_CORE wxRendererNative;
class WXDLLIMPEXP_FWD_BASE wxString;
class GSocketGUIFunctionsTable;
// ----------------------------------------------------------------------------
// wxAppTraits: this class defines various configurable aspects of wxApp
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_BASE wxStandardPathsBase;
class WXDLLIMPEXP_BASE wxAppTraitsBase
{
public:
// needed since this class declares virtual members
virtual ~wxAppTraitsBase() { }
// hooks for creating the global objects, may be overridden by the user
// ------------------------------------------------------------------------
#if wxUSE_LOG
// create the default log target
virtual wxLog *CreateLogTarget() = 0;
#endif // wxUSE_LOG
// create the global object used for printing out messages
virtual wxMessageOutput *CreateMessageOutput() = 0;
#if wxUSE_FONTMAP
// create the global font mapper object used for encodings/charset mapping
virtual wxFontMapper *CreateFontMapper() = 0;
#endif // wxUSE_FONTMAP
// get the renderer to use for drawing the generic controls (return value
// may be NULL in which case the default renderer for the current platform
// is used); this is used in GUI only and always returns NULL in console
//
// NB: returned pointer will be deleted by the caller
virtual wxRendererNative *CreateRenderer() = 0;
#if wxUSE_STDPATHS
// wxStandardPaths object is normally the same for wxBase and wxGUI
// except in the case of wxMac and wxCocoa
virtual wxStandardPathsBase& GetStandardPaths();
#endif // wxUSE_STDPATHS
// functions abstracting differences between GUI and console modes
// ------------------------------------------------------------------------
#ifdef __WXDEBUG__
// show the assert dialog with the specified message in GUI or just print
// the string to stderr in console mode
//
// base class version has an implementation (in spite of being pure
// virtual) in base/appbase.cpp which can be called as last resort.
//
// return true to suppress subsequent asserts, false to continue as before
virtual bool ShowAssertDialog(const wxString& msg) = 0;
#endif // __WXDEBUG__
// return true if fprintf(stderr) goes somewhere, false otherwise
virtual bool HasStderr() = 0;
// managing "pending delete" list: in GUI mode we can't immediately delete
// some objects because there may be unprocessed events for them and so we
// only do it during the next idle loop iteration while this is, of course,
// unnecessary in wxBase, so we have a few functions to abstract these
// operations
// add the object to the pending delete list in GUI, delete it immediately
// in wxBase
virtual void ScheduleForDestroy(wxObject *object) = 0;
// remove this object from the pending delete list in GUI, do nothing in
// wxBase
virtual void RemoveFromPendingDelete(wxObject *object) = 0;
#if wxUSE_SOCKETS
// return table of GUI callbacks for GSocket code or NULL in wxBase. This
// is needed because networking classes are in their own library and so
// they can't directly call GUI functions (the same net library can be
// used in both GUI and base apps). To complicate it further, GUI library
// ("wxCore") doesn't depend on networking library and so only a functions
// table can be passed around
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
#endif
// return information about the (native) toolkit currently used and its
// runtime (not compile-time) version.
// returns wxPORT_BASE for console applications and one of the remaining
// wxPORT_* values for GUI applications.
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
// return true if the port is using wxUniversal for the GUI, false if not
virtual bool IsUsingUniversalWidgets() const = 0;
// return the name of the Desktop Environment such as
// "KDE" or "GNOME". May return an empty string.
virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
protected:
#if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
// utility function: returns the stack frame as a plain wxString
virtual wxString GetAssertStackTrace();
#endif
};
// ----------------------------------------------------------------------------
// include the platform-specific version of the class
// ----------------------------------------------------------------------------
// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
// Unix code (and otherwise __UNIX__ wouldn't be defined)
// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
#if defined(__WXPALMOS__)
#include "wx/palmos/apptbase.h"
#elif defined(__WIN32__)
#include "wx/msw/apptbase.h"
#elif defined(__UNIX__) && !defined(__EMX__)
#include "wx/unix/apptbase.h"
#elif defined(__WXMAC__)
#include "wx/mac/apptbase.h"
#elif defined(__OS2__)
#include "wx/os2/apptbase.h"
#else // no platform-specific methods to add to wxAppTraits
// wxAppTraits must be a class because it was forward declared as class
class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
{
};
#endif // platform
// ============================================================================
// standard traits for console and GUI applications
// ============================================================================
// ----------------------------------------------------------------------------
// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG
virtual wxMessageOutput *CreateMessageOutput();
#if wxUSE_FONTMAP
virtual wxFontMapper *CreateFontMapper();
#endif // wxUSE_FONTMAP
virtual wxRendererNative *CreateRenderer();
#if wxUSE_SOCKETS
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
#endif
#ifdef __WXDEBUG__
virtual bool ShowAssertDialog(const wxString& msg);
#endif // __WXDEBUG__
virtual bool HasStderr();
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
// the GetToolkitVersion for console application is always the same
virtual wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
{
// no toolkits (wxBase is for console applications without GUI support)
// NB: zero means "no toolkit", -1 means "not initialized yet"
// so we must use zero here!
if (verMaj) *verMaj = 0;
if (verMin) *verMin = 0;
return wxPORT_BASE;
}
virtual bool IsUsingUniversalWidgets() const { return false; }
};
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG
virtual wxMessageOutput *CreateMessageOutput();
#if wxUSE_FONTMAP
virtual wxFontMapper *CreateFontMapper();
#endif // wxUSE_FONTMAP
virtual wxRendererNative *CreateRenderer();
#if wxUSE_SOCKETS
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
#endif
#ifdef __WXDEBUG__
virtual bool ShowAssertDialog(const wxString& msg);
#endif // __WXDEBUG__
virtual bool HasStderr();
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
virtual bool IsUsingUniversalWidgets() const
{
#ifdef __WXUNIVERSAL__
return true;
#else
return false;
#endif
}
};
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// include the platform-specific version of the classes above
// ----------------------------------------------------------------------------
// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
#if defined(__WXPALMOS__)
#include "wx/palmos/apptrait.h"
#elif defined(__WIN32__)
#include "wx/msw/apptrait.h"
#elif defined(__OS2__)
#include "wx/os2/apptrait.h"
#elif defined(__UNIX__)
#include "wx/unix/apptrait.h"
#elif defined(__WXMAC__)
#include "wx/mac/apptrait.h"
#elif defined(__DOS__)
#include "wx/msdos/apptrait.h"
#else
#if wxUSE_GUI
class wxGUIAppTraits : public wxGUIAppTraitsBase
{
};
#endif // wxUSE_GUI
class wxConsoleAppTraits: public wxConsoleAppTraitsBase
{
};
#endif // platform
#endif // _WX_APPTRAIT_H_

View File

@ -0,0 +1,381 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/archive.h
// Purpose: Streams for archive formats
// Author: Mike Wetherell
// RCS-ID: $Id: archive.h 43445 2006-11-16 14:30:20Z MW $
// Copyright: (c) 2004 Mike Wetherell
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ARCHIVE_H__
#define _WX_ARCHIVE_H__
#include "wx/defs.h"
#if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
#include "wx/stream.h"
#include "wx/filename.h"
/////////////////////////////////////////////////////////////////////////////
// wxArchiveNotifier
class WXDLLIMPEXP_BASE wxArchiveNotifier
{
public:
virtual ~wxArchiveNotifier() { }
virtual void OnEntryUpdated(class wxArchiveEntry& entry) = 0;
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveEntry
//
// Holds an entry's meta data, such as filename and timestamp.
class WXDLLIMPEXP_BASE wxArchiveEntry : public wxObject
{
public:
virtual ~wxArchiveEntry() { }
virtual wxDateTime GetDateTime() const = 0;
virtual wxFileOffset GetSize() const = 0;
virtual wxFileOffset GetOffset() const = 0;
virtual bool IsDir() const = 0;
virtual bool IsReadOnly() const = 0;
virtual wxString GetInternalName() const = 0;
virtual wxPathFormat GetInternalFormat() const = 0;
virtual wxString GetName(wxPathFormat format = wxPATH_NATIVE) const = 0;
virtual void SetDateTime(const wxDateTime& dt) = 0;
virtual void SetSize(wxFileOffset size) = 0;
virtual void SetIsDir(bool isDir = true) = 0;
virtual void SetIsReadOnly(bool isReadOnly = true) = 0;
virtual void SetName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE) = 0;
wxArchiveEntry *Clone() const { return DoClone(); }
void SetNotifier(wxArchiveNotifier& notifier);
virtual void UnsetNotifier() { m_notifier = NULL; }
protected:
wxArchiveEntry() : m_notifier(NULL) { }
wxArchiveEntry(const wxArchiveEntry& e) : wxObject(e), m_notifier(NULL) { }
virtual void SetOffset(wxFileOffset offset) = 0;
virtual wxArchiveEntry* DoClone() const = 0;
wxArchiveNotifier *GetNotifier() const { return m_notifier; }
wxArchiveEntry& operator=(const wxArchiveEntry& entry);
private:
wxArchiveNotifier *m_notifier;
DECLARE_ABSTRACT_CLASS(wxArchiveEntry)
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveInputStream
//
// GetNextEntry() returns an wxArchiveEntry object containing the meta-data
// for the next entry in the archive (and gives away ownership). Reading from
// the wxArchiveInputStream then returns the entry's data. Eof() becomes true
// after an attempt has been made to read past the end of the entry's data.
//
// When there are no more entries, GetNextEntry() returns NULL and sets Eof().
class WXDLLIMPEXP_BASE wxArchiveInputStream : public wxFilterInputStream
{
public:
typedef wxArchiveEntry entry_type;
virtual ~wxArchiveInputStream() { }
virtual bool OpenEntry(wxArchiveEntry& entry) = 0;
virtual bool CloseEntry() = 0;
wxArchiveEntry *GetNextEntry() { return DoGetNextEntry(); }
virtual char Peek() { return wxInputStream::Peek(); }
protected:
wxArchiveInputStream(wxInputStream& stream, wxMBConv& conv);
wxArchiveInputStream(wxInputStream *stream, wxMBConv& conv);
virtual wxArchiveEntry *DoGetNextEntry() = 0;
wxMBConv& GetConv() const { return m_conv; }
private:
wxMBConv& m_conv;
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveOutputStream
//
// PutNextEntry is used to create a new entry in the output archive, then
// the entry's data is written to the wxArchiveOutputStream.
//
// Only one entry can be open for output at a time; another call to
// PutNextEntry closes the current entry and begins the next.
//
// The overload 'bool PutNextEntry(wxArchiveEntry *entry)' takes ownership
// of the entry object.
class WXDLLIMPEXP_BASE wxArchiveOutputStream : public wxFilterOutputStream
{
public:
virtual ~wxArchiveOutputStream() { }
virtual bool PutNextEntry(wxArchiveEntry *entry) = 0;
virtual bool PutNextEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now(),
wxFileOffset size = wxInvalidOffset) = 0;
virtual bool PutNextDirEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now()) = 0;
virtual bool CopyEntry(wxArchiveEntry *entry,
wxArchiveInputStream& stream) = 0;
virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
virtual bool CloseEntry() = 0;
protected:
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
wxArchiveOutputStream(wxOutputStream *stream, wxMBConv& conv);
wxMBConv& GetConv() const { return m_conv; }
private:
wxMBConv& m_conv;
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveIterator
//
// An input iterator that can be used to transfer an archive's catalog to
// a container.
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
#include <iterator>
#include <utility>
template <class X, class Y> inline
void _wxSetArchiveIteratorValue(
X& val, Y entry, void *WXUNUSED(d))
{
val = X(entry);
}
template <class X, class Y, class Z> inline
void _wxSetArchiveIteratorValue(
std::pair<X, Y>& val, Z entry, Z WXUNUSED(d))
{
val = std::make_pair(X(entry->GetInternalName()), Y(entry));
}
#if defined _MSC_VER && _MSC_VER < 1300
template <class Arc, class T = Arc::entry_type*>
#else
template <class Arc, class T = typename Arc::entry_type*>
#endif
class wxArchiveIterator
{
public:
typedef std::input_iterator_tag iterator_category;
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;
wxArchiveIterator() : m_rep(NULL) { }
wxArchiveIterator(Arc& arc) {
typename Arc::entry_type* entry = arc.GetNextEntry();
m_rep = entry ? new Rep(arc, entry) : NULL;
}
wxArchiveIterator(const wxArchiveIterator& it) : m_rep(it.m_rep) {
if (m_rep)
m_rep->AddRef();
}
~wxArchiveIterator() {
if (m_rep)
m_rep->UnRef();
}
const T& operator *() const {
return m_rep->GetValue();
}
const T* operator ->() const {
return &**this;
}
wxArchiveIterator& operator =(const wxArchiveIterator& it) {
if (it.m_rep)
it.m_rep.AddRef();
if (m_rep)
m_rep.UnRef();
m_rep = it.m_rep;
return *this;
}
wxArchiveIterator& operator ++() {
m_rep = m_rep->Next();
return *this;
}
wxArchiveIterator operator ++(int) {
wxArchiveIterator it(*this);
++(*this);
return it;
}
bool operator ==(const wxArchiveIterator& j) const {
return m_rep == j.m_rep;
}
bool operator !=(const wxArchiveIterator& j) const {
return !(*this == j);
}
private:
class Rep {
Arc& m_arc;
typename Arc::entry_type* m_entry;
T m_value;
int m_ref;
public:
Rep(Arc& arc, typename Arc::entry_type* entry)
: m_arc(arc), m_entry(entry), m_value(), m_ref(1) { }
~Rep()
{ delete m_entry; }
void AddRef() {
m_ref++;
}
void UnRef() {
if (--m_ref == 0)
delete this;
}
Rep *Next() {
typename Arc::entry_type* entry = m_arc.GetNextEntry();
if (!entry) {
UnRef();
return NULL;
}
if (m_ref > 1) {
m_ref--;
return new Rep(m_arc, entry);
}
delete m_entry;
m_entry = entry;
m_value = T();
return this;
}
const T& GetValue() {
if (m_entry) {
_wxSetArchiveIteratorValue(m_value, m_entry, m_entry);
m_entry = NULL;
}
return m_value;
}
} *m_rep;
};
typedef wxArchiveIterator<wxArchiveInputStream> wxArchiveIter;
typedef wxArchiveIterator<wxArchiveInputStream,
std::pair<wxString, wxArchiveEntry*> > wxArchivePairIter;
#endif // wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
/////////////////////////////////////////////////////////////////////////////
// wxArchiveClassFactory
//
// A wxArchiveClassFactory instance for a particular archive type allows
// the creation of the other classes that may be needed.
void WXDLLIMPEXP_BASE wxUseArchiveClasses();
class WXDLLIMPEXP_BASE wxArchiveClassFactory : public wxFilterClassFactoryBase
{
public:
typedef wxArchiveEntry entry_type;
typedef wxArchiveInputStream instream_type;
typedef wxArchiveOutputStream outstream_type;
typedef wxArchiveNotifier notifier_type;
#if wxUSE_STL || defined WX_TEST_ARCHIVE_ITERATOR
typedef wxArchiveIter iter_type;
typedef wxArchivePairIter pairiter_type;
#endif
virtual ~wxArchiveClassFactory() { }
wxArchiveEntry *NewEntry() const
{ return DoNewEntry(); }
wxArchiveInputStream *NewStream(wxInputStream& stream) const
{ return DoNewStream(stream); }
wxArchiveOutputStream *NewStream(wxOutputStream& stream) const
{ return DoNewStream(stream); }
wxArchiveInputStream *NewStream(wxInputStream *stream) const
{ return DoNewStream(stream); }
wxArchiveOutputStream *NewStream(wxOutputStream *stream) const
{ return DoNewStream(stream); }
virtual wxString GetInternalName(
const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0;
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
wxMBConv& GetConv() const
{ if (m_pConv) return *m_pConv; else return wxConvLocal; }
static const wxArchiveClassFactory *Find(const wxChar *protocol,
wxStreamProtocolType type
= wxSTREAM_PROTOCOL);
static const wxArchiveClassFactory *GetFirst();
const wxArchiveClassFactory *GetNext() const { return m_next; }
void PushFront() { Remove(); m_next = sm_first; sm_first = this; }
void Remove();
protected:
// old compilers don't support covarient returns, so 'Do' methods are
// used to simulate them
virtual wxArchiveEntry *DoNewEntry() const = 0;
virtual wxArchiveInputStream *DoNewStream(wxInputStream& stream) const = 0;
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const = 0;
virtual wxArchiveInputStream *DoNewStream(wxInputStream *stream) const = 0;
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const = 0;
wxArchiveClassFactory() : m_pConv(NULL), m_next(this) { }
wxArchiveClassFactory& operator=(const wxArchiveClassFactory& WXUNUSED(f))
{ return *this; }
private:
wxMBConv *m_pConv;
static wxArchiveClassFactory *sm_first;
wxArchiveClassFactory *m_next;
DECLARE_ABSTRACT_CLASS(wxArchiveClassFactory)
};
#endif // wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
#endif // _WX_ARCHIVE_H__

View File

@ -0,0 +1,120 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/arrimpl.cpp
// Purpose: helper file for implementation of dynamic lists
// Author: Vadim Zeitlin
// Modified by:
// Created: 16.10.97
// RCS-ID: $Id: arrimpl.cpp 34241 2005-05-22 12:10:55Z JS $
// Copyright: (c) 1997 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
/*****************************************************************************
* Purpose: implements methods of "template" class declared in *
* DECLARE_OBJARRAY macro and which couldn't be implemented inline *
* (because they need the full definition of type T in scope) *
* *
* Usage: 1) #include dynarray.h *
* 2) WX_DECLARE_OBJARRAY *
* 3) #include arrimpl.cpp *
* 4) WX_DEFINE_OBJARRAY *
*****************************************************************************/
// needed to resolve the conflict between global T and macro parameter T
#define _WX_ERROR_REMOVE2(x) wxT("bad index in ") wxT(#x) wxT("::RemoveAt()")
// macro implements remaining (not inline) methods of template list
// (it's private to this file)
#undef _DEFINE_OBJARRAY
#define _DEFINE_OBJARRAY(T, name) \
name::~name() \
{ \
Empty(); \
} \
\
void name::DoCopy(const name& src) \
{ \
for ( size_t ui = 0; ui < src.size(); ui++ ) \
Add(src[ui]); \
} \
\
name& name::operator=(const name& src) \
{ \
Empty(); \
DoCopy(src); \
\
return *this; \
} \
\
name::name(const name& src) : wxArrayPtrVoid() \
{ \
DoCopy(src); \
} \
\
void name::DoEmpty() \
{ \
for ( size_t ui = 0; ui < size(); ui++ ) \
delete (T*)base_array::operator[](ui); \
} \
\
void name::RemoveAt(size_t uiIndex, size_t nRemove) \
{ \
wxCHECK_RET( uiIndex < size(), _WX_ERROR_REMOVE2(name) ); \
\
for (size_t i = 0; i < nRemove; i++ ) \
delete (T*)base_array::operator[](uiIndex + i); \
\
base_array::erase(begin() + uiIndex, begin() + uiIndex + nRemove); \
} \
\
void name::Add(const T& item, size_t nInsert) \
{ \
if (nInsert == 0) \
return; \
T* pItem = new T(item); \
size_t nOldSize = size(); \
if ( pItem != NULL ) \
base_array::insert(end(), nInsert, pItem); \
for (size_t i = 1; i < nInsert; i++) \
base_array::operator[](nOldSize + i) = new T(item); \
} \
\
void name::Insert(const T& item, size_t uiIndex, size_t nInsert) \
{ \
if (nInsert == 0) \
return; \
T* pItem = new T(item); \
if ( pItem != NULL ) \
base_array::insert(begin() + uiIndex, nInsert, pItem); \
for (size_t i = 1; i < nInsert; i++) \
base_array::operator[](uiIndex + i) = new T(item); \
} \
\
int name::Index(const T& Item, bool bFromEnd) const \
{ \
if ( bFromEnd ) { \
if ( size() > 0 ) { \
size_t ui = size() - 1; \
do { \
if ( (T*)base_array::operator[](ui) == &Item ) \
return wx_static_cast(int, ui); \
ui--; \
} \
while ( ui != 0 ); \
} \
} \
else { \
for( size_t ui = 0; ui < size(); ui++ ) { \
if( (T*)base_array::operator[](ui) == &Item ) \
return wx_static_cast(int, ui); \
} \
} \
\
return wxNOT_FOUND; \
}
// redefine the macro so that now it will generate the class implementation
// old value would provoke a compile-time error if this file is not included
#undef WX_DEFINE_OBJARRAY
#define WX_DEFINE_OBJARRAY(name) _DEFINE_OBJARRAY(_wxObjArray##name, name)

View File

@ -0,0 +1,377 @@
///////////////////////////////////////////////////////////////////////////////
// Name: include/wx/arrstr.h
// Purpose: wxArrayString class
// Author: Mattia Barbon and Vadim Zeitlin
// Modified by:
// Created: 07/07/03
// RCS-ID: $Id: arrstr.h 56758 2008-11-13 22:32:21Z VS $
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ARRSTR_H
#define _WX_ARRSTR_H
#include "wx/defs.h"
#include "wx/string.h"
WXDLLIMPEXP_BASE int wxCMPFUNC_CONV wxStringSortAscending(wxString*, wxString*);
WXDLLIMPEXP_BASE int wxCMPFUNC_CONV wxStringSortDescending(wxString*, wxString*);
#if wxUSE_STL
#include "wx/dynarray.h"
typedef int (wxCMPFUNC_CONV *CMPFUNCwxString)(wxString*, wxString*);
typedef wxString _wxArraywxBaseArrayStringBase;
_WX_DECLARE_BASEARRAY_2(_wxArraywxBaseArrayStringBase, wxBaseArrayStringBase,
wxArray_SortFunction<wxString>,
class WXDLLIMPEXP_BASE);
WX_DEFINE_USER_EXPORTED_TYPEARRAY(wxString, wxArrayStringBase,
wxBaseArrayStringBase, WXDLLIMPEXP_BASE);
_WX_DEFINE_SORTED_TYPEARRAY_2(wxString, wxSortedArrayStringBase,
wxBaseArrayStringBase, = wxStringSortAscending,
class WXDLLIMPEXP_BASE, CMPFUNCwxString);
class WXDLLIMPEXP_BASE wxArrayString : public wxArrayStringBase
{
public:
// type of function used by wxArrayString::Sort()
typedef int (wxCMPFUNC_CONV *CompareFunction)(const wxString& first,
const wxString& second);
wxArrayString() { }
wxArrayString(const wxArrayString& a) : wxArrayStringBase(a) { }
wxArrayString(size_t sz, const wxChar** a);
wxArrayString(size_t sz, const wxString* a);
int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
void Sort(bool reverseOrder = false);
void Sort(CompareFunction function);
void Sort(CMPFUNCwxString function) { wxArrayStringBase::Sort(function); }
size_t Add(const wxString& string, size_t copies = 1)
{
wxArrayStringBase::Add(string, copies);
return size() - copies;
}
};
class WXDLLIMPEXP_BASE wxSortedArrayString : public wxSortedArrayStringBase
{
public:
wxSortedArrayString() : wxSortedArrayStringBase(wxStringSortAscending)
{ }
wxSortedArrayString(const wxSortedArrayString& array)
: wxSortedArrayStringBase(array)
{ }
wxSortedArrayString(const wxArrayString& src)
: wxSortedArrayStringBase(wxStringSortAscending)
{
reserve(src.size());
for ( size_t n = 0; n < src.size(); n++ )
Add(src[n]);
}
int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
};
#else // if !wxUSE_STL
// ----------------------------------------------------------------------------
// The string array uses it's knowledge of internal structure of the wxString
// class to optimize string storage. Normally, we would store pointers to
// string, but as wxString is, in fact, itself a pointer (sizeof(wxString) is
// sizeof(char *)) we store these pointers instead. The cast to "wxString *" is
// really all we need to turn such pointer into a string!
//
// Of course, it can be called a dirty hack, but we use twice less memory and
// this approach is also more speed efficient, so it's probably worth it.
//
// Usage notes: when a string is added/inserted, a new copy of it is created,
// so the original string may be safely deleted. When a string is retrieved
// from the array (operator[] or Item() method), a reference is returned.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxArrayString
{
public:
// type of function used by wxArrayString::Sort()
typedef int (wxCMPFUNC_CONV *CompareFunction)(const wxString& first,
const wxString& second);
// type of function used by wxArrayString::Sort(), for compatibility with
// wxArray
typedef int (wxCMPFUNC_CONV *CompareFunction2)(wxString* first,
wxString* second);
// constructors and destructor
// default ctor
wxArrayString() { Init(false); }
// if autoSort is true, the array is always sorted (in alphabetical order)
//
// NB: the reason for using int and not bool is that like this we can avoid
// using this ctor for implicit conversions from "const char *" (which
// we'd like to be implicitly converted to wxString instead!)
//
// of course, using explicit would be even better - if all compilers
// supported it...
wxArrayString(int autoSort) { Init(autoSort != 0); }
// C string array ctor
wxArrayString(size_t sz, const wxChar** a);
// wxString string array ctor
wxArrayString(size_t sz, const wxString* a);
// copy ctor
wxArrayString(const wxArrayString& array);
// assignment operator
wxArrayString& operator=(const wxArrayString& src);
// not virtual, this class should not be derived from
~wxArrayString();
// memory management
// empties the list, but doesn't release memory
void Empty();
// empties the list and releases memory
void Clear();
// preallocates memory for given number of items
void Alloc(size_t nCount);
// minimzes the memory usage (by freeing all extra memory)
void Shrink();
// simple accessors
// number of elements in the array
size_t GetCount() const { return m_nCount; }
// is it empty?
bool IsEmpty() const { return m_nCount == 0; }
// number of elements in the array (GetCount is preferred API)
size_t Count() const { return m_nCount; }
// items access (range checking is done in debug version)
// get item at position uiIndex
wxString& Item(size_t nIndex) const
{
wxASSERT_MSG( nIndex < m_nCount,
_T("wxArrayString: index out of bounds") );
return *(wxString *)&(m_pItems[nIndex]);
}
// same as Item()
wxString& operator[](size_t nIndex) const { return Item(nIndex); }
// get last item
wxString& Last() const
{
wxASSERT_MSG( !IsEmpty(),
_T("wxArrayString: index out of bounds") );
return Item(Count() - 1);
}
// return a wxString[], useful for the controls which
// take one in their ctor. You must delete[] it yourself
// once you are done with it. Will return NULL if the
// ArrayString was empty.
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED( wxString* GetStringArray() const );
#endif
// item management
// Search the element in the array, starting from the beginning if
// bFromEnd is false or from end otherwise. If bCase, comparison is case
// sensitive (default). Returns index of the first item matched or
// wxNOT_FOUND
int Index (const wxChar *sz, bool bCase = true, bool bFromEnd = false) const;
// add new element at the end (if the array is not sorted), return its
// index
size_t Add(const wxString& str, size_t nInsert = 1);
// add new element at given position
void Insert(const wxString& str, size_t uiIndex, size_t nInsert = 1);
// expand the array to have count elements
void SetCount(size_t count);
// remove first item matching this value
void Remove(const wxChar *sz);
// remove item by index
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED( void Remove(size_t nIndex, size_t nRemove = 1) );
#endif
void RemoveAt(size_t nIndex, size_t nRemove = 1);
// sorting
// sort array elements in alphabetical order (or reversed alphabetical
// order if reverseOrder parameter is true)
void Sort(bool reverseOrder = false);
// sort array elements using specified comparaison function
void Sort(CompareFunction compareFunction);
void Sort(CompareFunction2 compareFunction);
// comparison
// compare two arrays case sensitively
bool operator==(const wxArrayString& a) const;
// compare two arrays case sensitively
bool operator!=(const wxArrayString& a) const { return !(*this == a); }
// STL-like interface
typedef wxString value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef int difference_type;
typedef size_t size_type;
// TODO: this code duplicates the one in dynarray.h
class reverse_iterator
{
typedef wxString value_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef reverse_iterator itor;
friend itor operator+(int o, const itor& it);
friend itor operator+(const itor& it, int o);
friend itor operator-(const itor& it, int o);
friend difference_type operator -(const itor& i1, const itor& i2);
public:
pointer m_ptr;
reverse_iterator() : m_ptr(NULL) { }
reverse_iterator(pointer ptr) : m_ptr(ptr) { }
reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }
reference operator*() const { return *m_ptr; }
pointer operator->() const { return m_ptr; }
itor& operator++() { --m_ptr; return *this; }
const itor operator++(int)
{ reverse_iterator tmp = *this; --m_ptr; return tmp; }
itor& operator--() { ++m_ptr; return *this; }
const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
};
class const_reverse_iterator
{
typedef wxString value_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef const_reverse_iterator itor;
friend itor operator+(int o, const itor& it);
friend itor operator+(const itor& it, int o);
friend itor operator-(const itor& it, int o);
friend difference_type operator -(const itor& i1, const itor& i2);
public:
pointer m_ptr;
const_reverse_iterator() : m_ptr(NULL) { }
const_reverse_iterator(pointer ptr) : m_ptr(ptr) { }
const_reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }
const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }
reference operator*() const { return *m_ptr; }
pointer operator->() const { return m_ptr; }
itor& operator++() { --m_ptr; return *this; }
const itor operator++(int)
{ itor tmp = *this; --m_ptr; return tmp; }
itor& operator--() { ++m_ptr; return *this; }
const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
};
wxArrayString(const_iterator first, const_iterator last)
{ Init(false); assign(first, last); }
wxArrayString(size_type n, const_reference v) { Init(false); assign(n, v); }
void assign(const_iterator first, const_iterator last);
void assign(size_type n, const_reference v)
{ clear(); Add(v, n); }
reference back() { return *(end() - 1); }
const_reference back() const { return *(end() - 1); }
iterator begin() { return (wxString *)&(m_pItems[0]); }
const_iterator begin() const { return (wxString *)&(m_pItems[0]); }
size_type capacity() const { return m_nSize; }
void clear() { Clear(); }
bool empty() const { return IsEmpty(); }
iterator end() { return begin() + GetCount(); }
const_iterator end() const { return begin() + GetCount(); }
iterator erase(iterator first, iterator last)
{
size_t idx = first - begin();
RemoveAt(idx, last - first);
return begin() + idx;
}
iterator erase(iterator it) { return erase(it, it + 1); }
reference front() { return *begin(); }
const_reference front() const { return *begin(); }
void insert(iterator it, size_type n, const_reference v)
{ Insert(v, it - begin(), n); }
iterator insert(iterator it, const_reference v = value_type())
{ size_t idx = it - begin(); Insert(v, idx); return begin() + idx; }
void insert(iterator it, const_iterator first, const_iterator last);
size_type max_size() const { return INT_MAX; }
void pop_back() { RemoveAt(GetCount() - 1); }
void push_back(const_reference v) { Add(v); }
reverse_iterator rbegin() { return reverse_iterator(end() - 1); }
const_reverse_iterator rbegin() const;
reverse_iterator rend() { return reverse_iterator(begin() - 1); }
const_reverse_iterator rend() const;
void reserve(size_type n) /* base::reserve*/;
void resize(size_type n, value_type v = value_type());
size_type size() const { return GetCount(); }
protected:
void Init(bool autoSort); // common part of all ctors
void Copy(const wxArrayString& src); // copies the contents of another array
private:
void Grow(size_t nIncrement = 0); // makes array bigger if needed
void Free(); // free all the strings stored
void DoSort(); // common part of all Sort() variants
size_t m_nSize, // current size of the array
m_nCount; // current number of elements
wxChar **m_pItems; // pointer to data
bool m_autoSort; // if true, keep the array always sorted
};
class WXDLLIMPEXP_BASE wxSortedArrayString : public wxArrayString
{
public:
wxSortedArrayString() : wxArrayString(true)
{ }
wxSortedArrayString(const wxArrayString& array) : wxArrayString(true)
{ Copy(array); }
};
#endif // !wxUSE_STL
// this class provides a temporary wxString* from a
// wxArrayString
class WXDLLIMPEXP_BASE wxCArrayString
{
public:
wxCArrayString( const wxArrayString& array )
: m_array( array ), m_strings( NULL )
{ }
~wxCArrayString() { delete[] m_strings; }
size_t GetCount() const { return m_array.GetCount(); }
wxString* GetStrings()
{
if( m_strings ) return m_strings;
size_t count = m_array.GetCount();
m_strings = new wxString[count];
for( size_t i = 0; i < count; ++i )
m_strings[i] = m_array[i];
return m_strings;
}
#if wxABI_VERSION >= 20810
wxString* Release();
#endif // wxABI_VERSION >= 20810
private:
const wxArrayString& m_array;
wxString* m_strings;
};
#endif

View File

@ -0,0 +1,204 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/artprov.h
// Purpose: wxArtProvider class
// Author: Vaclav Slavik
// Modified by:
// Created: 18/03/2002
// RCS-ID: $Id: artprov.h 57701 2008-12-31 23:40:06Z VS $
// Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ARTPROV_H_
#define _WX_ARTPROV_H_
#include "wx/string.h"
#include "wx/bitmap.h"
#include "wx/icon.h"
class WXDLLIMPEXP_FWD_CORE wxArtProvidersList;
class WXDLLIMPEXP_FWD_CORE wxArtProviderCache;
class wxArtProviderModule;
// ----------------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------------
typedef wxString wxArtClient;
typedef wxString wxArtID;
#define wxART_MAKE_CLIENT_ID_FROM_STR(id) (id + _T("_C"))
#define wxART_MAKE_CLIENT_ID(id) _T(#id) _T("_C")
#define wxART_MAKE_ART_ID_FROM_STR(id) (id)
#define wxART_MAKE_ART_ID(id) _T(#id)
// ----------------------------------------------------------------------------
// Art clients
// ----------------------------------------------------------------------------
#define wxART_TOOLBAR wxART_MAKE_CLIENT_ID(wxART_TOOLBAR)
#define wxART_MENU wxART_MAKE_CLIENT_ID(wxART_MENU)
#define wxART_FRAME_ICON wxART_MAKE_CLIENT_ID(wxART_FRAME_ICON)
#define wxART_CMN_DIALOG wxART_MAKE_CLIENT_ID(wxART_CMN_DIALOG)
#define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER)
#define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX)
#define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON)
#define wxART_OTHER wxART_MAKE_CLIENT_ID(wxART_OTHER)
// ----------------------------------------------------------------------------
// Art IDs
// ----------------------------------------------------------------------------
#define wxART_ADD_BOOKMARK wxART_MAKE_ART_ID(wxART_ADD_BOOKMARK)
#define wxART_DEL_BOOKMARK wxART_MAKE_ART_ID(wxART_DEL_BOOKMARK)
#define wxART_HELP_SIDE_PANEL wxART_MAKE_ART_ID(wxART_HELP_SIDE_PANEL)
#define wxART_HELP_SETTINGS wxART_MAKE_ART_ID(wxART_HELP_SETTINGS)
#define wxART_HELP_BOOK wxART_MAKE_ART_ID(wxART_HELP_BOOK)
#define wxART_HELP_FOLDER wxART_MAKE_ART_ID(wxART_HELP_FOLDER)
#define wxART_HELP_PAGE wxART_MAKE_ART_ID(wxART_HELP_PAGE)
#define wxART_GO_BACK wxART_MAKE_ART_ID(wxART_GO_BACK)
#define wxART_GO_FORWARD wxART_MAKE_ART_ID(wxART_GO_FORWARD)
#define wxART_GO_UP wxART_MAKE_ART_ID(wxART_GO_UP)
#define wxART_GO_DOWN wxART_MAKE_ART_ID(wxART_GO_DOWN)
#define wxART_GO_TO_PARENT wxART_MAKE_ART_ID(wxART_GO_TO_PARENT)
#define wxART_GO_HOME wxART_MAKE_ART_ID(wxART_GO_HOME)
#define wxART_FILE_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN)
#define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE)
#define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS)
#define wxART_PRINT wxART_MAKE_ART_ID(wxART_PRINT)
#define wxART_HELP wxART_MAKE_ART_ID(wxART_HELP)
#define wxART_TIP wxART_MAKE_ART_ID(wxART_TIP)
#define wxART_REPORT_VIEW wxART_MAKE_ART_ID(wxART_REPORT_VIEW)
#define wxART_LIST_VIEW wxART_MAKE_ART_ID(wxART_LIST_VIEW)
#define wxART_NEW_DIR wxART_MAKE_ART_ID(wxART_NEW_DIR)
#define wxART_HARDDISK wxART_MAKE_ART_ID(wxART_HARDDISK)
#define wxART_FLOPPY wxART_MAKE_ART_ID(wxART_FLOPPY)
#define wxART_CDROM wxART_MAKE_ART_ID(wxART_CDROM)
#define wxART_REMOVABLE wxART_MAKE_ART_ID(wxART_REMOVABLE)
#define wxART_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER)
#define wxART_FOLDER_OPEN wxART_MAKE_ART_ID(wxART_FOLDER_OPEN)
#define wxART_GO_DIR_UP wxART_MAKE_ART_ID(wxART_GO_DIR_UP)
#define wxART_EXECUTABLE_FILE wxART_MAKE_ART_ID(wxART_EXECUTABLE_FILE)
#define wxART_NORMAL_FILE wxART_MAKE_ART_ID(wxART_NORMAL_FILE)
#define wxART_TICK_MARK wxART_MAKE_ART_ID(wxART_TICK_MARK)
#define wxART_CROSS_MARK wxART_MAKE_ART_ID(wxART_CROSS_MARK)
#define wxART_ERROR wxART_MAKE_ART_ID(wxART_ERROR)
#define wxART_QUESTION wxART_MAKE_ART_ID(wxART_QUESTION)
#define wxART_WARNING wxART_MAKE_ART_ID(wxART_WARNING)
#define wxART_INFORMATION wxART_MAKE_ART_ID(wxART_INFORMATION)
#define wxART_MISSING_IMAGE wxART_MAKE_ART_ID(wxART_MISSING_IMAGE)
#define wxART_COPY wxART_MAKE_ART_ID(wxART_COPY)
#define wxART_CUT wxART_MAKE_ART_ID(wxART_CUT)
#define wxART_PASTE wxART_MAKE_ART_ID(wxART_PASTE)
#define wxART_DELETE wxART_MAKE_ART_ID(wxART_DELETE)
#define wxART_NEW wxART_MAKE_ART_ID(wxART_NEW)
#define wxART_UNDO wxART_MAKE_ART_ID(wxART_UNDO)
#define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO)
#define wxART_QUIT wxART_MAKE_ART_ID(wxART_QUIT)
#define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND)
#define wxART_FIND_AND_REPLACE wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE)
// ----------------------------------------------------------------------------
// wxArtProvider class
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxArtProvider : public wxObject
{
public:
// Dtor removes the provider from providers stack if it's still on it
virtual ~wxArtProvider();
// Add new provider to the top of providers stack (i.e. the provider will
// be queried first of all).
static void Push(wxArtProvider *provider);
// Add new provider to the bottom of providers stack (i.e. the provider
// will be queried as the last one).
#if wxABI_VERSION >= 20810
static void PushBack(wxArtProvider *provider);
#endif
// same as PushBack()
static void Insert(wxArtProvider *provider);
// Remove latest added provider and delete it.
static bool Pop();
// Remove provider from providers stack but don't delete it.
static bool Remove(wxArtProvider *provider);
// Delete the given provider and remove it from the providers stack.
static bool Delete(wxArtProvider *provider);
// Query the providers for bitmap with given ID and return it. Return
// wxNullBitmap if no provider provides it.
static wxBitmap GetBitmap(const wxArtID& id,
const wxArtClient& client = wxART_OTHER,
const wxSize& size = wxDefaultSize);
// Query the providers for icon with given ID and return it. Return
// wxNullIcon if no provider provides it.
static wxIcon GetIcon(const wxArtID& id,
const wxArtClient& client = wxART_OTHER,
const wxSize& size = wxDefaultSize);
// Get the size hint of an icon from a specific wxArtClient, queries
// the topmost provider if platform_dependent = false
static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false);
#if WXWIN_COMPATIBILITY_2_6
// use the corresponding methods without redundant "Provider" suffix
wxDEPRECATED( static void PushProvider(wxArtProvider *provider) );
wxDEPRECATED( static void InsertProvider(wxArtProvider *provider) );
wxDEPRECATED( static bool PopProvider() );
// use Delete() if this is what you really need, or just delete the
// provider pointer, do not use Remove() as it does not delete the pointer
// unlike RemoveProvider() which does
wxDEPRECATED( static bool RemoveProvider(wxArtProvider *provider) );
#endif // WXWIN_COMPATIBILITY_2_6
protected:
friend class wxArtProviderModule;
// Initializes default provider
static void InitStdProvider();
// Initializes platform's native provider, if available (e.g. GTK2)
static void InitNativeProvider();
// Destroy caches & all providers
static void CleanUpProviders();
// Get the default size of an icon for a specific client
virtual wxSize DoGetSizeHint(const wxArtClient& client)
{
return GetSizeHint(client, true);
}
// Derived classes must override this method to create requested
// art resource. This method is called only once per instance's
// lifetime for each requested wxArtID.
virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client),
const wxSize& WXUNUSED(size)) = 0;
private:
static void CommonAddingProvider();
private:
// list of providers:
static wxArtProvidersList *sm_providers;
// art resources cache (so that CreateXXX is not called that often):
static wxArtProviderCache *sm_cache;
DECLARE_ABSTRACT_CLASS(wxArtProvider)
};
#endif // _WX_ARTPROV_H_

View File

@ -0,0 +1,23 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/aui.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Modified by:
// Created: 2005-05-17
// RCS-ID: $Id: aui.h 55195 2008-08-23 06:31:01Z BIW $
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_H_
#define _WX_AUI_H_
#include "wx/aui/framemanager.h"
#include "wx/aui/dockart.h"
#include "wx/aui/floatpane.h"
#include "wx/aui/auibar.h"
#include "wx/aui/auibook.h"
#include "wx/aui/tabmdi.h"
#endif // _WX_AUI_H_

View File

@ -0,0 +1,684 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/toolbar.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Modified by:
// Created: 2008-08-04
// RCS-ID: $Id: auibar.h 55522 2008-09-08 09:54:28Z BIW $
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUIBAR_H_
#define _WX_AUIBAR_H_
#include "wx/defs.h"
#if wxUSE_AUI
#if wxABI_VERSION >= 20809
#include "wx/control.h"
enum wxAuiToolBarStyle
{
wxAUI_TB_TEXT = 1 << 0,
wxAUI_TB_NO_TOOLTIPS = 1 << 1,
wxAUI_TB_NO_AUTORESIZE = 1 << 2,
wxAUI_TB_GRIPPER = 1 << 3,
wxAUI_TB_OVERFLOW = 1 << 4,
wxAUI_TB_VERTICAL = 1 << 5,
wxAUI_TB_HORZ_LAYOUT = 1 << 6,
wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT),
wxAUI_TB_DEFAULT_STYLE = 0
};
enum wxAuiToolBarArtSetting
{
wxAUI_TBART_SEPARATOR_SIZE = 0,
wxAUI_TBART_GRIPPER_SIZE = 1,
wxAUI_TBART_OVERFLOW_SIZE = 2
};
enum wxAuiToolBarToolTextOrientation
{
wxAUI_TBTOOL_TEXT_LEFT = 0, // unused/unimplemented
wxAUI_TBTOOL_TEXT_RIGHT = 1,
wxAUI_TBTOOL_TEXT_TOP = 2, // unused/unimplemented
wxAUI_TBTOOL_TEXT_BOTTOM = 3
};
// aui toolbar event class
class WXDLLIMPEXP_AUI wxAuiToolBarEvent : public wxNotifyEvent
{
public:
wxAuiToolBarEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0)
: wxNotifyEvent(command_type, win_id)
{
is_dropdown_clicked = false;
click_pt = wxPoint(-1, -1);
rect = wxRect(-1,-1, 0, 0);
tool_id = -1;
}
#ifndef SWIG
wxAuiToolBarEvent(const wxAuiToolBarEvent& c) : wxNotifyEvent(c)
{
is_dropdown_clicked = c.is_dropdown_clicked;
click_pt = c.click_pt;
rect = c.rect;
tool_id = c.tool_id;
}
#endif
wxEvent *Clone() const { return new wxAuiToolBarEvent(*this); }
bool IsDropDownClicked() const { return is_dropdown_clicked; }
void SetDropDownClicked(bool c) { is_dropdown_clicked = c; }
wxPoint GetClickPoint() const { return click_pt; }
void SetClickPoint(const wxPoint& p) { click_pt = p; }
wxRect GetItemRect() const { return rect; }
void SetItemRect(const wxRect& r) { rect = r; }
int GetToolId() const { return tool_id; }
void SetToolId(int id) { tool_id = id; }
private:
bool is_dropdown_clicked;
wxPoint click_pt;
wxRect rect;
int tool_id;
#ifndef SWIG
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiToolBarEvent)
#endif
};
class WXDLLIMPEXP_AUI wxAuiToolBarItem
{
friend class wxAuiToolBar;
public:
wxAuiToolBarItem()
{
window = NULL;
sizer_item = NULL;
spacer_pixels = 0;
id = 0;
kind = wxITEM_NORMAL;
state = 0; // normal, enabled
proportion = 0;
active = true;
dropdown = true;
sticky = true;
user_data = 0;
}
wxAuiToolBarItem(const wxAuiToolBarItem& c)
{
Assign(c);
}
wxAuiToolBarItem& operator=(const wxAuiToolBarItem& c)
{
Assign(c);
return *this;
}
void Assign(const wxAuiToolBarItem& c)
{
window = c.window;
label = c.label;
bitmap = c.bitmap;
disabled_bitmap = c.disabled_bitmap;
hover_bitmap = c.hover_bitmap;
short_help = c.short_help;
long_help = c.long_help;
sizer_item = c.sizer_item;
min_size = c.min_size;
spacer_pixels = c.spacer_pixels;
id = c.id;
kind = c.kind;
state = c.state;
proportion = c.proportion;
active = c.active;
dropdown = c.dropdown;
sticky = c.sticky;
user_data = c.user_data;
}
void SetWindow(wxWindow* w) { window = w; }
wxWindow* GetWindow() { return window; }
void SetId(int new_id) { id = new_id; }
int GetId() const { return id; }
void SetKind(int new_kind) { kind = new_kind; }
int GetKind() const { return kind; }
void SetState(int new_state) { state = new_state; }
int GetState() const { return state; }
void SetSizerItem(wxSizerItem* s) { sizer_item = s; }
wxSizerItem* GetSizerItem() const { return sizer_item; }
void SetLabel(const wxString& s) { label = s; }
const wxString& GetLabel() const { return label; }
void SetBitmap(const wxBitmap& bmp) { bitmap = bmp; }
const wxBitmap& GetBitmap() const { return bitmap; }
void SetDisabledBitmap(const wxBitmap& bmp) { disabled_bitmap = bmp; }
const wxBitmap& GetDisabledBitmap() const { return disabled_bitmap; }
void SetHoverBitmap(const wxBitmap& bmp) { hover_bitmap = bmp; }
const wxBitmap& GetHoverBitmap() const { return hover_bitmap; }
void SetShortHelp(const wxString& s) { short_help = s; }
const wxString& GetShortHelp() const { return short_help; }
void SetLongHelp(const wxString& s) { long_help = s; }
const wxString& GetLongHelp() const { return long_help; }
void SetMinSize(const wxSize& s) { min_size = s; }
const wxSize& GetMinSize() const { return min_size; }
void SetSpacerPixels(int s) { spacer_pixels = s; }
int GetSpacerPixels() const { return spacer_pixels; }
void SetProportion(int p) { proportion = p; }
int GetProportion() const { return proportion; }
void SetActive(bool b) { active = b; }
bool IsActive() const { return active; }
void SetHasDropDown(bool b) { dropdown = b; }
bool HasDropDown() const { return dropdown; }
void SetSticky(bool b) { sticky = b; }
bool IsSticky() const { return sticky; }
void SetUserData(long l) { user_data = l; }
long GetUserData() const { return user_data; }
private:
wxWindow* window; // item's associated window
wxString label; // label displayed on the item
wxBitmap bitmap; // item's bitmap
wxBitmap disabled_bitmap; // item's disabled bitmap
wxBitmap hover_bitmap; // item's hover bitmap
wxString short_help; // short help (for tooltip)
wxString long_help; // long help (for status bar)
wxSizerItem* sizer_item; // sizer item
wxSize min_size; // item's minimum size
int spacer_pixels; // size of a spacer
int id; // item's id
int kind; // item's kind
int state; // state
int proportion; // proportion
bool active; // true if the item is currently active
bool dropdown; // true if the item has a dropdown button
bool sticky; // overrides button states if true (always active)
long user_data; // user-specified data
};
#ifndef SWIG
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiToolBarItem, wxAuiToolBarItemArray, WXDLLIMPEXP_AUI);
#endif
// tab art class
class WXDLLIMPEXP_AUI wxAuiToolBarArt
{
public:
wxAuiToolBarArt() { }
virtual ~wxAuiToolBarArt() { }
virtual wxAuiToolBarArt* Clone() = 0;
virtual void SetFlags(unsigned int flags) = 0;
virtual void SetFont(const wxFont& font) = 0;
virtual void SetTextOrientation(int orientation) = 0;
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawDropDownButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawControlLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawGripper(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawOverflowButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
int state) = 0;
virtual wxSize GetLabelSize(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) = 0;
virtual wxSize GetToolSize(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) = 0;
virtual int GetElementSize(int element_id) = 0;
virtual void SetElementSize(int element_id, int size) = 0;
virtual int ShowDropDown(
wxWindow* wnd,
const wxAuiToolBarItemArray& items) = 0;
};
class WXDLLIMPEXP_AUI wxAuiDefaultToolBarArt : public wxAuiToolBarArt
{
public:
wxAuiDefaultToolBarArt();
virtual ~wxAuiDefaultToolBarArt();
virtual wxAuiToolBarArt* Clone();
virtual void SetFlags(unsigned int flags);
virtual void SetFont(const wxFont& font);
virtual void SetTextOrientation(int orientation);
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
virtual void DrawLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect);
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect);
virtual void DrawDropDownButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect);
virtual void DrawControlLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect);
virtual void DrawSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
virtual void DrawGripper(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
virtual void DrawOverflowButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
int state);
virtual wxSize GetLabelSize(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item);
virtual wxSize GetToolSize(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item);
virtual int GetElementSize(int element);
virtual void SetElementSize(int element_id, int size);
virtual int ShowDropDown(wxWindow* wnd,
const wxAuiToolBarItemArray& items);
protected:
wxBitmap m_button_dropdown_bmp;
wxBitmap m_disabled_button_dropdown_bmp;
wxBitmap m_overflow_bmp;
wxBitmap m_disabled_overflow_bmp;
wxColour m_base_colour;
wxColour m_highlight_colour;
wxFont m_font;
unsigned int m_flags;
int m_text_orientation;
wxPen m_gripper_pen1;
wxPen m_gripper_pen2;
wxPen m_gripper_pen3;
int m_separator_size;
int m_gripper_size;
int m_overflow_size;
};
class WXDLLIMPEXP_AUI wxAuiToolBar : public wxControl
{
public:
wxAuiToolBar(wxWindow* parent,
wxWindowID id = -1,
const wxPoint& position = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_TB_DEFAULT_STYLE);
~wxAuiToolBar();
void SetWindowStyleFlag(long style);
void SetArtProvider(wxAuiToolBarArt* art);
wxAuiToolBarArt* GetArtProvider() const;
bool SetFont(const wxFont& font);
void AddTool(int tool_id,
const wxString& label,
const wxBitmap& bitmap,
const wxString& short_help_string = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL);
void AddTool(int tool_id,
const wxString& label,
const wxBitmap& bitmap,
const wxBitmap& disabled_bitmap,
wxItemKind kind,
const wxString& short_help_string,
const wxString& long_help_string,
wxObject* client_data);
void AddTool(int tool_id,
const wxBitmap& bitmap,
const wxBitmap& disabled_bitmap,
bool toggle = false,
wxObject* client_data = NULL,
const wxString& short_help_string = wxEmptyString,
const wxString& long_help_string = wxEmptyString)
{
AddTool(tool_id,
wxEmptyString,
bitmap,
disabled_bitmap,
toggle ? wxITEM_CHECK : wxITEM_NORMAL,
short_help_string,
long_help_string,
client_data);
}
void AddLabel(int tool_id,
const wxString& label = wxEmptyString,
const int width = -1);
void AddControl(wxControl* control,
const wxString& label = wxEmptyString);
void AddSeparator();
void AddSpacer(int pixels);
void AddStretchSpacer(int proportion = 1);
bool Realize();
wxControl* FindControl(int window_id);
wxAuiToolBarItem* FindToolByPosition(wxCoord x, wxCoord y) const;
wxAuiToolBarItem* FindToolByIndex(int idx) const;
wxAuiToolBarItem* FindTool(int tool_id) const;
void ClearTools() { Clear() ; }
void Clear();
bool DeleteTool(int tool_id);
bool DeleteByIndex(int tool_id);
size_t GetToolCount() const;
int GetToolPos(int tool_id) const { return GetToolIndex(tool_id); }
int GetToolIndex(int tool_id) const;
bool GetToolFits(int tool_id) const;
wxRect GetToolRect(int tool_id) const;
bool GetToolFitsByIndex(int tool_id) const;
bool GetToolBarFits() const;
void SetMargins(const wxSize& size) { SetMargins(size.x, size.x, size.y, size.y); }
void SetMargins(int x, int y) { SetMargins(x, x, y, y); }
void SetMargins(int left, int right, int top, int bottom);
void SetToolBitmapSize(const wxSize& size);
wxSize GetToolBitmapSize() const;
bool GetOverflowVisible() const;
void SetOverflowVisible(bool visible);
bool GetGripperVisible() const;
void SetGripperVisible(bool visible);
void ToggleTool(int tool_id, bool state);
bool GetToolToggled(int tool_id) const;
void EnableTool(int tool_id, bool state);
bool GetToolEnabled(int tool_id) const;
void SetToolDropDown(int tool_id, bool dropdown);
bool GetToolDropDown(int tool_id) const;
void SetToolBorderPadding(int padding);
int GetToolBorderPadding() const;
void SetToolTextOrientation(int orientation);
int GetToolTextOrientation() const;
void SetToolPacking(int packing);
int GetToolPacking() const;
void SetToolProportion(int tool_id, int proportion);
int GetToolProportion(int tool_id) const;
void SetToolSeparation(int separation);
int GetToolSeparation() const;
void SetToolSticky(int tool_id, bool sticky);
bool GetToolSticky(int tool_id) const;
wxString GetToolLabel(int tool_id) const;
void SetToolLabel(int tool_id, const wxString& label);
wxBitmap GetToolBitmap(int tool_id) const;
void SetToolBitmap(int tool_id, const wxBitmap& bitmap);
wxString GetToolShortHelp(int tool_id) const;
void SetToolShortHelp(int tool_id, const wxString& help_string);
wxString GetToolLongHelp(int tool_id) const;
void SetToolLongHelp(int tool_id, const wxString& help_string);
void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend,
const wxAuiToolBarItemArray& append);
protected:
virtual void OnCustomRender(wxDC& WXUNUSED(dc),
const wxAuiToolBarItem& WXUNUSED(item),
const wxRect& WXUNUSED(rect)) { }
protected:
void DoIdleUpdate();
void SetOrientation(int orientation);
void SetHoverItem(wxAuiToolBarItem* item);
void SetPressedItem(wxAuiToolBarItem* item);
void RefreshOverflowState();
int GetOverflowState() const;
wxRect GetOverflowRect() const;
wxSize GetLabelSize(const wxString& label);
wxAuiToolBarItem* FindToolByPositionWithPacking(wxCoord x, wxCoord y) const;
void DoSetSize(int x,
int y,
int width,
int height,
int sizeFlags = wxSIZE_AUTO);
protected: // handlers
void OnSize(wxSizeEvent& evt);
void OnIdle(wxIdleEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt);
void OnLeftDown(wxMouseEvent& evt);
void OnLeftUp(wxMouseEvent& evt);
void OnRightDown(wxMouseEvent& evt);
void OnRightUp(wxMouseEvent& evt);
void OnMiddleDown(wxMouseEvent& evt);
void OnMiddleUp(wxMouseEvent& evt);
void OnMotion(wxMouseEvent& evt);
void OnLeaveWindow(wxMouseEvent& evt);
void OnSetCursor(wxSetCursorEvent& evt);
protected:
wxAuiToolBarItemArray m_items; // array of toolbar items
wxAuiToolBarArt* m_art; // art provider
wxBoxSizer* m_sizer; // main sizer for toolbar
wxAuiToolBarItem* m_action_item; // item that's being acted upon (pressed)
wxAuiToolBarItem* m_tip_item; // item that has its tooltip shown
wxBitmap m_bitmap; // double-buffer bitmap
wxSizerItem* m_gripper_sizer_item;
wxSizerItem* m_overflow_sizer_item;
wxSize m_absolute_min_size;
wxPoint m_action_pos; // position of left-mouse down
wxAuiToolBarItemArray m_custom_overflow_prepend;
wxAuiToolBarItemArray m_custom_overflow_append;
int m_button_width;
int m_button_height;
int m_sizer_element_count;
int m_left_padding;
int m_right_padding;
int m_top_padding;
int m_bottom_padding;
int m_tool_packing;
int m_tool_border_padding;
int m_tool_text_orientation;
int m_overflow_state;
bool m_dragging;
bool m_gripper_visible;
bool m_overflow_visible;
long m_style;
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxAuiToolBar)
};
// wx event machinery
#ifndef SWIG
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, 0)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxAuiToolBarEventFunction)(wxAuiToolBarEvent&);
#define wxAuiToolBarEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiToolBarEventFunction, &func)
#define EVT_AUITOOLBAR_TOOL_DROPDOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_OVERFLOW_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_RIGHT_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_MIDDLE_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_BEGIN_DRAG(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, winid, wxAuiToolBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN;
%constant wxEventType wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK;
%constant wxEventType wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK;
%constant wxEventType wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK;
%constant wxEventType wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG;
%pythoncode {
EVT_AUITOOLBAR_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, 1 )
EVT_AUITOOLBAR_OVERFLOW_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK, 1 )
EVT_AUITOOLBAR_RIGHT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, 1 )
EVT_AUITOOLBAR_MIDDLE_CLICK = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK, 1 )
EVT_AUITOOLBAR_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG, 1 )
}
#endif // SWIG
#endif // wxABI_VERSION >= 20809
#endif // wxUSE_AUI
#endif // _WX_AUIBAR_H_

View File

@ -0,0 +1,753 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/auibook.h
// Purpose: wxaui: wx advanced user interface - notebook
// Author: Benjamin I. Williams
// Modified by:
// Created: 2006-06-28
// Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUINOTEBOOK_H_
#define _WX_AUINOTEBOOK_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/aui/framemanager.h"
#include "wx/aui/dockart.h"
#include "wx/aui/floatpane.h"
#include "wx/control.h"
class wxAuiNotebook;
enum wxAuiNotebookOption
{
wxAUI_NB_TOP = 1 << 0,
wxAUI_NB_LEFT = 1 << 1, // not implemented yet
wxAUI_NB_RIGHT = 1 << 2, // not implemented yet
wxAUI_NB_BOTTOM = 1 << 3,
wxAUI_NB_TAB_SPLIT = 1 << 4,
wxAUI_NB_TAB_MOVE = 1 << 5,
wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6,
wxAUI_NB_TAB_FIXED_WIDTH = 1 << 7,
wxAUI_NB_SCROLL_BUTTONS = 1 << 8,
wxAUI_NB_WINDOWLIST_BUTTON = 1 << 9,
wxAUI_NB_CLOSE_BUTTON = 1 << 10,
wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 11,
wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 12,
wxAUI_NB_MIDDLE_CLICK_CLOSE = 1 << 13,
wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP |
wxAUI_NB_TAB_SPLIT |
wxAUI_NB_TAB_MOVE |
wxAUI_NB_SCROLL_BUTTONS |
wxAUI_NB_CLOSE_ON_ACTIVE_TAB |
wxAUI_NB_MIDDLE_CLICK_CLOSE
};
// aui notebook event class
class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent
{
public:
wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL,
int win_id = 0)
: wxNotifyEvent(command_type, win_id)
{
old_selection = -1;
selection = -1;
drag_source = NULL;
}
#ifndef SWIG
wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c)
{
old_selection = c.old_selection;
selection = c.selection;
drag_source = c.drag_source;
}
#endif
wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); }
void SetSelection(int s) { selection = s; m_commandInt = s; }
int GetSelection() const { return selection; }
void SetOldSelection(int s) { old_selection = s; }
int GetOldSelection() const { return old_selection; }
void SetDragSource(wxAuiNotebook* s) { drag_source = s; }
wxAuiNotebook* GetDragSource() const { return drag_source; }
public:
int old_selection;
int selection;
wxAuiNotebook* drag_source;
#ifndef SWIG
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent)
#endif
};
class WXDLLIMPEXP_AUI wxAuiNotebookPage
{
public:
wxWindow* window; // page's associated window
wxString caption; // caption displayed on the tab
wxBitmap bitmap; // tab's bitmap
wxRect rect; // tab's hit rectangle
bool active; // true if the page is currently active
};
class WXDLLIMPEXP_AUI wxAuiTabContainerButton
{
public:
int id; // button's id
int cur_state; // current state (normal, hover, pressed, etc.)
int location; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
wxBitmap bitmap; // button's hover bitmap
wxBitmap dis_bitmap; // button's disabled bitmap
wxRect rect; // button's hit rectangle
};
#ifndef SWIG
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI);
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI);
#endif
// tab art class
class WXDLLIMPEXP_AUI wxAuiTabArt
{
public:
wxAuiTabArt() { }
virtual ~wxAuiTabArt() { }
virtual wxAuiTabArt* Clone() = 0;
virtual void SetFlags(unsigned int flags) = 0;
virtual void SetSizingInfo(const wxSize& tab_ctrl_size,
size_t tab_count) = 0;
virtual void SetNormalFont(const wxFont& font) = 0;
virtual void SetSelectedFont(const wxFont& font) = 0;
virtual void SetMeasuringFont(const wxFont& font) = 0;
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& pane,
const wxRect& in_rect,
int close_button_state,
wxRect* out_tab_rect,
wxRect* out_button_rect,
int* x_extent) = 0;
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& in_rect,
int bitmap_id,
int button_state,
int orientation,
wxRect* out_rect) = 0;
virtual wxSize GetTabSize(
wxDC& dc,
wxWindow* wnd,
const wxString& caption,
const wxBitmap& bitmap,
bool active,
int close_button_state,
int* x_extent) = 0;
virtual int ShowDropDown(
wxWindow* wnd,
const wxAuiNotebookPageArray& items,
int active_idx) = 0;
virtual int GetIndentSize() = 0;
virtual int GetBestTabCtrlSize(
wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& required_bmp_size) = 0;
};
class WXDLLIMPEXP_AUI wxAuiDefaultTabArt : public wxAuiTabArt
{
public:
wxAuiDefaultTabArt();
virtual ~wxAuiDefaultTabArt();
wxAuiTabArt* Clone();
void SetFlags(unsigned int flags);
void SetSizingInfo(const wxSize& tab_ctrl_size,
size_t tab_count);
void SetNormalFont(const wxFont& font);
void SetSelectedFont(const wxFont& font);
void SetMeasuringFont(const wxFont& font);
void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& pane,
const wxRect& in_rect,
int close_button_state,
wxRect* out_tab_rect,
wxRect* out_button_rect,
int* x_extent);
void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& in_rect,
int bitmap_id,
int button_state,
int orientation,
wxRect* out_rect);
int GetIndentSize();
wxSize GetTabSize(
wxDC& dc,
wxWindow* wnd,
const wxString& caption,
const wxBitmap& bitmap,
bool active,
int close_button_state,
int* x_extent);
int ShowDropDown(
wxWindow* wnd,
const wxAuiNotebookPageArray& items,
int active_idx);
int GetBestTabCtrlSize(wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& required_bmp_size);
protected:
wxFont m_normal_font;
wxFont m_selected_font;
wxFont m_measuring_font;
wxColour m_base_colour;
wxPen m_base_colour_pen;
wxPen m_border_pen;
wxBrush m_base_colour_brush;
wxBitmap m_active_close_bmp;
wxBitmap m_disabled_close_bmp;
wxBitmap m_active_left_bmp;
wxBitmap m_disabled_left_bmp;
wxBitmap m_active_right_bmp;
wxBitmap m_disabled_right_bmp;
wxBitmap m_active_windowlist_bmp;
wxBitmap m_disabled_windowlist_bmp;
int m_fixed_tab_width;
int m_tab_ctrl_height;
unsigned int m_flags;
};
class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArt
{
public:
wxAuiSimpleTabArt();
virtual ~wxAuiSimpleTabArt();
wxAuiTabArt* Clone();
void SetFlags(unsigned int flags);
void SetSizingInfo(const wxSize& tab_ctrl_size,
size_t tab_count);
void SetNormalFont(const wxFont& font);
void SetSelectedFont(const wxFont& font);
void SetMeasuringFont(const wxFont& font);
void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect);
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& pane,
const wxRect& in_rect,
int close_button_state,
wxRect* out_tab_rect,
wxRect* out_button_rect,
int* x_extent);
void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& in_rect,
int bitmap_id,
int button_state,
int orientation,
wxRect* out_rect);
int GetIndentSize();
wxSize GetTabSize(
wxDC& dc,
wxWindow* wnd,
const wxString& caption,
const wxBitmap& bitmap,
bool active,
int close_button_state,
int* x_extent);
int ShowDropDown(
wxWindow* wnd,
const wxAuiNotebookPageArray& items,
int active_idx);
int GetBestTabCtrlSize(wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& required_bmp_size);
protected:
wxFont m_normal_font;
wxFont m_selected_font;
wxFont m_measuring_font;
wxPen m_normal_bkpen;
wxPen m_selected_bkpen;
wxBrush m_normal_bkbrush;
wxBrush m_selected_bkbrush;
wxBrush m_bkbrush;
wxBitmap m_active_close_bmp;
wxBitmap m_disabled_close_bmp;
wxBitmap m_active_left_bmp;
wxBitmap m_disabled_left_bmp;
wxBitmap m_active_right_bmp;
wxBitmap m_disabled_right_bmp;
wxBitmap m_active_windowlist_bmp;
wxBitmap m_disabled_windowlist_bmp;
int m_fixed_tab_width;
unsigned int m_flags;
};
class WXDLLIMPEXP_AUI wxAuiTabContainer
{
public:
wxAuiTabContainer();
virtual ~wxAuiTabContainer();
void SetArtProvider(wxAuiTabArt* art);
wxAuiTabArt* GetArtProvider() const;
void SetFlags(unsigned int flags);
unsigned int GetFlags() const;
bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
bool MovePage(wxWindow* page, size_t new_idx);
bool RemovePage(wxWindow* page);
bool SetActivePage(wxWindow* page);
bool SetActivePage(size_t page);
void SetNoneActive();
int GetActivePage() const;
bool TabHitTest(int x, int y, wxWindow** hit) const;
bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const;
wxWindow* GetWindowFromIdx(size_t idx) const;
int GetIdxFromWindow(wxWindow* page) const;
size_t GetPageCount() const;
wxAuiNotebookPage& GetPage(size_t idx);
const wxAuiNotebookPage& GetPage(size_t idx) const;
wxAuiNotebookPageArray& GetPages();
void SetNormalFont(const wxFont& normal_font);
void SetSelectedFont(const wxFont& selected_font);
void SetMeasuringFont(const wxFont& measuring_font);
void DoShowHide();
void SetRect(const wxRect& rect);
void RemoveButton(int id);
void AddButton(int id,
int location,
const wxBitmap& normal_bitmap = wxNullBitmap,
const wxBitmap& disabled_bitmap = wxNullBitmap);
size_t GetTabOffset() const;
void SetTabOffset(size_t offset);
// Is the tab visible?
bool IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWindow* wnd);
// Make the tab visible if it wasn't already
void MakeTabVisible(int tabPage, wxWindow* win);
protected:
virtual void Render(wxDC* dc, wxWindow* wnd);
protected:
wxAuiTabArt* m_art;
wxAuiNotebookPageArray m_pages;
wxAuiTabContainerButtonArray m_buttons;
wxAuiTabContainerButtonArray m_tab_close_buttons;
wxRect m_rect;
size_t m_tab_offset;
unsigned int m_flags;
};
class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
public wxAuiTabContainer
{
public:
wxAuiTabCtrl(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
~wxAuiTabCtrl();
#if wxABI_VERSION >= 20805
bool IsDragging() const { return m_is_dragging; }
#endif
protected:
void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnLeftDown(wxMouseEvent& evt);
void OnLeftUp(wxMouseEvent& evt);
#if wxABI_VERSION >= 20805
void OnMiddleDown(wxMouseEvent& evt);
void OnMiddleUp(wxMouseEvent& evt);
void OnRightDown(wxMouseEvent& evt);
void OnRightUp(wxMouseEvent& evt);
void OnLeftDClick(wxMouseEvent& evt);
void OnSetFocus(wxFocusEvent& evt);
void OnKillFocus(wxFocusEvent& evt);
void OnChar(wxKeyEvent& evt);
#endif
#if wxABI_VERSION >= 20809
void OnCaptureLost(wxMouseCaptureLostEvent& evt);
#endif
void OnMotion(wxMouseEvent& evt);
void OnLeaveWindow(wxMouseEvent& evt);
void OnButton(wxAuiNotebookEvent& evt);
protected:
wxPoint m_click_pt;
wxWindow* m_click_tab;
bool m_is_dragging;
wxAuiTabContainerButton* m_hover_button;
wxAuiTabContainerButton* m_pressed_button;
#ifndef SWIG
DECLARE_CLASS(wxAuiTabCtrl)
DECLARE_EVENT_TABLE()
#endif
};
class WXDLLIMPEXP_AUI wxAuiNotebook : public wxControl
{
public:
wxAuiNotebook();
wxAuiNotebook(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_NB_DEFAULT_STYLE);
virtual ~wxAuiNotebook();
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
void SetWindowStyleFlag(long style);
void SetArtProvider(wxAuiTabArt* art);
wxAuiTabArt* GetArtProvider() const;
virtual void SetUniformBitmapSize(const wxSize& size);
virtual void SetTabCtrlHeight(int height);
bool AddPage(wxWindow* page,
const wxString& caption,
bool select = false,
const wxBitmap& bitmap = wxNullBitmap);
bool InsertPage(size_t page_idx,
wxWindow* page,
const wxString& caption,
bool select = false,
const wxBitmap& bitmap = wxNullBitmap);
bool DeletePage(size_t page);
bool RemovePage(size_t page);
size_t GetPageCount() const;
wxWindow* GetPage(size_t page_idx) const;
int GetPageIndex(wxWindow* page_wnd) const;
bool SetPageText(size_t page, const wxString& text);
wxString GetPageText(size_t page_idx) const;
bool SetPageBitmap(size_t page, const wxBitmap& bitmap);
wxBitmap GetPageBitmap(size_t page_idx) const;
size_t SetSelection(size_t new_page);
int GetSelection() const;
virtual void Split(size_t page, int direction);
#if wxABI_VERSION >= 20801
const wxAuiManager& GetAuiManager() const { return m_mgr; }
#endif
#if wxABI_VERSION >= 20805
// Sets the normal font
void SetNormalFont(const wxFont& font);
// Sets the selected tab font
void SetSelectedFont(const wxFont& font);
// Sets the measuring font
void SetMeasuringFont(const wxFont& font);
// Sets the tab font
virtual bool SetFont(const wxFont& font);
// Gets the tab control height
int GetTabCtrlHeight() const;
// Gets the height of the notebook for a given page height
int GetHeightForPageHeight(int pageHeight);
// Advances the selection, generation page selection events
void AdvanceSelection(bool forward = true);
// Shows the window menu
bool ShowWindowMenu();
#endif
protected:
// these can be overridden
virtual void UpdateTabCtrlHeight();
virtual int CalculateTabCtrlHeight();
virtual wxSize CalculateNewSplitSize();
protected:
void DoSizing();
void InitNotebook(long style);
wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt);
wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl);
wxAuiTabCtrl* GetActiveTabCtrl();
bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx);
void RemoveEmptyTabFrames();
void UpdateHintWindowSize();
protected:
void OnChildFocus(wxChildFocusEvent& evt);
void OnRender(wxAuiManagerEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnTabClicked(wxCommandEvent& evt);
void OnTabBeginDrag(wxCommandEvent& evt);
void OnTabDragMotion(wxCommandEvent& evt);
void OnTabEndDrag(wxCommandEvent& evt);
void OnTabButton(wxCommandEvent& evt);
#if wxABI_VERSION >= 20805
void OnTabMiddleDown(wxCommandEvent& evt);
void OnTabMiddleUp(wxCommandEvent& evt);
void OnTabRightDown(wxCommandEvent& evt);
void OnTabRightUp(wxCommandEvent& evt);
void OnNavigationKey(wxNavigationKeyEvent& event);
void OnTabBgDClick(wxCommandEvent& evt);
#endif
protected:
wxAuiManager m_mgr;
wxAuiTabContainer m_tabs;
int m_curpage;
int m_tab_id_counter;
wxWindow* m_dummy_wnd;
wxSize m_requested_bmp_size;
int m_requested_tabctrl_height;
wxFont m_selected_font;
wxFont m_normal_font;
int m_tab_ctrl_height;
int m_last_drag_x;
unsigned int m_flags;
#ifndef SWIG
DECLARE_CLASS(wxAuiNotebook)
DECLARE_EVENT_TABLE()
#endif
};
// wx event machinery
#ifndef SWIG
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 0)
#if wxABI_VERSION >= 20805
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 0)
#endif
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
#define wxAuiNotebookEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
#define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn))
#if wxABI_VERSION >= 20805
#define EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_DRAG_DONE(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_BG_DCLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, winid, wxAuiNotebookEventHandler(fn))
#endif
#else
// wxpython/swig event work
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN;
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP;
%pythoncode {
EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 1 )
EVT_AUINOTEBOOK_PAGE_CLOSED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 1 )
EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 )
EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 )
EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 )
EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 )
EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 )
EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 )
EVT_AUINOTEBOOK_ALLOW_DND = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 1 )
EVT_AUINOTEBOOK_DRAG_DONE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 1 )
EVT_AUINOTEBOOK_BG_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 1 )
EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, 1 )
EVT_AUINOTEBOOK_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP , 1 )
EVT_AUINOTEBOOK_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 1 )
EVT_AUINOTEBOOK_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 1 )
}
#endif
#endif // wxUSE_AUI
#endif // _WX_AUINOTEBOOK_H_

View File

@ -0,0 +1,173 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/dockart.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Modified by:
// Created: 2005-05-17
// RCS-ID: $Id: dockart.h 43154 2006-11-07 10:29:02Z BIW $
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DOCKART_H_
#define _WX_DOCKART_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/bitmap.h"
#include "wx/colour.h"
// dock art provider code - a dock provider provides all drawing
// functionality to the wxAui dock manager. This allows the dock
// manager to have plugable look-and-feels
class WXDLLIMPEXP_AUI wxAuiDockArt
{
public:
wxAuiDockArt() { }
virtual ~wxAuiDockArt() { }
virtual int GetMetric(int id) = 0;
virtual void SetMetric(int id, int new_val) = 0;
virtual void SetFont(int id, const wxFont& font) = 0;
virtual wxFont GetFont(int id) = 0;
virtual wxColour GetColour(int id) = 0;
virtual void SetColour(int id, const wxColor& colour) = 0;
wxColour GetColor(int id) { return GetColour(id); }
void SetColor(int id, const wxColour& color) { SetColour(id, color); }
virtual void DrawSash(wxDC& dc,
wxWindow* window,
int orientation,
const wxRect& rect) = 0;
virtual void DrawBackground(wxDC& dc,
wxWindow* window,
int orientation,
const wxRect& rect) = 0;
virtual void DrawCaption(wxDC& dc,
wxWindow* window,
const wxString& text,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
virtual void DrawGripper(wxDC& dc,
wxWindow* window,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
virtual void DrawBorder(wxDC& dc,
wxWindow* window,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
virtual void DrawPaneButton(wxDC& dc,
wxWindow* window,
int button,
int button_state,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
};
// this is the default art provider for wxAuiManager. Dock art
// can be customized by creating a class derived from this one,
// or replacing this class entirely
class WXDLLIMPEXP_AUI wxAuiDefaultDockArt : public wxAuiDockArt
{
public:
wxAuiDefaultDockArt();
int GetMetric(int metric_id);
void SetMetric(int metric_id, int new_val);
wxColour GetColour(int id);
void SetColour(int id, const wxColor& colour);
void SetFont(int id, const wxFont& font);
wxFont GetFont(int id);
void DrawSash(wxDC& dc,
wxWindow *window,
int orientation,
const wxRect& rect);
void DrawBackground(wxDC& dc,
wxWindow *window,
int orientation,
const wxRect& rect);
void DrawCaption(wxDC& dc,
wxWindow *window,
const wxString& text,
const wxRect& rect,
wxAuiPaneInfo& pane);
void DrawGripper(wxDC& dc,
wxWindow *window,
const wxRect& rect,
wxAuiPaneInfo& pane);
void DrawBorder(wxDC& dc,
wxWindow *window,
const wxRect& rect,
wxAuiPaneInfo& pane);
void DrawPaneButton(wxDC& dc,
wxWindow *window,
int button,
int button_state,
const wxRect& rect,
wxAuiPaneInfo& pane);
protected:
void DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active);
protected:
wxPen m_border_pen;
wxBrush m_sash_brush;
wxBrush m_background_brush;
wxBrush m_gripper_brush;
wxFont m_caption_font;
wxBitmap m_inactive_close_bitmap;
wxBitmap m_inactive_pin_bitmap;
wxBitmap m_inactive_maximize_bitmap;
wxBitmap m_inactive_restore_bitmap;
wxBitmap m_active_close_bitmap;
wxBitmap m_active_pin_bitmap;
wxBitmap m_active_maximize_bitmap;
wxBitmap m_active_restore_bitmap;
wxPen m_gripper_pen1;
wxPen m_gripper_pen2;
wxPen m_gripper_pen3;
wxColour m_base_colour;
wxColour m_active_caption_colour;
wxColour m_active_caption_gradient_colour;
wxColour m_active_caption_text_colour;
wxColour m_inactive_caption_colour;
wxColour m_inactive_caption_gradient_colour;
wxColour m_inactive_caption_text_colour;
int m_border_size;
int m_caption_size;
int m_sash_size;
int m_button_size;
int m_gripper_size;
int m_gradient_type;
};
#endif // wxUSE_AUI
#endif //_WX_DOCKART_H_

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/floatpane.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Modified by:
// Created: 2005-05-17
// RCS-ID: $Id: floatpane.h 43467 2006-11-17 13:07:01Z BIW $
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FLOATPANE_H_
#define _WX_FLOATPANE_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/frame.h"
#if defined( __WXMSW__ ) || defined( __WXMAC__ ) || defined( __WXGTK__ )
#include "wx/minifram.h"
#define wxAuiFloatingFrameBaseClass wxMiniFrame
#else
#define wxAuiFloatingFrameBaseClass wxFrame
#endif
class WXDLLIMPEXP_AUI wxAuiFloatingFrame : public wxAuiFloatingFrameBaseClass
{
public:
wxAuiFloatingFrame(wxWindow* parent,
wxAuiManager* owner_mgr,
const wxAuiPaneInfo& pane,
wxWindowID id = wxID_ANY,
long style = wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION |
wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT |
wxCLIP_CHILDREN
);
virtual ~wxAuiFloatingFrame();
void SetPaneWindow(const wxAuiPaneInfo& pane);
wxAuiManager* GetOwnerManager() const;
protected:
virtual void OnMoveStart();
virtual void OnMoving(const wxRect& window_rect, wxDirection dir);
virtual void OnMoveFinished();
private:
void OnSize(wxSizeEvent& event);
void OnClose(wxCloseEvent& event);
void OnMoveEvent(wxMoveEvent& event);
void OnIdle(wxIdleEvent& event);
void OnActivate(wxActivateEvent& event);
static bool isMouseDown();
private:
wxWindow* m_pane_window; // pane window being managed
bool m_solid_drag; // true if system uses solid window drag
bool m_moving;
wxRect m_last_rect;
wxRect m_last2_rect;
wxRect m_last3_rect;
wxSize m_last_size;
wxDirection m_lastDirection;
wxAuiManager* m_owner_mgr;
wxAuiManager m_mgr;
#ifndef SWIG
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxAuiFloatingFrame)
#endif // SWIG
};
#endif // wxUSE_AUI
#endif //_WX_FLOATPANE_H_

View File

@ -0,0 +1,856 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/framemanager.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Modified by:
// Created: 2005-05-17
// RCS-ID: $Id: framemanager.h 57885 2009-01-07 14:51:49Z JS $
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FRAMEMANAGER_H_
#define _WX_FRAMEMANAGER_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/dynarray.h"
#include "wx/gdicmn.h"
#include "wx/window.h"
#include "wx/timer.h"
#include "wx/sizer.h"
enum wxAuiManagerDock
{
wxAUI_DOCK_NONE = 0,
wxAUI_DOCK_TOP = 1,
wxAUI_DOCK_RIGHT = 2,
wxAUI_DOCK_BOTTOM = 3,
wxAUI_DOCK_LEFT = 4,
wxAUI_DOCK_CENTER = 5,
wxAUI_DOCK_CENTRE = wxAUI_DOCK_CENTER
};
enum wxAuiManagerOption
{
wxAUI_MGR_ALLOW_FLOATING = 1 << 0,
wxAUI_MGR_ALLOW_ACTIVE_PANE = 1 << 1,
wxAUI_MGR_TRANSPARENT_DRAG = 1 << 2,
wxAUI_MGR_TRANSPARENT_HINT = 1 << 3,
wxAUI_MGR_VENETIAN_BLINDS_HINT = 1 << 4,
wxAUI_MGR_RECTANGLE_HINT = 1 << 5,
wxAUI_MGR_HINT_FADE = 1 << 6,
wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 1 << 7,
wxAUI_MGR_LIVE_RESIZE = 1 << 8,
wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING |
wxAUI_MGR_TRANSPARENT_HINT |
wxAUI_MGR_HINT_FADE |
wxAUI_MGR_NO_VENETIAN_BLINDS_FADE
};
enum wxAuiPaneDockArtSetting
{
wxAUI_DOCKART_SASH_SIZE = 0,
wxAUI_DOCKART_CAPTION_SIZE = 1,
wxAUI_DOCKART_GRIPPER_SIZE = 2,
wxAUI_DOCKART_PANE_BORDER_SIZE = 3,
wxAUI_DOCKART_PANE_BUTTON_SIZE = 4,
wxAUI_DOCKART_BACKGROUND_COLOUR = 5,
wxAUI_DOCKART_SASH_COLOUR = 6,
wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR = 7,
wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR = 8,
wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR = 9,
wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR = 10,
wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR = 11,
wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR = 12,
wxAUI_DOCKART_BORDER_COLOUR = 13,
wxAUI_DOCKART_GRIPPER_COLOUR = 14,
wxAUI_DOCKART_CAPTION_FONT = 15,
wxAUI_DOCKART_GRADIENT_TYPE = 16
};
enum wxAuiPaneDockArtGradients
{
wxAUI_GRADIENT_NONE = 0,
wxAUI_GRADIENT_VERTICAL = 1,
wxAUI_GRADIENT_HORIZONTAL = 2
};
enum wxAuiPaneButtonState
{
wxAUI_BUTTON_STATE_NORMAL = 0,
wxAUI_BUTTON_STATE_HOVER = 1 << 1,
wxAUI_BUTTON_STATE_PRESSED = 1 << 2,
wxAUI_BUTTON_STATE_DISABLED = 1 << 3,
wxAUI_BUTTON_STATE_HIDDEN = 1 << 4,
wxAUI_BUTTON_STATE_CHECKED = 1 << 5
};
enum wxAuiButtonId
{
wxAUI_BUTTON_CLOSE = 101,
wxAUI_BUTTON_MAXIMIZE_RESTORE = 102,
wxAUI_BUTTON_MINIMIZE = 103,
wxAUI_BUTTON_PIN = 104,
wxAUI_BUTTON_OPTIONS = 105,
wxAUI_BUTTON_WINDOWLIST = 106,
wxAUI_BUTTON_LEFT = 107,
wxAUI_BUTTON_RIGHT = 108,
wxAUI_BUTTON_UP = 109,
wxAUI_BUTTON_DOWN = 110,
wxAUI_BUTTON_CUSTOM1 = 201,
wxAUI_BUTTON_CUSTOM2 = 202,
wxAUI_BUTTON_CUSTOM3 = 203
};
enum wxAuiPaneInsertLevel
{
wxAUI_INSERT_PANE = 0,
wxAUI_INSERT_ROW = 1,
wxAUI_INSERT_DOCK = 2
};
// forwards and array declarations
class wxAuiDockUIPart;
class wxAuiPaneButton;
class wxAuiPaneInfo;
class wxAuiDockInfo;
class wxAuiDockArt;
class wxAuiManagerEvent;
#ifndef SWIG
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiDockInfo, wxAuiDockInfoArray, WXDLLIMPEXP_AUI);
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiDockUIPart, wxAuiDockUIPartArray, WXDLLIMPEXP_AUI);
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiPaneButton, wxAuiPaneButtonArray, WXDLLIMPEXP_AUI);
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiPaneInfo, wxAuiPaneInfoArray, WXDLLIMPEXP_AUI);
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxAuiPaneInfo*, wxAuiPaneInfoPtrArray, class WXDLLIMPEXP_AUI);
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxAuiDockInfo*, wxAuiDockInfoPtrArray, class WXDLLIMPEXP_AUI);
#endif // SWIG
extern WXDLLIMPEXP_AUI wxAuiDockInfo wxAuiNullDockInfo;
extern WXDLLIMPEXP_AUI wxAuiPaneInfo wxAuiNullPaneInfo;
class WXDLLIMPEXP_AUI wxAuiPaneInfo
{
public:
wxAuiPaneInfo()
{
window = NULL;
frame = NULL;
state = 0;
dock_direction = wxAUI_DOCK_LEFT;
dock_layer = 0;
dock_row = 0;
dock_pos = 0;
floating_pos = wxDefaultPosition;
floating_size = wxDefaultSize;
best_size = wxDefaultSize;
min_size = wxDefaultSize;
max_size = wxDefaultSize;
dock_proportion = 0;
DefaultPane();
}
~wxAuiPaneInfo() {}
#ifndef SWIG
wxAuiPaneInfo(const wxAuiPaneInfo& c)
{
name = c.name;
caption = c.caption;
window = c.window;
frame = c.frame;
state = c.state;
dock_direction = c.dock_direction;
dock_layer = c.dock_layer;
dock_row = c.dock_row;
dock_pos = c.dock_pos;
best_size = c.best_size;
min_size = c.min_size;
max_size = c.max_size;
floating_pos = c.floating_pos;
floating_size = c.floating_size;
dock_proportion = c.dock_proportion;
buttons = c.buttons;
rect = c.rect;
}
wxAuiPaneInfo& operator=(const wxAuiPaneInfo& c)
{
name = c.name;
caption = c.caption;
window = c.window;
frame = c.frame;
state = c.state;
dock_direction = c.dock_direction;
dock_layer = c.dock_layer;
dock_row = c.dock_row;
dock_pos = c.dock_pos;
best_size = c.best_size;
min_size = c.min_size;
max_size = c.max_size;
floating_pos = c.floating_pos;
floating_size = c.floating_size;
dock_proportion = c.dock_proportion;
buttons = c.buttons;
rect = c.rect;
return *this;
}
#endif // SWIG
// Write the safe parts of a newly loaded PaneInfo structure "source" into "this"
// used on loading perspectives etc.
void SafeSet(wxAuiPaneInfo source)
{
// note source is not passed by reference so we can overwrite, to keep the
// unsafe bits of "dest"
source.window = window;
source.frame = frame;
source.buttons = buttons;
// now assign
*this = source;
}
bool IsOk() const { return (window != NULL) ? true : false; }
bool IsFixed() const { return !HasFlag(optionResizable); }
bool IsResizable() const { return HasFlag(optionResizable); }
bool IsShown() const { return !HasFlag(optionHidden); }
bool IsFloating() const { return HasFlag(optionFloating); }
bool IsDocked() const { return !HasFlag(optionFloating); }
bool IsToolbar() const { return HasFlag(optionToolbar); }
bool IsTopDockable() const { return HasFlag(optionTopDockable); }
bool IsBottomDockable() const { return HasFlag(optionBottomDockable); }
bool IsLeftDockable() const { return HasFlag(optionLeftDockable); }
bool IsRightDockable() const { return HasFlag(optionRightDockable); }
bool IsFloatable() const { return HasFlag(optionFloatable); }
bool IsMovable() const { return HasFlag(optionMovable); }
bool IsDestroyOnClose() const { return HasFlag(optionDestroyOnClose); }
bool IsMaximized() const { return HasFlag(optionMaximized); }
bool HasCaption() const { return HasFlag(optionCaption); }
bool HasGripper() const { return HasFlag(optionGripper); }
bool HasBorder() const { return HasFlag(optionPaneBorder); }
bool HasCloseButton() const { return HasFlag(buttonClose); }
bool HasMaximizeButton() const { return HasFlag(buttonMaximize); }
bool HasMinimizeButton() const { return HasFlag(buttonMinimize); }
bool HasPinButton() const { return HasFlag(buttonPin); }
bool HasGripperTop() const { return HasFlag(optionGripperTop); }
#ifdef SWIG
%typemap(out) wxAuiPaneInfo& { $result = $self; Py_INCREF($result); }
#endif
wxAuiPaneInfo& Window(wxWindow* w) { window = w; return *this; }
wxAuiPaneInfo& Name(const wxString& n) { name = n; return *this; }
wxAuiPaneInfo& Caption(const wxString& c) { caption = c; return *this; }
wxAuiPaneInfo& Left() { dock_direction = wxAUI_DOCK_LEFT; return *this; }
wxAuiPaneInfo& Right() { dock_direction = wxAUI_DOCK_RIGHT; return *this; }
wxAuiPaneInfo& Top() { dock_direction = wxAUI_DOCK_TOP; return *this; }
wxAuiPaneInfo& Bottom() { dock_direction = wxAUI_DOCK_BOTTOM; return *this; }
wxAuiPaneInfo& Center() { dock_direction = wxAUI_DOCK_CENTER; return *this; }
wxAuiPaneInfo& Centre() { dock_direction = wxAUI_DOCK_CENTRE; return *this; }
wxAuiPaneInfo& Direction(int direction) { dock_direction = direction; return *this; }
wxAuiPaneInfo& Layer(int layer) { dock_layer = layer; return *this; }
wxAuiPaneInfo& Row(int row) { dock_row = row; return *this; }
wxAuiPaneInfo& Position(int pos) { dock_pos = pos; return *this; }
wxAuiPaneInfo& BestSize(const wxSize& size) { best_size = size; return *this; }
wxAuiPaneInfo& MinSize(const wxSize& size) { min_size = size; return *this; }
wxAuiPaneInfo& MaxSize(const wxSize& size) { max_size = size; return *this; }
wxAuiPaneInfo& BestSize(int x, int y) { best_size.Set(x,y); return *this; }
wxAuiPaneInfo& MinSize(int x, int y) { min_size.Set(x,y); return *this; }
wxAuiPaneInfo& MaxSize(int x, int y) { max_size.Set(x,y); return *this; }
wxAuiPaneInfo& FloatingPosition(const wxPoint& pos) { floating_pos = pos; return *this; }
wxAuiPaneInfo& FloatingPosition(int x, int y) { floating_pos.x = x; floating_pos.y = y; return *this; }
wxAuiPaneInfo& FloatingSize(const wxSize& size) { floating_size = size; return *this; }
wxAuiPaneInfo& FloatingSize(int x, int y) { floating_size.Set(x,y); return *this; }
wxAuiPaneInfo& Fixed() { return SetFlag(optionResizable, false); }
wxAuiPaneInfo& Resizable(bool resizable = true) { return SetFlag(optionResizable, resizable); }
wxAuiPaneInfo& Dock() { return SetFlag(optionFloating, false); }
wxAuiPaneInfo& Float() { return SetFlag(optionFloating, true); }
wxAuiPaneInfo& Hide() { return SetFlag(optionHidden, true); }
wxAuiPaneInfo& Show(bool show = true) { return SetFlag(optionHidden, !show); }
wxAuiPaneInfo& CaptionVisible(bool visible = true) { return SetFlag(optionCaption, visible); }
wxAuiPaneInfo& Maximize() { return SetFlag(optionMaximized, true); }
wxAuiPaneInfo& Restore() { return SetFlag(optionMaximized, false); }
wxAuiPaneInfo& PaneBorder(bool visible = true) { return SetFlag(optionPaneBorder, visible); }
wxAuiPaneInfo& Gripper(bool visible = true) { return SetFlag(optionGripper, visible); }
wxAuiPaneInfo& GripperTop(bool attop = true) { return SetFlag(optionGripperTop, attop); }
wxAuiPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose, visible); }
wxAuiPaneInfo& MaximizeButton(bool visible = true) { return SetFlag(buttonMaximize, visible); }
wxAuiPaneInfo& MinimizeButton(bool visible = true) { return SetFlag(buttonMinimize, visible); }
wxAuiPaneInfo& PinButton(bool visible = true) { return SetFlag(buttonPin, visible); }
wxAuiPaneInfo& DestroyOnClose(bool b = true) { return SetFlag(optionDestroyOnClose, b); }
wxAuiPaneInfo& TopDockable(bool b = true) { return SetFlag(optionTopDockable, b); }
wxAuiPaneInfo& BottomDockable(bool b = true) { return SetFlag(optionBottomDockable, b); }
wxAuiPaneInfo& LeftDockable(bool b = true) { return SetFlag(optionLeftDockable, b); }
wxAuiPaneInfo& RightDockable(bool b = true) { return SetFlag(optionRightDockable, b); }
wxAuiPaneInfo& Floatable(bool b = true) { return SetFlag(optionFloatable, b); }
wxAuiPaneInfo& Movable(bool b = true) { return SetFlag(optionMovable, b); }
#if wxABI_VERSION >= 20807
wxAuiPaneInfo& DockFixed(bool b = true) { return SetFlag(optionDockFixed, b); }
#endif
wxAuiPaneInfo& Dockable(bool b = true)
{
return TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b);
}
wxAuiPaneInfo& DefaultPane()
{
state |= optionTopDockable | optionBottomDockable |
optionLeftDockable | optionRightDockable |
optionFloatable | optionMovable | optionResizable |
optionCaption | optionPaneBorder | buttonClose;
return *this;
}
wxAuiPaneInfo& CentrePane() { return CenterPane(); }
wxAuiPaneInfo& CenterPane()
{
state = 0;
return Center().PaneBorder().Resizable();
}
wxAuiPaneInfo& ToolbarPane()
{
DefaultPane();
state |= (optionToolbar | optionGripper);
state &= ~(optionResizable | optionCaption);
if (dock_layer == 0)
dock_layer = 10;
return *this;
}
wxAuiPaneInfo& SetFlag(unsigned int flag, bool option_state)
{
if (option_state)
state |= flag;
else
state &= ~flag;
return *this;
}
bool HasFlag(unsigned int flag) const
{
return (state & flag) ? true:false;
}
#ifdef SWIG
%typemap(out) wxAuiPaneInfo& ;
#endif
public:
// NOTE: You can add and subtract flags from this list,
// but do not change the values of the flags, because
// they are stored in a binary integer format in the
// perspective string. If you really need to change the
// values around, you'll have to ensure backwards-compatibility
// in the perspective loading code.
enum wxAuiPaneState
{
optionFloating = 1 << 0,
optionHidden = 1 << 1,
optionLeftDockable = 1 << 2,
optionRightDockable = 1 << 3,
optionTopDockable = 1 << 4,
optionBottomDockable = 1 << 5,
optionFloatable = 1 << 6,
optionMovable = 1 << 7,
optionResizable = 1 << 8,
optionPaneBorder = 1 << 9,
optionCaption = 1 << 10,
optionGripper = 1 << 11,
optionDestroyOnClose = 1 << 12,
optionToolbar = 1 << 13,
optionActive = 1 << 14,
optionGripperTop = 1 << 15,
optionMaximized = 1 << 16,
optionDockFixed = 1 << 17,
buttonClose = 1 << 21,
buttonMaximize = 1 << 22,
buttonMinimize = 1 << 23,
buttonPin = 1 << 24,
buttonCustom1 = 1 << 26,
buttonCustom2 = 1 << 27,
buttonCustom3 = 1 << 28,
savedHiddenState = 1 << 30, // used internally
actionPane = 1 << 31 // used internally
};
public:
wxString name; // name of the pane
wxString caption; // caption displayed on the window
wxWindow* window; // window that is in this pane
wxFrame* frame; // floating frame window that holds the pane
unsigned int state; // a combination of wxPaneState values
int dock_direction; // dock direction (top, bottom, left, right, center)
int dock_layer; // layer number (0 = innermost layer)
int dock_row; // row number on the docking bar (0 = first row)
int dock_pos; // position inside the row (0 = first position)
wxSize best_size; // size that the layout engine will prefer
wxSize min_size; // minimum size the pane window can tolerate
wxSize max_size; // maximum size the pane window can tolerate
wxPoint floating_pos; // position while floating
wxSize floating_size; // size while floating
int dock_proportion; // proportion while docked
wxAuiPaneButtonArray buttons; // buttons on the pane
wxRect rect; // current rectangle (populated by wxAUI)
};
class WXDLLIMPEXP_FWD_AUI wxAuiFloatingFrame;
class WXDLLIMPEXP_AUI wxAuiManager : public wxEvtHandler
{
friend class wxAuiFloatingFrame;
public:
wxAuiManager(wxWindow* managed_wnd = NULL,
unsigned int flags = wxAUI_MGR_DEFAULT);
virtual ~wxAuiManager();
void UnInit();
void SetFlags(unsigned int flags);
unsigned int GetFlags() const;
void SetManagedWindow(wxWindow* managed_wnd);
wxWindow* GetManagedWindow() const;
static wxAuiManager* GetManager(wxWindow* window);
void SetArtProvider(wxAuiDockArt* art_provider);
wxAuiDockArt* GetArtProvider() const;
wxAuiPaneInfo& GetPane(wxWindow* window);
wxAuiPaneInfo& GetPane(const wxString& name);
wxAuiPaneInfoArray& GetAllPanes();
bool AddPane(wxWindow* window,
const wxAuiPaneInfo& pane_info);
bool AddPane(wxWindow* window,
const wxAuiPaneInfo& pane_info,
const wxPoint& drop_pos);
bool AddPane(wxWindow* window,
int direction = wxLEFT,
const wxString& caption = wxEmptyString);
bool InsertPane(wxWindow* window,
const wxAuiPaneInfo& insert_location,
int insert_level = wxAUI_INSERT_PANE);
bool DetachPane(wxWindow* window);
void Update();
wxString SavePaneInfo(wxAuiPaneInfo& pane);
void LoadPaneInfo(wxString pane_part, wxAuiPaneInfo &pane);
wxString SavePerspective();
bool LoadPerspective(const wxString& perspective, bool update = true);
void SetDockSizeConstraint(double width_pct, double height_pct);
void GetDockSizeConstraint(double* width_pct, double* height_pct) const;
void ClosePane(wxAuiPaneInfo& pane_info);
void MaximizePane(wxAuiPaneInfo& pane_info);
void RestorePane(wxAuiPaneInfo& pane_info);
void RestoreMaximizedPane();
public:
virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p);
void StartPaneDrag(
wxWindow* pane_window,
const wxPoint& offset);
wxRect CalculateHintRect(
wxWindow* pane_window,
const wxPoint& pt,
const wxPoint& offset);
void DrawHintRect(
wxWindow* pane_window,
const wxPoint& pt,
const wxPoint& offset);
virtual void ShowHint(const wxRect& rect);
virtual void HideHint();
public:
// deprecated -- please use SetManagedWindow() and
// and GetManagedWindow() instead
wxDEPRECATED( void SetFrame(wxFrame* frame) );
wxDEPRECATED( wxFrame* GetFrame() const );
protected:
void UpdateHintWindowConfig();
void DoFrameLayout();
void LayoutAddPane(wxSizer* container,
wxAuiDockInfo& dock,
wxAuiPaneInfo& pane,
wxAuiDockUIPartArray& uiparts,
bool spacer_only);
void LayoutAddDock(wxSizer* container,
wxAuiDockInfo& dock,
wxAuiDockUIPartArray& uiparts,
bool spacer_only);
wxSizer* LayoutAll(wxAuiPaneInfoArray& panes,
wxAuiDockInfoArray& docks,
wxAuiDockUIPartArray& uiparts,
bool spacer_only = false);
virtual bool ProcessDockResult(wxAuiPaneInfo& target,
const wxAuiPaneInfo& new_pos);
bool DoDrop(wxAuiDockInfoArray& docks,
wxAuiPaneInfoArray& panes,
wxAuiPaneInfo& drop,
const wxPoint& pt,
const wxPoint& action_offset = wxPoint(0,0));
wxAuiDockUIPart* HitTest(int x, int y);
wxAuiDockUIPart* GetPanePart(wxWindow* pane);
int GetDockPixelOffset(wxAuiPaneInfo& test);
void OnFloatingPaneMoveStart(wxWindow* window);
void OnFloatingPaneMoving(wxWindow* window, wxDirection dir );
void OnFloatingPaneMoved(wxWindow* window, wxDirection dir);
void OnFloatingPaneActivated(wxWindow* window);
void OnFloatingPaneClosed(wxWindow* window, wxCloseEvent& evt);
void OnFloatingPaneResized(wxWindow* window, const wxSize& size);
void Render(wxDC* dc);
void Repaint(wxDC* dc = NULL);
void ProcessMgrEvent(wxAuiManagerEvent& event);
void UpdateButtonOnScreen(wxAuiDockUIPart* button_ui_part,
const wxMouseEvent& event);
void GetPanePositionsAndSizes(wxAuiDockInfo& dock,
wxArrayInt& positions,
wxArrayInt& sizes);
#if wxABI_VERSION >= 20810
/// Ends a resize action, or for live update, resizes the sash
bool DoEndResizeAction(wxMouseEvent& event);
#endif
public:
// public events (which can be invoked externally)
void OnRender(wxAuiManagerEvent& evt);
void OnPaneButton(wxAuiManagerEvent& evt);
protected:
// protected events
void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnSetCursor(wxSetCursorEvent& evt);
void OnLeftDown(wxMouseEvent& evt);
void OnLeftUp(wxMouseEvent& evt);
void OnMotion(wxMouseEvent& evt);
void OnLeaveWindow(wxMouseEvent& evt);
void OnChildFocus(wxChildFocusEvent& evt);
void OnHintFadeTimer(wxTimerEvent& evt);
void OnFindManager(wxAuiManagerEvent& evt);
protected:
enum
{
actionNone = 0,
actionResize,
actionClickButton,
actionClickCaption,
actionDragToolbarPane,
actionDragFloatingPane
};
protected:
wxWindow* m_frame; // the window being managed
wxAuiDockArt* m_art; // dock art object which does all drawing
unsigned int m_flags; // manager flags wxAUI_MGR_*
wxAuiPaneInfoArray m_panes; // array of panes structures
wxAuiDockInfoArray m_docks; // array of docks structures
wxAuiDockUIPartArray m_uiparts; // array of UI parts (captions, buttons, etc)
int m_action; // current mouse action
wxPoint m_action_start; // position where the action click started
wxPoint m_action_offset; // offset from upper left of the item clicked
wxAuiDockUIPart* m_action_part; // ptr to the part the action happened to
wxWindow* m_action_window; // action frame or window (NULL if none)
wxRect m_action_hintrect; // hint rectangle for the action
wxRect m_last_rect;
wxAuiDockUIPart* m_hover_button;// button uipart being hovered over
wxRect m_last_hint; // last hint rectangle
wxPoint m_last_mouse_move; // last mouse move position (see OnMotion)
bool m_skipping;
bool m_has_maximized;
double m_dock_constraint_x; // 0.0 .. 1.0; max pct of window width a dock can consume
double m_dock_constraint_y; // 0.0 .. 1.0; max pct of window height a dock can consume
wxFrame* m_hint_wnd; // transparent hint window, if supported by platform
wxTimer m_hint_fadetimer; // transparent fade timer
wxByte m_hint_fadeamt; // transparent fade amount
wxByte m_hint_fademax; // maximum value of hint fade
void* m_reserved;
#ifndef SWIG
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxAuiManager)
#endif // SWIG
};
// event declarations/classes
class WXDLLIMPEXP_AUI wxAuiManagerEvent : public wxEvent
{
public:
wxAuiManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type)
{
manager = NULL;
pane = NULL;
button = 0;
veto_flag = false;
canveto_flag = true;
dc = NULL;
}
#ifndef SWIG
wxAuiManagerEvent(const wxAuiManagerEvent& c) : wxEvent(c)
{
manager = c.manager;
pane = c.pane;
button = c.button;
veto_flag = c.veto_flag;
canveto_flag = c.canveto_flag;
dc = c.dc;
}
#endif
wxEvent *Clone() const { return new wxAuiManagerEvent(*this); }
void SetManager(wxAuiManager* mgr) { manager = mgr; }
void SetPane(wxAuiPaneInfo* p) { pane = p; }
void SetButton(int b) { button = b; }
void SetDC(wxDC* pdc) { dc = pdc; }
wxAuiManager* GetManager() const { return manager; }
wxAuiPaneInfo* GetPane() const { return pane; }
int GetButton() const { return button; }
wxDC* GetDC() const { return dc; }
void Veto(bool veto = true) { veto_flag = veto; }
bool GetVeto() const { return veto_flag; }
void SetCanVeto(bool can_veto) { canveto_flag = can_veto; }
bool CanVeto() const { return canveto_flag && veto_flag; }
public:
wxAuiManager* manager;
wxAuiPaneInfo* pane;
int button;
bool veto_flag;
bool canveto_flag;
wxDC* dc;
#ifndef SWIG
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiManagerEvent)
#endif
};
class WXDLLIMPEXP_AUI wxAuiDockInfo
{
public:
wxAuiDockInfo()
{
dock_direction = 0;
dock_layer = 0;
dock_row = 0;
size = 0;
min_size = 0;
resizable = true;
fixed = false;
toolbar = false;
reserved1 = false;
}
#ifndef SWIG
wxAuiDockInfo(const wxAuiDockInfo& c)
{
dock_direction = c.dock_direction;
dock_layer = c.dock_layer;
dock_row = c.dock_row;
size = c.size;
min_size = c.min_size;
resizable = c.resizable;
fixed = c.fixed;
toolbar = c.toolbar;
panes = c.panes;
rect = c.rect;
reserved1 = c.reserved1;
}
wxAuiDockInfo& operator=(const wxAuiDockInfo& c)
{
dock_direction = c.dock_direction;
dock_layer = c.dock_layer;
dock_row = c.dock_row;
size = c.size;
min_size = c.min_size;
resizable = c.resizable;
fixed = c.fixed;
toolbar = c.toolbar;
panes = c.panes;
rect = c.rect;
reserved1 = c.reserved1;
return *this;
}
#endif // SWIG
bool IsOk() const { return (dock_direction != 0) ? true : false; }
bool IsHorizontal() const { return (dock_direction == wxAUI_DOCK_TOP ||
dock_direction == wxAUI_DOCK_BOTTOM) ? true:false; }
bool IsVertical() const { return (dock_direction == wxAUI_DOCK_LEFT ||
dock_direction == wxAUI_DOCK_RIGHT ||
dock_direction == wxAUI_DOCK_CENTER) ? true:false; }
public:
wxAuiPaneInfoPtrArray panes; // array of panes
wxRect rect; // current rectangle
int dock_direction; // dock direction (top, bottom, left, right, center)
int dock_layer; // layer number (0 = innermost layer)
int dock_row; // row number on the docking bar (0 = first row)
int size; // size of the dock
int min_size; // minimum size of a dock (0 if there is no min)
bool resizable; // flag indicating whether the dock is resizable
bool toolbar; // flag indicating dock contains only toolbars
bool fixed; // flag indicating that the dock operates on
// absolute coordinates as opposed to proportional
bool reserved1;
};
class WXDLLIMPEXP_AUI wxAuiDockUIPart
{
public:
enum
{
typeCaption,
typeGripper,
typeDock,
typeDockSizer,
typePane,
typePaneSizer,
typeBackground,
typePaneBorder,
typePaneButton
};
int type; // ui part type (see enum above)
int orientation; // orientation (either wxHORIZONTAL or wxVERTICAL)
wxAuiDockInfo* dock; // which dock the item is associated with
wxAuiPaneInfo* pane; // which pane the item is associated with
wxAuiPaneButton* button; // which pane button the item is associated with
wxSizer* cont_sizer; // the part's containing sizer
wxSizerItem* sizer_item; // the sizer item of the part
wxRect rect; // client coord rectangle of the part itself
};
class WXDLLIMPEXP_AUI wxAuiPaneButton
{
public:
int button_id; // id of the button (e.g. buttonClose)
};
#ifndef SWIG
// wx event machinery
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_BUTTON, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_CLOSE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_MAXIMIZE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_RESTORE, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, 0)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_AUI_FIND_MANAGER, 0)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
#define wxAuiManagerEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiManagerEventFunction, &func)
#define EVT_AUI_PANE_BUTTON(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_BUTTON, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_CLOSE(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_MAXIMIZE(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_RESTORE(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_RESTORE, wxAuiManagerEventHandler(func))
#define EVT_AUI_RENDER(func) \
wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(func))
#define EVT_AUI_FIND_MANAGER(func) \
wx__DECLARE_EVT0(wxEVT_AUI_FIND_MANAGER, wxAuiManagerEventHandler(func))
#else
%constant wxEventType wxEVT_AUI_PANE_BUTTON;
%constant wxEventType wxEVT_AUI_PANE_CLOSE;
%constant wxEventType wxEVT_AUI_PANE_MAXIMIZE;
%constant wxEventType wxEVT_AUI_PANE_RESTORE;
%constant wxEventType wxEVT_AUI_RENDER;
%constant wxEventType wxEVT_AUI_FIND_MANAGER;
%pythoncode {
EVT_AUI_PANE_BUTTON = wx.PyEventBinder( wxEVT_AUI_PANE_BUTTON )
EVT_AUI_PANE_CLOSE = wx.PyEventBinder( wxEVT_AUI_PANE_CLOSE )
EVT_AUI_PANE_MAXIMIZE = wx.PyEventBinder( wxEVT_AUI_PANE_MAXIMIZE )
EVT_AUI_PANE_RESTORE = wx.PyEventBinder( wxEVT_AUI_PANE_RESTORE )
EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER )
EVT_AUI_FIND_MANAGER = wx.PyEventBinder( wxEVT_AUI_FIND_MANAGER )
}
#endif // SWIG
#endif // wxUSE_AUI
#endif //_WX_FRAMEMANAGER_H_

View File

@ -0,0 +1,269 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/tabmdi.h
// Purpose: Generic MDI (Multiple Document Interface) classes
// Author: Hans Van Leemputten
// Modified by: Benjamin I. Williams / Kirix Corporation
// Created: 29/07/2002
// RCS-ID: $Id: tabmdi.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) Hans Van Leemputten
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUITABMDI_H_
#define _WX_AUITABMDI_H_
#if wxUSE_AUI
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/frame.h"
#include "wx/panel.h"
#include "wx/notebook.h"
#include "wx/icon.h"
#include "wx/aui/auibook.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_AUI wxAuiMDIParentFrame;
class WXDLLIMPEXP_FWD_AUI wxAuiMDIClientWindow;
class WXDLLIMPEXP_FWD_AUI wxAuiMDIChildFrame;
//-----------------------------------------------------------------------------
// wxAuiMDIParentFrame
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_AUI wxAuiMDIParentFrame : public wxFrame
{
public:
wxAuiMDIParentFrame();
wxAuiMDIParentFrame(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxFrameNameStr);
~wxAuiMDIParentFrame();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxFrameNameStr );
void SetArtProvider(wxAuiTabArt* provider);
wxAuiTabArt* GetArtProvider();
wxAuiNotebook* GetNotebook() const;
#if wxUSE_MENUS
wxMenu* GetWindowMenu() const { return m_pWindowMenu; }
void SetWindowMenu(wxMenu* pMenu);
virtual void SetMenuBar(wxMenuBar *pMenuBar);
#endif // wxUSE_MENUS
void SetChildMenuBar(wxAuiMDIChildFrame *pChild);
virtual bool ProcessEvent(wxEvent& event);
wxAuiMDIChildFrame *GetActiveChild() const;
void SetActiveChild(wxAuiMDIChildFrame* pChildFrame);
wxAuiMDIClientWindow *GetClientWindow() const;
virtual wxAuiMDIClientWindow *OnCreateClient();
virtual void Cascade() { /* Has no effect */ }
virtual void Tile(wxOrientation orient = wxHORIZONTAL);
virtual void ArrangeIcons() { /* Has no effect */ }
virtual void ActivateNext();
virtual void ActivatePrevious();
protected:
wxAuiMDIClientWindow* m_pClientWindow;
wxAuiMDIChildFrame* m_pActiveChild;
wxEvent* m_pLastEvt;
#if wxUSE_MENUS
wxMenu *m_pWindowMenu;
wxMenuBar *m_pMyMenuBar;
#endif // wxUSE_MENUS
protected:
void Init();
#if wxUSE_MENUS
void RemoveWindowMenu(wxMenuBar *pMenuBar);
void AddWindowMenu(wxMenuBar *pMenuBar);
void DoHandleMenu(wxCommandEvent &event);
#endif // wxUSE_MENUS
virtual void DoGetClientSize(int *width, int *height) const;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxAuiMDIParentFrame)
};
//-----------------------------------------------------------------------------
// wxAuiMDIChildFrame
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxPanel
{
public:
wxAuiMDIChildFrame();
wxAuiMDIChildFrame(wxAuiMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
virtual ~wxAuiMDIChildFrame();
bool Create(wxAuiMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
#if wxUSE_MENUS
virtual void SetMenuBar(wxMenuBar *menu_bar);
virtual wxMenuBar *GetMenuBar() const;
#endif // wxUSE_MENUS
virtual void SetTitle(const wxString& title);
virtual wxString GetTitle() const;
virtual void SetIcons(const wxIconBundle& icons);
virtual const wxIconBundle& GetIcons() const;
virtual void SetIcon(const wxIcon& icon);
virtual const wxIcon& GetIcon() const;
virtual void Activate();
virtual bool Destroy();
#if wxUSE_STATUSBAR
// no status bars
virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1,
long WXUNUSED(style) = 1,
wxWindowID WXUNUSED(winid) = 1,
const wxString& WXUNUSED(name) = wxEmptyString)
{ return (wxStatusBar*)NULL; }
virtual wxStatusBar *GetStatusBar() const { return (wxStatusBar*)NULL; }
virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {}
virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {}
#endif
// no size hints
virtual void DoSetSizeHints(int WXUNUSED(minW),
int WXUNUSED(minH),
int WXUNUSED(maxW) = wxDefaultCoord,
int WXUNUSED(maxH) = wxDefaultCoord,
int WXUNUSED(incW) = wxDefaultCoord,
int WXUNUSED(incH) = wxDefaultCoord) {}
#if wxUSE_TOOLBAR
// no toolbar bars
virtual wxToolBar* CreateToolBar(long WXUNUSED(style),
wxWindowID WXUNUSED(winid),
const wxString& WXUNUSED(name))
{ return (wxToolBar*)NULL; }
virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; }
#endif
// no maximize etc
virtual void Maximize(bool WXUNUSED(maximize) = true) { /* Has no effect */ }
virtual void Restore() { /* Has no effect */ }
virtual void Iconize(bool WXUNUSED(iconize) = true) { /* Has no effect */ }
virtual bool IsMaximized() const { return true; }
virtual bool IsIconized() const { return false; }
virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style)) { return false; }
virtual bool IsFullScreen() const { return false; }
virtual bool IsTopLevel() const { return false; }
void OnMenuHighlight(wxMenuEvent& evt);
void OnActivate(wxActivateEvent& evt);
void OnCloseWindow(wxCloseEvent& evt);
void SetMDIParentFrame(wxAuiMDIParentFrame* parent);
wxAuiMDIParentFrame* GetMDIParentFrame() const;
protected:
void Init();
virtual bool Show(bool show = true);
virtual void DoSetSize(int x, int y, int width, int height, int size_flags);
virtual void DoMoveWindow(int x, int y, int width, int height);
public:
// This function needs to be called when a size change is confirmed,
// we needed this function to prevent anybody from the outside
// changing the panel... it messes the UI layout when we would allow it.
void ApplyMDIChildFrameRect();
void DoShow(bool show);
protected:
wxAuiMDIParentFrame* m_pMDIParentFrame;
wxRect m_mdi_newrect;
wxRect m_mdi_currect;
wxString m_title;
wxIcon m_icon;
wxIconBundle m_icon_bundle;
bool m_activate_on_create;
#if wxUSE_MENUS
wxMenuBar* m_pMenuBar;
#endif // wxUSE_MENUS
private:
DECLARE_DYNAMIC_CLASS(wxAuiMDIChildFrame)
DECLARE_EVENT_TABLE()
friend class wxAuiMDIClientWindow;
};
//-----------------------------------------------------------------------------
// wxAuiMDIClientWindow
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_AUI wxAuiMDIClientWindow : public wxAuiNotebook
{
public:
wxAuiMDIClientWindow();
wxAuiMDIClientWindow(wxAuiMDIParentFrame *parent, long style = 0);
~wxAuiMDIClientWindow();
virtual bool CreateClient(wxAuiMDIParentFrame *parent,
long style = wxVSCROLL | wxHSCROLL);
virtual int SetSelection(size_t page);
protected:
void PageChanged(int old_selection, int new_selection);
void OnPageClose(wxAuiNotebookEvent& evt);
void OnPageChanged(wxAuiNotebookEvent& evt);
void OnSize(wxSizeEvent& evt);
private:
DECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow)
DECLARE_EVENT_TABLE()
};
#endif // wxUSE_AUI
#endif // _WX_AUITABMDI_H_

View File

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////
// Name: include/wx/beforestd.h
// Purpose: #include before STL headers
// Author: Vadim Zeitlin
// Modified by:
// Created: 07/07/03
// RCS-ID: $Id: beforestd.h 42906 2006-11-01 14:16:42Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/**
Unfortunately, when compiling at maximum warning level, the standard
headers themselves may generate warnings -- and really lots of them. So
before including them, this header should be included to temporarily
suppress the warnings and after this the header afterstd.h should be
included to enable them back again.
Note that there are intentionally no inclusion guards in this file, because
it can be included several times.
*/
// VC 7.x isn't as bad as VC6 and doesn't give these warnings but eVC (which
// defines _MSC_VER as 1201) does need to be included as it's VC6-like
#if defined(__VISUALC__) && __VISUALC__ <= 1201
// MSVC 5 does not have this
#if __VISUALC__ > 1100
// we have to disable (and reenable in afterstd.h) this one because,
// even though it is of level 4, it is not disabled by warning(push, 1)
// below for VC7.1!
// unreachable code
#pragma warning(disable:4702)
#pragma warning(push, 1)
#else // VC 5
// 'expression' : signed/unsigned mismatch
#pragma warning(disable:4018)
// 'identifier' : unreferenced formal parameter
#pragma warning(disable:4100)
// 'conversion' : conversion from 'type1' to 'type2',
// possible loss of data
#pragma warning(disable:4244)
// C++ language change: to explicitly specialize class template
// 'identifier' use the following syntax
#pragma warning(disable:4663)
#endif
// these warning have to be disabled and not just temporarily disabled
// because they will be given at the end of the compilation of the
// current source and there is absolutely nothing we can do about them
// 'foo': unreferenced inline function has been removed
#pragma warning(disable:4514)
// 'function' : function not inlined
#pragma warning(disable:4710)
// 'id': identifier was truncated to 'num' characters in the debug info
#pragma warning(disable:4786)
#endif // VC++ < 7

View File

@ -0,0 +1,241 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bitmap.h
// Purpose: wxBitmap class interface
// Author: Vaclav Slavik
// Modified by:
// Created: 22.04.01
// RCS-ID: $Id: bitmap.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BITMAP_H_BASE_
#define _WX_BITMAP_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/string.h"
#include "wx/gdicmn.h" // for wxBitmapType
#include "wx/colour.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxPalette;
// ----------------------------------------------------------------------------
// wxVariant support
// ----------------------------------------------------------------------------
#if wxUSE_VARIANT
#include "wx/variant.h"
DECLARE_VARIANT_OBJECT_EXPORTED(wxBitmap,WXDLLEXPORT)
#endif
// ----------------------------------------------------------------------------
// wxMask represents the transparent area of the bitmap
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMaskBase : public wxObject
{
public:
// create the mask from bitmap pixels of the given colour
bool Create(const wxBitmap& bitmap, const wxColour& colour);
#if wxUSE_PALETTE
// create the mask from bitmap pixels with the given palette index
bool Create(const wxBitmap& bitmap, int paletteIndex);
#endif // wxUSE_PALETTE
// create the mask from the given mono bitmap
bool Create(const wxBitmap& bitmap);
protected:
// this function is called from Create() to free the existing mask data
virtual void FreeData() = 0;
// these functions must be overridden to implement the corresponding public
// Create() methods, they shouldn't call FreeData() as it's already called
// by the public wrappers
virtual bool InitFromColour(const wxBitmap& bitmap,
const wxColour& colour) = 0;
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) = 0;
};
#if defined(__WXMGL__) || \
defined(__WXDFB__) || \
defined(__WXMAC__) || \
defined(__WXGTK__) || \
defined(__WXCOCOA__) || \
defined(__WXMOTIF__) || \
defined(__WXX11__)
#define wxUSE_BITMAP_BASE 1
#else
#define wxUSE_BITMAP_BASE 0
#endif
// Only used by some ports
// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
#if wxUSE_BITMAP_BASE
// ----------------------------------------------------------------------------
// wxBitmapHandler: class which knows how to create/load/save bitmaps in
// different formats
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
{
public:
wxBitmapHandlerBase() { m_type = wxBITMAP_TYPE_INVALID; }
virtual ~wxBitmapHandlerBase() { }
virtual bool Create(wxBitmap *bitmap, const void* data, long flags,
int width, int height, int depth = 1);
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight);
virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
int type, const wxPalette *palette = NULL);
void SetName(const wxString& name) { m_name = name; }
void SetExtension(const wxString& ext) { m_extension = ext; }
void SetType(wxBitmapType type) { m_type = type; }
const wxString& GetName() const { return m_name; }
const wxString& GetExtension() const { return m_extension; }
wxBitmapType GetType() const { return m_type; }
private:
wxString m_name;
wxString m_extension;
wxBitmapType m_type;
DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
};
class WXDLLEXPORT wxBitmapBase : public wxGDIObject
{
public:
/*
Derived class must implement these:
wxBitmap();
wxBitmap(int width, int height, int depth = -1);
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(const char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
wxBitmap(const wxImage& image, int depth = -1);
bool Create(int width, int height, int depth = -1);
static void InitStandardHandlers();
*/
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const = 0;
virtual int GetHeight() const = 0;
virtual int GetWidth() const = 0;
virtual int GetDepth() const = 0;
virtual wxImage ConvertToImage() const = 0;
virtual wxMask *GetMask() const = 0;
virtual void SetMask(wxMask *mask) = 0;
virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
virtual bool SaveFile(const wxString &name, wxBitmapType type,
const wxPalette *palette = (wxPalette *)NULL) const = 0;
virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
/*
If raw bitmap access is supported (see wx/rawbmp.h), the following
methods should be implemented:
virtual bool GetRawData(wxRawBitmapData *data) = 0;
virtual void UngetRawData(wxRawBitmapData *data) = 0;
*/
#if wxUSE_PALETTE
virtual wxPalette *GetPalette() const = 0;
virtual void SetPalette(const wxPalette& palette) = 0;
#endif // wxUSE_PALETTE
// copies the contents and mask of the given (colour) icon to the bitmap
virtual bool CopyFromIcon(const wxIcon& icon) = 0;
// implementation:
virtual void SetHeight(int height) = 0;
virtual void SetWidth(int width) = 0;
virtual void SetDepth(int depth) = 0;
// Format handling
static inline wxList& GetHandlers() { return sm_handlers; }
static void AddHandler(wxBitmapHandlerBase *handler);
static void InsertHandler(wxBitmapHandlerBase *handler);
static bool RemoveHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
static wxBitmapHandler *FindHandler(wxBitmapType bitmapType);
//static void InitStandardHandlers();
// (wxBitmap must implement this one)
static void CleanUpHandlers();
// this method is only used by the generic implementation of wxMask
// currently but could be useful elsewhere in the future: it can be
// overridden to quantize the colour to correspond to bitmap colour depth
// if necessary; default implementation simply returns the colour as is
virtual wxColour QuantizeColour(const wxColour& colour) const
{
return colour;
}
protected:
static wxList sm_handlers;
DECLARE_ABSTRACT_CLASS(wxBitmapBase)
};
#endif // wxUSE_BITMAP_BASE
#if defined(__WXPALMOS__)
#include "wx/palmos/bitmap.h"
#elif defined(__WXMSW__)
#include "wx/msw/bitmap.h"
#elif defined(__WXMOTIF__)
#include "wx/x11/bitmap.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/bitmap.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/bitmap.h"
#elif defined(__WXX11__)
#include "wx/x11/bitmap.h"
#elif defined(__WXMGL__)
#include "wx/mgl/bitmap.h"
#elif defined(__WXDFB__)
#include "wx/dfb/bitmap.h"
#elif defined(__WXMAC__)
#include "wx/mac/bitmap.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/bitmap.h"
#elif defined(__WXPM__)
#include "wx/os2/bitmap.h"
#endif
// we must include generic mask.h after wxBitmap definition
#if defined(__WXMGL__) || defined(__WXDFB__)
#define wxUSE_GENERIC_MASK 1
#else
#define wxUSE_GENERIC_MASK 0
#endif
#if wxUSE_GENERIC_MASK
#include "wx/generic/mask.h"
#endif
#endif // _WX_BITMAP_H_BASE_

View File

@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpbutton.h
// Purpose: wxBitmapButton class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 25.08.00
// RCS-ID: $Id: bmpbuttn.h 45498 2007-04-16 13:03:05Z VZ $
// Copyright: (c) 2000 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPBUTTON_H_BASE_
#define _WX_BMPBUTTON_H_BASE_
#include "wx/defs.h"
#if wxUSE_BMPBUTTON
#include "wx/bitmap.h"
#include "wx/button.h"
extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[];
// ----------------------------------------------------------------------------
// wxBitmapButton: a button which shows bitmaps instead of the usual string.
// It has different bitmaps for different states (focused/disabled/pressed)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapButtonBase : public wxButton
{
public:
wxBitmapButtonBase()
{
m_marginX =
m_marginY = 0;
}
// set the bitmaps
void SetBitmapLabel(const wxBitmap& bitmap)
{ m_bmpNormal = bitmap; OnSetBitmap(); }
void SetBitmapSelected(const wxBitmap& sel)
{ m_bmpSelected = sel; OnSetBitmap(); }
void SetBitmapFocus(const wxBitmap& focus)
{ m_bmpFocus = focus; OnSetBitmap(); }
void SetBitmapDisabled(const wxBitmap& disabled)
{ m_bmpDisabled = disabled; OnSetBitmap(); }
void SetBitmapHover(const wxBitmap& hover)
{ m_bmpHover = hover; OnSetBitmap(); }
// retrieve the bitmaps
const wxBitmap& GetBitmapLabel() const { return m_bmpNormal; }
const wxBitmap& GetBitmapSelected() const { return m_bmpSelected; }
const wxBitmap& GetBitmapFocus() const { return m_bmpFocus; }
const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; }
const wxBitmap& GetBitmapHover() const { return m_bmpHover; }
wxBitmap& GetBitmapLabel() { return m_bmpNormal; }
wxBitmap& GetBitmapSelected() { return m_bmpSelected; }
wxBitmap& GetBitmapFocus() { return m_bmpFocus; }
wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; }
wxBitmap& GetBitmapHover() { return m_bmpHover; }
// set/get the margins around the button
virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
int GetMarginX() const { return m_marginX; }
int GetMarginY() const { return m_marginY; }
// deprecated synonym for SetBitmapLabel()
#if WXWIN_COMPATIBILITY_2_6
wxDEPRECATED( void SetLabel(const wxBitmap& bitmap) );
// prevent virtual function hiding
virtual void SetLabel(const wxString& label)
{ wxWindow::SetLabel(label); }
#endif // WXWIN_COMPATIBILITY_2_6
protected:
// function called when any of the bitmaps changes
virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }
// the bitmaps for various states
wxBitmap m_bmpNormal,
m_bmpSelected,
m_bmpFocus,
m_bmpDisabled,
m_bmpHover;
// the margins around the bitmap
int m_marginX,
m_marginY;
DECLARE_NO_COPY_CLASS(wxBitmapButtonBase)
};
#if WXWIN_COMPATIBILITY_2_6
inline void wxBitmapButtonBase::SetLabel(const wxBitmap& bitmap)
{
SetBitmapLabel(bitmap);
}
#endif // WXWIN_COMPATIBILITY_2_6
#if defined(__WXUNIVERSAL__)
#include "wx/univ/bmpbuttn.h"
#elif defined(__WXMSW__)
#include "wx/msw/bmpbuttn.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/bmpbuttn.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/bmpbuttn.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/bmpbuttn.h"
#elif defined(__WXMAC__)
#include "wx/mac/bmpbuttn.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/bmpbuttn.h"
#elif defined(__WXPM__)
#include "wx/os2/bmpbuttn.h"
#endif
#endif // wxUSE_BMPBUTTON
#endif // _WX_BMPBUTTON_H_BASE_

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpcbox.h
// Purpose: wxBitmapComboBox base header
// Author: Jaakko Salli
// Modified by:
// Created: Aug-31-2006
// Copyright: (c) Jaakko Salli
// RCS-ID: $Id: bmpcbox.h 42046 2006-10-16 09:30:01Z ABX $
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPCBOX_H_BASE_
#define _WX_BMPCBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_BITMAPCOMBOBOX
#include "wx/bitmap.h"
extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxBitmapComboBoxNameStr[];
class WXDLLIMPEXP_ADV wxBitmapComboBoxBase
{
public:
// ctors and such
wxBitmapComboBoxBase() { }
virtual ~wxBitmapComboBoxBase() { }
// Returns the image of the item with the given index.
virtual wxBitmap GetItemBitmap(unsigned int n) const = 0;
// Sets the image for the given item.
virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) = 0;
// Returns size of the image used in list
virtual wxSize GetBitmapSize() const = 0;
};
#include "wx/generic/bmpcbox.h"
#endif // wxUSE_BITMAPCOMBOBOX
#endif // _WX_BMPCBOX_H_BASE_

View File

@ -0,0 +1,403 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bookctrl.h
// Purpose: wxBookCtrlBase: common base class for wxList/Tree/Notebook
// Author: Vadim Zeitlin
// Modified by:
// Created: 19.08.03
// RCS-ID: $Id: bookctrl.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BOOKCTRL_H_
#define _WX_BOOKCTRL_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_BOOKCTRL
#include "wx/control.h"
#include "wx/dynarray.h"
WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages);
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxBookCtrlBaseEvent;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// wxBookCtrl hit results
enum
{
wxBK_HITTEST_NOWHERE = 1, // not on tab
wxBK_HITTEST_ONICON = 2, // on icon
wxBK_HITTEST_ONLABEL = 4, // on label
wxBK_HITTEST_ONITEM = wxBK_HITTEST_ONICON | wxBK_HITTEST_ONLABEL,
wxBK_HITTEST_ONPAGE = 8 // not on tab control, but over the selected page
};
// wxBookCtrl flags (common for wxNotebook, wxListbook, wxChoicebook, wxTreebook)
#define wxBK_DEFAULT 0x0000
#define wxBK_TOP 0x0010
#define wxBK_BOTTOM 0x0020
#define wxBK_LEFT 0x0040
#define wxBK_RIGHT 0x0080
#define wxBK_ALIGN_MASK (wxBK_TOP | wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT)
// ----------------------------------------------------------------------------
// wxBookCtrlBase
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBookCtrlBase : public wxControl
{
public:
// construction
// ------------
wxBookCtrlBase()
{
Init();
}
wxBookCtrlBase(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString)
{
Init();
(void)Create(parent, winid, pos, size, style, name);
}
// quasi ctor
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
// dtor
virtual ~wxBookCtrlBase();
// accessors
// ---------
// get number of pages in the dialog
virtual size_t GetPageCount() const { return m_pages.size(); }
// get the panel which represents the given page
wxWindow *GetPage(size_t n) { return m_pages[n]; }
wxWindow *GetPage(size_t n) const { return m_pages[n]; }
// get the current page or NULL if none
wxWindow *GetCurrentPage() const
{
const int n = GetSelection();
return n == wxNOT_FOUND ? NULL : GetPage(n);
}
// get the currently selected page or wxNOT_FOUND if none
virtual int GetSelection() const = 0;
// set/get the title of a page
virtual bool SetPageText(size_t n, const wxString& strText) = 0;
virtual wxString GetPageText(size_t n) const = 0;
// image list stuff: each page may have an image associated with it (all
// images belong to the same image list)
// ---------------------------------------------------------------------
// sets the image list to use, it is *not* deleted by the control
virtual void SetImageList(wxImageList *imageList);
// as SetImageList() but we will delete the image list ourselves
void AssignImageList(wxImageList *imageList);
// get pointer (may be NULL) to the associated image list
wxImageList* GetImageList() const { return m_imageList; }
// sets/returns item's image index in the current image list
virtual int GetPageImage(size_t n) const = 0;
virtual bool SetPageImage(size_t n, int imageId) = 0;
// geometry
// --------
// resize the notebook so that all pages will have the specified size
virtual void SetPageSize(const wxSize& size);
// calculate the size of the control from the size of its page
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
// get/set size of area between book control area and page area
unsigned int GetInternalBorder() const { return m_internalBorder; }
void SetInternalBorder(unsigned int border) { m_internalBorder = border; }
// Sets/gets the margin around the controller
void SetControlMargin(int margin) { m_controlMargin = margin; }
int GetControlMargin() const { return m_controlMargin; }
// returns true if we have wxBK_TOP or wxBK_BOTTOM style
bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
// set/get option to shrink to fit current page
void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
// returns the sizer containing the control, if any
wxSizer* GetControlSizer() const { return m_controlSizer; }
// operations
// ----------
// remove one page from the control and delete it
virtual bool DeletePage(size_t n);
// remove one page from the notebook, without deleting it
virtual bool RemovePage(size_t n)
{
DoInvalidateBestSize();
return DoRemovePage(n) != NULL;
}
// remove all pages and delete them
virtual bool DeleteAllPages()
{
DoInvalidateBestSize();
WX_CLEAR_ARRAY(m_pages);
return true;
}
// adds a new page to the control
virtual bool AddPage(wxWindow *page,
const wxString& text,
bool bSelect = false,
int imageId = -1)
{
DoInvalidateBestSize();
return InsertPage(GetPageCount(), page, text, bSelect, imageId);
}
// the same as AddPage(), but adds the page at the specified position
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect = false,
int imageId = -1) = 0;
// set the currently selected page, return the index of the previously
// selected one (or -1 on error)
//
// NB: this function will generate PAGE_CHANGING/ED events
virtual int SetSelection(size_t n) = 0;
// acts as SetSelection but does not generate events
virtual int ChangeSelection(size_t n) = 0;
// cycle thru the pages
void AdvanceSelection(bool forward = true)
{
int nPage = GetNextPage(forward);
if ( nPage != -1 )
{
// cast is safe because of the check above
SetSelection((size_t)nPage);
}
}
// hit test: returns which page is hit and, optionally, where (icon, label)
virtual int HitTest(const wxPoint& WXUNUSED(pt),
long * WXUNUSED(flags) = NULL) const
{
return wxNOT_FOUND;
}
// we do have multiple pages
virtual bool HasMultiplePages() const { return true; }
protected:
// flags for DoSetSelection()
enum
{
SetSelection_SendEvent = 1
};
// set the selection to the given page, sending the events (which can
// possibly prevent the page change from taking place) if SendEvent flag is
// included
virtual int DoSetSelection(size_t nPage, int flags = 0);
// if the derived class uses DoSetSelection() for implementing
// [Set|Change]Selection, it must override UpdateSelectedPage(),
// CreatePageChangingEvent() and MakeChangedEvent(), but as it might not
// use it, these functions are not pure virtual
// called to notify the control about a new current page
virtual void UpdateSelectedPage(size_t WXUNUSED(newsel))
{ wxFAIL_MSG(wxT("Override this function!")); }
// create a new "page changing" event
virtual wxBookCtrlBaseEvent* CreatePageChangingEvent() const
{ wxFAIL_MSG(wxT("Override this function!")); return NULL; }
// modify the event created by CreatePageChangingEvent() to "page changed"
// event, usually by just calling SetEventType() on it
virtual void MakeChangedEvent(wxBookCtrlBaseEvent& WXUNUSED(event))
{ wxFAIL_MSG(wxT("Override this function!")); }
// Should we accept NULL page pointers in Add/InsertPage()?
//
// Default is no but derived classes may override it if they can treat NULL
// pages in some sensible way (e.g. wxTreebook overrides this to allow
// having nodes without any associated page)
virtual bool AllowNullPage() const { return false; }
// remove the page and return a pointer to it
virtual wxWindow *DoRemovePage(size_t page) = 0;
// our best size is the size which fits all our pages
virtual wxSize DoGetBestSize() const;
// helper: get the next page wrapping if we reached the end
int GetNextPage(bool forward) const;
// Lay out controls
void DoSize();
// This method also invalidates the size of the controller and should be
// called instead of just InvalidateBestSize() whenever pages are added or
// removed as this also affects the controller
void DoInvalidateBestSize();
#if wxUSE_HELP
// Show the help for the corresponding page
void OnHelp(wxHelpEvent& event);
#endif // wxUSE_HELP
// the array of all pages of this control
wxArrayPages m_pages;
// the associated image list or NULL
wxImageList *m_imageList;
// true if we must delete m_imageList
bool m_ownsImageList;
// get the page area
wxRect GetPageRect() const;
// event handlers
virtual wxSize GetControllerSize() const;
void OnSize(wxSizeEvent& event);
// controller buddy if available, NULL otherwise (usually for native book controls like wxNotebook)
wxControl *m_bookctrl;
// Whether to shrink to fit current page
bool m_fitToCurrentPage;
// the sizer containing the choice control
wxSizer *m_controlSizer;
// the margin around the choice control
int m_controlMargin;
private:
// common part of all ctors
void Init();
// internal border
unsigned int m_internalBorder;
DECLARE_ABSTRACT_CLASS(wxBookCtrlBase)
DECLARE_NO_COPY_CLASS(wxBookCtrlBase)
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// wxBookCtrlBaseEvent: page changing events generated by derived classes
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBookCtrlBaseEvent : public wxNotifyEvent
{
public:
wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
int nSel = -1, int nOldSel = -1)
: wxNotifyEvent(commandType, winid)
{
m_nSel = nSel;
m_nOldSel = nOldSel;
}
wxBookCtrlBaseEvent(const wxBookCtrlBaseEvent& event)
: wxNotifyEvent(event)
{
m_nSel = event.m_nSel;
m_nOldSel = event.m_nOldSel;
}
// accessors
// the currently selected page (-1 if none)
int GetSelection() const { return m_nSel; }
void SetSelection(int nSel) { m_nSel = nSel; }
// the page that was selected before the change (-1 if none)
int GetOldSelection() const { return m_nOldSel; }
void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
private:
int m_nSel, // currently selected page
m_nOldSel; // previously selected page
};
// make a default book control for given platform
#if wxUSE_NOTEBOOK
// dedicated to majority of desktops
#include "wx/notebook.h"
#define wxBookCtrl wxNotebook
#define wxBookCtrlEvent wxNotebookEvent
#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
#define EVT_BOOKCTRL_PAGE_CHANGED(id, fn) EVT_NOTEBOOK_PAGE_CHANGED(id, fn)
#define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_NOTEBOOK_PAGE_CHANGING(id, fn)
#define wxBookctrlEventHandler(func) wxNotebookEventHandler(func)
#else
// dedicated to Smartphones
#include "wx/choicebk.h"
#define wxBookCtrl wxChoicebook
#define wxBookCtrlEvent wxChoicebookEvent
#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED
#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING
#define EVT_BOOKCTRL_PAGE_CHANGED(id, fn) EVT_CHOICEBOOK_PAGE_CHANGED(id, fn)
#define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_CHOICEBOOK_PAGE_CHANGING(id, fn)
#define wxBookctrlEventHandler(func) wxChoicebookEventHandler(func)
#endif
#if WXWIN_COMPATIBILITY_2_6
#define wxBC_TOP wxBK_TOP
#define wxBC_BOTTOM wxBK_BOTTOM
#define wxBC_LEFT wxBK_LEFT
#define wxBC_RIGHT wxBK_RIGHT
#define wxBC_DEFAULT wxBK_DEFAULT
#endif
#endif // wxUSE_BOOKCTRL
#endif // _WX_BOOKCTRL_H_

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/brush.h
// Purpose: Includes platform-specific wxBrush file
// Author: Julian Smart
// Modified by:
// Created:
// RCS-ID: $Id: brush.h 40865 2006-08-27 09:42:42Z VS $
// Copyright: Julian Smart
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BRUSH_H_BASE_
#define _WX_BRUSH_H_BASE_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/gdiobj.h"
// wxBrushBase
class WXDLLEXPORT wxBrushBase: public wxGDIObject
{
public:
virtual ~wxBrushBase() { }
virtual int GetStyle() const = 0;
virtual bool IsHatch() const
{ return (GetStyle()>=wxFIRST_HATCH) && (GetStyle()<=wxLAST_HATCH); }
};
#if defined(__WXPALMOS__)
#include "wx/palmos/brush.h"
#elif defined(__WXMSW__)
#include "wx/msw/brush.h"
#elif defined(__WXMOTIF__) || defined(__WXX11__)
#include "wx/x11/brush.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/brush.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/brush.h"
#elif defined(__WXMGL__)
#include "wx/mgl/brush.h"
#elif defined(__WXDFB__)
#include "wx/dfb/brush.h"
#elif defined(__WXMAC__)
#include "wx/mac/brush.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/brush.h"
#elif defined(__WXPM__)
#include "wx/os2/brush.h"
#endif
#endif
// _WX_BRUSH_H_BASE_

View File

@ -0,0 +1,314 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/buffer.h
// Purpose: auto buffer classes: buffers which automatically free memory
// Author: Vadim Zeitlin
// Modified by:
// Created: 12.04.99
// RCS-ID: $Id: buffer.h 45761 2007-05-02 17:09:30Z VS $
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUFFER_H
#define _WX_BUFFER_H
#include "wx/wxchar.h"
#include <stdlib.h> // malloc() and free()
// ----------------------------------------------------------------------------
// Special classes for (wide) character strings: they use malloc/free instead
// of new/delete
// ----------------------------------------------------------------------------
#define DEFINE_BUFFER(classname, chartype, strdupfunc) \
class WXDLLIMPEXP_BASE classname \
{ \
public: \
classname(const chartype *str = NULL) \
: m_str(str ? strdupfunc(str) : NULL) \
{ \
} \
\
classname(size_t len) \
: m_str((chartype *)malloc((len + 1)*sizeof(chartype))) \
{ \
m_str[len] = (chartype)0; \
} \
\
/* no need to check for NULL, free() does it */ \
~classname() { free(m_str); } \
\
/* \
WARNING: \
\
the copy ctor and assignment operators change the passed in object \
even although it is declared as "const", so: \
\
a) it shouldn't be really const \
b) you shouldn't use it afterwards (or know that it was reset) \
\
This is very ugly but is unfortunately needed to make the normal use\
of classname buffer objects possible and is very similar to what \
std::auto_ptr<> does (as if it were an excuse...) \
*/ \
\
/* \
because of the remark above, release() is declared const even if it \
isn't really const \
*/ \
chartype *release() const \
{ \
chartype *p = m_str; \
((classname *)this)->m_str = NULL; \
return p; \
} \
\
void reset() \
{ \
free(m_str); \
m_str = NULL; \
} \
\
classname(const classname& src) \
: m_str(src.release()) \
{ \
} \
\
classname& operator=(const chartype *str) \
{ \
free(m_str); \
m_str = str ? strdupfunc(str) : NULL; \
return *this; \
} \
\
classname& operator=(const classname& src) \
{ \
free(m_str); \
m_str = src.release(); \
\
return *this; \
} \
\
bool extend(size_t len) \
{ \
chartype * \
str = (chartype *)realloc(m_str, (len + 1)*sizeof(chartype)); \
if ( !str ) \
return false; \
\
m_str = str; \
\
return true; \
} \
\
chartype *data() { return m_str; } \
const chartype *data() const { return m_str; } \
operator const chartype *() const { return m_str; } \
chartype operator[](size_t n) const { return m_str[n]; } \
\
private: \
chartype *m_str; \
}
#if wxABI_VERSION >= 20804
// needed for wxString::char_str() and wchar_str()
#define DEFINE_WRITABLE_BUFFER(classname, baseclass, chartype) \
class WXDLLIMPEXP_BASE classname : public baseclass \
{ \
public: \
classname(const baseclass& src) : baseclass(src) {} \
classname(const chartype *str = NULL) : baseclass(str) {} \
\
operator chartype*() { return this->data(); } \
}
#endif // wxABI_VERSION >= 20804
DEFINE_BUFFER(wxCharBuffer, char, wxStrdupA);
#if wxABI_VERSION >= 20804
DEFINE_WRITABLE_BUFFER(wxWritableCharBuffer, wxCharBuffer, char);
#endif
#if wxUSE_WCHAR_T
DEFINE_BUFFER(wxWCharBuffer, wchar_t, wxStrdupW);
#if wxABI_VERSION >= 20804
DEFINE_WRITABLE_BUFFER(wxWritableWCharBuffer, wxWCharBuffer, wchar_t);
#endif
#endif // wxUSE_WCHAR_T
#undef DEFINE_BUFFER
#undef DEFINE_WRITABLE_BUFFER
#if wxUSE_UNICODE
typedef wxWCharBuffer wxWxCharBuffer;
#define wxMB2WXbuf wxWCharBuffer
#define wxWX2MBbuf wxCharBuffer
#define wxWC2WXbuf wxChar*
#define wxWX2WCbuf wxChar*
#else // ANSI
typedef wxCharBuffer wxWxCharBuffer;
#define wxMB2WXbuf wxChar*
#define wxWX2MBbuf wxChar*
#define wxWC2WXbuf wxCharBuffer
#define wxWX2WCbuf wxWCharBuffer
#endif // Unicode/ANSI
// ----------------------------------------------------------------------------
// A class for holding growable data buffers (not necessarily strings)
// ----------------------------------------------------------------------------
// This class manages the actual data buffer pointer and is ref-counted.
class wxMemoryBufferData
{
public:
// the initial size and also the size added by ResizeIfNeeded()
enum { DefBufSize = 1024 };
friend class wxMemoryBuffer;
// everyting is private as it can only be used by wxMemoryBuffer
private:
wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize)
: m_data(size ? malloc(size) : NULL), m_size(size), m_len(0), m_ref(0)
{
}
~wxMemoryBufferData() { free(m_data); }
void ResizeIfNeeded(size_t newSize)
{
if (newSize > m_size)
{
void *dataOld = m_data;
m_data = realloc(m_data, newSize + wxMemoryBufferData::DefBufSize);
if ( !m_data )
{
free(dataOld);
}
m_size = newSize + wxMemoryBufferData::DefBufSize;
}
}
void IncRef() { m_ref += 1; }
void DecRef()
{
m_ref -= 1;
if (m_ref == 0) // are there no more references?
delete this;
}
// the buffer containing the data
void *m_data;
// the size of the buffer
size_t m_size;
// the amount of data currently in the buffer
size_t m_len;
// the reference count
size_t m_ref;
DECLARE_NO_COPY_CLASS(wxMemoryBufferData)
};
class wxMemoryBuffer
{
public:
// ctor and dtor
wxMemoryBuffer(size_t size = wxMemoryBufferData::DefBufSize)
{
m_bufdata = new wxMemoryBufferData(size);
m_bufdata->IncRef();
}
~wxMemoryBuffer() { m_bufdata->DecRef(); }
// copy and assignment
wxMemoryBuffer(const wxMemoryBuffer& src)
: m_bufdata(src.m_bufdata)
{
m_bufdata->IncRef();
}
wxMemoryBuffer& operator=(const wxMemoryBuffer& src)
{
m_bufdata->DecRef();
m_bufdata = src.m_bufdata;
m_bufdata->IncRef();
return *this;
}
// Accessors
void *GetData() const { return m_bufdata->m_data; }
size_t GetBufSize() const { return m_bufdata->m_size; }
size_t GetDataLen() const { return m_bufdata->m_len; }
void SetBufSize(size_t size) { m_bufdata->ResizeIfNeeded(size); }
void SetDataLen(size_t len)
{
wxASSERT(len <= m_bufdata->m_size);
m_bufdata->m_len = len;
}
// Ensure the buffer is big enough and return a pointer to it
void *GetWriteBuf(size_t sizeNeeded)
{
m_bufdata->ResizeIfNeeded(sizeNeeded);
return m_bufdata->m_data;
}
// Update the length after the write
void UngetWriteBuf(size_t sizeUsed) { SetDataLen(sizeUsed); }
// Like the above, but appends to the buffer
void *GetAppendBuf(size_t sizeNeeded)
{
m_bufdata->ResizeIfNeeded(m_bufdata->m_len + sizeNeeded);
return (char*)m_bufdata->m_data + m_bufdata->m_len;
}
// Update the length after the append
void UngetAppendBuf(size_t sizeUsed)
{
SetDataLen(m_bufdata->m_len + sizeUsed);
}
// Other ways to append to the buffer
void AppendByte(char data)
{
wxCHECK_RET( m_bufdata->m_data, _T("invalid wxMemoryBuffer") );
m_bufdata->ResizeIfNeeded(m_bufdata->m_len + 1);
*(((char*)m_bufdata->m_data) + m_bufdata->m_len) = data;
m_bufdata->m_len += 1;
}
void AppendData(const void *data, size_t len)
{
memcpy(GetAppendBuf(len), data, len);
UngetAppendBuf(len);
}
operator const char *() const { return (const char*)GetData(); }
private:
wxMemoryBufferData* m_bufdata;
};
// ----------------------------------------------------------------------------
// template class for any kind of data
// ----------------------------------------------------------------------------
// TODO
#endif // _WX_BUFFER_H

View File

@ -0,0 +1,149 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/build.h
// Purpose: Runtime build options checking
// Author: Vadim Zeitlin, Vaclav Slavik
// Modified by:
// Created: 07.05.02
// RCS-ID: $Id: build.h 35858 2005-10-09 15:48:42Z MBN $
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUILD_H_
#define _WX_BUILD_H_
#include "wx/version.h"
// NB: This file contains macros for checking binary compatibility of libraries
// in multilib buildm, plugins and user components.
// The WX_BUILD_OPTIONS_SIGNATURE macro expands into string that should
// uniquely identify binary compatible builds: i.e. if two builds of the
// library are binary compatible, their signature string should be the
// same; if two builds are binary incompatible, their signatures should
// be different.
//
// Therefore, wxUSE_XXX flags that affect binary compatibility (vtables,
// function signatures) should be accounted for here. So should compilers
// and compiler versions (but note that binary compatible compiler versions
// such as gcc-2.95.2 and gcc-2.95.3 should have same signature!).
// ----------------------------------------------------------------------------
// WX_BUILD_OPTIONS_SIGNATURE
// ----------------------------------------------------------------------------
#define __WX_BO_STRINGIZE(x) __WX_BO_STRINGIZE0(x)
#define __WX_BO_STRINGIZE0(x) #x
#if (wxMINOR_VERSION % 2) == 0
#define __WX_BO_VERSION(x,y,z) \
__WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y)
#else
#define __WX_BO_VERSION(x,y,z) \
__WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y) "." __WX_BO_STRINGIZE(z)
#endif
#ifdef __WXDEBUG__
#define __WX_BO_DEBUG "debug"
#else
#define __WX_BO_DEBUG "no debug"
#endif
#if wxUSE_UNICODE
#define __WX_BO_UNICODE "Unicode"
#else
#define __WX_BO_UNICODE "ANSI"
#endif
// GCC and Intel C++ share same C++ ABI (and possibly others in the future),
// check if compiler versions are compatible:
#if defined(__GXX_ABI_VERSION)
#define __WX_BO_COMPILER \
",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION)
#elif defined(__INTEL_COMPILER)
#define __WX_BO_COMPILER ",Intel C++"
#elif defined(__GNUG__)
#define __WX_BO_COMPILER ",GCC " \
__WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__)
#elif defined(__VISUALC__)
#define __WX_BO_COMPILER ",Visual C++"
#elif defined(__BORLANDC__)
#define __WX_BO_COMPILER ",Borland C++"
#elif defined(__DIGITALMARS__)
#define __WX_BO_COMPILER ",DigitalMars"
#elif defined(__WATCOMC__)
#define __WX_BO_COMPILER ",Watcom C++"
#else
#define __WX_BO_COMPILER
#endif
// WXWIN_COMPATIBILITY macros affect presence of virtual functions
#if WXWIN_COMPATIBILITY_2_4
#define __WX_BO_WXWIN_COMPAT_2_4 ",compatible with 2.4"
#else
#define __WX_BO_WXWIN_COMPAT_2_4
#endif
#if WXWIN_COMPATIBILITY_2_6
#define __WX_BO_WXWIN_COMPAT_2_6 ",compatible with 2.6"
#else
#define __WX_BO_WXWIN_COMPAT_2_6
#endif
// deriving wxWin containers from STL ones changes them completely:
#if wxUSE_STL
#define __WX_BO_STL ",STL containers"
#else
#define __WX_BO_STL ",wx containers"
#endif
// This macro is passed as argument to wxConsoleApp::CheckBuildOptions()
#define WX_BUILD_OPTIONS_SIGNATURE \
__WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \
" (" __WX_BO_DEBUG "," __WX_BO_UNICODE \
__WX_BO_COMPILER \
__WX_BO_STL \
__WX_BO_WXWIN_COMPAT_2_4 __WX_BO_WXWIN_COMPAT_2_6 \
")"
// ----------------------------------------------------------------------------
// WX_CHECK_BUILD_OPTIONS
// ----------------------------------------------------------------------------
// Use this macro to check build options. Adding it to a file in DLL will
// ensure that the DLL checks build options in same way IMPLEMENT_APP() does.
#define WX_CHECK_BUILD_OPTIONS(libName) \
static struct wxBuildOptionsChecker \
{ \
wxBuildOptionsChecker() \
{ \
wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
libName); \
} \
} gs_buildOptionsCheck;
#if WXWIN_COMPATIBILITY_2_4
// ----------------------------------------------------------------------------
// wxBuildOptions
// ----------------------------------------------------------------------------
// NB: Don't use this class in new code, it relies on the ctor being always
// inlined. WX_BUILD_OPTIONS_SIGNATURE always works.
class wxBuildOptions
{
public:
// the ctor must be inline to get the compilation settings of the code
// which included this header
wxBuildOptions() : m_signature(WX_BUILD_OPTIONS_SIGNATURE) {}
private:
const char *m_signature;
// actually only CheckBuildOptions() should be our friend but well...
friend class wxAppConsole;
};
#endif // WXWIN_COMPATIBILITY_2_4
#endif // _WX_BUILD_H_

View File

@ -0,0 +1,21 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/busyinfo.h
// Purpose: Information window (when app is busy)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// RCS-ID: $Id: busyinfo.h 37158 2006-01-26 15:40:46Z ABX $
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __BUSYINFO_H_BASE__
#define __BUSYINFO_H_BASE__
#include "wx/defs.h"
#if wxUSE_BUSYINFO
#include "wx/generic/busyinfo.h"
#endif // wxUSE_BUSYINFO
#endif // __BUSYINFO_H_BASE__

View File

@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/button.h
// Purpose: wxButtonBase class
// Author: Vadim Zetlin
// Modified by:
// Created: 15.08.00
// RCS-ID: $Id: button.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) Vadim Zetlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTON_H_BASE_
#define _WX_BUTTON_H_BASE_
#include "wx/defs.h"
// ----------------------------------------------------------------------------
// wxButton flags shared with other classes
// ----------------------------------------------------------------------------
#if wxUSE_TOGGLEBTN || wxUSE_BUTTON
// These flags affect label alignment
#define wxBU_LEFT 0x0040
#define wxBU_TOP 0x0080
#define wxBU_RIGHT 0x0100
#define wxBU_BOTTOM 0x0200
#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM )
#endif
#if wxUSE_BUTTON
// ----------------------------------------------------------------------------
// wxButton specific flags
// ----------------------------------------------------------------------------
// These two flags are obsolete
#define wxBU_NOAUTODRAW 0x0000
#define wxBU_AUTODRAW 0x0004
// by default, the buttons will be created with some (system dependent)
// minimal size to make them look nicer, giving this style will make them as
// small as possible
#define wxBU_EXACTFIT 0x0001
#include "wx/control.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap;
extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[];
// ----------------------------------------------------------------------------
// wxButton: a push button
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxButtonBase : public wxControl
{
public:
wxButtonBase() { }
// show the image in the button in addition to the label
virtual void SetImageLabel(const wxBitmap& WXUNUSED(bitmap)) { }
// set the margins around the image
virtual void SetImageMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { }
// this wxButton method is called when the button becomes the default one
// on its panel
virtual void SetDefault() { }
// Buttons on MSW can look bad if they are not native colours, because
// then they become owner-drawn and not theme-drawn. Disable it here
// in wxButtonBase to make it consistent.
virtual bool ShouldInheritColours() const { return false; }
// returns the default button size for this platform
static wxSize GetDefaultSize();
protected:
DECLARE_NO_COPY_CLASS(wxButtonBase)
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/button.h"
#elif defined(__WXMSW__)
#include "wx/msw/button.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/button.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/button.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/button.h"
#elif defined(__WXMAC__)
#include "wx/mac/button.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/button.h"
#elif defined(__WXPM__)
#include "wx/os2/button.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/button.h"
#endif
#endif // wxUSE_BUTTON
#endif
// _WX_BUTTON_H_BASE_

View File

@ -0,0 +1,232 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/calctrl.h
// Purpose: date-picker control
// Author: Vadim Zeitlin
// Modified by:
// Created: 29.12.99
// RCS-ID: $Id: calctrl.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/*
TODO
1. implement multiple selections for date ranges
2. background bitmap for the calendar?
*/
#ifndef _WX_CALCTRL_H_
#define _WX_CALCTRL_H_
#include "wx/defs.h"
#if wxUSE_CALENDARCTRL
#include "wx/dateevt.h"
#include "wx/colour.h"
#include "wx/font.h"
// ----------------------------------------------------------------------------
// wxCalendarCtrl flags
// ----------------------------------------------------------------------------
enum
{
// show Sunday as the first day of the week (default)
wxCAL_SUNDAY_FIRST = 0x0000,
// show Monder as the first day of the week
wxCAL_MONDAY_FIRST = 0x0001,
// highlight holidays
wxCAL_SHOW_HOLIDAYS = 0x0002,
// disable the year change control, show only the month change one
wxCAL_NO_YEAR_CHANGE = 0x0004,
// don't allow changing neither month nor year (implies
// wxCAL_NO_YEAR_CHANGE)
wxCAL_NO_MONTH_CHANGE = 0x000c,
// use MS-style month-selection instead of combo-spin combination
wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010,
// show the neighbouring weeks in the previous and next month
wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// return values for the HitTest() method
enum wxCalendarHitTestResult
{
wxCAL_HITTEST_NOWHERE, // outside of anything
wxCAL_HITTEST_HEADER, // on the header (weekdays)
wxCAL_HITTEST_DAY, // on a day in the calendar
wxCAL_HITTEST_INCMONTH,
wxCAL_HITTEST_DECMONTH,
wxCAL_HITTEST_SURROUNDING_WEEK
};
// border types for a date
enum wxCalendarDateBorder
{
wxCAL_BORDER_NONE, // no border (default)
wxCAL_BORDER_SQUARE, // a rectangular border
wxCAL_BORDER_ROUND // a round border
};
// ----------------------------------------------------------------------------
// wxCalendarDateAttr: custom attributes for a calendar date
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxCalendarDateAttr
{
#if !defined(__VISAGECPP__)
protected:
// This has to be before the use of Init(), for MSVC++ 1.5
// But dorks up Visualage!
void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
{
m_border = border;
m_holiday = false;
}
#endif
public:
// ctors
wxCalendarDateAttr() { Init(); }
wxCalendarDateAttr(const wxColour& colText,
const wxColour& colBack = wxNullColour,
const wxColour& colBorder = wxNullColour,
const wxFont& font = wxNullFont,
wxCalendarDateBorder border = wxCAL_BORDER_NONE)
: m_colText(colText), m_colBack(colBack),
m_colBorder(colBorder), m_font(font)
{
Init(border);
}
wxCalendarDateAttr(wxCalendarDateBorder border,
const wxColour& colBorder = wxNullColour)
: m_colBorder(colBorder)
{
Init(border);
}
// setters
void SetTextColour(const wxColour& colText) { m_colText = colText; }
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
void SetBorderColour(const wxColour& col) { m_colBorder = col; }
void SetFont(const wxFont& font) { m_font = font; }
void SetBorder(wxCalendarDateBorder border) { m_border = border; }
void SetHoliday(bool holiday) { m_holiday = holiday; }
// accessors
bool HasTextColour() const { return m_colText.Ok(); }
bool HasBackgroundColour() const { return m_colBack.Ok(); }
bool HasBorderColour() const { return m_colBorder.Ok(); }
bool HasFont() const { return m_font.Ok(); }
bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; }
bool IsHoliday() const { return m_holiday; }
const wxColour& GetTextColour() const { return m_colText; }
const wxColour& GetBackgroundColour() const { return m_colBack; }
const wxColour& GetBorderColour() const { return m_colBorder; }
const wxFont& GetFont() const { return m_font; }
wxCalendarDateBorder GetBorder() const { return m_border; }
#if defined(__VISAGECPP__)
protected:
// This has to be here for VisualAge
void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
{
m_border = border;
m_holiday = false;
}
#endif
private:
wxColour m_colText,
m_colBack,
m_colBorder;
wxFont m_font;
wxCalendarDateBorder m_border;
bool m_holiday;
};
// ----------------------------------------------------------------------------
// wxCalendarCtrl events
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_ADV wxCalendarCtrl;
class WXDLLIMPEXP_ADV wxCalendarEvent : public wxDateEvent
{
friend class wxCalendarCtrl;
public:
wxCalendarEvent() { Init(); }
inline wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
void SetWeekDay(const wxDateTime::WeekDay wd) { m_wday = wd; }
wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
protected:
void Init()
{
m_wday = wxDateTime::Inv_WeekDay;
}
private:
wxDateTime::WeekDay m_wday;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxCalendarEvent)
};
// ----------------------------------------------------------------------------
// wxCalendarCtrl
// ----------------------------------------------------------------------------
// so far we only have a generic version, so keep it simple
#include "wx/generic/calctrl.h"
// now we can define the inline ctor using wxCalendarCtrl
inline
wxCalendarEvent::wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type)
: wxDateEvent(cal, cal->GetDate(), type)
{
}
// ----------------------------------------------------------------------------
// calendar event types and macros for handling them
// ----------------------------------------------------------------------------
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_SEL_CHANGED, 950)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_DAY_CHANGED, 951)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_MONTH_CHANGED, 952)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_YEAR_CHANGED, 953)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_DOUBLECLICKED, 954)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_CALENDAR_WEEKDAY_CLICKED, 955)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
#define wxCalendarEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCalendarEventFunction, &func)
#define wx__DECLARE_CALEVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_CALENDAR_ ## evt, id, wxCalendarEventHandler(fn))
#define EVT_CALENDAR(id, fn) wx__DECLARE_CALEVT(DOUBLECLICKED, id, fn)
#define EVT_CALENDAR_SEL_CHANGED(id, fn) wx__DECLARE_CALEVT(SEL_CHANGED, id, fn)
#define EVT_CALENDAR_DAY(id, fn) wx__DECLARE_CALEVT(DAY_CHANGED, id, fn)
#define EVT_CALENDAR_MONTH(id, fn) wx__DECLARE_CALEVT(MONTH_CHANGED, id, fn)
#define EVT_CALENDAR_YEAR(id, fn) wx__DECLARE_CALEVT(YEAR_CHANGED, id, fn)
#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEKDAY_CLICKED, id, fn)
#endif // wxUSE_CALENDARCTRL
#endif // _WX_CALCTRL_H_

View File

@ -0,0 +1,252 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/caret.h
// Purpose: wxCaretBase class - the interface of wxCaret
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.05.99
// RCS-ID: $Id: caret.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CARET_H_BASE_
#define _WX_CARET_H_BASE_
#include "wx/defs.h"
#if wxUSE_CARET
// ---------------------------------------------------------------------------
// forward declarations
// ---------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxWindowBase;
// ----------------------------------------------------------------------------
// headers we have to include
// ----------------------------------------------------------------------------
#include "wx/gdicmn.h" // for wxPoint, wxSize
// ----------------------------------------------------------------------------
// A caret is a blinking cursor showing the position where the typed text will
// appear. It can be either a solid block or a custom bitmap (TODO)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCaretBase
{
public:
// ctors
// -----
// default - use Create
wxCaretBase() { Init(); }
// create the caret of given (in pixels) width and height and associate
// with the given window
wxCaretBase(wxWindowBase *window, int width, int height)
{
Init();
(void)Create(window, width, height);
}
// same as above
wxCaretBase(wxWindowBase *window, const wxSize& size)
{
Init();
(void)Create(window, size);
}
// a virtual dtor has been provided since this class has virtual members
virtual ~wxCaretBase() { }
// Create() functions - same as ctor but returns the success code
// --------------------------------------------------------------
// same as ctor
bool Create(wxWindowBase *window, int width, int height)
{ return DoCreate(window, width, height); }
// same as ctor
bool Create(wxWindowBase *window, const wxSize& size)
{ return DoCreate(window, size.x, size.y); }
// accessors
// ---------
// is the caret valid?
bool IsOk() const { return m_width != 0 && m_height != 0; }
// is the caret currently shown?
bool IsVisible() const { return m_countVisible > 0; }
// get the caret position
void GetPosition(int *x, int *y) const
{
if ( x ) *x = m_x;
if ( y ) *y = m_y;
}
wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
// get the caret size
void GetSize(int *width, int *height) const
{
if ( width ) *width = m_width;
if ( height ) *height = m_height;
}
wxSize GetSize() const { return wxSize(m_width, m_height); }
// get the window we're associated with
wxWindow *GetWindow() const { return (wxWindow *)m_window; }
// change the size of the caret
void SetSize(int width, int height) {
m_width = width;
m_height = height;
DoSize();
}
void SetSize(const wxSize& size) { SetSize(size.x, size.y); }
// operations
// ----------
// move the caret to given position (in logical coords)
void Move(int x, int y) { m_x = x; m_y = y; DoMove(); }
void Move(const wxPoint& pt) { m_x = pt.x; m_y = pt.y; DoMove(); }
// show/hide the caret (should be called by wxWindow when needed):
// Show() must be called as many times as Hide() + 1 to make the caret
// visible
virtual void Show(bool show = true)
{
if ( show )
{
if ( m_countVisible++ == 0 )
DoShow();
}
else
{
if ( --m_countVisible == 0 )
DoHide();
}
}
virtual void Hide() { Show(false); }
// blink time is measured in milliseconds and is the time elapsed
// between 2 inversions of the caret (blink time of the caret is common
// to all carets in the Universe, so these functions are static)
static int GetBlinkTime();
static void SetBlinkTime(int milliseconds);
// implementation from now on
// --------------------------
// these functions should be called by wxWindow when the window gets/loses
// the focus - we create/show and hide/destroy the caret here
virtual void OnSetFocus() { }
virtual void OnKillFocus() { }
protected:
// these functions may be overriden in the derived classes, but they
// should call the base class version first
virtual bool DoCreate(wxWindowBase *window, int width, int height)
{
m_window = window;
m_width = width;
m_height = height;
return true;
}
// pure virtuals to implement in the derived class
virtual void DoShow() = 0;
virtual void DoHide() = 0;
virtual void DoMove() = 0;
virtual void DoSize() { }
// the common initialization
void Init()
{
m_window = (wxWindowBase *)NULL;
m_x = m_y = 0;
m_width = m_height = 0;
m_countVisible = 0;
}
// the size of the caret
int m_width, m_height;
// the position of the caret
int m_x, m_y;
// the window we're associated with
wxWindowBase *m_window;
// visibility count: the caret is visible only if it's positive
int m_countVisible;
private:
DECLARE_NO_COPY_CLASS(wxCaretBase)
};
// ---------------------------------------------------------------------------
// now include the real thing
// ---------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/caret.h"
#else
#include "wx/generic/caret.h"
#endif // platform
// ----------------------------------------------------------------------------
// wxCaretSuspend: a simple class which hides the caret in its ctor and
// restores it in the dtor, this should be used when drawing on the screen to
// avoid overdrawing the caret
// ----------------------------------------------------------------------------
#ifdef wxHAS_CARET_USING_OVERLAYS
// we don't need to hide the caret if it's rendered using overlays
class WXDLLEXPORT wxCaretSuspend
{
public:
wxCaretSuspend(wxWindow *WXUNUSED(win)) {}
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
};
#else // !wxHAS_CARET_USING_OVERLAYS
class WXDLLEXPORT wxCaretSuspend
{
public:
wxCaretSuspend(wxWindow *win)
{
m_caret = win->GetCaret();
m_show = false;
if ( m_caret && m_caret->IsVisible() )
{
m_caret->Hide();
m_show = true;
}
}
~wxCaretSuspend()
{
if ( m_caret && m_show )
m_caret->Show();
}
private:
wxCaret *m_caret;
bool m_show;
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
};
#endif // wxHAS_CARET_USING_OVERLAYS/!wxHAS_CARET_USING_OVERLAYS
#endif // wxUSE_CARET
#endif // _WX_CARET_H_BASE_

View File

@ -0,0 +1,156 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checkbox.h
// Purpose: wxCheckBox class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 07.09.00
// RCS-ID: $Id: checkbox.h 39901 2006-06-30 10:51:44Z VS $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKBOX_H_BASE_
#define _WX_CHECKBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_CHECKBOX
#include "wx/control.h"
/*
* wxCheckBox style flags
* (Using wxCHK_* because wxCB_* is used by wxComboBox).
* Determine whether to use a 3-state or 2-state
* checkbox. 3-state enables to differentiate
* between 'unchecked', 'checked' and 'undetermined'.
*/
#define wxCHK_2STATE 0x0000
#define wxCHK_3STATE 0x1000
/*
* If this style is set the user can set the checkbox to the
* undetermined state. If not set the undetermined set can only
* be set programmatically.
* This style can only be used with 3 state checkboxes.
*/
#define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
/*
* The possible states of a 3-state checkbox (Compatible
* with the 2-state checkbox).
*/
enum wxCheckBoxState
{
wxCHK_UNCHECKED,
wxCHK_CHECKED,
wxCHK_UNDETERMINED /* 3-state checkbox only */
};
extern WXDLLEXPORT_DATA(const wxChar) wxCheckBoxNameStr[];
// ----------------------------------------------------------------------------
// wxCheckBox: a control which shows a label and a box which may be checked
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCheckBoxBase : public wxControl
{
public:
wxCheckBoxBase() { }
// set/get the checked status of the listbox
virtual void SetValue(bool value) = 0;
virtual bool GetValue() const = 0;
bool IsChecked() const
{
wxASSERT_MSG( !Is3State(), wxT("Calling IsChecked() doesn't make sense for")
wxT(" a three state checkbox, Use Get3StateValue() instead") );
return GetValue();
}
wxCheckBoxState Get3StateValue() const
{
wxCheckBoxState state = DoGet3StateValue();
if ( state == wxCHK_UNDETERMINED && !Is3State() )
{
// Undetermined state with a 2-state checkbox??
wxFAIL_MSG( wxT("DoGet3StateValue() says the 2-state checkbox is ")
wxT("in an undetermined/third state") );
state = wxCHK_UNCHECKED;
}
return state;
}
void Set3StateValue(wxCheckBoxState state)
{
if ( state == wxCHK_UNDETERMINED && !Is3State() )
{
wxFAIL_MSG(wxT("Setting a 2-state checkbox to undetermined state"));
state = wxCHK_UNCHECKED;
}
DoSet3StateValue(state);
}
bool Is3State() const { return HasFlag(wxCHK_3STATE); }
bool Is3rdStateAllowedForUser() const
{
return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER);
}
virtual bool HasTransparentBackground() { return true; }
// wxCheckBox-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event)
{
wxControl::DoUpdateWindowUI(event);
if ( event.GetSetChecked() )
SetValue(event.GetChecked());
}
protected:
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
virtual wxCheckBoxState DoGet3StateValue() const
{
wxFAIL;
return wxCHK_UNCHECKED;
}
private:
DECLARE_NO_COPY_CLASS(wxCheckBoxBase)
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/checkbox.h"
#elif defined(__WXMSW__)
#include "wx/msw/checkbox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/checkbox.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/checkbox.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/checkbox.h"
#elif defined(__WXMAC__)
#include "wx/mac/checkbox.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/checkbox.h"
#elif defined(__WXPM__)
#include "wx/os2/checkbox.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/checkbox.h"
#endif
#endif // wxUSE_CHECKBOX
#endif
// _WX_CHECKBOX_H_BASE_

View File

@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checklst.h
// Purpose: wxCheckListBox class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 12.09.00
// RCS-ID: $Id: checklst.h 38319 2006-03-23 22:05:23Z VZ $
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKLST_H_BASE_
#define _WX_CHECKLST_H_BASE_
#if wxUSE_CHECKLISTBOX
#include "wx/listbox.h"
// ----------------------------------------------------------------------------
// wxCheckListBox: a listbox whose items may be checked
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCheckListBoxBase : public
#ifdef __WXWINCE__
// keep virtuals synchronised
wxListBoxBase
#else
wxListBox
#endif
{
public:
wxCheckListBoxBase() { }
// check list box specific methods
virtual bool IsChecked(unsigned int item) const = 0;
virtual void Check(unsigned int item, bool check = true) = 0;
DECLARE_NO_COPY_CLASS(wxCheckListBoxBase)
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/checklst.h"
#elif defined(__WXWINCE__)
#include "wx/msw/wince/checklst.h"
#elif defined(__WXMSW__)
#include "wx/msw/checklst.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/checklst.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/checklst.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/checklst.h"
#elif defined(__WXMAC__)
#include "wx/mac/checklst.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/checklst.h"
#elif defined(__WXPM__)
#include "wx/os2/checklst.h"
#endif
#endif // wxUSE_CHECKLISTBOX
#endif
// _WX_CHECKLST_H_BASE_

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/choicdgg.h
// Purpose: Includes generic choice dialog file
// Author: Julian Smart
// Modified by:
// Created:
// RCS-ID: $Id: choicdlg.h 33948 2005-05-04 18:57:50Z JS $
// Copyright: Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICDLG_H_BASE_
#define _WX_CHOICDLG_H_BASE_
#if wxUSE_CHOICEDLG
#include "wx/generic/choicdgg.h"
#endif
#endif
// _WX_CHOICDLG_H_BASE_

View File

@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/choice.h
// Purpose: wxChoice class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 26.07.99
// RCS-ID: $Id: choice.h 42727 2006-10-30 16:04:27Z VZ $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICE_H_BASE_
#define _WX_CHOICE_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_CHOICE
#include "wx/ctrlsub.h" // the base class
// ----------------------------------------------------------------------------
// global data
// ----------------------------------------------------------------------------
extern WXDLLEXPORT_DATA(const wxChar) wxChoiceNameStr[];
// ----------------------------------------------------------------------------
// wxChoice allows to select one of a non-modifiable list of strings
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxChoiceBase : public wxControlWithItems
{
public:
wxChoiceBase() { }
virtual ~wxChoiceBase();
// all generic methods are in wxControlWithItems
// get the current selection: this can only be different from the normal
// selection if the popup items list is currently opened and the user
// selected some item in it but didn't close the list yet; otherwise (and
// currently always on platforms other than MSW) this is the same as
// GetSelection()
virtual int GetCurrentSelection() const { return GetSelection(); }
// set/get the number of columns in the control (as they're not supported on
// most platforms, they do nothing by default)
virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
virtual int GetColumns() const { return 1 ; }
// emulate selecting the item event.GetInt()
void Command(wxCommandEvent& event);
private:
DECLARE_NO_COPY_CLASS(wxChoiceBase)
};
// ----------------------------------------------------------------------------
// include the platform-dependent class definition
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/choice.h"
#elif defined(__SMARTPHONE__) && defined(__WXWINCE__)
#include "wx/msw/wince/choicece.h"
#elif defined(__WXMSW__)
#include "wx/msw/choice.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/choice.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/choice.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/choice.h"
#elif defined(__WXMAC__)
#include "wx/mac/choice.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/choice.h"
#elif defined(__WXPM__)
#include "wx/os2/choice.h"
#endif
#endif // wxUSE_CHOICE
#endif // _WX_CHOICE_H_BASE_

View File

@ -0,0 +1,154 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/choicebk.h
// Purpose: wxChoicebook: wxChoice and wxNotebook combination
// Author: Vadim Zeitlin
// Modified by: Wlodzimierz ABX Skiba from wx/listbook.h
// Created: 15.09.04
// RCS-ID: $Id: choicebk.h 56623 2008-10-31 23:07:49Z VZ $
// Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICEBOOK_H_
#define _WX_CHOICEBOOK_H_
#include "wx/defs.h"
#if wxUSE_CHOICEBOOK
#include "wx/bookctrl.h"
#include "wx/choice.h"
class WXDLLIMPEXP_FWD_CORE wxChoice;
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
// wxChoicebook flags
#define wxCHB_DEFAULT wxBK_DEFAULT
#define wxCHB_TOP wxBK_TOP
#define wxCHB_BOTTOM wxBK_BOTTOM
#define wxCHB_LEFT wxBK_LEFT
#define wxCHB_RIGHT wxBK_RIGHT
#define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
// ----------------------------------------------------------------------------
// wxChoicebook
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase
{
public:
wxChoicebook()
{
Init();
}
wxChoicebook(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString)
{
Init();
(void)Create(parent, id, pos, size, style, name);
}
// quasi ctor
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId);
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect = false,
int imageId = -1);
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
virtual void SetImageList(wxImageList *imageList);
virtual bool DeleteAllPages();
// returns the choice control
wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
protected:
virtual wxWindow *DoRemovePage(size_t page);
// get the size which the choice control should have
virtual wxSize GetControllerSize() const;
void UpdateSelectedPage(size_t newsel)
{
m_selection = wx_static_cast(int, newsel);
GetChoiceCtrl()->Select(newsel);
}
wxBookCtrlBaseEvent* CreatePageChangingEvent() const;
void MakeChangedEvent(wxBookCtrlBaseEvent &event);
// event handlers
void OnChoiceSelected(wxCommandEvent& event);
// the currently selected page or wxNOT_FOUND if none
int m_selection;
private:
// common part of all constructors
void Init();
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
};
// ----------------------------------------------------------------------------
// choicebook event class and related stuff
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent
{
public:
wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
int nSel = -1, int nOldSel = -1)
: wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
{
}
wxChoicebookEvent(const wxChoicebookEvent& event)
: wxBookCtrlBaseEvent(event)
{
}
virtual wxEvent *Clone() const { return new wxChoicebookEvent(*this); }
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent)
};
typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&);
#define wxChoicebookEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxChoicebookEventFunction, &func)
#define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, winid, wxChoicebookEventHandler(fn))
#define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(fn))
#endif // wxUSE_CHOICEBOOK
#endif // _WX_CHOICEBOOK_H_

View File

@ -0,0 +1,145 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clipbrd.h
// Purpose: wxClipboad class and clipboard functions
// Author: Vadim Zeitlin
// Modified by:
// Created: 19.10.99
// RCS-ID: $Id: clipbrd.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) wxWidgets Team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLIPBRD_H_BASE_
#define _WX_CLIPBRD_H_BASE_
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/object.h"
#include "wx/wxchar.h"
class WXDLLIMPEXP_FWD_CORE wxDataFormat;
class WXDLLIMPEXP_FWD_CORE wxDataObject;
class WXDLLIMPEXP_FWD_CORE wxClipboard;
// ----------------------------------------------------------------------------
// wxClipboard represents the system clipboard. Normally, you should use
// wxTheClipboard which is a global pointer to the (unique) clipboard.
//
// Clipboard can be used to copy data to/paste data from. It works together
// with wxDataObject.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxClipboardBase : public wxObject
{
public:
wxClipboardBase() {}
// open the clipboard before Add/SetData() and GetData()
virtual bool Open() = 0;
// close the clipboard after Add/SetData() and GetData()
virtual void Close() = 0;
// query whether the clipboard is opened
virtual bool IsOpened() const = 0;
// add to the clipboard data
//
// NB: the clipboard owns the pointer and will delete it, so data must be
// allocated on the heap
virtual bool AddData( wxDataObject *data ) = 0;
// set the clipboard data, this is the same as Clear() followed by
// AddData()
virtual bool SetData( wxDataObject *data ) = 0;
// ask if data in correct format is available
virtual bool IsSupported( const wxDataFormat& format ) = 0;
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data ) = 0;
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear() = 0;
// flushes the clipboard: this means that the data which is currently on
// clipboard will stay available even after the application exits (possibly
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush() { return false; }
// X11 has two clipboards which get selected by this call. Empty on MSW.
virtual void UsePrimarySelection( bool WXUNUSED(primary) = false ) { }
// Returns global instance (wxTheClipboard) of the object:
static wxClipboard *Get();
};
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
// The global clipboard object - backward compatible access macro:
#define wxTheClipboard (wxClipboard::Get())
// ----------------------------------------------------------------------------
// include platform-specific class declaration
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/clipbrd.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/clipbrd.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/clipbrd.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/clipbrd.h"
#elif defined(__WXX11__)
#include "wx/x11/clipbrd.h"
#elif defined(__WXMGL__)
#include "wx/mgl/clipbrd.h"
#elif defined(__WXMAC__)
#include "wx/mac/clipbrd.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/clipbrd.h"
#elif defined(__WXPM__)
#include "wx/os2/clipbrd.h"
#endif
// ----------------------------------------------------------------------------
// helpful class for opening the clipboard and automatically closing it
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxClipboardLocker
{
public:
wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
{
m_clipboard = clipboard ? clipboard : wxTheClipboard;
if ( m_clipboard )
{
m_clipboard->Open();
}
}
bool operator!() const { return !m_clipboard->IsOpened(); }
~wxClipboardLocker()
{
if ( m_clipboard )
{
m_clipboard->Close();
}
}
private:
wxClipboard *m_clipboard;
DECLARE_NO_COPY_CLASS(wxClipboardLocker)
};
#endif // wxUSE_CLIPBOARD
#endif // _WX_CLIPBRD_H_BASE_

View File

@ -0,0 +1,273 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clntdata.h
// Purpose: A mixin class for holding a wxClientData or void pointer
// Author: Robin Dunn
// Modified by:
// Created: 9-Oct-2001
// RCS-ID: $Id: clntdata.h 36973 2006-01-18 16:45:41Z JS $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLNTDATAH__
#define _WX_CLNTDATAH__
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/hashmap.h"
typedef int (*wxShadowObjectMethod)(void*, void*);
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(
wxShadowObjectMethod,
wxShadowObjectMethods,
class WXDLLIMPEXP_BASE
);
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(
void *,
wxShadowObjectFields,
class WXDLLIMPEXP_BASE
);
class WXDLLIMPEXP_BASE wxShadowObject
{
public:
wxShadowObject() { }
void AddMethod( const wxString &name, wxShadowObjectMethod method )
{
wxShadowObjectMethods::iterator it = m_methods.find( name );
if (it == m_methods.end())
m_methods[ name ] = method;
else
it->second = method;
}
bool InvokeMethod( const wxString &name, void* window, void* param, int* returnValue )
{
wxShadowObjectMethods::iterator it = m_methods.find( name );
if (it == m_methods.end())
return false;
wxShadowObjectMethod method = it->second;
int ret = (*method)(window, param);
if (returnValue)
*returnValue = ret;
return true;
}
void AddField( const wxString &name, void* initialValue = NULL )
{
wxShadowObjectFields::iterator it = m_fields.find( name );
if (it == m_fields.end())
m_fields[ name ] = initialValue;
else
it->second = initialValue;
}
void SetField( const wxString &name, void* value )
{
wxShadowObjectFields::iterator it = m_fields.find( name );
if (it == m_fields.end())
return;
it->second = value;
}
void* GetField( const wxString &name, void *defaultValue = NULL )
{
wxShadowObjectFields::iterator it = m_fields.find( name );
if (it == m_fields.end())
return defaultValue;
return it->second;
}
private:
wxShadowObjectMethods m_methods;
wxShadowObjectFields m_fields;
};
// ----------------------------------------------------------------------------
// what kind of client data do we have?
enum wxClientDataType
{
wxClientData_None, // we don't know yet because we don't have it at all
wxClientData_Object, // our client data is typed and we own it
wxClientData_Void // client data is untyped and we don't own it
};
class WXDLLIMPEXP_BASE wxClientData
{
public:
wxClientData() { }
virtual ~wxClientData() { }
};
class WXDLLIMPEXP_BASE wxStringClientData : public wxClientData
{
public:
wxStringClientData() : m_data() { }
wxStringClientData( const wxString &data ) : m_data(data) { }
void SetData( const wxString &data ) { m_data = data; }
const wxString& GetData() const { return m_data; }
private:
wxString m_data;
};
// This class is a mixin that provides storage and management of "client
// data." The client data stored can either be a pointer to a wxClientData
// object in which case it is managed by the container (i.e. it will delete
// the data when it's destroyed) or an untyped pointer which won't be deleted
// by the container - but not both of them
//
// NOTE: This functionality is currently duplicated in wxEvtHandler in order
// to avoid having more than one vtable in that class hierarchy.
class WXDLLIMPEXP_BASE wxClientDataContainer
{
public:
wxClientDataContainer();
virtual ~wxClientDataContainer();
void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
wxClientData *GetClientObject() const { return DoGetClientObject(); }
void SetClientData( void *data ) { DoSetClientData(data); }
void *GetClientData() const { return DoGetClientData(); }
protected:
// The user data: either an object which will be deleted by the container
// when it's deleted or some raw pointer which we do nothing with. Only
// one type of data can be used with the given window, i.e. you cannot set
// the void data and then associate the container with wxClientData or vice
// versa.
union
{
wxClientData *m_clientObject;
void *m_clientData;
};
// client data accessors
virtual void DoSetClientObject( wxClientData *data );
virtual wxClientData *DoGetClientObject() const;
virtual void DoSetClientData( void *data );
virtual void *DoGetClientData() const;
// what kind of data do we have?
wxClientDataType m_clientDataType;
};
#include "wx/vector.h"
struct WXDLLIMPEXP_BASE wxClientDataDictionaryPair
{
wxClientDataDictionaryPair( size_t idx ) : index( idx ), data( 0 ) { }
size_t index;
wxClientData* data;
};
_WX_DECLARE_VECTOR(
wxClientDataDictionaryPair,
wxClientDataDictionaryPairVector,
WXDLLIMPEXP_BASE
);
// this class is used internally to maintain the association between items
// of (some subclasses of) wxControlWithItems and their client data
// NOTE: this class does not keep track of whether it contains
// wxClientData or void*. The client must ensure that
// it does not contain a mix of the two, and that
// DestroyData is called if it contains wxClientData
class WXDLLIMPEXP_BASE wxClientDataDictionary
{
public:
wxClientDataDictionary() {}
// deletes all the data
void DestroyData()
{
for( size_t i = 0, end = m_vec.size(); i != end; ++i )
delete m_vec[i].data;
m_vec.clear();
}
// if data for the given index is not present, add it,
// if it is present, delete the old data and replace it with
// the new one
void Set( size_t index, wxClientData* data, bool doDelete )
{
size_t ptr = Find( index );
if( !data )
{
if( ptr == m_vec.size() ) return;
if( doDelete )
delete m_vec[ptr].data;
m_vec.erase( ptr );
}
else
{
if( ptr == m_vec.size() )
{
m_vec.push_back( wxClientDataDictionaryPair( index ) );
ptr = m_vec.size() - 1;
}
if( doDelete )
delete m_vec[ptr].data;
m_vec[ptr].data = data;
}
}
// get the data associated with the given index,
// return 0 if not found
wxClientData* Get( size_t index ) const
{
size_t it = Find( index );
if( it == m_vec.size() ) return 0;
return (wxClientData*)m_vec[it].data; // const cast
}
// delete the data associated with the given index
// it also decreases by one the indices of all the elements
// with an index greater than the given index
void Delete( size_t index, bool doDelete )
{
size_t todel = m_vec.size();
for( size_t i = 0, end = m_vec.size(); i != end; ++i )
{
if( m_vec[i].index == index )
todel = i;
else if( m_vec[i].index > index )
--(m_vec[i].index);
}
if( todel != m_vec.size() )
{
if( doDelete )
delete m_vec[todel].data;
m_vec.erase( todel );
}
}
private:
// returns MyVec.size() if not found
size_t Find( size_t index ) const
{
for( size_t i = 0, end = m_vec.size(); i != end; ++i )
{
if( m_vec[i].index == index )
return i;
}
return m_vec.size();
}
wxClientDataDictionaryPairVector m_vec;
};
#endif // _WX_CLNTDATAH__

View File

@ -0,0 +1,200 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clrpicker.h
// Purpose: wxColourPickerCtrl base header
// Author: Francesco Montorsi (based on Vadim Zeitlin's code)
// Modified by:
// Created: 14/4/2006
// Copyright: (c) Vadim Zeitlin, Francesco Montorsi
// RCS-ID: $Id: clrpicker.h 53135 2008-04-12 02:31:04Z VZ $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLRPICKER_H_BASE_
#define _WX_CLRPICKER_H_BASE_
#include "wx/defs.h"
#if wxUSE_COLOURPICKERCTRL
#include "wx/pickerbase.h"
class WXDLLIMPEXP_FWD_CORE wxColourPickerEvent;
extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerWidgetNameStr[];
extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerCtrlNameStr[];
// ----------------------------------------------------------------------------
// wxColourPickerWidgetBase: a generic abstract interface which must be
// implemented by controls used by wxColourPickerCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxColourPickerWidgetBase
{
public:
wxColourPickerWidgetBase() { m_colour = *wxBLACK; }
virtual ~wxColourPickerWidgetBase() {}
wxColour GetColour() const
{ return m_colour; }
virtual void SetColour(const wxColour &col)
{ m_colour = col; UpdateColour(); }
virtual void SetColour(const wxString &col)
{ m_colour.Set(col); UpdateColour(); }
protected:
virtual void UpdateColour() = 0;
// the current colour (may be invalid if none)
wxColour m_colour;
};
// Styles which must be supported by all controls implementing wxColourPickerWidgetBase
// NB: these styles must be defined to carefully-chosen values to
// avoid conflicts with wxButton's styles
// show the colour in HTML form (#AABBCC) as colour button label
// (instead of no label at all)
// NOTE: this style is supported just by wxColourButtonGeneric and
// thus is not exposed in wxColourPickerCtrl
#define wxCLRP_SHOW_LABEL 0x0008
// map platform-dependent controls which implement the wxColourPickerWidgetBase
// under the name "wxColourPickerWidget".
// NOTE: wxColourPickerCtrl allocates a wxColourPickerWidget and relies on the
// fact that all classes being mapped as wxColourPickerWidget have the
// same prototype for their contructor (and also explains why we use
// define instead of a typedef)
// since GTK > 2.4, there is GtkColorButton
#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/clrpicker.h"
#define wxColourPickerWidget wxColourButton
#else
#include "wx/generic/clrpickerg.h"
#define wxColourPickerWidget wxGenericColourButton
#endif
// ----------------------------------------------------------------------------
// wxColourPickerCtrl: platform-independent class which embeds a
// platform-dependent wxColourPickerWidget and, if wxCLRP_USE_TEXTCTRL style is
// used, a textctrl next to it.
// ----------------------------------------------------------------------------
#define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
#define wxCLRP_DEFAULT_STYLE 0
class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase
{
public:
wxColourPickerCtrl() : m_bIgnoreNextTextCtrlUpdate(false) {}
virtual ~wxColourPickerCtrl() {}
wxColourPickerCtrl(wxWindow *parent, wxWindowID id,
const wxColour& col = *wxBLACK, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxColourPickerCtrlNameStr)
: m_bIgnoreNextTextCtrlUpdate(false)
{ Create(parent, id, col, pos, size, style, validator, name); }
bool Create(wxWindow *parent, wxWindowID id,
const wxColour& col = *wxBLACK,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxColourPickerCtrlNameStr);
public: // public API
// get the colour chosen
wxColour GetColour() const
{ return ((wxColourPickerWidget *)m_picker)->GetColour(); }
// set currently displayed color
void SetColour(const wxColour& col);
// set colour using RGB(r,g,b) syntax or considering given text as a colour name;
// returns true if the given text was successfully recognized.
bool SetColour(const wxString& text);
public: // internal functions
// update the button colour to match the text control contents
void UpdatePickerFromTextCtrl();
// update the text control to match the button's colour
void UpdateTextCtrlFromPicker();
// event handler for our picker
void OnColourChange(wxColourPickerEvent &);
protected:
virtual long GetPickerStyle(long style) const
{ return (style & wxCLRP_SHOW_LABEL); }
// true if the next UpdateTextCtrl() call is to ignore
bool m_bIgnoreNextTextCtrlUpdate;
private:
DECLARE_DYNAMIC_CLASS(wxColourPickerCtrl)
};
// ----------------------------------------------------------------------------
// wxColourPickerEvent: used by wxColourPickerCtrl only
// ----------------------------------------------------------------------------
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COLOURPICKER_CHANGED, 1102)
END_DECLARE_EVENT_TYPES()
class WXDLLIMPEXP_CORE wxColourPickerEvent : public wxCommandEvent
{
public:
wxColourPickerEvent() {}
wxColourPickerEvent(wxObject *generator, int id, const wxColour &col)
: wxCommandEvent(wxEVT_COMMAND_COLOURPICKER_CHANGED, id),
m_colour(col)
{
SetEventObject(generator);
}
wxColour GetColour() const { return m_colour; }
void SetColour(const wxColour &c) { m_colour = c; }
// default copy ctor, assignment operator and dtor are ok
virtual wxEvent *Clone() const { return new wxColourPickerEvent(*this); }
private:
wxColour m_colour;
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxColourPickerEvent)
};
// ----------------------------------------------------------------------------
// event types and macros
// ----------------------------------------------------------------------------
typedef void (wxEvtHandler::*wxColourPickerEventFunction)(wxColourPickerEvent&);
#define wxColourPickerEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxColourPickerEventFunction, &func)
#define EVT_COLOURPICKER_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_COLOURPICKER_CHANGED, id, wxColourPickerEventHandler(fn))
#endif // wxUSE_COLOURPICKERCTRL
#endif // _WX_CLRPICKER_H_BASE_

View File

@ -0,0 +1,239 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cmdline.h
// Purpose: wxCmdLineParser and related classes for parsing the command
// line options
// Author: Vadim Zeitlin
// Modified by:
// Created: 04.01.00
// RCS-ID: $Id: cmdline.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMDLINE_H_
#define _WX_CMDLINE_H_
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/arrstr.h"
#if wxUSE_CMDLINE_PARSER
class WXDLLIMPEXP_FWD_BASE wxDateTime;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// by default, options are optional (sic) and each call to AddParam() allows
// one more parameter - this may be changed by giving non-default flags to it
enum
{
wxCMD_LINE_OPTION_MANDATORY = 0x01, // this option must be given
wxCMD_LINE_PARAM_OPTIONAL = 0x02, // the parameter may be omitted
wxCMD_LINE_PARAM_MULTIPLE = 0x04, // the parameter may be repeated
wxCMD_LINE_OPTION_HELP = 0x08, // this option is a help request
wxCMD_LINE_NEEDS_SEPARATOR = 0x10 // must have sep before the value
};
// an option value or parameter may be a string (the most common case), a
// number or a date
enum wxCmdLineParamType
{
wxCMD_LINE_VAL_STRING, // should be 0 (default)
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_VAL_DATE,
wxCMD_LINE_VAL_NONE
};
// for constructing the cmd line description using Init()
enum wxCmdLineEntryType
{
wxCMD_LINE_SWITCH,
wxCMD_LINE_OPTION,
wxCMD_LINE_PARAM,
wxCMD_LINE_NONE // to terminate the list
};
// ----------------------------------------------------------------------------
// wxCmdLineEntryDesc is a description of one command line
// switch/option/parameter
// ----------------------------------------------------------------------------
struct wxCmdLineEntryDesc
{
wxCmdLineEntryType kind;
const wxChar *shortName;
const wxChar *longName;
const wxChar *description;
wxCmdLineParamType type;
int flags;
};
// ----------------------------------------------------------------------------
// wxCmdLineParser is a class for parsing command line.
//
// It has the following features:
//
// 1. distinguishes options, switches and parameters; allows option grouping
// 2. allows both short and long options
// 3. automatically generates the usage message from the cmd line description
// 4. does type checks on the options values (number, date, ...)
//
// To use it you should:
//
// 1. construct it giving it the cmd line to parse and optionally its desc
// 2. construct the cmd line description using AddXXX() if not done in (1)
// 3. call Parse()
// 4. use GetXXX() to retrieve the parsed info
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
// ctors and initializers
// ----------------------
// default ctor or ctor giving the cmd line in either Unix or Win form
wxCmdLineParser() { Init(); }
wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); }
#if wxUSE_UNICODE
wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); }
#endif // wxUSE_UNICODE
wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); }
// the same as above, but also gives the cmd line description - otherwise,
// use AddXXX() later
wxCmdLineParser(const wxCmdLineEntryDesc *desc)
{ Init(); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, char **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
#if wxUSE_UNICODE
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
#endif // wxUSE_UNICODE
wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline)
{ Init(); SetCmdLine(cmdline); SetDesc(desc); }
// set cmd line to parse after using one of the ctors which don't do it
void SetCmdLine(int argc, char **argv);
#if wxUSE_UNICODE
void SetCmdLine(int argc, wxChar **argv);
#endif // wxUSE_UNICODE
void SetCmdLine(const wxString& cmdline);
// not virtual, don't use this class polymorphically
~wxCmdLineParser();
// set different parser options
// ----------------------------
// by default, '-' is switch char under Unix, '-' or '/' under Win:
// switchChars contains all characters with which an option or switch may
// start
void SetSwitchChars(const wxString& switchChars);
// long options are not POSIX-compliant, this option allows to disable them
void EnableLongOptions(bool enable = true);
void DisableLongOptions() { EnableLongOptions(false); }
bool AreLongOptionsEnabled();
// extra text may be shown by Usage() method if set by this function
void SetLogo(const wxString& logo);
// construct the cmd line description
// ----------------------------------
// take the cmd line description from the wxCMD_LINE_NONE terminated table
void SetDesc(const wxCmdLineEntryDesc *desc);
// a switch: i.e. an option without value
void AddSwitch(const wxString& name, const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString,
int flags = 0);
// an option taking a value of the given type
void AddOption(const wxString& name, const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
// a parameter
void AddParam(const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
// actions
// -------
// parse the command line, return 0 if ok, -1 if "-h" or "--help" option
// was encountered and the help message was given or a positive value if a
// syntax error occurred
//
// if showUsage is true, Usage() is called in case of syntax error or if
// help was requested
int Parse(bool showUsage = true);
// give the usage message describing all program options
void Usage();
// get the command line arguments
// ------------------------------
// returns true if the given switch was found
bool Found(const wxString& name) const;
// returns true if an option taking a string value was found and stores the
// value in the provided pointer
bool Found(const wxString& name, wxString *value) const;
// returns true if an option taking an integer value was found and stores
// the value in the provided pointer
bool Found(const wxString& name, long *value) const;
#if wxUSE_DATETIME
// returns true if an option taking a date value was found and stores the
// value in the provided pointer
bool Found(const wxString& name, wxDateTime *value) const;
#endif // wxUSE_DATETIME
// gets the number of parameters found
size_t GetParamCount() const;
// gets the value of Nth parameter (as string only for now)
wxString GetParam(size_t n = 0u) const;
// Resets switches and options
void Reset();
// break down the command line in arguments
static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
private:
// get usage string
wxString GetUsageString();
// common part of all ctors
void Init();
struct wxCmdLineParserData *m_data;
DECLARE_NO_COPY_CLASS(wxCmdLineParser)
};
#else // !wxUSE_CMDLINE_PARSER
// this function is always available (even if !wxUSE_CMDLINE_PARSER) because it
// is used by wxWin itself under Windows
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
};
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
#endif // _WX_CMDLINE_H_

View File

@ -0,0 +1,144 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cmdproc.h
// Purpose: undo/redo capable command processing framework
// Author: Julian Smart (extracted from docview.h by VZ)
// Modified by:
// Created: 05.11.00
// RCS-ID: $Id: cmdproc.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMDPROC_H_
#define _WX_CMDPROC_H_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/list.h"
class WXDLLIMPEXP_FWD_CORE wxMenu;
// ----------------------------------------------------------------------------
// wxCommand: a single command capable of performing itself
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCommand : public wxObject
{
public:
wxCommand(bool canUndoIt = false, const wxString& name = wxEmptyString);
virtual ~wxCommand(){}
// Override this to perform a command
virtual bool Do() = 0;
// Override this to undo a command
virtual bool Undo() = 0;
virtual bool CanUndo() const { return m_canUndo; }
virtual wxString GetName() const { return m_commandName; }
protected:
bool m_canUndo;
wxString m_commandName;
private:
DECLARE_CLASS(wxCommand)
};
// ----------------------------------------------------------------------------
// wxCommandProcessor: wxCommand manager
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCommandProcessor : public wxObject
{
public:
// if max number of commands is -1, it is unlimited
wxCommandProcessor(int maxCommands = -1);
virtual ~wxCommandProcessor();
// Pass a command to the processor. The processor calls Do(); if
// successful, is appended to the command history unless storeIt is false.
virtual bool Submit(wxCommand *command, bool storeIt = true);
// just store the command without executing it
virtual void Store(wxCommand *command);
virtual bool Undo();
virtual bool Redo();
virtual bool CanUndo() const;
virtual bool CanRedo() const;
// Initialises the current command and menu strings.
virtual void Initialize();
// Sets the Undo/Redo menu strings for the current menu.
virtual void SetMenuStrings();
// Gets the current Undo menu label.
wxString GetUndoMenuLabel() const;
// Gets the current Undo menu label.
wxString GetRedoMenuLabel() const;
#if wxUSE_MENUS
// Call this to manage an edit menu.
void SetEditMenu(wxMenu *menu) { m_commandEditMenu = menu; }
wxMenu *GetEditMenu() const { return m_commandEditMenu; }
#endif // wxUSE_MENUS
// command list access
wxList& GetCommands() { return m_commands; }
const wxList& GetCommands() const { return m_commands; }
wxCommand *GetCurrentCommand() const
{
return (wxCommand *)(m_currentCommand ? m_currentCommand->GetData() : NULL);
}
int GetMaxCommands() const { return m_maxNoCommands; }
virtual void ClearCommands();
// Has the current project been changed?
virtual bool IsDirty() const
{
return m_currentCommand && (m_lastSavedCommand != m_currentCommand);
}
// Mark the current command as the one where the last save took place
void MarkAsSaved()
{
m_lastSavedCommand = m_currentCommand;
}
// By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
const wxString& GetUndoAccelerator() const { return m_undoAccelerator; }
const wxString& GetRedoAccelerator() const { return m_redoAccelerator; }
void SetUndoAccelerator(const wxString& accel) { m_undoAccelerator = accel; }
void SetRedoAccelerator(const wxString& accel) { m_redoAccelerator = accel; }
protected:
// for further flexibility, command processor doesn't call wxCommand::Do()
// and Undo() directly but uses these functions which can be overridden in
// the derived class
virtual bool DoCommand(wxCommand& cmd);
virtual bool UndoCommand(wxCommand& cmd);
int m_maxNoCommands;
wxList m_commands;
wxList::compatibility_iterator m_currentCommand,
m_lastSavedCommand;
#if wxUSE_MENUS
wxMenu* m_commandEditMenu;
#endif // wxUSE_MENUS
wxString m_undoAccelerator;
wxString m_redoAccelerator;
private:
DECLARE_DYNAMIC_CLASS(wxCommandProcessor)
DECLARE_NO_COPY_CLASS(wxCommandProcessor)
};
#endif // _WX_CMDPROC_H_

View File

@ -0,0 +1,454 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cmndata.h
// Purpose: Common GDI data classes
// Author: Julian Smart and others
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: cmndata.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMNDATA_H_BASE_
#define _WX_CMNDATA_H_BASE_
#include "wx/window.h"
#include "wx/font.h"
#include "wx/encinfo.h"
#include "wx/colour.h"
#include "wx/gdicmn.h"
#if wxUSE_STREAMS
#include "wx/stream.h"
#endif
class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
class WXDLLEXPORT wxColourData: public wxObject
{
public:
wxColourData();
wxColourData(const wxColourData& data);
virtual ~wxColourData();
void SetChooseFull(bool flag) { m_chooseFull = flag; }
bool GetChooseFull() const { return m_chooseFull; }
void SetColour(const wxColour& colour) { m_dataColour = colour; }
const wxColour& GetColour() const { return m_dataColour; }
wxColour& GetColour() { return m_dataColour; }
// Array of 16 custom colours
void SetCustomColour(int i, const wxColour& colour);
wxColour GetCustomColour(int i);
void operator=(const wxColourData& data);
public:
wxColour m_dataColour;
wxColour m_custColours[16];
bool m_chooseFull;
private:
DECLARE_DYNAMIC_CLASS(wxColourData)
};
class WXDLLEXPORT wxFontData : public wxObject
{
public:
wxFontData();
virtual ~wxFontData();
wxFontData(const wxFontData& data)
: wxObject(),
m_fontColour(data.m_fontColour),
m_showHelp(data.m_showHelp),
m_allowSymbols(data.m_allowSymbols),
m_enableEffects(data.m_enableEffects),
m_initialFont(data.m_initialFont),
m_chosenFont(data.m_chosenFont),
m_minSize(data.m_minSize),
m_maxSize(data.m_maxSize),
m_encoding(data.m_encoding),
m_encodingInfo(data.m_encodingInfo)
{
}
wxFontData& operator=(const wxFontData& data)
{
wxObject::operator=(data);
m_fontColour = data.m_fontColour;
m_showHelp = data.m_showHelp;
m_allowSymbols = data.m_allowSymbols;
m_enableEffects = data.m_enableEffects;
m_initialFont = data.m_initialFont;
m_chosenFont = data.m_chosenFont;
m_minSize = data.m_minSize;
m_maxSize = data.m_maxSize;
m_encoding = data.m_encoding;
m_encodingInfo = data.m_encodingInfo;
return *this;
}
void SetAllowSymbols(bool flag) { m_allowSymbols = flag; }
bool GetAllowSymbols() const { return m_allowSymbols; }
void SetColour(const wxColour& colour) { m_fontColour = colour; }
const wxColour& GetColour() const { return m_fontColour; }
void SetShowHelp(bool flag) { m_showHelp = flag; }
bool GetShowHelp() const { return m_showHelp; }
void EnableEffects(bool flag) { m_enableEffects = flag; }
bool GetEnableEffects() const { return m_enableEffects; }
void SetInitialFont(const wxFont& font) { m_initialFont = font; }
wxFont GetInitialFont() const { return m_initialFont; }
void SetChosenFont(const wxFont& font) { m_chosenFont = font; }
wxFont GetChosenFont() const { return m_chosenFont; }
void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; }
// encoding info is split into 2 parts: the logical wxWin encoding
// (wxFontEncoding) and a structure containing the native parameters for
// it (wxNativeEncodingInfo)
wxFontEncoding GetEncoding() const { return m_encoding; }
void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; }
wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; }
// public for backwards compatibility only: don't use directly
public:
wxColour m_fontColour;
bool m_showHelp;
bool m_allowSymbols;
bool m_enableEffects;
wxFont m_initialFont;
wxFont m_chosenFont;
int m_minSize;
int m_maxSize;
private:
wxFontEncoding m_encoding;
wxNativeEncodingInfo m_encodingInfo;
private:
DECLARE_DYNAMIC_CLASS(wxFontData)
};
#if wxUSE_PRINTING_ARCHITECTURE
/*
* wxPrintData
* Encapsulates printer information (not printer dialog information)
*/
enum wxPrintBin
{
wxPRINTBIN_DEFAULT,
wxPRINTBIN_ONLYONE,
wxPRINTBIN_LOWER,
wxPRINTBIN_MIDDLE,
wxPRINTBIN_MANUAL,
wxPRINTBIN_ENVELOPE,
wxPRINTBIN_ENVMANUAL,
wxPRINTBIN_AUTO,
wxPRINTBIN_TRACTOR,
wxPRINTBIN_SMALLFMT,
wxPRINTBIN_LARGEFMT,
wxPRINTBIN_LARGECAPACITY,
wxPRINTBIN_CASSETTE,
wxPRINTBIN_FORMSOURCE,
wxPRINTBIN_USER
};
const int wxPRINTMEDIA_DEFAULT = 0;
class WXDLLEXPORT wxPrintData: public wxObject
{
public:
wxPrintData();
wxPrintData(const wxPrintData& printData);
virtual ~wxPrintData();
int GetNoCopies() const { return m_printNoCopies; }
bool GetCollate() const { return m_printCollate; }
int GetOrientation() const { return m_printOrientation; }
bool IsOrientationReversed() const { return m_printOrientationReversed; }
// Is this data OK for showing the print dialog?
bool Ok() const { return IsOk(); }
bool IsOk() const ;
const wxString& GetPrinterName() const { return m_printerName; }
bool GetColour() const { return m_colour; }
wxDuplexMode GetDuplex() const { return m_duplexMode; }
wxPaperSize GetPaperId() const { return m_paperId; }
const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
// in wxPageSetupDialogData
wxPrintQuality GetQuality() const { return m_printQuality; }
wxPrintBin GetBin() const { return m_bin; }
wxPrintMode GetPrintMode() const { return m_printMode; }
int GetMedia() const { return m_media; }
void SetNoCopies(int v) { m_printNoCopies = v; }
void SetCollate(bool flag) { m_printCollate = flag; }
void SetOrientation(int orient) { m_printOrientation = orient; }
void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
void SetPrinterName(const wxString& name) { m_printerName = name; }
void SetColour(bool colour) { m_colour = colour; }
void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
void SetBin(wxPrintBin bin) { m_bin = bin; }
void SetMedia(int media) { m_media = media; }
void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
wxString GetFilename() const { return m_filename; }
void SetFilename( const wxString &filename ) { m_filename = filename; }
void operator=(const wxPrintData& data);
char* GetPrivData() const { return m_privData; }
int GetPrivDataLen() const { return m_privDataLen; }
void SetPrivData( char *privData, int len );
#if WXWIN_COMPATIBILITY_2_4
// PostScript-specific data
wxString GetPrinterCommand() const;
wxString GetPrinterOptions() const;
wxString GetPreviewCommand() const;
wxString GetFontMetricPath() const;
double GetPrinterScaleX() const;
double GetPrinterScaleY() const;
long GetPrinterTranslateX() const;
long GetPrinterTranslateY() const;
void SetPrinterCommand(const wxString& command);
void SetPrinterOptions(const wxString& options);
void SetPreviewCommand(const wxString& command);
void SetFontMetricPath(const wxString& path);
void SetPrinterScaleX(double x);
void SetPrinterScaleY(double y);
void SetPrinterScaling(double x, double y);
void SetPrinterTranslateX(long x);
void SetPrinterTranslateY(long y);
void SetPrinterTranslation(long x, long y);
#endif
// Convert between wxPrintData and native data
void ConvertToNative();
void ConvertFromNative();
// Holds the native print data
wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; }
private:
wxPrintBin m_bin;
int m_media;
wxPrintMode m_printMode;
int m_printNoCopies;
int m_printOrientation;
bool m_printOrientationReversed;
bool m_printCollate;
wxString m_printerName;
bool m_colour;
wxDuplexMode m_duplexMode;
wxPrintQuality m_printQuality;
wxPaperSize m_paperId;
wxSize m_paperSize;
wxString m_filename;
char* m_privData;
int m_privDataLen;
wxPrintNativeDataBase *m_nativeData;
private:
DECLARE_DYNAMIC_CLASS(wxPrintData)
};
/*
* wxPrintDialogData
* Encapsulates information displayed and edited in the printer dialog box.
* Contains a wxPrintData object which is filled in according to the values retrieved
* from the dialog.
*/
class WXDLLEXPORT wxPrintDialogData: public wxObject
{
public:
wxPrintDialogData();
wxPrintDialogData(const wxPrintDialogData& dialogData);
wxPrintDialogData(const wxPrintData& printData);
virtual ~wxPrintDialogData();
int GetFromPage() const { return m_printFromPage; }
int GetToPage() const { return m_printToPage; }
int GetMinPage() const { return m_printMinPage; }
int GetMaxPage() const { return m_printMaxPage; }
int GetNoCopies() const { return m_printNoCopies; }
bool GetAllPages() const { return m_printAllPages; }
bool GetSelection() const { return m_printSelection; }
bool GetCollate() const { return m_printCollate; }
bool GetPrintToFile() const { return m_printToFile; }
#if WXWIN_COMPATIBILITY_2_4
bool GetSetupDialog() const { return m_printSetupDialog; }
#endif
void SetFromPage(int v) { m_printFromPage = v; }
void SetToPage(int v) { m_printToPage = v; }
void SetMinPage(int v) { m_printMinPage = v; }
void SetMaxPage(int v) { m_printMaxPage = v; }
void SetNoCopies(int v) { m_printNoCopies = v; }
void SetAllPages(bool flag) { m_printAllPages = flag; }
void SetSelection(bool flag) { m_printSelection = flag; }
void SetCollate(bool flag) { m_printCollate = flag; }
void SetPrintToFile(bool flag) { m_printToFile = flag; }
#if WXWIN_COMPATIBILITY_2_4
void SetSetupDialog(bool flag) { m_printSetupDialog = flag; }
#endif
void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }
void EnableSelection(bool flag) { m_printEnableSelection = flag; }
void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }
void EnableHelp(bool flag) { m_printEnableHelp = flag; }
bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }
bool GetEnableSelection() const { return m_printEnableSelection; }
bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }
bool GetEnableHelp() const { return m_printEnableHelp; }
// Is this data OK for showing the print dialog?
bool Ok() const { return IsOk(); }
bool IsOk() const { return m_printData.Ok() ; }
wxPrintData& GetPrintData() { return m_printData; }
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
void operator=(const wxPrintDialogData& data);
void operator=(const wxPrintData& data); // Sets internal m_printData member
private:
int m_printFromPage;
int m_printToPage;
int m_printMinPage;
int m_printMaxPage;
int m_printNoCopies;
bool m_printAllPages;
bool m_printCollate;
bool m_printToFile;
bool m_printSelection;
bool m_printEnableSelection;
bool m_printEnablePageNumbers;
bool m_printEnableHelp;
bool m_printEnablePrintToFile;
#if WXWIN_COMPATIBILITY_2_4
bool m_printSetupDialog;
#endif
wxPrintData m_printData;
private:
DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
};
/*
* This is the data used (and returned) by the wxPageSetupDialog.
*/
// Compatibility with old name
#define wxPageSetupData wxPageSetupDialogData
class WXDLLEXPORT wxPageSetupDialogData: public wxObject
{
public:
wxPageSetupDialogData();
wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
wxPageSetupDialogData(const wxPrintData& printData);
virtual ~wxPageSetupDialogData();
wxSize GetPaperSize() const { return m_paperSize; }
wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }
wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }
wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }
wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }
wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }
bool GetDefaultMinMargins() const { return m_defaultMinMargins; }
bool GetEnableMargins() const { return m_enableMargins; }
bool GetEnableOrientation() const { return m_enableOrientation; }
bool GetEnablePaper() const { return m_enablePaper; }
bool GetEnablePrinter() const { return m_enablePrinter; }
bool GetDefaultInfo() const { return m_getDefaultInfo; }
bool GetEnableHelp() const { return m_enableHelp; }
// Is this data OK for showing the page setup dialog?
bool Ok() const { return IsOk(); }
bool IsOk() const { return m_printData.Ok() ; }
// If a corresponding paper type is found in the paper database, will set the m_printData
// paper size id member as well.
void SetPaperSize(const wxSize& sz);
void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }
// Sets the wxPrintData id, plus the paper width/height if found in the paper database.
void SetPaperSize(wxPaperSize id);
void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }
void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }
void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }
void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }
void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }
void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }
void EnableMargins(bool flag) { m_enableMargins = flag; }
void EnableOrientation(bool flag) { m_enableOrientation = flag; }
void EnablePaper(bool flag) { m_enablePaper = flag; }
void EnablePrinter(bool flag) { m_enablePrinter = flag; }
void EnableHelp(bool flag) { m_enableHelp = flag; }
// Use paper size defined in this object to set the wxPrintData
// paper id
void CalculateIdFromPaperSize();
// Use paper id in wxPrintData to set this object's paper size
void CalculatePaperSizeFromId();
wxPageSetupDialogData& operator=(const wxPageSetupData& data);
wxPageSetupDialogData& operator=(const wxPrintData& data);
wxPrintData& GetPrintData() { return m_printData; }
const wxPrintData& GetPrintData() const { return m_printData; }
void SetPrintData(const wxPrintData& printData);
private:
wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
wxPoint m_minMarginTopLeft;
wxPoint m_minMarginBottomRight;
wxPoint m_marginTopLeft;
wxPoint m_marginBottomRight;
bool m_defaultMinMargins;
bool m_enableMargins;
bool m_enableOrientation;
bool m_enablePaper;
bool m_enablePrinter;
bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
bool m_enableHelp;
wxPrintData m_printData;
private:
DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
};
#endif // wxUSE_PRINTING_ARCHITECTURE
#endif
// _WX_CMNDATA_H_BASE_

View File

@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/collpane.h
// Purpose: wxCollapsiblePane
// Author: Francesco Montorsi
// Modified by:
// Created: 8/10/2006
// RCS-ID: $Id: collpane.h 43300 2006-11-11 07:32:08Z RD $
// Copyright: (c) Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLLAPSABLE_PANE_H_BASE_
#define _WX_COLLAPSABLE_PANE_H_BASE_
#include "wx/defs.h"
#if wxUSE_COLLPANE
#include "wx/control.h"
// ----------------------------------------------------------------------------
// wxCollapsiblePaneBase: interface for wxCollapsiblePane
// ----------------------------------------------------------------------------
#define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
#define wxCP_NO_TLW_RESIZE (0x0002)
class WXDLLIMPEXP_CORE wxCollapsiblePaneBase : public wxControl
{
public:
wxCollapsiblePaneBase() {}
virtual void Collapse(bool collapse = true) = 0;
void Expand() { Collapse(false); }
virtual bool IsCollapsed() const = 0;
bool IsExpanded() const { return !IsCollapsed(); }
virtual wxWindow *GetPane() const = 0;
virtual wxString GetLabel() const = 0;
virtual void SetLabel(const wxString& label) = 0;
};
// ----------------------------------------------------------------------------
// event types and macros
// ----------------------------------------------------------------------------
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COLLPANE_CHANGED, 1102)
END_DECLARE_EVENT_TYPES()
class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent
{
public:
wxCollapsiblePaneEvent() {}
wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed)
: wxCommandEvent(wxEVT_COMMAND_COLLPANE_CHANGED, id),
m_bCollapsed(collapsed)
{
SetEventObject(generator);
}
bool GetCollapsed() const { return m_bCollapsed; }
void SetCollapsed(bool c) { m_bCollapsed = c; }
// default copy ctor, assignment operator and dtor are ok
virtual wxEvent *Clone() const { return new wxCollapsiblePaneEvent(*this); }
private:
bool m_bCollapsed;
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCollapsiblePaneEvent)
};
// ----------------------------------------------------------------------------
// event types and macros
// ----------------------------------------------------------------------------
typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&);
#define wxCollapsiblePaneEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCollapsiblePaneEventFunction, &func)
#define EVT_COLLAPSIBLEPANE_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_COLLPANE_CHANGED, id, wxCollapsiblePaneEventHandler(fn))
#if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/collpane.h"
#else
#include "wx/generic/collpaneg.h"
// use #define and not a typedef to allow forward declaring the class
#define wxCollapsiblePane wxGenericCollapsiblePane
#endif
#endif // wxUSE_COLLPANE
#endif // _WX_COLLAPSABLE_PANE_H_BASE_

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/colrdlgg.h
// Purpose: wxColourDialog
// Author: Vadim Zeitiln
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: colordlg.h 36623 2006-01-02 14:26:36Z JS $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLORDLG_H_BASE_
#define _WX_COLORDLG_H_BASE_
#include "wx/defs.h"
#if wxUSE_COLOURDLG
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/colordlg.h"
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
#include "wx/mac/colordlg.h"
#elif defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/colordlg.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/colordlg.h"
#else
#include "wx/generic/colrdlgg.h"
#define wxColourDialog wxGenericColourDialog
#endif
// get the colour from user and return it
wxColour WXDLLEXPORT
wxGetColourFromUser(wxWindow *parent = (wxWindow *)NULL,
const wxColour& colInit = wxNullColour, const wxString& caption = wxEmptyString);
#endif // wxUSE_COLOURDLG
#endif
// _WX_COLORDLG_H_BASE_

View File

@ -0,0 +1,154 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/colour.h
// Purpose: wxColourBase definition
// Author: Julian Smart
// Modified by: Francesco Montorsi
// Created:
// RCS-ID: $Id: colour.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOUR_H_BASE_
#define _WX_COLOUR_H_BASE_
#include "wx/defs.h"
#include "wx/gdiobj.h"
class WXDLLIMPEXP_FWD_CORE wxColour;
// the standard wxColour constructors;
// this macro avoids to repeat these lines across all colour.h files, since
// Set() is a virtual function and thus cannot be called by wxColourBase
// constructors
#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
wxColour( ChannelType red, ChannelType green, ChannelType blue, \
ChannelType alpha = wxALPHA_OPAQUE ) \
{ Set(red, green, blue, alpha); } \
wxColour( unsigned long colRGB ) { Set(colRGB); } \
wxColour(const wxString &colourName) { Set(colourName); } \
wxColour(const wxChar *colourName) { Set(colourName); }
// flags for wxColour -> wxString conversion (see wxColour::GetAsString)
#define wxC2S_NAME 1 // return colour name, when possible
#define wxC2S_CSS_SYNTAX 2 // return colour in rgb(r,g,b) syntax
#define wxC2S_HTML_SYNTAX 4 // return colour in #rrggbb syntax
const unsigned char wxALPHA_TRANSPARENT = 0;
const unsigned char wxALPHA_OPAQUE = 0xff;
// ----------------------------------------------------------------------------
// wxVariant support
// ----------------------------------------------------------------------------
#if wxUSE_VARIANT
#include "wx/variant.h"
DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLEXPORT)
#endif
//-----------------------------------------------------------------------------
// wxColourBase: this class has no data members, just some functions to avoid
// code redundancy in all native wxColour implementations
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxColourBase : public wxGDIObject
{
public:
// type of a single colour component
typedef unsigned char ChannelType;
wxColourBase() {}
virtual ~wxColourBase() {}
// Set() functions
// ---------------
void Set(ChannelType red,
ChannelType green,
ChannelType blue,
ChannelType alpha = wxALPHA_OPAQUE)
{ InitRGBA(red,green,blue, alpha); }
// implemented in colourcmn.cpp
bool Set(const wxChar *str)
{ return FromString(str); }
bool Set(const wxString &str)
{ return FromString(str); }
void Set(unsigned long colRGB)
{
// we don't need to know sizeof(long) here because we assume that the three
// least significant bytes contain the R, G and B values
Set((ChannelType)(0xFF & colRGB),
(ChannelType)(0xFF & (colRGB >> 8)),
(ChannelType)(0xFF & (colRGB >> 16)));
}
// accessors
// ---------
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const = 0;
virtual ChannelType Red() const = 0;
virtual ChannelType Green() const = 0;
virtual ChannelType Blue() const = 0;
virtual ChannelType Alpha() const
{ return wxALPHA_OPAQUE ; }
// implemented in colourcmn.cpp
virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
// old, deprecated
// ---------------
#if WXWIN_COMPATIBILITY_2_6
wxDEPRECATED( static wxColour CreateByName(const wxString& name) );
wxDEPRECATED( void InitFromName(const wxString& col) );
#endif
protected:
virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
virtual bool FromString(const wxChar *s);
};
#if defined(__WXPALMOS__)
#include "wx/generic/colour.h"
#elif defined(__WXMSW__)
#include "wx/msw/colour.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/colour.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/colour.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/colour.h"
#elif defined(__WXMGL__)
#include "wx/generic/colour.h"
#elif defined(__WXDFB__)
#include "wx/generic/colour.h"
#elif defined(__WXX11__)
#include "wx/x11/colour.h"
#elif defined(__WXMAC__)
#include "wx/mac/colour.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/colour.h"
#elif defined(__WXPM__)
#include "wx/os2/colour.h"
#endif
#define wxColor wxColour
#endif // _WX_COLOUR_H_BASE_

View File

@ -0,0 +1,746 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/combo.h
// Purpose: wxComboCtrl declaration
// Author: Jaakko Salli
// Modified by:
// Created: Apr-30-2006
// RCS-ID: $Id: combo.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) Jaakko Salli
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOCONTROL_H_BASE_
#define _WX_COMBOCONTROL_H_BASE_
/*
A few words about all the classes defined in this file are probably in
order: why do we need extra wxComboCtrl and wxComboPopup classes?
This is because a traditional combobox is a combination of a text control
(with a button allowing to open the pop down list) with a listbox and
wxComboBox class is exactly such control, however we want to also have other
combinations - in fact, we want to allow anything at all to be used as pop
down list, not just a wxListBox.
So we define a base wxComboCtrl which can use any control as pop down
list and wxComboBox deriving from it which implements the standard wxWidgets
combobox API. wxComboCtrl needs to be told somehow which control to use
and this is done by SetPopupControl(). However, we need something more than
just a wxControl in this method as, for example, we need to call
SetSelection("initial text value") and wxControl doesn't have such method.
So we also need a wxComboPopup which is just a very simple interface which
must be implemented by a control to be usable as a popup.
We couldn't derive wxComboPopup from wxControl as this would make it
impossible to have a class deriving from both wxListBx and from it, so
instead it is just a mix-in.
*/
#include "wx/defs.h"
#if wxUSE_COMBOCTRL
#include "wx/control.h"
#include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags
#include "wx/bitmap.h" // wxBitmap used by-value
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxComboPopup;
//
// New window styles for wxComboCtrlBase
//
enum
{
// Double-clicking a read-only combo triggers call to popup's OnComboPopup.
// In wxOwnerDrawnComboBox, for instance, it cycles item.
wxCC_SPECIAL_DCLICK = 0x0100,
// Dropbutton acts like standard push button.
wxCC_STD_BUTTON = 0x0200
};
// wxComboCtrl internal flags
enum
{
// First those that can be passed to Customize.
// It is Windows style for all flags to be clear.
// Button is preferred outside the border (GTK style)
wxCC_BUTTON_OUTSIDE_BORDER = 0x0001,
// Show popup on mouse up instead of mouse down (which is the Windows style)
wxCC_POPUP_ON_MOUSE_UP = 0x0002,
// All text is not automatically selected on click
wxCC_NO_TEXT_AUTO_SELECT = 0x0004,
// Internal use: signals creation is complete
wxCC_IFLAG_CREATED = 0x0100,
// Internal use: really put button outside
wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200,
// Internal use: SetTextIndent has been called
wxCC_IFLAG_INDENT_SET = 0x0400,
// Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed
wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800,
// Internal use: Secondary popup window type should be used (if available).
wxCC_IFLAG_USE_ALT_POPUP = 0x1000,
// Internal use: Skip popup animation.
wxCC_IFLAG_DISABLE_POPUP_ANIM = 0x2000
};
// Flags used by PreprocessMouseEvent and HandleButtonMouseEvent
enum
{
wxCC_MF_ON_BUTTON = 0x0001, // cursor is on dropbutton area
wxCC_MF_ON_CLICK_AREA = 0x0002 // cursor is on dropbutton or other area
// that can be clicked to show the popup.
};
// Namespace for wxComboCtrl feature flags
struct wxComboCtrlFeatures
{
enum
{
MovableButton = 0x0001, // Button can be on either side of control
BitmapButton = 0x0002, // Button may be replaced with bitmap
ButtonSpacing = 0x0004, // Button can have spacing from the edge
// of the control
TextIndent = 0x0008, // SetTextIndent can be used
PaintControl = 0x0010, // Combo control itself can be custom painted
PaintWritable = 0x0020, // A variable-width area in front of writable
// combo control's textctrl can be custom
// painted
Borderless = 0x0040, // wxNO_BORDER window style works
// There are no feature flags for...
// PushButtonBitmapBackground - if its in wxRendererNative, then it should be
// not an issue to have it automatically under the bitmap.
All = MovableButton|BitmapButton|
ButtonSpacing|TextIndent|
PaintControl|PaintWritable|
Borderless
};
};
class WXDLLEXPORT wxComboCtrlBase : public wxControl
{
friend class wxComboPopup;
public:
// ctors and such
wxComboCtrlBase() : wxControl() { Init(); }
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
virtual ~wxComboCtrlBase();
// show/hide popup window
virtual void ShowPopup();
virtual void HidePopup();
// Override for totally custom combo action
virtual void OnButtonClick();
// return true if the popup is currently shown
bool IsPopupShown() const { return m_popupWinState == Visible; }
// set interface class instance derived from wxComboPopup
// NULL popup can be used to indicate default in a derived class
void SetPopupControl( wxComboPopup* popup )
{
DoSetPopupControl(popup);
}
// get interface class instance derived from wxComboPopup
wxComboPopup* GetPopupControl()
{
EnsurePopupControl();
return m_popupInterface;
}
// get the popup window containing the popup control
wxWindow *GetPopupWindow() const { return m_winPopup; }
// Get the text control which is part of the combobox.
wxTextCtrl *GetTextCtrl() const { return m_text; }
// get the dropdown button which is part of the combobox
// note: its not necessarily a wxButton or wxBitmapButton
wxWindow *GetButton() const { return m_btn; }
// forward these methods to all subcontrols
virtual bool Enable(bool enable = true);
virtual bool Show(bool show = true);
virtual bool SetFont(const wxFont& font);
#if wxUSE_VALIDATORS
virtual void SetValidator(const wxValidator &validator);
virtual wxValidator *GetValidator();
#endif // wxUSE_VALIDATORS
// wxTextCtrl methods - for readonly combo they should return
// without errors.
virtual wxString GetValue() const;
virtual void SetValue(const wxString& value);
virtual void Copy();
virtual void Cut();
virtual void Paste();
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const;
virtual long GetLastPosition() const;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to);
virtual void Undo();
// This method sets the text without affecting list selection
// (ie. wxComboPopup::SetStringValue doesn't get called).
void SetText(const wxString& value);
// This method sets value and also optionally sends EVT_TEXT
// (needed by combo popups)
void SetValueWithEvent(const wxString& value, bool withEvent = true);
//
// Popup customization methods
//
// Sets minimum width of the popup. If wider than combo control, it will extend to the left.
// Remarks:
// * Value -1 indicates the default.
// * Custom popup may choose to ignore this (wxOwnerDrawnComboBox does not).
void SetPopupMinWidth( int width )
{
m_widthMinPopup = width;
}
// Sets preferred maximum height of the popup.
// Remarks:
// * Value -1 indicates the default.
// * Custom popup may choose to ignore this (wxOwnerDrawnComboBox does not).
void SetPopupMaxHeight( int height )
{
m_heightPopup = height;
}
// Extends popup size horizontally, relative to the edges of the combo control.
// Remarks:
// * Popup minimum width may override extLeft (ie. it has higher precedence).
// * Values 0 indicate default.
// * Custom popup may not take this fully into account (wxOwnerDrawnComboBox takes).
void SetPopupExtents( int extLeft, int extRight )
{
m_extLeft = extLeft;
m_extRight = extRight;
}
// Set width, in pixels, of custom paint area in writable combo.
// In read-only, used to indicate area that is not covered by the
// focus rectangle (which may or may not be drawn, depending on the
// popup type).
void SetCustomPaintWidth( int width );
int GetCustomPaintWidth() const { return m_widthCustomPaint; }
// Set side of the control to which the popup will align itself.
// Valid values are wxLEFT, wxRIGHT and 0. The default value 0 wmeans
// that the side of the button will be used.
void SetPopupAnchor( int anchorSide )
{
m_anchorSide = anchorSide;
}
// Set position of dropdown button.
// width: button width. <= 0 for default.
// height: button height. <= 0 for default.
// side: wxLEFT or wxRIGHT, indicates on which side the button will be placed.
// spacingX: empty space on sides of the button. Default is 0.
// Remarks:
// There is no spacingY - the button will be centered vertically.
void SetButtonPosition( int width = -1,
int height = -1,
int side = wxRIGHT,
int spacingX = 0 );
// Returns current size of the dropdown button.
wxSize GetButtonSize();
//
// Sets dropbutton to be drawn with custom bitmaps.
//
// bmpNormal: drawn when cursor is not on button
// pushButtonBg: Draw push button background below the image.
// NOTE! This is usually only properly supported on platforms with appropriate
// method in wxRendererNative.
// bmpPressed: drawn when button is depressed
// bmpHover: drawn when cursor hovers on button. This is ignored on platforms
// that do not generally display hover differently.
// bmpDisabled: drawn when combobox is disabled.
void SetButtonBitmaps( const wxBitmap& bmpNormal,
bool pushButtonBg = false,
const wxBitmap& bmpPressed = wxNullBitmap,
const wxBitmap& bmpHover = wxNullBitmap,
const wxBitmap& bmpDisabled = wxNullBitmap );
//
// This will set the space in pixels between left edge of the control and the
// text, regardless whether control is read-only (ie. no wxTextCtrl) or not.
// Platform-specific default can be set with value-1.
// Remarks
// * This method may do nothing on some native implementations.
void SetTextIndent( int indent );
// Returns actual indentation in pixels.
wxCoord GetTextIndent() const
{
return m_absIndent;
}
// Returns area covered by the text field.
const wxRect& GetTextRect() const
{
return m_tcArea;
}
// Call with enable as true to use a type of popup window that guarantees ability
// to focus the popup control, and normal function of common native controls.
// This alternative popup window is usually a wxDialog, and as such it's parent
// frame will appear as if the focus has been lost from it.
void UseAltPopupWindow( bool enable = true )
{
wxASSERT_MSG( !m_winPopup,
wxT("call this only before SetPopupControl") );
if ( enable )
m_iFlags |= wxCC_IFLAG_USE_ALT_POPUP;
else
m_iFlags &= ~wxCC_IFLAG_USE_ALT_POPUP;
}
// Call with false to disable popup animation, if any.
void EnablePopupAnimation( bool enable = true )
{
if ( enable )
m_iFlags &= ~wxCC_IFLAG_DISABLE_POPUP_ANIM;
else
m_iFlags |= wxCC_IFLAG_DISABLE_POPUP_ANIM;
}
//
// Utilies needed by the popups or native implementations
//
// Returns true if given key combination should toggle the popup.
// NB: This is a separate from other keyboard handling because:
// 1) Replaceability.
// 2) Centralized code (otherwise it'd be split up between
// wxComboCtrl key handler and wxVListBoxComboPopup's
// key handler).
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const = 0;
// Prepare background of combo control or an item in a dropdown list
// in a way typical on platform. This includes painting the focus/disabled
// background and setting the clipping region.
// Unless you plan to paint your own focus indicator, you should always call this
// in your wxComboPopup::PaintComboControl implementation.
// In addition, it sets pen and text colour to what looks good and proper
// against the background.
// flags: wxRendererNative flags: wxCONTROL_ISSUBMENU: is drawing a list item instead of combo control
// wxCONTROL_SELECTED: list item is selected
// wxCONTROL_DISABLED: control/item is disabled
virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
// Returns true if focus indicator should be drawn in the control.
bool ShouldDrawFocus() const
{
const wxWindow* curFocus = FindFocus();
return ( !IsPopupShown() &&
(curFocus == this || (m_btn && curFocus == m_btn)) &&
(m_windowStyle & wxCB_READONLY) );
}
// These methods return references to appropriate dropbutton bitmaps
const wxBitmap& GetBitmapNormal() const { return m_bmpNormal; }
const wxBitmap& GetBitmapPressed() const { return m_bmpPressed; }
const wxBitmap& GetBitmapHover() const { return m_bmpHover; }
const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; }
// Return internal flags
wxUint32 GetInternalFlags() const { return m_iFlags; }
// Return true if Create has finished
bool IsCreated() const { return m_iFlags & wxCC_IFLAG_CREATED ? true : false; }
// common code to be called on popup hide/dismiss
void OnPopupDismiss();
// PopupShown states
enum
{
Hidden = 0,
//Closing = 1,
Animating = 2,
Visible = 3
};
bool IsPopupWindowState( int state ) const { return (state == m_popupWinState) ? true : false; }
wxByte GetPopupWindowState() const { return m_popupWinState; }
// Set value returned by GetMainWindowOfCompositeControl
void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; }
protected:
//
// Override these for customization purposes
//
// called from wxSizeEvent handler
virtual void OnResize() = 0;
// Return native text identation (for pure text, not textctrl)
virtual wxCoord GetNativeTextIndent() const;
// Called in syscolourchanged handler and base create
virtual void OnThemeChange();
// Creates wxTextCtrl.
// extraStyle: Extra style parameters
void CreateTextCtrl( int extraStyle, const wxValidator& validator );
// Installs standard input handler to combo (and optionally to the textctrl)
void InstallInputHandlers();
// flags for DrawButton()
enum
{
Draw_PaintBg = 1
};
// Draws dropbutton. Using wxRenderer or bitmaps, as appropriate.
void DrawButton( wxDC& dc, const wxRect& rect, int flags = Draw_PaintBg );
// Call if cursor is on button area or mouse is captured for the button.
//bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside );
bool HandleButtonMouseEvent( wxMouseEvent& event, int flags );
// returns true if event was consumed or filtered (event type is also set to 0 in this case)
bool PreprocessMouseEvent( wxMouseEvent& event, int flags );
//
// This will handle left_down and left_dclick events outside button in a Windows-like manner.
// If you need alternate behaviour, it is recommended you manipulate and filter events to it
// instead of building your own handling routine (for reference, on wxEVT_LEFT_DOWN it will
// toggle popup and on wxEVT_LEFT_DCLICK it will do the same or run the popup's dclick method,
// if defined - you should pass events of other types of it for common processing).
void HandleNormalMouseEvent( wxMouseEvent& event );
// Creates popup window, calls interface->Create(), etc
void CreatePopup();
// Destroy popup window and all related constructs
void DestroyPopup();
// override the base class virtuals involved in geometry calculations
virtual wxSize DoGetBestSize() const;
// NULL popup can be used to indicate default in a derived class
virtual void DoSetPopupControl(wxComboPopup* popup);
// ensures there is atleast the default popup
void EnsurePopupControl();
// Recalculates button and textctrl areas. Called when size or button setup change.
// btnWidth: default/calculated width of the dropbutton. 0 means unchanged,
// just recalculate.
void CalculateAreas( int btnWidth = 0 );
// Standard textctrl positioning routine. Just give it platform-dependant
// textctrl coordinate adjustment.
void PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust );
// event handlers
void OnSizeEvent( wxSizeEvent& event );
void OnFocusEvent(wxFocusEvent& event);
void OnIdleEvent(wxIdleEvent& event);
void OnTextCtrlEvent(wxCommandEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnKeyEvent(wxKeyEvent& event);
// Set customization flags (directs how wxComboCtrlBase helpers behave)
void Customize( wxUint32 flags ) { m_iFlags |= flags; }
// Dispatches size event and refreshes
void RecalcAndRefresh();
// Flags for DoShowPopup and AnimateShow
enum
{
ShowBelow = 0x0000, // Showing popup below the control
ShowAbove = 0x0001, // Showing popup above the control
CanDeferShow = 0x0002 // Can only return true from AnimateShow if this is set
};
// Shows and positions the popup.
virtual void DoShowPopup( const wxRect& rect, int flags );
// Implement in derived class to create a drop-down animation.
// Return true if finished immediately. Otherwise popup is only
// shown when the derived class call DoShowPopup.
// Flags are same as for DoShowPopup.
virtual bool AnimateShow( const wxRect& rect, int flags );
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif
virtual wxWindow *GetMainWindowOfCompositeControl()
{ return m_mainCtrlWnd; }
// This is used when m_text is hidden (readonly).
wxString m_valueString;
// the text control and button we show all the time
wxTextCtrl* m_text;
wxWindow* m_btn;
// wxPopupWindow or similar containing the window managed by the interface.
wxWindow* m_winPopup;
// the popup control/panel
wxWindow* m_popup;
// popup interface
wxComboPopup* m_popupInterface;
// this is input etc. handler for the text control
wxEvtHandler* m_textEvtHandler;
// this is for the top level window
wxEvtHandler* m_toplevEvtHandler;
// this is for the control in popup
wxEvtHandler* m_popupExtraHandler;
// this is for the popup window
wxEvtHandler* m_popupWinEvtHandler;
// main (ie. topmost) window of a composite control (default = this)
wxWindow* m_mainCtrlWnd;
// used to prevent immediate re-popupping incase closed popup
// by clicking on the combo control (needed because of inconsistent
// transient implementation across platforms).
wxLongLong m_timeCanAcceptClick;
// how much popup should expand to the left/right of the control
wxCoord m_extLeft;
wxCoord m_extRight;
// minimum popup width
wxCoord m_widthMinPopup;
// preferred popup height
wxCoord m_heightPopup;
// how much of writable combo is custom-paint by callback?
// also used to indicate area that is not covered by "blue"
// selection indicator.
wxCoord m_widthCustomPaint;
// absolute text indentation, in pixels
wxCoord m_absIndent;
// side on which the popup is aligned
int m_anchorSide;
// Width of the "fake" border
wxCoord m_widthCustomBorder;
// The button and textctrl click/paint areas
wxRect m_tcArea;
wxRect m_btnArea;
// current button state (uses renderer flags)
int m_btnState;
// button position
int m_btnWid;
int m_btnHei;
int m_btnSide;
int m_btnSpacingX;
// last default button width
int m_btnWidDefault;
// custom dropbutton bitmaps
wxBitmap m_bmpNormal;
wxBitmap m_bmpPressed;
wxBitmap m_bmpHover;
wxBitmap m_bmpDisabled;
// area used by the button
wxSize m_btnSize;
// platform-dependant customization and other flags
wxUint32 m_iFlags;
// draw blank button background under bitmap?
bool m_blankButtonBg;
// is the popup window currenty shown?
wxByte m_popupWinState;
// should the focus be reset to the textctrl in idle time?
bool m_resetFocus;
private:
void Init();
wxByte m_ignoreEvtText; // Number of next EVT_TEXTs to ignore
// Is popup window wxPopupTransientWindow, wxPopupWindow or wxDialog?
wxByte m_popupWinType;
DECLARE_EVENT_TABLE()
DECLARE_ABSTRACT_CLASS(wxComboCtrlBase)
};
// ----------------------------------------------------------------------------
// wxComboPopup is the interface which must be implemented by a control to be
// used as a popup by wxComboCtrl
// ----------------------------------------------------------------------------
// wxComboPopup internal flags
enum
{
wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called
};
class WXDLLEXPORT wxComboPopup
{
friend class wxComboCtrlBase;
public:
wxComboPopup()
{
m_combo = (wxComboCtrlBase*) NULL;
m_iFlags = 0;
}
// This is called immediately after construction finishes. m_combo member
// variable has been initialized before the call.
// NOTE: It is not in constructor so the derived class doesn't need to redefine
// a default constructor of its own.
virtual void Init() { }
virtual ~wxComboPopup();
// Create the popup child control.
// Return true for success.
virtual bool Create(wxWindow* parent) = 0;
// We must have an associated control which is subclassed by the combobox.
virtual wxWindow *GetControl() = 0;
// Called immediately after the popup is shown
virtual void OnPopup();
// Called when popup is dismissed
virtual void OnDismiss();
// Called just prior to displaying popup.
// Default implementation does nothing.
virtual void SetStringValue( const wxString& value );
// Gets displayed string representation of the value.
virtual wxString GetStringValue() const = 0;
// This is called to custom paint in the combo control itself (ie. not the popup).
// Default implementation draws value as string.
virtual void PaintComboControl( wxDC& dc, const wxRect& rect );
// Receives key events from the parent wxComboCtrl.
// Events not handled should be skipped, as usual.
virtual void OnComboKeyEvent( wxKeyEvent& event );
// Implement if you need to support special action when user
// double-clicks on the parent wxComboCtrl.
virtual void OnComboDoubleClick();
// Return final size of popup. Called on every popup, just prior to OnShow.
// minWidth = preferred minimum width for window
// prefHeight = preferred height. Only applies if > 0,
// maxHeight = max height for window, as limited by screen size
// and should only be rounded down, if necessary.
virtual wxSize GetAdjustedSize( int minWidth, int prefHeight, int maxHeight );
// Return true if you want delay call to Create until the popup is shown
// for the first time. It is more efficient, but note that it is often
// more convenient to have the control created immediately.
// Default returns false.
virtual bool LazyCreate();
//
// Utilies
//
// Hides the popup
void Dismiss();
// Returns true if Create has been called.
bool IsCreated() const
{
return (m_iFlags & wxCP_IFLAG_CREATED) ? true : false;
}
// Default PaintComboControl behaviour
static void DefaultPaintComboControl( wxComboCtrlBase* combo,
wxDC& dc,
const wxRect& rect );
protected:
wxComboCtrlBase* m_combo;
wxUint32 m_iFlags;
private:
// Called in wxComboCtrlBase::SetPopupControl
void InitBase(wxComboCtrlBase *combo)
{
m_combo = combo;
}
};
// ----------------------------------------------------------------------------
// include the platform-dependent header defining the real class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
// No native universal (but it must still be first in the list)
#elif defined(__WXMSW__)
#include "wx/msw/combo.h"
#endif
// Any ports may need generic as an alternative
#include "wx/generic/combo.h"
#endif // wxUSE_COMBOCTRL
#endif
// _WX_COMBOCONTROL_H_BASE_

View File

@ -0,0 +1,97 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/combobox.h
// Purpose: wxComboBox declaration
// Author: Vadim Zeitlin
// Modified by:
// Created: 24.12.00
// RCS-ID: $Id: combobox.h 42727 2006-10-30 16:04:27Z VZ $
// Copyright: (c) 1996-2000 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOBOX_H_BASE_
#define _WX_COMBOBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_COMBOBOX
extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[];
// ----------------------------------------------------------------------------
// wxComboBoxBase: this interface defines the methods wxComboBox must implement
// ----------------------------------------------------------------------------
#include "wx/textctrl.h"
#include "wx/ctrlsub.h"
class WXDLLEXPORT wxComboBoxBase : public wxItemContainer
{
public:
// wxTextCtrl-like methods wxComboBox must implement
virtual wxString GetValue() const = 0;
virtual void SetValue(const wxString& value) = 0;
virtual void Copy() = 0;
virtual void Cut() = 0;
virtual void Paste() = 0;
virtual void SetInsertionPoint(long pos) = 0;
virtual long GetInsertionPoint() const = 0;
virtual wxTextPos GetLastPosition() const = 0;
virtual void Replace(long from, long to, const wxString& value) = 0;
virtual void SetSelection(long from, long to) = 0;
virtual void SetEditable(bool editable) = 0;
virtual void SetInsertionPointEnd()
{ SetInsertionPoint(GetLastPosition()); }
virtual void Remove(long from, long to)
{ Replace(from, to, wxEmptyString); }
virtual bool IsEditable() const = 0;
virtual void Undo() = 0;
virtual void Redo() = 0;
virtual void SelectAll() = 0;
virtual bool CanCopy() const = 0;
virtual bool CanCut() const = 0;
virtual bool CanPaste() const = 0;
virtual bool CanUndo() const = 0;
virtual bool CanRedo() const = 0;
// may return value different from GetSelection() when the combobox
// dropdown is shown and the user selected, but not yet accepted, a value
// different from the old one in it
virtual int GetCurrentSelection() const { return GetSelection(); }
// redeclare inherited SetSelection() overload here as well to avoid
// virtual function hiding
virtual void SetSelection(int n) = 0;
};
// ----------------------------------------------------------------------------
// include the platform-dependent header defining the real class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/combobox.h"
#elif defined(__WXMSW__)
#include "wx/msw/combobox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/combobox.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/combobox.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/combobox.h"
#elif defined(__WXMAC__)
#include "wx/mac/combobox.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/combobox.h"
#elif defined(__WXPM__)
#include "wx/os2/combobox.h"
#endif
#endif // wxUSE_COMBOBOX
#endif
// _WX_COMBOBOX_H_BASE_

View File

@ -0,0 +1,359 @@
///////////////////////////////////////////////////////////////////////////////
// Name: confbase.h
// Purpose: declaration of the base class of all config implementations
// (see also: fileconf.h and msw/regconf.h and iniconf.h)
// Author: Karsten Ballueder & Vadim Zeitlin
// Modified by:
// Created: 07.04.98 (adapted from appconf.h)
// RCS-ID: $Id: confbase.h 50711 2007-12-15 02:57:58Z VZ $
// Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net
// Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONFBASE_H_
#define _WX_CONFBASE_H_
#include "wx/defs.h"
#include "wx/string.h"
class WXDLLIMPEXP_FWD_BASE wxArrayString;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
/// shall we be case sensitive in parsing variable names?
#ifndef wxCONFIG_CASE_SENSITIVE
#define wxCONFIG_CASE_SENSITIVE 0
#endif
/// separates group and entry names (probably shouldn't be changed)
#ifndef wxCONFIG_PATH_SEPARATOR
#define wxCONFIG_PATH_SEPARATOR _T('/')
#endif
/// introduces immutable entries
// (i.e. the ones which can't be changed from the local config file)
#ifndef wxCONFIG_IMMUTABLE_PREFIX
#define wxCONFIG_IMMUTABLE_PREFIX _T('!')
#endif
#if wxUSE_CONFIG
#include "wx/string.h"
/// should we use registry instead of configuration files under Windows?
// (i.e. whether wxConfigBase::Create() will create a wxFileConfig (if it's
// false) or wxRegConfig (if it's true and we're under Win32))
#ifndef wxUSE_CONFIG_NATIVE
#define wxUSE_CONFIG_NATIVE 1
#endif
// Style flags for constructor style parameter
enum
{
wxCONFIG_USE_LOCAL_FILE = 1,
wxCONFIG_USE_GLOBAL_FILE = 2,
wxCONFIG_USE_RELATIVE_PATH = 4,
wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8,
wxCONFIG_USE_SUBDIR = 16
};
// ----------------------------------------------------------------------------
// abstract base class wxConfigBase which defines the interface for derived
// classes
//
// wxConfig organizes the items in a tree-like structure (modeled after the
// Unix/Dos filesystem). There are groups (directories) and keys (files).
// There is always one current group given by the current path.
//
// Keys are pairs "key_name = value" where value may be of string or integer
// (long) type (TODO doubles and other types such as wxDate coming soon).
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConfigBase
{
public:
// constants
// the type of an entry
enum EntryType
{
Type_Unknown,
Type_String,
Type_Boolean,
Type_Integer, // use Read(long *)
Type_Float // use Read(double *)
};
// static functions
// sets the config object, returns the previous pointer
static wxConfigBase *Set(wxConfigBase *pConfig);
// get the config object, creates it on demand unless DontCreateOnDemand
// was called
static wxConfigBase *Get(bool createOnDemand = true)
{ if ( createOnDemand && (!ms_pConfig) ) Create(); return ms_pConfig; }
// create a new config object: this function will create the "best"
// implementation of wxConfig available for the current platform, see
// comments near definition wxUSE_CONFIG_NATIVE for details. It returns
// the created object and also sets it as ms_pConfig.
static wxConfigBase *Create();
// should Get() try to create a new log object if the current one is NULL?
static void DontCreateOnDemand() { ms_bAutoCreate = false; }
// ctor & virtual dtor
// ctor (can be used as default ctor too)
//
// Not all args will always be used by derived classes, but including
// them all in each class ensures compatibility. If appName is empty,
// uses wxApp name
wxConfigBase(const wxString& appName = wxEmptyString,
const wxString& vendorName = wxEmptyString,
const wxString& localFilename = wxEmptyString,
const wxString& globalFilename = wxEmptyString,
long style = 0);
// empty but ensures that dtor of all derived classes is virtual
virtual ~wxConfigBase();
// path management
// set current path: if the first character is '/', it's the absolute path,
// otherwise it's a relative path. '..' is supported. If the strPath
// doesn't exist it is created.
virtual void SetPath(const wxString& strPath) = 0;
// retrieve the current path (always as absolute path)
virtual const wxString& GetPath() const = 0;
// enumeration: all functions here return false when there are no more items.
// you must pass the same lIndex to GetNext and GetFirst (don't modify it)
// enumerate subgroups
virtual bool GetFirstGroup(wxString& str, long& lIndex) const = 0;
virtual bool GetNextGroup (wxString& str, long& lIndex) const = 0;
// enumerate entries
virtual bool GetFirstEntry(wxString& str, long& lIndex) const = 0;
virtual bool GetNextEntry (wxString& str, long& lIndex) const = 0;
// get number of entries/subgroups in the current group, with or without
// it's subgroups
virtual size_t GetNumberOfEntries(bool bRecursive = false) const = 0;
virtual size_t GetNumberOfGroups(bool bRecursive = false) const = 0;
// tests of existence
// returns true if the group by this name exists
virtual bool HasGroup(const wxString& strName) const = 0;
// same as above, but for an entry
virtual bool HasEntry(const wxString& strName) const = 0;
// returns true if either a group or an entry with a given name exist
bool Exists(const wxString& strName) const
{ return HasGroup(strName) || HasEntry(strName); }
// get the entry type
virtual EntryType GetEntryType(const wxString& name) const
{
// by default all entries are strings
return HasEntry(name) ? Type_String : Type_Unknown;
}
// key access: returns true if value was really read, false if default used
// (and if the key is not found the default value is returned.)
// read a string from the key
bool Read(const wxString& key, wxString *pStr) const;
bool Read(const wxString& key, wxString *pStr, const wxString& defVal) const;
// read a number (long)
bool Read(const wxString& key, long *pl) const;
bool Read(const wxString& key, long *pl, long defVal) const;
// read an int
bool Read(const wxString& key, int *pi) const;
bool Read(const wxString& key, int *pi, int defVal) const;
// read a double
bool Read(const wxString& key, double* val) const;
bool Read(const wxString& key, double* val, double defVal) const;
// read a bool
bool Read(const wxString& key, bool* val) const;
bool Read(const wxString& key, bool* val, bool defVal) const;
// convenience functions returning directly the value (we don't have them for
// int/double/bool as there would be ambiguities with the long one then)
wxString Read(const wxString& key,
const wxString& defVal = wxEmptyString) const
{ wxString s; (void)Read(key, &s, defVal); return s; }
long Read(const wxString& key, long defVal) const
{ long l; (void)Read(key, &l, defVal); return l; }
// write the value (return true on success)
bool Write(const wxString& key, const wxString& value)
{ return DoWriteString(key, value); }
bool Write(const wxString& key, long value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, int value)
{ return DoWriteInt(key, value); }
bool Write(const wxString& key, double value)
{ return DoWriteDouble(key, value); }
bool Write(const wxString& key, bool value)
{ return DoWriteBool(key, value); }
// we have to provide a separate version for C strings as otherwise they
// would be converted to bool and not to wxString as expected!
bool Write(const wxString& key, const wxChar *value)
{ return Write(key, wxString(value)); }
// permanently writes all changes
virtual bool Flush(bool bCurrentOnly = false) = 0;
// renaming, all functions return false on failure (probably because the new
// name is already taken by an existing entry)
// rename an entry
virtual bool RenameEntry(const wxString& oldName,
const wxString& newName) = 0;
// rename a group
virtual bool RenameGroup(const wxString& oldName,
const wxString& newName) = 0;
// delete entries/groups
// deletes the specified entry and the group it belongs to if
// it was the last key in it and the second parameter is true
virtual bool DeleteEntry(const wxString& key,
bool bDeleteGroupIfEmpty = true) = 0;
// delete the group (with all subgroups)
virtual bool DeleteGroup(const wxString& key) = 0;
// delete the whole underlying object (disk file, registry key, ...)
// primarily for use by uninstallation routine.
virtual bool DeleteAll() = 0;
// options
// we can automatically expand environment variables in the config entries
// (this option is on by default, you can turn it on/off at any time)
bool IsExpandingEnvVars() const { return m_bExpandEnvVars; }
void SetExpandEnvVars(bool bDoIt = true) { m_bExpandEnvVars = bDoIt; }
// recording of default values
void SetRecordDefaults(bool bDoIt = true) { m_bRecordDefaults = bDoIt; }
bool IsRecordingDefaults() const { return m_bRecordDefaults; }
// does expansion only if needed
wxString ExpandEnvVars(const wxString& str) const;
// misc accessors
wxString GetAppName() const { return m_appName; }
wxString GetVendorName() const { return m_vendorName; }
// Used wxIniConfig to set members in constructor
void SetAppName(const wxString& appName) { m_appName = appName; }
void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
void SetStyle(long style) { m_style = style; }
long GetStyle() const { return m_style; }
protected:
static bool IsImmutable(const wxString& key)
{ return !key.IsEmpty() && key[0] == wxCONFIG_IMMUTABLE_PREFIX; }
// return the path without trailing separator, if any: this should be called
// to sanitize paths referring to the group names before passing them to
// wxConfigPathChanger as "/foo/bar/" should be the same as "/foo/bar" and it
// isn't interpreted in the same way by it (and this can't be changed there
// as it's not the same for the entries names)
static wxString RemoveTrailingSeparator(const wxString& key);
// do read/write the values of different types
virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0;
virtual bool DoReadLong(const wxString& key, long *pl) const = 0;
virtual bool DoReadInt(const wxString& key, int *pi) const;
virtual bool DoReadDouble(const wxString& key, double* val) const;
virtual bool DoReadBool(const wxString& key, bool* val) const;
virtual bool DoWriteString(const wxString& key, const wxString& value) = 0;
virtual bool DoWriteLong(const wxString& key, long value) = 0;
virtual bool DoWriteInt(const wxString& key, int value);
virtual bool DoWriteDouble(const wxString& key, double value);
virtual bool DoWriteBool(const wxString& key, bool value);
private:
// are we doing automatic environment variable expansion?
bool m_bExpandEnvVars;
// do we record default values?
bool m_bRecordDefaults;
// static variables
static wxConfigBase *ms_pConfig;
static bool ms_bAutoCreate;
// Application name and organisation name
wxString m_appName;
wxString m_vendorName;
// Style flag
long m_style;
};
// a handy little class which changes current path to the path of given entry
// and restores it in dtor: so if you declare a local variable of this type,
// you work in the entry directory and the path is automatically restored
// when the function returns
// Taken out of wxConfig since not all compilers can cope with nested classes.
class WXDLLIMPEXP_BASE wxConfigPathChanger
{
public:
// ctor/dtor do path changing/restoring of the path
wxConfigPathChanger(const wxConfigBase *pContainer, const wxString& strEntry);
~wxConfigPathChanger();
// get the key name
const wxString& Name() const { return m_strName; }
// this method must be called if the original path (i.e. the current path at
// the moment of creation of this object) could have been deleted to prevent
// us from restoring the not existing (any more) path
//
// if the original path doesn't exist any more, the path will be restored to
// the deepest still existing component of the old path
void UpdateIfDeleted();
private:
wxConfigBase *m_pContainer; // object we live in
wxString m_strName, // name of entry (i.e. name only)
m_strOldPath; // saved path
bool m_bChanged; // was the path changed?
DECLARE_NO_COPY_CLASS(wxConfigPathChanger)
};
// ----------------------------------------------------------------------------
// the native wxConfigBase implementation
// ----------------------------------------------------------------------------
// under Windows we prefer to use the native implementation
// wxIniConfig isn't native anywhere after droping win16 in wxWidgets 2.6
#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
#define wxConfig wxRegConfig
#else // either we're under Unix or wish to use files even under Windows
#define wxConfig wxFileConfig
#endif
#endif // wxUSE_CONFIG
/*
Replace environment variables ($SOMETHING) with their values. The format is
$VARNAME or ${VARNAME} where VARNAME contains alphanumeric characters and
'_' only. '$' must be escaped ('\$') in order to be taken literally.
*/
WXDLLIMPEXP_BASE wxString wxExpandEnvVars(const wxString &sz);
/*
Split path into parts removing '..' in progress
*/
WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxChar *sz);
#endif
// _WX_CONFIG_H_

View File

@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////
// Name: config.h
// Purpose: wxConfig base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: config.h 33948 2005-05-04 18:57:50Z JS $
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONFIG_H_BASE_
#define _WX_CONFIG_H_BASE_
#include "wx/defs.h"
#include "wx/confbase.h"
#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
# ifdef __WIN32__
# include "wx/msw/regconf.h"
# else
# include "wx/msw/iniconf.h"
# endif
#elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
# include "wx/palmos/prefconf.h"
#else
# include "wx/fileconf.h"
#endif
#endif
// _WX_CONFIG_H_BASE_

View File

@ -0,0 +1,142 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/containr.h
// Purpose: wxControlContainer class declration: a "mix-in" class which
// implements the TAB navigation between the controls
// Author: Vadim Zeitlin
// Modified by:
// Created: 06.08.01
// RCS-ID: $Id: containr.h 50863 2007-12-20 18:32:55Z VS $
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTAINR_H_
#define _WX_CONTAINR_H_
class WXDLLIMPEXP_FWD_CORE wxFocusEvent;
class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxWindowBase;
/*
Implementation note: wxControlContainer is not a real mix-in but rather
a class meant to be agregated with (and not inherited from). Although
logically it should be a mix-in, doing it like this has no advantage from
the point of view of the existing code but does have some problems (we'd
need to play tricks with event handlers which may be difficult to do
safely). The price we pay for this simplicity is the ugly macros below.
*/
// ----------------------------------------------------------------------------
// wxControlContainer
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxControlContainer
{
public:
// ctors and such
wxControlContainer(wxWindow *winParent = NULL);
void SetContainerWindow(wxWindow *winParent) { m_winParent = winParent; }
// the methods to be called from the window event handlers
void HandleOnNavigationKey(wxNavigationKeyEvent& event);
void HandleOnFocus(wxFocusEvent& event);
void HandleOnWindowDestroy(wxWindowBase *child);
// should be called from SetFocus(), returns false if we did nothing with
// the focus and the default processing should take place
bool DoSetFocus();
// can our child get the focus?
bool AcceptsFocus() const;
// called from OnChildFocus() handler, i.e. when one of our (grand)
// children gets the focus
void SetLastFocus(wxWindow *win);
protected:
// set the focus to the child which had it the last time
bool SetFocusToChild();
// the parent window we manage the children for
wxWindow *m_winParent;
// the child which had the focus last time this panel was activated
wxWindow *m_winLastFocused;
// a guard against infinite recursion
bool m_inSetFocus;
DECLARE_NO_COPY_CLASS(wxControlContainer)
};
// this function is for wxWidgets internal use only
extern bool wxSetFocusToChild(wxWindow *win, wxWindow **child);
// ----------------------------------------------------------------------------
// macros which may be used by the classes wishing to implement TAB navigation
// among their children
// ----------------------------------------------------------------------------
// declare the methods to be forwarded
#define WX_DECLARE_CONTROL_CONTAINER() \
public: \
void OnNavigationKey(wxNavigationKeyEvent& event); \
void OnFocus(wxFocusEvent& event); \
virtual void OnChildFocus(wxChildFocusEvent& event); \
virtual void SetFocus(); \
virtual void SetFocusIgnoringChildren(); \
virtual void RemoveChild(wxWindowBase *child); \
virtual bool AcceptsFocus() const; \
\
protected: \
wxControlContainer m_container
// implement the event table entries for wxControlContainer
#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \
EVT_SET_FOCUS(classname::OnFocus) \
EVT_CHILD_FOCUS(classname::OnChildFocus) \
EVT_NAVIGATION_KEY(classname::OnNavigationKey)
// implement the methods forwarding to the wxControlContainer
#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \
void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \
{ \
m_container.HandleOnNavigationKey(event); \
} \
\
void classname::RemoveChild(wxWindowBase *child) \
{ \
m_container.HandleOnWindowDestroy(child); \
\
basename::RemoveChild(child); \
} \
\
void classname::SetFocus() \
{ \
if ( !m_container.DoSetFocus() ) \
basename::SetFocus(); \
} \
\
void classname::SetFocusIgnoringChildren() \
{ \
basename::SetFocus(); \
} \
\
void classname::OnChildFocus(wxChildFocusEvent& event) \
{ \
m_container.SetLastFocus(event.GetWindow()); \
event.Skip(); \
} \
\
void classname::OnFocus(wxFocusEvent& event) \
{ \
m_container.HandleOnFocus(event); \
} \
bool classname::AcceptsFocus() const \
{ \
return m_container.AcceptsFocus(); \
}
#endif // _WX_CONTAINR_H_

View File

@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/control.h
// Purpose: wxControl common interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 26.07.99
// RCS-ID: $Id: control.h 42816 2006-10-31 08:50:17Z RD $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTROL_H_BASE_
#define _WX_CONTROL_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_CONTROLS
#include "wx/window.h" // base class
extern WXDLLEXPORT_DATA(const wxChar) wxControlNameStr[];
// ----------------------------------------------------------------------------
// wxControl is the base class for all controls
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxControlBase : public wxWindow
{
public:
wxControlBase() { }
virtual ~wxControlBase();
// Create() function adds the validator parameter
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
// get the control alignment (left/right/centre, top/bottom/centre)
int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; }
// get the string without mnemonic characters ('&')
static wxString GetLabelText(const wxString& label);
// get just the text of the label, without mnemonic characters ('&')
wxString GetLabelText() const { return GetLabelText(GetLabel()); }
// controls by default inherit the colours of their parents, if a
// particular control class doesn't want to do it, it can override
// ShouldInheritColours() to return false
virtual bool ShouldInheritColours() const { return true; }
// WARNING: this doesn't work for all controls nor all platforms!
//
// simulates the event of given type (i.e. wxButton::Command() is just as
// if the button was clicked)
virtual void Command(wxCommandEvent &event);
virtual void SetLabel( const wxString &label );
virtual bool SetFont(const wxFont& font);
// wxControl-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
protected:
// creates the control (calls wxWindowBase::CreateBase inside) and adds it
// to the list of parents children
bool CreateControl(wxWindowBase *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
// initialize the common fields of wxCommandEvent
void InitCommandEvent(wxCommandEvent& event) const;
DECLARE_NO_COPY_CLASS(wxControlBase)
};
// ----------------------------------------------------------------------------
// include platform-dependent wxControl declarations
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/control.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/control.h"
#elif defined(__WXMSW__)
#include "wx/msw/control.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/control.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/control.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/control.h"
#elif defined(__WXMAC__)
#include "wx/mac/control.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/control.h"
#elif defined(__WXPM__)
#include "wx/os2/control.h"
#endif
#endif // wxUSE_CONTROLS
#endif
// _WX_CONTROL_H_BASE_

View File

@ -0,0 +1,108 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/convauto.h
// Purpose: wxConvAuto class declaration
// Author: Vadim Zeitlin
// Created: 2006-04-03
// RCS-ID: $Id: convauto.h 45893 2007-05-08 20:05:16Z VZ $
// Copyright: (c) 2006 Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONVAUTO_H_
#define _WX_CONVAUTO_H_
#include "wx/strconv.h"
#if wxUSE_WCHAR_T
// ----------------------------------------------------------------------------
// wxConvAuto: uses BOM to automatically detect input encoding
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConvAuto : public wxMBConv
{
public:
// default ctor, the real conversion will be created on demand
wxConvAuto() { m_conv = NULL; /* the rest will be initialized later */ }
// copy ctor doesn't initialize anything neither as conversion can only be
// deduced on first use
wxConvAuto(const wxConvAuto& WXUNUSED(other)) : wxMBConv() { m_conv = NULL; }
virtual ~wxConvAuto() { if ( m_conv && m_ownsConv ) delete m_conv; }
// override the base class virtual function(s) to use our m_conv
virtual size_t ToWChar(wchar_t *dst, size_t dstLen,
const char *src, size_t srcLen = wxNO_LEN) const;
virtual size_t FromWChar(char *dst, size_t dstLen,
const wchar_t *src, size_t srcLen = wxNO_LEN) const;
virtual size_t GetMBNulLen() const { return m_conv->GetMBNulLen(); }
virtual wxMBConv *Clone() const { return new wxConvAuto(*this); }
private:
// all currently recognized BOM values
enum BOMType
{
BOM_None,
BOM_UTF32BE,
BOM_UTF32LE,
BOM_UTF16BE,
BOM_UTF16LE,
BOM_UTF8
};
// return the BOM type of this buffer
static BOMType DetectBOM(const char *src, size_t srcLen);
// initialize m_conv with the conversion to use by default (UTF-8)
void InitWithDefault()
{
m_conv = &wxConvUTF8;
m_ownsConv = false;
}
// create the correct conversion object for the given BOM type
void InitFromBOM(BOMType bomType);
// create the correct conversion object for the BOM present in the
// beginning of the buffer; adjust the buffer to skip the BOM if found
void InitFromInput(const char **src, size_t *len);
// adjust src and len to skip over the BOM (identified by m_bomType) at the
// start of the buffer
void SkipBOM(const char **src, size_t *len) const;
// conversion object which we really use, NULL until the first call to
// either ToWChar() or FromWChar()
wxMBConv *m_conv;
// our BOM type
BOMType m_bomType;
// true if we allocated m_conv ourselves, false if we just use an existing
// global conversion
bool m_ownsConv;
// true if we already skipped BOM when converting (and not just calculating
// the size)
bool m_consumedBOM;
DECLARE_NO_ASSIGN_CLASS(wxConvAuto)
};
#else // !wxUSE_WCHAR_T
// it doesn't matter how we define it in this case as it's unused anyhow, but
// do define it to allow the code using wxConvAuto() as default argument (this
// is done in many places) to compile
typedef wxMBConv wxConvAuto;
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
#endif // _WX_CONVAUTO_H_

View File

@ -0,0 +1,57 @@
/*
* Name: wx/cpp.h
* Purpose: Various preprocessor helpers
* Author: Vadim Zeitlin
* Created: 2006-09-30
* RCS-ID: $Id: cpp.h 42993 2006-11-03 21:06:57Z VZ $
* Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_CPP_H_
#define _WX_CPP_H_
/* wxCONCAT works like preprocessor ## operator but also works with macros */
#define wxCONCAT_HELPER(text, line) text ## line
#define wxCONCAT(text, line) wxCONCAT_HELPER(text, line)
/* wxSTRINGIZE works as the preprocessor # operator but also works with macros */
#define wxSTRINGIZE_HELPER(x) #x
#define wxSTRINGIZE(x) wxSTRINGIZE_HELPER(x)
/* a Unicode-friendly version of wxSTRINGIZE_T */
#define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x))
/*
Helper macros for wxMAKE_UNIQUE_NAME: normally this works by appending the
current line number to the given identifier to reduce the probability of the
conflict (it may still happen if this is used in the headers, hence you
should avoid doing it or provide unique prefixes then) but we have to do it
differently for VC++
*/
#if defined(__VISUALC__) && (__VISUALC__ >= 1300)
/*
__LINE__ handling is completely broken in VC++ when using "Edit and
Continue" (/ZI option) and results in preprocessor errors if we use it
inside the macros. Luckily VC7 has another standard macro which can be
used like this and is even better than __LINE__ because it is globally
unique.
*/
# define wxCONCAT_LINE(text) wxCONCAT(text, __COUNTER__)
#else /* normal compilers */
# define wxCONCAT_LINE(text) wxCONCAT(text, __LINE__)
#endif
/* Create a "unique" name with the given prefix */
#define wxMAKE_UNIQUE_NAME(text) wxCONCAT_LINE(text)
/*
This macro can be passed as argument to another macro when you don't have
anything to pass in fact.
*/
#define wxEMPTY_PARAMETER_VALUE /* Fake macro parameter value */
#endif // _WX_CPP_H_

View File

@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cppunit.h
// Purpose: wrapper header for CppUnit headers
// Author: Vadim Zeitlin
// Created: 15.02.04
// RCS-ID: $Id: cppunit.h 53917 2008-06-01 20:32:26Z VZ $
// Copyright: (c) 2004 Vadim Zeitlin
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CPPUNIT_H_
#define _WX_CPPUNIT_H_
///////////////////////////////////////////////////////////////////////////////
// using CPPUNIT_TEST() macro results in this warning, disable it as there is
// no other way to get rid of it and it's not very useful anyhow
#ifdef __VISUALC__
// typedef-name 'foo' used as synonym for class-name 'bar'
#pragma warning(disable:4097)
// unreachable code: we don't care about warnings in CppUnit headers
#pragma warning(disable:4702)
// 'id': identifier was truncated to 'num' characters in the debug info
#pragma warning(disable:4786)
#endif // __VISUALC__
#ifdef __BORLANDC__
#pragma warn -8022
#endif
#ifndef CPPUNIT_STD_NEED_ALLOCATOR
#define CPPUNIT_STD_NEED_ALLOCATOR 0
#endif
///////////////////////////////////////////////////////////////////////////////
// Set the default format for the errors, which can be used by an IDE to jump
// to the error location. This default gets overridden by the cppunit headers
// for some compilers (e.g. VC++).
#ifndef CPPUNIT_COMPILER_LOCATION_FORMAT
#define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l:"
#endif
///////////////////////////////////////////////////////////////////////////////
// Include all needed cppunit headers.
//
#include "wx/beforestd.h"
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TestCase.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/CompilerOutputter.h>
#include "wx/afterstd.h"
///////////////////////////////////////////////////////////////////////////////
// Set of helpful test macros.
//
// Base macro for wrapping CPPUNIT_TEST macros and so making them conditional
// tests, meaning that the test only get registered and thus run when a given
// runtime condition is true.
// In case the condition is evaluated as false a skip message is logged
// (the message will only be shown in verbose mode).
#define WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, anyTest) \
if (Condition) \
{ anyTest; } \
else \
wxLogInfo(wxString::Format(_T("skipping: %s.%s\n reason: %s equals false\n"), \
wxString(suiteName, wxConvUTF8).c_str(), \
wxString(#testMethod, wxConvUTF8).c_str(), \
wxString(#Condition, wxConvUTF8).c_str()))
// Conditional CPPUNIT_TEST macro.
#define WXTEST_WITH_CONDITION(suiteName, Condition, testMethod) \
WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST(testMethod))
// Conditional CPPUNIT_TEST_FAIL macro.
#define WXTEST_FAIL_WITH_CONDITION(suiteName, Condition, testMethod) \
WXTEST_ANY_WITH_CONDITION(suiteName, Condition, testMethod, CPPUNIT_TEST_FAIL(testMethod))
// Use this macro to compare a wxString with a literal string.
#define WX_ASSERT_STR_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(wxString(p), s)
// Use this macro to compare a size_t with a literal integer
#define WX_ASSERT_SIZET_EQUAL(n, m) CPPUNIT_ASSERT_EQUAL(((size_t)n), m)
// Use this macro to compare the expected time_t value with the result of not
// necessarily time_t type
#define WX_ASSERT_TIME_T_EQUAL(t, n) CPPUNIT_ASSERT_EQUAL((t), (time_t)(n))
///////////////////////////////////////////////////////////////////////////////
// stream inserter for wxString
//
#include "wx/string.h"
inline std::ostream& operator<<(std::ostream& o, const wxString& s)
{
return o << s.mb_str();
}
///////////////////////////////////////////////////////////////////////////////
// Some more compiler warning tweaking and auto linking.
//
#ifdef __BORLANDC__
#pragma warn .8022
#endif
#ifdef _MSC_VER
#pragma warning(default:4702)
#endif // _MSC_VER
// for VC++ automatically link in cppunit library
#ifdef __VISUALC__
#ifdef NDEBUG
#pragma comment(lib, "cppunit.lib")
#else // Debug
#pragma comment(lib, "cppunitd.lib")
#endif // Release/Debug
#endif
#endif // _WX_CPPUNIT_H_

View File

@ -0,0 +1,244 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cshelp.h
// Purpose: Context-sensitive help support classes
// Author: Julian Smart, Vadim Zeitlin
// Modified by:
// Created: 08/09/2000
// RCS-ID: $Id: cshelp.h 39675 2006-06-11 21:10:32Z VZ $
// Copyright: (c) 2000 Julian Smart, Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CSHELP_H_
#define _WX_CSHELP_H_
#include "wx/defs.h"
#if wxUSE_HELP
#include "wx/help.h"
#include "wx/hashmap.h"
#if wxUSE_BMPBUTTON
#include "wx/bmpbuttn.h"
#endif
#include "wx/event.h"
// ----------------------------------------------------------------------------
// classes used to implement context help UI
// ----------------------------------------------------------------------------
/*
* wxContextHelp
* Invokes context-sensitive help. When the user
* clicks on a window, a wxEVT_HELP event will be sent to that
* window for the application to display help for.
*/
class WXDLLEXPORT wxContextHelp : public wxObject
{
public:
wxContextHelp(wxWindow* win = NULL, bool beginHelp = true);
virtual ~wxContextHelp();
bool BeginContextHelp(wxWindow* win);
bool EndContextHelp();
bool EventLoop();
bool DispatchEvent(wxWindow* win, const wxPoint& pt);
void SetStatus(bool status) { m_status = status; }
protected:
bool m_inHelp;
bool m_status; // true if the user left-clicked
private:
DECLARE_DYNAMIC_CLASS(wxContextHelp)
};
#if wxUSE_BMPBUTTON
/*
* wxContextHelpButton
* You can add this to your dialogs (especially on non-Windows platforms)
* to put the application into context help mode.
*/
class WXDLLEXPORT wxContextHelpButton : public wxBitmapButton
{
public:
wxContextHelpButton(wxWindow* parent,
wxWindowID id = wxID_CONTEXT_HELP,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBU_AUTODRAW);
void OnContextHelp(wxCommandEvent& event);
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxContextHelpButton)
DECLARE_EVENT_TABLE()
};
#endif
// ----------------------------------------------------------------------------
// classes used to implement context help support
// ----------------------------------------------------------------------------
// wxHelpProvider is an abstract class used by the program implementing context help to
// show the help text (or whatever: it may be HTML page or anything else) for
// the given window.
//
// The current help provider must be explicitly set by the application using
// wxHelpProvider::Set().
//
// Special note about ShowHelpAtPoint() and ShowHelp(): we want to be able to
// override ShowHelpAtPoint() when we need to use different help messages for
// different parts of the window, but it should also be possible to override
// just ShowHelp() both for backwards compatibility and just because most
// often the help does not, in fact, depend on the position and so
// implementing just ShowHelp() is simpler and more natural, so by default
// ShowHelpAtPoint() forwards to ShowHelp(). But this means that
// wxSimpleHelpProvider has to override ShowHelp() and not ShowHelpAtPoint()
// for backwards compatibility as otherwise the existing code deriving from it
// and overriding ShowHelp() but calling the base class version wouldn't work
// any more, which forces us to use a rather ugly hack and pass the extra
// parameters of ShowHelpAtPoint() to ShowHelp() via member variables.
class WXDLLEXPORT wxHelpProvider
{
public:
// get/set the current (application-global) help provider (Set() returns
// the previous one)
static wxHelpProvider *Set(wxHelpProvider *helpProvider)
{
wxHelpProvider *helpProviderOld = ms_helpProvider;
ms_helpProvider = helpProvider;
return helpProviderOld;
}
// unlike some other class, the help provider is not created on demand,
// this must be explicitly done by the application
static wxHelpProvider *Get() { return ms_helpProvider; }
// get the help string (whose interpretation is help provider dependent
// except that empty string always means that no help is associated with
// the window) for this window
virtual wxString GetHelp(const wxWindowBase *window) = 0;
// do show help for the given window (uses window->GetHelpAtPoint()
// internally if applicable), return true if it was done or false
// if no help available for this window
virtual bool ShowHelpAtPoint(wxWindowBase *window,
const wxPoint& pt,
wxHelpEvent::Origin origin)
{
wxCHECK_MSG( window, false, _T("window must not be NULL") );
m_helptextAtPoint = pt;
m_helptextOrigin = origin;
return ShowHelp(window);
}
// show help for the given window, see ShowHelpAtPoint() above
virtual bool ShowHelp(wxWindowBase * WXUNUSED(window)) { return false; }
// associate the text with the given window or id: although all help
// providers have these functions to allow making wxWindow::SetHelpText()
// work, not all of them implement them
virtual void AddHelp(wxWindowBase *window, const wxString& text);
// this version associates the given text with all window with this id
// (may be used to set the same help string for all [Cancel] buttons in
// the application, for example)
virtual void AddHelp(wxWindowID id, const wxString& text);
// removes the association
virtual void RemoveHelp(wxWindowBase* window);
// virtual dtor for any base class
virtual ~wxHelpProvider();
protected:
wxHelpProvider()
: m_helptextAtPoint(wxDefaultPosition),
m_helptextOrigin(wxHelpEvent::Origin_Unknown)
{
}
// helper method used by ShowHelp(): returns the help string to use by
// using m_helptextAtPoint/m_helptextOrigin if they're set or just GetHelp
// otherwise
wxString GetHelpTextMaybeAtPoint(wxWindowBase *window);
// parameters of the last ShowHelpAtPoint() call, used by ShowHelp()
wxPoint m_helptextAtPoint;
wxHelpEvent::Origin m_helptextOrigin;
private:
static wxHelpProvider *ms_helpProvider;
};
WX_DECLARE_EXPORTED_HASH_MAP( wxUIntPtr, wxString, wxIntegerHash,
wxIntegerEqual, wxSimpleHelpProviderHashMap );
// wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
// only plain text help strings and shows the string associated with the
// control (if any) in a tooltip
class WXDLLEXPORT wxSimpleHelpProvider : public wxHelpProvider
{
public:
// implement wxHelpProvider methods
virtual wxString GetHelp(const wxWindowBase *window);
// override ShowHelp() and not ShowHelpAtPoint() as explained above
virtual bool ShowHelp(wxWindowBase *window);
virtual void AddHelp(wxWindowBase *window, const wxString& text);
virtual void AddHelp(wxWindowID id, const wxString& text);
virtual void RemoveHelp(wxWindowBase* window);
protected:
// we use 2 hashes for storing the help strings associated with windows
// and the ids
wxSimpleHelpProviderHashMap m_hashWindows,
m_hashIds;
};
// wxHelpControllerHelpProvider is an implementation of wxHelpProvider which supports
// both context identifiers and plain text help strings. If the help text is an integer,
// it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the string
// in a tooltip as per wxSimpleHelpProvider.
class WXDLLEXPORT wxHelpControllerHelpProvider : public wxSimpleHelpProvider
{
public:
// Note that it doesn't own the help controller. The help controller
// should be deleted separately.
wxHelpControllerHelpProvider(wxHelpControllerBase* hc = (wxHelpControllerBase*) NULL);
// implement wxHelpProvider methods
// again (see above): this should be ShowHelpAtPoint() but we need to
// override ShowHelp() to avoid breaking existing code
virtual bool ShowHelp(wxWindowBase *window);
// Other accessors
void SetHelpController(wxHelpControllerBase* hc) { m_helpController = hc; }
wxHelpControllerBase* GetHelpController() const { return m_helpController; }
protected:
wxHelpControllerBase* m_helpController;
DECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider)
};
// Convenience function for turning context id into wxString
WXDLLEXPORT wxString wxContextId(int id);
#endif // wxUSE_HELP
#endif // _WX_CSHELP_H_

View File

@ -0,0 +1,210 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
// Purpose: wxControlWithItems interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 22.10.99
// RCS-ID: $Id: ctrlsub.h 42816 2006-10-31 08:50:17Z RD $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CTRLSUB_H_BASE_
#define _WX_CTRLSUB_H_BASE_
#include "wx/defs.h"
#if wxUSE_CONTROLS
#include "wx/control.h" // base class
// ----------------------------------------------------------------------------
// wxItemContainer defines an interface which is implemented by all controls
// which have string subitems each of which may be selected.
//
// It is decomposed in wxItemContainerImmutable which omits all methods
// adding/removing items and is used by wxRadioBox and wxItemContainer itself.
//
// Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
// implements an extended interface deriving from this one)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxItemContainerImmutable
{
public:
wxItemContainerImmutable() { }
virtual ~wxItemContainerImmutable();
// accessing strings
// -----------------
virtual unsigned int GetCount() const = 0;
bool IsEmpty() const { return GetCount() == 0; }
virtual wxString GetString(unsigned int n) const = 0;
wxArrayString GetStrings() const;
virtual void SetString(unsigned int n, const wxString& s) = 0;
// finding string natively is either case sensitive or insensitive
// but never both so fall back to this base version for not
// supported search type
virtual int FindString(const wxString& s, bool bCase = false) const
{
unsigned int count = GetCount();
for ( unsigned int i = 0; i < count ; ++i )
{
if (GetString(i).IsSameAs( s , bCase ))
return (int)i;
}
return wxNOT_FOUND;
}
// selection
// ---------
virtual void SetSelection(int n) = 0;
virtual int GetSelection() const = 0;
// set selection to the specified string, return false if not found
bool SetStringSelection(const wxString& s);
// return the selected string or empty string if none
wxString GetStringSelection() const;
// this is the same as SetSelection( for single-selection controls but
// reads better for multi-selection ones
void Select(int n) { SetSelection(n); }
protected:
// check that the index is valid
inline bool IsValid(unsigned int n) const { return n < GetCount(); }
inline bool IsValidInsert(unsigned int n) const { return n <= GetCount(); }
};
class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable
{
public:
wxItemContainer() { m_clientDataItemsType = wxClientData_None; }
virtual ~wxItemContainer();
// adding items
// ------------
int Append(const wxString& item)
{ return DoAppend(item); }
int Append(const wxString& item, void *clientData)
{ int n = DoAppend(item); SetClientData(n, clientData); return n; }
int Append(const wxString& item, wxClientData *clientData)
{ int n = DoAppend(item); SetClientObject(n, clientData); return n; }
// only for rtti needs (separate name)
void AppendString( const wxString& item)
{ Append( item ); }
// append several items at once to the control
void Append(const wxArrayString& strings);
int Insert(const wxString& item, unsigned int pos)
{ return DoInsert(item, pos); }
int Insert(const wxString& item, unsigned int pos, void *clientData);
int Insert(const wxString& item, unsigned int pos, wxClientData *clientData);
// deleting items
// --------------
virtual void Clear() = 0;
virtual void Delete(unsigned int n) = 0;
// misc
// ----
// client data stuff
void SetClientData(unsigned int n, void* clientData);
void* GetClientData(unsigned int n) const;
void SetClientObject(unsigned int n, wxClientData* clientData);
wxClientData* GetClientObject(unsigned int n) const;
bool HasClientObjectData() const
{ return m_clientDataItemsType == wxClientData_Object; }
bool HasClientUntypedData() const
{ return m_clientDataItemsType == wxClientData_Void; }
protected:
virtual int DoAppend(const wxString& item) = 0;
virtual int DoInsert(const wxString& item, unsigned int pos) = 0;
virtual void DoSetItemClientData(unsigned int n, void* clientData) = 0;
virtual void* DoGetItemClientData(unsigned int n) const = 0;
virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData) = 0;
virtual wxClientData* DoGetItemClientObject(unsigned int n) const = 0;
// the type of the client data for the items
wxClientDataType m_clientDataItemsType;
};
// this macro must (unfortunately) be used in any class deriving from both
// wxItemContainer and wxControl because otherwise there is ambiguity when
// calling GetClientXXX() functions -- the compiler can't choose between the
// two versions
#define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \
void SetClientData(void *data) \
{ wxEvtHandler::SetClientData(data); } \
void *GetClientData() const \
{ return wxEvtHandler::GetClientData(); } \
void SetClientObject(wxClientData *data) \
{ wxEvtHandler::SetClientObject(data); } \
wxClientData *GetClientObject() const \
{ return wxEvtHandler::GetClientObject(); } \
void SetClientData(unsigned int n, void* clientData) \
{ wxItemContainer::SetClientData(n, clientData); } \
void* GetClientData(unsigned int n) const \
{ return wxItemContainer::GetClientData(n); } \
void SetClientObject(unsigned int n, wxClientData* clientData) \
{ wxItemContainer::SetClientObject(n, clientData); } \
wxClientData* GetClientObject(unsigned int n) const \
{ return wxItemContainer::GetClientObject(n); }
class WXDLLEXPORT wxControlWithItems : public wxControl, public wxItemContainer
{
public:
wxControlWithItems() { }
virtual ~wxControlWithItems();
// we have to redefine these functions here to avoid ambiguities in classes
// deriving from us which would arise otherwise because both base classses
// have the methods with the same names - hopefully, a smart compiler can
// optimize away these simple inline wrappers so we don't suffer much from
// this
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
// usually the controls like list/combo boxes have their own background
// colour
virtual bool ShouldInheritColours() const { return false; }
protected:
// fill in the client object or data field of the event as appropriate
//
// calls InitCommandEvent() and, if n != wxNOT_FOUND, also sets the per
// item client data
void InitCommandEventWithItems(wxCommandEvent& event, int n);
private:
DECLARE_ABSTRACT_CLASS(wxControlWithItems)
DECLARE_NO_COPY_CLASS(wxControlWithItems)
};
// ----------------------------------------------------------------------------
// inline functions
// ----------------------------------------------------------------------------
#endif // wxUSE_CONTROLS
#endif // _WX_CTRLSUB_H_BASE_

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cursor.h
// Purpose: wxCursor base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: cursor.h 40865 2006-08-27 09:42:42Z VS $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CURSOR_H_BASE_
#define _WX_CURSOR_H_BASE_
#include "wx/defs.h"
#if defined(__WXPALMOS__)
#include "wx/palmos/cursor.h"
#elif defined(__WXMSW__)
#include "wx/msw/cursor.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/cursor.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/cursor.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/cursor.h"
#elif defined(__WXX11__)
#include "wx/x11/cursor.h"
#elif defined(__WXMGL__)
#include "wx/mgl/cursor.h"
#elif defined(__WXDFB__)
#include "wx/dfb/cursor.h"
#elif defined(__WXMAC__)
#include "wx/mac/cursor.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/cursor.h"
#elif defined(__WXPM__)
#include "wx/os2/cursor.h"
#endif
#include "wx/utils.h"
/* This is a small class which can be used by all ports
to temporarily suspend the busy cursor. Useful in modal
dialogs.
Actually that is not (any longer) quite true.. currently it is
only used in wxGTK Dialog::ShowModal() and now uses static
wxBusyCursor methods that are only implemented for wxGTK so far.
The BusyCursor handling code should probably be implemented in
common code somewhere instead of the separate implementations we
currently have. Also the name BusyCursorSuspender is a little
misleading since it doesn't actually suspend the BusyCursor, just
masks one that is already showing.
If another call to wxBeginBusyCursor is made while this is active
the Busy Cursor will again be shown. But at least now it doesn't
interfere with the state of wxIsBusy() -- RL
*/
class wxBusyCursorSuspender
{
public:
wxBusyCursorSuspender()
{
if( wxIsBusy() )
{
wxSetCursor( wxBusyCursor::GetStoredCursor() );
}
}
~wxBusyCursorSuspender()
{
if( wxIsBusy() )
{
wxSetCursor( wxBusyCursor::GetBusyCursor() );
}
}
};
#endif
// _WX_CURSOR_H_BASE_

View File

@ -0,0 +1,540 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dataobj.h
// Purpose: common data object classes
// Author: Vadim Zeitlin, Robert Roebling
// Modified by:
// Created: 26.05.99
// RCS-ID: $Id: dataobj.h 40772 2006-08-23 13:38:45Z VZ $
// Copyright: (c) wxWidgets Team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAOBJ_H_BASE_
#define _WX_DATAOBJ_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_DATAOBJ
#include "wx/string.h"
#include "wx/bitmap.h"
#include "wx/list.h"
#include "wx/arrstr.h"
// ============================================================================
/*
Generic data transfer related classes. The class hierarchy is as follows:
- wxDataObject-
/ \
/ \
wxDataObjectSimple wxDataObjectComposite
/ | \
/ | \
wxTextDataObject | wxBitmapDataObject
|
wxCustomDataObject
*/
// ============================================================================
// ----------------------------------------------------------------------------
// wxDataFormat class is declared in platform-specific headers: it represents
// a format for data which may be either one of the standard ones (text,
// bitmap, ...) or a custom one which is then identified by a unique string.
// ----------------------------------------------------------------------------
/* the class interface looks like this (pseudo code):
class wxDataFormat
{
public:
typedef <integral type> NativeFormat;
wxDataFormat(NativeFormat format = wxDF_INVALID);
wxDataFormat(const wxChar *format);
wxDataFormat& operator=(NativeFormat format);
wxDataFormat& operator=(const wxDataFormat& format);
bool operator==(NativeFormat format) const;
bool operator!=(NativeFormat format) const;
void SetType(NativeFormat format);
NativeFormat GetType() const;
wxString GetId() const;
void SetId(const wxChar *format);
};
*/
#if defined(__WXMSW__)
#include "wx/msw/ole/dataform.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dataform.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/dataform.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dataform.h"
#elif defined(__WXX11__)
#include "wx/x11/dataform.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataform.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/dataform.h"
#elif defined(__WXPM__)
#include "wx/os2/dataform.h"
#endif
// the value for default argument to some functions (corresponds to
// wxDF_INVALID)
extern WXDLLEXPORT const wxDataFormat& wxFormatInvalid;
// ----------------------------------------------------------------------------
// wxDataObject represents a piece of data which knows which formats it
// supports and knows how to render itself in each of them - GetDataHere(),
// and how to restore data from the buffer (SetData()).
//
// Although this class may be used directly (i.e. custom classes may be
// derived from it), in many cases it might be simpler to use either
// wxDataObjectSimple or wxDataObjectComposite classes.
//
// A data object may be "read only", i.e. support only GetData() functions or
// "read-write", i.e. support both GetData() and SetData() (in principle, it
// might be "write only" too, but this is rare). Moreover, it doesn't have to
// support the same formats in Get() and Set() directions: for example, a data
// object containing JPEG image might accept BMPs in GetData() because JPEG
// image may be easily transformed into BMP but not in SetData(). Accordingly,
// all methods dealing with formats take an additional "direction" argument
// which is either SET or GET and which tells the function if the format needs
// to be supported by SetData() or GetDataHere().
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDataObjectBase
{
public:
enum Direction
{
Get = 0x01, // format is supported by GetDataHere()
Set = 0x02, // format is supported by SetData()
Both = 0x03 // format is supported by both (unused currently)
};
// this class is polymorphic, hence it needs a virtual dtor
virtual ~wxDataObjectBase();
// get the best suited format for rendering our data
virtual wxDataFormat GetPreferredFormat(Direction dir = Get) const = 0;
// get the number of formats we support
virtual size_t GetFormatCount(Direction dir = Get) const = 0;
// return all formats in the provided array (of size GetFormatCount())
virtual void GetAllFormats(wxDataFormat *formats,
Direction dir = Get) const = 0;
// get the (total) size of data for the given format
virtual size_t GetDataSize(const wxDataFormat& format) const = 0;
// copy raw data (in the specified format) to the provided buffer, return
// true if data copied successfully, false otherwise
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const = 0;
// get data from the buffer of specified length (in the given format),
// return true if the data was read successfully, false otherwise
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t WXUNUSED(len), const void * WXUNUSED(buf))
{
return false;
}
// returns true if this format is supported
bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
};
// ----------------------------------------------------------------------------
// include the platform-specific declarations of wxDataObject
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dataobj.h"
#elif defined(__WXX11__)
#include "wx/x11/dataobj.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/dataobj.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dataobj.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataobj.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/dataobj.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj.h"
#endif
// ----------------------------------------------------------------------------
// wxDataObjectSimple is a wxDataObject which only supports one format (in
// both Get and Set directions, but you may return false from GetDataHere() or
// SetData() if one of them is not supported). This is the simplest possible
// wxDataObject implementation.
//
// This is still an "abstract base class" (although it doesn't have any pure
// virtual functions), to use it you should derive from it and implement
// GetDataSize(), GetDataHere() and SetData() functions because the base class
// versions don't do anything - they just return "not implemented".
//
// This class should be used when you provide data in only one format (no
// conversion to/from other formats), either a standard or a custom one.
// Otherwise, you should use wxDataObjectComposite or wxDataObject directly.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDataObjectSimple : public wxDataObject
{
public:
// ctor takes the format we support, but it can also be set later with
// SetFormat()
wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid)
: m_format(format)
{
}
// get/set the format we support
const wxDataFormat& GetFormat() const { return m_format; }
void SetFormat(const wxDataFormat& format) { m_format = format; }
// virtual functions to override in derived class (the base class versions
// just return "not implemented")
// -----------------------------------------------------------------------
// get the size of our data
virtual size_t GetDataSize() const
{ return 0; }
// copy our data to the buffer
virtual bool GetDataHere(void *WXUNUSED(buf)) const
{ return false; }
// copy data from buffer to our data
virtual bool SetData(size_t WXUNUSED(len), const void *WXUNUSED(buf))
{ return false; }
// implement base class pure virtuals
// ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
{ return m_format; }
virtual size_t GetFormatCount(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
{ return 1; }
virtual void GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
{ *formats = m_format; }
virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
{ return GetDataSize(); }
virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
void *buf) const
{ return GetDataHere(buf); }
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t len, const void *buf)
{ return SetData(len, buf); }
private:
// the one and only format we support
wxDataFormat m_format;
DECLARE_NO_COPY_CLASS(wxDataObjectSimple)
};
// ----------------------------------------------------------------------------
// wxDataObjectComposite is the simplest way to implement wxDataObject
// supporting multiple formats. It contains several wxDataObjectSimple and
// supports all formats supported by any of them.
//
// This class shouldn't be (normally) derived from, but may be used directly.
// If you need more flexibility than what it provides, you should probably use
// wxDataObject directly.
// ----------------------------------------------------------------------------
WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList);
class WXDLLEXPORT wxDataObjectComposite : public wxDataObject
{
public:
// ctor
wxDataObjectComposite();
virtual ~wxDataObjectComposite();
// add data object (it will be deleted by wxDataObjectComposite, hence it
// must be allocated on the heap) whose format will become the preferred
// one if preferred == true
void Add(wxDataObjectSimple *dataObject, bool preferred = false);
// Report the format passed to the SetData method. This should be the
// format of the data object within the composite that recieved data from
// the clipboard or the DnD operation. You can use this method to find
// out what kind of data object was recieved.
wxDataFormat GetReceivedFormat() const;
// implement base class pure virtuals
// ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction dir = Get) const;
virtual size_t GetFormatCount(wxDataObjectBase::Direction dir = Get) const;
virtual void GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction dir = Get) const;
virtual size_t GetDataSize(const wxDataFormat& format) const;
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
virtual bool SetData(const wxDataFormat& format, size_t len, const void *buf);
#if defined(__WXMSW__)
virtual const void* GetSizeFromBuffer( const void* buffer, size_t* size,
const wxDataFormat& format );
virtual void* SetSizeInBuffer( void* buffer, size_t size,
const wxDataFormat& format );
virtual size_t GetBufferOffset( const wxDataFormat& format );
#endif
protected:
// returns the pointer to the object which supports this format or NULL
wxDataObjectSimple *GetObject(const wxDataFormat& format) const;
private:
// the list of all (simple) data objects whose formats we support
wxSimpleDataObjectList m_dataObjects;
// the index of the preferred one (0 initially, so by default the first
// one is the preferred)
size_t m_preferred;
wxDataFormat m_receivedFormat;
DECLARE_NO_COPY_CLASS(wxDataObjectComposite)
};
// ============================================================================
// Standard implementations of wxDataObjectSimple which can be used directly
// (i.e. without having to derive from them) for standard data type transfers.
//
// Note that although all of them can work with provided data, you can also
// override their virtual GetXXX() functions to only provide data on demand.
// ============================================================================
// ----------------------------------------------------------------------------
// wxTextDataObject contains text data
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTextDataObject : public wxDataObjectSimple
{
public:
// ctor: you can specify the text here or in SetText(), or override
// GetText()
wxTextDataObject(const wxString& text = wxEmptyString)
: wxDataObjectSimple(
#if wxUSE_UNICODE
wxDF_UNICODETEXT
#else
wxDF_TEXT
#endif
),
m_text(text)
{
}
// virtual functions which you may override if you want to provide text on
// demand only - otherwise, the trivial default versions will be used
virtual size_t GetTextLength() const { return m_text.Len() + 1; }
virtual wxString GetText() const { return m_text; }
virtual void SetText(const wxString& text) { m_text = text; }
// implement base class pure virtuals
// ----------------------------------
// some platforms have 2 and not 1 format for text data
#if wxUSE_UNICODE && (defined(__WXGTK20__) || defined(__WXMAC__))
virtual size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const { return 2; }
virtual void GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const;
virtual size_t GetDataSize() const { return GetDataSize(GetPreferredFormat()); }
virtual bool GetDataHere(void *buf) const { return GetDataHere(GetPreferredFormat(), buf); }
virtual bool SetData(size_t len, const void *buf) { return SetData(GetPreferredFormat(), len, buf); }
size_t GetDataSize(const wxDataFormat& format) const;
bool GetDataHere(const wxDataFormat& format, void *pBuf) const;
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf);
#else
virtual size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf);
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf)
{
return SetData(len, buf);
}
#endif
private:
wxString m_text;
DECLARE_NO_COPY_CLASS(wxTextDataObject)
};
// ----------------------------------------------------------------------------
// wxBitmapDataObject contains a bitmap
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapDataObjectBase : public wxDataObjectSimple
{
public:
// ctor: you can specify the bitmap here or in SetBitmap(), or override
// GetBitmap()
wxBitmapDataObjectBase(const wxBitmap& bitmap = wxNullBitmap)
: wxDataObjectSimple(wxDF_BITMAP), m_bitmap(bitmap)
{
}
// virtual functions which you may override if you want to provide data on
// demand only - otherwise, the trivial default versions will be used
virtual wxBitmap GetBitmap() const { return m_bitmap; }
virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
protected:
wxBitmap m_bitmap;
DECLARE_NO_COPY_CLASS(wxBitmapDataObjectBase)
};
// ----------------------------------------------------------------------------
// wxFileDataObject contains a list of filenames
//
// NB: notice that this is a "write only" object, it can only be filled with
// data from drag and drop operation.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFileDataObjectBase : public wxDataObjectSimple
{
public:
// ctor: use AddFile() later to fill the array
wxFileDataObjectBase() : wxDataObjectSimple(wxDF_FILENAME) { }
// get a reference to our array
const wxArrayString& GetFilenames() const { return m_filenames; }
protected:
wxArrayString m_filenames;
DECLARE_NO_COPY_CLASS(wxFileDataObjectBase)
};
// ----------------------------------------------------------------------------
// wxCustomDataObject contains arbitrary untyped user data.
//
// It is understood that this data can be copied bitwise.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCustomDataObject : public wxDataObjectSimple
{
public:
// if you don't specify the format in the ctor, you can still use
// SetFormat() later
wxCustomDataObject(const wxDataFormat& format = wxFormatInvalid);
// the dtor calls Free()
virtual ~wxCustomDataObject();
// you can call SetData() to set m_data: it will make a copy of the data
// you pass - or you can use TakeData() which won't copy anything, but
// will take ownership of data (i.e. will call Free() on it later)
void TakeData(size_t size, void *data);
// this function is called to allocate "size" bytes of memory from
// SetData(). The default version uses operator new[].
virtual void *Alloc(size_t size);
// this function is called when the data is freed, you may override it to
// anything you want (or may be nothing at all). The default version calls
// operator delete[] on m_data
virtual void Free();
// get data: you may override these functions if you wish to provide data
// only when it's requested
virtual size_t GetSize() const { return m_size; }
virtual void *GetData() const { return m_data; }
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t size, const void *buf);
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf)
{
return SetData(len, buf);
}
private:
size_t m_size;
void *m_data;
DECLARE_NO_COPY_CLASS(wxCustomDataObject)
};
// ----------------------------------------------------------------------------
// include platform-specific declarations of wxXXXBase classes
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj2.h"
// wxURLDataObject defined in msw/ole/dataobj2.h
#else // !__WXMSW__
#if defined(__WXGTK20__)
#include "wx/gtk/dataobj2.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dataobj2.h"
#elif defined(__WXX11__)
#include "wx/x11/dataobj2.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dataobj2.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataobj2.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/dataobj2.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj2.h"
#endif
// wxURLDataObject is simply wxTextDataObject with a different name
class WXDLLEXPORT wxURLDataObject : public wxTextDataObject
{
public:
wxURLDataObject(const wxString& url = wxEmptyString)
: wxTextDataObject(url)
{
}
wxString GetURL() const { return GetText(); }
void SetURL(const wxString& url) { SetText(url); }
};
#endif // __WXMSW__/!__WXMSW__
#endif // wxUSE_DATAOBJ
#endif // _WX_DATAOBJ_H_BASE_

View File

@ -0,0 +1,462 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dataview.h
// Purpose: wxDataViewCtrl base classes
// Author: Robert Roebling
// Modified by:
// Created: 08.01.06
// RCS-ID: $Id: dataview.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAVIEW_H_BASE_
#define _WX_DATAVIEW_H_BASE_
#include "wx/defs.h"
#if wxUSE_DATAVIEWCTRL
#include "wx/control.h"
#include "wx/textctrl.h"
#include "wx/bitmap.h"
#include "wx/variant.h"
#if defined(__WXGTK20__)
// for testing
// #define wxUSE_GENERICDATAVIEWCTRL 1
#elif defined(__WXMAC__)
#define wxUSE_GENERICDATAVIEWCTRL 1
#else
#define wxUSE_GENERICDATAVIEWCTRL 1
#endif
// ----------------------------------------------------------------------------
// wxDataViewCtrl flags
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxDataViewCtrl globals
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
class WXDLLIMPEXP_FWD_ADV wxDataViewListModel;
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
// ---------------------------------------------------------
// wxDataViewModel
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewModel: public wxObject
{
public:
wxDataViewModel() { }
virtual ~wxDataViewModel() { }
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
};
// ---------------------------------------------------------
// wxDataViewListModelNotifier
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewListModelNotifier: public wxObject
{
public:
wxDataViewListModelNotifier() { }
virtual ~wxDataViewListModelNotifier() { }
virtual bool RowAppended() = 0;
virtual bool RowPrepended() = 0;
virtual bool RowInserted( unsigned int before ) = 0;
virtual bool RowDeleted( unsigned int row ) = 0;
virtual bool RowChanged( unsigned int row ) = 0;
virtual bool ValueChanged( unsigned int col, unsigned int row ) = 0;
virtual bool RowsReordered( unsigned int *new_order ) = 0;
virtual bool Cleared() = 0;
void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; }
wxDataViewListModel *GetOwner() { return m_owner; }
private:
wxDataViewListModel *m_owner;
};
// ---------------------------------------------------------
// wxDataViewListModel
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewViewingColumn: public wxObject
{
public:
wxDataViewViewingColumn( wxDataViewColumn *view_column, unsigned int model_column )
{
m_viewColumn = view_column;
m_modelColumn = model_column;
}
wxDataViewColumn *m_viewColumn;
unsigned int m_modelColumn;
};
class WXDLLIMPEXP_ADV wxDataViewListModel: public wxDataViewModel
{
public:
wxDataViewListModel();
virtual ~wxDataViewListModel();
virtual unsigned int GetNumberOfRows() = 0;
virtual unsigned int GetNumberOfCols() = 0;
// return type as reported by wxVariant
virtual wxString GetColType( unsigned int col ) = 0;
// get value into a wxVariant
virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row ) = 0;
// set value, call ValueChanged() afterwards!
virtual bool SetValue( wxVariant &variant, unsigned int col, unsigned int row ) = 0;
// delegated notifiers
virtual bool RowAppended();
virtual bool RowPrepended();
virtual bool RowInserted( unsigned int before );
virtual bool RowDeleted( unsigned int row );
virtual bool RowChanged( unsigned int row );
virtual bool ValueChanged( unsigned int col, unsigned int row );
virtual bool RowsReordered( unsigned int *new_order );
virtual bool Cleared();
// Used internally
void AddViewingColumn( wxDataViewColumn *view_column, unsigned int model_column );
void RemoveViewingColumn( wxDataViewColumn *column );
void AddNotifier( wxDataViewListModelNotifier *notifier );
void RemoveNotifier( wxDataViewListModelNotifier *notifier );
wxList m_notifiers;
wxList m_viewingColumns;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
};
// ---------------------------------------------------------
// wxDataViewSortedListModel
// ---------------------------------------------------------
typedef int (wxCALLBACK *wxDataViewListModelCompare)
(unsigned int row1, unsigned int row2, unsigned int col, wxDataViewListModel* model );
WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSortedIndexArray, WXDLLIMPEXP_ADV);
class WXDLLIMPEXP_ADV wxDataViewSortedListModel: public wxDataViewListModel
{
public:
wxDataViewSortedListModel( wxDataViewListModel *child );
virtual ~wxDataViewSortedListModel();
void SetAscending( bool ascending ) { m_ascending = ascending; }
bool GetAscending() { return m_ascending; }
virtual unsigned int GetNumberOfRows();
virtual unsigned int GetNumberOfCols();
// return type as reported by wxVariant
virtual wxString GetColType( unsigned int col );
// get value into a wxVariant
virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row );
// set value, call ValueChanged() afterwards!
virtual bool SetValue( wxVariant &variant, unsigned int col, unsigned int row );
// called from user
virtual bool RowAppended();
virtual bool RowPrepended();
virtual bool RowInserted( unsigned int before );
virtual bool RowDeleted( unsigned int row );
virtual bool RowChanged( unsigned int row );
virtual bool ValueChanged( unsigned int col, unsigned int row );
virtual bool RowsReordered( unsigned int *new_order );
virtual bool Cleared();
// called if child's notifiers are called
bool ChildRowAppended();
bool ChildRowPrepended();
bool ChildRowInserted( unsigned int before );
bool ChildRowDeleted( unsigned int row );
bool ChildRowChanged( unsigned int row );
bool ChildValueChanged( unsigned int col, unsigned int row );
bool ChildRowsReordered( unsigned int *new_order );
bool ChildCleared();
virtual void Resort();
private:
bool m_ascending;
wxDataViewListModel *m_child;
wxDataViewSortedIndexArray m_array;
wxDataViewListModelNotifier *m_notifierOnChild;
void InitStatics(); // BAD
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewSortedListModel)
};
// ---------------------------------------------------------
// wxDataViewRendererBase
// ---------------------------------------------------------
enum wxDataViewCellMode
{
wxDATAVIEW_CELL_INERT,
wxDATAVIEW_CELL_ACTIVATABLE,
wxDATAVIEW_CELL_EDITABLE
};
enum wxDataViewCellRenderState
{
wxDATAVIEW_CELL_SELECTED = 1,
wxDATAVIEW_CELL_PRELIT = 2,
wxDATAVIEW_CELL_INSENSITIVE = 4,
wxDATAVIEW_CELL_FOCUSED = 8
};
class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
{
public:
wxDataViewRendererBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
virtual bool SetValue( const wxVariant& WXUNUSED(value) ) { return true; }
virtual bool GetValue( wxVariant& WXUNUSED(value) ) { return true; }
virtual bool Validate( wxVariant& WXUNUSED(value) ) { return true; }
wxString GetVariantType() { return m_variantType; }
wxDataViewCellMode GetMode() { return m_mode; }
void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
wxDataViewColumn* GetOwner() { return m_owner; }
protected:
wxDataViewCellMode m_mode;
wxString m_variantType;
wxDataViewColumn *m_owner;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
};
// ---------------------------------------------------------
// wxDataViewColumnBase
// ---------------------------------------------------------
enum wxDataViewColumnFlags
{
wxDATAVIEW_COL_RESIZABLE = 1,
wxDATAVIEW_COL_SORTABLE = 2,
wxDATAVIEW_COL_HIDDEN = 4
};
class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
{
public:
wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
virtual ~wxDataViewColumnBase();
virtual void SetTitle( const wxString &title );
virtual wxString GetTitle();
virtual void SetBitmap( const wxBitmap &bitmap );
virtual const wxBitmap &GetBitmap();
virtual void SetAlignment( wxAlignment align ) = 0;
virtual void SetSortable( bool sortable ) = 0;
virtual bool GetSortable() = 0;
virtual void SetSortOrder( bool ascending ) = 0;
virtual bool IsSortOrderAscending() = 0;
wxDataViewRenderer* GetRenderer() { return m_renderer; }
unsigned int GetModelColumn() { return m_model_column; }
virtual void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
wxDataViewCtrl *GetOwner() { return m_owner; }
virtual int GetWidth() = 0;
private:
wxDataViewCtrl *m_ctrl;
wxDataViewRenderer *m_renderer;
int m_model_column;
int m_flags;
wxString m_title;
wxBitmap m_bitmap;
wxDataViewCtrl *m_owner;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
};
// ---------------------------------------------------------
// wxDataViewCtrlBase
// ---------------------------------------------------------
#define wxDV_SINGLE 0x0000 // for convenience
#define wxDV_MULTIPLE 0x0020 // can select multiple items
class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
{
public:
wxDataViewCtrlBase();
virtual ~wxDataViewCtrlBase();
virtual bool AssociateModel( wxDataViewListModel *model );
wxDataViewListModel* GetModel();
// short cuts
bool AppendTextColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
bool AppendToggleColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 30 );
bool AppendProgressColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 80 );
bool AppendDateColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1 );
bool AppendBitmapColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
bool AppendTextColumn( const wxBitmap &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 30 );
bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 80 );
bool AppendDateColumn( const wxBitmap &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1 );
bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetNumberOfColumns();
virtual bool DeleteColumn( unsigned int pos );
virtual bool ClearColumns();
virtual wxDataViewColumn* GetColumn( unsigned int pos );
virtual void SetSelection( int row ) = 0; // -1 for unselect
inline void ClearSelection() { SetSelection( -1 ); }
virtual void Unselect( unsigned int row ) = 0;
virtual void SetSelectionRange( unsigned int from, unsigned int to ) = 0;
virtual void SetSelections( const wxArrayInt& aSelections) = 0;
virtual bool IsSelected( unsigned int row ) const = 0;
virtual int GetSelection() const = 0;
virtual int GetSelections(wxArrayInt& aSelections) const = 0;
private:
wxDataViewListModel *m_model;
wxList m_cols;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
};
// ----------------------------------------------------------------------------
// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
{
public:
wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxNotifyEvent(commandType, winid),
m_col(-1),
m_row(-1),
m_model(NULL),
m_value(wxNullVariant),
m_editCancelled(false),
m_column(NULL)
{ }
wxDataViewEvent(const wxDataViewEvent& event)
: wxNotifyEvent(event),
m_col(event.m_col),
m_row(event.m_col),
m_model(event.m_model),
m_value(event.m_value),
m_editCancelled(event.m_editCancelled),
m_column(event.m_column)
{ }
int GetColumn() const { return m_col; }
void SetColumn( int col ) { m_col = col; }
int GetRow() const { return m_row; }
void SetRow( int row ) { m_row = row; }
wxDataViewModel* GetModel() const { return m_model; }
void SetModel( wxDataViewModel *model ) { m_model = model; }
const wxVariant &GetValue() const { return m_value; }
void SetValue( const wxVariant &value ) { m_value = value; }
// for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
wxDataViewColumn *GetDataViewColumn() { return m_column; }
// was label editing canceled? (for wxEVT_COMMAND_DATVIEW_END_LABEL_EDIT only)
bool IsEditCancelled() const { return m_editCancelled; }
void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; }
virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
protected:
int m_col;
int m_row;
wxDataViewModel *m_model;
wxVariant m_value;
bool m_editCancelled;
wxDataViewColumn *m_column;
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
};
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ROW_SELECTED, -1)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, -1)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
#define wxDataViewEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
#define EVT_DATAVIEW_ROW_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_SELECTED, id, fn)
#define EVT_DATAVIEW_ROW_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_ACTIVATED, id, fn)
#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
#if defined(wxUSE_GENERICDATAVIEWCTRL)
#include "wx/generic/dataview.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/dataview.h"
#elif defined(__WXMAC__)
// TODO
// #include "wx/mac/dataview.h"
#else
#include "wx/generic/dataview.h"
#endif
#endif // wxUSE_DATAVIEWCTRL
#endif
// _WX_DATAVIEW_H_BASE_

View File

@ -0,0 +1,112 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/datectrl.h
// Purpose: implements wxDatePickerCtrl
// Author: Vadim Zeitlin
// Modified by:
// Created: 2005-01-09
// RCS-ID: $Id: datectrl.h 37663 2006-02-21 22:14:31Z MR $
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATECTRL_H_
#define _WX_DATECTRL_H_
#include "wx/defs.h"
#if wxUSE_DATEPICKCTRL
#include "wx/control.h" // the base class
#include "wx/datetime.h"
#define wxDatePickerCtrlNameStr _T("datectrl")
// wxDatePickerCtrl styles
enum
{
// default style on this platform, either wxDP_SPIN or wxDP_DROPDOWN
wxDP_DEFAULT = 0,
// a spin control-like date picker (not supported in generic version)
wxDP_SPIN = 1,
// a combobox-like date picker (not supported in mac version)
wxDP_DROPDOWN = 2,
// always show century in the default date display (otherwise it depends on
// the system date format which may include the century or not)
wxDP_SHOWCENTURY = 4,
// allow not having any valid date in the control (by default it always has
// some date, today initially if no valid date specified in ctor)
wxDP_ALLOWNONE = 8
};
// ----------------------------------------------------------------------------
// wxDatePickerCtrl: allow the user to enter the date
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxControl
{
public:
/*
The derived classes should implement ctor and Create() method with the
following signature:
bool Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr);
*/
// set/get the date
virtual void SetValue(const wxDateTime& dt) = 0;
virtual wxDateTime GetValue() const = 0;
// set/get the allowed valid range for the dates, if either/both of them
// are invalid, there is no corresponding limit and if neither is set
// GetRange() returns false
virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0;
virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0;
};
#if defined(__WXPALMOS__)
#include "wx/palmos/datectrl.h"
#define wxHAS_NATIVE_DATEPICKCTRL
#elif defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/datectrl.h"
#define wxHAS_NATIVE_DATEPICKCTRL
#else
#include "wx/generic/datectrl.h"
class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlGeneric
{
public:
wxDatePickerCtrl() { }
wxDatePickerCtrl(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr)
: wxDatePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name)
{
}
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl)
};
#endif
#endif // wxUSE_DATEPICKCTRL
#endif // _WX_DATECTRL_H_

View File

@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dateevt.h
// Purpose: declares wxDateEvent class
// Author: Vadim Zeitlin
// Modified by:
// Created: 2005-01-10
// RCS-ID: $Id: dateevt.h 39637 2006-06-08 18:27:44Z RD $
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATEEVT_H_
#define _WX_DATEEVT_H_
#include "wx/event.h"
#include "wx/datetime.h"
#include "wx/window.h"
// ----------------------------------------------------------------------------
// wxDateEvent: used by wxCalendarCtrl and wxDatePickerCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDateEvent : public wxCommandEvent
{
public:
wxDateEvent() { }
wxDateEvent(wxWindow *win, const wxDateTime& dt, wxEventType type)
: wxCommandEvent(type, win->GetId()),
m_date(dt)
{
SetEventObject(win);
}
const wxDateTime& GetDate() const { return m_date; }
void SetDate(const wxDateTime &date) { m_date = date; }
// default copy ctor, assignment operator and dtor are ok
virtual wxEvent *Clone() const { return new wxDateEvent(*this); }
private:
wxDateTime m_date;
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDateEvent)
};
// ----------------------------------------------------------------------------
// event types and macros for handling them
// ----------------------------------------------------------------------------
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_DATE_CHANGED, 1101)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxDateEventFunction)(wxDateEvent&);
#define wxDateEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDateEventFunction, &func)
#define EVT_DATE_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_DATE_CHANGED, id, wxDateEventHandler(fn))
#ifdef _WX_DEFINE_DATE_EVENTS_
DEFINE_EVENT_TYPE(wxEVT_DATE_CHANGED)
IMPLEMENT_DYNAMIC_CLASS(wxDateEvent, wxCommandEvent)
#endif
#endif // _WX_DATEEVT_H_

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
/////////////////////////////////////////////////////////////////////////////
// Name: datstrm.h
// Purpose: Data stream classes
// Author: Guilhem Lavaux
// Modified by: Mickael Gilabert
// Created: 28/06/1998
// RCS-ID: $Id: datstrm.h 38576 2006-04-05 16:10:08Z VZ $
// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATSTREAM_H_
#define _WX_DATSTREAM_H_
#include "wx/stream.h"
#include "wx/longlong.h"
#include "wx/convauto.h"
#if wxUSE_STREAMS
class WXDLLIMPEXP_BASE wxDataInputStream
{
public:
#if wxUSE_UNICODE
wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvAuto());
#else
wxDataInputStream(wxInputStream& s);
#endif
~wxDataInputStream();
bool IsOk() { return m_input->IsOk(); }
#if wxHAS_INT64
wxUint64 Read64();
#endif
#if wxUSE_LONGLONG
wxLongLong ReadLL();
#endif
wxUint32 Read32();
wxUint16 Read16();
wxUint8 Read8();
double ReadDouble();
wxString ReadString();
#if wxHAS_INT64
void Read64(wxUint64 *buffer, size_t size);
void Read64(wxInt64 *buffer, size_t size);
#endif
#if defined(wxLongLong_t) && wxUSE_LONGLONG
void Read64(wxULongLong *buffer, size_t size);
void Read64(wxLongLong *buffer, size_t size);
#endif
#if wxUSE_LONGLONG
void ReadLL(wxULongLong *buffer, size_t size);
void ReadLL(wxLongLong *buffer, size_t size);
#endif
void Read32(wxUint32 *buffer, size_t size);
void Read16(wxUint16 *buffer, size_t size);
void Read8(wxUint8 *buffer, size_t size);
void ReadDouble(double *buffer, size_t size);
wxDataInputStream& operator>>(wxString& s);
wxDataInputStream& operator>>(wxInt8& c);
wxDataInputStream& operator>>(wxInt16& i);
wxDataInputStream& operator>>(wxInt32& i);
wxDataInputStream& operator>>(wxUint8& c);
wxDataInputStream& operator>>(wxUint16& i);
wxDataInputStream& operator>>(wxUint32& i);
#if wxHAS_INT64
wxDataInputStream& operator>>(wxUint64& i);
wxDataInputStream& operator>>(wxInt64& i);
#endif
#if defined(wxLongLong_t) && wxUSE_LONGLONG
wxDataInputStream& operator>>(wxULongLong& i);
wxDataInputStream& operator>>(wxLongLong& i);
#endif
wxDataInputStream& operator>>(double& i);
wxDataInputStream& operator>>(float& f);
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
protected:
wxInputStream *m_input;
bool m_be_order;
#if wxUSE_UNICODE
wxMBConv *m_conv;
#endif
DECLARE_NO_COPY_CLASS(wxDataInputStream)
};
class WXDLLIMPEXP_BASE wxDataOutputStream
{
public:
#if wxUSE_UNICODE
wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvAuto());
#else
wxDataOutputStream(wxOutputStream& s);
#endif
~wxDataOutputStream();
bool IsOk() { return m_output->IsOk(); }
#if wxHAS_INT64
void Write64(wxUint64 i);
void Write64(wxInt64 i);
#endif
#if wxUSE_LONGLONG
void WriteLL(const wxLongLong &ll);
void WriteLL(const wxULongLong &ll);
#endif
void Write32(wxUint32 i);
void Write16(wxUint16 i);
void Write8(wxUint8 i);
void WriteDouble(double d);
void WriteString(const wxString& string);
#if wxHAS_INT64
void Write64(const wxUint64 *buffer, size_t size);
void Write64(const wxInt64 *buffer, size_t size);
#endif
#if defined(wxLongLong_t) && wxUSE_LONGLONG
void Write64(const wxULongLong *buffer, size_t size);
void Write64(const wxLongLong *buffer, size_t size);
#endif
#if wxUSE_LONGLONG
void WriteLL(const wxULongLong *buffer, size_t size);
void WriteLL(const wxLongLong *buffer, size_t size);
#endif
void Write32(const wxUint32 *buffer, size_t size);
void Write16(const wxUint16 *buffer, size_t size);
void Write8(const wxUint8 *buffer, size_t size);
void WriteDouble(const double *buffer, size_t size);
wxDataOutputStream& operator<<(const wxChar *string);
wxDataOutputStream& operator<<(const wxString& string);
wxDataOutputStream& operator<<(wxInt8 c);
wxDataOutputStream& operator<<(wxInt16 i);
wxDataOutputStream& operator<<(wxInt32 i);
wxDataOutputStream& operator<<(wxUint8 c);
wxDataOutputStream& operator<<(wxUint16 i);
wxDataOutputStream& operator<<(wxUint32 i);
#if wxHAS_INT64
wxDataOutputStream& operator<<(wxUint64 i);
wxDataOutputStream& operator<<(wxInt64 i);
#endif
#if defined(wxLongLong_t) && wxUSE_LONGLONG
wxDataOutputStream& operator<<(const wxULongLong &i);
wxDataOutputStream& operator<<(const wxLongLong &i);
#endif
wxDataOutputStream& operator<<(double f);
wxDataOutputStream& operator<<(float f);
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
protected:
wxOutputStream *m_output;
bool m_be_order;
#if wxUSE_UNICODE
wxMBConv *m_conv;
#endif
DECLARE_NO_COPY_CLASS(wxDataOutputStream)
};
#endif
// wxUSE_STREAMS
#endif
// _WX_DATSTREAM_H_

View File

@ -0,0 +1,853 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/db.h
// Purpose: Header file wxDb class. The wxDb class represents a connection
// to an ODBC data source. The wxDb class allows operations on the data
// source such as opening and closing the data source.
// Author: Doug Card
// Modified by: George Tasker
// Bart Jourquin
// Mark Johnson, wxWindows@mj10777.de
// Mods: Dec, 1998:
// -Added support for SQL statement logging and database cataloging
// April, 1999
// -Added QUERY_ONLY mode support to reduce default number of cursors
// -Added additional SQL logging code
// -Added DEBUG-ONLY tracking of Ctable objects to detect orphaned DB connections
// -Set ODBC option to only read committed writes to the DB so all
// databases operate the same in that respect
//
// Created: 9.96
// RCS-ID: $Id: db.h 56697 2008-11-07 22:45:47Z VZ $
// Copyright: (c) 1996 Remstar International, Inc.
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DB_H_
#define _WX_DB_H_
// BJO 20000503: introduce new GetColumns members which are more database independent and
// return columns in the order they were created
#define OLD_GETCOLUMNS 1
#define EXPERIMENTAL_WXDB_FUNCTIONS 1
#include "wx/defs.h"
#include "wx/string.h"
#if defined(__VISUALC__)
// we need to include standard Windows headers but we can't include
// <windows.h> directly when using MFC because it includes it itself in a
// different manner
#if wxUSE_MFC
#include <afxwin.h>
#else // !wxUSE_MFC
#include "wx/msw/wrapwin.h"
#endif // wxUSE_MFC/!wxUSE_MFC
// If you use the wxDbCreateDataSource() function with MSW/VC6,
// you cannot use the iODBC headers, you must use the VC headers,
// plus the odbcinst.h header - gt Nov 2 2000
//
// Must add "odbccp32.lib" in \wx2\wxWidgets\src\makevc.env to the WINLIBS= line
//
#include "sql.h"
#include "sqlext.h"
//#if wxUSE_UNICODE
// #include <sqlucode.h>
//#endif
#include "odbcinst.h"
#else
#if defined(__WINDOWS__) && ( defined(HAVE_W32API_H) || defined(__BORLANDC__) || defined (__DMC__))
#include "wx/msw/wrapwin.h"
#endif
extern "C" {
#if defined(wxUSE_BUILTIN_IODBC) && wxUSE_BUILTIN_IODBC
// Use the ones from the library
#include "wx/isql.h"
#include "wx/isqlext.h"
// Not available in v2.x of iODBC
#ifndef __WXMSW__
#if wxUSE_UNICODE
typedef wxChar SQLTCHAR;
#else
typedef UCHAR SQLTCHAR;
#endif
#endif
#else // !wxUSE_BUILTIN_IODBC
// SQL headers define BOOL if it's not defined yet but BOOL is also
// defined in many other places on other systems (Motif, at least on
// OpenVMS; Cocoa and X11) so prevent the problem by defining it before
// including these headers
#ifndef BOOL
#define BOOL int
#include <sql.h>
#include <sqlext.h>
#undef BOOL
#else
#include <sql.h>
#include <sqlext.h>
#endif
#endif // wxUSE_BUILTIN_IODBC/!wxUSE_BUILTIN_IODBC
}
#endif
#if wxUSE_UNICODE
#define SQL_C_WXCHAR SQL_C_WCHAR
#else
#define SQL_C_WXCHAR SQL_C_CHAR
#endif
#ifdef __DIGITALMARS__
#if wxUSE_UNICODE
typedef wxChar SQLTCHAR;
#else
typedef UCHAR SQLTCHAR;
#endif
#endif
typedef float SFLOAT;
typedef double SDOUBLE;
typedef unsigned int UINT;
#define ULONG UDWORD
#ifndef wxODBC_FWD_ONLY_CURSORS
#define wxODBC_FWD_ONLY_CURSORS 1
#endif
enum enumDummy {enumDum1};
#ifndef SQL_C_BOOLEAN
#define SQL_C_BOOLEAN(datatype) (sizeof(datatype) == 1 ? SQL_C_UTINYINT : (sizeof(datatype) == 2 ? SQL_C_USHORT : SQL_C_ULONG))
#endif
#ifndef SQL_C_ENUM
#define SQL_C_ENUM (sizeof(enumDummy) == 2 ? SQL_C_USHORT : SQL_C_ULONG)
#endif
// NOTE: If SQL_C_BLOB is defined, and it is not SQL_C_BINARY, iODBC 2.x
// may not function correctly. Likely best to use SQL_C_BINARY direct
#ifndef SQL_C_BLOB
#ifdef SQL_C_BINARY
#define SQL_C_BLOB SQL_C_BINARY
#endif
#endif
#ifndef _WIN64
#ifndef SQLLEN
#define SQLLEN SQLINTEGER
#endif
#ifndef SQLULEN
#define SQLULEN SQLUINTEGER
#endif
#endif
const int wxDB_PATH_MAX = 254;
extern WXDLLIMPEXP_DATA_ODBC(wxChar const *) SQL_LOG_FILENAME;
extern WXDLLIMPEXP_DATA_ODBC(wxChar const *) SQL_CATALOG_FILENAME;
// Database Globals
const int DB_TYPE_NAME_LEN = 40;
const int DB_MAX_STATEMENT_LEN = 4096;
const int DB_MAX_WHERE_CLAUSE_LEN = 2048;
const int DB_MAX_ERROR_MSG_LEN = 512;
const int DB_MAX_ERROR_HISTORY = 5;
const int DB_MAX_TABLE_NAME_LEN = 128;
const int DB_MAX_COLUMN_NAME_LEN = 128;
const int DB_DATA_TYPE_VARCHAR = 1;
const int DB_DATA_TYPE_INTEGER = 2;
const int DB_DATA_TYPE_FLOAT = 3;
const int DB_DATA_TYPE_DATE = 4;
const int DB_DATA_TYPE_BLOB = 5;
const int DB_DATA_TYPE_MEMO = 6;
const int DB_SELECT_KEYFIELDS = 1;
const int DB_SELECT_WHERE = 2;
const int DB_SELECT_MATCHING = 3;
const int DB_SELECT_STATEMENT = 4;
const int DB_UPD_KEYFIELDS = 1;
const int DB_UPD_WHERE = 2;
const int DB_DEL_KEYFIELDS = 1;
const int DB_DEL_WHERE = 2;
const int DB_DEL_MATCHING = 3;
const int DB_WHERE_KEYFIELDS = 1;
const int DB_WHERE_MATCHING = 2;
const int DB_GRANT_SELECT = 1;
const int DB_GRANT_INSERT = 2;
const int DB_GRANT_UPDATE = 4;
const int DB_GRANT_DELETE = 8;
const int DB_GRANT_ALL = DB_GRANT_SELECT | DB_GRANT_INSERT | DB_GRANT_UPDATE | DB_GRANT_DELETE;
// ODBC Error codes (derived from ODBC SqlState codes)
enum wxODBC_ERRORS
{
DB_FAILURE = 0,
DB_SUCCESS = 1,
DB_ERR_NOT_IN_USE,
DB_ERR_GENERAL_WARNING, // SqlState = '01000'
DB_ERR_DISCONNECT_ERROR, // SqlState = '01002'
DB_ERR_DATA_TRUNCATED, // SqlState = '01004'
DB_ERR_PRIV_NOT_REVOKED, // SqlState = '01006'
DB_ERR_INVALID_CONN_STR_ATTR, // SqlState = '01S00'
DB_ERR_ERROR_IN_ROW, // SqlState = '01S01'
DB_ERR_OPTION_VALUE_CHANGED, // SqlState = '01S02'
DB_ERR_NO_ROWS_UPD_OR_DEL, // SqlState = '01S03'
DB_ERR_MULTI_ROWS_UPD_OR_DEL, // SqlState = '01S04'
DB_ERR_WRONG_NO_OF_PARAMS, // SqlState = '07001'
DB_ERR_DATA_TYPE_ATTR_VIOL, // SqlState = '07006'
DB_ERR_UNABLE_TO_CONNECT, // SqlState = '08001'
DB_ERR_CONNECTION_IN_USE, // SqlState = '08002'
DB_ERR_CONNECTION_NOT_OPEN, // SqlState = '08003'
DB_ERR_REJECTED_CONNECTION, // SqlState = '08004'
DB_ERR_CONN_FAIL_IN_TRANS, // SqlState = '08007'
DB_ERR_COMM_LINK_FAILURE, // SqlState = '08S01'
DB_ERR_INSERT_VALUE_LIST_MISMATCH, // SqlState = '21S01'
DB_ERR_DERIVED_TABLE_MISMATCH, // SqlState = '21S02'
DB_ERR_STRING_RIGHT_TRUNC, // SqlState = '22001'
DB_ERR_NUMERIC_VALUE_OUT_OF_RNG, // SqlState = '22003'
DB_ERR_ERROR_IN_ASSIGNMENT, // SqlState = '22005'
DB_ERR_DATETIME_FLD_OVERFLOW, // SqlState = '22008'
DB_ERR_DIVIDE_BY_ZERO, // SqlState = '22012'
DB_ERR_STR_DATA_LENGTH_MISMATCH, // SqlState = '22026'
DB_ERR_INTEGRITY_CONSTRAINT_VIOL, // SqlState = '23000'
DB_ERR_INVALID_CURSOR_STATE, // SqlState = '24000'
DB_ERR_INVALID_TRANS_STATE, // SqlState = '25000'
DB_ERR_INVALID_AUTH_SPEC, // SqlState = '28000'
DB_ERR_INVALID_CURSOR_NAME, // SqlState = '34000'
DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL, // SqlState = '37000'
DB_ERR_DUPLICATE_CURSOR_NAME, // SqlState = '3C000'
DB_ERR_SERIALIZATION_FAILURE, // SqlState = '40001'
DB_ERR_SYNTAX_ERROR_OR_ACCESS_VIOL2, // SqlState = '42000'
DB_ERR_OPERATION_ABORTED, // SqlState = '70100'
DB_ERR_UNSUPPORTED_FUNCTION, // SqlState = 'IM001'
DB_ERR_NO_DATA_SOURCE, // SqlState = 'IM002'
DB_ERR_DRIVER_LOAD_ERROR, // SqlState = 'IM003'
DB_ERR_SQLALLOCENV_FAILED, // SqlState = 'IM004'
DB_ERR_SQLALLOCCONNECT_FAILED, // SqlState = 'IM005'
DB_ERR_SQLSETCONNECTOPTION_FAILED, // SqlState = 'IM006'
DB_ERR_NO_DATA_SOURCE_DLG_PROHIB, // SqlState = 'IM007'
DB_ERR_DIALOG_FAILED, // SqlState = 'IM008'
DB_ERR_UNABLE_TO_LOAD_TRANSLATION_DLL, // SqlState = 'IM009'
DB_ERR_DATA_SOURCE_NAME_TOO_LONG, // SqlState = 'IM010'
DB_ERR_DRIVER_NAME_TOO_LONG, // SqlState = 'IM011'
DB_ERR_DRIVER_KEYWORD_SYNTAX_ERROR, // SqlState = 'IM012'
DB_ERR_TRACE_FILE_ERROR, // SqlState = 'IM013'
DB_ERR_TABLE_OR_VIEW_ALREADY_EXISTS, // SqlState = 'S0001'
DB_ERR_TABLE_NOT_FOUND, // SqlState = 'S0002'
DB_ERR_INDEX_ALREADY_EXISTS, // SqlState = 'S0011'
DB_ERR_INDEX_NOT_FOUND, // SqlState = 'S0012'
DB_ERR_COLUMN_ALREADY_EXISTS, // SqlState = 'S0021'
DB_ERR_COLUMN_NOT_FOUND, // SqlState = 'S0022'
DB_ERR_NO_DEFAULT_FOR_COLUMN, // SqlState = 'S0023'
DB_ERR_GENERAL_ERROR, // SqlState = 'S1000'
DB_ERR_MEMORY_ALLOCATION_FAILURE, // SqlState = 'S1001'
DB_ERR_INVALID_COLUMN_NUMBER, // SqlState = 'S1002'
DB_ERR_PROGRAM_TYPE_OUT_OF_RANGE, // SqlState = 'S1003'
DB_ERR_SQL_DATA_TYPE_OUT_OF_RANGE, // SqlState = 'S1004'
DB_ERR_OPERATION_CANCELLED, // SqlState = 'S1008'
DB_ERR_INVALID_ARGUMENT_VALUE, // SqlState = 'S1009'
DB_ERR_FUNCTION_SEQUENCE_ERROR, // SqlState = 'S1010'
DB_ERR_OPERATION_INVALID_AT_THIS_TIME, // SqlState = 'S1011'
DB_ERR_INVALID_TRANS_OPERATION_CODE, // SqlState = 'S1012'
DB_ERR_NO_CURSOR_NAME_AVAIL, // SqlState = 'S1015'
DB_ERR_INVALID_STR_OR_BUF_LEN, // SqlState = 'S1090'
DB_ERR_DESCRIPTOR_TYPE_OUT_OF_RANGE, // SqlState = 'S1091'
DB_ERR_OPTION_TYPE_OUT_OF_RANGE, // SqlState = 'S1092'
DB_ERR_INVALID_PARAM_NO, // SqlState = 'S1093'
DB_ERR_INVALID_SCALE_VALUE, // SqlState = 'S1094'
DB_ERR_FUNCTION_TYPE_OUT_OF_RANGE, // SqlState = 'S1095'
DB_ERR_INF_TYPE_OUT_OF_RANGE, // SqlState = 'S1096'
DB_ERR_COLUMN_TYPE_OUT_OF_RANGE, // SqlState = 'S1097'
DB_ERR_SCOPE_TYPE_OUT_OF_RANGE, // SqlState = 'S1098'
DB_ERR_NULLABLE_TYPE_OUT_OF_RANGE, // SqlState = 'S1099'
DB_ERR_UNIQUENESS_OPTION_TYPE_OUT_OF_RANGE, // SqlState = 'S1100'
DB_ERR_ACCURACY_OPTION_TYPE_OUT_OF_RANGE, // SqlState = 'S1101'
DB_ERR_DIRECTION_OPTION_OUT_OF_RANGE, // SqlState = 'S1103'
DB_ERR_INVALID_PRECISION_VALUE, // SqlState = 'S1104'
DB_ERR_INVALID_PARAM_TYPE, // SqlState = 'S1105'
DB_ERR_FETCH_TYPE_OUT_OF_RANGE, // SqlState = 'S1106'
DB_ERR_ROW_VALUE_OUT_OF_RANGE, // SqlState = 'S1107'
DB_ERR_CONCURRENCY_OPTION_OUT_OF_RANGE, // SqlState = 'S1108'
DB_ERR_INVALID_CURSOR_POSITION, // SqlState = 'S1109'
DB_ERR_INVALID_DRIVER_COMPLETION, // SqlState = 'S1110'
DB_ERR_INVALID_BOOKMARK_VALUE, // SqlState = 'S1111'
DB_ERR_DRIVER_NOT_CAPABLE, // SqlState = 'S1C00'
DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
};
#ifndef MAXNAME
#define MAXNAME 31
#endif
#ifndef SQL_MAX_AUTHSTR_LEN
// There does not seem to be a standard for this, so I am
// defaulting to the value that MS uses
#define SQL_MAX_AUTHSTR_LEN MAXNAME
#endif
#ifndef SQL_MAX_CONNECTSTR_LEN
// There does not seem to be a standard for this, so I am
// defaulting to the value that MS recommends
#define SQL_MAX_CONNECTSTR_LEN 1024
#endif
class WXDLLIMPEXP_ODBC wxDbConnectInf
{
private:
bool freeHenvOnDestroy;
bool useConnectionStr;
public:
HENV Henv;
wxChar Dsn[SQL_MAX_DSN_LENGTH+1]; // Data Source Name
wxChar Uid[SQL_MAX_USER_NAME_LEN+1]; // User ID
wxChar AuthStr[SQL_MAX_AUTHSTR_LEN+1]; // Authorization string (password)
wxChar ConnectionStr[SQL_MAX_CONNECTSTR_LEN+1]; // Connection string (password)
wxString Description; // Not sure what the max length is
wxString FileType; // Not sure what the max length is
// Optionals needed for some databases like dBase
wxString DefaultDir; // Directory that db file resides in
public:
wxDbConnectInf();
wxDbConnectInf(HENV henv, const wxString &dsn, const wxString &userID=wxEmptyString,
const wxString &password=wxEmptyString, const wxString &defaultDir=wxEmptyString,
const wxString &description=wxEmptyString, const wxString &fileType=wxEmptyString);
~wxDbConnectInf();
bool Initialize();
bool AllocHenv();
void FreeHenv();
// Accessors
const HENV &GetHenv() { return Henv; }
const wxChar *GetDsn() { return Dsn; }
const wxChar *GetUid() { return Uid; }
const wxChar *GetUserID() { return Uid; }
const wxChar *GetAuthStr() { return AuthStr; }
const wxChar *GetPassword() { return AuthStr; }
const wxChar *GetConnectionStr() { return ConnectionStr; }
bool UseConnectionStr() { return useConnectionStr; }
const wxChar *GetDescription() { return Description; }
const wxChar *GetFileType() { return FileType; }
const wxChar *GetDefaultDir() { return DefaultDir; }
void SetHenv(const HENV henv) { Henv = henv; }
void SetDsn(const wxString &dsn);
void SetUserID(const wxString &userID);
void SetUid(const wxString &uid) { SetUserID(uid); }
void SetPassword(const wxString &password);
void SetAuthStr(const wxString &authstr) { SetPassword(authstr); }
void SetConnectionStr(const wxString &connectStr);
void SetDescription(const wxString &desc) { Description = desc; }
void SetFileType(const wxString &fileType) { FileType = fileType; }
void SetDefaultDir(const wxString &defDir) { DefaultDir = defDir; }
}; // class wxDbConnectInf
struct WXDLLIMPEXP_ODBC wxDbSqlTypeInfo
{
wxString TypeName;
SWORD FsqlType;
long Precision;
short CaseSensitive;
short MaximumScale;
};
class WXDLLIMPEXP_ODBC wxDbColFor
{
public:
wxString s_Field; // Formatted String for Output
wxString s_Format[7]; // Formatted Objects - TIMESTAMP has the biggest (7)
wxString s_Amount[7]; // Formatted Objects - amount of things that can be formatted
int i_Amount[7]; // Formatted Objects - TT MM YYYY HH MM SS m
int i_Nation; // 0 = timestamp , 1=EU, 2=UK, 3=International, 4=US
int i_dbDataType; // conversion of the 'sqlDataType' to the generic data type used by these classes
SWORD i_sqlDataType;
wxDbColFor();
~wxDbColFor(){}
void Initialize();
int Format(int Nation, int dbDataType, SWORD sqlDataType, short columnLength, short decimalDigits);
};
class WXDLLIMPEXP_ODBC wxDbColInf
{
public:
wxChar catalog[128+1];
wxChar schema[128+1];
wxChar tableName[DB_MAX_TABLE_NAME_LEN+1];
wxChar colName[DB_MAX_COLUMN_NAME_LEN+1];
SWORD sqlDataType;
wxChar typeName[128+1];
SWORD columnLength;
SWORD bufferSize;
short decimalDigits;
short numPrecRadix;
short nullable;
wxChar remarks[254+1];
int dbDataType; // conversion of the 'sqlDataType' to the generic data type used by these classes
// mj10777.19991224 : new
int PkCol; // Primary key column 0=No; 1= First Key, 2 = Second Key etc.
wxChar PkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Tables that use this PKey as a FKey
int FkCol; // Foreign key column 0=No; 1= First Key, 2 = Second Key etc.
wxChar FkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Foreign key table name
wxDbColFor *pColFor; // How should this columns be formatted
wxDbColInf();
~wxDbColInf();
bool Initialize();
};
class WXDLLIMPEXP_ODBC wxDbTableInf // Description of a Table
{
public:
wxChar tableName[DB_MAX_TABLE_NAME_LEN+1];
wxChar tableType[254+1]; // "TABLE" or "SYSTEM TABLE" etc.
wxChar tableRemarks[254+1];
UWORD numCols; // How many Columns does this Table have: GetColumnCount(..);
wxDbColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
wxDbTableInf();
~wxDbTableInf();
bool Initialize();
};
class WXDLLIMPEXP_ODBC wxDbInf // Description of a Database
{
public:
wxChar catalog[128+1];
wxChar schema[128+1];
int numTables; // How many tables does this database have
wxDbTableInf *pTableInf; // pTableInf = new wxDbTableInf[numTables];
wxDbInf();
~wxDbInf();
bool Initialize();
};
enum wxDbSqlLogState
{
sqlLogOFF,
sqlLogON
};
// These are the databases currently tested and working with these classes
// See the comments in wxDb::Dbms() for exceptions/issues with
// each of these database engines
enum wxDBMS
{
dbmsUNIDENTIFIED,
dbmsORACLE,
dbmsSYBASE_ASA, // Adaptive Server Anywhere
dbmsSYBASE_ASE, // Adaptive Server Enterprise
dbmsMS_SQL_SERVER,
dbmsMY_SQL,
dbmsPOSTGRES,
dbmsACCESS,
dbmsDBASE,
dbmsINFORMIX,
dbmsVIRTUOSO,
dbmsDB2,
dbmsINTERBASE,
dbmsPERVASIVE_SQL,
dbmsXBASE_SEQUITER,
dbmsFIREBIRD,
dbmsMAXDB,
dbmsFuture1,
dbmsFuture2,
dbmsFuture3,
dbmsFuture4,
dbmsFuture5,
dbmsFuture6,
dbmsFuture7,
dbmsFuture8,
dbmsFuture9,
dbmsFuture10
};
// The wxDb::errorList is copied to this variable when the wxDb object
// is closed. This way, the error list is still available after the
// database object is closed. This is necessary if the database
// connection fails so the calling application can show the operator
// why the connection failed. Note: as each wxDb object is closed, it
// will overwrite the errors of the previously destroyed wxDb object in
// this variable.
extern WXDLLIMPEXP_DATA_ODBC(wxChar)
DBerrorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN+1];
class WXDLLIMPEXP_ODBC wxDb
{
private:
bool dbIsOpen;
bool dbIsCached; // Was connection created by caching functions
bool dbOpenedWithConnectionString; // Was the database connection opened with a connection string
wxString dsn; // Data source name
wxString uid; // User ID
wxString authStr; // Authorization string (password)
wxString inConnectionStr; // Connection string used to connect to the database
wxString outConnectionStr;// Connection string returned by the database when a connection is successfully opened
FILE *fpSqlLog; // Sql Log file pointer
wxDbSqlLogState sqlLogState; // On or Off
bool fwdOnlyCursors;
wxDBMS dbmsType; // Type of datasource - i.e. Oracle, dBase, SQLServer, etc
// Private member functions
bool getDbInfo(bool failOnDataTypeUnsupported=true);
bool getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo);
bool setConnectionOptions(void);
void logError(const wxString &errMsg, const wxString &SQLState);
const wxChar *convertUserID(const wxChar *userID, wxString &UserID);
bool determineDataTypes(bool failOnDataTypeUnsupported);
void initialize();
bool open(bool failOnDataTypeUnsupported=true);
#if !wxODBC_BACKWARD_COMPATABILITY
// ODBC handles
HENV henv; // ODBC Environment handle
HDBC hdbc; // ODBC DB Connection handle
HSTMT hstmt; // ODBC Statement handle
//Error reporting mode
bool silent;
// Number of Ctable objects connected to this db object. FOR INTERNAL USE ONLY!!!
unsigned int nTables;
// Information about logical data types VARCHAR, INTEGER, FLOAT and DATE.
//
// This information is obtained from the ODBC driver by use of the
// SQLGetTypeInfo() function. The key piece of information is the
// type name the data source uses for each logical data type.
// e.g. VARCHAR; Oracle calls it VARCHAR2.
wxDbSqlTypeInfo typeInfVarchar;
wxDbSqlTypeInfo typeInfInteger;
wxDbSqlTypeInfo typeInfFloat;
wxDbSqlTypeInfo typeInfDate;
wxDbSqlTypeInfo typeInfBlob;
wxDbSqlTypeInfo typeInfMemo;
#endif
public:
void setCached(bool cached) { dbIsCached = cached; } // This function must only be called by wxDbGetConnection() and wxDbCloseConnections!!!
bool IsCached() { return dbIsCached; }
bool GetDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo)
{ return getDataTypeInfo(fSqlType, structSQLTypeInfo); }
#if wxODBC_BACKWARD_COMPATABILITY
// ODBC handles
HENV henv; // ODBC Environment handle
HDBC hdbc; // ODBC DB Connection handle
HSTMT hstmt; // ODBC Statement handle
//Error reporting mode
bool silent;
// Number of Ctable objects connected to this db object. FOR INTERNAL USE ONLY!!!
unsigned int nTables;
#endif
// The following structure contains database information gathered from the
// datasource when the datasource is first opened.
struct
{
wxChar dbmsName[40]; // Name of the dbms product
wxChar dbmsVer[64]; // Version # of the dbms product
wxChar driverName[40]; // Driver name
wxChar odbcVer[60]; // ODBC version of the driver
wxChar drvMgrOdbcVer[60]; // ODBC version of the driver manager
wxChar driverVer[60]; // Driver version
wxChar serverName[80]; // Server Name, typically a connect string
wxChar databaseName[128]; // Database filename
wxChar outerJoins[2]; // Indicates whether the data source supports outer joins
wxChar procedureSupport[2]; // Indicates whether the data source supports stored procedures
wxChar accessibleTables[2]; // Indicates whether the data source only reports accessible tables in SQLTables.
UWORD maxConnections; // Maximum # of connections the data source supports
UWORD maxStmts; // Maximum # of HSTMTs per HDBC
UWORD apiConfLvl; // ODBC API conformance level
UWORD cliConfLvl; // Indicates whether the data source is SAG compliant
UWORD sqlConfLvl; // SQL conformance level
UWORD cursorCommitBehavior; // Indicates how cursors are affected by a db commit
UWORD cursorRollbackBehavior; // Indicates how cursors are affected by a db rollback
UWORD supportNotNullClause; // Indicates if data source supports NOT NULL clause
wxChar supportIEF[2]; // Integrity Enhancement Facility (Referential Integrity)
UDWORD txnIsolation; // Default transaction isolation level supported by the driver
UDWORD txnIsolationOptions; // Transaction isolation level options available
UDWORD fetchDirections; // Fetch directions supported
UDWORD lockTypes; // Lock types supported in SQLSetPos
UDWORD posOperations; // Position operations supported in SQLSetPos
UDWORD posStmts; // Position statements supported
UDWORD scrollConcurrency; // Concurrency control options supported for scrollable cursors
UDWORD scrollOptions; // Scroll Options supported for scrollable cursors
UDWORD staticSensitivity; // Indicates if additions, deletions and updates can be detected
UWORD txnCapable; // Indicates if the data source supports transactions
UDWORD loginTimeout; // Number seconds to wait for a login request
} dbInf;
// ODBC Error Inf.
SWORD cbErrorMsg;
int DB_STATUS;
#ifdef __VMS
// The DECC compiler chokes when in db.cpp the array is accessed outside
// its bounds. Maybe this change should also applied for other platforms.
wxChar errorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN+1];
#else
wxChar errorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
#endif
wxChar errorMsg[SQL_MAX_MESSAGE_LENGTH];
SQLINTEGER nativeError;
wxChar sqlState[20];
#if wxODBC_BACKWARD_COMPATABILITY
// Information about logical data types VARCHAR, INTEGER, FLOAT and DATE.
//
// This information is obtained from the ODBC driver by use of the
// SQLGetTypeInfo() function. The key piece of information is the
// type name the data source uses for each logical data type.
// e.g. VARCHAR; Oracle calls it VARCHAR2.
wxDbSqlTypeInfo typeInfVarchar;
wxDbSqlTypeInfo typeInfInteger;
wxDbSqlTypeInfo typeInfFloat;
wxDbSqlTypeInfo typeInfDate;
wxDbSqlTypeInfo typeInfBlob;
#endif
// Public member functions
wxDb(const HENV &aHenv, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
~wxDb();
// Data Source Name, User ID, Password and whether open should fail on data type not supported
bool Open(const wxString& inConnectStr, bool failOnDataTypeUnsupported=true);
///This version of Open will open the odbc source selection dialog. Cast a wxWindow::GetHandle() to SQLHWND to use.
bool Open(const wxString& inConnectStr, SQLHWND parentWnd, bool failOnDataTypeUnsupported=true);
bool Open(const wxString &Dsn, const wxString &Uid, const wxString &AuthStr, bool failOnDataTypeUnsupported=true);
bool Open(wxDbConnectInf *dbConnectInf, bool failOnDataTypeUnsupported=true);
bool Open(wxDb *copyDb); // pointer to a wxDb whose connection info should be copied rather than re-queried
void Close(void);
bool CommitTrans(void);
bool RollbackTrans(void);
bool DispAllErrors(HENV aHenv, HDBC aHdbc = SQL_NULL_HDBC, HSTMT aHstmt = SQL_NULL_HSTMT);
bool GetNextError(HENV aHenv, HDBC aHdbc = SQL_NULL_HDBC, HSTMT aHstmt = SQL_NULL_HSTMT);
void DispNextError(void);
bool CreateView(const wxString &viewName, const wxString &colList, const wxString &pSqlStmt, bool attemptDrop=true);
bool DropView(const wxString &viewName);
bool ExecSql(const wxString &pSqlStmt);
bool ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcols);
bool GetNext(void);
bool GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SQLLEN FAR *cbReturned);
bool Grant(int privileges, const wxString &tableName, const wxString &userList = wxT("PUBLIC"));
int TranslateSqlState(const wxString &SQLState);
wxDbInf *GetCatalog(const wxChar *userID=NULL);
bool Catalog(const wxChar *userID=NULL, const wxString &fileName=SQL_CATALOG_FILENAME);
int GetKeyFields(const wxString &tableName, wxDbColInf* colInf, UWORD noCols);
wxDbColInf *GetColumns(wxChar *tableName[], const wxChar *userID=NULL);
wxDbColInf *GetColumns(const wxString &tableName, UWORD *numCols, const wxChar *userID=NULL);
int GetColumnCount(const wxString &tableName, const wxChar *userID=NULL);
const wxChar *GetDatabaseName(void) {return dbInf.dbmsName;}
const wxString &GetDataSource(void) {return dsn;}
const wxString &GetDatasourceName(void){return dsn;}
const wxString &GetUsername(void) {return uid;}
const wxString &GetPassword(void) {return authStr;}
const wxString &GetConnectionInStr(void) {return inConnectionStr;}
const wxString &GetConnectionOutStr(void) {return outConnectionStr;}
bool IsOpen(void) {return dbIsOpen;}
bool OpenedWithConnectionString(void) {return dbOpenedWithConnectionString;}
HENV GetHENV(void) {return henv;}
HDBC GetHDBC(void) {return hdbc;}
HSTMT GetHSTMT(void) {return hstmt;}
int GetTableCount() {return nTables;} // number of tables using this connection
wxDbSqlTypeInfo GetTypeInfVarchar() {return typeInfVarchar;}
wxDbSqlTypeInfo GetTypeInfInteger() {return typeInfInteger;}
wxDbSqlTypeInfo GetTypeInfFloat() {return typeInfFloat;}
wxDbSqlTypeInfo GetTypeInfDate() {return typeInfDate;}
wxDbSqlTypeInfo GetTypeInfBlob() {return typeInfBlob;}
wxDbSqlTypeInfo GetTypeInfMemo() {return typeInfMemo;}
// tableName can refer to a table, view, alias or synonym
bool TableExists(const wxString &tableName, const wxChar *userID=NULL,
const wxString &tablePath=wxEmptyString);
bool TablePrivileges(const wxString &tableName, const wxString &priv,
const wxChar *userID=NULL, const wxChar *schema=NULL,
const wxString &path=wxEmptyString);
// These two functions return the table name or column name in a form ready
// for use in SQL statements. For example, if the datasource allows spaces
// in the table name or column name, the returned string will have the
// correct enclosing marks around the name to allow it to be properly
// included in a SQL statement
const wxString SQLTableName(const wxChar *tableName);
const wxString SQLColumnName(const wxChar *colName);
void LogError(const wxString &errMsg, const wxString &SQLState = wxEmptyString)
{ logError(errMsg, SQLState); }
void SetDebugErrorMessages(bool state) { silent = !state; }
bool SetSqlLogging(wxDbSqlLogState state, const wxString &filename = SQL_LOG_FILENAME,
bool append = false);
bool WriteSqlLog(const wxString &logMsg);
wxDBMS Dbms(void);
bool ModifyColumn(const wxString &tableName, const wxString &columnName,
int dataType, ULONG columnLength=0,
const wxString &optionalParam=wxEmptyString);
bool FwdOnlyCursors(void) {return fwdOnlyCursors;}
// return the string with all special SQL characters escaped
wxString EscapeSqlChars(const wxString& value);
// These two functions are provided strictly for use by wxDbTable.
// DO NOT USE THESE FUNCTIONS, OR MEMORY LEAKS MAY OCCUR
void incrementTableCount() { nTables++; return; }
void decrementTableCount() { nTables--; return; }
}; // wxDb
// This structure forms a node in a linked list. The linked list of "DbList" objects
// keeps track of allocated database connections. This allows the application to
// open more than one database connection through ODBC for multiple transaction support
// or for multiple database support.
struct wxDbList
{
wxDbList *PtrPrev; // Pointer to previous item in the list
wxString Dsn; // Data Source Name
wxString Uid; // User ID
wxString AuthStr; // Authorization string (password)
wxString ConnectionStr; // Connection string used instead of DSN
wxDb *PtrDb; // Pointer to the wxDb object
bool Free; // Is item free or in use?
wxDbList *PtrNext; // Pointer to next item in the list
};
#ifdef __WXDEBUG__
#include "wx/object.h"
class wxTablesInUse : public wxObject
{
public:
const wxChar *tableName;
ULONG tableID;
class wxDb *pDb;
}; // wxTablesInUse
#endif
// The following routines allow a user to get new database connections, free them
// for other code segments to use, or close all of them when the application has
// completed.
wxDb WXDLLIMPEXP_ODBC *wxDbGetConnection(wxDbConnectInf *pDbConfig, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
bool WXDLLIMPEXP_ODBC wxDbFreeConnection(wxDb *pDb);
void WXDLLIMPEXP_ODBC wxDbCloseConnections(void);
int WXDLLIMPEXP_ODBC wxDbConnectionsInUse(void);
// Writes a message to the wxLog window (stdout usually) when an internal error
// situation occurs. This function only works in DEBUG builds
const wxChar WXDLLIMPEXP_ODBC *
wxDbLogExtendedErrorMsg(const wxChar *userText,
wxDb *pDb,
const wxChar *ErrFile,
int ErrLine);
// This function sets the sql log state for all open wxDb objects
bool WXDLLIMPEXP_ODBC
wxDbSqlLog(wxDbSqlLogState state, const wxString &filename = SQL_LOG_FILENAME);
#if 0
// MSW/VC6 ONLY!!! Experimental
int WXDLLEXPORT wxDbCreateDataSource(const wxString &driverName, const wxString &dsn, const wxString &description=wxEmptyString,
bool sysDSN=false, const wxString &defDir=wxEmptyString, wxWindow *parent=NULL);
#endif
// This routine allows you to query a driver manager
// for a list of available datasources. Call this routine
// the first time using SQL_FETCH_FIRST. Continue to call it
// using SQL_FETCH_NEXT until you've exhausted the list.
bool WXDLLIMPEXP_ODBC
wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMaxLength, wxChar *DsDesc,
SWORD DsDescMaxLength, UWORD direction = SQL_FETCH_NEXT);
// Change this to 0 to remove use of all deprecated functions
#if wxODBC_BACKWARD_COMPATABILITY
//#################################################################################
//############### DEPRECATED functions for backward compatibility #################
//#################################################################################
// Backward compability structures/classes. This will eventually go away
const int DB_PATH_MAX = wxDB_PATH_MAX;
typedef wxDb wxDB;
typedef wxDbTableInf wxTableInf;
typedef wxDbColInf wxColInf;
typedef wxDbColInf CcolInf;
typedef wxDbColFor wxColFor;
typedef wxDbSqlTypeInfo SqlTypeInfo;
typedef wxDbSqlTypeInfo wxSqlTypeInfo;
typedef enum wxDbSqlLogState sqlLog;
typedef enum wxDbSqlLogState wxSqlLogState;
typedef enum wxDBMS dbms;
typedef enum wxDBMS DBMS;
typedef wxODBC_ERRORS ODBC_ERRORS;
typedef wxDbConnectInf DbStuff;
typedef wxDbList DbList;
#ifdef __WXDEBUG__
typedef wxTablesInUse CstructTablesInUse;
#endif
// Deprecated function names that are replaced by the function names listed above
wxDB WXDLLIMPEXP_ODBC
*GetDbConnection(DbStuff *pDbStuff, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
bool WXDLLIMPEXP_ODBC FreeDbConnection(wxDB *pDb);
void WXDLLIMPEXP_ODBC CloseDbConnections(void);
int WXDLLIMPEXP_ODBC NumberDbConnectionsInUse(void);
bool SqlLog(sqlLog state, const wxChar *filename = SQL_LOG_FILENAME);
bool WXDLLIMPEXP_ODBC
GetDataSource(HENV henv, char *Dsn, SWORD DsnMaxLength, char *DsDesc, SWORD DsDescMaxLength,
UWORD direction = SQL_FETCH_NEXT);
#endif // Deprecated structures/classes/functions
#endif // _WX_DB_H_

View File

@ -0,0 +1,177 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dbgrid.h
// Purpose: Displays a wxDbTable in a wxGrid.
// Author: Roger Gammans, Paul Gammans
// Modified by:
// Created:
// RCS-ID: $Id: dbgrid.h 41020 2006-09-05 20:47:48Z VZ $
// Copyright: (c) 1999 The Computer Surgery (roger@computer-surgery.co.uk)
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// Branched From : dbgrid.h,v 1.19 2001/03/28 11:16:01
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_DBGRID_H_
#define _WX_GENERIC_DBGRID_H_
#if wxUSE_ODBC
#if wxUSE_GRID
#include "wx/log.h"
#include "wx/dbtable.h"
#include "wx/dynarray.h"
#include "wx/grid.h"
#include "wx/dbkeyg.h"
#define wxGRID_VALUE_DBAUTO _T("dbauto")
WX_DECLARE_USER_EXPORTED_OBJARRAY(GenericKey,keyarray,WXDLLIMPEXP_DBGRID);
static const int wxUSE_QUERY = -1;
class WXDLLIMPEXP_DBGRID wxDbGridColInfoBase
{
public:
//Default ctor
wxDbGridColInfoBase() { }
wxDbGridColInfoBase(int colNo,
wxString type, wxString title) :
DbCol(colNo),
wxtypename(type),
Title(title)
{ }
//Copy Ctor
wxDbGridColInfoBase(const wxDbGridColInfoBase& ref)
{
DbCol = ref.DbCol;
wxtypename = ref.wxtypename;
Title = ref.Title;
}
//Empty destructor for member obj's
~wxDbGridColInfoBase() {}
int DbCol;
wxString wxtypename;
wxString Title;
};
class WXDLLIMPEXP_DBGRID wxDbGridColInfo
{
public:
wxDbGridColInfo(int colNo,
wxString type,
wxString title,
wxDbGridColInfo *next) :
m_data(colNo,type,title)
{
m_next=next;
}
//Empty List
~wxDbGridColInfo() { delete m_next; }
//Recurse to find length.
int Length() { return (m_next ? m_next->Length() +1 : 1); }
// Adds a new column info (2 step creation)
void AddColInfo (int colNo,
wxString type,
wxString title)
{
GetLast()->m_next = new wxDbGridColInfo (colNo, type, title, NULL);
}
// Searches last
wxDbGridColInfo *GetLast() { return (m_next ? m_next->GetLast() : this); }
protected:
wxDbGridColInfoBase m_data;
wxDbGridColInfo *m_next;
friend class wxDbGridTableBase;
};
class WXDLLIMPEXP_DBGRID wxDbGridCellAttrProvider : public wxGridCellAttrProvider
{
public:
wxDbGridCellAttrProvider();
wxDbGridCellAttrProvider(wxDbTable *tab, wxDbGridColInfoBase* ColInfo);
virtual ~wxDbGridCellAttrProvider();
virtual wxGridCellAttr *GetAttr(int row, int col,
wxGridCellAttr::wxAttrKind kind) const;
virtual void AssignDbTable(wxDbTable *tab);
private:
wxDbTable *m_data;
wxDbGridColInfoBase *m_ColInfo;
};
class WXDLLIMPEXP_DBGRID wxDbGridTableBase : public wxGridTableBase
{
public:
wxDbGridTableBase(wxDbTable *tab, wxDbGridColInfo *ColInfo,
int count = wxUSE_QUERY, bool takeOwnership = true);
virtual ~wxDbGridTableBase();
virtual int GetNumberRows()
{
wxLogDebug(_T(" GetNumberRows() = %i"),m_rowtotal);
return m_rowtotal;
}
virtual int GetNumberCols()
{
wxLogDebug(_T(" GetNumberCols() = %i"),m_nocols);
return m_nocols;
}
virtual bool IsEmptyCell(int row, int col) ;
virtual wxString GetValue(int row, int col) ;
virtual void SetValue(int row, int col, const wxString& value);
virtual bool CanHaveAttributes();
virtual wxString GetTypeName(int row, int col);
virtual bool CanGetValueAs(int row, int col, const wxString& typeName);
virtual bool CanSetValueAs(int row, int col, const wxString& typeName);
virtual long GetValueAsLong(int row, int col);
virtual double GetValueAsDouble(int row, int col);
virtual bool GetValueAsBool(int row, int col);
virtual void SetValueAsLong(int row, int col, long value);
virtual void SetValueAsDouble(int row, int col, double value);
virtual void SetValueAsBool(int row, int col, bool value);
virtual void *GetValueAsCustom(int row, int col, const wxString& typeName);
virtual void SetValueAsCustom(int row, int col, const wxString& typeName, void* value);
virtual wxString GetColLabelValue(int col);
virtual bool AssignDbTable(wxDbTable *tab, int count = wxUSE_QUERY, bool takeOwnership=true);
virtual void ValidateRow(int row);
virtual bool UpdateRow(int row) const
{
if (m_row != row)
return true;
else
return Writeback();
}
private:
//Operates on the current row
bool Writeback() const;
typedef wxGridTableBase inherited;
keyarray m_keys;
wxDbTable *m_data;
bool m_dbowner;
int m_rowtotal;
int m_nocols;
int m_row;
wxDbGridColInfoBase *m_ColInfo;
bool m_rowmodified;
};
#endif // #if wxUSE_GRID
#endif // #if wxUSE_ODBC
#endif // _WX_GENERIC_DBGRID_H_

View File

@ -0,0 +1,41 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dbkeyg.h
// Purpose: Generic key support for wxDbTable
// Author: Roger Gammans
// Modified by:
// Created:
// RCS-ID: $Id: dbkeyg.h 29077 2004-09-10 12:56:07Z ABX $
// Copyright: (c) 1999 The Computer Surgery (roger@computer-surgery.co.uk)
// Licence: wxWindows licence
//
// NOTE : There is no CPP file to go along with this
//
///////////////////////////////////////////////////////////////////////////////
// Branched From : gkey.h,v 1.3 2001/06/01 10:31:41
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DBGKEY_H_
#define _WX_DBGKEY_H_
class GenericKey
{
public:
GenericKey(void *blk, size_t sz) { clone(blk,sz); }
GenericKey(const GenericKey &ref) { clone(ref.m_data,ref.m_sz); }
~GenericKey() { free(m_data); }
void *GetBlk(void) const { return m_data; }
private:
void clone(void *blk, size_t sz)
{
m_data = malloc(sz);
memcpy(m_data,blk,sz);
m_sz = sz;
}
void *m_data;
size_t m_sz;
};
#endif // _WX_DBGKEY_H_

View File

@ -0,0 +1,377 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dbtable.h
// Purpose: Declaration of the wxDbTable class.
// Author: Doug Card
// Modified by: George Tasker
// Bart Jourquin
// Mark Johnson
// Created: 9.96
// RCS-ID: $Id: dbtable.h 35650 2005-09-23 12:56:45Z MR $
// Copyright: (c) 1996 Remstar International, Inc.
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/*
// SYNOPSIS START
// SYNOPSIS STOP
*/
#ifndef DBTABLE_DOT_H
#define DBTABLE_DOT_H
#include "wx/defs.h"
#include "wx/db.h"
#include "wx/variant.h"
#include "wx/dbkeyg.h"
const int wxDB_ROWID_LEN = 24; // 18 is the max, 24 is in case it gets larger
const int wxDB_DEFAULT_CURSOR = 0;
const bool wxDB_QUERY_ONLY = true;
const bool wxDB_DISABLE_VIEW = true;
// Used to indicate end of a variable length list of
// column numbers passed to member functions
const int wxDB_NO_MORE_COLUMN_NUMBERS = -1;
// The following class is used to define a column of a table.
// The wxDbTable constructor will dynamically allocate as many of
// these as there are columns in the table. The class derived
// from wxDbTable must initialize these column definitions in it's
// constructor. These column definitions provide inf. to the
// wxDbTable class which allows it to create a table in the data
// source, exchange data between the data source and the C++
// object, and so on.
class WXDLLIMPEXP_ODBC wxDbColDef
{
public:
wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
int DbDataType; // Logical Data Type; e.g. DB_DATA_TYPE_INTEGER
SWORD SqlCtype; // C data type; e.g. SQL_C_LONG
void *PtrDataObj; // Address of the data object
int SzDataObj; // Size, in bytes, of the data object
bool KeyField; // true if this column is part of the PRIMARY KEY to the table; Date fields should NOT be KeyFields.
bool Updateable; // Specifies whether this column is updateable
bool InsertAllowed; // Specifies whether this column should be included in an INSERT statement
bool DerivedCol; // Specifies whether this column is a derived value
SQLLEN CbValue; // Internal use only!!!
bool Null; // NOT FULLY IMPLEMENTED - Allows NULL values in Inserts and Updates
wxDbColDef();
bool Initialize();
}; // wxDbColDef
class WXDLLIMPEXP_ODBC wxDbColDataPtr
{
public:
void *PtrDataObj;
int SzDataObj;
SWORD SqlCtype;
}; // wxDbColDataPtr
// This structure is used when creating secondary indexes.
class WXDLLIMPEXP_ODBC wxDbIdxDef
{
public:
wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1];
bool Ascending;
}; // wxDbIdxDef
class WXDLLIMPEXP_ODBC wxDbTable
{
private:
ULONG tableID; // Used for debugging. This can help to match up mismatched constructors/destructors
// Private member variables
UDWORD cursorType;
bool insertable;
// Private member functions
bool initialize(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxString &qryTblName, bool qryOnly, const wxString &tblPath);
void cleanup();
void setCbValueForColumn(int columnIndex);
bool bindParams(bool forUpdate); // called by the other 'bind' functions
bool bindInsertParams(void);
bool bindUpdateParams(void);
bool bindCols(HSTMT cursor);
bool getRec(UWORD fetchType);
bool execDelete(const wxString &pSqlStmt);
bool execUpdate(const wxString &pSqlStmt);
bool query(int queryType, bool forUpdate, bool distinct, const wxString &pSqlStmt=wxEmptyString);
#if !wxODBC_BACKWARD_COMPATABILITY
// these were public
// Where, Order By and From clauses
wxString where; // Standard SQL where clause, minus the word WHERE
wxString orderBy; // Standard SQL order by clause, minus the ORDER BY
wxString from; // Allows for joins in a wxDbTable::Query(). Format: ",tbl,tbl..."
// ODBC Handles
HENV henv; // ODBC Environment handle
HDBC hdbc; // ODBC DB Connection handle
HSTMT hstmt; // ODBC Statement handle
HSTMT *hstmtDefault; // Default cursor
HSTMT hstmtInsert; // ODBC Statement handle used specifically for inserts
HSTMT hstmtDelete; // ODBC Statement handle used specifically for deletes
HSTMT hstmtUpdate; // ODBC Statement handle used specifically for updates
HSTMT hstmtInternal; // ODBC Statement handle used internally only
HSTMT *hstmtCount; // ODBC Statement handle used by Count() function (No binding of columns)
// Flags
bool selectForUpdate;
// Pointer to the database object this table belongs to
wxDb *pDb;
// Table Inf.
wxString tablePath; // needed for dBase tables
wxString tableName; // Table name
wxString queryTableName; // Query Table Name
UWORD m_numCols; // # of columns in the table
bool queryOnly; // Query Only, no inserts, updates or deletes
// Column Definitions
wxDbColDef *colDefs; // Array of wxDbColDef structures
#endif
public:
#if wxODBC_BACKWARD_COMPATABILITY
// Where, Order By and From clauses
char *where; // Standard SQL where clause, minus the word WHERE
char *orderBy; // Standard SQL order by clause, minus the ORDER BY
char *from; // Allows for joins in a wxDbTable::Query(). Format: ",tbl,tbl..."
// ODBC Handles
HENV henv; // ODBC Environment handle
HDBC hdbc; // ODBC DB Connection handle
HSTMT hstmt; // ODBC Statement handle
HSTMT *hstmtDefault; // Default cursor
HSTMT hstmtInsert; // ODBC Statement handle used specifically for inserts
HSTMT hstmtDelete; // ODBC Statement handle used specifically for deletes
HSTMT hstmtUpdate; // ODBC Statement handle used specifically for updates
HSTMT hstmtInternal; // ODBC Statement handle used internally only
HSTMT *hstmtCount; // ODBC Statement handle used by Count() function (No binding of columns)
// Flags
bool selectForUpdate;
// Pointer to the database object this table belongs to
wxDb *pDb;
// Table Inf.
char tablePath[wxDB_PATH_MAX]; // needed for dBase tables
char tableName[DB_MAX_TABLE_NAME_LEN+1]; // Table name
char queryTableName[DB_MAX_TABLE_NAME_LEN+1]; // Query Table Name
UWORD m_numCols; // # of columns in the table
bool queryOnly; // Query Only, no inserts, updates or deletes
// Column Definitions
wxDbColDef *colDefs; // Array of wxDbColDef structures
#endif
// Public member functions
wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxString &qryTblName=wxEmptyString, bool qryOnly = !wxDB_QUERY_ONLY,
const wxString &tblPath=wxEmptyString);
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED(
wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxChar *qryTblName, bool qryOnly,
const wxString &tblPath)
);
#endif // WXWIN_COMPATIBILITY_2_4
virtual ~wxDbTable();
bool Open(bool checkPrivileges=false, bool checkTableExists=true);
bool CreateTable(bool attemptDrop=true);
bool DropTable(void);
bool CreateIndex(const wxString &indexName, bool unique, UWORD numIndexColumns,
wxDbIdxDef *pIndexDefs, bool attemptDrop=true);
bool DropIndex(const wxString &indexName);
// Accessors
// The member variables returned by these accessors are all
// set when the wxDbTable instance is created and cannot be
// changed, hence there is no corresponding SetXxxx function
wxDb *GetDb() { return pDb; }
const wxString &GetTableName() { return tableName; }
const wxString &GetQueryTableName() { return queryTableName; }
const wxString &GetTablePath() { return tablePath; }
UWORD GetNumberOfColumns() { return m_numCols; } // number of "defined" columns for this wxDbTable instance
const wxString &GetFromClause() { return from; }
const wxString &GetOrderByClause() { return orderBy; }
const wxString &GetWhereClause() { return where; }
bool IsQueryOnly() { return queryOnly; }
#if wxODBC_BACKWARD_COMPATABILITY
void SetFromClause(const char *From) { from = (char *)From; }
void SetOrderByClause(const char *OrderBy) { orderBy = (char *)OrderBy; }
void SetWhereClause(const char *Where) { where = (char *)Where; }
#else
void SetFromClause(const wxString &From) { from = From; }
void SetOrderByClause(const wxString &OrderBy) { orderBy = OrderBy; }
bool SetOrderByColNums(UWORD first, ...);
void SetWhereClause(const wxString &Where) { where = Where; }
void From(const wxString &From) { from = From; }
void OrderBy(const wxString &OrderBy) { orderBy = OrderBy; }
void Where(const wxString &Where) { where = Where; }
const wxString &Where() { return where; }
const wxString &OrderBy() { return orderBy; }
const wxString &From() { return from; }
#endif
int Insert(void);
bool Update(void);
bool Update(const wxString &pSqlStmt);
bool UpdateWhere(const wxString &pWhereClause);
bool Delete(void);
bool DeleteWhere(const wxString &pWhereClause);
bool DeleteMatching(void);
virtual bool Query(bool forUpdate = false, bool distinct = false);
bool QueryBySqlStmt(const wxString &pSqlStmt);
bool QueryMatching(bool forUpdate = false, bool distinct = false);
bool QueryOnKeyFields(bool forUpdate = false, bool distinct = false);
bool Refresh(void);
bool GetNext(void) { return(getRec(SQL_FETCH_NEXT)); }
bool operator++(int) { return(getRec(SQL_FETCH_NEXT)); }
/***** These four functions only work with wxDb instances that are defined *****
***** as not being FwdOnlyCursors *****/
bool GetPrev(void);
bool operator--(int);
bool GetFirst(void);
bool GetLast(void);
bool IsCursorClosedOnCommit(void);
UWORD GetRowNum(void);
void BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool distinct);
void BuildSelectStmt(wxChar *pSqlStmt, int typeOfSelect, bool distinct);
void BuildDeleteStmt(wxString &pSqlStmt, int typeOfDel, const wxString &pWhereClause=wxEmptyString);
void BuildDeleteStmt(wxChar *pSqlStmt, int typeOfDel, const wxString &pWhereClause=wxEmptyString);
void BuildUpdateStmt(wxString &pSqlStmt, int typeOfUpdate, const wxString &pWhereClause=wxEmptyString);
void BuildUpdateStmt(wxChar *pSqlStmt, int typeOfUpdate, const wxString &pWhereClause=wxEmptyString);
void BuildWhereClause(wxString &pWhereClause, int typeOfWhere, const wxString &qualTableName=wxEmptyString, bool useLikeComparison=false);
void BuildWhereClause(wxChar *pWhereClause, int typeOfWhere, const wxString &qualTableName=wxEmptyString, bool useLikeComparison=false);
#if wxODBC_BACKWARD_COMPATABILITY
// The following member functions are deprecated. You should use the BuildXxxxxStmt functions (above)
void GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
{ BuildSelectStmt(pSqlStmt,typeOfSelect,distinct); }
void GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause = NULL)
{ BuildDeleteStmt(pSqlStmt,typeOfDel,pWhereClause); }
void GetUpdateStmt(char *pSqlStmt, int typeOfUpdate, const char *pWhereClause = NULL)
{ BuildUpdateStmt(pSqlStmt,typeOfUpdate,pWhereClause); }
void GetWhereClause(char *pWhereClause, int typeOfWhere,
const char *qualTableName = NULL, bool useLikeComparison=false)
{ BuildWhereClause(pWhereClause,typeOfWhere,qualTableName,useLikeComparison); }
#endif
bool CanSelectForUpdate(void);
#if wxODBC_BACKWARD_COMPATABILITY
bool CanUpdByROWID(void) { return CanUpdateByRowID(); };
#endif
bool CanUpdateByROWID(void);
void ClearMemberVar(UWORD colNumber, bool setToNull=false);
void ClearMemberVars(bool setToNull=false);
bool SetQueryTimeout(UDWORD nSeconds);
wxDbColDef *GetColDefs() { return colDefs; }
bool SetColDefs(UWORD index, const wxString &fieldName, int dataType,
void *pData, SWORD cType,
int size, bool keyField = false, bool updateable = true,
bool insertAllowed = true, bool derivedColumn = false);
wxDbColDataPtr *SetColDefs(wxDbColInf *colInfs, UWORD numCols);
bool CloseCursor(HSTMT cursor);
bool DeleteCursor(HSTMT *hstmtDel);
void SetCursor(HSTMT *hstmtActivate = (void **) wxDB_DEFAULT_CURSOR);
HSTMT GetCursor(void) { return(hstmt); }
HSTMT *GetNewCursor(bool setCursor = false, bool bindColumns = true);
#if wxODBC_BACKWARD_COMPATABILITY
// The following member function is deprecated. You should use the GetNewCursor
HSTMT *NewCursor(bool setCursor = false, bool bindColumns = true) { return GetNewCursor(setCursor,bindColumns); }
#endif
ULONG Count(const wxString &args=_T("*"));
int DB_STATUS(void) { return(pDb->DB_STATUS); }
bool IsColNull(UWORD colNumber) const;
bool SetColNull(UWORD colNumber, bool set=true);
bool SetColNull(const wxString &colName, bool set=true);
#if wxODBC_BACKWARD_COMPATABILITY
// The following member functions are deprecated. You should use the SetColNull()
bool SetNull(int colNumber, bool set=true) { return (SetNull(colNumber,set)); }
bool SetNull(const char *colName, bool set=true) { return (SetNull(colName,set)); }
#endif
#ifdef __WXDEBUG__
ULONG GetTableID() { return tableID; }
#endif
//TODO: Need to Document
typedef enum { WX_ROW_MODE_QUERY , WX_ROW_MODE_INDIVIDUAL } rowmode_t;
virtual void SetRowMode(const rowmode_t rowmode);
#if wxODBC_BACKWARD_COMPATABILITY
virtual wxVariant GetCol(const int colNumber) const { return GetColumn(colNumber); };
virtual void SetCol(const int colNumber, const wxVariant value) { return SetColumn(colNumber, value); };
#endif
virtual wxVariant GetColumn(const int colNumber) const ;
virtual void SetColumn(const int colNumber, const wxVariant value);
virtual GenericKey GetKey(void);
virtual void SetKey(const GenericKey &key);
private:
HSTMT *m_hstmtGridQuery;
rowmode_t m_rowmode;
size_t m_keysize;
// typedef enum {unmodified=0, UpdatePending, InsertPending } recStatus;
// recStatus get_ModifiedStatus() { return m_recstatus; }
// void modify() {
// if (m_recstatus==unmodified)
// m_recstatus=UpdatePending;
// }
// protected:
// void insertify() {m_recstatus=InsertPending; }
// void unmodify() {m_recstatus=unmodified; }
// recStatus m_recstatus;
//TODO: Need to Document
}; // wxDbTable
// Change this to 0 to remove use of all deprecated functions
#if wxODBC_BACKWARD_COMPATABILITY
//#################################################################################
//############### DEPRECATED functions for backward compatibility #################
//#################################################################################
// Backward compability. These will eventually go away
typedef wxDbTable wxTable;
typedef wxDbIdxDef wxIdxDef;
typedef wxDbIdxDef CidxDef;
typedef wxDbColDef wxColDef;
typedef wxDbColDef CcolDef;
typedef wxDbColDataPtr wxColDataPtr;
typedef wxDbColDataPtr CcolDataPtr;
const int ROWID = wxDB_ROWID_LEN;
const int DEFAULT_CURSOR = wxDB_DEFAULT_CURSOR;
const bool QUERY_ONLY = wxDB_QUERY_ONLY;
const bool DISABLE_VIEW = wxDB_DISABLE_VIEW;
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,276 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcbuffer.h
// Purpose: wxBufferedDC class
// Author: Ron Lee <ron@debian.org>
// Modified by: Vadim Zeitlin (refactored, added bg preservation)
// Created: 16/03/02
// RCS-ID: $Id: dcbuffer.h 44609 2007-03-05 08:58:09Z VZ $
// Copyright: (c) Ron Lee
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCBUFFER_H_
#define _WX_DCBUFFER_H_
#include "wx/dcmemory.h"
#include "wx/dcclient.h"
#include "wx/window.h"
// Split platforms into two groups - those which have well-working
// double-buffering by default, and those which do not.
#if defined(__WXMAC__) || defined(__WXGTK20__) || defined(__WXDFB__)
#define wxALWAYS_NATIVE_DOUBLE_BUFFER 1
#else
#define wxALWAYS_NATIVE_DOUBLE_BUFFER 0
#endif
// ----------------------------------------------------------------------------
// Double buffering helper.
// ----------------------------------------------------------------------------
// Assumes the buffer bitmap covers the entire scrolled window,
// and prepares the window DC accordingly
#define wxBUFFER_VIRTUAL_AREA 0x01
// Assumes the buffer bitmap only covers the client area;
// does not prepare the window DC
#define wxBUFFER_CLIENT_AREA 0x02
class WXDLLEXPORT wxBufferedDC : public wxMemoryDC
{
public:
// Default ctor, must subsequently call Init for two stage construction.
wxBufferedDC()
: m_dc(NULL),
m_buffer(NULL),
m_style(0)
{
}
// Construct a wxBufferedDC using a user supplied buffer.
wxBufferedDC(wxDC *dc,
wxBitmap& buffer = wxNullBitmap,
int style = wxBUFFER_CLIENT_AREA)
: m_dc(NULL), m_buffer(NULL)
{
Init(dc, buffer, style);
}
// Construct a wxBufferedDC with an internal buffer of 'area'
// (where area is usually something like the size of the window
// being buffered)
wxBufferedDC(wxDC *dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA)
: m_dc(NULL), m_buffer(NULL)
{
Init(dc, area, style);
}
// The usually desired action in the dtor is to blit the buffer.
virtual ~wxBufferedDC()
{
if ( m_dc )
UnMask();
}
// These reimplement the actions of the ctors for two stage creation
void Init(wxDC *dc,
wxBitmap& buffer = wxNullBitmap,
int style = wxBUFFER_CLIENT_AREA)
{
InitCommon(dc, style);
m_buffer = &buffer;
UseBuffer();
}
void Init(wxDC *dc, const wxSize &area, int style = wxBUFFER_CLIENT_AREA)
{
InitCommon(dc, style);
UseBuffer(area.x, area.y);
}
// Blits the buffer to the dc, and detaches the dc from the buffer (so it
// can be effectively used once only).
//
// Usually called in the dtor or by the dtor of derived classes if the
// BufferedDC must blit before the derived class (which may own the dc it's
// blitting to) is destroyed.
void UnMask()
{
wxCHECK_RET( m_dc, _T("no underlying wxDC?") );
wxASSERT_MSG( m_buffer && m_buffer->IsOk(), _T("invalid backing store") );
wxCoord x = 0,
y = 0;
if ( m_style & wxBUFFER_CLIENT_AREA )
GetDeviceOrigin(&x, &y);
m_dc->Blit(0, 0, m_buffer->GetWidth(), m_buffer->GetHeight(),
this, -x, -y );
m_dc = NULL;
}
// Set and get the style
void SetStyle(int style) { m_style = style; }
int GetStyle() const { return m_style; }
private:
// common part of Init()s
void InitCommon(wxDC *dc, int style)
{
wxASSERT_MSG( !m_dc, _T("wxBufferedDC already initialised") );
m_dc = dc;
m_style = style;
// inherit the same layout direction as the original DC
if (dc && dc->IsOk())
SetLayoutDirection(dc->GetLayoutDirection());
}
// check that the bitmap is valid and use it
void UseBuffer(wxCoord w = -1, wxCoord h = -1);
// the underlying DC to which we copy everything drawn on this one in
// UnMask()
//
// NB: Without the existence of a wxNullDC, this must be a pointer, else it
// could probably be a reference.
wxDC *m_dc;
// the buffer (selected in this DC), initially invalid
wxBitmap *m_buffer;
// the buffering style
int m_style;
DECLARE_DYNAMIC_CLASS(wxBufferedDC)
DECLARE_NO_COPY_CLASS(wxBufferedDC)
};
// ----------------------------------------------------------------------------
// Double buffered PaintDC.
// ----------------------------------------------------------------------------
// Creates a double buffered wxPaintDC, optionally allowing the
// user to specify their own buffer to use.
class WXDLLEXPORT wxBufferedPaintDC : public wxBufferedDC
{
public:
// If no bitmap is supplied by the user, a temporary one will be created.
wxBufferedPaintDC(wxWindow *window, wxBitmap& buffer, int style = wxBUFFER_CLIENT_AREA)
: m_paintdc(window)
{
// If we're buffering the virtual window, scale the paint DC as well
if (style & wxBUFFER_VIRTUAL_AREA)
window->PrepareDC( m_paintdc );
if( buffer.IsOk() )
Init(&m_paintdc, buffer, style);
else
Init(&m_paintdc, GetBufferedSize(window, style), style);
}
// If no bitmap is supplied by the user, a temporary one will be created.
wxBufferedPaintDC(wxWindow *window, int style = wxBUFFER_CLIENT_AREA)
: m_paintdc(window)
{
// If we're using the virtual window, scale the paint DC as well
if (style & wxBUFFER_VIRTUAL_AREA)
window->PrepareDC( m_paintdc );
Init(&m_paintdc, GetBufferedSize(window, style), style);
}
// default copy ctor ok.
virtual ~wxBufferedPaintDC()
{
// We must UnMask here, else by the time the base class
// does it, the PaintDC will have already been destroyed.
UnMask();
}
protected:
// return the size needed by the buffer: this depends on whether we're
// buffering just the currently shown part or the total (scrolled) window
static wxSize GetBufferedSize(wxWindow *window, int style)
{
return style & wxBUFFER_VIRTUAL_AREA ? window->GetVirtualSize()
: window->GetClientSize();
}
private:
wxPaintDC m_paintdc;
DECLARE_ABSTRACT_CLASS(wxBufferedPaintDC)
DECLARE_NO_COPY_CLASS(wxBufferedPaintDC)
};
//
// wxAutoBufferedPaintDC is a wxPaintDC in toolkits which have double-
// buffering by default. Otherwise it is a wxBufferedPaintDC. Thus,
// you can only expect it work with a simple constructor that
// accepts single wxWindow* argument.
//
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
#define wxAutoBufferedPaintDCBase wxPaintDC
#else
#define wxAutoBufferedPaintDCBase wxBufferedPaintDC
#endif
#ifdef __WXDEBUG__
class wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase
{
public:
wxAutoBufferedPaintDC(wxWindow* win)
: wxAutoBufferedPaintDCBase(win)
{
TestWinStyle(win);
}
virtual ~wxAutoBufferedPaintDC() { }
private:
void TestWinStyle(wxWindow* win)
{
// Help the user to get the double-buffering working properly.
wxASSERT_MSG( win->GetBackgroundStyle() == wxBG_STYLE_CUSTOM,
wxT("In constructor, you need to call SetBackgroundStyle(wxBG_STYLE_CUSTOM), ")
wxT("and also, if needed, paint the background manually in the paint event handler."));
}
DECLARE_NO_COPY_CLASS(wxAutoBufferedPaintDC)
};
#else // !__WXDEBUG__
// In release builds, just use typedef
typedef wxAutoBufferedPaintDCBase wxAutoBufferedPaintDC;
#endif
// Check if the window is natively double buffered and will return a wxPaintDC
// if it is, a wxBufferedPaintDC otherwise. It is the caller's responsibility
// to delete the wxDC pointer when finished with it.
inline wxDC* wxAutoBufferedPaintDCFactory(wxWindow* window)
{
if ( window->IsDoubleBuffered() )
return new wxPaintDC(window);
else
return new wxBufferedPaintDC(window);
}
#endif // _WX_DCBUFFER_H_

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcclient.h
// Purpose: wxClientDC base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: dcclient.h 40865 2006-08-27 09:42:42Z VS $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCCLIENT_H_BASE_
#define _WX_DCCLIENT_H_BASE_
#include "wx/defs.h"
#if defined(__WXPALMOS__)
#include "wx/palmos/dcclient.h"
#elif defined(__WXMSW__)
#include "wx/msw/dcclient.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dcclient.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/dcclient.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dcclient.h"
#elif defined(__WXX11__)
#include "wx/x11/dcclient.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcclient.h"
#elif defined(__WXDFB__)
#include "wx/dfb/dcclient.h"
#elif defined(__WXMAC__)
#include "wx/mac/dcclient.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/dcclient.h"
#elif defined(__WXPM__)
#include "wx/os2/dcclient.h"
#endif
#endif
// _WX_DCCLIENT_H_BASE_

View File

@ -0,0 +1,190 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/graphdc.h
// Purpose: graphics context device bridge header
// Author: Stefan Csomor
// Modified by:
// Created:
// Copyright: (c) Stefan Csomor
// RCS-ID: $Id: dcgraph.h 53390 2008-04-28 04:19:15Z KO $
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GRAPHICS_DC_H_
#define _WX_GRAPHICS_DC_H_
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/geometry.h"
#include "wx/dynarray.h"
#include "wx/graphics.h"
class WXDLLEXPORT wxWindowDC;
#ifdef __WXMAC__
#define wxGCDC wxDC
#endif
class WXDLLEXPORT wxGCDC:
#ifdef __WXMAC__
public wxDCBase
#else
public wxDC
#endif
{
DECLARE_DYNAMIC_CLASS(wxGCDC)
DECLARE_NO_COPY_CLASS(wxGCDC)
public:
wxGCDC(const wxWindowDC& dc);
#ifdef __WXMSW__
wxGCDC( const wxMemoryDC& dc);
#endif
wxGCDC();
virtual ~wxGCDC();
void Init();
// implement base class pure virtuals
// ----------------------------------
virtual void Clear();
virtual bool StartDoc( const wxString& message );
virtual void EndDoc();
virtual void StartPage();
virtual void EndPage();
// to be virtualized on next major
// flushing the content of this dc immediately onto screen
void Flush();
virtual void SetFont(const wxFont& font);
virtual void SetPen(const wxPen& pen);
virtual void SetBrush(const wxBrush& brush);
virtual void SetBackground(const wxBrush& brush);
virtual void SetBackgroundMode(int mode);
virtual void SetPalette(const wxPalette& palette);
virtual void DestroyClippingRegion();
virtual wxCoord GetCharHeight() const;
virtual wxCoord GetCharWidth() const;
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;
virtual int GetDepth() const;
virtual wxSize GetPPI() const;
virtual void SetMapMode(int mode);
virtual void SetUserScale(double x, double y);
virtual void SetLogicalScale(double x, double y);
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
virtual void SetLogicalFunction(int function);
virtual void SetTextForeground(const wxColour& colour);
virtual void SetTextBackground(const wxColour& colour);
virtual void ComputeScaleAndOrigin();
wxGraphicsContext* GetGraphicsContext() { return m_graphicContext; }
virtual void SetGraphicsContext( wxGraphicsContext* ctx );
protected:
// the true implementations
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
int style = wxFLOOD_SURFACE);
virtual void DoGradientFillLinear(const wxRect& rect,
const wxColour& initialColour,
const wxColour& destColour,
wxDirection nDirection = wxEAST);
virtual void DoGradientFillConcentric(const wxRect& rect,
const wxColour& initialColour,
const wxColour& destColour,
const wxPoint& circleCenter);
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
virtual void DoDrawPoint(wxCoord x, wxCoord y);
#if wxUSE_SPLINES
virtual void DoDrawSpline(wxList *points);
#endif
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc);
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea);
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius);
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoCrossHair(wxCoord x, wxCoord y);
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = false);
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle);
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
virtual void DoGetSize(int *,int *) const;
virtual void DoGetSizeMM(int* width, int* height) const;
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset);
virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle = wxODDEVEN_RULE);
virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle);
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
protected:
// scaling variables
bool m_logicalFunctionSupported;
double m_mm_to_pix_x, m_mm_to_pix_y;
wxGraphicsMatrix m_matrixOriginal;
wxGraphicsMatrix m_matrixCurrent;
double m_formerScaleX, m_formerScaleY;
wxGraphicsContext* m_graphicContext;
};
#endif
#endif // _WX_GRAPHICS_DC_H_

View File

@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcmemory.h
// Purpose: wxMemoryDC base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: dcmemory.h 43843 2006-12-07 05:44:44Z PC $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMEMORY_H_BASE_
#define _WX_DCMEMORY_H_BASE_
#include "wx/bitmap.h"
// NOTE: different native implementations of wxMemoryDC will derive from
// different wxDC classes (wxPaintDC, wxWindowDC, etc), so that
// we cannot derive wxMemoryDCBase from wxDC and then use it as the
// only base class for native impl of wxMemoryDC...
class WXDLLEXPORT wxMemoryDCBase
{
public:
wxMemoryDCBase() { }
// avoid warnings about having virtual functions but non virtual dtor
virtual ~wxMemoryDCBase() { }
// select the given bitmap to draw on it
void SelectObject(wxBitmap& bmp)
{
// make sure that the given wxBitmap is not sharing its data with other
// wxBitmap instances as its contents will be modified by any drawing
// operation done on this DC
if (bmp.IsOk())
bmp.UnShare();
DoSelect(bmp);
}
// select the given bitmap for read-only
virtual void SelectObjectAsSource(const wxBitmap& bmp)
{
DoSelect(bmp);
}
protected:
virtual void DoSelect(const wxBitmap& bmp) = 0;
};
#if defined(__WXPALMOS__)
#include "wx/palmos/dcmemory.h"
#elif defined(__WXMSW__)
#include "wx/msw/dcmemory.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dcmemory.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/dcmemory.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dcmemory.h"
#elif defined(__WXX11__)
#include "wx/x11/dcmemory.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcmemory.h"
#elif defined(__WXDFB__)
#include "wx/dfb/dcmemory.h"
#elif defined(__WXMAC__)
#include "wx/mac/dcmemory.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/dcmemory.h"
#elif defined(__WXPM__)
#include "wx/os2/dcmemory.h"
#endif
#endif
// _WX_DCMEMORY_H_BASE_

View File

@ -0,0 +1,287 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dcmirror.h
// Purpose: wxMirrorDC class
// Author: Vadim Zeitlin
// Modified by:
// Created: 21.07.2003
// RCS-ID: $Id: dcmirror.h 41751 2006-10-08 21:56:55Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMIRROR_H_
#define _WX_DCMIRROR_H_
#include "wx/dc.h"
// ----------------------------------------------------------------------------
// wxMirrorDC allows to write the same code for horz/vertical layout
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMirrorDC : public wxDC
{
public:
// constructs a mirror DC associated with the given real DC
//
// if mirror parameter is true, all vertical and horizontal coordinates are
// exchanged, otherwise this class behaves in exactly the same way as a
// plain DC
//
// the cast to wxMirrorDC is a dirty hack done to allow us to call the
// protected methods of wxDCBase directly in our code below, without it it
// would be impossible (this is correct from C++ point of view but doesn't
// make any sense in this particular situation)
wxMirrorDC(wxDC& dc, bool mirror) : m_dc((wxMirrorDC&)dc)
{ m_mirror = mirror; }
// wxDCBase operations
virtual void Clear() { m_dc.Clear(); }
virtual void SetFont(const wxFont& font) { m_dc.SetFont(font); }
virtual void SetPen(const wxPen& pen) { m_dc.SetPen(pen); }
virtual void SetBrush(const wxBrush& brush) { m_dc.SetBrush(brush); }
virtual void SetBackground(const wxBrush& brush)
{ m_dc.SetBackground(brush); }
virtual void SetBackgroundMode(int mode) { m_dc.SetBackgroundMode(mode); }
#if wxUSE_PALETTE
virtual void SetPalette(const wxPalette& palette)
{ m_dc.SetPalette(palette); }
#endif // wxUSE_PALETTE
virtual void DestroyClippingRegion() { m_dc.DestroyClippingRegion(); }
virtual wxCoord GetCharHeight() const { return m_dc.GetCharHeight(); }
virtual wxCoord GetCharWidth() const { return m_dc.GetCharWidth(); }
virtual bool CanDrawBitmap() const { return m_dc.CanDrawBitmap(); }
virtual bool CanGetTextExtent() const { return m_dc.CanGetTextExtent(); }
virtual int GetDepth() const { return m_dc.GetDepth(); }
virtual wxSize GetPPI() const { return m_dc.GetPPI(); }
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return m_dc.Ok(); }
virtual void SetMapMode(int mode) { m_dc.SetMapMode(mode); }
virtual void SetUserScale(double x, double y)
{ m_dc.SetUserScale(GetX(x, y), GetY(x, y)); }
virtual void SetLogicalOrigin(wxCoord x, wxCoord y)
{ m_dc.SetLogicalOrigin(GetX(x, y), GetY(x, y)); }
virtual void SetDeviceOrigin(wxCoord x, wxCoord y)
{ m_dc.SetDeviceOrigin(GetX(x, y), GetY(x, y)); }
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
{ m_dc.SetAxisOrientation(GetX(xLeftRight, yBottomUp),
GetY(xLeftRight, yBottomUp)); }
virtual void SetLogicalFunction(int function)
{ m_dc.SetLogicalFunction(function); }
// helper functions which may be useful for the users of this class
wxSize Reflect(const wxSize& sizeOrig)
{
return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig;
}
protected:
// returns x and y if not mirroring or y and x if mirroring
wxCoord GetX(wxCoord x, wxCoord y) const { return m_mirror ? y : x; }
wxCoord GetY(wxCoord x, wxCoord y) const { return m_mirror ? x : y; }
double GetX(double x, double y) const { return m_mirror ? y : x; }
double GetY(double x, double y) const { return m_mirror ? x : y; }
bool GetX(bool x, bool y) const { return m_mirror ? y : x; }
bool GetY(bool x, bool y) const { return m_mirror ? x : y; }
// same thing but for pointers
wxCoord *GetX(wxCoord *x, wxCoord *y) const { return m_mirror ? y : x; }
wxCoord *GetY(wxCoord *x, wxCoord *y) const { return m_mirror ? x : y; }
// exchange x and y unconditionally
static void Swap(wxCoord& x, wxCoord& y)
{
wxCoord t = x;
x = y;
y = t;
}
// exchange x and y components of all points in the array if necessary
void Mirror(int n, wxPoint points[]) const
{
if ( m_mirror )
{
for ( int i = 0; i < n; i++ )
{
Swap(points[i].x, points[i].y);
}
}
}
// wxDCBase functions
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
int style = wxFLOOD_SURFACE)
{
return m_dc.DoFloodFill(GetX(x, y), GetY(x, y), col, style);
}
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
{
return m_dc.DoGetPixel(GetX(x, y), GetY(x, y), col);
}
virtual void DoDrawPoint(wxCoord x, wxCoord y)
{
m_dc.DoDrawPoint(GetX(x, y), GetY(x, y));
}
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
m_dc.DoDrawLine(GetX(x1, y1), GetY(x1, y1), GetX(x2, y2), GetY(x2, y2));
}
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc)
{
wxFAIL_MSG( _T("this is probably wrong") );
m_dc.DoDrawArc(GetX(x1, y1), GetY(x1, y1),
GetX(x2, y2), GetY(x2, y2),
xc, yc);
}
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
wxCoord w, wxCoord h)
{
m_dc.DoDrawCheckMark(GetX(x, y), GetY(x, y),
GetX(w, h), GetY(w, h));
}
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea)
{
wxFAIL_MSG( _T("this is probably wrong") );
m_dc.DoDrawEllipticArc(GetX(x, y), GetY(x, y),
GetX(w, h), GetY(w, h),
sa, ea);
}
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
m_dc.DoDrawRectangle(GetX(x, y), GetY(x, y), GetX(w, h), GetY(w, h));
}
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord w, wxCoord h,
double radius)
{
m_dc.DoDrawRoundedRectangle(GetX(x, y), GetY(x, y),
GetX(w, h), GetY(w, h),
radius);
}
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
m_dc.DoDrawEllipse(GetX(x, y), GetY(x, y), GetX(w, h), GetY(w, h));
}
virtual void DoCrossHair(wxCoord x, wxCoord y)
{
m_dc.DoCrossHair(GetX(x, y), GetY(x, y));
}
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
{
m_dc.DoDrawIcon(icon, GetX(x, y), GetY(x, y));
}
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = false)
{
m_dc.DoDrawBitmap(bmp, GetX(x, y), GetY(x, y), useMask);
}
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
// this is never mirrored
m_dc.DoDrawText(text, x, y);
}
virtual void DoDrawRotatedText(const wxString& text,
wxCoord x, wxCoord y, double angle)
{
// this is never mirrored
m_dc.DoDrawRotatedText(text, x, y, angle);
}
virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
wxCoord w, wxCoord h,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
{
return m_dc.DoBlit(GetX(xdest, ydest), GetY(xdest, ydest),
GetX(w, h), GetY(w, h),
source, GetX(xsrc, ysrc), GetY(xsrc, ysrc),
rop, useMask,
GetX(xsrcMask, ysrcMask), GetX(xsrcMask, ysrcMask));
}
virtual void DoGetSize(int *w, int *h) const
{
m_dc.DoGetSize(GetX(w, h), GetY(w, h));
}
virtual void DoGetSizeMM(int *w, int *h) const
{
m_dc.DoGetSizeMM(GetX(w, h), GetY(w, h));
}
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset)
{
Mirror(n, points);
m_dc.DoDrawLines(n, points,
GetX(xoffset, yoffset), GetY(xoffset, yoffset));
Mirror(n, points);
}
virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle = wxODDEVEN_RULE)
{
Mirror(n, points);
m_dc.DoDrawPolygon(n, points,
GetX(xoffset, yoffset), GetY(xoffset, yoffset),
fillStyle);
Mirror(n, points);
}
virtual void DoSetClippingRegionAsRegion(const wxRegion& WXUNUSED(region))
{
wxFAIL_MSG( _T("not implemented") );
}
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord w, wxCoord h)
{
m_dc.DoSetClippingRegion(GetX(x, y), GetY(x, y), GetX(w, h), GetY(w, h));
}
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const
{
// never mirrored
m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont);
}
private:
wxMirrorDC& m_dc;
bool m_mirror;
DECLARE_NO_COPY_CLASS(wxMirrorDC)
};
#endif // _WX_DCMIRROR_H_

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcprint.h
// Purpose: wxPrinterDC base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: dcprint.h 41240 2006-09-15 16:45:48Z PC $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCPRINT_H_BASE_
#define _WX_DCPRINT_H_BASE_
#include "wx/defs.h"
#if wxUSE_PRINTING_ARCHITECTURE
#if defined(__WXPALMOS__)
#include "wx/palmos/dcprint.h"
#elif defined(__WXMSW__)
#include "wx/msw/dcprint.h"
#endif
#if defined(__WXPM__)
#include "wx/os2/dcprint.h"
#endif
#if defined(__WXMAC__)
#include "wx/mac/dcprint.h"
#endif
#endif // wxUSE_PRINTING_ARCHITECTURE
#endif
// _WX_DCPRINT_H_BASE_

View File

@ -0,0 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcps.h
// Purpose: wxPostScriptDC base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: dcps.h 33948 2005-05-04 18:57:50Z JS $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCPS_H_BASE_
#define _WX_DCPS_H_BASE_
#include "wx/generic/dcpsg.h"
#endif

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcscreen.h
// Purpose: wxScreenDC base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: dcscreen.h 40865 2006-08-27 09:42:42Z VS $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCSCREEN_H_BASE_
#define _WX_DCSCREEN_H_BASE_
#include "wx/defs.h"
#if defined(__WXPALMOS__)
#include "wx/palmos/dcscreen.h"
#elif defined(__WXMSW__)
#include "wx/msw/dcscreen.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dcscreen.h"
#elif defined(__WXGTK20__)
#include "wx/gtk/dcscreen.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dcscreen.h"
#elif defined(__WXX11__)
#include "wx/x11/dcscreen.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcscreen.h"
#elif defined(__WXDFB__)
#include "wx/dfb/dcscreen.h"
#elif defined(__WXMAC__)
#include "wx/mac/dcscreen.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/dcscreen.h"
#elif defined(__WXPM__)
#include "wx/os2/dcscreen.h"
#endif
#endif
// _WX_DCSCREEN_H_BASE_

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dde.h
// Purpose: DDE base header
// Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart
// RCS-ID: $Id: dde.h 53135 2008-04-12 02:31:04Z VZ $
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DDE_H_BASE_
#define _WX_DDE_H_BASE_
#include "wx/list.h"
class WXDLLIMPEXP_FWD_BASE wxDDEClient;
class WXDLLIMPEXP_FWD_BASE wxDDEServer;
class WXDLLIMPEXP_FWD_BASE wxDDEConnection;
WX_DECLARE_USER_EXPORTED_LIST(wxDDEClient, wxDDEClientList, WXDLLIMPEXP_BASE);
WX_DECLARE_USER_EXPORTED_LIST(wxDDEServer, wxDDEServerList, WXDLLIMPEXP_BASE);
WX_DECLARE_USER_EXPORTED_LIST(wxDDEConnection, wxDDEConnectionList, WXDLLIMPEXP_BASE);
#if defined(__WXMSW__)
#include "wx/msw/dde.h"
#else
#error DDE is only supported on MSW
#endif
#endif
// _WX_DDE_H_BASE_

View File

@ -0,0 +1,316 @@
/**
* Name: wx/debug.h
* Purpose: Misc debug functions and macros
* Author: Vadim Zeitlin
* Modified by: Ryan Norton (Converted to C)
* Created: 29/01/98
* RCS-ID: $Id: debug.h 54492 2008-07-05 17:54:03Z SN $
* Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_DEBUG_H_
#define _WX_DEBUG_H_
#ifndef __WXWINCE__
#include <assert.h>
#endif
#include <limits.h> /* for CHAR_BIT used below */
#include "wx/wxchar.h" /* for __TFILE__ and wxChar */
/* ---------------------------------------------------------------------------- */
/* Defines controlling the debugging macros */
/* ---------------------------------------------------------------------------- */
/* if _DEBUG is defined (MS VC++ and others use it in debug builds), define */
/* __WXDEBUG__ too */
#ifdef _DEBUG
#ifndef __WXDEBUG__
#define __WXDEBUG__
#endif /* !__WXDEBUG__ */
#endif /* _DEBUG */
/* if NDEBUG is defined (<assert.h> uses it), undef __WXDEBUG__ and WXDEBUG */
#ifdef NDEBUG
#undef __WXDEBUG__
#undef WXDEBUG
#endif /* NDEBUG */
/* if __WXDEBUG__ is defined, make sure that WXDEBUG is defined and >= 1 */
#ifdef __WXDEBUG__
#if !defined(WXDEBUG) || !WXDEBUG
#undef WXDEBUG
#define WXDEBUG 1
#endif /* !WXDEBUG */
#endif /* __WXDEBUG__ */
#ifndef __WXFUNCTION__
/* TODO: add more compilers supporting __FUNCTION__ */
#if defined(__DMC__)
/*
__FUNCTION__ happens to be not defined within class members
http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.beta/485
*/
#define __WXFUNCTION__ (NULL)
#elif defined(__GNUC__) || \
(defined(_MSC_VER) && _MSC_VER >= 1300) || \
defined(__FUNCTION__)
#define __WXFUNCTION__ __FUNCTION__
#else
/* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */
#define __WXFUNCTION__ (NULL)
#endif
#endif /* __WXFUNCTION__ already defined */
/* ---------------------------------------------------------------------------- */
/* Debugging macros */
/* */
/* All debugging macros rely on ASSERT() which in turn calls the user-defined */
/* OnAssert() function. To keep things simple, it's called even when the */
/* expression is true (i.e. everything is ok) and by default does nothing: just */
/* returns the same value back. But if you redefine it to do something more sexy */
/* (popping up a message box in your favourite GUI, sending you e-mail or */
/* whatever) it will affect all ASSERTs, FAILs and CHECKs in your code. */
/* */
/* Warning: if you don't like advice on programming style, don't read */
/* further! ;-) */
/* */
/* Extensive use of these macros is recommended! Remember that ASSERTs are */
/* disabled in final build (without __WXDEBUG__ defined), so they add strictly */
/* nothing to your program's code. On the other hand, CHECK macros do stay */
/* even in release builds, but in general are not much of a burden, while */
/* a judicious use of them might increase your program's stability. */
/* ---------------------------------------------------------------------------- */
/* Macros which are completely disabled in 'release' mode */
/* */
/* NB: these functions are implemented in src/common/appcmn.cpp */
#if defined(__cplusplus) && defined(__WXDEBUG__)
/*
This function is called whenever one of debugging macros fails (i.e.
condition is false in an assertion). To customize its behaviour, override
wxApp::OnAssert().
Parameters:
szFile and nLine - file name and line number of the ASSERT
szFunc - function name of the ASSERT, may be NULL (NB: ASCII)
szCond - text form of the condition which failed
szMsg - optional message explaining the reason
*/
extern void WXDLLIMPEXP_BASE wxOnAssert(const wxChar *szFile,
int nLine,
const char *szFunc,
const wxChar *szCond,
const wxChar *szMsg = NULL);
/* call this function to break into the debugger unconditionally (assuming */
/* the program is running under debugger, of course) */
extern void WXDLLIMPEXP_BASE wxTrap();
/* generic assert macro */
#define wxASSERT(cond) wxASSERT_MSG(cond, NULL)
/* assert with additional message explaining its cause */
/* compilers can give a warning (such as "possible unwanted ;") when using */
/* the default definition of wxASSERT_MSG so we provide an alternative */
#if defined(__MWERKS__)
#define wxASSERT_MSG(cond, msg) \
if ( cond ) \
{} \
else \
wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, _T(#cond), msg)
#else
#define wxASSERT_MSG(cond, msg) \
if ( cond ) \
; \
else \
wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, _T(#cond), msg)
#endif
/* special form of assert: always triggers it (in debug mode) */
#define wxFAIL wxFAIL_MSG(NULL)
/* FAIL with some message */
#define wxFAIL_MSG(msg) wxFAIL_COND_MSG("wxAssertFailure", msg)
/* FAIL with some message and a condition */
#define wxFAIL_COND_MSG(cond, msg) \
wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, _T(cond), msg)
/* An assert helper used to avoid warning when testing constant expressions, */
/* i.e. wxASSERT( sizeof(int) == 4 ) can generate a compiler warning about */
/* expression being always true, but not using */
/* wxASSERT( wxAssertIsEqual(sizeof(int), 4) ) */
/* */
/* NB: this is made obsolete by wxCOMPILE_TIME_ASSERT() and should no */
/* longer be used. */
extern bool WXDLLIMPEXP_BASE wxAssertIsEqual(int x, int y);
#else
#define wxTrap()
/* nothing to do in release mode (hopefully at this moment there are */
/* no more bugs ;-) */
#define wxASSERT(cond)
#define wxASSERT_MSG(cond, msg)
#define wxFAIL
#define wxFAIL_MSG(msg)
#define wxFAIL_COND_MSG(cond, msg)
#endif /* __WXDEBUG__ */
#ifdef __cplusplus
/* Use of wxFalse instead of false suppresses compiler warnings about testing */
/* constant expression */
extern WXDLLIMPEXP_DATA_BASE(const bool) wxFalse;
#endif
#define wxAssertFailure wxFalse
/* NB: the following macros also work in release mode! */
/*
These macros must be used only in invalid situation: for example, an
invalid parameter (e.g. a NULL pointer) is passed to a function. Instead of
dereferencing it and causing core dump the function might try using
CHECK( p != NULL ) or CHECK( p != NULL, return LogError("p is NULL!!") )
*/
/* check that expression is true, "return" if not (also FAILs in debug mode) */
#define wxCHECK(cond, rc) wxCHECK_MSG(cond, rc, NULL)
/* as wxCHECK but with a message explaining why we fail */
#define wxCHECK_MSG(cond, rc, msg) wxCHECK2_MSG(cond, return rc, msg)
/* check that expression is true, perform op if not */
#define wxCHECK2(cond, op) wxCHECK2_MSG(cond, op, NULL)
/* as wxCHECK2 but with a message explaining why we fail */
#ifdef __GNUC__
#define wxFORCE_SEMICOLON typedef int wxDummyCheckInt
/* Note: old gcc versions (e.g. 2.8) give an internal compiler error */
/* on a simple forward declaration, when used in a template */
/* function, so rather use a dummy typedef which does work... */
#else
#define wxFORCE_SEMICOLON struct wxDummyCheckStruct
/* Note2: however, some other compilers (notably Digital Mars */
/* don't like multiple typedefs (even though the standard */
/* does allow them), so use a forward declaration for non-gcc. */
#endif
/* see comment near the definition of wxASSERT_MSG for the # if/else reason */
#if defined(__MWERKS__)
#define wxCHECK2_MSG(cond, op, msg) \
if ( cond ) \
{} \
else \
{ \
wxFAIL_COND_MSG(#cond, msg); \
op; \
} \
struct wxDummyCheckStruct /* just to force a semicolon */
#else
#define wxCHECK2_MSG(cond, op, msg) \
if ( cond ) \
; \
else \
{ \
wxFAIL_COND_MSG(#cond, msg); \
op; \
} \
wxFORCE_SEMICOLON /* just to force a semicolon */
#endif
/* special form of wxCHECK2: as wxCHECK, but for use in void functions */
/* */
/* NB: there is only one form (with msg parameter) and it's intentional: */
/* there is no other way to tell the caller what exactly went wrong */
/* from the void function (of course, the function shouldn't be void */
/* to begin with...) */
#define wxCHECK_RET(cond, msg) wxCHECK2_MSG(cond, return, msg)
/* ---------------------------------------------------------------------------- */
/* Compile time asserts */
/* */
/* Unlike the normal assert and related macros above which are checked during */
/* the program tun-time the macros below will result in a compilation error if */
/* the condition they check is false. This is usually used to check the */
/* expressions containing sizeof()s which cannot be tested with the */
/* preprocessor. If you can use the #if's, do use them as you can give a more */
/* detailed error message then. */
/* ---------------------------------------------------------------------------- */
/*
How this works (you don't have to understand it to be able to use the
macros): we rely on the fact that it is invalid to define a named bit field
in a struct of width 0. All the rest are just the hacks to minimize the
possibility of the compiler warnings when compiling this macro: in
particular, this is why we define a struct and not an object (which would
result in a warning about unused variable) and a named struct (otherwise we'd
get a warning about an unnamed struct not used to define an object!).
*/
#define wxMAKE_UNIQUE_ASSERT_NAME wxMAKE_UNIQUE_NAME(wxAssert_)
/*
The second argument of this macro must be a valid C++ identifier and not a
string. I.e. you should use it like this:
wxCOMPILE_TIME_ASSERT( sizeof(int) >= 2, YourIntsAreTooSmall );
It may be used both within a function and in the global scope.
*/
#if defined(__WATCOMC__) && defined(__cplusplus)
/* avoid "unused symbol" warning */
#define wxCOMPILE_TIME_ASSERT(expr, msg) \
class wxMAKE_UNIQUE_ASSERT_NAME { \
unsigned int msg: expr; \
wxMAKE_UNIQUE_ASSERT_NAME() { wxUnusedVar(msg); } \
}
#else
#define wxCOMPILE_TIME_ASSERT(expr, msg) \
struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; }
#endif
/*
When using VC++ 6 with "Edit and Continue" on, the compiler completely
mishandles __LINE__ and so wxCOMPILE_TIME_ASSERT() doesn't work, provide a
way to make "unique" assert names by specifying a unique prefix explicitly
*/
#define wxMAKE_UNIQUE_ASSERT_NAME2(text) wxCONCAT(wxAssert_, text)
#define wxCOMPILE_TIME_ASSERT2(expr, msg, text) \
struct wxMAKE_UNIQUE_ASSERT_NAME2(text) { unsigned int msg: expr; }
/* helpers for wxCOMPILE_TIME_ASSERT below, for private use only */
#define wxMAKE_BITSIZE_MSG(type, size) type ## SmallerThan ## size ## Bits
/* a special case of compile time assert: check that the size of the given type */
/* is at least the given number of bits */
#define wxASSERT_MIN_BITSIZE(type, size) \
wxCOMPILE_TIME_ASSERT(sizeof(type) * CHAR_BIT >= size, \
wxMAKE_BITSIZE_MSG(type, size))
/* ---------------------------------------------------------------------------- */
/* other miscellaneous debugger-related functions */
/* ---------------------------------------------------------------------------- */
/*
Return true if we're running under debugger.
Currently this only really works under Win32 and Mac in CodeWarrior builds,
it always returns false in other cases.
*/
#ifdef __cplusplus
/* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */
#if defined(__WXMAC__) || defined(__WIN32__)
extern bool WXDLLIMPEXP_BASE wxIsDebuggerRunning();
#else /* !Mac */
inline bool wxIsDebuggerRunning() { return false; }
#endif /* Mac/!Mac */
#endif /* __cplusplus */
#endif /* _WX_DEBUG_H_ */

View File

@ -0,0 +1,235 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/debugrpt.h
// Purpose: declaration of wxDebugReport class
// Author: Vadim Zeitlin
// Created: 2005-01-17
// RCS-ID: $Id: debugrpt.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DEBUGRPT_H_
#define _WX_DEBUGRPT_H_
#include "wx/defs.h"
#if wxUSE_DEBUGREPORT && wxUSE_XML
#include "wx/string.h"
#include "wx/arrstr.h"
class WXDLLIMPEXP_FWD_XML wxXmlNode;
// ----------------------------------------------------------------------------
// wxDebugReport: generate a debug report, processing is done in derived class
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_QA wxDebugReport
{
public:
// this is used for the functions which may report either the current state
// or the state during the last (fatal) exception
enum Context { Context_Current, Context_Exception };
// ctor creates a temporary directory where we create the files which will
// be included in the report, use IsOk() to check for errors
wxDebugReport();
// dtor normally destroys the temporary directory created in the ctor (with
// all the files it contains), call Reset() to prevent this from happening
virtual ~wxDebugReport();
// return the name of the directory used for this report
const wxString& GetDirectory() const { return m_dir; }
// return true if the object was successfully initialized
bool IsOk() const { return !GetDirectory().empty(); }
// reset the directory name we use, the object can't be used any more after
// this as it becomes invalid/uninitialized
void Reset() { m_dir.clear(); }
// add another file to the report: the file must already exist, its name
// can be either absolute in which case it is copied to the debug report
// directory or relative to GetDirectory()
//
// description is shown to the user in the report summary
virtual void AddFile(const wxString& filename, const wxString& description);
// convenience function: write the given text to a file with the given name
// and then add it to the report (the difference with AddFile() is that the
// file will be created by this function and doesn't have to already exist)
bool AddText(const wxString& filename,
const wxString& text,
const wxString& description);
#if wxUSE_STACKWALKER
// add an XML file containing the current or exception context and the
// stack trace
bool AddCurrentContext() { return AddContext(Context_Current); }
bool AddExceptionContext() { return AddContext(Context_Exception); }
virtual bool AddContext(Context ctx);
#endif
#if wxUSE_CRASHREPORT
// add a file with crash report
bool AddCurrentDump() { return AddDump(Context_Current); }
bool AddExceptionDump() { return AddDump(Context_Exception); }
virtual bool AddDump(Context ctx);
#endif // wxUSE_CRASHREPORT
// add all available information to the report
void AddAll(Context context = Context_Exception);
// process this report: the base class simply notifies the user that the
// report has been generated, this is usually not enough -- instead you
// should override this method to do something more useful to you
bool Process();
// get the name used as base name for various files, by default
// wxApp::GetName()
virtual wxString GetReportName() const;
// get the files in this report
size_t GetFilesCount() const { return m_files.GetCount(); }
bool GetFile(size_t n, wxString *name, wxString *desc) const;
// remove the file from report: this is used by wxDebugReportPreview to
// allow the user to remove files potentially containing private
// information from the report
void RemoveFile(const wxString& name);
protected:
#if wxUSE_STACKWALKER
// used by AddContext()
virtual bool DoAddSystemInfo(wxXmlNode *nodeSystemInfo);
virtual bool DoAddLoadedModules(wxXmlNode *nodeModules);
virtual bool DoAddExceptionInfo(wxXmlNode *nodeContext);
virtual void DoAddCustomContext(wxXmlNode * WXUNUSED(nodeRoot)) { }
#endif
// used by Process()
virtual bool DoProcess();
private:
// name of the report directory
wxString m_dir;
// the arrays of files in this report and their descriptions
wxArrayString m_files,
m_descriptions;
};
#if wxUSE_ZIPSTREAM
// ----------------------------------------------------------------------------
// wxDebugReportCompress: compress all files of this debug report in a .ZIP
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_QA wxDebugReportCompress : public wxDebugReport
{
public:
wxDebugReportCompress() { }
// returns the full path of the compressed file (empty if creation failed)
const wxString& GetCompressedFileName() const { return m_zipfile; }
protected:
virtual bool DoProcess();
private:
// full path to the ZIP file we created
wxString m_zipfile;
};
// ----------------------------------------------------------------------------
// wxDebugReportUploader: uploads compressed file using HTTP POST request
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_QA wxDebugReportUpload : public wxDebugReportCompress
{
public:
// this class will upload the compressed file created by its base class to
// an HTML multipart/form-data form at the specified address
//
// the URL is the base address, input is the name of the "type=file"
// control on the form used for the file name and action is the value of
// the form action field
wxDebugReportUpload(const wxString& url,
const wxString& input,
const wxString& action,
const wxString& curl = _T("curl"));
protected:
virtual bool DoProcess();
// this function may be overridden in a derived class to show the output
// from curl: this may be an HTML page or anything else that the server
// returned
//
// return value becomes the return value of Process()
virtual bool OnServerReply(const wxArrayString& WXUNUSED(reply))
{
return true;
}
private:
// the full URL to use with HTTP POST request
wxString m_uploadURL;
// the name of the input field containing the file name in the form at
// above URL
wxString m_inputField;
// the curl command (by default it is just "curl" but could be full path to
// curl or a wrapper script with curl-compatible syntax)
wxString m_curlCmd;
};
#endif // wxUSE_ZIPSTREAM
// ----------------------------------------------------------------------------
// wxDebugReportPreview: presents the debug report to the user and allows him
// to veto report entirely or remove some parts of it
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_QA wxDebugReportPreview
{
public:
// ctor is trivial
wxDebugReportPreview() { }
// present the report to the user and allow him to modify it by removing
// some or all of the files and, potentially, adding some notes
//
// return true if the report should be processed or false if the user chose
// to cancel report generation or removed all files from it
virtual bool Show(wxDebugReport& dbgrpt) const = 0;
// dtor is trivial as well but should be virtual for a base class
virtual ~wxDebugReportPreview() { }
};
#if wxUSE_GUI
// ----------------------------------------------------------------------------
// wxDebugReportPreviewStd: standard debug report preview window
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_QA wxDebugReportPreviewStd : public wxDebugReportPreview
{
public:
wxDebugReportPreviewStd() { }
virtual bool Show(wxDebugReport& dbgrpt) const;
};
#endif // wxUSE_GUI
#endif // wxUSE_DEBUGREPORT && wxUSE_XML
#endif // _WX_DEBUGRPT_H_

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More