Compare commits
1 Commits
wxPy_b4_vi
...
BEFORE_INI
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b692ff639 |
2
include/.cvsignore
Normal file
2
include/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile.in
|
||||
*.mch
|
||||
2
include/wx/.cvsignore
Normal file
2
include/wx/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile.in
|
||||
|
||||
136
include/wx/accel.h
Normal file
136
include/wx/accel.h
Normal file
@@ -0,0 +1,136 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) wxWindows 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 WXDLLEXPORT wxAcceleratorTable;
|
||||
class WXDLLEXPORT wxMenuItem;
|
||||
class WXDLLEXPORT 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
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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)
|
||||
{ }
|
||||
|
||||
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
|
||||
|
||||
private:
|
||||
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 WXDLLEXPORT 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(__WXGTK__)
|
||||
#include "wx/gtk/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
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
|
||||
|
||||
#endif // wxUSE_ACCEL
|
||||
|
||||
#endif
|
||||
// _WX_ACCEL_H_BASE_
|
||||
386
include/wx/access.h
Normal file
386
include/wx/access.h
Normal file
@@ -0,0 +1,386 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/access.h
|
||||
// Purpose: Accessibility classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 2003-02-12
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_ACCESSBASE_H_
|
||||
#define _WX_ACCESSBASE_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "accessbase.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers we have to include here
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#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 WXDLLEXPORT wxAccessible;
|
||||
class WXDLLEXPORT wxWindow;
|
||||
class WXDLLEXPORT wxPoint;
|
||||
class WXDLLEXPORT 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; }
|
||||
|
||||
// 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; }
|
||||
|
||||
// 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"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/generic/access.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/generic/access.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/generic/access.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/generic/access.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/generic/access.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/generic/access.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_ACCESSBASE_H_
|
||||
|
||||
634
include/wx/app.h
Normal file
634
include/wx/app.h
Normal file
@@ -0,0 +1,634 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// 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
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/window.h" // for wxTopLevelWindows
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#include "wx/build.h"
|
||||
|
||||
class WXDLLEXPORT wxApp;
|
||||
class WXDLLEXPORT wxAppTraits;
|
||||
class WXDLLEXPORT wxCmdLineParser;
|
||||
class WXDLLEXPORT wxLog;
|
||||
class WXDLLEXPORT wxMessageOutput;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// typedefs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the type of the function used to create a wxApp object on program start up
|
||||
typedef wxApp* (*wxAppInitializerFunction)();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
wxPRINT_WINDOWS = 1,
|
||||
wxPRINT_POSTSCRIPT = 2
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// support for framebuffer ports
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
// VS: Fullscreen/framebuffer application needs to choose display mode prior
|
||||
// to wxWindows initialization. This class holds information about display
|
||||
// mode. It is used by wxApp::Set/GetDisplayMode.
|
||||
class WXDLLEXPORT wxDisplayModeInfo
|
||||
{
|
||||
public:
|
||||
wxDisplayModeInfo() : m_ok(FALSE) {}
|
||||
wxDisplayModeInfo(unsigned width, unsigned height, unsigned depth)
|
||||
: m_width(width), m_height(height), m_depth(depth), m_ok(TRUE) {}
|
||||
|
||||
unsigned GetWidth() const { return m_width; }
|
||||
unsigned GetHeight() const { return m_height; }
|
||||
unsigned GetDepth() const { return m_depth; }
|
||||
bool IsOk() const { return m_ok; }
|
||||
|
||||
private:
|
||||
unsigned m_width, m_height, m_depth;
|
||||
bool m_ok;
|
||||
};
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAppConsole: wxApp for non-GUI applications
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxAppConsole : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
// ctor and dtor
|
||||
wxAppConsole();
|
||||
virtual ~wxAppConsole();
|
||||
|
||||
|
||||
// the virtual functions which may/must be overridden in the derived class
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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 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();
|
||||
|
||||
// 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
|
||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||
|
||||
// called after successfully parsing the command line, return TRUE
|
||||
// to continue and FALSE to exit
|
||||
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<66>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.
|
||||
virtual wxLog *CreateLogTarget();
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
// similar to CreateLogTarget() but for the global wxMessageOutput
|
||||
// object
|
||||
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);
|
||||
|
||||
// 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() { }
|
||||
|
||||
|
||||
// debugging support
|
||||
// -----------------
|
||||
|
||||
// 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 place where the assert occured, the text of the
|
||||
// assert itself and the user-specified message
|
||||
#ifdef __WXDEBUG__
|
||||
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 wxBuildOptions& buildOptions);
|
||||
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// helpers for dynamic wxApp construction
|
||||
static void SetInitializerFunction(wxAppInitializerFunction fn)
|
||||
{ ms_appInitFn = fn; }
|
||||
static wxAppInitializerFunction GetInitializerFunction()
|
||||
{ return ms_appInitFn; }
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
// 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 WXDLLEXPORT wxAppBase : public wxAppConsole
|
||||
{
|
||||
public:
|
||||
wxAppBase();
|
||||
virtual ~wxAppBase();
|
||||
|
||||
// the virtual functions which may/must be overridden in the derived class
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// 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();
|
||||
|
||||
// exit the main loop thus terminating the application
|
||||
virtual void Exit();
|
||||
|
||||
|
||||
// the worker functions - usually not used directly by the user code
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
// execute the main GUI loop, the function returns when the loop ends
|
||||
virtual int MainLoop() = 0;
|
||||
|
||||
// exit the main GUI loop during the next iteration (i.e. it does not
|
||||
// stop the program immediately!)
|
||||
virtual void ExitMainLoop() = 0;
|
||||
|
||||
// returns TRUE if the program is initialized
|
||||
virtual bool Initialized() = 0;
|
||||
|
||||
// returns TRUE if there are unprocessed events in the event queue
|
||||
virtual bool Pending() = 0;
|
||||
|
||||
// process the first event in the event queue (blocks until an event
|
||||
// apperas if there are none currently)
|
||||
virtual void Dispatch() = 0;
|
||||
|
||||
// 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() = 0;
|
||||
|
||||
|
||||
// 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
|
||||
{
|
||||
if (m_topWindow)
|
||||
return m_topWindow;
|
||||
else if (wxTopLevelWindows.GetCount() > 0)
|
||||
return wxTopLevelWindows.GetFirst()->GetData();
|
||||
else
|
||||
return (wxWindow *)NULL;
|
||||
}
|
||||
|
||||
// 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).
|
||||
virtual wxDisplayModeInfo GetDisplayMode() const { return wxDisplayModeInfo(); }
|
||||
// Set display mode to use. This is only used in framebuffer wxWin
|
||||
// ports (such as wxMGL). This method should be called from
|
||||
// wxApp::OnInitGui
|
||||
virtual bool SetDisplayMode(const wxDisplayModeInfo& WXUNUSED(info)) { return TRUE; }
|
||||
|
||||
// set use of best visual flag (see below)
|
||||
void SetUseBestVisual( bool flag ) { m_useBestVisual = flag; }
|
||||
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; }
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
protected:
|
||||
// override base class method to use GUI traits
|
||||
virtual wxAppTraits *CreateTraits();
|
||||
|
||||
|
||||
// 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 apps whats to use the best visual on systems where
|
||||
// more than one are available (Sun, SGI, XFree86 4.0 ?)
|
||||
bool m_useBestVisual;
|
||||
|
||||
// does any of our windows has focus?
|
||||
bool m_isActive;
|
||||
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxAppBase)
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// now include the declaration of the real class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
#if 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(__WXGTK__)
|
||||
#include "wx/gtk/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
|
||||
// can't use typedef because wxApp forward declared as a class
|
||||
class WXDLLEXPORT wxApp : public wxAppConsole
|
||||
{
|
||||
};
|
||||
#endif // GUI/!GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the global data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the one and only application object - use of wxTheApp in application code
|
||||
// is discouraged, 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)
|
||||
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// event loop related functions only work in GUI programs
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Force an exit from main loop
|
||||
extern void WXDLLEXPORT wxExit();
|
||||
|
||||
// Yield to other apps/messages
|
||||
extern bool WXDLLEXPORT wxYield();
|
||||
|
||||
// Yield to other apps/messages
|
||||
extern void WXDLLEXPORT wxWakeUpIdle();
|
||||
|
||||
|
||||
// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros
|
||||
// and call these functions instead at the program startup and termination
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#if !wxUSE_GUI
|
||||
|
||||
// initialize the library (may be called as many times as needed, but each
|
||||
// call to wxInitialize() must be matched by wxUninitialize())
|
||||
extern bool WXDLLEXPORT wxInitialize();
|
||||
|
||||
// clean up - the library can't be used any more after the last call to
|
||||
// wxUninitialize()
|
||||
extern void WXDLLEXPORT wxUninitialize();
|
||||
|
||||
// create an object of this class on stack to initialize/cleanup thel ibrary
|
||||
// automatically
|
||||
class WXDLLEXPORT wxInitializer
|
||||
{
|
||||
public:
|
||||
// initialize the library
|
||||
wxInitializer() { m_ok = wxInitialize(); }
|
||||
|
||||
// has the initialization been successful? (explicit test)
|
||||
bool IsOk() const { return m_ok; }
|
||||
|
||||
// has the initialization been successful? (implicit test)
|
||||
operator bool() const { return m_ok; }
|
||||
|
||||
// dtor only does clean up if we initialized the library properly
|
||||
~wxInitializer() { if ( m_ok ) wxUninitialize(); }
|
||||
|
||||
private:
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
#endif // !wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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 WXDLLEXPORT wxAppInitializer
|
||||
{
|
||||
public:
|
||||
wxAppInitializer(wxAppInitializerFunction fn)
|
||||
{ wxApp::SetInitializerFunction(fn); }
|
||||
};
|
||||
|
||||
// Here's a macro 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.
|
||||
|
||||
#if !wxUSE_GUI || defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__) || defined(__WXMGL__) || defined(__WXCOCOA__)
|
||||
#define IMPLEMENT_WXWIN_MAIN \
|
||||
extern int wxEntry( int argc, char **argv ); \
|
||||
int main(int argc, char **argv) { return wxEntry(argc, argv); }
|
||||
#elif defined(__WXMAC__)
|
||||
// wxMac seems to have a specific wxEntry prototype
|
||||
#define IMPLEMENT_WXWIN_MAIN \
|
||||
extern int wxEntry( int argc, char **argv, bool enterLoop = TRUE ); \
|
||||
int main(int argc, char **argv) { return wxEntry(argc, argv); }
|
||||
#elif defined(__WXMSW__) && defined(WXUSINGDLL)
|
||||
// NT defines APIENTRY, 3.x not
|
||||
#if !defined(WXAPIENTRY)
|
||||
#define WXAPIENTRY WXFAR wxSTDCALL
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include "wx/msw/winundef.h"
|
||||
|
||||
#define IMPLEMENT_WXWIN_MAIN \
|
||||
extern "C" int WXAPIENTRY WinMain(HINSTANCE hInstance,\
|
||||
HINSTANCE hPrevInstance,\
|
||||
LPSTR m_lpCmdLine, int nCmdShow)\
|
||||
{\
|
||||
return wxEntry((WXHINSTANCE) hInstance,\
|
||||
(WXHINSTANCE) hPrevInstance,\
|
||||
m_lpCmdLine, nCmdShow);\
|
||||
}
|
||||
#else
|
||||
#define IMPLEMENT_WXWIN_MAIN
|
||||
#endif
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
#define IMPLEMENT_WX_THEME_SUPPORT \
|
||||
WX_USE_THEME(win32); \
|
||||
WX_USE_THEME(gtk);
|
||||
#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) \
|
||||
wxApp *wxCreateApp() \
|
||||
{ \
|
||||
wxApp::CheckBuildOptions(wxBuildOptions()); \
|
||||
return new appname; \
|
||||
} \
|
||||
wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
|
||||
appname& wxGetApp() { return *(appname *)wxTheApp; }
|
||||
|
||||
// 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
|
||||
|
||||
// this macro can be used multiple times and just allows you to use wxGetApp()
|
||||
// function
|
||||
#define DECLARE_APP(appname) extern appname& wxGetApp();
|
||||
|
||||
#endif
|
||||
// _WX_APP_H_BASE_
|
||||
183
include/wx/apptrait.h
Normal file
183
include/wx/apptrait.h
Normal file
@@ -0,0 +1,183 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/apptrait.h
|
||||
// Purpose: declaration of wxAppTraits and derived classes
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 19.06.2003
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_APPTRAIT_H_
|
||||
#define _WX_APPTRAIT_H_
|
||||
|
||||
class WXDLLEXPORT wxAppTraits;
|
||||
#if wxUSE_FONTMAP
|
||||
class WXDLLEXPORT wxFontMapper;
|
||||
#endif // wxUSE_FONTMAP
|
||||
class WXDLLEXPORT wxLog;
|
||||
class WXDLLEXPORT wxMessageOutput;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAppTraits: this class defines various configurable aspects of wxApp
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxAppTraitsBase
|
||||
{
|
||||
public:
|
||||
// wxAppTraits is an ABC, but we also provide 2 standard implementations of
|
||||
// it, one for the console apps and the other for the GUI ones
|
||||
static wxAppTraits *CreateConsole();
|
||||
#if wxUSE_GUI
|
||||
static wxAppTraits *CreateGUI();
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
// other miscellaneous helpers
|
||||
// ---------------------------
|
||||
|
||||
// wxGetOsVersion() behaves differently in GUI and non-GUI builds under
|
||||
// Unix: in the former case it returns the information about the toolkit
|
||||
// and in the latter -- about the OS, so we need to virtualize it
|
||||
virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include the platform-specific version of the class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/apptbase.h"
|
||||
#elif defined(__UNIX__)
|
||||
#include "wx/unix/apptbase.h"
|
||||
#else // no platform-specific methods to add to wxAppTraits
|
||||
typedef
|
||||
// wxAppTraits must be a class because it was forward declared as class
|
||||
class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
|
||||
{
|
||||
};
|
||||
#endif // platform
|
||||
|
||||
// ============================================================================
|
||||
// standard traits for console and GUI applications
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class 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
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
virtual bool ShowAssertDialog(const wxString& msg);
|
||||
#endif // __WXDEBUG__
|
||||
virtual bool HasStderr();
|
||||
|
||||
virtual void ScheduleForDestroy(wxObject *object);
|
||||
virtual void RemoveFromPendingDelete(wxObject *object);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
class 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
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
virtual bool ShowAssertDialog(const wxString& msg);
|
||||
#endif // __WXDEBUG__
|
||||
virtual bool HasStderr();
|
||||
|
||||
virtual void ScheduleForDestroy(wxObject *object);
|
||||
virtual void RemoveFromPendingDelete(wxObject *object);
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include the platform-specific version of the classes above
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/apptrait.h"
|
||||
#elif defined(__UNIX__)
|
||||
#include "wx/unix/apptrait.h"
|
||||
#else // no platform-specific methods to add to wxAppTraits
|
||||
#if wxUSE_GUI
|
||||
typedef wxGUIAppTraitsBase wxGUIAppTraits;
|
||||
#endif // wxUSE_GUI
|
||||
typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
|
||||
#endif // platform
|
||||
|
||||
#endif // _WX_APPTRAIT_H_
|
||||
|
||||
120
include/wx/arrimpl.cpp
Normal file
120
include/wx/arrimpl.cpp
Normal 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$
|
||||
// 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.Count(); 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 < Count(); ui++ ) \
|
||||
delete (T*)wxBaseArrayPtrVoid::Item(ui); \
|
||||
} \
|
||||
\
|
||||
void name::RemoveAt(size_t uiIndex, size_t nRemove) \
|
||||
{ \
|
||||
wxCHECK_RET( uiIndex < Count(), _WX_ERROR_REMOVE2(name) ); \
|
||||
\
|
||||
for (size_t i = 0; i < nRemove; i++ ) \
|
||||
delete (T*)wxBaseArrayPtrVoid::Item(uiIndex + i); \
|
||||
\
|
||||
wxBaseArrayPtrVoid::RemoveAt(uiIndex, nRemove); \
|
||||
} \
|
||||
\
|
||||
void name::Add(const T& item, size_t nInsert) \
|
||||
{ \
|
||||
if (nInsert == 0) \
|
||||
return; \
|
||||
T* pItem = new T(item); \
|
||||
size_t nOldSize = GetCount(); \
|
||||
if ( pItem != NULL ) \
|
||||
wxBaseArrayPtrVoid::Add(pItem, nInsert); \
|
||||
for (size_t i = 1; i < nInsert; i++) \
|
||||
wxBaseArrayPtrVoid::Item(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 ) \
|
||||
wxBaseArrayPtrVoid::Insert(pItem, uiIndex, nInsert); \
|
||||
for (size_t i = 1; i < nInsert; i++) \
|
||||
wxBaseArrayPtrVoid::Item(uiIndex + i) = new T(item); \
|
||||
} \
|
||||
\
|
||||
int name::Index(const T& Item, bool bFromEnd) const \
|
||||
{ \
|
||||
if ( bFromEnd ) { \
|
||||
if ( Count() > 0 ) { \
|
||||
size_t ui = Count() - 1; \
|
||||
do { \
|
||||
if ( (T*)wxBaseArrayPtrVoid::Item(ui) == &Item ) \
|
||||
return ui; \
|
||||
ui--; \
|
||||
} \
|
||||
while ( ui != 0 ); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
for( size_t ui = 0; ui < Count(); ui++ ) { \
|
||||
if( (T*)wxBaseArrayPtrVoid::Item(ui) == &Item ) \
|
||||
return 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)
|
||||
142
include/wx/artprov.h
Normal file
142
include/wx/artprov.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: artprov.h
|
||||
// Purpose: wxArtProvider class
|
||||
// Author: Vaclav Slavik
|
||||
// Modified by:
|
||||
// Created: 18/03/2002
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_ARTPROV_H_
|
||||
#define _WX_ARTPROV_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "artprov.h"
|
||||
#endif
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
class WXDLLEXPORT wxArtProvidersList;
|
||||
class WXDLLEXPORT wxArtProviderCache;
|
||||
class wxArtProviderModule;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef wxString wxArtClient;
|
||||
typedef wxString wxArtID;
|
||||
|
||||
#define wxART_MAKE_CLIENT_ID_FROM_STR(id) (wxString(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_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_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_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER)
|
||||
#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)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxArtProvider class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxArtProvider : public wxObject
|
||||
{
|
||||
public:
|
||||
// Add new provider to the top of providers stack.
|
||||
static void PushProvider(wxArtProvider *provider);
|
||||
|
||||
// Remove latest added provider and delete it.
|
||||
static bool PopProvider();
|
||||
|
||||
// Remove provider. The provider must have been added previously!
|
||||
// The provider is _not_ deleted.
|
||||
static bool RemoveProvider(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);
|
||||
|
||||
protected:
|
||||
friend class wxArtProviderModule;
|
||||
// Initializes default provider
|
||||
static void InitStdProvider();
|
||||
// Destroy caches & all providers
|
||||
static void CleanUpProviders();
|
||||
|
||||
// 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:
|
||||
// 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_
|
||||
181
include/wx/bitmap.h
Normal file
181
include/wx/bitmap.h
Normal file
@@ -0,0 +1,181 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/bitmap.h
|
||||
// Purpose: wxBitmap class interface
|
||||
// Author: Vaclav Slavik
|
||||
// Modified by:
|
||||
// Created: 22.04.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_BITMAP_H_BASE_
|
||||
#define _WX_BITMAP_H_BASE_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "bitmapbase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/gdiobj.h"
|
||||
#include "wx/gdicmn.h" // for wxBitmapType
|
||||
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class WXDLLEXPORT wxBitmapHandler;
|
||||
class WXDLLEXPORT wxImage;
|
||||
class WXDLLEXPORT wxMask;
|
||||
class WXDLLEXPORT wxPalette;
|
||||
|
||||
#if defined(__WXMGL__) || defined(__WXMAC__) || defined(__WXCOCOA__) || defined(__WXMOTIF__) || defined(__WXX11__)
|
||||
// Only used by some ports
|
||||
// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmapHandler: class which knows how to create/load/save bitmaps in
|
||||
// different formats
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
|
||||
{
|
||||
public:
|
||||
wxBitmapHandlerBase()
|
||||
: m_name()
|
||||
, m_extension()
|
||||
, m_type(wxBITMAP_TYPE_INVALID)
|
||||
{ }
|
||||
|
||||
virtual ~wxBitmapHandlerBase() { }
|
||||
|
||||
virtual bool Create(wxBitmap *bitmap, void *data, long flags,
|
||||
int width, int height, int depth = 1) = 0;
|
||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight) = 0;
|
||||
virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
|
||||
int type, const wxPalette *palette = NULL) = 0;
|
||||
|
||||
void SetName(const wxString& name) { m_name = name; }
|
||||
void SetExtension(const wxString& ext) { m_extension = ext; }
|
||||
void SetType(wxBitmapType type) { m_type = type; }
|
||||
wxString GetName() const { return m_name; }
|
||||
wxString GetExtension() const { return m_extension; }
|
||||
wxBitmapType GetType() const { return m_type; }
|
||||
|
||||
protected:
|
||||
wxString m_name;
|
||||
wxString m_extension;
|
||||
wxBitmapType m_type;
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxBitmapBase : public wxGDIObject
|
||||
{
|
||||
public:
|
||||
wxBitmapBase() : wxGDIObject() {}
|
||||
virtual ~wxBitmapBase() {}
|
||||
|
||||
/*
|
||||
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 **bits);
|
||||
wxBitmap(char **bits);
|
||||
wxBitmap(const wxBitmap& bmp);
|
||||
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
|
||||
wxBitmap(const wxImage& image, int depth = -1);
|
||||
wxBitmap& operator = (const wxBitmap& bmp);
|
||||
bool operator == (const wxBitmap& bmp) const;
|
||||
bool operator != (const wxBitmap& bmp) const;
|
||||
|
||||
bool Create(int width, int height, int depth = -1);
|
||||
|
||||
static void InitStandardHandlers();
|
||||
*/
|
||||
|
||||
virtual bool Ok() 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();
|
||||
|
||||
protected:
|
||||
static wxList sm_handlers;
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(wxBitmapBase)
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/bitmap.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/x11/bitmap.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/bitmap.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/bitmap.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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
|
||||
|
||||
#endif
|
||||
// _WX_BITMAP_H_BASE_
|
||||
99
include/wx/bmpbuttn.h
Normal file
99
include/wx/bmpbuttn.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/bmpbutton.h
|
||||
// Purpose: wxBitmapButton class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 25.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_BMPBUTTON_H_BASE_
|
||||
#define _WX_BMPBUTTON_H_BASE_
|
||||
|
||||
#if wxUSE_BMPBUTTON
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/button.h"
|
||||
|
||||
WXDLLEXPORT_DATA(extern 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_bmpNormal(), m_bmpSelected(), m_bmpFocus(), m_bmpDisabled()
|
||||
, m_marginX(0), 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 SetLabel(const wxBitmap& bitmap)
|
||||
{ SetBitmapLabel(bitmap); }
|
||||
|
||||
// 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; }
|
||||
wxBitmap& GetBitmapLabel() { return m_bmpNormal; }
|
||||
wxBitmap& GetBitmapSelected() { return m_bmpSelected; }
|
||||
wxBitmap& GetBitmapFocus() { return m_bmpFocus; }
|
||||
wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; }
|
||||
|
||||
// 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; }
|
||||
|
||||
protected:
|
||||
// function called when any of the bitmaps changes
|
||||
virtual void OnSetBitmap() { }
|
||||
|
||||
// the bitmaps for various states
|
||||
wxBitmap m_bmpNormal,
|
||||
m_bmpSelected,
|
||||
m_bmpFocus,
|
||||
m_bmpDisabled;
|
||||
|
||||
// the margins around the bitmap
|
||||
int m_marginX,
|
||||
m_marginY;
|
||||
private:
|
||||
// Prevent Virtual function hiding warnings
|
||||
void SetLabel(const wxString& rsLabel)
|
||||
{ wxWindowBase::SetLabel(rsLabel); }
|
||||
};
|
||||
|
||||
#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(__WXGTK__)
|
||||
#include "wx/gtk/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_
|
||||
23
include/wx/brush.h
Normal file
23
include/wx/brush.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _WX_BRUSH_H_BASE_
|
||||
#define _WX_BRUSH_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/brush.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/x11/brush.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/brush.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/brush.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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_
|
||||
272
include/wx/buffer.h
Normal file
272
include/wx/buffer.h
Normal file
@@ -0,0 +1,272 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// these classes are for private use only for now, they're not documented
|
||||
|
||||
#ifndef _WX_BUFFER_H
|
||||
#define _WX_BUFFER_H
|
||||
|
||||
#include "wx/wxchar.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Special classes for (wide) character strings: they use malloc/free instead
|
||||
// of new/delete
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define DEFINE_BUFFER(classname, chartype, strdupfunc) \
|
||||
class classname \
|
||||
{ \
|
||||
public: \
|
||||
classname(const chartype *str) \
|
||||
: 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; \
|
||||
} \
|
||||
\
|
||||
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; \
|
||||
} \
|
||||
\
|
||||
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; \
|
||||
}
|
||||
|
||||
DEFINE_BUFFER(wxCharBuffer, char, wxStrdupA);
|
||||
|
||||
#if wxUSE_WCHAR_T
|
||||
|
||||
DEFINE_BUFFER(wxWCharBuffer, wchar_t, wxStrdupW);
|
||||
|
||||
#endif // wxUSE_WCHAR_T
|
||||
|
||||
#undef DEFINE_BUFFER
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#define wxMB2WXbuf wxWCharBuffer
|
||||
#define wxWX2MBbuf wxCharBuffer
|
||||
#define wxWC2WXbuf wxChar*
|
||||
#define wxWX2WCbuf wxChar*
|
||||
#else // ANSI
|
||||
#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 { BLOCK_SIZE = 1024 };
|
||||
|
||||
friend class wxMemoryBuffer;
|
||||
|
||||
// everyting is private as it can only be used by wxMemoryBuffer
|
||||
private:
|
||||
wxMemoryBufferData(size_t size = wxMemoryBufferData::BLOCK_SIZE)
|
||||
: 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::BLOCK_SIZE);
|
||||
if ( !m_data )
|
||||
{
|
||||
free(dataOld);
|
||||
}
|
||||
|
||||
m_size = newSize + wxMemoryBufferData::BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
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::BLOCK_SIZE)
|
||||
{
|
||||
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(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
|
||||
57
include/wx/build.h
Normal file
57
include/wx/build.h
Normal file
@@ -0,0 +1,57 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/build.h
|
||||
// Purpose: wxBuildOptions class declaration
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 07.05.02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_BUILD_H_
|
||||
#define _WX_BUILD_H_
|
||||
|
||||
#include "wx/version.h"
|
||||
|
||||
class WXDLLEXPORT wxAppConsole;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBuildOptions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxBuildOptions
|
||||
{
|
||||
public:
|
||||
// the ctor must be inline to get the compilation settings of the code
|
||||
// which included this header
|
||||
wxBuildOptions()
|
||||
{
|
||||
// debug/release
|
||||
#ifdef __WXDEBUG__
|
||||
m_isDebug = TRUE;
|
||||
#else
|
||||
m_isDebug = FALSE;
|
||||
#endif
|
||||
|
||||
// version: we don't test the micro version as hopefully changes
|
||||
// between 2 micro versions don't result in fatal compatibility
|
||||
// problems
|
||||
m_verMaj = wxMAJOR_VERSION;
|
||||
m_verMin = wxMINOR_VERSION;
|
||||
}
|
||||
|
||||
private:
|
||||
// the version
|
||||
int m_verMaj,
|
||||
m_verMin;
|
||||
|
||||
// compiled with __WXDEBUG__?
|
||||
bool m_isDebug;
|
||||
|
||||
// actually only CheckBuildOptions() should be our friend but well...
|
||||
friend class wxAppConsole;
|
||||
};
|
||||
|
||||
#endif // _WX_BUILD_H_
|
||||
|
||||
56
include/wx/busyinfo.h
Normal file
56
include/wx/busyinfo.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: busyinfo.h
|
||||
// Purpose: Information window (when app is busy)
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __INFOWIN_H__
|
||||
#define __INFOWIN_H__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "busyinfo.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/frame.h"
|
||||
|
||||
#if wxUSE_BUSYINFO
|
||||
|
||||
class WXDLLEXPORT wxInfoFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
wxInfoFrame(wxWindow *parent, const wxString& message);
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxBusyInfo
|
||||
// Displays progress information
|
||||
// Can be used in exactly same way as wxBusyCursor
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBusyInfo : public wxObject
|
||||
{
|
||||
public:
|
||||
wxBusyInfo(const wxString& message, wxWindow *parent = NULL);
|
||||
|
||||
virtual ~wxBusyInfo();
|
||||
|
||||
private:
|
||||
wxInfoFrame *m_InfoFrame;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxBusyInfo)
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
82
include/wx/button.h
Normal file
82
include/wx/button.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/button.h
|
||||
// Purpose: wxButtonBase class
|
||||
// Author: Vadim Zetlin
|
||||
// Modified by:
|
||||
// Created: 15.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vadim Zetlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_BUTTON_H_BASE_
|
||||
#define _WX_BUTTON_H_BASE_
|
||||
|
||||
#if wxUSE_BUTTON
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxButton flags
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// These two flags are obsolete
|
||||
#define wxBU_NOAUTODRAW 0x0000
|
||||
#define wxBU_AUTODRAW 0x0004
|
||||
|
||||
// These flags affect label alignment
|
||||
#define wxBU_LEFT 0x0040
|
||||
#define wxBU_TOP 0x0080
|
||||
#define wxBU_RIGHT 0x0100
|
||||
#define wxBU_BOTTOM 0x0200
|
||||
|
||||
// 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 WXDLLEXPORT wxBitmap;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxButton: a push button
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxButtonBase : public wxControl
|
||||
{
|
||||
public:
|
||||
// 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() { }
|
||||
|
||||
// returns the default button size for this platform
|
||||
static wxSize GetDefaultSize();
|
||||
};
|
||||
|
||||
#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(__WXGTK__)
|
||||
#include "wx/gtk/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"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_BUTTON
|
||||
|
||||
#endif
|
||||
// _WX_BUTTON_H_BASE_
|
||||
216
include/wx/calctrl.h
Normal file
216
include/wx/calctrl.h
Normal file
@@ -0,0 +1,216 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/calctrl.h
|
||||
// Purpose: date-picker control
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 29.12.99
|
||||
// RCS-ID: $Id$
|
||||
// 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/datetime.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 WXDLLEXPORT 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 WXDLLEXPORT wxCalendarCtrl;
|
||||
|
||||
class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent
|
||||
{
|
||||
friend class wxCalendarCtrl;
|
||||
public:
|
||||
wxCalendarEvent() { Init(); }
|
||||
wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
|
||||
|
||||
const wxDateTime& GetDate() const { return m_date; }
|
||||
wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
private:
|
||||
wxDateTime m_date;
|
||||
wxDateTime::WeekDay m_wday;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxCalendarEvent)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxCalendarCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// so far we only have a generic version, so keep it simple
|
||||
#include "wx/generic/calctrl.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// calendar event types and macros for handling them
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED, 950)
|
||||
DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED, 951)
|
||||
DECLARE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED, 952)
|
||||
DECLARE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED, 953)
|
||||
DECLARE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED, 954)
|
||||
DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED, 955)
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
|
||||
|
||||
#define EVT_CALENDAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DOUBLECLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
|
||||
#define EVT_CALENDAR_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
|
||||
#define EVT_CALENDAR_DAY(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
|
||||
#define EVT_CALENDAR_MONTH(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
|
||||
#define EVT_CALENDAR_YEAR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
|
||||
#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CALENDAR_WEEKDAY_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxCalendarEventFunction) & fn, (wxObject *) NULL),
|
||||
|
||||
#endif // wxUSE_CALENDARCTRL
|
||||
|
||||
#endif // _WX_CALCTRL_H_
|
||||
|
||||
234
include/wx/caret.h
Normal file
234
include/wx/caret.h
Normal file
@@ -0,0 +1,234 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: caret.h
|
||||
// Purpose: wxCaretBase class - the interface of wxCaret
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 23.05.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CARET_H_BASE_
|
||||
#define _WX_CARET_H_BASE_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_CARET
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "caret.h"
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxWindow;
|
||||
class WXDLLEXPORT 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);
|
||||
}
|
||||
|
||||
// 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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxCaretSuspend
|
||||
{
|
||||
public:
|
||||
wxCaretSuspend(wxWindow *win)
|
||||
{
|
||||
m_caret = win->GetCaret();
|
||||
if ( m_caret )
|
||||
m_caret->Hide();
|
||||
}
|
||||
|
||||
~wxCaretSuspend()
|
||||
{
|
||||
if ( m_caret )
|
||||
m_caret->Show();
|
||||
}
|
||||
|
||||
private:
|
||||
wxCaret *m_caret;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxCaretSuspend)
|
||||
};
|
||||
|
||||
#endif // wxUSE_CARET
|
||||
|
||||
#endif // _WX_CARET_H_BASE_
|
||||
|
||||
54
include/wx/checkbox.h
Normal file
54
include/wx/checkbox.h
Normal file
@@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/checkbox.h
|
||||
// Purpose: wxCheckBox class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 07.09.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CHECKBOX_H_BASE_
|
||||
#define _WX_CHECKBOX_H_BASE_
|
||||
|
||||
#if wxUSE_CHECKBOX
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxCheckBoxNameStr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxCheckBox: a control which shows a label and a box which may be checked
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxCheckBoxBase : public wxControl
|
||||
{
|
||||
public:
|
||||
// set/get the checked status of the listbox
|
||||
virtual void SetValue(bool value) = 0;
|
||||
virtual bool GetValue() const = 0;
|
||||
|
||||
bool IsChecked() const { return GetValue(); }
|
||||
};
|
||||
|
||||
#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(__WXGTK__)
|
||||
#include "wx/gtk/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"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_CHECKBOX
|
||||
|
||||
#endif
|
||||
// _WX_CHECKBOX_H_BASE_
|
||||
50
include/wx/checklst.h
Normal file
50
include/wx/checklst.h
Normal file
@@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/checklst.h
|
||||
// Purpose: wxCheckListBox class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 12.09.00
|
||||
// RCS-ID: $Id$
|
||||
// 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 wxListBox
|
||||
{
|
||||
public:
|
||||
// check list box specific methods
|
||||
virtual bool IsChecked(size_t item) const = 0;
|
||||
virtual void Check(size_t item, bool check = TRUE) = 0;
|
||||
};
|
||||
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/checklst.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/checklst.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/checklst.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/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_
|
||||
1269
include/wx/chkconf.h
Normal file
1269
include/wx/chkconf.h
Normal file
File diff suppressed because it is too large
Load Diff
7
include/wx/choicdlg.h
Normal file
7
include/wx/choicdlg.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _WX_CHOICDLG_H_BASE_
|
||||
#define _WX_CHOICDLG_H_BASE_
|
||||
|
||||
#include "wx/generic/choicdgg.h"
|
||||
|
||||
#endif
|
||||
// _WX_CHOICDLG_H_BASE_
|
||||
82
include/wx/choice.h
Normal file
82
include/wx/choice.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/choice.h
|
||||
// Purpose: wxChoice class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 26.07.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CHOICE_H_BASE_
|
||||
#define _WX_CHOICE_H_BASE_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "choicebase.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_CHOICE
|
||||
|
||||
#include "wx/ctrlsub.h" // the base class
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxChoice allows to select one of a non-modifiable list of strings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxChoiceBase : public wxControlWithItems
|
||||
{
|
||||
public:
|
||||
// all generic methods are in wxControlWithItems
|
||||
virtual ~wxChoiceBase();
|
||||
|
||||
// single selection logic
|
||||
virtual void SetSelection(int n) = 0;
|
||||
virtual bool SetStringSelection(const wxString& s);
|
||||
|
||||
// don't override this
|
||||
virtual void Select(int n) { SetSelection(n); }
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include the platform-dependent class definition
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/choice.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/choice.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/choice.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/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_
|
||||
142
include/wx/clipbrd.h
Normal file
142
include/wx/clipbrd.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/clipbrd.h
|
||||
// Purpose: wxClipboad class and clipboard functions
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 19.10.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows Team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CLIPBRD_H_BASE_
|
||||
#define _WX_CLIPBRD_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "clipboardbase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_CLIPBOARD
|
||||
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/wxchar.h"
|
||||
|
||||
class WXDLLEXPORT wxDataFormat;
|
||||
class WXDLLEXPORT wxDataObject;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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 ) { }
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include platform-specific class declaration
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/clipbrd.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/clipbrd.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/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(__WXPM__)
|
||||
#include "wx/os2/clipbrd.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// The global clipboard object
|
||||
WXDLLEXPORT_DATA(extern wxClipboard *) wxTheClipboard;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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_
|
||||
209
include/wx/clntdata.h
Normal file
209
include/wx/clntdata.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CLNTDATAH__
|
||||
#define _WX_CLNTDATAH__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "clntdata.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// 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 WXDLLEXPORT wxClientData
|
||||
{
|
||||
public:
|
||||
wxClientData() { }
|
||||
virtual ~wxClientData() { }
|
||||
};
|
||||
|
||||
class WXDLLEXPORT 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 WXDLLEXPORT 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;
|
||||
|
||||
};
|
||||
|
||||
// not Motif-specific, but currently used only under Motif
|
||||
#ifdef __WXMOTIF__
|
||||
|
||||
#include <wx/vector.h>
|
||||
|
||||
struct WXDLLEXPORT wxClientDataDictionaryPair
|
||||
{
|
||||
wxClientDataDictionaryPair( size_t idx ) : index( idx ), data( 0 ) { }
|
||||
|
||||
size_t index;
|
||||
wxClientData* data;
|
||||
};
|
||||
|
||||
WX_DECLARE_VECTOR(wxClientDataDictionaryPair,wxClientDataDictionaryPairVector);
|
||||
|
||||
// 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 WXDLLEXPORT 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 // __WXMOTIF__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
#endif
|
||||
|
||||
231
include/wx/cmdline.h
Normal file
231
include/wx/cmdline.h
Normal file
@@ -0,0 +1,231 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CMDLINE_H_
|
||||
#define _WX_CMDLINE_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "cmdline.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
|
||||
class WXDLLEXPORT 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 WXDLLEXPORT wxCmdLineParser
|
||||
{
|
||||
public:
|
||||
// ctors and initializers
|
||||
// ----------------------
|
||||
|
||||
// default ctor or ctor giving the cmd line in either Unix or Win form
|
||||
wxCmdLineParser() { Init(); }
|
||||
wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); }
|
||||
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, wxChar **argv)
|
||||
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
|
||||
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, wxChar **argv);
|
||||
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 occured
|
||||
//
|
||||
// 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 WXDLLEXPORT wxCmdLineParser
|
||||
{
|
||||
public:
|
||||
static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
|
||||
};
|
||||
|
||||
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
|
||||
|
||||
#endif // _WX_CMDLINE_H_
|
||||
|
||||
131
include/wx/cmdproc.h
Normal file
131
include/wx/cmdproc.h
Normal file
@@ -0,0 +1,131 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CMDPROC_H_
|
||||
#define _WX_CMDPROC_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "cmdproc.h"
|
||||
#endif
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/list.h"
|
||||
|
||||
class WXDLLEXPORT wxMenu;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxCommand: a single command capable of performing itself
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxCommand : public wxObject
|
||||
{
|
||||
public:
|
||||
wxCommand(bool canUndoIt = FALSE, const wxString& name = wxT(""));
|
||||
~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() const { return (wxList&) m_commands; }
|
||||
wxCommand *GetCurrentCommand() const
|
||||
{
|
||||
return (wxCommand *)(m_currentCommand ? m_currentCommand->GetData() : NULL);
|
||||
}
|
||||
int GetMaxCommands() const { return m_maxNoCommands; }
|
||||
virtual void ClearCommands();
|
||||
|
||||
// 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;
|
||||
wxNode* m_currentCommand;
|
||||
|
||||
#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_
|
||||
455
include/wx/cmndata.h
Normal file
455
include/wx/cmndata.h
Normal file
@@ -0,0 +1,455 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cmndata.h
|
||||
// Purpose: Common GDI data classes
|
||||
// Author: Julian Smart and others
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CMNDATA_H_BASE_
|
||||
#define _WX_CMNDATA_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "cmndata.h"
|
||||
#endif
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/font.h"
|
||||
#include "wx/colour.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
class WXDLLEXPORT wxColourData: public wxObject
|
||||
{
|
||||
public:
|
||||
wxColourData();
|
||||
wxColourData(const wxColourData& data);
|
||||
~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();
|
||||
~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; }
|
||||
wxColour &GetColour() { 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:
|
||||
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)
|
||||
*/
|
||||
|
||||
#ifdef __WXMAC__
|
||||
|
||||
class wxNativePrintData ;
|
||||
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxPrintData: public wxObject
|
||||
{
|
||||
public:
|
||||
wxPrintData();
|
||||
wxPrintData(const wxPrintData& printData);
|
||||
~wxPrintData();
|
||||
|
||||
int GetNoCopies() const { return m_printNoCopies; };
|
||||
bool GetCollate() const { return m_printCollate; };
|
||||
int GetOrientation() const { return m_printOrientation; };
|
||||
|
||||
// Is this data OK for showing the print dialog?
|
||||
bool Ok() 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; }
|
||||
|
||||
void SetNoCopies(int v) { m_printNoCopies = v; };
|
||||
void SetCollate(bool flag) { m_printCollate = flag; };
|
||||
void SetOrientation(int orient) { m_printOrientation = orient; };
|
||||
|
||||
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; }
|
||||
|
||||
// PostScript-specific data
|
||||
const wxString& GetPrinterCommand() const { return m_printerCommand; }
|
||||
const wxString& GetPrinterOptions() const { return m_printerOptions; }
|
||||
const wxString& GetPreviewCommand() const { return m_previewCommand; }
|
||||
const wxString& GetFilename() const { return m_filename; }
|
||||
const wxString& GetFontMetricPath() const { return m_afmPath; }
|
||||
double GetPrinterScaleX() const { return m_printerScaleX; }
|
||||
double GetPrinterScaleY() const { return m_printerScaleY; }
|
||||
long GetPrinterTranslateX() const { return m_printerTranslateX; }
|
||||
long GetPrinterTranslateY() const { return m_printerTranslateY; }
|
||||
wxPrintMode GetPrintMode() const { return m_printMode; }
|
||||
|
||||
void SetPrinterCommand(const wxString& command) { m_printerCommand = command; }
|
||||
void SetPrinterOptions(const wxString& options) { m_printerOptions = options; }
|
||||
void SetPreviewCommand(const wxString& command) { m_previewCommand = command; }
|
||||
void SetFilename(const wxString& filename) { m_filename = filename; }
|
||||
void SetFontMetricPath(const wxString& path) { m_afmPath = path; }
|
||||
void SetPrinterScaleX(double x) { m_printerScaleX = x; }
|
||||
void SetPrinterScaleY(double y) { m_printerScaleY = y; }
|
||||
void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; }
|
||||
void SetPrinterTranslateX(long x) { m_printerTranslateX = x; }
|
||||
void SetPrinterTranslateY(long y) { m_printerTranslateY = y; }
|
||||
void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; }
|
||||
void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
|
||||
|
||||
void operator=(const wxPrintData& data);
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
// Convert to/from the DEVMODE structure
|
||||
void ConvertToNative();
|
||||
void ConvertFromNative();
|
||||
void* GetNativeData() const { return m_devMode; }
|
||||
void SetNativeData(void* data) { m_devMode = data; }
|
||||
void* GetNativeDataDevNames() const { return m_devNames; }
|
||||
void SetNativeDataDevNames(void* data) { m_devNames = data; }
|
||||
#elif defined(__WXMAC__)
|
||||
void ConvertToNative();
|
||||
void ConvertFromNative();
|
||||
#endif
|
||||
|
||||
public:
|
||||
#if defined(__WXMSW__)
|
||||
void* m_devMode;
|
||||
void* m_devNames;
|
||||
#elif defined(__WXMAC__)
|
||||
wxNativePrintData* m_nativePrintData ;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
int m_printNoCopies;
|
||||
int m_printOrientation;
|
||||
bool m_printCollate;
|
||||
|
||||
// New members, 24/3/99
|
||||
wxString m_printerName;
|
||||
bool m_colour;
|
||||
wxDuplexMode m_duplexMode;
|
||||
wxPrintQuality m_printQuality;
|
||||
wxPaperSize m_paperId;
|
||||
wxSize m_paperSize;
|
||||
|
||||
// PostScript-specific data
|
||||
wxString m_printerCommand;
|
||||
wxString m_previewCommand;
|
||||
wxString m_printerOptions;
|
||||
wxString m_filename;
|
||||
wxString m_afmPath;
|
||||
double m_printerScaleX;
|
||||
double m_printerScaleY;
|
||||
long m_printerTranslateX;
|
||||
long m_printerTranslateY;
|
||||
wxPrintMode m_printMode;
|
||||
|
||||
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);
|
||||
~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; };
|
||||
bool GetSetupDialog() const { return m_printSetupDialog; };
|
||||
|
||||
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; };
|
||||
void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
|
||||
|
||||
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 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
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Convert to/from the PRINTDLG structure
|
||||
void ConvertToNative();
|
||||
void ConvertFromNative();
|
||||
void SetOwnerWindow(wxWindow* win);
|
||||
void* GetNativeData() const { return m_printDlgData; }
|
||||
#elif defined(__WXMAC__)
|
||||
void ConvertToNative();
|
||||
void ConvertFromNative();
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
void* m_printDlgData;
|
||||
#endif
|
||||
|
||||
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;
|
||||
bool m_printSetupDialog;
|
||||
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);
|
||||
~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 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; };
|
||||
|
||||
#if defined(__WIN95__)
|
||||
// Convert to/from the PAGESETUPDLG structure
|
||||
void ConvertToNative();
|
||||
void ConvertFromNative();
|
||||
void SetOwnerWindow(wxWindow* win);
|
||||
void* GetNativeData() const { return m_pageSetupData; }
|
||||
#elif defined(__WXMAC__)
|
||||
void ConvertToNative();
|
||||
void ConvertFromNative();
|
||||
#endif
|
||||
|
||||
// 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; }
|
||||
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
|
||||
|
||||
#if defined(__WIN95__)
|
||||
void* m_pageSetupData;
|
||||
#endif
|
||||
|
||||
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_
|
||||
36
include/wx/colordlg.h
Normal file
36
include/wx/colordlg.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/colrdlgg.h
|
||||
// Purpose: wxColourDialog
|
||||
// Author: Vadim Zeitiln
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_COLORDLG_H_BASE_
|
||||
#define _WX_COLORDLG_H_BASE_
|
||||
|
||||
#if wxUSE_COLOURDLG
|
||||
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/colordlg.h"
|
||||
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/mac/colordlg.h"
|
||||
#else
|
||||
#include "wx/generic/colrdlgg.h"
|
||||
|
||||
#define wxColourDialog wxGenericColourDialog
|
||||
#define sm_classwxColourDialog sm_classwxGenericColourDialog
|
||||
#endif
|
||||
|
||||
// get the colour from user and return it
|
||||
wxColour WXDLLEXPORT
|
||||
wxGetColourFromUser(wxWindow *parent = (wxWindow *)NULL,
|
||||
const wxColour& colInit = wxNullColour);
|
||||
|
||||
#endif // wxUSE_COLOURDLG
|
||||
|
||||
#endif
|
||||
// _WX_COLORDLG_H_BASE_
|
||||
25
include/wx/colour.h
Normal file
25
include/wx/colour.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _WX_COLOUR_H_BASE_
|
||||
#define _WX_COLOUR_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/colour.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/colour.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/colour.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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_
|
||||
71
include/wx/combobox.h
Normal file
71
include/wx/combobox.h
Normal file
@@ -0,0 +1,71 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/combobox.h
|
||||
// Purpose: wxComboBox declaration
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 24.12.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1996-2000 wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_COMBOBOX_H_BASE_
|
||||
#define _WX_COMBOBOX_H_BASE_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_COMBOBOX
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxComboBoxBase: this interface defines the methods wxComboBox must implement
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#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 long 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); }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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(__WXGTK__)
|
||||
#include "wx/gtk/combobox.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/combobox.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/combobox.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_COMBOBOX
|
||||
|
||||
#endif
|
||||
// _WX_COMBOBOX_H_BASE_
|
||||
351
include/wx/confbase.h
Normal file
351
include/wx/confbase.h
Normal file
@@ -0,0 +1,351 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 Ball<6C>der & Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 07.04.98 (adapted from appconf.h)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1997 Karsten Ball<6C>der Ballueder@usa.net
|
||||
// Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CONFBASE_H_
|
||||
#define _WX_CONFBASE_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "confbase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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) or wxIniConfig
|
||||
// (under Win16))
|
||||
#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
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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 WXDLLEXPORT 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, ...)
|
||||
// primarly for use by desinstallation 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; }
|
||||
|
||||
// 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 wxConfigPathChanger
|
||||
{
|
||||
public:
|
||||
// ctor/dtor do path changing/restorin
|
||||
wxConfigPathChanger(const wxConfigBase *pContainer, const wxString& strEntry);
|
||||
~wxConfigPathChanger();
|
||||
|
||||
// get the key name
|
||||
const wxString& Name() const { return m_strName; }
|
||||
|
||||
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
|
||||
#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
|
||||
#ifdef __WIN32__
|
||||
#define wxConfig wxRegConfig
|
||||
#define sm_classwxConfig sm_classwxRegConfig
|
||||
#else //WIN16
|
||||
#define wxConfig wxIniConfig
|
||||
#define sm_classwxConfig sm_classwxIniConfig
|
||||
#endif
|
||||
#else // either we're under Unix or wish to use files even under Windows
|
||||
#define wxConfig wxFileConfig
|
||||
#define sm_classwxConfig sm_classwxFileConfig
|
||||
#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.
|
||||
*/
|
||||
|
||||
WXDLLEXPORT wxString wxExpandEnvVars(const wxString &sz);
|
||||
|
||||
/*
|
||||
Split path into parts removing '..' in progress
|
||||
*/
|
||||
WXDLLEXPORT void wxSplitPath(wxArrayString& aParts, const wxChar *sz);
|
||||
|
||||
|
||||
#endif
|
||||
// _WX_CONFIG_H_
|
||||
|
||||
17
include/wx/config.h
Normal file
17
include/wx/config.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _WX_CONFIG_H_BASE_
|
||||
#define _WX_CONFIG_H_BASE_
|
||||
|
||||
#include "wx/confbase.h"
|
||||
|
||||
#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
|
||||
# ifdef __WIN32__
|
||||
# include "wx/msw/regconf.h"
|
||||
#else
|
||||
# include "wx/msw/iniconf.h"
|
||||
# endif
|
||||
#else
|
||||
# include "wx/fileconf.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_CONFIG_H_BASE_
|
||||
178
include/wx/containr.h
Normal file
178
include/wx/containr.h
Normal file
@@ -0,0 +1,178 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CONTAINR_H_
|
||||
#define _WX_CONTAINR_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "containr.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxFocusEvent;
|
||||
class WXDLLEXPORT wxNavigationKeyEvent;
|
||||
class WXDLLEXPORT wxWindow;
|
||||
class WXDLLEXPORT 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; }
|
||||
|
||||
// default item access: we have a permanent default item which is the one
|
||||
// set by the user code but we may also have a temporary default item which
|
||||
// would be chosen if the user pressed "Enter" now but the default action
|
||||
// reverts to the "permanent" default as soon as this temporary default
|
||||
// item lsoes focus
|
||||
|
||||
// get the default item, temporary or permanent
|
||||
wxWindow *GetDefaultItem() const
|
||||
{ return m_winTmpDefault ? m_winTmpDefault : m_winDefault; }
|
||||
|
||||
// set the permanent default item, return its old value
|
||||
wxWindow *SetDefaultItem(wxWindow *win)
|
||||
{ wxWindow *winOld = m_winDefault; m_winDefault = win; return winOld; }
|
||||
|
||||
// set a temporary default item, SetTmpDefaultItem(NULL) should be called
|
||||
// soon after a call to SetTmpDefaultItem(window)
|
||||
void SetTmpDefaultItem(wxWindow *win) { m_winTmpDefault = win; }
|
||||
|
||||
// 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 default window (usually a button) or NULL
|
||||
wxWindow *m_winDefault;
|
||||
|
||||
// a temporary override of m_winDefault, use the latter if NULL
|
||||
wxWindow *m_winTmpDefault;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxControlContainer)
|
||||
};
|
||||
|
||||
// this function is for wxWindows 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 RemoveChild(wxWindowBase *child); \
|
||||
virtual wxWindow *GetDefaultItem() const; \
|
||||
virtual wxWindow *SetDefaultItem(wxWindow *child); \
|
||||
virtual void SetTmpDefaultItem(wxWindow *win); \
|
||||
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) \
|
||||
wxWindow *classname::SetDefaultItem(wxWindow *child) \
|
||||
{ \
|
||||
return m_container.SetDefaultItem(child); \
|
||||
} \
|
||||
\
|
||||
void classname::SetTmpDefaultItem(wxWindow *child) \
|
||||
{ \
|
||||
m_container.SetTmpDefaultItem(child); \
|
||||
} \
|
||||
\
|
||||
wxWindow *classname::GetDefaultItem() const \
|
||||
{ \
|
||||
return m_container.GetDefaultItem(); \
|
||||
} \
|
||||
\
|
||||
void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \
|
||||
{ \
|
||||
m_container.HandleOnNavigationKey(event); \
|
||||
} \
|
||||
\
|
||||
void classname::RemoveChild(wxWindowBase *child) \
|
||||
{ \
|
||||
m_container.HandleOnWindowDestroy(child); \
|
||||
\
|
||||
wxWindow::RemoveChild(child); \
|
||||
} \
|
||||
\
|
||||
void classname::SetFocus() \
|
||||
{ \
|
||||
if ( !m_container.DoSetFocus() ) \
|
||||
wxWindow::SetFocus(); \
|
||||
} \
|
||||
\
|
||||
void classname::OnChildFocus(wxChildFocusEvent& event) \
|
||||
{ \
|
||||
m_container.SetLastFocus(event.GetWindow()); \
|
||||
} \
|
||||
\
|
||||
void classname::OnFocus(wxFocusEvent& event) \
|
||||
{ \
|
||||
m_container.HandleOnFocus(event); \
|
||||
} \
|
||||
bool classname::AcceptsFocus() const \
|
||||
{ \
|
||||
return m_container.AcceptsFocus(); \
|
||||
}
|
||||
|
||||
|
||||
#endif // _WX_CONTAINR_H_
|
||||
94
include/wx/control.h
Normal file
94
include/wx/control.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/control.h
|
||||
// Purpose: wxControl common interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 26.07.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CONTROL_H_BASE_
|
||||
#define _WX_CONTROL_H_BASE_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "controlbase.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_CONTROLS
|
||||
|
||||
#include "wx/window.h" // base class
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxControl is the base class for all controls
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxControlBase : public wxWindow
|
||||
{
|
||||
public:
|
||||
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);
|
||||
|
||||
// simulates the event of given type (i.e. wxButton::Command() is just as
|
||||
// if the button was clicked)
|
||||
virtual void Command(wxCommandEvent &event);
|
||||
|
||||
// get the control alignment (left/right/centre, top/bottom/centre)
|
||||
int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; }
|
||||
|
||||
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);
|
||||
|
||||
// inherit colour and font settings from the parent window
|
||||
void InheritAttributes();
|
||||
|
||||
// initialize the common fields of wxCommandEvent
|
||||
void InitCommandEvent(wxCommandEvent& event) const;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include platform-dependent wxControl declarations
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/control.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/control.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/control.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/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_
|
||||
193
include/wx/cshelp.h
Normal file
193
include/wx/cshelp.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cshelp.h
|
||||
// Purpose: Context-sensitive help support classes
|
||||
// Author: Julian Smart, Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 08/09/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Julian Smart, Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CSHELPH__
|
||||
#define _WX_CSHELPH__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "cshelp.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_HELP
|
||||
|
||||
#include "wx/help.h"
|
||||
|
||||
#if wxUSE_BMPBUTTON
|
||||
#include "wx/bmpbuttn.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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_CLASS(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().
|
||||
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 GetHelp() internally if
|
||||
// applicable), return TRUE if it was done or FALSE if no help available
|
||||
// for this window
|
||||
virtual bool ShowHelp(wxWindowBase *window) = 0;
|
||||
|
||||
// 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();
|
||||
|
||||
private:
|
||||
static wxHelpProvider *ms_helpProvider;
|
||||
};
|
||||
|
||||
// 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);
|
||||
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
|
||||
wxStringHashTable 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
|
||||
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_CSHELPH__
|
||||
|
||||
169
include/wx/ctrlsub.h
Normal file
169
include/wx/ctrlsub.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
|
||||
// Purpose: wxControlWithItems interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 22.10.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CTRLSUB_H_BASE_
|
||||
#define _WX_CTRLSUB_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "controlwithitems.h"
|
||||
#endif
|
||||
|
||||
#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.
|
||||
//
|
||||
// Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
|
||||
// implements an extended interface deriving from this one)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxItemContainer
|
||||
{
|
||||
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; }
|
||||
|
||||
// append several items at once to the control
|
||||
void Append(const wxArrayString& strings);
|
||||
|
||||
int Insert(const wxString& item, int pos)
|
||||
{ return DoInsert(item, pos); }
|
||||
int Insert(const wxString& item, int pos, void *clientData);
|
||||
int Insert(const wxString& item, int pos, wxClientData *clientData);
|
||||
|
||||
// deleting items
|
||||
// --------------
|
||||
|
||||
virtual void Clear() = 0;
|
||||
virtual void Delete(int n) = 0;
|
||||
|
||||
// accessing strings
|
||||
// -----------------
|
||||
|
||||
virtual int GetCount() const = 0;
|
||||
bool IsEmpty() const { return GetCount() == 0; }
|
||||
|
||||
virtual wxString GetString(int n) const = 0;
|
||||
virtual void SetString(int n, const wxString& s) = 0;
|
||||
virtual int FindString(const wxString& s) const = 0;
|
||||
|
||||
// selection
|
||||
// ---------
|
||||
|
||||
virtual void Select(int n) = 0;
|
||||
virtual int GetSelection() const = 0;
|
||||
|
||||
wxString GetStringSelection() const;
|
||||
|
||||
// misc
|
||||
// ----
|
||||
|
||||
// client data stuff
|
||||
void SetClientData(int n, void* clientData);
|
||||
void* GetClientData(int n) const;
|
||||
|
||||
void SetClientObject(int n, wxClientData* clientData);
|
||||
wxClientData* GetClientObject(int n) const;
|
||||
|
||||
bool HasClientObjectData() const
|
||||
{ return m_clientDataItemsType == wxClientData_Object; }
|
||||
bool HasClientUntypedData() const
|
||||
{ return m_clientDataItemsType == wxClientData_Void; }
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
// compatibility - these functions are deprecated, use the new ones
|
||||
// instead
|
||||
int Number() const { return GetCount(); }
|
||||
#endif // WXWIN_COMPATIBILITY_2_2
|
||||
|
||||
protected:
|
||||
virtual int DoAppend(const wxString& item) = 0;
|
||||
virtual int DoInsert(const wxString& item, int pos) = 0;
|
||||
|
||||
virtual void DoSetItemClientData(int n, void* clientData) = 0;
|
||||
virtual void* DoGetItemClientData(int n) const = 0;
|
||||
virtual void DoSetItemClientObject(int n, wxClientData* clientData) = 0;
|
||||
virtual wxClientData* DoGetItemClientObject(int n) const = 0;
|
||||
|
||||
// the type of the client data for the items
|
||||
wxClientDataType m_clientDataItemsType;
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
void SetClientData(void *data)
|
||||
{
|
||||
wxControl::SetClientData(data);
|
||||
}
|
||||
|
||||
void *GetClientData() const
|
||||
{
|
||||
return wxControl::GetClientData();
|
||||
}
|
||||
|
||||
void SetClientObject(wxClientData *data)
|
||||
{
|
||||
wxControl::SetClientObject(data);
|
||||
}
|
||||
|
||||
wxClientData *GetClientObject() const
|
||||
{
|
||||
return wxControl::GetClientObject();
|
||||
}
|
||||
|
||||
void SetClientData(int n, void* clientData)
|
||||
{
|
||||
wxItemContainer::SetClientData(n, clientData);
|
||||
}
|
||||
|
||||
void* GetClientData(int n) const
|
||||
{
|
||||
return wxItemContainer::GetClientData(n);
|
||||
}
|
||||
|
||||
void SetClientObject(int n, wxClientData* clientData)
|
||||
{
|
||||
wxItemContainer::SetClientObject(n, clientData);
|
||||
}
|
||||
|
||||
wxClientData* GetClientObject(int n) const
|
||||
{
|
||||
return wxItemContainer::GetClientObject(n);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // wxUSE_CONTROLS
|
||||
|
||||
#endif // _WX_CTRLSUB_H_BASE_
|
||||
|
||||
60
include/wx/cursor.h
Normal file
60
include/wx/cursor.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef _WX_CURSOR_H_BASE_
|
||||
#define _WX_CURSOR_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/cursor.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/cursor.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/cursor.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/cursor.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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_
|
||||
486
include/wx/dataobj.h
Normal file
486
include/wx/dataobj.h
Normal file
@@ -0,0 +1,486 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dataobj.h
|
||||
// Purpose: common data object classes
|
||||
// Author: Vadim Zeitlin, Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 26.05.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows Team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DATAOBJ_H_BASE_
|
||||
#define _WX_DATAOBJ_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dataobjbase.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DATAOBJ
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/list.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(__WXGTK__)
|
||||
#include "wx/gtk/dataform.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/dataform.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/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(__WXGTK__)
|
||||
#include "wx/gtk/dataobj.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/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;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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();
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
protected:
|
||||
// returns the pointer to the object which supports this format or NULL
|
||||
wxDataObjectSimple *GetObject(const wxDataFormat& format) const;
|
||||
#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
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// 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(wxUSE_UNICODE?wxDF_UNICODETEXT:wxDF_TEXT),
|
||||
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
|
||||
// ----------------------------------
|
||||
virtual size_t GetDataSize() const;
|
||||
virtual bool GetDataHere(void *buf) const;
|
||||
virtual bool SetData(size_t len, const void *buf);
|
||||
|
||||
private:
|
||||
wxString m_text;
|
||||
|
||||
// virtual function hiding supression
|
||||
size_t GetDataSize(const wxDataFormat& format) const
|
||||
{ return(wxDataObjectSimple::GetDataSize(format)); }
|
||||
bool GetDataHere(const wxDataFormat& format, void *pBuf) const
|
||||
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
|
||||
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
|
||||
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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; }
|
||||
|
||||
// the Get() functions do nothing for us
|
||||
virtual size_t GetDataSize() const { return 0; }
|
||||
virtual bool GetDataHere(void *WXUNUSED(buf)) const { return FALSE; }
|
||||
|
||||
protected:
|
||||
wxArrayString m_filenames;
|
||||
|
||||
private:
|
||||
// Virtual function hiding supression
|
||||
size_t GetDataSize(const wxDataFormat& format) const
|
||||
{ return(wxDataObjectSimple::GetDataSize(format)); }
|
||||
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
|
||||
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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);
|
||||
|
||||
private:
|
||||
size_t m_size;
|
||||
void *m_data;
|
||||
|
||||
// virtual function hiding supression
|
||||
size_t GetDataSize(const wxDataFormat& format) const
|
||||
{ return(wxDataObjectSimple::GetDataSize(format)); }
|
||||
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
|
||||
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
|
||||
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
|
||||
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
|
||||
|
||||
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(__WXGTK__)
|
||||
#include "wx/gtk/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(__WXPM__)
|
||||
#include "wx/os2/dataobj2.h"
|
||||
#endif
|
||||
|
||||
// wxURLDataObject is simply wxTextDataObject with a different name
|
||||
class WXDLLEXPORT wxURLDataObject : public wxTextDataObject
|
||||
{
|
||||
public:
|
||||
wxString GetURL() const { return GetText(); }
|
||||
void SetURL(const wxString& url) { SetText(url); }
|
||||
};
|
||||
#endif // __WXMSW__/!__WXMSW__
|
||||
|
||||
#endif // wxUSE_DATAOBJ
|
||||
|
||||
#endif // _WX_DATAOBJ_H_BASE_
|
||||
1625
include/wx/datetime.h
Normal file
1625
include/wx/datetime.h
Normal file
File diff suppressed because it is too large
Load Diff
547
include/wx/datetime.inl
Normal file
547
include/wx/datetime.inl
Normal file
@@ -0,0 +1,547 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/datetime.inl
|
||||
// Purpose: definition of inline functions of wxDateTime and related
|
||||
// classes declared in datetime.h
|
||||
// Author: Vadim Zeitlin
|
||||
// Remarks: having the inline functions here allows us to minimize the
|
||||
// dependencies (and hence the rebuild time) in debug builds.
|
||||
// Modified by:
|
||||
// Created: 30.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDED_FROM_WX_DATETIME_H
|
||||
#error "This file is only included by wx/datetime.h, don't include it manually!"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define MILLISECONDS_PER_DAY 86400000l
|
||||
|
||||
// some broken compilers (HP-UX CC) refuse to compile the "normal" version, but
|
||||
// using a temp variable always might prevent other compilers from optimising
|
||||
// it away - hence use of this ugly macro
|
||||
#ifndef __HPUX__
|
||||
#define MODIFY_AND_RETURN(op) return wxDateTime(*this).op
|
||||
#else
|
||||
#define MODIFY_AND_RETURN(op) wxDateTime dt(*this); dt.op; return dt
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTime construction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline bool wxDateTime::IsInStdRange() const
|
||||
{
|
||||
return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX;
|
||||
}
|
||||
|
||||
/* static */
|
||||
inline wxDateTime wxDateTime::Now()
|
||||
{
|
||||
return wxDateTime(*GetTmNow());
|
||||
}
|
||||
|
||||
/* static */
|
||||
inline wxDateTime wxDateTime::Today()
|
||||
{
|
||||
struct tm *time = GetTmNow();
|
||||
time->tm_hour = 0;
|
||||
time->tm_min = 0;
|
||||
time->tm_sec = 0;
|
||||
|
||||
return wxDateTime(*time);
|
||||
}
|
||||
|
||||
#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
|
||||
inline wxDateTime& wxDateTime::Set(time_t timet)
|
||||
{
|
||||
// assign first to avoid long multiplication overflow!
|
||||
m_time = timet - WX_TIME_BASE_OFFSET ;
|
||||
m_time *= TIME_T_FACTOR;
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline wxDateTime& wxDateTime::SetToCurrent()
|
||||
{
|
||||
*this = Now();
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
|
||||
inline wxDateTime::wxDateTime(time_t timet)
|
||||
{
|
||||
Set(timet);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline wxDateTime::wxDateTime(const struct tm& tm)
|
||||
{
|
||||
Set(tm);
|
||||
}
|
||||
|
||||
inline wxDateTime::wxDateTime(const Tm& tm)
|
||||
{
|
||||
Set(tm);
|
||||
}
|
||||
|
||||
inline wxDateTime::wxDateTime(double jdn)
|
||||
{
|
||||
Set(jdn);
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::Set(const Tm& tm)
|
||||
{
|
||||
wxASSERT_MSG( tm.IsValid(), _T("invalid broken down date/time") );
|
||||
|
||||
return Set(tm.mday, (Month)tm.mon, tm.year, tm.hour, tm.min, tm.sec);
|
||||
}
|
||||
|
||||
inline wxDateTime::wxDateTime(wxDateTime_t hour,
|
||||
wxDateTime_t minute,
|
||||
wxDateTime_t second,
|
||||
wxDateTime_t millisec)
|
||||
{
|
||||
Set(hour, minute, second, millisec);
|
||||
}
|
||||
|
||||
inline wxDateTime::wxDateTime(wxDateTime_t day,
|
||||
Month month,
|
||||
int year,
|
||||
wxDateTime_t hour,
|
||||
wxDateTime_t minute,
|
||||
wxDateTime_t second,
|
||||
wxDateTime_t millisec)
|
||||
{
|
||||
Set(day, month, year, hour, minute, second, millisec);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTime accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxLongLong wxDateTime::GetValue() const
|
||||
{
|
||||
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return m_time;
|
||||
}
|
||||
|
||||
inline time_t wxDateTime::GetTicks() const
|
||||
{
|
||||
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
|
||||
if ( !IsInStdRange() )
|
||||
{
|
||||
return (time_t)-1;
|
||||
}
|
||||
|
||||
return (time_t)((m_time / (long)TIME_T_FACTOR).GetLo())+WX_TIME_BASE_OFFSET ;
|
||||
}
|
||||
|
||||
inline bool wxDateTime::SetToLastWeekDay(WeekDay weekday,
|
||||
Month month,
|
||||
int year)
|
||||
{
|
||||
return SetToWeekDay(weekday, -1, month, year);
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetWeekDayInSameWeek(WeekDay weekday,
|
||||
WeekFlags flags) const
|
||||
{
|
||||
MODIFY_AND_RETURN( SetToWeekDayInSameWeek(weekday) );
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetNextWeekDay(WeekDay weekday) const
|
||||
{
|
||||
MODIFY_AND_RETURN( SetToNextWeekDay(weekday) );
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetPrevWeekDay(WeekDay weekday) const
|
||||
{
|
||||
MODIFY_AND_RETURN( SetToPrevWeekDay(weekday) );
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetWeekDay(WeekDay weekday,
|
||||
int n,
|
||||
Month month,
|
||||
int year) const
|
||||
{
|
||||
wxDateTime dt(*this);
|
||||
|
||||
return dt.SetToWeekDay(weekday, n, month, year) ? dt : wxInvalidDateTime;
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetLastWeekDay(WeekDay weekday,
|
||||
Month month,
|
||||
int year)
|
||||
{
|
||||
wxDateTime dt(*this);
|
||||
|
||||
return dt.SetToLastWeekDay(weekday, month, year) ? dt : wxInvalidDateTime;
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetWeek(wxDateTime_t numWeek,
|
||||
WeekDay weekday,
|
||||
WeekFlags flags) const
|
||||
{
|
||||
wxDateTime dt(*this);
|
||||
|
||||
return dt.SetToTheWeek(numWeek, weekday, flags) ? dt : wxInvalidDateTime;
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetLastMonthDay(Month month, int year) const
|
||||
{
|
||||
MODIFY_AND_RETURN( SetToLastMonthDay(month, year) );
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::GetYearDay(wxDateTime_t yday) const
|
||||
{
|
||||
MODIFY_AND_RETURN( SetToYearDay(yday) );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTime comparison
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline bool wxDateTime::IsEqualTo(const wxDateTime& datetime) const
|
||||
{
|
||||
wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return m_time == datetime.m_time;
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsEarlierThan(const wxDateTime& datetime) const
|
||||
{
|
||||
wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return m_time < datetime.m_time;
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsLaterThan(const wxDateTime& datetime) const
|
||||
{
|
||||
wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return m_time > datetime.m_time;
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsStrictlyBetween(const wxDateTime& t1,
|
||||
const wxDateTime& t2) const
|
||||
{
|
||||
// no need for assert, will be checked by the functions we call
|
||||
return IsLaterThan(t1) && IsEarlierThan(t2);
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsBetween(const wxDateTime& t1,
|
||||
const wxDateTime& t2) const
|
||||
{
|
||||
// no need for assert, will be checked by the functions we call
|
||||
return IsEqualTo(t1) || IsEqualTo(t2) || IsStrictlyBetween(t1, t2);
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsSameDate(const wxDateTime& dt) const
|
||||
{
|
||||
Tm tm1 = GetTm(),
|
||||
tm2 = dt.GetTm();
|
||||
|
||||
return tm1.year == tm2.year &&
|
||||
tm1.mon == tm2.mon &&
|
||||
tm1.mday == tm2.mday;
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsSameTime(const wxDateTime& dt) const
|
||||
{
|
||||
// notice that we can't do something like this:
|
||||
//
|
||||
// m_time % MILLISECONDS_PER_DAY == dt.m_time % MILLISECONDS_PER_DAY
|
||||
//
|
||||
// because we have also to deal with (possibly) different DST settings!
|
||||
Tm tm1 = GetTm(),
|
||||
tm2 = dt.GetTm();
|
||||
|
||||
return tm1.hour == tm2.hour &&
|
||||
tm1.min == tm2.min &&
|
||||
tm1.sec == tm2.sec &&
|
||||
tm1.msec == tm2.msec;
|
||||
}
|
||||
|
||||
inline bool wxDateTime::IsEqualUpTo(const wxDateTime& dt,
|
||||
const wxTimeSpan& ts) const
|
||||
{
|
||||
return IsBetween(dt.Subtract(ts), dt.Add(ts));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTime arithmetics
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxDateTime wxDateTime::Add(const wxTimeSpan& diff) const
|
||||
{
|
||||
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return wxDateTime(m_time + diff.GetValue());
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::Add(const wxTimeSpan& diff)
|
||||
{
|
||||
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
m_time += diff.GetValue();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::operator+=(const wxTimeSpan& diff)
|
||||
{
|
||||
return Add(diff);
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::Subtract(const wxTimeSpan& diff) const
|
||||
{
|
||||
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return wxDateTime(m_time - diff.GetValue());
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::Subtract(const wxTimeSpan& diff)
|
||||
{
|
||||
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
m_time -= diff.GetValue();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::operator-=(const wxTimeSpan& diff)
|
||||
{
|
||||
return Subtract(diff);
|
||||
}
|
||||
|
||||
inline wxTimeSpan wxDateTime::Subtract(const wxDateTime& datetime) const
|
||||
{
|
||||
wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
|
||||
|
||||
return wxTimeSpan(GetValue() - datetime.GetValue());
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::Add(const wxDateSpan& diff) const
|
||||
{
|
||||
return wxDateTime(*this).Add(diff);
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::Subtract(const wxDateSpan& diff)
|
||||
{
|
||||
return Add(diff.Negate());
|
||||
}
|
||||
|
||||
inline wxDateTime wxDateTime::Subtract(const wxDateSpan& diff) const
|
||||
{
|
||||
return wxDateTime(*this).Subtract(diff);
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::operator-=(const wxDateSpan& diff)
|
||||
{
|
||||
return Subtract(diff);
|
||||
}
|
||||
|
||||
inline wxDateTime& wxDateTime::operator+=(const wxDateSpan& diff)
|
||||
{
|
||||
return Add(diff);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateTime and timezones
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxDateTime wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz,
|
||||
bool noDST) const
|
||||
{
|
||||
MODIFY_AND_RETURN( MakeTimezone(tz, noDST) );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimeSpan construction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxTimeSpan::wxTimeSpan(long hours,
|
||||
long minutes,
|
||||
long seconds,
|
||||
long milliseconds)
|
||||
{
|
||||
// assign first to avoid precision loss
|
||||
m_diff = hours;
|
||||
m_diff *= 60l;
|
||||
m_diff += minutes;
|
||||
m_diff *= 60l;
|
||||
m_diff += seconds;
|
||||
m_diff *= 1000l;
|
||||
m_diff += milliseconds;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimeSpan accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxLongLong wxTimeSpan::GetSeconds() const
|
||||
{
|
||||
return m_diff / 1000l;
|
||||
}
|
||||
|
||||
inline int wxTimeSpan::GetMinutes() const
|
||||
{
|
||||
return (GetSeconds() / 60l).GetLo();
|
||||
}
|
||||
|
||||
inline int wxTimeSpan::GetHours() const
|
||||
{
|
||||
return GetMinutes() / 60;
|
||||
}
|
||||
|
||||
inline int wxTimeSpan::GetDays() const
|
||||
{
|
||||
return GetHours() / 24;
|
||||
}
|
||||
|
||||
inline int wxTimeSpan::GetWeeks() const
|
||||
{
|
||||
return GetDays() / 7;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimeSpan arithmetics
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxTimeSpan wxTimeSpan::Add(const wxTimeSpan& diff) const
|
||||
{
|
||||
return wxTimeSpan(m_diff + diff.GetValue());
|
||||
}
|
||||
|
||||
inline wxTimeSpan& wxTimeSpan::Add(const wxTimeSpan& diff)
|
||||
{
|
||||
m_diff += diff.GetValue();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxTimeSpan wxTimeSpan::Subtract(const wxTimeSpan& diff) const
|
||||
{
|
||||
return wxTimeSpan(m_diff - diff.GetValue());
|
||||
}
|
||||
|
||||
inline wxTimeSpan& wxTimeSpan::Subtract(const wxTimeSpan& diff)
|
||||
{
|
||||
m_diff -= diff.GetValue();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxTimeSpan& wxTimeSpan::Multiply(int n)
|
||||
{
|
||||
m_diff *= (long)n;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxTimeSpan wxTimeSpan::Multiply(int n) const
|
||||
{
|
||||
return wxTimeSpan(m_diff * (long)n);
|
||||
}
|
||||
|
||||
inline wxTimeSpan wxTimeSpan::Abs() const
|
||||
{
|
||||
return wxTimeSpan(GetValue().Abs());
|
||||
}
|
||||
|
||||
inline bool wxTimeSpan::IsEqualTo(const wxTimeSpan& ts) const
|
||||
{
|
||||
return GetValue() == ts.GetValue();
|
||||
}
|
||||
|
||||
inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const
|
||||
{
|
||||
return GetValue().Abs() > ts.GetValue().Abs();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDateSpan
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline wxDateSpan& wxDateSpan::operator+=(const wxDateSpan& other)
|
||||
{
|
||||
m_years += other.m_years;
|
||||
m_months += other.m_months;
|
||||
m_weeks += other.m_weeks;
|
||||
m_days += other.m_days;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxDateSpan& wxDateSpan::Add(const wxDateSpan& other)
|
||||
{
|
||||
return *this += other;
|
||||
}
|
||||
|
||||
inline wxDateSpan wxDateSpan::Add(const wxDateSpan& other) const
|
||||
{
|
||||
wxDateSpan ds(*this);
|
||||
ds.Add(other);
|
||||
return ds;
|
||||
}
|
||||
|
||||
inline wxDateSpan& wxDateSpan::Multiply(int factor)
|
||||
{
|
||||
m_years *= factor;
|
||||
m_months *= factor;
|
||||
m_weeks *= factor;
|
||||
m_days *= factor;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxDateSpan wxDateSpan::Multiply(int factor) const
|
||||
{
|
||||
wxDateSpan ds(*this);
|
||||
ds.Multiply(factor);
|
||||
return ds;
|
||||
}
|
||||
|
||||
inline wxDateSpan wxDateSpan::Negate() const
|
||||
{
|
||||
return wxDateSpan(-m_years, -m_months, -m_weeks, -m_days);
|
||||
}
|
||||
|
||||
inline wxDateSpan& wxDateSpan::Neg()
|
||||
{
|
||||
m_years = -m_years;
|
||||
m_months = -m_months;
|
||||
m_weeks = -m_weeks;
|
||||
m_days = -m_days;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline wxDateSpan& wxDateSpan::operator-=(const wxDateSpan& other)
|
||||
{
|
||||
return *this += other.Negate();
|
||||
}
|
||||
|
||||
inline wxDateSpan& wxDateSpan::Subtract(const wxDateSpan& other)
|
||||
{
|
||||
return *this -= other;
|
||||
}
|
||||
|
||||
inline wxDateSpan wxDateSpan::Subtract(const wxDateSpan& other) const
|
||||
{
|
||||
wxDateSpan ds(*this);
|
||||
ds.Subtract(other);
|
||||
return ds;
|
||||
}
|
||||
|
||||
#undef MILLISECONDS_PER_DAY
|
||||
|
||||
#undef MODIFY_AND_RETURN
|
||||
114
include/wx/datstrm.h
Normal file
114
include/wx/datstrm.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: datstrm.h
|
||||
// Purpose: Data stream classes
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: 28/06/1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DATSTREAM_H_
|
||||
#define _WX_DATSTREAM_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "datstrm.h"
|
||||
#endif
|
||||
|
||||
#include "wx/stream.h"
|
||||
#include "wx/longlong.h"
|
||||
#include "wx/strconv.h"
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
class WXDLLEXPORT wxDataInputStream
|
||||
{
|
||||
public:
|
||||
#if wxUSE_UNICODE
|
||||
wxDataInputStream(wxInputStream& s, wxMBConv& conv = wxConvUTF8);
|
||||
#else
|
||||
wxDataInputStream(wxInputStream& s);
|
||||
#endif
|
||||
~wxDataInputStream();
|
||||
|
||||
bool IsOk() { return m_input->IsOk(); }
|
||||
|
||||
wxUint64 Read64();
|
||||
wxUint32 Read32();
|
||||
wxUint16 Read16();
|
||||
wxUint8 Read8();
|
||||
double ReadDouble();
|
||||
wxString ReadString();
|
||||
|
||||
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);
|
||||
wxDataInputStream& operator>>(wxUint64& i);
|
||||
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 WXDLLEXPORT wxDataOutputStream
|
||||
{
|
||||
public:
|
||||
#if wxUSE_UNICODE
|
||||
wxDataOutputStream(wxOutputStream& s, wxMBConv& conv = wxConvUTF8);
|
||||
#else
|
||||
wxDataOutputStream(wxOutputStream& s);
|
||||
#endif
|
||||
~wxDataOutputStream();
|
||||
|
||||
bool IsOk() { return m_output->IsOk(); }
|
||||
|
||||
void Write64(wxUint64 i);
|
||||
void Write32(wxUint32 i);
|
||||
void Write16(wxUint16 i);
|
||||
void Write8(wxUint8 i);
|
||||
void WriteDouble(double d);
|
||||
void WriteString(const wxString& string);
|
||||
|
||||
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);
|
||||
wxDataOutputStream& operator<<(wxUint64 i);
|
||||
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_
|
||||
776
include/wx/db.h
Normal file
776
include/wx/db.h
Normal file
@@ -0,0 +1,776 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) 1996 Remstar International, Inc.
|
||||
// Licence: wxWindows licence, plus:
|
||||
// Notice: This class library and its intellectual design are free of charge for use,
|
||||
// modification, enhancement, debugging under the following conditions:
|
||||
// 1) These classes may only be used as part of the implementation of a
|
||||
// wxWindows-based application
|
||||
// 2) All enhancements and bug fixes are to be submitted back to the wxWindows
|
||||
// user groups free of all charges for use with the wxWindows library.
|
||||
// 3) These classes may not be distributed as part of any other class library,
|
||||
// DLL, text (written or electronic), other than a complete distribution of
|
||||
// the wxWindows GUI development toolkit.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DB_H_
|
||||
#define _WX_DB_H_
|
||||
|
||||
|
||||
// BJO 20000503: introduce new GetColumns members which are more database independant and
|
||||
// return columns in the order they were created
|
||||
#define OLD_GETCOLUMNS 1
|
||||
#define EXPERIMENTAL_WXDB_FUNCTIONS 1
|
||||
|
||||
#include "wx/version.h"
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "db.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#ifdef __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
|
||||
#ifndef STRICT
|
||||
#define STRICT 1
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include "wx/msw/winundef.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\wxWindows\src\makevc.env to the WINLIBS= line
|
||||
//
|
||||
#include "sql.h"
|
||||
#include "sqlext.h"
|
||||
#include "odbcinst.h"
|
||||
#else
|
||||
// Use the ones from the library
|
||||
extern "C" {
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
}
|
||||
#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))
|
||||
//# define SQL_C_BOOLEAN (sizeof(int) == 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
|
||||
|
||||
#ifndef SQL_C_BLOB
|
||||
#ifdef SQL_LONGVARBINARY
|
||||
#define SQL_C_BLOB SQL_LONGVARBINARY
|
||||
#elif SQL_VARBINARY
|
||||
#define SQL_C_BLOB SQL_VARBINARY
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
#ifndef TRUE
|
||||
#define TRUE true
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE false
|
||||
#endif
|
||||
*/
|
||||
const int wxDB_PATH_MAX = 254;
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxChar const *) SQL_LOG_FILENAME;
|
||||
WXDLLEXPORT_DATA(extern 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_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
|
||||
|
||||
class WXDLLEXPORT wxDbConnectInf
|
||||
{
|
||||
private:
|
||||
bool freeHenvOnDestroy;
|
||||
|
||||
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)
|
||||
|
||||
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 *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 SetDescription(const wxString &desc) { Description = desc; };
|
||||
void SetFileType(const wxString &fileType) { FileType = fileType; };
|
||||
void SetDefaultDir(const wxString &defDir) { DefaultDir = defDir; };
|
||||
}; // class wxDbConnectInf
|
||||
|
||||
|
||||
struct WXDLLEXPORT wxDbSqlTypeInfo
|
||||
{
|
||||
wxString TypeName;
|
||||
SWORD FsqlType;
|
||||
long Precision;
|
||||
short CaseSensitive;
|
||||
// short MinimumScale;
|
||||
short MaximumScale;
|
||||
};
|
||||
|
||||
|
||||
class WXDLLEXPORT wxDbColFor
|
||||
{
|
||||
public:
|
||||
wxString s_Field; // Formated String for Output
|
||||
wxString s_Format[7]; // Formated Objects - TIMESTAMP has the biggest (7)
|
||||
wxString s_Amount[7]; // Formated Objects - amount of things that can be formatted
|
||||
int i_Amount[7]; // Formated 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 columnSize, short decimalDigits);
|
||||
};
|
||||
|
||||
|
||||
class WXDLLEXPORT 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 columnSize;
|
||||
SWORD bufferLength;
|
||||
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 WXDLLEXPORT 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 WXDLLEXPORT 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
|
||||
};
|
||||
|
||||
|
||||
// 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.
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxChar) DBerrorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
|
||||
|
||||
|
||||
class WXDLLEXPORT wxDb
|
||||
{
|
||||
private:
|
||||
bool dbIsOpen;
|
||||
bool dbIsCached; // Was connection created by caching functions
|
||||
wxString dsn; // Data source name
|
||||
wxString uid; // User ID
|
||||
wxString authStr; // Authorization string (password)
|
||||
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(void);
|
||||
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);
|
||||
void initialize();
|
||||
|
||||
#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;
|
||||
#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;
|
||||
wxChar errorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
|
||||
wxChar errorMsg[SQL_MAX_MESSAGE_LENGTH];
|
||||
SDWORD 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 &Dsn, const wxString &Uid, const wxString &AuthStr, bool failOnDataTypeUnsupported=TRUE);
|
||||
bool Open(wxDbConnectInf *dbConnectInf);
|
||||
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 GetNext(void);
|
||||
bool GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SDWORD 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;}
|
||||
bool IsOpen(void) {return dbIsOpen;}
|
||||
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;}
|
||||
|
||||
// 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;}
|
||||
|
||||
// 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)
|
||||
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 WXDLLEXPORT *wxDbGetConnection(wxDbConnectInf *pDbConfig, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
|
||||
bool WXDLLEXPORT wxDbFreeConnection(wxDb *pDb);
|
||||
void WXDLLEXPORT wxDbCloseConnections(void);
|
||||
int WXDLLEXPORT 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* WXDLLEXPORT wxDbLogExtendedErrorMsg(const wxChar *userText,
|
||||
wxDb *pDb,
|
||||
const wxChar *ErrFile,
|
||||
int ErrLine);
|
||||
|
||||
|
||||
// This function sets the sql log state for all open wxDb objects
|
||||
bool WXDLLEXPORT 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 WXDLLEXPORT wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMax, wxChar *DsDesc,
|
||||
SWORD DsDescMax, UWORD direction = SQL_FETCH_NEXT);
|
||||
|
||||
|
||||
// Change this to 0 to remove use of all deprecated functions
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
//#################################################################################
|
||||
//############### DEPRECATED functions for backward compatability #################
|
||||
//#################################################################################
|
||||
|
||||
// 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 WXDLLEXPORT *GetDbConnection(DbStuff *pDbStuff, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
|
||||
bool WXDLLEXPORT FreeDbConnection(wxDB *pDb);
|
||||
void WXDLLEXPORT CloseDbConnections(void);
|
||||
int WXDLLEXPORT NumberDbConnectionsInUse(void);
|
||||
|
||||
bool SqlLog(sqlLog state, const wxChar *filename = SQL_LOG_FILENAME);
|
||||
|
||||
bool WXDLLEXPORT GetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD DsDescMax,
|
||||
UWORD direction = SQL_FETCH_NEXT);
|
||||
#endif // Deprecated structures/classes/functions
|
||||
|
||||
#endif // _WX_DB_H_
|
||||
|
||||
181
include/wx/dbgrid.h
Normal file
181
include/wx/dbgrid.h
Normal file
@@ -0,0 +1,181 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dbgrid.h
|
||||
// Purpose: Displays a wxDbTable in a wxGrid.
|
||||
// Author: Roger Gammans, Paul Gammans
|
||||
// Modified by:
|
||||
// Created:
|
||||
// RCS-ID: $Id$
|
||||
// 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 defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dbgrid.h"
|
||||
#endif
|
||||
|
||||
#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_EXPORTED_OBJARRAY(GenericKey,keyarray);
|
||||
|
||||
static const int wxUSE_QUERY = -1;
|
||||
|
||||
class WXDLLEXPORT 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 WXDLLEXPORT 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 WXDLLEXPORT 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 WXDLLEXPORT wxDbGridTableBase : public wxGridTableBase
|
||||
{
|
||||
public:
|
||||
wxDbGridTableBase(wxDbTable *tab, wxDbGridColInfo *ColInfo,
|
||||
int count = wxUSE_QUERY, bool takeOwnership = TRUE);
|
||||
~wxDbGridTableBase();
|
||||
|
||||
virtual int GetNumberRows()
|
||||
{
|
||||
wxLogDebug(" GetNumberRows() = %i",m_rowtotal);
|
||||
return m_rowtotal;
|
||||
}
|
||||
virtual int GetNumberCols()
|
||||
{
|
||||
wxLogDebug(" 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_
|
||||
41
include/wx/dbkeyg.h
Normal file
41
include/wx/dbkeyg.h
Normal file
@@ -0,0 +1,41 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dbkeyg.h
|
||||
// Purpose: Generic key support for wxDbTable
|
||||
// Author: Roger Gammans
|
||||
// Modified by:
|
||||
// Created:
|
||||
// RCS-ID: $Id$
|
||||
// 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_
|
||||
379
include/wx/dbtable.h
Normal file
379
include/wx/dbtable.h
Normal file
@@ -0,0 +1,379 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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$
|
||||
// Copyright: (c) 1996 Remstar International, Inc.
|
||||
// Licence: wxWindows licence, plus:
|
||||
// Notice: This class library and its intellectual design are free of charge for use,
|
||||
// modification, enhancement, debugging under the following conditions:
|
||||
// 1) These classes may only be used as part of the implementation of a
|
||||
// wxWindows-based application
|
||||
// 2) All enhancements and bug fixes are to be submitted back to the wxWindows
|
||||
// user groups free of all charges for use with the wxWindows library.
|
||||
// 3) These classes may not be distributed as part of any other class library,
|
||||
// DLL, text (written or electronic), other than a complete distribution of
|
||||
// the wxWindows GUI development toolkit.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
// SYNOPSIS START
|
||||
// SYNOPSIS STOP
|
||||
*/
|
||||
|
||||
#ifndef DBTABLE_DOT_H
|
||||
#define DBTABLE_DOT_H
|
||||
|
||||
#include "wx/version.h"
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dbtable.h"
|
||||
#endif
|
||||
|
||||
#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 WXDLLEXPORT 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
|
||||
SDWORD CbValue; // Internal use only!!!
|
||||
bool Null; // NOT FULLY IMPLEMENTED - Allows NULL values in Inserts and Updates
|
||||
|
||||
wxDbColDef();
|
||||
|
||||
bool Initialize();
|
||||
}; // wxDbColDef
|
||||
|
||||
|
||||
class WXDLLEXPORT wxDbColDataPtr
|
||||
{
|
||||
public:
|
||||
void *PtrDataObj;
|
||||
int SzDataObj;
|
||||
SWORD SqlCtype;
|
||||
}; // wxDbColDataPtr
|
||||
|
||||
|
||||
// This structure is used when creating secondary indexes.
|
||||
class WXDLLEXPORT wxDbIdxDef
|
||||
{
|
||||
public:
|
||||
wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1];
|
||||
bool Ascending;
|
||||
}; // wxDbIdxDef
|
||||
|
||||
|
||||
class WXDLLEXPORT 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();
|
||||
|
||||
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 noCols; // # 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 noCols; // # 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="", bool qryOnly = !wxDB_QUERY_ONLY,
|
||||
const wxString &tblPath="");
|
||||
|
||||
// DEPRECATED
|
||||
wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
|
||||
const wxChar *qryTblName="", bool qryOnly = !wxDB_QUERY_ONLY,
|
||||
const wxString &tblPath="");
|
||||
|
||||
virtual ~wxDbTable();
|
||||
|
||||
bool Open(bool checkPrivileges=FALSE, bool checkTableExists=TRUE);
|
||||
bool CreateTable(bool attemptDrop=TRUE);
|
||||
bool DropTable(void);
|
||||
bool CreateIndex(const wxString &idxName, bool unique, UWORD noIdxCols,
|
||||
wxDbIdxDef *pIdxDefs, bool attemptDrop=TRUE);
|
||||
bool DropIndex(const wxString &idxName);
|
||||
|
||||
// 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 noCols; } // 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="");
|
||||
void BuildDeleteStmt(wxChar *pSqlStmt, int typeOfDel, const wxString &pWhereClause="");
|
||||
|
||||
void BuildUpdateStmt(wxString &pSqlStmt, int typeOfUpd, const wxString &pWhereClause="");
|
||||
void BuildUpdateStmt(wxChar *pSqlStmt, int typeOfUpd, const wxString &pWhereClause="");
|
||||
|
||||
void BuildWhereClause(wxString &pWhereClause, int typeOfWhere, const wxString &qualTableName="", bool useLikeComparison=FALSE);
|
||||
void BuildWhereClause(wxChar *pWhereClause, int typeOfWhere, const wxString &qualTableName="", 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 typeOfUpd, const char *pWhereClause = NULL)
|
||||
{ BuildUpdateStmt(pSqlStmt,typeOfUpd,pWhereClause); }
|
||||
void GetWhereClause(char *pWhereClause, int typeOfWhere,
|
||||
const char *qualTableName = NULL, bool useLikeComparison=FALSE)
|
||||
{ BuildWhereClause(pWhereClause,typeOfWhere,qualTableName,useLikeComparison); }
|
||||
#endif
|
||||
bool CanSelectForUpdate(void);
|
||||
bool CanUpdByROWID(void);
|
||||
void ClearMemberVar(UWORD colNo, bool setToNull=FALSE);
|
||||
void ClearMemberVars(bool setToNull=FALSE);
|
||||
bool SetQueryTimeout(UDWORD nSeconds);
|
||||
|
||||
wxDbColDef *GetColDefs() { return colDefs; }
|
||||
void SetColDefs(UWORD index, const wxString &fieldName, int dataType,
|
||||
void *pData, SWORD cType,
|
||||
int size, bool keyField = FALSE, bool upd = TRUE,
|
||||
bool insAllow = TRUE, bool derivedCol = 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="*");
|
||||
int DB_STATUS(void) { return(pDb->DB_STATUS); }
|
||||
|
||||
bool IsColNull(UWORD colNo) const;
|
||||
bool SetColNull(UWORD colNo, 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 colNo, bool set=TRUE) { return (SetNull(colNo,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);
|
||||
virtual wxVariant GetCol(const int colNo) const ;
|
||||
virtual void SetCol(const int colNo, 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 compatability #################
|
||||
//#################################################################################
|
||||
|
||||
// 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
|
||||
815
include/wx/dc.h
Normal file
815
include/wx/dc.h
Normal file
@@ -0,0 +1,815 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dc.h
|
||||
// Purpose: wxDC class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 05/25/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DC_H_BASE_
|
||||
#define _WX_DC_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dcbase.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers which we must include here
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/object.h" // the base class
|
||||
|
||||
#include "wx/cursor.h" // we have member variables of these classes
|
||||
#include "wx/font.h" // so we can't do without them
|
||||
#include "wx/colour.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/pen.h"
|
||||
#include "wx/palette.h"
|
||||
#include "wx/list.h" // we use wxList in inline functions
|
||||
|
||||
class WXDLLEXPORT wxDC;
|
||||
class WXDLLEXPORT wxDCBase;
|
||||
|
||||
class WXDLLEXPORT wxDrawObject
|
||||
{
|
||||
public:
|
||||
|
||||
wxDrawObject()
|
||||
: m_isBBoxValid(FALSE)
|
||||
, m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
|
||||
{ }
|
||||
|
||||
virtual ~wxDrawObject() { }
|
||||
|
||||
virtual void Draw(wxDCBase&) const { }
|
||||
|
||||
virtual void CalcBoundingBox(wxCoord x, wxCoord y)
|
||||
{
|
||||
if ( m_isBBoxValid )
|
||||
{
|
||||
if ( x < m_minX ) m_minX = x;
|
||||
if ( y < m_minY ) m_minY = y;
|
||||
if ( x > m_maxX ) m_maxX = x;
|
||||
if ( y > m_maxY ) m_maxY = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isBBoxValid = TRUE;
|
||||
|
||||
m_minX = x;
|
||||
m_minY = y;
|
||||
m_maxX = x;
|
||||
m_maxY = y;
|
||||
}
|
||||
}
|
||||
|
||||
void ResetBoundingBox()
|
||||
{
|
||||
m_isBBoxValid = FALSE;
|
||||
|
||||
m_minX = m_maxX = m_minY = m_maxY = 0;
|
||||
}
|
||||
|
||||
// Get the final bounding box of the PostScript or Metafile picture.
|
||||
|
||||
wxCoord MinX() const { return m_minX; }
|
||||
wxCoord MaxX() const { return m_maxX; }
|
||||
wxCoord MinY() const { return m_minY; }
|
||||
wxCoord MaxY() const { return m_maxY; }
|
||||
|
||||
//to define the type of object for derived objects
|
||||
virtual int GetType()=0;
|
||||
|
||||
protected:
|
||||
//for boundingbox calculation
|
||||
bool m_isBBoxValid:1;
|
||||
//for boundingbox calculation
|
||||
wxCoord m_minX, m_minY, m_maxX, m_maxY;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(extern int) wxPageNumber;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDC is the device context - object on which any drawing is done
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDCBase : public wxObject
|
||||
{
|
||||
public:
|
||||
wxDCBase()
|
||||
: m_colour(wxColourDisplay())
|
||||
, m_ok(TRUE)
|
||||
, m_clipping(FALSE)
|
||||
, m_isInteractive(0)
|
||||
, m_isBBoxValid(FALSE)
|
||||
, m_logicalOriginX(0), m_logicalOriginY(0)
|
||||
, m_deviceOriginX(0), m_deviceOriginY(0)
|
||||
, m_logicalScaleX(1.0), m_logicalScaleY(1.0)
|
||||
, m_userScaleX(1.0), m_userScaleY(1.0)
|
||||
, m_scaleX(1.0), m_scaleY(1.0)
|
||||
, m_signX(1), m_signY(1)
|
||||
, m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
|
||||
, m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
|
||||
, m_logicalFunction(wxCOPY)
|
||||
, m_backgroundMode(wxTRANSPARENT)
|
||||
, m_mappingMode(wxMM_TEXT)
|
||||
, m_pen()
|
||||
, m_brush()
|
||||
, m_backgroundBrush(*wxTRANSPARENT_BRUSH)
|
||||
, m_textForegroundColour(*wxBLACK)
|
||||
, m_textBackgroundColour(*wxWHITE)
|
||||
, m_font()
|
||||
#if wxUSE_PALETTE
|
||||
, m_palette()
|
||||
, m_hasCustomPalette(FALSE)
|
||||
#endif // wxUSE_PALETTE
|
||||
{
|
||||
ResetBoundingBox();
|
||||
}
|
||||
|
||||
~wxDCBase() { }
|
||||
|
||||
virtual void BeginDrawing() { }
|
||||
virtual void EndDrawing() { }
|
||||
|
||||
// graphic primitives
|
||||
// ------------------
|
||||
|
||||
virtual void DrawObject(wxDrawObject* drawobject)
|
||||
{
|
||||
drawobject->Draw(*this);
|
||||
CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
|
||||
CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
|
||||
}
|
||||
|
||||
bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
||||
int style = wxFLOOD_SURFACE)
|
||||
{ return DoFloodFill(x, y, col, style); }
|
||||
bool FloodFill(const wxPoint& pt, const wxColour& col,
|
||||
int style = wxFLOOD_SURFACE)
|
||||
{ return DoFloodFill(pt.x, pt.y, col, style); }
|
||||
|
||||
bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
|
||||
{ return DoGetPixel(x, y, col); }
|
||||
bool GetPixel(const wxPoint& pt, wxColour *col) const
|
||||
{ return DoGetPixel(pt.x, pt.y, col); }
|
||||
|
||||
void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
{ DoDrawLine(x1, y1, x2, y2); }
|
||||
void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
|
||||
{ DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
|
||||
|
||||
void CrossHair(wxCoord x, wxCoord y)
|
||||
{ DoCrossHair(x, y); }
|
||||
void CrossHair(const wxPoint& pt)
|
||||
{ DoCrossHair(pt.x, pt.y); }
|
||||
|
||||
void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
|
||||
wxCoord xc, wxCoord yc)
|
||||
{ DoDrawArc(x1, y1, x2, y2, xc, yc); }
|
||||
void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
|
||||
{ DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
|
||||
|
||||
void DrawCheckMark(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height)
|
||||
{ DoDrawCheckMark(x, y, width, height); }
|
||||
void DrawCheckMark(const wxRect& rect)
|
||||
{ DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
|
||||
|
||||
void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
double sa, double ea)
|
||||
{ DoDrawEllipticArc(x, y, w, h, sa, ea); }
|
||||
void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
|
||||
double sa, double ea)
|
||||
{ DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
|
||||
|
||||
void DrawPoint(wxCoord x, wxCoord y)
|
||||
{ DoDrawPoint(x, y); }
|
||||
void DrawPoint(const wxPoint& pt)
|
||||
{ DoDrawPoint(pt.x, pt.y); }
|
||||
|
||||
void DrawLines(int n, wxPoint points[],
|
||||
wxCoord xoffset = 0, wxCoord yoffset = 0)
|
||||
{ DoDrawLines(n, points, xoffset, yoffset); }
|
||||
void DrawLines(const wxList *list,
|
||||
wxCoord xoffset = 0, wxCoord yoffset = 0);
|
||||
|
||||
void DrawPolygon(int n, wxPoint points[],
|
||||
wxCoord xoffset = 0, wxCoord yoffset = 0,
|
||||
int fillStyle = wxODDEVEN_RULE)
|
||||
{ DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
|
||||
|
||||
void DrawPolygon(const wxList *list,
|
||||
wxCoord xoffset = 0, wxCoord yoffset = 0,
|
||||
int fillStyle = wxODDEVEN_RULE);
|
||||
|
||||
void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ DoDrawRectangle(x, y, width, height); }
|
||||
void DrawRectangle(const wxPoint& pt, const wxSize& sz)
|
||||
{ DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
|
||||
void DrawRectangle(const wxRect& rect)
|
||||
{ DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
|
||||
|
||||
void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
|
||||
double radius)
|
||||
{ DoDrawRoundedRectangle(x, y, width, height, radius); }
|
||||
void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
|
||||
double radius)
|
||||
{ DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
|
||||
void DrawRoundedRectangle(const wxRect& r, double radius)
|
||||
{ DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
|
||||
|
||||
void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
|
||||
{ DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
|
||||
void DrawCircle(const wxPoint& pt, wxCoord radius)
|
||||
{ DrawCircle(pt.x, pt.y, radius); }
|
||||
|
||||
void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ DoDrawEllipse(x, y, width, height); }
|
||||
void DrawEllipse(const wxPoint& pt, const wxSize& sz)
|
||||
{ DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
|
||||
void DrawEllipse(const wxRect& rect)
|
||||
{ DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
|
||||
|
||||
void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
|
||||
{ DoDrawIcon(icon, x, y); }
|
||||
void DrawIcon(const wxIcon& icon, const wxPoint& pt)
|
||||
{ DoDrawIcon(icon, pt.x, pt.y); }
|
||||
|
||||
void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
|
||||
bool useMask = FALSE)
|
||||
{ DoDrawBitmap(bmp, x, y, useMask); }
|
||||
void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
|
||||
bool useMask = FALSE)
|
||||
{ DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
|
||||
|
||||
void DrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||
{ DoDrawText(text, x, y); }
|
||||
void DrawText(const wxString& text, const wxPoint& pt)
|
||||
{ DoDrawText(text, pt.x, pt.y); }
|
||||
|
||||
void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
|
||||
{ DoDrawRotatedText(text, x, y, angle); }
|
||||
void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
|
||||
{ DoDrawRotatedText(text, pt.x, pt.y, angle); }
|
||||
|
||||
// this version puts both optional bitmap and the text into the given
|
||||
// rectangle and aligns is as specified by alignment parameter; it also
|
||||
// will emphasize the character with the given index if it is != -1 and
|
||||
// return the bounding rectangle if required
|
||||
virtual void DrawLabel(const wxString& text,
|
||||
const wxBitmap& image,
|
||||
const wxRect& rect,
|
||||
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
|
||||
int indexAccel = -1,
|
||||
wxRect *rectBounding = NULL);
|
||||
|
||||
void DrawLabel(const wxString& text, const wxRect& rect,
|
||||
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
|
||||
int indexAccel = -1)
|
||||
{ DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
|
||||
|
||||
bool Blit(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)
|
||||
{
|
||||
return DoBlit(xdest, ydest, width, height,
|
||||
source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
|
||||
}
|
||||
bool Blit(const wxPoint& destPt, const wxSize& sz,
|
||||
wxDC *source, const wxPoint& srcPt,
|
||||
int rop = wxCOPY, bool useMask = FALSE, const wxPoint& srcPtMask = wxPoint(-1, -1))
|
||||
{
|
||||
return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
|
||||
source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
|
||||
}
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
// TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
|
||||
void DrawSpline(wxCoord x1, wxCoord y1,
|
||||
wxCoord x2, wxCoord y2,
|
||||
wxCoord x3, wxCoord y3);
|
||||
void DrawSpline(int n, wxPoint points[]);
|
||||
|
||||
void DrawSpline(wxList *points) { DoDrawSpline(points); }
|
||||
#endif // wxUSE_SPLINES
|
||||
|
||||
// global DC operations
|
||||
// --------------------
|
||||
|
||||
virtual void Clear() = 0;
|
||||
|
||||
virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
|
||||
virtual void EndDoc() { }
|
||||
|
||||
virtual void StartPage() { }
|
||||
virtual void EndPage() { }
|
||||
|
||||
// set objects to use for drawing
|
||||
// ------------------------------
|
||||
|
||||
virtual void SetFont(const wxFont& font) = 0;
|
||||
virtual void SetPen(const wxPen& pen) = 0;
|
||||
virtual void SetBrush(const wxBrush& brush) = 0;
|
||||
virtual void SetBackground(const wxBrush& brush) = 0;
|
||||
virtual void SetBackgroundMode(int mode) = 0;
|
||||
#if wxUSE_PALETTE
|
||||
virtual void SetPalette(const wxPalette& palette) = 0;
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
// clipping region
|
||||
// ---------------
|
||||
|
||||
void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{ DoSetClippingRegion(x, y, width, height); }
|
||||
void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
|
||||
{ DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
|
||||
void SetClippingRegion(const wxRect& rect)
|
||||
{ DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
|
||||
void SetClippingRegion(const wxRegion& region)
|
||||
{ DoSetClippingRegionAsRegion(region); }
|
||||
|
||||
virtual void DestroyClippingRegion() = 0;
|
||||
|
||||
void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
|
||||
{ DoGetClippingBox(x, y, w, h); }
|
||||
void GetClippingBox(wxRect& rect) const
|
||||
{
|
||||
#if 1
|
||||
DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
|
||||
#else
|
||||
// Necessary to use intermediate variables for 16-bit compilation
|
||||
// REMOVE ME if the above is OK for all current platforms
|
||||
wxCoord x, y, w, h;
|
||||
DoGetClippingBox(&x, &y, &w, &h);
|
||||
rect.x = x; rect.y = y; rect.width = w; rect.height = h;
|
||||
#endif
|
||||
}
|
||||
|
||||
// text extent
|
||||
// -----------
|
||||
|
||||
virtual wxCoord GetCharHeight() const = 0;
|
||||
virtual wxCoord GetCharWidth() const = 0;
|
||||
|
||||
// only works for single line strings
|
||||
void GetTextExtent(const wxString& string,
|
||||
wxCoord *x, wxCoord *y,
|
||||
wxCoord *descent = NULL,
|
||||
wxCoord *externalLeading = NULL,
|
||||
wxFont *theFont = NULL) const
|
||||
{ DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
|
||||
|
||||
// works for single as well as multi-line strings
|
||||
virtual void GetMultiLineTextExtent(const wxString& text,
|
||||
wxCoord *width,
|
||||
wxCoord *height,
|
||||
wxCoord *heightLine = NULL,
|
||||
wxFont *font = NULL);
|
||||
|
||||
// size and resolution
|
||||
// -------------------
|
||||
|
||||
// in device units
|
||||
void GetSize(int *width, int *height) const
|
||||
{ DoGetSize(width, height); }
|
||||
wxSize GetSize() const
|
||||
{
|
||||
int w, h;
|
||||
DoGetSize(&w, &h);
|
||||
|
||||
return wxSize(w, h);
|
||||
}
|
||||
|
||||
// in mm
|
||||
void GetSizeMM(int* width, int* height) const
|
||||
{ DoGetSizeMM(width, height); }
|
||||
wxSize GetSizeMM() const
|
||||
{
|
||||
int w, h;
|
||||
DoGetSizeMM(&w, &h);
|
||||
|
||||
return wxSize(w, h);
|
||||
}
|
||||
|
||||
// coordinates conversions
|
||||
// -----------------------
|
||||
|
||||
// This group of functions does actual conversion of the input, as you'd
|
||||
// expect.
|
||||
wxCoord DeviceToLogicalX(wxCoord x) const;
|
||||
wxCoord DeviceToLogicalY(wxCoord y) const;
|
||||
wxCoord DeviceToLogicalXRel(wxCoord x) const;
|
||||
wxCoord DeviceToLogicalYRel(wxCoord y) const;
|
||||
wxCoord LogicalToDeviceX(wxCoord x) const;
|
||||
wxCoord LogicalToDeviceY(wxCoord y) const;
|
||||
wxCoord LogicalToDeviceXRel(wxCoord x) const;
|
||||
wxCoord LogicalToDeviceYRel(wxCoord y) const;
|
||||
|
||||
// query DC capabilities
|
||||
// ---------------------
|
||||
|
||||
virtual bool CanDrawBitmap() const = 0;
|
||||
virtual bool CanGetTextExtent() const = 0;
|
||||
|
||||
// colour depth
|
||||
virtual int GetDepth() const = 0;
|
||||
|
||||
// Resolution in Pixels per inch
|
||||
virtual wxSize GetPPI() const = 0;
|
||||
|
||||
virtual bool Ok() const { return m_ok; }
|
||||
|
||||
// accessors
|
||||
// ---------
|
||||
|
||||
// const...
|
||||
int GetBackgroundMode() const { return m_backgroundMode; }
|
||||
const wxBrush& GetBackground() const { return m_backgroundBrush; }
|
||||
const wxBrush& GetBrush() const { return m_brush; }
|
||||
const wxFont& GetFont() const { return m_font; }
|
||||
const wxPen& GetPen() const { return m_pen; }
|
||||
const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
|
||||
const wxColour& GetTextForeground() const { return m_textForegroundColour; }
|
||||
|
||||
// ... and non const
|
||||
wxBrush& GetBackground() { return m_backgroundBrush; }
|
||||
wxBrush& GetBrush() { return m_brush; }
|
||||
wxFont& GetFont() { return m_font; }
|
||||
wxPen& GetPen() { return m_pen; }
|
||||
wxColour& GetTextBackground() { return m_textBackgroundColour; }
|
||||
wxColour& GetTextForeground() { return m_textForegroundColour; }
|
||||
|
||||
virtual void SetTextForeground(const wxColour& colour)
|
||||
{ m_textForegroundColour = colour; }
|
||||
virtual void SetTextBackground(const wxColour& colour)
|
||||
{ m_textBackgroundColour = colour; }
|
||||
|
||||
int GetMapMode() const { return m_mappingMode; }
|
||||
virtual void SetMapMode(int mode) = 0;
|
||||
|
||||
virtual void GetUserScale(double *x, double *y) const
|
||||
{
|
||||
if ( x ) *x = m_userScaleX;
|
||||
if ( y ) *y = m_userScaleY;
|
||||
}
|
||||
virtual void SetUserScale(double x, double y) = 0;
|
||||
|
||||
virtual void GetLogicalScale(double *x, double *y)
|
||||
{
|
||||
if ( x ) *x = m_logicalScaleX;
|
||||
if ( y ) *y = m_logicalScaleY;
|
||||
}
|
||||
virtual void SetLogicalScale(double x, double y)
|
||||
{
|
||||
m_logicalScaleX = x;
|
||||
m_logicalScaleY = y;
|
||||
}
|
||||
|
||||
void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
|
||||
{ DoGetLogicalOrigin(x, y); }
|
||||
wxPoint GetLogicalOrigin() const
|
||||
{ wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
|
||||
virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
|
||||
|
||||
void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
|
||||
{ DoGetDeviceOrigin(x, y); }
|
||||
wxPoint GetDeviceOrigin() const
|
||||
{ wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
|
||||
virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
|
||||
|
||||
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
|
||||
|
||||
int GetLogicalFunction() const { return m_logicalFunction; }
|
||||
virtual void SetLogicalFunction(int function) = 0;
|
||||
|
||||
// Sometimes we need to override optimization, e.g. if other software is
|
||||
// drawing onto our surface and we can't be sure of who's done what.
|
||||
//
|
||||
// FIXME: is this (still) used?
|
||||
virtual void SetOptimization(bool WXUNUSED(opt)) { }
|
||||
virtual bool GetOptimization() { return FALSE; }
|
||||
|
||||
// bounding box
|
||||
// ------------
|
||||
|
||||
virtual void CalcBoundingBox(wxCoord x, wxCoord y)
|
||||
{
|
||||
if ( m_isBBoxValid )
|
||||
{
|
||||
if ( x < m_minX ) m_minX = x;
|
||||
if ( y < m_minY ) m_minY = y;
|
||||
if ( x > m_maxX ) m_maxX = x;
|
||||
if ( y > m_maxY ) m_maxY = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isBBoxValid = TRUE;
|
||||
|
||||
m_minX = x;
|
||||
m_minY = y;
|
||||
m_maxX = x;
|
||||
m_maxY = y;
|
||||
}
|
||||
}
|
||||
|
||||
void ResetBoundingBox()
|
||||
{
|
||||
m_isBBoxValid = FALSE;
|
||||
|
||||
m_minX = m_maxX = m_minY = m_maxY = 0;
|
||||
}
|
||||
|
||||
// Get the final bounding box of the PostScript or Metafile picture.
|
||||
wxCoord MinX() const { return m_minX; }
|
||||
wxCoord MaxX() const { return m_maxX; }
|
||||
wxCoord MinY() const { return m_minY; }
|
||||
wxCoord MaxY() const { return m_maxY; }
|
||||
|
||||
// misc old functions
|
||||
// ------------------
|
||||
|
||||
// for compatibility with the old code when wxCoord was long everywhere
|
||||
#ifndef __WIN16__
|
||||
void GetTextExtent(const wxString& string,
|
||||
long *x, long *y,
|
||||
long *descent = NULL,
|
||||
long *externalLeading = NULL,
|
||||
wxFont *theFont = NULL) const
|
||||
{
|
||||
wxCoord x2, y2, descent2, externalLeading2;
|
||||
DoGetTextExtent(string, &x2, &y2,
|
||||
&descent2, &externalLeading2,
|
||||
theFont);
|
||||
if ( x )
|
||||
*x = x2;
|
||||
if ( y )
|
||||
*y = y2;
|
||||
if ( descent )
|
||||
*descent = descent2;
|
||||
if ( externalLeading )
|
||||
*externalLeading = externalLeading2;
|
||||
}
|
||||
|
||||
void GetLogicalOrigin(long *x, long *y) const
|
||||
{
|
||||
wxCoord x2, y2;
|
||||
DoGetLogicalOrigin(&x2, &y2);
|
||||
if ( x )
|
||||
*x = x2;
|
||||
if ( y )
|
||||
*y = y2;
|
||||
}
|
||||
|
||||
void GetDeviceOrigin(long *x, long *y) const
|
||||
{
|
||||
wxCoord x2, y2;
|
||||
DoGetDeviceOrigin(&x2, &y2);
|
||||
if ( x )
|
||||
*x = x2;
|
||||
if ( y )
|
||||
*y = y2;
|
||||
}
|
||||
void GetClippingBox(long *x, long *y, long *w, long *h) const
|
||||
{
|
||||
wxCoord xx,yy,ww,hh;
|
||||
DoGetClippingBox(&xx, &yy, &ww, &hh);
|
||||
if (x) *x = xx;
|
||||
if (y) *y = yy;
|
||||
if (w) *w = ww;
|
||||
if (h) *h = hh;
|
||||
}
|
||||
#endif // !Win16
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
|
||||
void GetTextExtent(const wxString& string, float *x, float *y,
|
||||
float *descent = NULL, float *externalLeading = NULL,
|
||||
wxFont *theFont = NULL, bool use16bit = FALSE) const ;
|
||||
void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
|
||||
void GetSizeMM(float *width, float *height) const { int w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
protected:
|
||||
// the pure virtual functions which should be implemented by wxDC
|
||||
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
||||
int style = wxFLOOD_SURFACE) = 0;
|
||||
|
||||
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
|
||||
|
||||
virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
|
||||
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
|
||||
|
||||
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
||||
wxCoord x2, wxCoord y2,
|
||||
wxCoord xc, wxCoord yc) = 0;
|
||||
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) = 0;
|
||||
|
||||
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
|
||||
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height,
|
||||
double radius) = 0;
|
||||
virtual void DoDrawEllipse(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height) = 0;
|
||||
|
||||
virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
|
||||
|
||||
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
|
||||
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
|
||||
bool useMask = FALSE) = 0;
|
||||
|
||||
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
|
||||
virtual void DoDrawRotatedText(const wxString& text,
|
||||
wxCoord x, wxCoord y, double angle) = 0;
|
||||
|
||||
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) = 0;
|
||||
|
||||
virtual void DoGetSize(int *width, int *height) const = 0;
|
||||
virtual void DoGetSizeMM(int* width, int* height) const = 0;
|
||||
|
||||
virtual void DoDrawLines(int n, wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset) = 0;
|
||||
virtual void DoDrawPolygon(int n, wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
int fillStyle = wxODDEVEN_RULE) = 0;
|
||||
|
||||
virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
|
||||
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height) = 0;
|
||||
|
||||
// FIXME are these functions really different?
|
||||
virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
|
||||
wxCoord *w, wxCoord *h)
|
||||
{ DoGetClippingBox(x, y, w, h); }
|
||||
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
|
||||
wxCoord *w, wxCoord *h) const
|
||||
{
|
||||
if ( m_clipping )
|
||||
{
|
||||
if ( x ) *x = m_clipX1;
|
||||
if ( y ) *y = m_clipY1;
|
||||
if ( w ) *w = m_clipX2 - m_clipX1;
|
||||
if ( h ) *h = m_clipY2 - m_clipY1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = *y = *w = *h = 0;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
|
||||
{
|
||||
if ( x ) *x = m_logicalOriginX;
|
||||
if ( y ) *y = m_logicalOriginY;
|
||||
}
|
||||
|
||||
virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
|
||||
{
|
||||
if ( x ) *x = m_deviceOriginX;
|
||||
if ( y ) *y = m_deviceOriginY;
|
||||
}
|
||||
|
||||
virtual void DoGetTextExtent(const wxString& string,
|
||||
wxCoord *x, wxCoord *y,
|
||||
wxCoord *descent = NULL,
|
||||
wxCoord *externalLeading = NULL,
|
||||
wxFont *theFont = NULL) const = 0;
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
virtual void DoDrawSpline(wxList *points);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// flags
|
||||
bool m_colour:1;
|
||||
bool m_ok:1;
|
||||
bool m_clipping:1;
|
||||
bool m_isInteractive:1;
|
||||
bool m_isBBoxValid:1;
|
||||
|
||||
// coordinate system variables
|
||||
|
||||
// TODO short descriptions of what exactly they are would be nice...
|
||||
|
||||
wxCoord m_logicalOriginX, m_logicalOriginY;
|
||||
wxCoord m_deviceOriginX, m_deviceOriginY;
|
||||
|
||||
double m_logicalScaleX, m_logicalScaleY;
|
||||
double m_userScaleX, m_userScaleY;
|
||||
double m_scaleX, m_scaleY;
|
||||
|
||||
// Used by SetAxisOrientation() to invert the axes
|
||||
int m_signX, m_signY;
|
||||
|
||||
// bounding and clipping boxes
|
||||
wxCoord m_minX, m_minY, m_maxX, m_maxY;
|
||||
wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
|
||||
|
||||
int m_logicalFunction;
|
||||
int m_backgroundMode;
|
||||
int m_mappingMode;
|
||||
|
||||
// GDI objects
|
||||
wxPen m_pen;
|
||||
wxBrush m_brush;
|
||||
wxBrush m_backgroundBrush;
|
||||
wxColour m_textForegroundColour;
|
||||
wxColour m_textBackgroundColour;
|
||||
wxFont m_font;
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
wxPalette m_palette;
|
||||
bool m_hasCustomPalette;
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
private:
|
||||
DECLARE_NO_COPY_CLASS(wxDCBase)
|
||||
DECLARE_ABSTRACT_CLASS(wxDCBase)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// now include the declaration of wxDC class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dc.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dc.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dc.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/dc.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/dc.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dc.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/dc.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/dc.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helper class: you can use it to temporarily change the DC text colour and
|
||||
// restore it automatically when the object goes out of scope
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDCTextColourChanger
|
||||
{
|
||||
public:
|
||||
wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
|
||||
|
||||
~wxDCTextColourChanger()
|
||||
{
|
||||
if ( m_colFgOld.Ok() )
|
||||
m_dc.SetTextForeground(m_colFgOld);
|
||||
}
|
||||
|
||||
void Set(const wxColour& col)
|
||||
{
|
||||
if ( !m_colFgOld.Ok() )
|
||||
m_colFgOld = m_dc.GetTextForeground();
|
||||
m_dc.SetTextForeground(col);
|
||||
}
|
||||
|
||||
private:
|
||||
wxDC& m_dc;
|
||||
|
||||
wxColour m_colFgOld;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// another small helper class: sets the clipping region in its ctor and
|
||||
// destroys it in the dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDCClipper
|
||||
{
|
||||
public:
|
||||
wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
|
||||
{ dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
|
||||
wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
|
||||
{ dc.SetClippingRegion(x, y, w, h); }
|
||||
|
||||
~wxDCClipper() { m_dc.DestroyClippingRegion(); }
|
||||
|
||||
private:
|
||||
wxDC& m_dc;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_DC_H_BASE_
|
||||
104
include/wx/dcbuffer.h
Normal file
104
include/wx/dcbuffer.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dcbuffer.h
|
||||
// Purpose: wxBufferedDC class
|
||||
// Author: Ron Lee <ron@debian.org>
|
||||
// Modified by:
|
||||
// Created: 16/03/02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Ron Lee
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DCBUFFER_H_
|
||||
#define _WX_DCBUFFER_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dcbuffer.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dcmemory.h"
|
||||
|
||||
|
||||
// ==============================================================
|
||||
// Double buffering helper.
|
||||
// --------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBufferedDC : public wxMemoryDC
|
||||
{
|
||||
private:
|
||||
|
||||
// Without the existence of a wxNullDC, this must be
|
||||
// a pointer, else it could probably be a reference.
|
||||
|
||||
wxDC *m_dc;
|
||||
wxBitmap m_buffer;
|
||||
|
||||
public:
|
||||
|
||||
// Default ctor, must subsequently call Init for
|
||||
// two stage construction.
|
||||
|
||||
wxBufferedDC()
|
||||
: m_dc( 0 )
|
||||
{}
|
||||
|
||||
// Construct a wxBufferedDC using a user supplied buffer.
|
||||
|
||||
wxBufferedDC( wxDC *dc, const wxBitmap &buffer );
|
||||
|
||||
// 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 );
|
||||
|
||||
// default copy ctor ok.
|
||||
|
||||
// The usually desired action in the dtor is to blit the buffer.
|
||||
|
||||
~wxBufferedDC();
|
||||
|
||||
// These reimplement the actions of the ctors for
|
||||
// two stage creation, but are not used by the ctors
|
||||
// themselves to save a few cpu cycles.
|
||||
|
||||
void Init( wxDC *dc, const wxBitmap &bitmap );
|
||||
void Init( wxDC *dc, const wxSize &area );
|
||||
|
||||
// Blits the buffer to the dc, and detaches the dc from
|
||||
// the buffer. 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();
|
||||
|
||||
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
|
||||
{
|
||||
private:
|
||||
|
||||
wxPaintDC m_paintdc;
|
||||
|
||||
public:
|
||||
|
||||
wxBufferedPaintDC( wxWindow *window, const wxBitmap &buffer = wxNullBitmap );
|
||||
|
||||
// default copy ctor ok.
|
||||
|
||||
~wxBufferedPaintDC();
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_DCBUFFER_H_
|
||||
|
||||
23
include/wx/dcclient.h
Normal file
23
include/wx/dcclient.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _WX_DCCLIENT_H_BASE_
|
||||
#define _WX_DCCLIENT_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dcclient.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dcclient.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dcclient.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/dcclient.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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_
|
||||
23
include/wx/dcmemory.h
Normal file
23
include/wx/dcmemory.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _WX_DCMEMORY_H_BASE_
|
||||
#define _WX_DCMEMORY_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dcmemory.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dcmemory.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dcmemory.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/dcmemory.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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_
|
||||
15
include/wx/dcprint.h
Normal file
15
include/wx/dcprint.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _WX_DCPRINT_H_BASE_
|
||||
#define _WX_DCPRINT_H_BASE_
|
||||
|
||||
#if 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
|
||||
// _WX_DCPRINT_H_BASE_
|
||||
7
include/wx/dcps.h
Normal file
7
include/wx/dcps.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _WX_DCPS_H_BASE_
|
||||
#define _WX_DCPS_H_BASE_
|
||||
|
||||
#include "wx/generic/dcpsg.h"
|
||||
|
||||
#endif
|
||||
|
||||
23
include/wx/dcscreen.h
Normal file
23
include/wx/dcscreen.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _WX_DCSCREEN_H_BASE_
|
||||
#define _WX_DCSCREEN_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dcscreen.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dcscreen.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dcscreen.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/dcscreen.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/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_
|
||||
28
include/wx/dde.h
Normal file
28
include/wx/dde.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _WX_DDE_H_BASE_
|
||||
#define _WX_DDE_H_BASE_
|
||||
|
||||
#include "wx/list.h"
|
||||
|
||||
class wxDDEClient;
|
||||
class wxDDEServer;
|
||||
class wxDDEConnection;
|
||||
|
||||
WX_DECLARE_EXPORTED_LIST(wxDDEClient, wxDDEClientList);
|
||||
WX_DECLARE_EXPORTED_LIST(wxDDEServer, wxDDEServerList);
|
||||
WX_DECLARE_EXPORTED_LIST(wxDDEConnection, wxDDEConnectionList);
|
||||
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dde.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dde.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dde.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dde.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/dde.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_DDE_H_BASE_
|
||||
236
include/wx/debug.h
Normal file
236
include/wx/debug.h
Normal file
@@ -0,0 +1,236 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/debug.h
|
||||
// Purpose: Misc debug functions and macros
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 29/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Debugging macros
|
||||
//
|
||||
// All debugging macros rely on ASSERT() which in turn calls 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
|
||||
#ifdef __WXDEBUG__
|
||||
/*
|
||||
this function may be redefined to do something non trivial and is called
|
||||
whenever one of debugging macros fails (i.e. condition is false in an
|
||||
assertion)
|
||||
|
||||
parameters:
|
||||
szFile and nLine - file name and line number of the ASSERT
|
||||
szMsg - optional message explaining the reason
|
||||
*/
|
||||
extern void WXDLLEXPORT wxOnAssert(const wxChar *szFile,
|
||||
int nLine,
|
||||
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 WXDLLEXPORT wxTrap();
|
||||
|
||||
// helper function used to implement wxASSERT and wxASSERT_MSG
|
||||
//
|
||||
// note using "int" and not "bool" for cond to avoid VC++ warnings about
|
||||
// implicit conversions when doing "wxAssert( pointer )" and also use of
|
||||
// "!!cond" below to ensure that everything is converted to int
|
||||
extern void WXDLLEXPORT wxAssert(int cond,
|
||||
const wxChar *szFile,
|
||||
int nLine,
|
||||
const wxChar *szCond,
|
||||
const wxChar *szMsg = NULL) ;
|
||||
|
||||
// generic assert macro
|
||||
#define wxASSERT(cond) wxAssert(!!(cond), __TFILE__, __LINE__, _T(#cond))
|
||||
|
||||
// assert with additional message explaining it's cause
|
||||
#define wxASSERT_MSG(cond, msg) \
|
||||
wxAssert(!!(cond), __TFILE__, __LINE__, _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 shouldn't be
|
||||
// used any longer
|
||||
extern bool WXDLLEXPORT wxAssertIsEqual(int x, int y);
|
||||
#else
|
||||
#define wxTrap()
|
||||
|
||||
// nothing to do in release modes (hopefully at this moment there are
|
||||
// no more bugs ;-)
|
||||
#define wxASSERT(cond)
|
||||
#define wxASSERT_MSG(x, m)
|
||||
#endif //__WXDEBUG__
|
||||
|
||||
// Use of wxFalse instead of FALSE suppresses compiler warnings about testing
|
||||
// constant expression
|
||||
WXDLLEXPORT_DATA(extern const bool) wxFalse;
|
||||
#define wxAssertFailure wxFalse
|
||||
|
||||
// special form of assert: always triggers it (in debug mode)
|
||||
#define wxFAIL wxASSERT(wxAssertFailure)
|
||||
|
||||
// FAIL with some message
|
||||
#define wxFAIL_MSG(msg) wxASSERT_MSG(wxAssertFailure, msg)
|
||||
|
||||
// NB: the following macros work also in release mode!
|
||||
|
||||
/*
|
||||
These macros must be used only in invalid situation: for example, an
|
||||
invalid parameter (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(x, rc) if (!(x)) {wxFAIL; return rc; }
|
||||
|
||||
// as wxCHECK but with a message explaining why we fail
|
||||
#define wxCHECK_MSG(x, rc, msg) if (!(x)) {wxFAIL_MSG(msg); return rc; }
|
||||
|
||||
// check that expression is true, perform op if not
|
||||
#define wxCHECK2(x, op) if (!(x)) {wxFAIL; op; }
|
||||
|
||||
// as wxCHECK2 but with a message explaining why we fail
|
||||
#define wxCHECK2_MSG(x, op, msg) if (!(x)) {wxFAIL_MSG(msg); op; }
|
||||
|
||||
// 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(x, msg) if (!(x)) {wxFAIL_MSG(msg); return; }
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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!).
|
||||
The _n__ part is to stop VC++ 7 being confused since it encloses __LINE++ in
|
||||
parentheses. Unfortunately this does not work with other compilers, so
|
||||
we will only enable it when we know the _precise_ symbols to test for.
|
||||
*/
|
||||
|
||||
#define wxMAKE_ASSERT_NAME_HELPER(line) wxAssert_ ## line
|
||||
#define wxMAKE_ASSERT_NAME(line) wxMAKE_ASSERT_NAME_HELPER(line)
|
||||
#if 0
|
||||
#define wxMAKE_UNIQUE_ASSERT_NAME wxMAKE_ASSERT_NAME(_n___ ## __LINE__)
|
||||
#else
|
||||
#define wxMAKE_UNIQUE_ASSERT_NAME wxMAKE_ASSERT_NAME(__LINE__)
|
||||
#endif
|
||||
#define wxMAKE_UNIQUE_ASSERT_NAME2(text) wxMAKE_ASSERT_NAME(text)
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#define wxCOMPILE_TIME_ASSERT(expr, msg) \
|
||||
struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; }
|
||||
|
||||
#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 Mac in CodeWarrior builds, it always
|
||||
// returns false otherwise
|
||||
#ifdef __WXMAC__
|
||||
extern bool WXDLLEXPORT wxIsDebuggerRunning();
|
||||
#else // !Mac
|
||||
inline bool WXDLLEXPORT wxIsDebuggerRunning() { return false; }
|
||||
#endif // Mac/!Mac
|
||||
|
||||
#endif // _WX_DEBUG_H_
|
||||
|
||||
2253
include/wx/defs.h
Normal file
2253
include/wx/defs.h
Normal file
File diff suppressed because it is too large
Load Diff
77
include/wx/dialog.h
Normal file
77
include/wx/dialog.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dialog.h
|
||||
// Purpose: wxDialogBase class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 29.06.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DIALOG_H_BASE_
|
||||
#define _WX_DIALOG_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dialogbase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/containr.h"
|
||||
#include "wx/toplevel.h"
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
|
||||
|
||||
class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
|
||||
{
|
||||
public:
|
||||
wxDialogBase() { Init(); }
|
||||
virtual ~wxDialogBase() { }
|
||||
|
||||
void Init();
|
||||
|
||||
// the modal dialogs have a return code - usually the id of the last
|
||||
// pressed button
|
||||
void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
|
||||
int GetReturnCode() const { return m_returnCode; }
|
||||
|
||||
#if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
||||
// splits text up at newlines and places the
|
||||
// lines into a vertical wxBoxSizer
|
||||
wxSizer *CreateTextSizer( const wxString &message );
|
||||
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
||||
|
||||
#if wxUSE_BUTTON
|
||||
// places buttons into a horizontal wxBoxSizer
|
||||
wxSizer *CreateButtonSizer( long flags );
|
||||
#endif // wxUSE_BUTTON
|
||||
|
||||
protected:
|
||||
// the return code from modal dialog
|
||||
int m_returnCode;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
WX_DECLARE_CONTROL_CONTAINER();
|
||||
};
|
||||
|
||||
|
||||
#if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__)
|
||||
#include "wx/univ/dialog.h"
|
||||
#else
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/dialog.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dialog.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dialog.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dialog.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/dialog.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/dialog.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_DIALOG_H_BASE_
|
||||
201
include/wx/dialup.h
Normal file
201
include/wx/dialup.h
Normal file
@@ -0,0 +1,201 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dialup.h
|
||||
// Purpose: Network related wxWindows classes and functions
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 07.07.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DIALUP_H
|
||||
#define _WX_DIALUP_H
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dialup.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_DIALUP_MANAGER
|
||||
|
||||
#include "wx/event.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxArrayString;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
#define WXDIALUP_MANAGER_DEFAULT_BEACONHOST wxT("www.yahoo.com")
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A class which groups functions dealing with connecting to the network from a
|
||||
// workstation using dial-up access to the net. There is at most one instance
|
||||
// of this class in the program accessed via GetDialUpManager().
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* TODO
|
||||
*
|
||||
* 1. more configurability for Unix: i.e. how to initiate the connection, how
|
||||
* to check for online status, &c.
|
||||
* 2. a function to enumerate all connections (ISPs) and show a dialog in
|
||||
* Dial() allowing to choose between them if no ISP given
|
||||
* 3. add an async version of dialing functions which notify the caller about
|
||||
* the progress (or may be even start another thread to monitor it)
|
||||
* 4. the static creation/accessor functions are not MT-safe - but is this
|
||||
* really crucial? I think we may suppose they're always called from the
|
||||
* main thread?
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxDialUpManager
|
||||
{
|
||||
public:
|
||||
// this function should create and return the object of the
|
||||
// platform-specific class derived from wxDialUpManager. It's implemented
|
||||
// in the platform-specific source files.
|
||||
static wxDialUpManager *Create();
|
||||
|
||||
// could the dialup manager be initialized correctly? If this function
|
||||
// returns FALSE, no other functions will work neither, so it's a good idea
|
||||
// to call this function and check its result before calling any other
|
||||
// wxDialUpManager methods
|
||||
virtual bool IsOk() const = 0;
|
||||
|
||||
// virtual dtor for any base class
|
||||
virtual ~wxDialUpManager() { }
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// fills the array with the names of all possible values for the first
|
||||
// parameter to Dial() on this machine and returns their number (may be 0)
|
||||
virtual size_t GetISPNames(wxArrayString& names) const = 0;
|
||||
|
||||
// dial the given ISP, use username and password to authentificate
|
||||
//
|
||||
// if no nameOfISP is given, the function will select the default one
|
||||
//
|
||||
// if no username/password are given, the function will try to do without
|
||||
// them, but will ask the user if really needed
|
||||
//
|
||||
// if async parameter is FALSE, the function waits until the end of dialing
|
||||
// and returns TRUE upon successful completion.
|
||||
// if async is TRUE, the function only initiates the connection and returns
|
||||
// immediately - the result is reported via events (an event is sent
|
||||
// anyhow, but if dialing failed it will be a DISCONNECTED one)
|
||||
virtual bool Dial(const wxString& nameOfISP = wxEmptyString,
|
||||
const wxString& username = wxEmptyString,
|
||||
const wxString& password = wxEmptyString,
|
||||
bool async = TRUE) = 0;
|
||||
|
||||
// returns TRUE if (async) dialing is in progress
|
||||
virtual bool IsDialing() const = 0;
|
||||
|
||||
// cancel dialing the number initiated with Dial(async = TRUE)
|
||||
// NB: this won't result in DISCONNECTED event being sent
|
||||
virtual bool CancelDialing() = 0;
|
||||
|
||||
// hang up the currently active dial up connection
|
||||
virtual bool HangUp() = 0;
|
||||
|
||||
// online status
|
||||
// -------------
|
||||
|
||||
// returns TRUE if the computer has a permanent network connection (i.e. is
|
||||
// on a LAN) and so there is no need to use Dial() function to go online
|
||||
//
|
||||
// NB: this functions tries to guess the result and it is not always
|
||||
// guaranteed to be correct, so it's better to ask user for
|
||||
// confirmation or give him a possibility to override it
|
||||
virtual bool IsAlwaysOnline() const = 0;
|
||||
|
||||
// returns TRUE if the computer is connected to the network: under Windows,
|
||||
// this just means that a RAS connection exists, under Unix we check that
|
||||
// the "well-known host" (as specified by SetWellKnownHost) is reachable
|
||||
virtual bool IsOnline() const = 0;
|
||||
|
||||
// sometimes the built-in logic for determining the online status may fail,
|
||||
// so, in general, the user should be allowed to override it. This function
|
||||
// allows to forcefully set the online status - whatever our internal
|
||||
// algorithm may think about it.
|
||||
virtual void SetOnlineStatus(bool isOnline = TRUE) = 0;
|
||||
|
||||
// set misc wxDialUpManager options
|
||||
// --------------------------------
|
||||
|
||||
// enable automatical checks for the connection status and sending of
|
||||
// wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events. The interval
|
||||
// parameter is only for Unix where we do the check manually: under
|
||||
// Windows, the notification about the change of connection status is
|
||||
// instantenous.
|
||||
//
|
||||
// Returns FALSE if couldn't set up automatic check for online status.
|
||||
virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds = 60) = 0;
|
||||
|
||||
// disable automatic check for connection status change - notice that the
|
||||
// wxEVT_DIALUP_XXX events won't be sent any more neither.
|
||||
virtual void DisableAutoCheckOnlineStatus() = 0;
|
||||
|
||||
// additional Unix-only configuration
|
||||
// ----------------------------------
|
||||
|
||||
// under Unix, the value of well-known host is used to check whether we're
|
||||
// connected to the internet. It's unused under Windows, but this function
|
||||
// is always safe to call. The default value is www.yahoo.com.
|
||||
virtual void SetWellKnownHost(const wxString& hostname,
|
||||
int portno = 80) = 0;
|
||||
|
||||
// Sets the commands to start up the network and to hang up again. Used by
|
||||
// the Unix implementations only.
|
||||
virtual void
|
||||
SetConnectCommand(const wxString& commandDial = wxT("/usr/bin/pon"),
|
||||
const wxString& commandHangup = wxT("/usr/bin/poff")) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDialUpManager events
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED, 450)
|
||||
DECLARE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED, 451)
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
// the event class for the dialup events
|
||||
class WXDLLEXPORT wxDialUpEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
wxDialUpEvent(bool isConnected, bool isOwnEvent) : wxEvent(isOwnEvent)
|
||||
{
|
||||
SetEventType(isConnected ? wxEVT_DIALUP_CONNECTED
|
||||
: wxEVT_DIALUP_DISCONNECTED);
|
||||
}
|
||||
|
||||
// is this a CONNECTED or DISCONNECTED event?
|
||||
bool IsConnectedEvent() const
|
||||
{ return GetEventType() == wxEVT_DIALUP_CONNECTED; }
|
||||
|
||||
// does this event come from wxDialUpManager::Dial() or from some extrenal
|
||||
// process (i.e. does it result from our own attempt to establish the
|
||||
// connection)?
|
||||
bool IsOwnEvent() const { return m_id != 0; }
|
||||
|
||||
// implement the base class pure virtual
|
||||
virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); }
|
||||
};
|
||||
|
||||
// the type of dialup event handler function
|
||||
typedef void (wxEvtHandler::*wxDialUpEventFunction)(wxDialUpEvent&);
|
||||
|
||||
// macros to catch dialup events
|
||||
#define EVT_DIALUP_CONNECTED(func) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( wxEVT_DIALUP_CONNECTED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDialUpEventFunction) & func, NULL),
|
||||
#define EVT_DIALUP_DISCONNECTED(func) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( wxEVT_DIALUP_DISCONNECTED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxDialUpEventFunction) & func, NULL),
|
||||
|
||||
|
||||
#endif // wxUSE_DIALUP_MANAGER
|
||||
|
||||
#endif // _WX_DIALUP_H
|
||||
151
include/wx/dir.h
Normal file
151
include/wx/dir.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dir.h
|
||||
// Purpose: wxDir is a class for enumerating the files in a directory
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 08.12.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DIR_H_
|
||||
#define _WX_DIR_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dir.h"
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// these flags define what kind of filenames is included in the list of files
|
||||
// enumerated by GetFirst/GetNext
|
||||
enum
|
||||
{
|
||||
wxDIR_FILES = 0x0001, // include files
|
||||
wxDIR_DIRS = 0x0002, // include directories
|
||||
wxDIR_HIDDEN = 0x0004, // include hidden files
|
||||
wxDIR_DOTDOT = 0x0008, // include '.' and '..'
|
||||
|
||||
// by default, enumerate everything except '.' and '..'
|
||||
wxDIR_DEFAULT = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN
|
||||
};
|
||||
|
||||
// these constants are possible return value of wxDirTraverser::OnDir()
|
||||
enum wxDirTraverseResult
|
||||
{
|
||||
wxDIR_IGNORE = -1, // ignore this directory but continue with others
|
||||
wxDIR_STOP, // stop traversing
|
||||
wxDIR_CONTINUE // continue into this directory
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDirTraverser: helper class for wxDir::Traverse()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDirTraverser
|
||||
{
|
||||
public:
|
||||
// called for each file found by wxDir::Traverse()
|
||||
//
|
||||
// return wxDIR_STOP or wxDIR_CONTINUE from here (wxDIR_IGNORE doesn't
|
||||
// make sense)
|
||||
virtual wxDirTraverseResult OnFile(const wxString& filename) = 0;
|
||||
|
||||
// called for each directory found by wxDir::Traverse()
|
||||
//
|
||||
// return one of the enum elements defined above
|
||||
virtual wxDirTraverseResult OnDir(const wxString& dirname) = 0;
|
||||
|
||||
// called for each directory which we couldn't open during our traversal
|
||||
// of the directory tyree
|
||||
//
|
||||
// this method can also return either wxDIR_STOP, wxDIR_IGNORE or
|
||||
// wxDIR_CONTINUE but the latter is treated specially: it means to retry
|
||||
// opening the directory and so may lead to infinite loop if it is
|
||||
// returned unconditionally, be careful with this!
|
||||
//
|
||||
// the base class version always returns wxDIR_IGNORE
|
||||
virtual wxDirTraverseResult OnOpenError(const wxString& dirname);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDir: portable equivalent of {open/read/close}dir functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDirData;
|
||||
|
||||
class WXDLLEXPORT wxDir
|
||||
{
|
||||
public:
|
||||
// test for existence of a directory with the given name
|
||||
static bool Exists(const wxString& dir);
|
||||
|
||||
// ctors
|
||||
// -----
|
||||
|
||||
// default, use Open()
|
||||
wxDir() { m_data = NULL; }
|
||||
|
||||
// opens the directory for enumeration, use IsOpened() to test success
|
||||
wxDir(const wxString& dir);
|
||||
|
||||
// dtor cleans up the associated ressources
|
||||
~wxDir();
|
||||
|
||||
// open the directory for enumerating
|
||||
bool Open(const wxString& dir);
|
||||
|
||||
// returns TRUE if the directory was successfully opened
|
||||
bool IsOpened() const;
|
||||
|
||||
// get the full name of the directory (without '/' at the end)
|
||||
wxString GetName() const;
|
||||
|
||||
// file enumeration routines
|
||||
// -------------------------
|
||||
|
||||
// start enumerating all files matching filespec (or all files if it is
|
||||
// empty) and flags, return TRUE on success
|
||||
bool GetFirst(wxString *filename,
|
||||
const wxString& filespec = wxEmptyString,
|
||||
int flags = wxDIR_DEFAULT) const;
|
||||
|
||||
// get next file in the enumeration started with GetFirst()
|
||||
bool GetNext(wxString *filename) const;
|
||||
|
||||
// return true if this directory has any files in it
|
||||
bool HasFiles(const wxString& spec = wxEmptyString);
|
||||
|
||||
// return true if this directory has any subdirectories
|
||||
bool HasSubDirs(const wxString& spec = wxEmptyString);
|
||||
|
||||
// enumerate all files in this directory and its subdirectories
|
||||
//
|
||||
// return the number of files found
|
||||
size_t Traverse(wxDirTraverser& sink,
|
||||
const wxString& filespec = wxEmptyString,
|
||||
int flags = wxDIR_DEFAULT) const;
|
||||
|
||||
// simplest version of Traverse(): get the names of all files under this
|
||||
// directory into filenames array, return the number of files
|
||||
static size_t GetAllFiles(const wxString& dirname,
|
||||
wxArrayString *files,
|
||||
const wxString& filespec = wxEmptyString,
|
||||
int flags = wxDIR_DEFAULT);
|
||||
|
||||
private:
|
||||
friend class WXDLLEXPORT wxDirData;
|
||||
|
||||
wxDirData *m_data;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDir)
|
||||
};
|
||||
|
||||
#endif // _WX_DIR_H_
|
||||
7
include/wx/dirctrl.h
Normal file
7
include/wx/dirctrl.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _WX_DIRCTRL_H_BASE_
|
||||
#define _WX_DIRCTRL_H_BASE_
|
||||
|
||||
#include "wx/generic/dirctrlg.h"
|
||||
|
||||
#endif
|
||||
// _WX_DIRCTRL_H_BASE_
|
||||
87
include/wx/dirdlg.h
Normal file
87
include/wx/dirdlg.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef _WX_DIRDLG_H_BASE_
|
||||
#define _WX_DIRDLG_H_BASE_
|
||||
|
||||
#if wxUSE_DIRDLG
|
||||
|
||||
#include "wx/dialog.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogNameStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxDirSelectorPromptStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
#define wxDD_DEFAULT_STYLE \
|
||||
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxDD_NEW_DIR_BUTTON)
|
||||
|
||||
/*
|
||||
The interface (TODO: make the other classes really derive from it!) is
|
||||
something like this:
|
||||
|
||||
class WXDLLEXPORT wxDirDialogBase : public wxDialog
|
||||
{
|
||||
public:
|
||||
wxDirDialogBase(wxWindow *parent,
|
||||
const wxString& title = wxFileSelectorPromptStr,
|
||||
const wxString& defaultPath = wxEmptyString,
|
||||
long style = wxDD_DEFAULT_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& sz = wxDefaultSize,
|
||||
const wxString& name = _T("dirdialog"));
|
||||
|
||||
void SetMessage(const wxString& message);
|
||||
void SetPath(const wxString& path);
|
||||
void SetStyle(long style);
|
||||
|
||||
wxString GetMessage() const;
|
||||
wxString GetPath() const;
|
||||
long GetStyle() const;
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#if defined(__WIN16__) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS) || defined(__SALFORDC__) || !wxUSE_OLE
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#define wxDirDialog wxGenericDirDialog
|
||||
#else
|
||||
#include "wx/msw/dirdlg.h"
|
||||
#endif
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dirdlg.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/generic/dirdlgg.h"
|
||||
#endif
|
||||
|
||||
#if !defined(__WXMSW__) && !defined(__WXMAC__)
|
||||
#define wxDirDialog wxGenericDirDialog
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// common ::wxDirSelector() function
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT wxString
|
||||
wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
|
||||
const wxString& defaultPath = wxEmptyString,
|
||||
long style = wxDD_DEFAULT_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
wxWindow *parent = NULL);
|
||||
|
||||
#endif // wxUSE_DIRDLG
|
||||
|
||||
#endif
|
||||
// _WX_DIRDLG_H_BASE_
|
||||
164
include/wx/display.h
Normal file
164
include/wx/display.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/display.h
|
||||
// Purpose: wxDisplay class
|
||||
// Author: Royce Mitchell III
|
||||
// Modified by: Vadim Zeitlin (resolution changes, display modes, ...)
|
||||
// Created: 06/21/02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2002-2003 wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DISPLAY_H_BASE_
|
||||
#define _WX_DISPLAY_H_BASE_
|
||||
|
||||
#if wxUSE_DISPLAY
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "displaybase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
|
||||
class WXDLLEXPORT wxWindow;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxVideoMode: contains video mode parameters for a display
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
struct WXDLLEXPORT wxVideoMode
|
||||
{
|
||||
wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0)
|
||||
{
|
||||
w = width;
|
||||
h = height;
|
||||
|
||||
bpp = depth;
|
||||
|
||||
refresh = freq;
|
||||
}
|
||||
|
||||
// default copy ctor and assignment operator are ok
|
||||
|
||||
bool operator==(const wxVideoMode& m) const
|
||||
{
|
||||
return w == m.w && h == m.h && bpp == m.bpp && refresh == m.refresh;
|
||||
}
|
||||
bool operator!=(const wxVideoMode& mode) const
|
||||
{
|
||||
return !operator==(mode);
|
||||
}
|
||||
|
||||
// returns true if this mode matches the other one in the sense that all
|
||||
// non zero fields of the other mode have the same value in this one
|
||||
// (except for refresh which is allowed to have a greater value)
|
||||
bool Matches(const wxVideoMode& other) const
|
||||
{
|
||||
return (!other.w || w == other.w) &&
|
||||
(!other.h || h == other.h) &&
|
||||
(!other.bpp || bpp == other.bpp) &&
|
||||
(!other.refresh || refresh >= other.refresh);
|
||||
}
|
||||
|
||||
// the screen size in pixels (e.g. 640*480), 0 means unspecified
|
||||
int w, h;
|
||||
|
||||
// bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known
|
||||
int bpp;
|
||||
|
||||
// refresh frequency in Hz, 0 means unspecified/unknown
|
||||
int refresh;
|
||||
};
|
||||
|
||||
WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
|
||||
|
||||
// default, uninitialized, video mode object
|
||||
WXDLLEXPORT_DATA(extern const wxVideoMode) wxDefaultVideoMode;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDisplayBase: represents a display/monitor attached to the system
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDisplayBase
|
||||
{
|
||||
public:
|
||||
// initialize the object containing all information about the given
|
||||
// display
|
||||
//
|
||||
// the displays are numbered from 0 to GetCount() - 1, 0 is always the
|
||||
// primary display and the only one which is always supported
|
||||
wxDisplayBase(size_t index = 0);
|
||||
|
||||
// return the number of available displays, valid parameters to
|
||||
// wxDisplay ctor are from 0 up to this number
|
||||
static size_t GetCount();
|
||||
|
||||
// find the display where the given point lies, return wxNOT_FOUND if
|
||||
// it doesn't belong to any display
|
||||
static int GetFromPoint(const wxPoint& pt);
|
||||
|
||||
// find the display where the given window lies, return wxNOT_FOUND if it
|
||||
// is not shown at all
|
||||
static int GetFromWindow(wxWindow *window);
|
||||
|
||||
|
||||
// return true if the object was initialized successfully
|
||||
virtual bool IsOk() const { return true; }
|
||||
|
||||
// get the display size
|
||||
virtual wxRect GetGeometry() const = 0;
|
||||
|
||||
// name may be empty
|
||||
virtual wxString GetName() const = 0;
|
||||
|
||||
// display 0 is always the primary display
|
||||
bool IsPrimary() const { return m_index == 0; }
|
||||
|
||||
|
||||
// enumerate all video modes supported by this display matching the given
|
||||
// one (in the sense of wxVideoMode::Match())
|
||||
//
|
||||
// as any mode matches the default value of the argument and there is
|
||||
// always at least one video mode supported by display, the returned array
|
||||
// is only empty for the default value of the argument if this function is
|
||||
// not supported at all on this platform
|
||||
virtual wxArrayVideoModes
|
||||
GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const = 0;
|
||||
|
||||
// get current video mode
|
||||
virtual wxVideoMode GetCurrentMode() const = 0;
|
||||
|
||||
// change current mode, return true if succeeded, false otherwise
|
||||
//
|
||||
// for the default value of the argument restores the video mode to default
|
||||
virtual bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode) = 0;
|
||||
|
||||
// restore the default video mode (just a more readable synonym)
|
||||
void ResetMode() { (void)ChangeMode(); }
|
||||
|
||||
// virtual dtor as for any base class
|
||||
virtual ~wxDisplayBase() { }
|
||||
|
||||
protected:
|
||||
// the index of this display (0 is always the primary one)
|
||||
size_t m_index;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDisplayBase);
|
||||
};
|
||||
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/display.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/display.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/unix/displayx11.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/display.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/display.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_DISPLAY
|
||||
|
||||
#endif // _WX_DISPLAY_H_BASE_
|
||||
251
include/wx/dnd.h
Normal file
251
include/wx/dnd.h
Normal file
@@ -0,0 +1,251 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dnd.h
|
||||
// Purpose: Drag and drop classes declarations
|
||||
// Author: Vadim Zeitlin, Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 26.05.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows Team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DND_H_BASE_
|
||||
#define _WX_DND_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dndbase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
|
||||
#include "wx/dataobj.h"
|
||||
#include "wx/cursor.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// flags for wxDropSource::DoDragDrop()
|
||||
//
|
||||
// NB: wxDrag_CopyOnly must be 0 (== FALSE) and wxDrag_AllowMove must be 1
|
||||
// (== TRUE) for compatibility with the old DoDragDrop(bool) method!
|
||||
enum
|
||||
{
|
||||
wxDrag_CopyOnly = 0, // allow only copying
|
||||
wxDrag_AllowMove = 1, // allow moving (copying is always allowed)
|
||||
wxDrag_DefaultMove = 3 // the default operation is move, not copy
|
||||
};
|
||||
|
||||
// result of wxDropSource::DoDragDrop() call
|
||||
enum wxDragResult
|
||||
{
|
||||
wxDragError, // error prevented the d&d operation from completing
|
||||
wxDragNone, // drag target didn't accept the data
|
||||
wxDragCopy, // the data was successfully copied
|
||||
wxDragMove, // the data was successfully moved (MSW only)
|
||||
wxDragLink, // operation is a drag-link
|
||||
wxDragCancel // the operation was cancelled by user (not an error)
|
||||
};
|
||||
|
||||
inline WXDLLEXPORT bool wxIsDragResultOk(wxDragResult res)
|
||||
{
|
||||
return res == wxDragCopy || res == wxDragMove || res == wxDragLink;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDropSource is the object you need to create (and call DoDragDrop on it)
|
||||
// to initiate a drag-and-drop operation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDropSourceBase
|
||||
{
|
||||
public:
|
||||
wxDropSourceBase(const wxCursor &cursorCopy = wxNullCursor,
|
||||
const wxCursor &cursorMove = wxNullCursor,
|
||||
const wxCursor &cursorStop = wxNullCursor)
|
||||
: m_cursorCopy(cursorCopy),
|
||||
m_cursorMove(cursorMove),
|
||||
m_cursorStop(cursorStop)
|
||||
{ m_data = (wxDataObject *)NULL; }
|
||||
virtual ~wxDropSourceBase() { }
|
||||
|
||||
// set the data which is transfered by drag and drop
|
||||
void SetData(wxDataObject& data)
|
||||
{ m_data = &data; }
|
||||
|
||||
wxDataObject *GetDataObject()
|
||||
{ return m_data; }
|
||||
|
||||
// set the icon corresponding to given drag result
|
||||
void SetCursor(wxDragResult res, const wxCursor& cursor)
|
||||
{
|
||||
if ( res == wxDragCopy )
|
||||
m_cursorCopy = cursor;
|
||||
else if ( res == wxDragMove )
|
||||
m_cursorMove = cursor;
|
||||
else
|
||||
m_cursorStop = cursor;
|
||||
}
|
||||
|
||||
// start drag action, see enum wxDragResult for return value description
|
||||
//
|
||||
// if flags contains wxDrag_AllowMove, moving (and only copying) data is
|
||||
// allowed, if it contains wxDrag_DefaultMove (which includes the previous
|
||||
// flag), it is even the default operation
|
||||
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly) = 0;
|
||||
|
||||
// override to give feedback depending on the current operation result
|
||||
// "effect" and return TRUE if you did something, FALSE to let the library
|
||||
// give the default feedback
|
||||
virtual bool GiveFeedback(wxDragResult WXUNUSED(effect)) { return FALSE; }
|
||||
|
||||
protected:
|
||||
const wxCursor& GetCursor(wxDragResult res) const
|
||||
{
|
||||
if ( res == wxDragCopy )
|
||||
return m_cursorCopy;
|
||||
else if ( res == wxDragMove )
|
||||
return m_cursorMove;
|
||||
else
|
||||
return m_cursorStop;
|
||||
}
|
||||
|
||||
// the data we're dragging
|
||||
wxDataObject *m_data;
|
||||
|
||||
// the cursors to use for feedback
|
||||
wxCursor m_cursorCopy,
|
||||
m_cursorMove,
|
||||
m_cursorStop;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDropSourceBase)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDropTarget should be associated with a window if it wants to be able to
|
||||
// receive data via drag and drop.
|
||||
//
|
||||
// To use this class, you should derive from wxDropTarget and implement
|
||||
// OnData() pure virtual method. You may also wish to override OnDrop() if you
|
||||
// want to accept the data only inside some region of the window (this may
|
||||
// avoid having to copy the data to this application which happens only when
|
||||
// OnData() is called)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDropTargetBase
|
||||
{
|
||||
public:
|
||||
// ctor takes a pointer to heap-allocated wxDataObject which will be owned
|
||||
// by wxDropTarget and deleted by it automatically. If you don't give it
|
||||
// here, you can use SetDataObject() later.
|
||||
wxDropTargetBase(wxDataObject *dataObject = (wxDataObject*)NULL)
|
||||
{ m_dataObject = dataObject; }
|
||||
// dtor deletes our data object
|
||||
virtual ~wxDropTargetBase()
|
||||
{ delete m_dataObject; }
|
||||
|
||||
// get/set the associated wxDataObject
|
||||
wxDataObject *GetDataObject() const
|
||||
{ return m_dataObject; }
|
||||
void SetDataObject(wxDataObject *dataObject)
|
||||
{ if (m_dataObject) delete m_dataObject;
|
||||
m_dataObject = dataObject; }
|
||||
|
||||
// these functions are called when data is moved over position (x, y) and
|
||||
// may return either wxDragCopy, wxDragMove or wxDragNone depending on
|
||||
// what would happen if the data were dropped here.
|
||||
//
|
||||
// the last parameter is what would happen by default and is determined by
|
||||
// the platform-specific logic (for example, under Windows it's wxDragCopy
|
||||
// if Ctrl key is pressed and wxDragMove otherwise) except that it will
|
||||
// always be wxDragNone if the carried data is in an unsupported format.
|
||||
|
||||
// called when the mouse enters the window (only once until OnLeave())
|
||||
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
|
||||
{ return OnDragOver(x, y, def); }
|
||||
|
||||
// called when the mouse moves in the window - shouldn't take long to
|
||||
// execute or otherwise mouse movement would be too slow
|
||||
virtual wxDragResult OnDragOver(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
||||
wxDragResult def)
|
||||
{ return def; }
|
||||
|
||||
// called when mouse leaves the window: might be used to remove the
|
||||
// feedback which was given in OnEnter()
|
||||
virtual void OnLeave() { }
|
||||
|
||||
// this function is called when data is dropped at position (x, y) - if it
|
||||
// returns TRUE, OnData() will be called immediately afterwards which will
|
||||
// allow to retrieve the data dropped.
|
||||
virtual bool OnDrop(wxCoord x, wxCoord y) = 0;
|
||||
|
||||
// called after OnDrop() returns TRUE: you will usually just call
|
||||
// GetData() from here and, probably, also refresh something to update the
|
||||
// new data and, finally, return the code indicating how did the operation
|
||||
// complete (returning default value in case of success and wxDragError on
|
||||
// failure is usually ok)
|
||||
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0;
|
||||
|
||||
// may be called *only* from inside OnData() and will fill m_dataObject
|
||||
// with the data from the drop source if it returns TRUE
|
||||
virtual bool GetData() = 0;
|
||||
|
||||
protected:
|
||||
wxDataObject *m_dataObject;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDropTargetBase)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include platform dependent class declarations
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/ole/dropsrc.h"
|
||||
#include "wx/msw/ole/droptgt.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dnd.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/dnd.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dnd.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/dnd.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/dnd.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// standard wxDropTarget implementations (implemented in common/dobjcmn.cpp)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// A simple wxDropTarget derived class for text data: you only need to
|
||||
// override OnDropText() to get something working
|
||||
class WXDLLEXPORT wxTextDropTarget : public wxDropTarget
|
||||
{
|
||||
public:
|
||||
wxTextDropTarget();
|
||||
|
||||
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
|
||||
|
||||
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||
};
|
||||
|
||||
// A drop target which accepts files (dragged from File Manager or Explorer)
|
||||
class WXDLLEXPORT wxFileDropTarget : public wxDropTarget
|
||||
{
|
||||
public:
|
||||
wxFileDropTarget();
|
||||
|
||||
// parameters are the number of files and the array of file names
|
||||
virtual bool OnDropFiles(wxCoord x, wxCoord y,
|
||||
const wxArrayString& filenames) = 0;
|
||||
|
||||
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||
};
|
||||
|
||||
#endif // wxUSE_DRAG_AND_DROP
|
||||
|
||||
#endif // _WX_DND_H_BASE_
|
||||
93
include/wx/docmdi.h
Normal file
93
include/wx/docmdi.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: docmdi.h
|
||||
// Purpose: Frame classes for MDI document/view applications
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DOCMDI_H_
|
||||
#define _WX_DOCMDI_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "docmdi.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_MDI_ARCHITECTURE
|
||||
|
||||
#include "wx/docview.h"
|
||||
#include "wx/mdi.h"
|
||||
|
||||
/*
|
||||
* Use this instead of wxMDIParentFrame
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxDocMDIParentFrame: public wxMDIParentFrame
|
||||
{
|
||||
public:
|
||||
wxDocMDIParentFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id,
|
||||
const wxString& title, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame"));
|
||||
|
||||
// Extend event processing to search the document manager's event table
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
wxDocManager *GetDocumentManager(void) const { return m_docManager; }
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnMRUFile(wxCommandEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
protected:
|
||||
wxDocManager *m_docManager;
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxDocMDIParentFrame)
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxDocMDIParentFrame)
|
||||
};
|
||||
|
||||
/*
|
||||
* Use this instead of wxMDIChildFrame
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxDocMDIChildFrame: public wxMDIChildFrame
|
||||
{
|
||||
public:
|
||||
wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id,
|
||||
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame"));
|
||||
~wxDocMDIChildFrame();
|
||||
|
||||
// Extend event processing to search the view's event table
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
inline wxDocument *GetDocument() const { return m_childDocument; }
|
||||
inline wxView *GetView(void) const { return m_childView; }
|
||||
inline void SetDocument(wxDocument *doc) { m_childDocument = doc; }
|
||||
inline void SetView(wxView *view) { m_childView = view; }
|
||||
bool Destroy() { m_childView = (wxView *)NULL; return wxMDIChildFrame::Destroy(); }
|
||||
|
||||
protected:
|
||||
wxDocument* m_childDocument;
|
||||
wxView* m_childView;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_CLASS(wxDocMDIChildFrame)
|
||||
DECLARE_NO_COPY_CLASS(wxDocMDIChildFrame)
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_MDI_ARCHITECTURE
|
||||
|
||||
#endif
|
||||
// _WX_DOCMDI_H_
|
||||
614
include/wx/docview.h
Normal file
614
include/wx/docview.h
Normal file
@@ -0,0 +1,614 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: docview.h
|
||||
// Purpose: Doc/View classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DOCH__
|
||||
#define _WX_DOCH__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "docview.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
|
||||
#include "wx/list.h"
|
||||
#include "wx/cmndata.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/frame.h"
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
#include "wx/print.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxWindow;
|
||||
class WXDLLEXPORT wxDocument;
|
||||
class WXDLLEXPORT wxView;
|
||||
class WXDLLEXPORT wxDocTemplate;
|
||||
class WXDLLEXPORT wxDocManager;
|
||||
class WXDLLEXPORT wxPrintInfo;
|
||||
class WXDLLEXPORT wxCommandProcessor;
|
||||
class WXDLLEXPORT wxFileHistory;
|
||||
class WXDLLEXPORT wxConfigBase;
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
#include "wx/iosfwrap.h"
|
||||
#else
|
||||
#include "wx/stream.h"
|
||||
#endif
|
||||
|
||||
// Document manager flags
|
||||
enum
|
||||
{
|
||||
wxDOC_SDI = 1,
|
||||
wxDOC_MDI,
|
||||
wxDOC_NEW,
|
||||
wxDOC_SILENT,
|
||||
wxDEFAULT_DOCMAN_FLAGS = wxDOC_SDI
|
||||
};
|
||||
|
||||
// Document template flags
|
||||
enum
|
||||
{
|
||||
wxTEMPLATE_VISIBLE = 1,
|
||||
wxTEMPLATE_INVISIBLE,
|
||||
wxDEFAULT_TEMPLATE_FLAGS = wxTEMPLATE_VISIBLE
|
||||
};
|
||||
|
||||
#define wxMAX_FILE_HISTORY 9
|
||||
|
||||
class WXDLLEXPORT wxDocument : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
wxDocument(wxDocument *parent = (wxDocument *) NULL);
|
||||
~wxDocument();
|
||||
|
||||
// accessors
|
||||
void SetFilename(const wxString& filename, bool notifyViews = FALSE);
|
||||
wxString GetFilename() const { return m_documentFile; }
|
||||
|
||||
void SetTitle(const wxString& title) { m_documentTitle = title; };
|
||||
wxString GetTitle() const { return m_documentTitle; }
|
||||
|
||||
void SetDocumentName(const wxString& name) { m_documentTypeName = name; };
|
||||
wxString GetDocumentName() const { return m_documentTypeName; }
|
||||
|
||||
bool GetDocumentSaved() const { return m_savedYet; }
|
||||
void SetDocumentSaved(bool saved = TRUE) { m_savedYet = saved; }
|
||||
|
||||
virtual bool Close();
|
||||
virtual bool Save();
|
||||
virtual bool SaveAs();
|
||||
virtual bool Revert();
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
virtual wxSTD ostream& SaveObject(wxSTD ostream& stream);
|
||||
virtual wxSTD istream& LoadObject(wxSTD istream& stream);
|
||||
#else
|
||||
virtual wxOutputStream& SaveObject(wxOutputStream& stream);
|
||||
virtual wxInputStream& LoadObject(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
// Called by wxWindows
|
||||
virtual bool OnSaveDocument(const wxString& filename);
|
||||
virtual bool OnOpenDocument(const wxString& filename);
|
||||
virtual bool OnNewDocument();
|
||||
virtual bool OnCloseDocument();
|
||||
|
||||
// Prompts for saving if about to close a modified document. Returns TRUE
|
||||
// if ok to close the document (may have saved in the meantime, or set
|
||||
// modified to FALSE)
|
||||
virtual bool OnSaveModified();
|
||||
|
||||
// Called by framework if created automatically by the default document
|
||||
// manager: gives document a chance to initialise and (usually) create a
|
||||
// view
|
||||
virtual bool OnCreate(const wxString& path, long flags);
|
||||
|
||||
// By default, creates a base wxCommandProcessor.
|
||||
virtual wxCommandProcessor *OnCreateCommandProcessor();
|
||||
virtual wxCommandProcessor *GetCommandProcessor() const { return m_commandProcessor; }
|
||||
virtual void SetCommandProcessor(wxCommandProcessor *proc) { m_commandProcessor = proc; }
|
||||
|
||||
// Called after a view is added or removed. The default implementation
|
||||
// deletes the document if this is there are no more views.
|
||||
virtual void OnChangedViewList();
|
||||
|
||||
virtual bool DeleteContents();
|
||||
|
||||
virtual bool Draw(wxDC&);
|
||||
virtual bool IsModified() const { return m_documentModified; }
|
||||
virtual void Modify(bool mod) { m_documentModified = mod; }
|
||||
|
||||
virtual bool AddView(wxView *view);
|
||||
virtual bool RemoveView(wxView *view);
|
||||
wxList& GetViews() const { return (wxList&) m_documentViews; }
|
||||
wxView *GetFirstView() const;
|
||||
|
||||
virtual void UpdateAllViews(wxView *sender = (wxView *) NULL, wxObject *hint = (wxObject *) NULL);
|
||||
virtual void NotifyClosing();
|
||||
|
||||
// Remove all views (because we're closing the document)
|
||||
virtual bool DeleteAllViews();
|
||||
|
||||
// Other stuff
|
||||
virtual wxDocManager *GetDocumentManager() const;
|
||||
virtual wxDocTemplate *GetDocumentTemplate() const { return m_documentTemplate; }
|
||||
virtual void SetDocumentTemplate(wxDocTemplate *temp) { m_documentTemplate = temp; }
|
||||
|
||||
// Get title, or filename if no title, else [unnamed]
|
||||
virtual bool GetPrintableName(wxString& buf) const;
|
||||
|
||||
// Returns a window that can be used as a parent for document-related
|
||||
// dialogs. Override if necessary.
|
||||
virtual wxWindow *GetDocumentWindow() const;
|
||||
|
||||
protected:
|
||||
wxList m_documentViews;
|
||||
wxString m_documentFile;
|
||||
wxString m_documentTitle;
|
||||
wxString m_documentTypeName;
|
||||
wxDocTemplate* m_documentTemplate;
|
||||
bool m_documentModified;
|
||||
wxDocument* m_documentParent;
|
||||
wxCommandProcessor* m_commandProcessor;
|
||||
bool m_savedYet;
|
||||
|
||||
private:
|
||||
DECLARE_ABSTRACT_CLASS(wxDocument)
|
||||
DECLARE_NO_COPY_CLASS(wxDocument)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxView: public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
// wxView(wxDocument *doc = (wxDocument *) NULL);
|
||||
wxView();
|
||||
~wxView();
|
||||
|
||||
wxDocument *GetDocument() const { return m_viewDocument; }
|
||||
virtual void SetDocument(wxDocument *doc);
|
||||
|
||||
wxString GetViewName() const { return m_viewTypeName; }
|
||||
void SetViewName(const wxString& name) { m_viewTypeName = name; };
|
||||
|
||||
wxWindow *GetFrame() const { return m_viewFrame ; }
|
||||
void SetFrame(wxWindow *frame) { m_viewFrame = frame; }
|
||||
|
||||
virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView);
|
||||
virtual void OnDraw(wxDC *dc) = 0;
|
||||
virtual void OnPrint(wxDC *dc, wxObject *info);
|
||||
virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
||||
virtual void OnClosingDocument() {};
|
||||
virtual void OnChangeFilename();
|
||||
|
||||
// Called by framework if created automatically by the default document
|
||||
// manager class: gives view a chance to initialise
|
||||
virtual bool OnCreate(wxDocument *WXUNUSED(doc), long WXUNUSED(flags)) { return TRUE; };
|
||||
|
||||
// Checks if the view is the last one for the document; if so, asks user
|
||||
// to confirm save data (if modified). If ok, deletes itself and returns
|
||||
// TRUE.
|
||||
virtual bool Close(bool deleteWindow = TRUE);
|
||||
|
||||
// Override to do cleanup/veto close
|
||||
virtual bool OnClose(bool deleteWindow);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
// Defeat compiler warning
|
||||
bool OnClose() { return wxEvtHandler::OnClose(); }
|
||||
#endif
|
||||
|
||||
// Extend event processing to search the document's event table
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
// A view's window can call this to notify the view it is (in)active.
|
||||
// The function then notifies the document manager.
|
||||
virtual void Activate(bool activate);
|
||||
|
||||
wxDocManager *GetDocumentManager() const
|
||||
{ return m_viewDocument->GetDocumentManager(); }
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
virtual wxPrintout *OnCreatePrintout();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
wxDocument* m_viewDocument;
|
||||
wxString m_viewTypeName;
|
||||
wxWindow* m_viewFrame;
|
||||
|
||||
private:
|
||||
DECLARE_ABSTRACT_CLASS(wxView)
|
||||
DECLARE_NO_COPY_CLASS(wxView)
|
||||
};
|
||||
|
||||
// Represents user interface (and other) properties of documents and views
|
||||
class WXDLLEXPORT wxDocTemplate: public wxObject
|
||||
{
|
||||
|
||||
friend class WXDLLEXPORT wxDocManager;
|
||||
|
||||
public:
|
||||
// Associate document and view types. They're for identifying what view is
|
||||
// associated with what template/document type
|
||||
wxDocTemplate(wxDocManager *manager,
|
||||
const wxString& descr,
|
||||
const wxString& filter,
|
||||
const wxString& dir,
|
||||
const wxString& ext,
|
||||
const wxString& docTypeName,
|
||||
const wxString& viewTypeName,
|
||||
wxClassInfo *docClassInfo = (wxClassInfo *) NULL,
|
||||
wxClassInfo *viewClassInfo = (wxClassInfo *)NULL,
|
||||
long flags = wxDEFAULT_TEMPLATE_FLAGS);
|
||||
|
||||
~wxDocTemplate();
|
||||
|
||||
// By default, these two member functions dynamically creates document and
|
||||
// view using dynamic instance construction. Override these if you need a
|
||||
// different method of construction.
|
||||
virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
|
||||
virtual wxView *CreateView(wxDocument *doc, long flags = 0);
|
||||
|
||||
wxString GetDefaultExtension() const { return m_defaultExt; };
|
||||
wxString GetDescription() const { return m_description; }
|
||||
wxString GetDirectory() const { return m_directory; };
|
||||
wxDocManager *GetDocumentManager() const { return m_documentManager; }
|
||||
void SetDocumentManager(wxDocManager *manager) { m_documentManager = manager; }
|
||||
wxString GetFileFilter() const { return m_fileFilter; };
|
||||
long GetFlags() const { return m_flags; };
|
||||
virtual wxString GetViewName() const { return m_viewTypeName; }
|
||||
virtual wxString GetDocumentName() const { return m_docTypeName; }
|
||||
|
||||
void SetFileFilter(const wxString& filter) { m_fileFilter = filter; };
|
||||
void SetDirectory(const wxString& dir) { m_directory = dir; };
|
||||
void SetDescription(const wxString& descr) { m_description = descr; };
|
||||
void SetDefaultExtension(const wxString& ext) { m_defaultExt = ext; };
|
||||
void SetFlags(long flags) { m_flags = flags; };
|
||||
|
||||
bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
|
||||
|
||||
virtual bool FileMatchesTemplate(const wxString& path);
|
||||
|
||||
protected:
|
||||
long m_flags;
|
||||
wxString m_fileFilter;
|
||||
wxString m_directory;
|
||||
wxString m_description;
|
||||
wxString m_defaultExt;
|
||||
wxString m_docTypeName;
|
||||
wxString m_viewTypeName;
|
||||
wxDocManager* m_documentManager;
|
||||
|
||||
// For dynamic creation of appropriate instances.
|
||||
wxClassInfo* m_docClassInfo;
|
||||
wxClassInfo* m_viewClassInfo;
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxDocTemplate)
|
||||
DECLARE_NO_COPY_CLASS(wxDocTemplate)
|
||||
};
|
||||
|
||||
// One object of this class may be created in an application, to manage all
|
||||
// the templates and documents.
|
||||
class WXDLLEXPORT wxDocManager: public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
wxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = TRUE);
|
||||
~wxDocManager();
|
||||
|
||||
virtual bool Initialize();
|
||||
|
||||
// Handlers for common user commands
|
||||
void OnFileClose(wxCommandEvent& event);
|
||||
void OnFileCloseAll(wxCommandEvent& event);
|
||||
void OnFileNew(wxCommandEvent& event);
|
||||
void OnFileOpen(wxCommandEvent& event);
|
||||
void OnFileRevert(wxCommandEvent& event);
|
||||
void OnFileSave(wxCommandEvent& event);
|
||||
void OnFileSaveAs(wxCommandEvent& event);
|
||||
void OnPrint(wxCommandEvent& event);
|
||||
void OnPrintSetup(wxCommandEvent& event);
|
||||
void OnPreview(wxCommandEvent& event);
|
||||
void OnUndo(wxCommandEvent& event);
|
||||
void OnRedo(wxCommandEvent& event);
|
||||
|
||||
// Handlers for UI update commands
|
||||
void OnUpdateFileOpen(wxUpdateUIEvent& event);
|
||||
void OnUpdateFileClose(wxUpdateUIEvent& event);
|
||||
void OnUpdateFileRevert(wxUpdateUIEvent& event);
|
||||
void OnUpdateFileNew(wxUpdateUIEvent& event);
|
||||
void OnUpdateFileSave(wxUpdateUIEvent& event);
|
||||
void OnUpdateFileSaveAs(wxUpdateUIEvent& event);
|
||||
void OnUpdateUndo(wxUpdateUIEvent& event);
|
||||
void OnUpdateRedo(wxUpdateUIEvent& event);
|
||||
|
||||
void OnUpdatePrint(wxUpdateUIEvent& event);
|
||||
void OnUpdatePrintSetup(wxUpdateUIEvent& event);
|
||||
void OnUpdatePreview(wxUpdateUIEvent& event);
|
||||
|
||||
// Extend event processing to search the view's event table
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
// called when file format detection didn't work, can be overridden to do
|
||||
// something in this case
|
||||
virtual void OnOpenFileFailure() { }
|
||||
|
||||
virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
|
||||
virtual wxView *CreateView(wxDocument *doc, long flags = 0);
|
||||
virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
|
||||
virtual bool FlushDoc(wxDocument *doc);
|
||||
virtual wxDocTemplate *MatchTemplate(const wxString& path);
|
||||
virtual wxDocTemplate *SelectDocumentPath(wxDocTemplate **templates,
|
||||
int noTemplates, wxString& path, long flags, bool save = FALSE);
|
||||
virtual wxDocTemplate *SelectDocumentType(wxDocTemplate **templates,
|
||||
int noTemplates, bool sort = FALSE);
|
||||
virtual wxDocTemplate *SelectViewType(wxDocTemplate **templates,
|
||||
int noTemplates, bool sort = FALSE);
|
||||
virtual wxDocTemplate *FindTemplateForPath(const wxString& path);
|
||||
|
||||
void AssociateTemplate(wxDocTemplate *temp);
|
||||
void DisassociateTemplate(wxDocTemplate *temp);
|
||||
|
||||
wxDocument *GetCurrentDocument() const;
|
||||
|
||||
void SetMaxDocsOpen(int n) { m_maxDocsOpen = n; }
|
||||
int GetMaxDocsOpen() const { return m_maxDocsOpen; }
|
||||
|
||||
// Add and remove a document from the manager's list
|
||||
void AddDocument(wxDocument *doc);
|
||||
void RemoveDocument(wxDocument *doc);
|
||||
|
||||
// closes all currently open documents
|
||||
bool CloseDocuments(bool force = TRUE);
|
||||
|
||||
// closes the specified document
|
||||
bool CloseDocument(wxDocument* doc, bool force = FALSE);
|
||||
|
||||
// Clear remaining documents and templates
|
||||
bool Clear(bool force = TRUE);
|
||||
|
||||
// Views or windows should inform the document manager
|
||||
// when a view is going in or out of focus
|
||||
virtual void ActivateView(wxView *view, bool activate = TRUE, bool deleting = FALSE);
|
||||
virtual wxView *GetCurrentView() const;
|
||||
|
||||
wxList& GetDocuments() { return m_docs; }
|
||||
wxList& GetTemplates() { return m_templates; }
|
||||
|
||||
// Make a default document name
|
||||
virtual bool MakeDefaultName(wxString& buf);
|
||||
|
||||
// Make a frame title (override this to do something different)
|
||||
virtual wxString MakeFrameTitle(wxDocument* doc);
|
||||
|
||||
virtual wxFileHistory *OnCreateFileHistory();
|
||||
virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
|
||||
|
||||
// File history management
|
||||
virtual void AddFileToHistory(const wxString& file);
|
||||
virtual void RemoveFileFromHistory(size_t i);
|
||||
virtual size_t GetHistoryFilesCount() const;
|
||||
virtual wxString GetHistoryFile(size_t i) const;
|
||||
virtual void FileHistoryUseMenu(wxMenu *menu);
|
||||
virtual void FileHistoryRemoveMenu(wxMenu *menu);
|
||||
#if wxUSE_CONFIG
|
||||
virtual void FileHistoryLoad(wxConfigBase& config);
|
||||
virtual void FileHistorySave(wxConfigBase& config);
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
virtual void FileHistoryAddFilesToMenu();
|
||||
virtual void FileHistoryAddFilesToMenu(wxMenu* menu);
|
||||
|
||||
wxString GetLastDirectory() const { return m_lastDirectory; }
|
||||
void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
|
||||
|
||||
// Get the current document manager
|
||||
static wxDocManager* GetDocumentManager() { return sm_docManager; }
|
||||
|
||||
// deprecated, use GetHistoryFilesCount() instead
|
||||
wxDEPRECATED( size_t GetNoHistoryFiles() const );
|
||||
|
||||
protected:
|
||||
long m_flags;
|
||||
int m_defaultDocumentNameCounter;
|
||||
int m_maxDocsOpen;
|
||||
wxList m_docs;
|
||||
wxList m_templates;
|
||||
wxView* m_currentView;
|
||||
wxFileHistory* m_fileHistory;
|
||||
wxString m_lastDirectory;
|
||||
static wxDocManager* sm_docManager;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxDocManager)
|
||||
DECLARE_NO_COPY_CLASS(wxDocManager)
|
||||
};
|
||||
|
||||
inline size_t wxDocManager::GetNoHistoryFiles() const
|
||||
{
|
||||
return GetHistoryFilesCount();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A default child frame
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDocChildFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
wxDocChildFrame(wxDocument *doc,
|
||||
wxView *view,
|
||||
wxFrame *frame,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long type = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxT("frame"));
|
||||
~wxDocChildFrame();
|
||||
|
||||
// Extend event processing to search the view's event table
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
wxDocument *GetDocument() const { return m_childDocument; }
|
||||
wxView *GetView() const { return m_childView; }
|
||||
void SetDocument(wxDocument *doc) { m_childDocument = doc; }
|
||||
void SetView(wxView *view) { m_childView = view; }
|
||||
bool Destroy() { m_childView = (wxView *)NULL; return wxFrame::Destroy(); }
|
||||
|
||||
protected:
|
||||
wxDocument* m_childDocument;
|
||||
wxView* m_childView;
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxDocChildFrame)
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxDocChildFrame)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A default parent frame
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDocParentFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
wxDocParentFrame(wxDocManager *manager,
|
||||
wxFrame *frame,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long type = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxT("frame"));
|
||||
|
||||
// Extend event processing to search the document manager's event table
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
wxDocManager *GetDocumentManager() const { return m_docManager; }
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnMRUFile(wxCommandEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
protected:
|
||||
wxDocManager *m_docManager;
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxDocParentFrame)
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxDocParentFrame)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Provide simple default printing facilities
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
class WXDLLEXPORT wxDocPrintout : public wxPrintout
|
||||
{
|
||||
public:
|
||||
wxDocPrintout(wxView *view = (wxView *) NULL, const wxString& title = wxT("Printout"));
|
||||
bool OnPrintPage(int page);
|
||||
bool HasPage(int page);
|
||||
bool OnBeginDocument(int startPage, int endPage);
|
||||
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
||||
|
||||
virtual wxView *GetView() { return m_printoutView; }
|
||||
|
||||
protected:
|
||||
wxView* m_printoutView;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxDocPrintout)
|
||||
DECLARE_NO_COPY_CLASS(wxDocPrintout)
|
||||
};
|
||||
#endif // wxUSE_PRINTING_ARCHITECTURE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// File history management
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFileHistory : public wxObject
|
||||
{
|
||||
public:
|
||||
wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
|
||||
~wxFileHistory();
|
||||
|
||||
// Operations
|
||||
virtual void AddFileToHistory(const wxString& file);
|
||||
virtual void RemoveFileFromHistory(size_t i);
|
||||
virtual int GetMaxFiles() const { return m_fileMaxFiles; }
|
||||
virtual void UseMenu(wxMenu *menu);
|
||||
|
||||
// Remove menu from the list (MDI child may be closing)
|
||||
virtual void RemoveMenu(wxMenu *menu);
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
virtual void Load(wxConfigBase& config);
|
||||
virtual void Save(wxConfigBase& config);
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
virtual void AddFilesToMenu();
|
||||
virtual void AddFilesToMenu(wxMenu* menu); // Single menu
|
||||
|
||||
// Accessors
|
||||
virtual wxString GetHistoryFile(size_t i) const;
|
||||
virtual size_t GetCount() const { return m_fileHistoryN; }
|
||||
|
||||
const wxList& GetMenus() const { return m_fileMenus; }
|
||||
|
||||
// deprecated, use GetCount() instead
|
||||
wxDEPRECATED( size_t GetNoHistoryFiles() const );
|
||||
|
||||
protected:
|
||||
// Last n files
|
||||
wxChar** m_fileHistory;
|
||||
// Number of files saved
|
||||
size_t m_fileHistoryN;
|
||||
// Menus to maintain (may need several for an MDI app)
|
||||
wxList m_fileMenus;
|
||||
// Max files to maintain
|
||||
size_t m_fileMaxFiles;
|
||||
|
||||
private:
|
||||
// The ID of the first history menu item (Doesn't have to be wxID_FILE1)
|
||||
wxWindowID m_idBase;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxFileHistory)
|
||||
DECLARE_NO_COPY_CLASS(wxFileHistory)
|
||||
};
|
||||
|
||||
inline size_t wxFileHistory::GetNoHistoryFiles() const
|
||||
{
|
||||
return m_fileHistoryN;
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
// For compatibility with existing file formats:
|
||||
// converts from/to a stream to/from a temporary file.
|
||||
bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream);
|
||||
bool WXDLLEXPORT wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename);
|
||||
#else
|
||||
// For compatibility with existing file formats:
|
||||
// converts from/to a stream to/from a temporary file.
|
||||
bool WXDLLEXPORT wxTransferFileToStream(const wxString& filename, wxOutputStream& stream);
|
||||
bool WXDLLEXPORT wxTransferStreamToFile(wxInputStream& stream, const wxString& filename);
|
||||
#endif // wxUSE_STD_IOSTREAM
|
||||
|
||||
#endif // wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
|
||||
#endif // _WX_DOCH__
|
||||
49
include/wx/dragimag.h
Normal file
49
include/wx/dragimag.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef _WX_DRAGIMAG_H_BASE_
|
||||
#define _WX_DRAGIMAG_H_BASE_
|
||||
|
||||
#if wxUSE_DRAGIMAGE
|
||||
|
||||
class WXDLLEXPORT wxRect;
|
||||
class WXDLLEXPORT wxMemoryDC;
|
||||
class WXDLLEXPORT wxDC;
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#if defined(__WIN16__) || defined(__WXUNIVERSAL__)
|
||||
#include "wx/generic/dragimgg.h"
|
||||
#define wxDragImage wxGenericDragImage
|
||||
#define sm_classwxDragImage sm_classwxGenericDragImage
|
||||
|
||||
#else
|
||||
#include "wx/msw/dragimag.h"
|
||||
#endif
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/generic/dragimgg.h"
|
||||
#define wxDragImage wxGenericDragImage
|
||||
#define sm_classwxDragImage sm_classwxGenericDragImage
|
||||
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/generic/dragimgg.h"
|
||||
#define wxDragImage wxGenericDragImage
|
||||
#define sm_classwxDragImage sm_classwxGenericDragImage
|
||||
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/generic/dragimgg.h"
|
||||
#define wxDragImage wxGenericDragImage
|
||||
#define sm_classwxDragImage sm_classwxGenericDragImage
|
||||
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/generic/dragimgg.h"
|
||||
#define wxDragImage wxGenericDragImage
|
||||
#define sm_classwxDragImage sm_classwxGenericDragImage
|
||||
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/generic/dragimgg.h"
|
||||
#define wxDragImage wxGenericDragImage
|
||||
#define sm_classwxDragImage sm_classwxGenericDragImage
|
||||
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_DRAGIMAGE
|
||||
|
||||
#endif
|
||||
// _WX_DRAGIMAG_H_BASE_
|
||||
628
include/wx/dynarray.h
Normal file
628
include/wx/dynarray.h
Normal file
@@ -0,0 +1,628 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dynarray.h
|
||||
// Purpose: auto-resizable (i.e. dynamic) array support
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 12.09.97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _DYNARRAY_H
|
||||
#define _DYNARRAY_H
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dynarray.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
/*
|
||||
This header defines the dynamic arrays and object arrays (i.e. arrays which
|
||||
own their elements). Dynamic means that the arrays grow automatically as
|
||||
needed.
|
||||
|
||||
These macros are ugly (especially if you look in the sources ;-), but they
|
||||
allow us to define "template" classes without actually using templates and so
|
||||
this works with all compilers (and may be also much faster to compile even
|
||||
with a compiler which does support templates). The arrays defined with these
|
||||
macros are type-safe.
|
||||
|
||||
Range checking is performed in debug build for both arrays and objarrays but
|
||||
not in release build - so using an invalid index will just lead to a crash
|
||||
then.
|
||||
|
||||
Note about memory usage: arrays never shrink automatically (although you may
|
||||
use Shrink() function explicitly), they only grow, so loading 10 millions in
|
||||
an array only to delete them 2 lines below might be a bad idea if the array
|
||||
object is not going to be destroyed soon. However, as it does free memory
|
||||
when destroyed, it is ok if the array is a local variable.
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
The initial size by which an array grows when an element is added default
|
||||
value avoids allocate one or two bytes when the array is created which is
|
||||
rather inefficient
|
||||
*/
|
||||
#define WX_ARRAY_DEFAULT_INITIAL_SIZE (16)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Callback compare function for quick sort.
|
||||
|
||||
It must return negative value, 0 or positive value if the first item is
|
||||
less than, equal to or greater than the second one.
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
typedef int (wxCMPFUNC_CONV *CMPFUNC)(const void* pItem1, const void* pItem2);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Base class managing data having size of type 'long' (not used directly)
|
||||
//
|
||||
// NB: for efficiency this often used class has no virtual functions (hence no
|
||||
// virtual table), even dtor is *not* virtual. If used as expected it
|
||||
// won't create any problems because ARRAYs from DEFINE_ARRAY have no dtor
|
||||
// at all, so it's not too important if it's not called (this happens when
|
||||
// you cast "SomeArray *" as "BaseArray *" and then delete it)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define _WX_DECLARE_BASEARRAY(T, name, classexp) \
|
||||
classexp name \
|
||||
{ \
|
||||
public: \
|
||||
name(); \
|
||||
name(const name& array); \
|
||||
name& operator=(const name& src); \
|
||||
~name(); \
|
||||
\
|
||||
void Empty() { m_nCount = 0; } \
|
||||
void Clear(); \
|
||||
void Alloc(size_t uiSize); \
|
||||
void Shrink(); \
|
||||
\
|
||||
size_t GetCount() const { return m_nCount; } \
|
||||
void SetCount(size_t n, T defval = T(0)); \
|
||||
bool IsEmpty() const { return m_nCount == 0; } \
|
||||
size_t Count() const { return m_nCount; } \
|
||||
\
|
||||
typedef T base_type; \
|
||||
\
|
||||
protected: \
|
||||
T& Item(size_t uiIndex) const \
|
||||
{ wxASSERT( uiIndex < m_nCount ); return m_pItems[uiIndex]; } \
|
||||
T& operator[](size_t uiIndex) const { return Item(uiIndex); } \
|
||||
\
|
||||
int Index(T lItem, bool bFromEnd = FALSE) const; \
|
||||
int Index(T lItem, CMPFUNC fnCompare) const; \
|
||||
size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const; \
|
||||
void Add(T lItem, size_t nInsert = 1); \
|
||||
void Add(T lItem, CMPFUNC fnCompare); \
|
||||
void Insert(T lItem, size_t uiIndex, size_t nInsert = 1); \
|
||||
void Remove(T lItem); \
|
||||
void RemoveAt(size_t uiIndex, size_t nRemove = 1); \
|
||||
\
|
||||
void Sort(CMPFUNC fnCompare); \
|
||||
\
|
||||
private: \
|
||||
void Grow(size_t nIncrement = 0); \
|
||||
bool Realloc(size_t nSize); \
|
||||
\
|
||||
size_t m_nSize, \
|
||||
m_nCount; \
|
||||
\
|
||||
T *m_pItems; \
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// The private helper macros containing the core of the array classes
|
||||
// ============================================================================
|
||||
|
||||
// Implementation notes:
|
||||
//
|
||||
// JACS: Salford C++ doesn't like 'var->operator=' syntax, as in:
|
||||
// { ((wxBaseArray *)this)->operator=((const wxBaseArray&)src);
|
||||
// so using a temporary variable instead.
|
||||
//
|
||||
// The classes need a (even trivial) ~name() to link under Mac X
|
||||
//
|
||||
// _WX_ERROR_REMOVE is needed to resolve the name conflict between the wxT()
|
||||
// macro and T typedef: we can't use wxT() inside WX_DEFINE_ARRAY!
|
||||
|
||||
#define _WX_ERROR_REMOVE wxT("removing inexisting element in wxArray::Remove")
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// _WX_DEFINE_TYPEARRAY: array for simple types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define _WX_DEFINE_TYPEARRAY(T, name, base, classexp) \
|
||||
wxCOMPILE_TIME_ASSERT2(sizeof(T) <= sizeof(base::base_type), \
|
||||
TypeTooBigToBeStoredIn##base, \
|
||||
name); \
|
||||
typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \
|
||||
classexp name : public base \
|
||||
{ \
|
||||
public: \
|
||||
name() { } \
|
||||
~name() { } \
|
||||
\
|
||||
name& operator=(const name& src) \
|
||||
{ base* temp = (base*) this; \
|
||||
(*temp) = ((const base&)src); \
|
||||
return *this; } \
|
||||
\
|
||||
T& operator[](size_t uiIndex) const \
|
||||
{ return (T&)(base::Item(uiIndex)); } \
|
||||
T& Item(size_t uiIndex) const \
|
||||
{ return (T&)(base::Item(uiIndex)); } \
|
||||
T& Last() const \
|
||||
{ return (T&)(base::Item(Count() - 1)); } \
|
||||
\
|
||||
int Index(T Item, bool bFromEnd = FALSE) const \
|
||||
{ return base::Index((base_type)Item, bFromEnd); } \
|
||||
\
|
||||
void Add(T Item, size_t nInsert = 1) \
|
||||
{ base::Add((base_type)Item, nInsert); } \
|
||||
void Insert(T Item, size_t uiIndex, size_t nInsert = 1) \
|
||||
{ base::Insert((base_type)Item, uiIndex, nInsert) ; } \
|
||||
\
|
||||
void RemoveAt(size_t uiIndex, size_t nRemove = 1) \
|
||||
{ base::RemoveAt(uiIndex, nRemove); } \
|
||||
void Remove(T Item) \
|
||||
{ int iIndex = Index(Item); \
|
||||
wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
|
||||
_WX_ERROR_REMOVE); \
|
||||
base::RemoveAt((size_t)iIndex); } \
|
||||
\
|
||||
void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC)fCmp); } \
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// _WX_DEFINE_SORTED_TYPEARRAY: sorted array for simple data types
|
||||
// cannot handle types with size greater than pointer because of sorting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define _WX_DEFINE_SORTED_TYPEARRAY(T, name, base, defcomp, classexp) \
|
||||
wxCOMPILE_TIME_ASSERT2(sizeof(T) <= sizeof(void *), \
|
||||
TypeTooBigToBeStoredInSorted##base, \
|
||||
name); \
|
||||
typedef int (CMPFUNC_CONV *SCMPFUNC##T)(T pItem1, T pItem2); \
|
||||
classexp name : public base \
|
||||
{ \
|
||||
public: \
|
||||
name(SCMPFUNC##T fn defcomp) { m_fnCompare = fn; } \
|
||||
\
|
||||
name& operator=(const name& src) \
|
||||
{ base* temp = (base*) this; \
|
||||
(*temp) = ((const base&)src); \
|
||||
m_fnCompare = src.m_fnCompare; \
|
||||
return *this; } \
|
||||
\
|
||||
T& operator[](size_t uiIndex) const \
|
||||
{ return (T&)(base::Item(uiIndex)); } \
|
||||
T& Item(size_t uiIndex) const \
|
||||
{ return (T&)(base::Item(uiIndex)); } \
|
||||
T& Last() const \
|
||||
{ return (T&)(base::Item(Count() - 1)); } \
|
||||
\
|
||||
int Index(T Item) const \
|
||||
{ return base::Index(Item, (CMPFUNC)m_fnCompare); } \
|
||||
\
|
||||
size_t IndexForInsert(T Item) const \
|
||||
{ return base::IndexForInsert(Item, (CMPFUNC)m_fnCompare); } \
|
||||
\
|
||||
void AddAt(T item, size_t index) \
|
||||
{ base::Insert(item, index); } \
|
||||
\
|
||||
void Add(T Item) \
|
||||
{ base::Add(Item, (CMPFUNC)m_fnCompare); } \
|
||||
\
|
||||
void RemoveAt(size_t uiIndex, size_t nRemove = 1) \
|
||||
{ base::RemoveAt(uiIndex, nRemove); } \
|
||||
void Remove(T Item) \
|
||||
{ int iIndex = Index(Item); \
|
||||
wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
|
||||
_WX_ERROR_REMOVE ); \
|
||||
base::RemoveAt((size_t)iIndex); } \
|
||||
\
|
||||
private: \
|
||||
SCMPFUNC##T m_fnCompare; \
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// _WX_DECLARE_OBJARRAY: an array for pointers to type T with owning semantics
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define _WX_DECLARE_OBJARRAY(T, name, base, classexp) \
|
||||
typedef int (CMPFUNC_CONV *CMPFUNC##T)(T **pItem1, T **pItem2); \
|
||||
classexp name : public base \
|
||||
{ \
|
||||
typedef int (CMPFUNC_CONV *CMPFUNC##base)(void **pItem1, void **pItem2); \
|
||||
public: \
|
||||
name() { } \
|
||||
name(const name& src); \
|
||||
name& operator=(const name& src); \
|
||||
\
|
||||
~name(); \
|
||||
\
|
||||
T& operator[](size_t uiIndex) const \
|
||||
{ return *(T*)base::Item(uiIndex); } \
|
||||
T& Item(size_t uiIndex) const \
|
||||
{ return *(T*)base::Item(uiIndex); } \
|
||||
T& Last() const \
|
||||
{ return *(T*)(base::Item(Count() - 1)); } \
|
||||
\
|
||||
int Index(const T& Item, bool bFromEnd = FALSE) const; \
|
||||
\
|
||||
void Add(const T& Item, size_t nInsert = 1); \
|
||||
void Add(const T* pItem) \
|
||||
{ base::Add((T*)pItem); } \
|
||||
\
|
||||
void Insert(const T& Item, size_t uiIndex, size_t nInsert = 1); \
|
||||
void Insert(const T* pItem, size_t uiIndex) \
|
||||
{ base::Insert((T*)pItem, uiIndex); } \
|
||||
\
|
||||
void Empty() { DoEmpty(); base::Empty(); } \
|
||||
void Clear() { DoEmpty(); base::Clear(); } \
|
||||
\
|
||||
T* Detach(size_t uiIndex) \
|
||||
{ T* p = (T*)base::Item(uiIndex); \
|
||||
base::RemoveAt(uiIndex); return p; } \
|
||||
void RemoveAt(size_t uiIndex, size_t nRemove = 1); \
|
||||
\
|
||||
void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC##base)fCmp); } \
|
||||
\
|
||||
private: \
|
||||
void DoEmpty(); \
|
||||
void DoCopy(const name& src); \
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// The public macros for declaration and definition of the dynamic arrays
|
||||
// ============================================================================
|
||||
|
||||
// Please note that for each macro WX_FOO_ARRAY we also have
|
||||
// WX_FOO_EXPORTED_ARRAY and WX_FOO_USER_EXPORTED_ARRAY which are exactly the
|
||||
// same except that they use an additional __declspec(dllexport) or equivalent
|
||||
// under Windows if needed.
|
||||
//
|
||||
// The first (just EXPORTED) macros do it if wxWindows was compiled as a DLL
|
||||
// and so must be used used inside the library. The second kind (USER_EXPORTED)
|
||||
// allow the user code to do it when it wants. This is needed if you have a dll
|
||||
// that wants to export a wxArray daubed with your own import/export goo.
|
||||
//
|
||||
// Finally, you can define the macro below as something special to modify the
|
||||
// arrays defined by a simple WX_FOO_ARRAY as well. By default is is empty.
|
||||
#define wxARRAY_DEFAULT_EXPORT
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WX_DECLARE_BASEARRAY(T, name) declare an array class named "name" containing
|
||||
// the elements of type T
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DECLARE_BASEARRAY(T, name) \
|
||||
WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, wxARRAY_DEFAULT_EXPORT)
|
||||
|
||||
#define WX_DECLARE_EXPORTED_BASEARRAY(T, name) \
|
||||
WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, WXDLLEXPORT)
|
||||
|
||||
#define WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, expmode) \
|
||||
typedef T _wxArray##name; \
|
||||
_WX_DECLARE_BASEARRAY(_wxArray##name, name, class expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WX_DEFINE_TYPEARRAY(T, name, base) define an array class named "name" deriving
|
||||
// from class "base" containing the elements of type T
|
||||
//
|
||||
// Note that the class defined has only inline function and doesn't take any
|
||||
// space at all so there is no size penalty for defining multiple array classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DEFINE_TYPEARRAY(T, name, base) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, base, wxARRAY_DEFAULT_EXPORT)
|
||||
|
||||
#define WX_DEFINE_EXPORTED_TYPEARRAY(T, name, base) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, base, WXDLLEXPORT)
|
||||
|
||||
#define WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, base, expmode) \
|
||||
typedef T _wxArray##name; \
|
||||
_WX_DEFINE_TYPEARRAY(_wxArray##name, name, base, class expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WX_DEFINE_SORTED_TYPEARRAY: this is the same as the previous macro, but it
|
||||
// defines a sorted array.
|
||||
//
|
||||
// Differences:
|
||||
// 1) it must be given a COMPARE function in ctor which takes 2 items of type
|
||||
// T* and should return -1, 0 or +1 if the first one is less/greater
|
||||
// than/equal to the second one.
|
||||
// 2) the Add() method inserts the item in such was that the array is always
|
||||
// sorted (it uses the COMPARE function)
|
||||
// 3) it has no Sort() method because it's always sorted
|
||||
// 4) Index() method is much faster (the sorted arrays use binary search
|
||||
// instead of linear one), but Add() is slower.
|
||||
// 5) there is no Insert() method because you can't insert an item into the
|
||||
// given position in a sorted array but there is IndexForInsert()/AddAt()
|
||||
// pair which may be used to optimize a common operation of "insert only if
|
||||
// not found"
|
||||
//
|
||||
// Note that you have to specify the comparison function when creating the
|
||||
// objects of this array type. If, as in 99% of cases, the comparison function
|
||||
// is the same for all objects of a class, WX_DEFINE_SORTED_TYPEARRAY_CMP below
|
||||
// is more convenient.
|
||||
//
|
||||
// Summary: use this class when the speed of Index() function is important, use
|
||||
// the normal arrays otherwise.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxARRAY_EMPTY_CMP
|
||||
|
||||
#define WX_DEFINE_SORTED_TYPEARRAY(T, name, base) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, \
|
||||
wxARRAY_DEFAULT_EXPORT)
|
||||
|
||||
#define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, base) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, WXDLLEXPORT)
|
||||
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, expmode) \
|
||||
typedef T _wxArray##name; \
|
||||
_WX_DEFINE_SORTED_TYPEARRAY(_wxArray##name, name, base, \
|
||||
wxARRAY_EMPTY_CMP, class expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WX_DEFINE_SORTED_TYPEARRAY_CMP: exactly the same as above but the comparison
|
||||
// function is provided by this macro and the objects of this class have a
|
||||
// default constructor which just uses it.
|
||||
//
|
||||
// The arguments are: the element type, the comparison function and the array
|
||||
// name
|
||||
//
|
||||
// NB: this is, of course, how WX_DEFINE_SORTED_TYPEARRAY() should have worked
|
||||
// from the very beginning - unfortunately I didn't think about this earlier
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \
|
||||
wxARRAY_DEFAULT_EXPORT)
|
||||
|
||||
#define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \
|
||||
WXDLLEXPORT)
|
||||
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \
|
||||
expmode) \
|
||||
typedef T _wxArray##name; \
|
||||
_WX_DEFINE_SORTED_TYPEARRAY(_wxArray##name, name, base, = cmpfunc, \
|
||||
class expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WX_DECLARE_OBJARRAY(T, name): this macro generates a new array class
|
||||
// named "name" which owns the objects of type T it contains, i.e. it will
|
||||
// delete them when it is destroyed.
|
||||
//
|
||||
// An element is of type T*, but arguments of type T& are taken (see below!)
|
||||
// and T& is returned.
|
||||
//
|
||||
// Don't use this for simple types such as "int" or "long"!
|
||||
//
|
||||
// Note on Add/Insert functions:
|
||||
// 1) function(T*) gives the object to the array, i.e. it will delete the
|
||||
// object when it's removed or in the array's dtor
|
||||
// 2) function(T&) will create a copy of the object and work with it
|
||||
//
|
||||
// Also:
|
||||
// 1) Remove() will delete the object after removing it from the array
|
||||
// 2) Detach() just removes the object from the array (returning pointer to it)
|
||||
//
|
||||
// NB1: Base type T should have an accessible copy ctor if Add(T&) is used
|
||||
// NB2: Never ever cast a array to it's base type: as dtor is not virtual
|
||||
// and so you risk having at least the memory leaks and probably worse
|
||||
//
|
||||
// Some functions of this class are not inline, so it takes some space to
|
||||
// define new class from this template even if you don't use it - which is not
|
||||
// the case for the simple (non-object) array classes
|
||||
//
|
||||
// To use an objarray class you must
|
||||
// #include "dynarray.h"
|
||||
// WX_DECLARE_OBJARRAY(element_type, list_class_name)
|
||||
// #include "arrimpl.cpp"
|
||||
// WX_DEFINE_OBJARRAY(list_class_name) // name must be the same as above!
|
||||
//
|
||||
// This is necessary because at the moment of DEFINE_OBJARRAY class parsing the
|
||||
// element_type must be fully defined (i.e. forward declaration is not
|
||||
// enough), while WX_DECLARE_OBJARRAY may be done anywhere. The separation of
|
||||
// two allows to break cicrcular dependencies with classes which have member
|
||||
// variables of objarray type.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DECLARE_OBJARRAY(T, name) \
|
||||
WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, wxARRAY_DEFAULT_EXPORT)
|
||||
|
||||
#define WX_DECLARE_EXPORTED_OBJARRAY(T, name) \
|
||||
WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, WXDLLEXPORT)
|
||||
|
||||
#define WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, expmode) \
|
||||
typedef T _wxObjArray##name; \
|
||||
_WX_DECLARE_OBJARRAY(_wxObjArray##name, name, wxArrayPtrVoid, class expmode)
|
||||
|
||||
// WX_DEFINE_OBJARRAY is going to be redefined when arrimpl.cpp is included,
|
||||
// try to provoke a human-understandable error if it used incorrectly.
|
||||
//
|
||||
// there is no real need for 3 different macros in the DEFINE case but do it
|
||||
// anyhow for consistency
|
||||
#define WX_DEFINE_OBJARRAY(name) DidYouIncludeArrimplCpp
|
||||
#define WX_DEFINE_EXPORTED_OBJARRAY(name) WX_DEFINE_OBJARRAY(name)
|
||||
#define WX_DEFINE_USER_EXPORTED_OBJARRAY(name) WX_DEFINE_OBJARRAY(name)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Some commonly used predefined base arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_EXPORTED_BASEARRAY(const void *, wxBaseArrayPtrVoid);
|
||||
WX_DECLARE_EXPORTED_BASEARRAY(short, wxBaseArrayShort);
|
||||
WX_DECLARE_EXPORTED_BASEARRAY(int, wxBaseArrayInt);
|
||||
WX_DECLARE_EXPORTED_BASEARRAY(long, wxBaseArrayLong);
|
||||
WX_DECLARE_EXPORTED_BASEARRAY(double, wxBaseArrayDouble);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Convenience macros to define arrays from base arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DEFINE_ARRAY(T, name) \
|
||||
WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
|
||||
#define WX_DEFINE_EXPORTED_ARRAY(T, name) \
|
||||
WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
|
||||
#define WX_DEFINE_USER_EXPORTED_ARRAY(T, name, expmode) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid, expmode)
|
||||
|
||||
#define WX_DEFINE_ARRAY_SHORT(T, name) \
|
||||
WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayShort)
|
||||
#define WX_DEFINE_EXPORTED_ARRAY_SHORT(T, name) \
|
||||
WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort)
|
||||
#define WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort, expmode)
|
||||
|
||||
#define WX_DEFINE_ARRAY_INT(T, name) \
|
||||
WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayInt)
|
||||
#define WX_DEFINE_EXPORTED_ARRAY_INT(T, name) \
|
||||
WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt)
|
||||
#define WX_DEFINE_USER_EXPORTED_ARRAY_INT(T, name, expmode) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt, expmode)
|
||||
|
||||
#define WX_DEFINE_ARRAY_LONG(T, name) \
|
||||
WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayLong)
|
||||
#define WX_DEFINE_EXPORTED_ARRAY_LONG(T, name) \
|
||||
WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong)
|
||||
#define WX_DEFINE_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong, expmode)
|
||||
|
||||
#define WX_DEFINE_ARRAY_DOUBLE(T, name) \
|
||||
WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayDouble)
|
||||
#define WX_DEFINE_EXPORTED_ARRAY_DOUBLE(T, name) \
|
||||
WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayDouble)
|
||||
#define WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(T, name, expmode) \
|
||||
WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayDouble, expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Convenience macros to define sorted arrays from base arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY(T, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid, expmode)
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_SHORT(T, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayShort)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_SHORT(T, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort, expmode)
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_INT(T, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayInt)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_INT(T, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT(T, name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt, expmode)
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_LONG(T, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayLong)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_LONG(T, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong, expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Convenience macros to define sorted arrays from base arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_CMP(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP(T, cmpfunc, \
|
||||
name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
|
||||
wxBaseArrayPtrVoid, expmode)
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, \
|
||||
name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
|
||||
wxBaseArrayShort, expmode)
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_CMP_INT(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, \
|
||||
name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
|
||||
wxBaseArrayInt, expmode)
|
||||
|
||||
#define WX_DEFINE_SORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong)
|
||||
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \
|
||||
WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong)
|
||||
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, \
|
||||
name, expmode) \
|
||||
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
|
||||
wxBaseArrayLong, expmode)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Some commonly used predefined arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WX_DEFINE_EXPORTED_ARRAY_SHORT (short, wxArrayShort);
|
||||
WX_DEFINE_EXPORTED_ARRAY_INT (int, wxArrayInt);
|
||||
WX_DEFINE_EXPORTED_ARRAY_LONG (long, wxArrayLong);
|
||||
WX_DEFINE_EXPORTED_ARRAY (void *, wxArrayPtrVoid);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// convenience macros
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// append all element of one array to another one
|
||||
#define WX_APPEND_ARRAY(array, other) \
|
||||
{ \
|
||||
size_t count = (other).Count(); \
|
||||
for ( size_t n = 0; n < count; n++ ) \
|
||||
{ \
|
||||
(array).Add((other)[n]); \
|
||||
} \
|
||||
}
|
||||
|
||||
// delete all array elements
|
||||
//
|
||||
// NB: the class declaration of the array elements must be visible from the
|
||||
// place where you use this macro, otherwise the proper destructor may not
|
||||
// be called (a decent compiler should give a warning about it, but don't
|
||||
// count on it)!
|
||||
#define WX_CLEAR_ARRAY(array) \
|
||||
{ \
|
||||
size_t count = (array).Count(); \
|
||||
for ( size_t n = 0; n < count; n++ ) \
|
||||
{ \
|
||||
delete (array)[n]; \
|
||||
} \
|
||||
\
|
||||
(array).Empty(); \
|
||||
}
|
||||
|
||||
#endif // _DYNARRAY_H
|
||||
|
||||
246
include/wx/dynlib.h
Normal file
246
include/wx/dynlib.h
Normal file
@@ -0,0 +1,246 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/dynlib.h
|
||||
// Purpose: Dynamic library loading classes
|
||||
// Author: Guilhem Lavaux, Vadim Zeitlin, Vaclav Slavik
|
||||
// Modified by:
|
||||
// Created: 20/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DYNLIB_H__
|
||||
#define _WX_DYNLIB_H__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
# pragma interface "dynlib.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#if wxUSE_DYNAMIC_LOADER
|
||||
|
||||
#include "wx/dynload.h" // Use the new (version of) wxDynamicLibrary instead
|
||||
|
||||
#elif wxUSE_DYNLIB_CLASS
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/hash.h"
|
||||
|
||||
// this is normally done by configure, but I leave it here for now...
|
||||
#if defined(__UNIX__) && !(defined(HAVE_DLOPEN) || defined(HAVE_SHL_LOAD))
|
||||
# if defined(__LINUX__) || defined(__SOLARIS__) || defined(__SUNOS__) || defined(__FREEBSD__)
|
||||
# define HAVE_DLOPEN
|
||||
# elif defined(__HPUX__)
|
||||
# define HAVE_SHL_LOAD
|
||||
# endif // Unix flavour
|
||||
#endif // !Unix or already have some HAVE_xxx defined
|
||||
|
||||
// Note: WXPM/EMX has to be tested first, since we want to use
|
||||
// native version, even if configure detected presence of DLOPEN.
|
||||
#if defined(__WXPM__) || defined(__EMX__)
|
||||
# define INCL_DOS
|
||||
# include <os2.h>
|
||||
typedef HMODULE wxDllType;
|
||||
#elif defined(HAVE_DLOPEN)
|
||||
# include <dlfcn.h>
|
||||
typedef void *wxDllType;
|
||||
#elif defined(HAVE_SHL_LOAD)
|
||||
# include <dl.h>
|
||||
typedef shl_t wxDllType;
|
||||
#elif defined(__WINDOWS__)
|
||||
# include <windows.h> // needed to get HMODULE
|
||||
typedef HMODULE wxDllType;
|
||||
#elif defined(__DARWIN__)
|
||||
typedef void *wxDllType;
|
||||
#elif defined(__WXMAC__)
|
||||
typedef void *wxDllType;
|
||||
#else
|
||||
# error "wxLibrary can't be compiled on this platform, sorry."
|
||||
#endif // OS
|
||||
|
||||
// LoadLibrary is defined in windows.h as LoadLibraryA, but wxDllLoader method
|
||||
// should be called LoadLibrary, not LoadLibraryA or LoadLibraryW!
|
||||
#if defined(__WIN32__) && defined(LoadLibrary)
|
||||
# include "wx/msw/winundef.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDllLoader: low level DLL functions, use wxDynamicLibrary in your code
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
wxDllLoader is a class providing an interface similar to unix's dlopen().
|
||||
It is used by wxDynamicLibrary wxLibrary and manages the actual loading of
|
||||
DLLs and the resolving of symbols in them. There are no instances of this
|
||||
class, it simply serves as a namespace for its static member functions.
|
||||
*/
|
||||
class WXDLLEXPORT wxDllLoader
|
||||
{
|
||||
public:
|
||||
/*
|
||||
This function loads the shared library libname into memory.
|
||||
|
||||
libname may be either the full path to the file or just the filename in
|
||||
which case the library is searched for in all standard locations
|
||||
(use GetDllExt() to construct the filename)
|
||||
|
||||
if success pointer is not NULL, it will be filled with TRUE if everything
|
||||
went ok and FALSE otherwise
|
||||
*/
|
||||
static wxDllType LoadLibrary(const wxString& libname, bool *success = 0);
|
||||
|
||||
/*
|
||||
This function unloads the shared library previously loaded with
|
||||
LoadLibrary
|
||||
*/
|
||||
static void UnloadLibrary(wxDllType dll);
|
||||
|
||||
/*
|
||||
This function returns a valid handle for the main program
|
||||
itself or NULL if back linking is not supported by the current platform
|
||||
(e.g. Win32).
|
||||
*/
|
||||
static wxDllType GetProgramHandle();
|
||||
|
||||
/*
|
||||
This function resolves a symbol in a loaded DLL, such as a
|
||||
variable or function name.
|
||||
|
||||
dllHandle Handle of the DLL, as returned by LoadDll().
|
||||
name Name of the symbol.
|
||||
|
||||
Returns the pointer to the symbol or NULL on error.
|
||||
*/
|
||||
static void *GetSymbol(wxDllType dllHandle,
|
||||
const wxString &name,
|
||||
bool *success = NULL);
|
||||
|
||||
// return the standard DLL extension (with leading dot) for this platform
|
||||
static const wxString &GetDllExt() { return ms_dllext; }
|
||||
|
||||
private:
|
||||
// forbid construction of objects
|
||||
wxDllLoader();
|
||||
static const wxString ms_dllext;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDynamicLibrary - friendly interface to wxDllLoader
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDynamicLibrary
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxDynamicLibrary() { m_library = 0; }
|
||||
wxDynamicLibrary(const wxString& name) { Load(name); }
|
||||
|
||||
// return TRUE if the library was loaded successfully
|
||||
bool IsLoaded() const { return m_library != 0; }
|
||||
operator bool() const { return IsLoaded(); }
|
||||
|
||||
// load the library with the given name (full or not), return TRUE on
|
||||
// success
|
||||
bool Load(const wxString& name)
|
||||
{
|
||||
m_library = wxDllLoader::LoadLibrary(name);
|
||||
|
||||
return IsLoaded();
|
||||
}
|
||||
|
||||
// unload the library, also done automatically in dtor
|
||||
void Unload()
|
||||
{
|
||||
if ( IsLoaded() )
|
||||
wxDllLoader::UnloadLibrary(m_library);
|
||||
}
|
||||
|
||||
// load a symbol from the library, return NULL if an error occured or
|
||||
// symbol wasn't found
|
||||
void *GetSymbol(const wxString& name) const
|
||||
{
|
||||
wxCHECK_MSG( IsLoaded(), NULL,
|
||||
_T("can't load symbol from unloaded library") );
|
||||
|
||||
return wxDllLoader::GetSymbol(m_library, name);
|
||||
}
|
||||
|
||||
// unload the library
|
||||
//
|
||||
// NB: dtor is not virtual, don't derive from this class
|
||||
~wxDynamicLibrary() { Unload(); }
|
||||
|
||||
private:
|
||||
// the handle to DLL or NULL
|
||||
wxDllType m_library;
|
||||
|
||||
// no copy ctor/assignment operators (or we'd try to unload the library
|
||||
// twice)
|
||||
DECLARE_NO_COPY_CLASS(wxDynamicLibrary)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxLibrary
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxLibrary : public wxObject
|
||||
{
|
||||
public:
|
||||
wxLibrary(wxDllType handle);
|
||||
virtual ~wxLibrary();
|
||||
|
||||
// Get a symbol from the dynamic library
|
||||
void *GetSymbol(const wxString& symbname);
|
||||
|
||||
// Create the object whose classname is "name"
|
||||
wxObject *CreateObject(const wxString& name);
|
||||
|
||||
protected:
|
||||
void PrepareClasses(wxClassInfo *first);
|
||||
|
||||
wxDllType m_handle;
|
||||
|
||||
public:
|
||||
wxHashTable classTable;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxLibraries
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxLibraries
|
||||
{
|
||||
public:
|
||||
wxLibraries();
|
||||
~wxLibraries();
|
||||
|
||||
// caller is responsible for deleting the returned pointer if !NULL
|
||||
wxLibrary *LoadLibrary(const wxString& basename);
|
||||
|
||||
wxObject *CreateObject(const wxString& name);
|
||||
|
||||
protected:
|
||||
wxList m_loaded;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Global variables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern WXDLLEXPORT_DATA(wxLibraries) wxTheLibraries;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Interesting defines
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define WXDLL_ENTRY_FUNCTION() \
|
||||
extern "C" WXEXPORT const wxClassInfo *wxGetClassFirst(); \
|
||||
const wxClassInfo *wxGetClassFirst() { \
|
||||
return wxClassInfo::GetFirst(); \
|
||||
}
|
||||
|
||||
#endif // wxUSE_DYNLIB_CLASS
|
||||
|
||||
#endif // _WX_DYNLIB_H__
|
||||
332
include/wx/dynload.h
Normal file
332
include/wx/dynload.h
Normal file
@@ -0,0 +1,332 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dynload.h
|
||||
// Purpose: Dynamic loading framework
|
||||
// Author: Ron Lee, David Falkinder, Vadim Zeitlin and a cast of 1000's
|
||||
// (derived in part from dynlib.cpp (c) 1998 Guilhem Lavaux)
|
||||
// Modified by:
|
||||
// Created: 03/12/01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Ron Lee <ron@debian.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DYNAMICLOADER_H__
|
||||
#define _WX_DYNAMICLOADER_H__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "dynload.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DYNAMIC_LOADER
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
// FIXME: can this go in private.h or something too??
|
||||
#if defined(__WXPM__) || defined(__EMX__)
|
||||
#define INCL_DOS
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/private.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxPluginLibrary;
|
||||
|
||||
WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxPluginLibrary *, wxDLManifest);
|
||||
typedef wxDLManifest wxDLImports;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// conditional compilation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Note: WXPM/EMX has to be tested first, since we want to use
|
||||
// native version, even if configure detected presence of DLOPEN.
|
||||
|
||||
#if defined(__WXPM__) || defined(__EMX__) || defined(__WINDOWS__)
|
||||
typedef HMODULE wxDllType;
|
||||
#elif defined(HAVE_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
typedef void *wxDllType;
|
||||
#elif defined(HAVE_SHL_LOAD)
|
||||
#include <dl.h>
|
||||
typedef shl_t wxDllType;
|
||||
#elif defined(__DARWIN__)
|
||||
typedef void *wxDllType;
|
||||
#elif defined(__WXMAC__)
|
||||
typedef CFragConnectionID wxDllType;
|
||||
#else
|
||||
#error "Dynamic Loading classes can't be compiled on this platform, sorry."
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDynamicLibrary
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
//FIXME: This class isn't really common at all, it should be moved
|
||||
// into platform dependent files.
|
||||
|
||||
// NOTE: this class is (deliberately) not virtual, do not attempt
|
||||
// to use it polymorphically.
|
||||
|
||||
enum wxDLFlags
|
||||
{
|
||||
wxDL_LAZY = 0x00000001, // resolve undefined symbols at first use
|
||||
wxDL_NOW = 0x00000002, // resolve undefined symbols on load
|
||||
wxDL_GLOBAL = 0x00000004, // export extern symbols to subsequently
|
||||
// loaded libs.
|
||||
wxDL_VERBATIM = 0x00000008, // Attempt to load the supplied library
|
||||
// name without appending the usual dll
|
||||
// filename extension.
|
||||
|
||||
wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded
|
||||
|
||||
// FIXME: why? (VZ)
|
||||
#ifdef __osf__
|
||||
wxDL_DEFAULT = wxDL_LAZY
|
||||
#else
|
||||
wxDL_DEFAULT = wxDL_LAZY | wxDL_GLOBAL
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class WXDLLEXPORT wxDynamicLibrary
|
||||
{
|
||||
public:
|
||||
|
||||
// return a valid handle for the main program itself or NULL if
|
||||
// back linking is not supported by the current platform (e.g. Win32)
|
||||
|
||||
static wxDllType GetProgramHandle();
|
||||
|
||||
// return the platform standard DLL extension (with leading dot)
|
||||
|
||||
static const wxChar *GetDllExt() { return ms_dllext; }
|
||||
|
||||
wxDynamicLibrary() : m_handle(0) {}
|
||||
wxDynamicLibrary(wxString libname, int flags = wxDL_DEFAULT)
|
||||
: m_handle(0)
|
||||
{
|
||||
Load(libname, flags);
|
||||
}
|
||||
~wxDynamicLibrary() { Unload(); }
|
||||
|
||||
// return TRUE if the library was loaded successfully
|
||||
|
||||
bool IsLoaded() const { return m_handle != 0; }
|
||||
|
||||
// load the library with the given name
|
||||
// (full or not), return TRUE on success
|
||||
|
||||
bool Load(wxString libname, int flags = wxDL_DEFAULT);
|
||||
|
||||
// detach the library object from its handle, i.e. prevent the object
|
||||
// from unloading the library in its dtor -- the caller is now
|
||||
// responsible for doing this
|
||||
wxDllType Detach() { wxDllType h = m_handle; m_handle = 0; return h; }
|
||||
|
||||
// unload the library, also done automatically in dtor
|
||||
|
||||
void Unload();
|
||||
|
||||
// Return the raw handle from dlopen and friends.
|
||||
|
||||
wxDllType GetLibHandle() const { return m_handle; }
|
||||
|
||||
// resolve a symbol in a loaded DLL, such as a variable or function
|
||||
// name. 'name' is the (possibly mangled) name of the symbol.
|
||||
// (use extern "C" to export unmangled names)
|
||||
//
|
||||
// Since it is perfectly valid for the returned symbol to actually be
|
||||
// NULL, that is not always indication of an error. Pass and test the
|
||||
// parameter 'success' for a true indication of success or failure to
|
||||
// load the symbol.
|
||||
//
|
||||
// Returns a pointer to the symbol on success, or NULL if an error
|
||||
// occurred or the symbol wasn't found.
|
||||
|
||||
void *GetSymbol(const wxString& name, bool *success = 0) const;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
operator bool() const { return IsLoaded(); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Platform specific shared lib suffix.
|
||||
|
||||
static const wxChar *ms_dllext;
|
||||
|
||||
// the handle to DLL or NULL
|
||||
|
||||
wxDllType m_handle;
|
||||
|
||||
// no copy ctor/assignment operators
|
||||
// or we'd try to unload the library twice
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDynamicLibrary)
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxPluginLibrary
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// NOTE: Do not attempt to use a base class pointer to this class.
|
||||
// wxDL is not virtual and we deliberately hide some of it's
|
||||
// methods here.
|
||||
//
|
||||
// Unless you know exacty why you need to, you probably shouldn't
|
||||
// instantiate this class directly anyway, use wxPluginManager
|
||||
// instead.
|
||||
|
||||
class WXDLLEXPORT wxPluginLibrary : public wxDynamicLibrary
|
||||
{
|
||||
public:
|
||||
|
||||
static wxDLImports* ms_classes; // Static hash of all imported classes.
|
||||
|
||||
wxPluginLibrary( const wxString &libname, int flags = wxDL_DEFAULT );
|
||||
~wxPluginLibrary();
|
||||
|
||||
wxPluginLibrary *RefLib();
|
||||
bool UnrefLib();
|
||||
|
||||
// These two are called by the PluginSentinel on (PLUGGABLE) object
|
||||
// creation/destruction. There is usually no reason for the user to
|
||||
// call them directly. We have to separate this from the link count,
|
||||
// since the two are not interchangeable.
|
||||
|
||||
// FIXME: for even better debugging PluginSentinel should register
|
||||
// the name of the class created too, then we can state
|
||||
// exactly which object was not destroyed which may be
|
||||
// difficult to find otherwise. Also this code should
|
||||
// probably only be active in DEBUG mode, but let's just
|
||||
// get it right first.
|
||||
|
||||
void RefObj() { ++m_objcount; }
|
||||
void UnrefObj()
|
||||
{
|
||||
wxASSERT_MSG( m_objcount > 0, _T("Too many objects deleted??") );
|
||||
--m_objcount;
|
||||
}
|
||||
|
||||
// Override/hide some base class methods
|
||||
|
||||
bool IsLoaded() const { return m_linkcount > 0; }
|
||||
void Unload() { UnrefLib(); }
|
||||
|
||||
private:
|
||||
|
||||
wxClassInfo *m_before; // sm_first before loading this lib
|
||||
wxClassInfo *m_after; // ..and after.
|
||||
|
||||
size_t m_linkcount; // Ref count of library link calls
|
||||
size_t m_objcount; // ..and (pluggable) object instantiations.
|
||||
wxModuleList m_wxmodules; // any wxModules that we initialised.
|
||||
|
||||
void UpdateClassInfo(); // Update the wxClassInfo table
|
||||
void RestoreClassInfo(); // Restore the original wxClassInfo state.
|
||||
void RegisterModules(); // Init any wxModules in the lib.
|
||||
void UnregisterModules(); // Cleanup any wxModules we installed.
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxPluginLibrary)
|
||||
};
|
||||
|
||||
|
||||
class WXDLLEXPORT wxPluginManager
|
||||
{
|
||||
public:
|
||||
|
||||
// Static accessors.
|
||||
|
||||
static wxPluginLibrary *LoadLibrary( const wxString &libname,
|
||||
int flags = wxDL_DEFAULT );
|
||||
static bool UnloadLibrary(const wxString &libname);
|
||||
|
||||
// This is used by wxDllLoader. It's wrapped in the compatibility
|
||||
// macro because it's of arguable use outside of that.
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
static wxPluginLibrary *GetObjectFromHandle(wxDllType handle);
|
||||
#endif
|
||||
|
||||
// Instance methods.
|
||||
|
||||
wxPluginManager() : m_entry(NULL) {};
|
||||
wxPluginManager(const wxString &libname, int flags = wxDL_DEFAULT)
|
||||
{
|
||||
Load(libname, flags);
|
||||
}
|
||||
~wxPluginManager() { Unload(); }
|
||||
|
||||
bool Load(const wxString &libname, int flags = wxDL_DEFAULT);
|
||||
void Unload();
|
||||
|
||||
bool IsLoaded() const { return m_entry && m_entry->IsLoaded(); }
|
||||
void *GetSymbol(const wxString &symbol, bool *success = 0)
|
||||
{
|
||||
return m_entry->GetSymbol( symbol, success );
|
||||
}
|
||||
|
||||
static void CreateManifest() { ms_manifest = new wxDLManifest(wxKEY_STRING); }
|
||||
static void ClearManifest() { delete ms_manifest; ms_manifest = NULL; }
|
||||
|
||||
private:
|
||||
// return the pointer to the entry for the library with given name in
|
||||
// ms_manifest or NULL if none
|
||||
static wxPluginLibrary *FindByName(const wxString& name)
|
||||
{
|
||||
const wxDLManifest::iterator i = ms_manifest->find(name);
|
||||
|
||||
return i == ms_manifest->end() ? NULL : i->second;
|
||||
}
|
||||
|
||||
static wxDLManifest* ms_manifest; // Static hash of loaded libs.
|
||||
wxPluginLibrary* m_entry; // Cache our entry in the manifest.
|
||||
|
||||
// We could allow this class to be copied if we really
|
||||
// wanted to, but not without modification.
|
||||
DECLARE_NO_COPY_CLASS(wxPluginManager)
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDllLoader
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Cross platform wrapper for dlopen and friends.
|
||||
// There are no instances of this class, it simply
|
||||
// serves as a namespace for its static member functions.
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
class WXDLLEXPORT wxDllLoader
|
||||
{
|
||||
public:
|
||||
|
||||
static wxDllType LoadLibrary(const wxString& name, bool *success = NULL);
|
||||
static void UnloadLibrary(wxDllType dll);
|
||||
|
||||
static wxDllType GetProgramHandle() { return wxDynamicLibrary::GetProgramHandle(); }
|
||||
|
||||
static void *GetSymbol(wxDllType dllHandle, const wxString &name, bool *success = 0);
|
||||
|
||||
static wxString GetDllExt() { return wxDynamicLibrary::GetDllExt(); }
|
||||
|
||||
private:
|
||||
|
||||
wxDllLoader(); // forbid construction of objects
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_DYNAMIC_LOADER
|
||||
#endif // _WX_DYNAMICLOADER_H__
|
||||
|
||||
75
include/wx/effects.h
Normal file
75
include/wx/effects.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: effects.h
|
||||
// Purpose: wxEffects class
|
||||
// Draws 3D effects.
|
||||
// Author: Julian Smart et al
|
||||
// Modified by:
|
||||
// Created: 25/4/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "effects.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_EFFECTS_H_
|
||||
#define _WX_EFFECTS_H_
|
||||
|
||||
/*
|
||||
* wxEffects: various 3D effects
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxEffects: public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxEffects)
|
||||
|
||||
public:
|
||||
// Assume system colours
|
||||
wxEffects() ;
|
||||
// Going from lightest to darkest
|
||||
wxEffects(const wxColour& highlightColour, const wxColour& lightShadow,
|
||||
const wxColour& faceColour, const wxColour& mediumShadow,
|
||||
const wxColour& darkShadow) ;
|
||||
|
||||
// Accessors
|
||||
wxColour GetHighlightColour() const { return m_highlightColour; }
|
||||
wxColour GetLightShadow() const { return m_lightShadow; }
|
||||
wxColour GetFaceColour() const { return m_faceColour; }
|
||||
wxColour GetMediumShadow() const { return m_mediumShadow; }
|
||||
wxColour GetDarkShadow() const { return m_darkShadow; }
|
||||
|
||||
void SetHighlightColour(const wxColour& c) { m_highlightColour = c; }
|
||||
void SetLightShadow(const wxColour& c) { m_lightShadow = c; }
|
||||
void SetFaceColour(const wxColour& c) { m_faceColour = c; }
|
||||
void SetMediumShadow(const wxColour& c) { m_mediumShadow = c; }
|
||||
void SetDarkShadow(const wxColour& c) { m_darkShadow = c; }
|
||||
|
||||
void Set(const wxColour& highlightColour, const wxColour& lightShadow,
|
||||
const wxColour& faceColour, const wxColour& mediumShadow,
|
||||
const wxColour& darkShadow)
|
||||
{
|
||||
SetHighlightColour(highlightColour);
|
||||
SetLightShadow(lightShadow);
|
||||
SetFaceColour(faceColour);
|
||||
SetMediumShadow(mediumShadow);
|
||||
SetDarkShadow(darkShadow);
|
||||
}
|
||||
|
||||
// Draw a sunken edge
|
||||
void DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize = 1);
|
||||
|
||||
// Tile a bitmap
|
||||
bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap);
|
||||
|
||||
protected:
|
||||
wxColour m_highlightColour; // Usually white
|
||||
wxColour m_lightShadow; // Usually light grey
|
||||
wxColour m_faceColour; // Usually grey
|
||||
wxColour m_mediumShadow; // Usually dark grey
|
||||
wxColour m_darkShadow; // Usually black
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
156
include/wx/encconv.h
Normal file
156
include/wx/encconv.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/encconv.h
|
||||
// Purpose: wxEncodingConverter class for converting between different
|
||||
// font encodings
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_ENCCONV_H_
|
||||
#define _WX_ENCCONV_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "encconv.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/fontenc.h"
|
||||
#include "wx/dynarray.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
wxCONVERT_STRICT,
|
||||
wxCONVERT_SUBSTITUTE
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
wxPLATFORM_CURRENT = -1,
|
||||
|
||||
wxPLATFORM_UNIX = 0,
|
||||
wxPLATFORM_WINDOWS,
|
||||
wxPLATFORM_OS2,
|
||||
wxPLATFORM_MAC
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WX_DEFINE_ARRAY_INT(wxFontEncoding, wxFontEncodingArray);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxEncodingConverter
|
||||
// This class is capable of converting strings between any two
|
||||
// 8bit encodings/charsets. It can also convert from/to Unicode
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxEncodingConverter : public wxObject
|
||||
{
|
||||
public:
|
||||
|
||||
wxEncodingConverter();
|
||||
~wxEncodingConverter() { if (m_Table) delete[] m_Table; }
|
||||
|
||||
// Initialize conversion. Both output or input encoding may
|
||||
// be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
|
||||
//
|
||||
// All subsequent calls to Convert() will interpret it's argument
|
||||
// as a string in input_enc encoding and will output string in
|
||||
// output_enc encoding.
|
||||
//
|
||||
// You must call this method before calling Convert. You may call
|
||||
// it more than once in order to switch to another conversion
|
||||
//
|
||||
// Method affects behaviour of Convert() in case input character
|
||||
// cannot be converted because it does not exist in output encoding:
|
||||
// wxCONVERT_STRICT --
|
||||
// follow behaviour of GNU Recode - just copy unconvertable
|
||||
// characters to output and don't change them (it's integer
|
||||
// value will stay the same)
|
||||
// wxCONVERT_SUBSTITUTE --
|
||||
// try some (lossy) substitutions - e.g. replace
|
||||
// unconvertable latin capitals with acute by ordinary
|
||||
// capitals, replace en-dash or em-dash by '-' etc.
|
||||
// both modes gurantee that output string will have same length
|
||||
// as input string
|
||||
//
|
||||
// Returns FALSE if given conversion is impossible, TRUE otherwise
|
||||
// (conversion may be impossible either if you try to convert
|
||||
// to Unicode with non-Unicode build of wxWindows or if input
|
||||
// or output encoding is not supported.)
|
||||
bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
|
||||
|
||||
// Convert input string according to settings passed to Init.
|
||||
// Note that you must call Init before using Convert!
|
||||
void Convert(const char* input, char* output);
|
||||
void Convert(char* str) { Convert(str, str); }
|
||||
wxString Convert(const wxString& input);
|
||||
|
||||
#if wxUSE_WCHAR_T
|
||||
void Convert(const char* input, wchar_t* output);
|
||||
void Convert(const wchar_t* input, char* output);
|
||||
void Convert(const wchar_t* input, wchar_t* output);
|
||||
void Convert(wchar_t* str) { Convert(str, str); }
|
||||
#endif
|
||||
// Return equivalent(s) for given font that are used
|
||||
// under given platform. wxPLATFORM_CURRENT means the plaform
|
||||
// this binary was compiled for
|
||||
//
|
||||
// Examples:
|
||||
// current platform enc returned value
|
||||
// -----------------------------------------------------
|
||||
// unix CP1250 {ISO8859_2}
|
||||
// unix ISO8859_2 {}
|
||||
// windows ISO8859_2 {CP1250}
|
||||
//
|
||||
// Equivalence is defined in terms of convertibility:
|
||||
// 2 encodings are equivalent if you can convert text between
|
||||
// then without loosing information (it may - and will - happen
|
||||
// that you loose special chars like quotation marks or em-dashes
|
||||
// but you shouldn't loose any diacritics and language-specific
|
||||
// characters when converting between equivalent encodings).
|
||||
//
|
||||
// Convert() method is not limited to converting between
|
||||
// equivalent encodings, it can convert between arbitrary
|
||||
// two encodings!
|
||||
//
|
||||
// Remember that this function does _NOT_ check for presence of
|
||||
// fonts in system. It only tells you what are most suitable
|
||||
// encodings. (It usually returns only one encoding)
|
||||
//
|
||||
// Note that argument enc itself may be present in returned array!
|
||||
// (so that you can -- as a side effect -- detect whether the
|
||||
// encoding is native for this platform or not)
|
||||
static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc, int platform = wxPLATFORM_CURRENT);
|
||||
|
||||
// Similar to GetPlatformEquivalent, but this one will return ALL
|
||||
// equivalent encodings, regardless the platform, including itself.
|
||||
static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
|
||||
|
||||
private:
|
||||
|
||||
#if wxUSE_WCHAR_T
|
||||
wchar_t *m_Table;
|
||||
#else
|
||||
char *m_Table;
|
||||
#endif
|
||||
bool m_UnicodeInput, m_UnicodeOutput;
|
||||
bool m_JustCopy;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxEncodingConverter)
|
||||
};
|
||||
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
||||
#endif // _WX_ENCCONV_H_
|
||||
2492
include/wx/event.h
Normal file
2492
include/wx/event.h
Normal file
File diff suppressed because it is too large
Load Diff
62
include/wx/evtloop.h
Normal file
62
include/wx/evtloop.h
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/evtloop.h
|
||||
// Purpose: declares wxEventLoop class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 01.06.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_EVTLOOP_H_
|
||||
#define _WX_EVTLOOP_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "evtloop.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxEventLoop: a GUI event loop
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxEventLoop
|
||||
{
|
||||
public:
|
||||
// ctor
|
||||
wxEventLoop() { m_impl = NULL; }
|
||||
|
||||
// dtor
|
||||
virtual ~wxEventLoop();
|
||||
|
||||
// start the event loop, return the exit code when it is finished
|
||||
virtual int Run();
|
||||
|
||||
// exit from the loop with the given exit code
|
||||
virtual void Exit(int rc = 0);
|
||||
|
||||
// return TRUE if any events are available
|
||||
virtual bool Pending() const;
|
||||
|
||||
// dispatch a single event, return FALSE if we should exit from the loop
|
||||
virtual bool Dispatch();
|
||||
|
||||
// is the event loop running now?
|
||||
virtual bool IsRunning() const;
|
||||
|
||||
// return currently active (running) event loop, may be NULL
|
||||
static wxEventLoop *GetActive() { return ms_activeLoop; }
|
||||
|
||||
// set currently active (running) event loop
|
||||
static void SetActive(wxEventLoop* loop) { ms_activeLoop = loop; }
|
||||
|
||||
protected:
|
||||
// the pointer to the port specific implementation class
|
||||
class WXDLLEXPORT wxEventLoopImpl *m_impl;
|
||||
// the pointer to currently active loop
|
||||
static wxEventLoop *ms_activeLoop;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxEventLoop)
|
||||
};
|
||||
|
||||
#endif // _WX_EVTLOOP_H_
|
||||
222
include/wx/fdrepdlg.h
Normal file
222
include/wx/fdrepdlg.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fdrepdlg.h
|
||||
// Purpose: wxFindReplaceDialog class
|
||||
// Author: Markus Greither and Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 23/03/2001
|
||||
// RCS-ID:
|
||||
// Copyright: (c) Markus Greither
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FINDREPLACEDLG_H_
|
||||
#define _WX_FINDREPLACEDLG_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fdrepdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_FINDREPLDLG
|
||||
|
||||
#include "wx/dialog.h"
|
||||
|
||||
class WXDLLEXPORT wxFindDialogEvent;
|
||||
class WXDLLEXPORT wxFindReplaceDialog;
|
||||
class WXDLLEXPORT wxFindReplaceData;
|
||||
class WXDLLEXPORT wxFindReplaceDialogImpl;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Flags for wxFindReplaceData.Flags
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// flages used by wxFindDialogEvent::GetFlags()
|
||||
enum wxFindReplaceFlags
|
||||
{
|
||||
// downward search/replace selected (otherwise - upwards)
|
||||
wxFR_DOWN = 1,
|
||||
|
||||
// whole word search/replace selected
|
||||
wxFR_WHOLEWORD = 2,
|
||||
|
||||
// case sensitive search/replace selected (otherwise - case insensitive)
|
||||
wxFR_MATCHCASE = 4
|
||||
};
|
||||
|
||||
// these flags can be specified in wxFindReplaceDialog ctor or Create()
|
||||
enum wxFindReplaceDialogStyles
|
||||
{
|
||||
// replace dialog (otherwise find dialog)
|
||||
wxFR_REPLACEDIALOG = 1,
|
||||
|
||||
// don't allow changing the search direction
|
||||
wxFR_NOUPDOWN = 2,
|
||||
|
||||
// don't allow case sensitive searching
|
||||
wxFR_NOMATCHCASE = 4,
|
||||
|
||||
// don't allow whole word searching
|
||||
wxFR_NOWHOLEWORD = 8
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFindReplaceData: holds Setup Data/Feedback Data for wxFindReplaceDialog
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFindReplaceData : public wxObject
|
||||
{
|
||||
public:
|
||||
wxFindReplaceData() { Init(); }
|
||||
wxFindReplaceData(wxUint32 flags) { Init(); SetFlags(flags); }
|
||||
|
||||
// accessors
|
||||
const wxString& GetFindString() { return m_FindWhat; }
|
||||
const wxString& GetReplaceString() { return m_ReplaceWith; }
|
||||
|
||||
int GetFlags() const { return m_Flags; }
|
||||
|
||||
// setters: may only be called before showing the dialog, no effect later
|
||||
void SetFlags(wxUint32 flags) { m_Flags = flags; }
|
||||
|
||||
void SetFindString(const wxString& str) { m_FindWhat = str; }
|
||||
void SetReplaceString(const wxString& str) { m_ReplaceWith = str; }
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
private:
|
||||
wxUint32 m_Flags;
|
||||
wxString m_FindWhat,
|
||||
m_ReplaceWith;
|
||||
|
||||
friend class wxFindReplaceDialogBase;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFindReplaceDialogBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFindReplaceDialogBase : public wxDialog
|
||||
{
|
||||
public:
|
||||
// ctors and such
|
||||
wxFindReplaceDialogBase() { m_FindReplaceData = NULL; }
|
||||
wxFindReplaceDialogBase(wxWindow * WXUNUSED(parent),
|
||||
wxFindReplaceData *data,
|
||||
const wxString& WXUNUSED(title),
|
||||
int WXUNUSED(style) = 0)
|
||||
{
|
||||
m_FindReplaceData = data;
|
||||
}
|
||||
|
||||
virtual ~wxFindReplaceDialogBase();
|
||||
|
||||
// find dialog data access
|
||||
const wxFindReplaceData *GetData() const { return m_FindReplaceData; }
|
||||
void SetData(wxFindReplaceData *data) { m_FindReplaceData = data; }
|
||||
|
||||
// implementation only, don't use
|
||||
void Send(wxFindDialogEvent& event);
|
||||
|
||||
protected:
|
||||
wxFindReplaceData *m_FindReplaceData;
|
||||
|
||||
// the last string we searched for
|
||||
wxString m_lastSearch;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxFindReplaceDialogBase)
|
||||
};
|
||||
|
||||
// include wxFindReplaceDialog declaration
|
||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/fdrepdlg.h"
|
||||
#else
|
||||
#define wxGenericFindReplaceDialog wxFindReplaceDialog
|
||||
#define sm_classwxGenericFindReplaceDialog sm_classwxFindReplaceDialog
|
||||
|
||||
#include "wx/generic/fdrepdlg.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFindReplaceDialog events
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFindDialogEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
wxFindDialogEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
||||
: wxCommandEvent(commandType, id) { }
|
||||
|
||||
int GetFlags() const { return GetInt(); }
|
||||
wxString GetFindString() const { return GetString(); }
|
||||
const wxString& GetReplaceString() const { return m_strReplace; }
|
||||
|
||||
wxFindReplaceDialog *GetDialog() const
|
||||
{ return wxStaticCast(GetEventObject(), wxFindReplaceDialog); }
|
||||
|
||||
// implementation only
|
||||
void SetFlags(int flags) { SetInt(flags); }
|
||||
void SetFindString(const wxString& str) { SetString(str); }
|
||||
void SetReplaceString(const wxString& str) { m_strReplace = str; }
|
||||
|
||||
private:
|
||||
wxString m_strReplace;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxFindDialogEvent)
|
||||
};
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND, 510)
|
||||
DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_NEXT, 511)
|
||||
DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE, 512)
|
||||
DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_REPLACE_ALL, 513)
|
||||
DECLARE_EVENT_TYPE(wxEVT_COMMAND_FIND_CLOSE, 514)
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
typedef void (wxEvtHandler::*wxFindDialogEventFunction)(wxFindDialogEvent&);
|
||||
|
||||
#define EVT_FIND(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_COMMAND_FIND, id, -1, \
|
||||
(wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
|
||||
& fn, \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
#define EVT_FIND_NEXT(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_COMMAND_FIND_NEXT, id, -1, \
|
||||
(wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
|
||||
& fn, \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
#define EVT_FIND_REPLACE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_COMMAND_FIND_REPLACE, id, -1, \
|
||||
(wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
|
||||
& fn, \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
#define EVT_FIND_REPLACE_ALL(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_COMMAND_FIND_REPLACE_ALL, id, -1, \
|
||||
(wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
|
||||
& fn, \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
#define EVT_FIND_CLOSE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_COMMAND_FIND_CLOSE, id, -1, \
|
||||
(wxObjectEventFunction)(wxEventFunction)(wxFindDialogEventFunction) \
|
||||
& fn, \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
#endif // wxUSE_FINDREPLDLG
|
||||
|
||||
#endif
|
||||
// _WX_FDREPDLG_H
|
||||
39
include/wx/features.h
Normal file
39
include/wx/features.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/features.h
|
||||
// Purpose: test macros for the features which might be available in some
|
||||
// wxWindows ports but not others
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 18.03.02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FEATURES_H_
|
||||
#define _WX_FEATURES_H_
|
||||
|
||||
// radio menu items are currently only implemented in wxGTK and wxMSW
|
||||
#if defined(__WXGTK__) || defined(__WXMSW__)
|
||||
#define wxHAS_RADIO_MENU_ITEMS
|
||||
#else
|
||||
#undef wxHAS_RADIO_MENU_ITEMS
|
||||
#endif
|
||||
|
||||
// the raw keyboard codes are generated under wxGTK and wxMSW only
|
||||
#if defined(__WXGTK__) || defined(__WXMSW__)
|
||||
#define wxHAS_RAW_KEY_CODES
|
||||
#else
|
||||
#undef wxHAS_RAW_KEY_CODES
|
||||
#endif
|
||||
|
||||
// taskbar is only implemented in wxMSW and X11 ports
|
||||
#if defined(__WXMSW__) || \
|
||||
defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__)
|
||||
#define wxHAS_TASK_BAR_ICON
|
||||
#else
|
||||
#undef wxHAS_TASK_BAR_ICON
|
||||
#endif
|
||||
|
||||
#endif // _WX_FEATURES_H_
|
||||
|
||||
117
include/wx/ffile.h
Normal file
117
include/wx/ffile.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/ffile.h
|
||||
// Purpose: wxFFile - encapsulates "FILE *" stream
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 14.07.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FFILE_H_
|
||||
#define _WX_FFILE_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "ffile.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h" // for wxUSE_FFILE
|
||||
|
||||
#if wxUSE_FFILE
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#include "wx/filefn.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// class wxFFile: standard C stream library IO
|
||||
//
|
||||
// NB: for space efficiency this class has no virtual functions, including
|
||||
// dtor which is _not_ virtual, so it shouldn't be used as a base class.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFFile
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
// -----
|
||||
// def ctor
|
||||
wxFFile() { m_fp = NULL; }
|
||||
// open specified file (may fail, use IsOpened())
|
||||
wxFFile(const wxChar *filename, const wxChar *mode = _T("r"));
|
||||
// attach to (already opened) file
|
||||
wxFFile(FILE *fp) { m_fp = fp; }
|
||||
|
||||
// open/close
|
||||
// open a file (existing or not - the mode controls what happens)
|
||||
bool Open(const wxChar *filename, const wxChar *mode = _T("r"));
|
||||
// closes the opened file (this is a NOP if not opened)
|
||||
bool Close();
|
||||
|
||||
// assign an existing file descriptor and get it back from wxFFile object
|
||||
void Attach(FILE *fp, const wxString& name = wxT(""))
|
||||
{ Close(); m_fp = fp; m_name = name; }
|
||||
void Detach() { m_fp = NULL; }
|
||||
FILE *fp() const { return m_fp; }
|
||||
|
||||
// read/write (unbuffered)
|
||||
// read all data from the file into a string (useful for text files)
|
||||
bool ReadAll(wxString *str);
|
||||
// returns number of bytes read - use Eof() and Error() to see if an error
|
||||
// occured or not
|
||||
size_t Read(void *pBuf, size_t nCount);
|
||||
// returns the number of bytes written
|
||||
size_t Write(const void *pBuf, size_t nCount);
|
||||
// returns true on success
|
||||
bool Write(const wxString& s, wxMBConv& conv = wxConvUTF8)
|
||||
{
|
||||
const wxWX2MBbuf buf = s.mb_str(conv);
|
||||
size_t size = strlen(buf);
|
||||
return Write((const char *)buf, size) == size;
|
||||
}
|
||||
// flush data not yet written
|
||||
bool Flush();
|
||||
|
||||
// file pointer operations (return ofsInvalid on failure)
|
||||
// move ptr ofs bytes related to start/current pos/end of file
|
||||
bool Seek(long ofs, wxSeekMode mode = wxFromStart);
|
||||
// move ptr to ofs bytes before the end
|
||||
bool SeekEnd(long ofs = 0) { return Seek(ofs, wxFromEnd); }
|
||||
// get current position in the file
|
||||
size_t Tell() const;
|
||||
// get current file length
|
||||
size_t Length() const;
|
||||
|
||||
// simple accessors
|
||||
// is file opened?
|
||||
bool IsOpened() const { return m_fp != NULL; }
|
||||
// is end of file reached?
|
||||
bool Eof() const { return feof(m_fp) != 0; }
|
||||
// is an error occured?
|
||||
bool Error() const { return ferror(m_fp) != 0; }
|
||||
// get the file name
|
||||
const wxString& GetName() const { return m_name; }
|
||||
|
||||
// dtor closes the file if opened
|
||||
~wxFFile() { Close(); }
|
||||
|
||||
private:
|
||||
// copy ctor and assignment operator are private because it doesn't make
|
||||
// sense to copy files this way: attempt to do it will provoke a compile-time
|
||||
// error.
|
||||
wxFFile(const wxFFile&);
|
||||
wxFFile& operator=(const wxFFile&);
|
||||
|
||||
FILE *m_fp; // IO stream or NULL if not opened
|
||||
|
||||
wxString m_name; // the name of the file (for diagnostic messages)
|
||||
};
|
||||
|
||||
#endif // wxUSE_FFILE
|
||||
|
||||
#endif // _WX_FFILE_H_
|
||||
|
||||
192
include/wx/file.h
Normal file
192
include/wx/file.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: file.h
|
||||
// Purpose: wxFile - encapsulates low-level "file descriptor"
|
||||
// wxTempFile - safely replace the old file
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 29/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FILEH__
|
||||
#define _WX_FILEH__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "file.h"
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#include "wx/filefn.h"
|
||||
#include "wx/strconv.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// we redefine these constants here because S_IREAD &c are _not_ standard
|
||||
// however, we do assume that the values correspond to the Unix umask bits
|
||||
#define wxS_IRUSR 00400
|
||||
#define wxS_IWUSR 00200
|
||||
#define wxS_IXUSR 00100
|
||||
|
||||
#define wxS_IRGRP 00040
|
||||
#define wxS_IWGRP 00020
|
||||
#define wxS_IXGRP 00010
|
||||
|
||||
#define wxS_IROTH 00004
|
||||
#define wxS_IWOTH 00002
|
||||
#define wxS_IXOTH 00001
|
||||
|
||||
// default mode for the new files: corresponds to umask 022
|
||||
#define wxS_DEFAULT (wxS_IRUSR | wxS_IWUSR | wxS_IRGRP | wxS_IWGRP |\
|
||||
wxS_IROTH | wxS_IWOTH)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// class wxFile: raw file IO
|
||||
//
|
||||
// NB: for space efficiency this class has no virtual functions, including
|
||||
// dtor which is _not_ virtual, so it shouldn't be used as a base class.
|
||||
// ----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxFile
|
||||
{
|
||||
public:
|
||||
// more file constants
|
||||
// -------------------
|
||||
// opening mode
|
||||
enum OpenMode { read, write, read_write, write_append, write_excl };
|
||||
// standard values for file descriptor
|
||||
enum { fd_invalid = -1, fd_stdin, fd_stdout, fd_stderr };
|
||||
|
||||
// static functions
|
||||
// ----------------
|
||||
// check whether a regular file by this name exists
|
||||
static bool Exists(const wxChar *name);
|
||||
// check whetther we can access the given file in given mode
|
||||
// (only read and write make sense here)
|
||||
static bool Access(const wxChar *name, OpenMode mode);
|
||||
|
||||
// ctors
|
||||
// -----
|
||||
// def ctor
|
||||
wxFile() { m_fd = fd_invalid; }
|
||||
// open specified file (may fail, use IsOpened())
|
||||
wxFile(const wxChar *szFileName, OpenMode mode = read);
|
||||
// attach to (already opened) file
|
||||
wxFile(int fd) { m_fd = fd; }
|
||||
|
||||
// open/close
|
||||
// create a new file (with the default value of bOverwrite, it will fail if
|
||||
// the file already exists, otherwise it will overwrite it and succeed)
|
||||
bool Create(const wxChar *szFileName, bool bOverwrite = FALSE,
|
||||
int access = wxS_DEFAULT);
|
||||
bool Open(const wxChar *szFileName, OpenMode mode = read,
|
||||
int access = wxS_DEFAULT);
|
||||
bool Close(); // Close is a NOP if not opened
|
||||
|
||||
// assign an existing file descriptor and get it back from wxFile object
|
||||
void Attach(int fd) { Close(); m_fd = fd; }
|
||||
void Detach() { m_fd = fd_invalid; }
|
||||
int fd() const { return m_fd; }
|
||||
|
||||
// read/write (unbuffered)
|
||||
// returns number of bytes read or ofsInvalid on error
|
||||
off_t Read(void *pBuf, off_t nCount);
|
||||
// returns the number of bytes written
|
||||
size_t Write(const void *pBuf, size_t nCount);
|
||||
// returns true on success
|
||||
bool Write(const wxString& s, wxMBConv& conv = wxConvUTF8)
|
||||
{
|
||||
const wxWX2MBbuf buf = s.mb_str(conv);
|
||||
size_t size = strlen(buf);
|
||||
return Write((const char *) buf, size) == size;
|
||||
}
|
||||
// flush data not yet written
|
||||
bool Flush();
|
||||
|
||||
// file pointer operations (return ofsInvalid on failure)
|
||||
// move ptr ofs bytes related to start/current off_t/end of file
|
||||
off_t Seek(off_t ofs, wxSeekMode mode = wxFromStart);
|
||||
// move ptr to ofs bytes before the end
|
||||
off_t SeekEnd(off_t ofs = 0) { return Seek(ofs, wxFromEnd); }
|
||||
// get current off_t
|
||||
off_t Tell() const;
|
||||
// get current file length
|
||||
off_t Length() const;
|
||||
|
||||
// simple accessors
|
||||
// is file opened?
|
||||
bool IsOpened() const { return m_fd != fd_invalid; }
|
||||
// is end of file reached?
|
||||
bool Eof() const;
|
||||
// has an error occured?
|
||||
bool Error() const { return m_error; }
|
||||
|
||||
// dtor closes the file if opened
|
||||
~wxFile() { Close(); }
|
||||
|
||||
private:
|
||||
// copy ctor and assignment operator are private because
|
||||
// it doesn't make sense to copy files this way:
|
||||
// attempt to do it will provoke a compile-time error.
|
||||
wxFile(const wxFile&);
|
||||
wxFile& operator=(const wxFile&);
|
||||
|
||||
int m_fd; // file descriptor or INVALID_FD if not opened
|
||||
bool m_error; // error memory
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// class wxTempFile: if you want to replace another file, create an instance
|
||||
// of wxTempFile passing the name of the file to be replaced to the ctor. Then
|
||||
// you can write to wxTempFile and call Commit() function to replace the old
|
||||
// file (and close this one) or call Discard() to cancel the modification. If
|
||||
// you call neither of them, dtor will call Discard().
|
||||
// ----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxTempFile
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
// default
|
||||
wxTempFile() { }
|
||||
// associates the temp file with the file to be replaced and opens it
|
||||
wxTempFile(const wxString& strName);
|
||||
|
||||
// open the temp file (strName is the name of file to be replaced)
|
||||
bool Open(const wxString& strName);
|
||||
|
||||
// is the file opened?
|
||||
bool IsOpened() const { return m_file.IsOpened(); }
|
||||
|
||||
// I/O (both functions return true on success, false on failure)
|
||||
bool Write(const void *p, size_t n) { return m_file.Write(p, n) != 0; }
|
||||
bool Write(const wxString& str, wxMBConv& conv = wxConvUTF8)
|
||||
{ return m_file.Write(str, conv); }
|
||||
|
||||
// different ways to close the file
|
||||
// validate changes and delete the old file of name m_strName
|
||||
bool Commit();
|
||||
// discard changes
|
||||
void Discard();
|
||||
|
||||
// dtor calls Discard() if file is still opened
|
||||
~wxTempFile();
|
||||
|
||||
private:
|
||||
// no copy ctor/assignment operator
|
||||
wxTempFile(const wxTempFile&);
|
||||
wxTempFile& operator=(const wxTempFile&);
|
||||
|
||||
wxString m_strName, // name of the file to replace in Commit()
|
||||
m_strTemp; // temporary file name
|
||||
wxFile m_file; // the temporary file
|
||||
};
|
||||
|
||||
#endif // wxUSE_FILE
|
||||
|
||||
#endif // _WX_FILEH__
|
||||
226
include/wx/fileconf.h
Normal file
226
include/wx/fileconf.h
Normal file
@@ -0,0 +1,226 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fileconf.h
|
||||
// Purpose: wxFileConfig derivation of wxConfigBase
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 07.04.98 (adapted from appconf.cpp)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1997 Karsten Ball<6C>der & Vadim Zeitlin
|
||||
// Ballueder@usa.net <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _FILECONF_H
|
||||
#define _FILECONF_H
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fileconf.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
|
||||
#include "wx/textfile.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileConfig
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
wxFileConfig derives from base Config and implements file based config class,
|
||||
i.e. it uses ASCII disk files to store the information. These files are
|
||||
alternatively called INI, .conf or .rc in the documentation. They are
|
||||
organized in groups or sections, which can nest (i.e. a group contains
|
||||
subgroups, which contain their own subgroups &c). Each group has some
|
||||
number of entries, which are "key = value" pairs. More precisely, the format
|
||||
is:
|
||||
|
||||
# comments are allowed after either ';' or '#' (Win/UNIX standard)
|
||||
|
||||
# blank lines (as above) are ignored
|
||||
|
||||
# global entries are members of special (no name) top group
|
||||
written_for = Windows
|
||||
platform = Linux
|
||||
|
||||
# the start of the group 'Foo'
|
||||
[Foo] # may put comments like this also
|
||||
# following 3 lines are entries
|
||||
key = value
|
||||
another_key = " strings with spaces in the beginning should be quoted, \
|
||||
otherwise the spaces are lost"
|
||||
last_key = but you don't have to put " normally (nor quote them, like here)
|
||||
|
||||
# subgroup of the group 'Foo'
|
||||
# (order is not important, only the name is: separator is '/', as in paths)
|
||||
[Foo/Bar]
|
||||
# entries prefixed with "!" are immutable, i.e. can't be changed if they are
|
||||
# set in the system-wide config file
|
||||
!special_key = value
|
||||
bar_entry = whatever
|
||||
|
||||
[Foo/Bar/Fubar] # depth is (theoretically :-) unlimited
|
||||
# may have the same name as key in another section
|
||||
bar_entry = whatever not
|
||||
|
||||
You have {read/write/delete}Entry functions (guess what they do) and also
|
||||
setCurrentPath to select current group. enum{Subgroups/Entries} allow you
|
||||
to get all entries in the config file (in the current group). Finally,
|
||||
flush() writes immediately all changed entries to disk (otherwise it would
|
||||
be done automatically in dtor)
|
||||
|
||||
wxFileConfig manages not less than 2 config files for each program: global
|
||||
and local (or system and user if you prefer). Entries are read from both of
|
||||
them and the local entries override the global ones unless the latter is
|
||||
immutable (prefixed with '!') in which case a warning message is generated
|
||||
and local value is ignored. Of course, the changes are always written to local
|
||||
file only.
|
||||
|
||||
The names of these files can be specified in a number of ways. First of all,
|
||||
you can use the standard convention: using the ctor which takes 'strAppName'
|
||||
parameter will probably be sufficient for 90% of cases. If, for whatever
|
||||
reason you wish to use the files with some other names, you can always use the
|
||||
second ctor.
|
||||
|
||||
wxFileConfig also may automatically expand the values of environment variables
|
||||
in the entries it reads: for example, if you have an entry
|
||||
score_file = $HOME/.score
|
||||
a call to Read(&str, "score_file") will return a complete path to .score file
|
||||
unless the expansion was previousle disabled with SetExpandEnvVars(FALSE) call
|
||||
(it's on by default, the current status can be retrieved with
|
||||
IsExpandingEnvVars function).
|
||||
*/
|
||||
class WXDLLEXPORT wxFileConfigGroup;
|
||||
class WXDLLEXPORT wxFileConfigEntry;
|
||||
class WXDLLEXPORT wxFileConfigLineList;
|
||||
class WXDLLEXPORT wxInputStream;
|
||||
|
||||
class WXDLLEXPORT wxFileConfig : public wxConfigBase
|
||||
{
|
||||
public:
|
||||
// construct the "standard" full name for global (system-wide) and
|
||||
// local (user-specific) config files from the base file name.
|
||||
//
|
||||
// the following are the filenames returned by this functions:
|
||||
// global local
|
||||
// Unix /etc/file.ext ~/.file
|
||||
// Win %windir%\file.ext %USERPROFILE%\file.ext
|
||||
//
|
||||
// where file is the basename of szFile, ext is it's extension
|
||||
// or .conf (Unix) or .ini (Win) if it has none
|
||||
static wxString GetGlobalFileName(const wxChar *szFile);
|
||||
static wxString GetLocalFileName(const wxChar *szFile);
|
||||
|
||||
// ctor & dtor
|
||||
// New constructor: one size fits all. Specify wxCONFIG_USE_LOCAL_FILE or
|
||||
// wxCONFIG_USE_GLOBAL_FILE to say which files should be used.
|
||||
wxFileConfig(const wxString& appName = wxT(""),
|
||||
const wxString& vendorName = wxT(""),
|
||||
const wxString& localFilename = wxT(""),
|
||||
const wxString& globalFilename = wxT(""),
|
||||
long style = wxCONFIG_USE_LOCAL_FILE,
|
||||
wxMBConv& conv = wxConvUTF8);
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
// ctor that takes an input stream.
|
||||
wxFileConfig(wxInputStream &inStream,
|
||||
wxMBConv& conv = wxConvUTF8);
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
// dtor will save unsaved data
|
||||
virtual ~wxFileConfig();
|
||||
|
||||
// under Unix, set the umask to be used for the file creation, do nothing
|
||||
// under other systems
|
||||
#ifdef __UNIX__
|
||||
void SetUmask(int mode) { m_umask = mode; }
|
||||
#else // !__UNIX__
|
||||
void SetUmask(int WXUNUSED(mode)) { }
|
||||
#endif // __UNIX__/!__UNIX__
|
||||
|
||||
// implement inherited pure virtual functions
|
||||
virtual void SetPath(const wxString& strPath);
|
||||
virtual const wxString& GetPath() const { return m_strPath; }
|
||||
|
||||
virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
|
||||
virtual bool GetNextGroup (wxString& str, long& lIndex) const;
|
||||
virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
|
||||
virtual bool GetNextEntry (wxString& str, long& lIndex) const;
|
||||
|
||||
virtual size_t GetNumberOfEntries(bool bRecursive = FALSE) const;
|
||||
virtual size_t GetNumberOfGroups(bool bRecursive = FALSE) const;
|
||||
|
||||
virtual bool HasGroup(const wxString& strName) const;
|
||||
virtual bool HasEntry(const wxString& strName) const;
|
||||
|
||||
virtual bool Flush(bool bCurrentOnly = FALSE);
|
||||
|
||||
virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
|
||||
virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
|
||||
|
||||
virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = TRUE);
|
||||
virtual bool DeleteGroup(const wxString& szKey);
|
||||
virtual bool DeleteAll();
|
||||
|
||||
public:
|
||||
// functions to work with this list
|
||||
wxFileConfigLineList *LineListAppend(const wxString& str);
|
||||
wxFileConfigLineList *LineListInsert(const wxString& str,
|
||||
wxFileConfigLineList *pLine); // NULL => Prepend()
|
||||
void LineListRemove(wxFileConfigLineList *pLine);
|
||||
bool LineListIsEmpty();
|
||||
|
||||
protected:
|
||||
virtual bool DoReadString(const wxString& key, wxString *pStr) const;
|
||||
virtual bool DoReadLong(const wxString& key, long *pl) const;
|
||||
|
||||
virtual bool DoWriteString(const wxString& key, const wxString& szValue);
|
||||
virtual bool DoWriteLong(const wxString& key, long lValue);
|
||||
|
||||
private:
|
||||
// GetXXXFileName helpers: return ('/' terminated) directory names
|
||||
static wxString GetGlobalDir();
|
||||
static wxString GetLocalDir();
|
||||
|
||||
// common part of all ctors (assumes that m_str{Local|Global}File are already
|
||||
// initialized
|
||||
void Init();
|
||||
|
||||
// common part of from dtor and DeleteAll
|
||||
void CleanUp();
|
||||
|
||||
// parse the whole file
|
||||
void Parse(wxTextBuffer& buffer, bool bLocal);
|
||||
|
||||
// the same as SetPath("/")
|
||||
void SetRootPath();
|
||||
|
||||
// member variables
|
||||
// ----------------
|
||||
wxFileConfigLineList *m_linesHead, // head of the linked list
|
||||
*m_linesTail; // tail
|
||||
|
||||
wxString m_strLocalFile, // local file name passed to ctor
|
||||
m_strGlobalFile; // global
|
||||
wxString m_strPath; // current path (not '/' terminated)
|
||||
|
||||
wxFileConfigGroup *m_pRootGroup, // the top (unnamed) group
|
||||
*m_pCurrentGroup; // the current group
|
||||
|
||||
wxMBConv &m_conv;
|
||||
|
||||
#ifdef __UNIX__
|
||||
int m_umask; // the umask to use for file creation
|
||||
#endif // __UNIX__
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxFileConfig)
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_CONFIG
|
||||
|
||||
#endif
|
||||
//_FILECONF_H
|
||||
|
||||
111
include/wx/filedlg.h
Normal file
111
include/wx/filedlg.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: filedlg.h
|
||||
// Purpose: wxFileDialog base header
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 8/17/99
|
||||
// Copyright: (c) Robert Roebling
|
||||
// RCS-ID:
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FILEDLG_H_BASE_
|
||||
#define _WX_FILEDLG_H_BASE_
|
||||
|
||||
#if wxUSE_FILEDLG
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "filedlg.h"
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxFileDialog data and generic functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
wxOPEN = 0x0001,
|
||||
wxSAVE = 0x0002,
|
||||
wxOVERWRITE_PROMPT = 0x0004,
|
||||
wxHIDE_READONLY = 0x0008,
|
||||
wxFILE_MUST_EXIST = 0x0010,
|
||||
wxMULTIPLE = 0x0020,
|
||||
wxCHANGE_DIR = 0x0040
|
||||
};
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
|
||||
|
||||
// Parses the filterStr, returning the number of filters.
|
||||
// Returns 0 if none or if there's a problem, they arrays will contain an equal
|
||||
// number of items found before the error.
|
||||
// filterStr is in the form:
|
||||
// "All files (*.*)|*.*|Image Files (*.jpeg *.png)|*.jpg;*.png"
|
||||
extern int wxParseFileFilter(const wxString& filterStr,
|
||||
wxArrayString& descriptions,
|
||||
wxArrayString& filters);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxFileDialog convenience functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// File selector - backward compatibility
|
||||
WXDLLEXPORT wxString
|
||||
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
|
||||
const wxChar *default_path = NULL,
|
||||
const wxChar *default_filename = NULL,
|
||||
const wxChar *default_extension = NULL,
|
||||
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
|
||||
int flags = 0,
|
||||
wxWindow *parent = NULL,
|
||||
int x = -1, int y = -1);
|
||||
|
||||
// An extended version of wxFileSelector
|
||||
WXDLLEXPORT wxString
|
||||
wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
|
||||
const wxChar *default_path = NULL,
|
||||
const wxChar *default_filename = NULL,
|
||||
int *indexDefaultExtension = NULL,
|
||||
const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
|
||||
int flags = 0,
|
||||
wxWindow *parent = NULL,
|
||||
int x = -1, int y = -1);
|
||||
|
||||
// Ask for filename to load
|
||||
WXDLLEXPORT wxString
|
||||
wxLoadFileSelector(const wxChar *what,
|
||||
const wxChar *extension,
|
||||
const wxChar *default_name = (const wxChar *)NULL,
|
||||
wxWindow *parent = (wxWindow *) NULL);
|
||||
|
||||
// Ask for filename to save
|
||||
WXDLLEXPORT wxString
|
||||
wxSaveFileSelector(const wxChar *what,
|
||||
const wxChar *extension,
|
||||
const wxChar *default_name = (const wxChar *) NULL,
|
||||
wxWindow *parent = (wxWindow *) NULL);
|
||||
|
||||
|
||||
#if defined (__WXUNIVERSAL__)
|
||||
#include "wx/generic/filedlgg.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/filedlg.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/filedlg.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/generic/filedlgg.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/generic/filedlgg.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/generic/filedlgg.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/filedlg.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/generic/filedlgg.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/filedlg.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_FILEDLG
|
||||
|
||||
#endif // _WX_FILEDLG_H_BASE_
|
||||
386
include/wx/filefn.h
Normal file
386
include/wx/filefn.h
Normal file
@@ -0,0 +1,386 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: filefn.h
|
||||
// Purpose: File- and directory-related functions
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 29/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _FILEFN_H_
|
||||
#define _FILEFN_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "filefn.h"
|
||||
#endif
|
||||
|
||||
#include "wx/list.h"
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXWINCE__
|
||||
typedef long off_t;
|
||||
#else
|
||||
|
||||
// define off_t
|
||||
#if !defined(__WXMAC__) || defined(__UNIX__) || defined(__MACH__)
|
||||
#include <sys/types.h>
|
||||
#else
|
||||
typedef long off_t;
|
||||
#endif
|
||||
|
||||
#if defined(__VISUALC__) || ( defined(__MWERKS__) && defined( __INTEL__) )
|
||||
typedef _off_t off_t;
|
||||
#elif defined(__BORLANDC__) && defined(__WIN16__)
|
||||
typedef long off_t;
|
||||
#elif defined(__SYMANTEC__)
|
||||
typedef long off_t;
|
||||
#elif defined(__MWERKS__) && !defined(__INTEL__) && !defined(__MACH__)
|
||||
typedef long off_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
||||
//
|
||||
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
||||
// in headers included by more than one primary source
|
||||
//
|
||||
extern const off_t wxInvalidOffset;
|
||||
#else
|
||||
const off_t wxInvalidOffset = (off_t)-1;
|
||||
#endif
|
||||
|
||||
enum wxSeekMode
|
||||
{
|
||||
wxFromStart,
|
||||
wxFromCurrent,
|
||||
wxFromEnd
|
||||
};
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// declare our versions of low level file functions: some compilers prepend
|
||||
// underscores to the usual names, some also have Unicode versions of them
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Microsoft compiler loves underscores, feed them to it
|
||||
#if defined( __VISUALC__ ) \
|
||||
|| ( defined(__MINGW32__) && !defined(__WINE__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
|
||||
|| ( defined(__MWERKS__) && defined(__WXMSW__) )
|
||||
// functions
|
||||
#ifdef __BORLANDC__
|
||||
#define _tell tell
|
||||
#endif
|
||||
#define wxClose _close
|
||||
#define wxRead _read
|
||||
#define wxWrite _write
|
||||
#define wxLseek _lseek
|
||||
#define wxFsync _commit
|
||||
#define wxEof _eof
|
||||
|
||||
#define wxTell _tell
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#if wxUSE_UNICODE_MSLU
|
||||
#define wxOpen wxMSLU__wopen
|
||||
|
||||
#define wxAccess wxMSLU__waccess
|
||||
#define wxMkDir wxMSLU__wmkdir
|
||||
#define wxRmDir wxMSLU__wrmdir
|
||||
#define wxStat wxMSLU__wstat
|
||||
#else
|
||||
#define wxOpen _wopen
|
||||
#define wxAccess _waccess
|
||||
#define wxMkDir _wmkdir
|
||||
#define wxRmDir _wrmdir
|
||||
#define wxStat _wstat
|
||||
#endif
|
||||
#else // !wxUSE_UNICODE
|
||||
#ifdef __BORLANDC__
|
||||
#define wxOpen open
|
||||
#else
|
||||
#define wxOpen _open
|
||||
#endif
|
||||
#define wxAccess _access
|
||||
#define wxMkDir _mkdir
|
||||
#define wxRmDir _rmdir
|
||||
#define wxStat _stat
|
||||
#endif
|
||||
|
||||
// types
|
||||
#define wxStructStat struct _stat
|
||||
|
||||
// constants (unless already defined by the user code)
|
||||
#if !defined(O_RDONLY) && !defined(__BORLANDC__)
|
||||
#define O_RDONLY _O_RDONLY
|
||||
#define O_WRONLY _O_WRONLY
|
||||
#define O_RDWR _O_RDWR
|
||||
#define O_EXCL _O_EXCL
|
||||
#define O_CREAT _O_CREAT
|
||||
#define O_BINARY _O_BINARY
|
||||
#endif
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
#define S_IFMT _S_IFMT
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#define S_IFREG _S_IFREG
|
||||
#endif // O_RDONLY
|
||||
#else
|
||||
// functions
|
||||
#define wxClose close
|
||||
#define wxRead read
|
||||
#define wxWrite write
|
||||
#define wxLseek lseek
|
||||
#define wxFsync commit
|
||||
#define wxEof eof
|
||||
|
||||
#define wxMkDir mkdir
|
||||
#define wxRmDir rmdir
|
||||
|
||||
#define wxTell(fd) lseek(fd, 0, SEEK_CUR)
|
||||
|
||||
#define wxStructStat struct stat
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
# define wxNEED_WX_UNISTD_H
|
||||
#if defined(__MWERKS__) && defined(macintosh)
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf );
|
||||
WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode );
|
||||
WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode );
|
||||
#else
|
||||
#define wxOpen open
|
||||
#define wxStat stat
|
||||
#define wxAccess access
|
||||
#endif
|
||||
|
||||
#endif // VC++
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// functions
|
||||
// ----------------------------------------------------------------------------
|
||||
WXDLLEXPORT bool wxFileExists(const wxString& filename);
|
||||
|
||||
// does the path exist? (may have or not '/' or '\\' at the end)
|
||||
WXDLLEXPORT bool wxPathExists(const wxChar *pszPathName);
|
||||
|
||||
WXDLLEXPORT bool wxIsAbsolutePath(const wxString& filename);
|
||||
|
||||
// Get filename
|
||||
WXDLLEXPORT wxChar* wxFileNameFromPath(wxChar *path);
|
||||
WXDLLEXPORT wxString wxFileNameFromPath(const wxString& path);
|
||||
|
||||
// Get directory
|
||||
WXDLLEXPORT wxString wxPathOnly(const wxString& path);
|
||||
|
||||
// wxString version
|
||||
WXDLLEXPORT wxString wxRealPath(const wxString& path);
|
||||
|
||||
WXDLLEXPORT void wxDos2UnixFilename(wxChar *s);
|
||||
|
||||
WXDLLEXPORT void wxUnix2DosFilename(wxChar *s);
|
||||
|
||||
// Strip the extension, in situ
|
||||
WXDLLEXPORT void wxStripExtension(wxChar *buffer);
|
||||
WXDLLEXPORT void wxStripExtension(wxString& buffer);
|
||||
|
||||
// Get a temporary filename
|
||||
WXDLLEXPORT wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = (wxChar *) NULL);
|
||||
WXDLLEXPORT bool wxGetTempFileName(const wxString& prefix, wxString& buf);
|
||||
|
||||
// Expand file name (~/ and ${OPENWINHOME}/ stuff)
|
||||
WXDLLEXPORT wxChar* wxExpandPath(wxChar *dest, const wxChar *path);
|
||||
WXDLLEXPORT bool wxExpandPath(wxString& dest, const wxChar *path);
|
||||
|
||||
// Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib)
|
||||
// and make (if under the home tree) relative to home
|
||||
// [caller must copy-- volatile]
|
||||
WXDLLEXPORT wxChar* wxContractPath(const wxString& filename,
|
||||
const wxString& envname = wxEmptyString,
|
||||
const wxString& user = wxEmptyString);
|
||||
|
||||
// Destructive removal of /./ and /../ stuff
|
||||
WXDLLEXPORT wxChar* wxRealPath(wxChar *path);
|
||||
|
||||
// Allocate a copy of the full absolute path
|
||||
WXDLLEXPORT wxChar* wxCopyAbsolutePath(const wxString& path);
|
||||
|
||||
// Get first file name matching given wild card.
|
||||
// Flags are reserved for future use.
|
||||
#define wxFILE 1
|
||||
#define wxDIR 2
|
||||
WXDLLEXPORT wxString wxFindFirstFile(const wxChar *spec, int flags = wxFILE);
|
||||
WXDLLEXPORT wxString wxFindNextFile();
|
||||
|
||||
// Does the pattern contain wildcards?
|
||||
WXDLLEXPORT bool wxIsWild(const wxString& pattern);
|
||||
|
||||
// Does the pattern match the text (usually a filename)?
|
||||
// If dot_special is TRUE, doesn't match * against . (eliminating
|
||||
// `hidden' dot files)
|
||||
WXDLLEXPORT bool wxMatchWild(const wxString& pattern, const wxString& text, bool dot_special = TRUE);
|
||||
|
||||
// Concatenate two files to form third
|
||||
WXDLLEXPORT bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3);
|
||||
|
||||
// Copy file1 to file2
|
||||
WXDLLEXPORT bool wxCopyFile(const wxString& file1, const wxString& file2,
|
||||
bool overwrite = TRUE);
|
||||
|
||||
// Remove file
|
||||
WXDLLEXPORT bool wxRemoveFile(const wxString& file);
|
||||
|
||||
// Rename file
|
||||
WXDLLEXPORT bool wxRenameFile(const wxString& file1, const wxString& file2);
|
||||
|
||||
// Get current working directory.
|
||||
// If buf is NULL, allocates space using new, else
|
||||
// copies into buf.
|
||||
// IMPORTANT NOTE getcwd is know not to work under some releases
|
||||
// of Win32s 1.3, according to MS release notes!
|
||||
WXDLLEXPORT wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000);
|
||||
// new and preferred version of wxGetWorkingDirectory
|
||||
// NB: can't have the same name because of overloading ambiguity
|
||||
WXDLLEXPORT wxString wxGetCwd();
|
||||
|
||||
// Set working directory
|
||||
WXDLLEXPORT bool wxSetWorkingDirectory(const wxString& d);
|
||||
|
||||
// Make directory
|
||||
WXDLLEXPORT bool wxMkdir(const wxString& dir, int perm = 0777);
|
||||
|
||||
// Remove directory. Flags reserved for future use.
|
||||
WXDLLEXPORT bool wxRmdir(const wxString& dir, int flags = 0);
|
||||
|
||||
// compatibility defines, don't use in new code
|
||||
#define wxDirExists wxPathExists
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2
|
||||
#define FileExists wxFileExists
|
||||
#define DirExists wxDirExists
|
||||
#define IsAbsolutePath wxIsAbsolutePath
|
||||
#define FileNameFromPath wxFileNameFromPath
|
||||
#define PathOnly wxPathOnly
|
||||
#define Dos2UnixFilename wxDos2UnixFilename
|
||||
#define Unix2DosFilename wxUnix2DosFilename
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// separators in file names
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// between file name and extension
|
||||
#define wxFILE_SEP_EXT wxT('.')
|
||||
|
||||
// between drive/volume name and the path
|
||||
#define wxFILE_SEP_DSK wxT(':')
|
||||
|
||||
// between the path components
|
||||
#define wxFILE_SEP_PATH_DOS wxT('\\')
|
||||
#define wxFILE_SEP_PATH_UNIX wxT('/')
|
||||
#define wxFILE_SEP_PATH_MAC wxT(':')
|
||||
#define wxFILE_SEP_PATH_VMS wxT('.') // VMS also uses '[' and ']'
|
||||
|
||||
// separator in the path list (as in PATH environment variable)
|
||||
// there is no PATH variable in Classic Mac OS so just use the
|
||||
// semicolon (it must be different from the file name separator)
|
||||
// NB: these are strings and not characters on purpose!
|
||||
#define wxPATH_SEP_DOS wxT(";")
|
||||
#define wxPATH_SEP_UNIX wxT(":")
|
||||
#define wxPATH_SEP_MAC wxT(";")
|
||||
|
||||
// platform independent versions
|
||||
#if defined(__UNIX__) && !defined(__CYGWIN__)
|
||||
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX
|
||||
#define wxPATH_SEP wxPATH_SEP_UNIX
|
||||
#elif defined(__MAC__)
|
||||
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC
|
||||
#define wxPATH_SEP wxPATH_SEP_MAC
|
||||
#elif defined(__CYGWIN__) // Cygwin
|
||||
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
|
||||
#define wxPATH_SEP wxPATH_SEP_UNIX
|
||||
#else // Windows and OS/2
|
||||
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
|
||||
#define wxPATH_SEP wxPATH_SEP_DOS
|
||||
#endif // Unix/Windows
|
||||
|
||||
// this is useful for wxString::IsSameAs(): to compare two file names use
|
||||
// filename1.IsSameAs(filename2, wxARE_FILENAMES_CASE_SENSITIVE)
|
||||
#if defined(__UNIX__) && !defined(__DARWIN__)
|
||||
#define wxARE_FILENAMES_CASE_SENSITIVE TRUE
|
||||
#else // Windows, Mac OS and OS/2
|
||||
#define wxARE_FILENAMES_CASE_SENSITIVE FALSE
|
||||
#endif // Unix/Windows
|
||||
|
||||
// is the char a path separator?
|
||||
inline bool wxIsPathSeparator(wxChar c)
|
||||
{
|
||||
// under DOS/Windows we should understand both Unix and DOS file separators
|
||||
#if defined(__UNIX__) || defined(__MAC__)
|
||||
return c == wxFILE_SEP_PATH;
|
||||
#else
|
||||
return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX;
|
||||
#endif
|
||||
}
|
||||
|
||||
// does the string ends with path separator?
|
||||
WXDLLEXPORT bool wxEndsWithPathSeparator(const wxChar *pszFileName);
|
||||
|
||||
// split the full path into path (including drive for DOS), name and extension
|
||||
// (understands both '/' and '\\')
|
||||
WXDLLEXPORT void wxSplitPath(const wxChar *pszFileName,
|
||||
wxString *pstrPath,
|
||||
wxString *pstrName,
|
||||
wxString *pstrExt);
|
||||
|
||||
// find a file in a list of directories, returns false if not found
|
||||
WXDLLEXPORT bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile);
|
||||
|
||||
// Get the OS directory if appropriate (such as the Windows directory).
|
||||
// On non-Windows platform, probably just return the empty string.
|
||||
WXDLLEXPORT wxString wxGetOSDirectory();
|
||||
|
||||
// Get file modification time
|
||||
WXDLLEXPORT time_t wxFileModificationTime(const wxString& filename);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Path searching
|
||||
class WXDLLEXPORT wxPathList : public wxStringList
|
||||
{
|
||||
public:
|
||||
// Adds all paths in environment variable
|
||||
void AddEnvList(const wxString& envVariable);
|
||||
|
||||
void Add(const wxString& path);
|
||||
// Avoid compiler warning
|
||||
wxNode *Add(const wxChar *s) { return wxStringList::Add(s); }
|
||||
// Find the first full path for which the file exists
|
||||
wxString FindValidPath(const wxString& filename);
|
||||
// Find the first full path for which the file exists; ensure it's an
|
||||
// absolute path that gets returned.
|
||||
wxString FindAbsoluteValidPath(const wxString& filename);
|
||||
// Given full path and filename, add path to list
|
||||
void EnsureFileAccessible(const wxString& path);
|
||||
// Returns TRUE if the path is in the list
|
||||
bool Member(const wxString& path);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxPathList)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_FILEFN_H_
|
||||
427
include/wx/filename.h
Normal file
427
include/wx/filename.h
Normal file
@@ -0,0 +1,427 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/filename.h
|
||||
// Purpose: wxFileName - encapsulates a file path
|
||||
// Author: Robert Roebling, Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 28.12.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FILENAME_H_
|
||||
#define _WX_FILENAME_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "filename.h"
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
TODO:
|
||||
|
||||
1. support for drives under Windows
|
||||
2. more file operations:
|
||||
a) chmod()
|
||||
b) [acm]time() - get and set
|
||||
c) file size
|
||||
d) file permissions with readable accessors for most common bits
|
||||
such as IsReadable() &c
|
||||
e) rename()?
|
||||
3. SameFileAs() function to compare inodes under Unix
|
||||
*/
|
||||
|
||||
// ridiculously enough, this will replace DirExists with wxDirExists etc
|
||||
#include "wx/filefn.h"
|
||||
#include "wx/datetime.h"
|
||||
|
||||
class WXDLLEXPORT wxFile;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the various values for the path format: this mainly affects the path
|
||||
// separator but also whether or not the path has the drive part (as under
|
||||
// Windows)
|
||||
enum wxPathFormat
|
||||
{
|
||||
wxPATH_NATIVE = 0, // the path format for the current platform
|
||||
wxPATH_UNIX,
|
||||
wxPATH_MAC,
|
||||
wxPATH_DOS,
|
||||
wxPATH_VMS,
|
||||
|
||||
wxPATH_BEOS = wxPATH_UNIX,
|
||||
wxPATH_WIN = wxPATH_DOS,
|
||||
wxPATH_OS2 = wxPATH_DOS
|
||||
};
|
||||
|
||||
// the kind of normalization to do with the file name: these values can be
|
||||
// or'd together to perform several operations at once
|
||||
enum wxPathNormalize
|
||||
{
|
||||
wxPATH_NORM_ENV_VARS = 0x0001, // replace env vars with their values
|
||||
wxPATH_NORM_DOTS = 0x0002, // squeeze all .. and . and prepend cwd
|
||||
wxPATH_NORM_TILDE = 0x0004, // Unix only: replace ~ and ~user
|
||||
wxPATH_NORM_CASE = 0x0008, // if case insensitive => tolower
|
||||
wxPATH_NORM_ABSOLUTE = 0x0010, // make the path absolute
|
||||
wxPATH_NORM_LONG = 0x0020, // make the path the long form
|
||||
wxPATH_NORM_ALL = 0x003f
|
||||
};
|
||||
|
||||
// what exactly should GetPath() return?
|
||||
enum
|
||||
{
|
||||
wxPATH_GET_VOLUME = 0x0001, // include the volume if applicable
|
||||
wxPATH_GET_SEPARATOR = 0x0002 // terminate the path with the separator
|
||||
};
|
||||
|
||||
// MkDir flags
|
||||
enum
|
||||
{
|
||||
wxPATH_MKDIR_FULL = 0x0001 // create directories recursively
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileName: encapsulates a file path
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFileName
|
||||
{
|
||||
public:
|
||||
// constructors and assignment
|
||||
|
||||
// the usual stuff
|
||||
wxFileName() { Clear(); }
|
||||
wxFileName( const wxFileName &filepath ) { Assign(filepath); }
|
||||
|
||||
// from a full filename: if it terminates with a '/', a directory path
|
||||
// is contructed (the name will be empty), otherwise a file name and
|
||||
// extension are extracted from it
|
||||
wxFileName( const wxString& fullpath, wxPathFormat format = wxPATH_NATIVE )
|
||||
{ Assign( fullpath, format ); }
|
||||
|
||||
// from a directory name and a file name
|
||||
wxFileName(const wxString& path,
|
||||
const wxString& name,
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{ Assign(path, name, format); }
|
||||
|
||||
// from a volume, directory name, file base name and extension
|
||||
wxFileName(const wxString& volume,
|
||||
const wxString& path,
|
||||
const wxString& name,
|
||||
const wxString& ext,
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{ Assign(volume, path, name, ext, format); }
|
||||
|
||||
// from a directory name, file base name and extension
|
||||
wxFileName(const wxString& path,
|
||||
const wxString& name,
|
||||
const wxString& ext,
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{ Assign(path, name, ext, format); }
|
||||
|
||||
// the same for delayed initialization
|
||||
|
||||
void Assign(const wxFileName& filepath);
|
||||
|
||||
void Assign(const wxString& fullpath,
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
void Assign(const wxString& volume,
|
||||
const wxString& path,
|
||||
const wxString& name,
|
||||
const wxString& ext,
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
void Assign(const wxString& path,
|
||||
const wxString& name,
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
void Assign(const wxString& path,
|
||||
const wxString& name,
|
||||
const wxString& ext,
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{
|
||||
// empty volume
|
||||
Assign(_T(""), path, name, ext, format);
|
||||
}
|
||||
|
||||
void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// assorted assignment operators
|
||||
|
||||
wxFileName& operator=(const wxFileName& filename)
|
||||
{ Assign(filename); return *this; }
|
||||
|
||||
wxFileName& operator=(const wxString& filename)
|
||||
{ Assign(filename); return *this; }
|
||||
|
||||
// reset all components to default, uninitialized state
|
||||
void Clear();
|
||||
|
||||
// static pseudo constructors
|
||||
static wxFileName FileName(const wxString& file);
|
||||
static wxFileName DirName(const wxString& dir);
|
||||
|
||||
// file tests
|
||||
|
||||
// is the filename valid at all?
|
||||
bool IsOk() const { return !m_dirs.IsEmpty() || !m_name.IsEmpty(); }
|
||||
|
||||
// does the file with this name exists?
|
||||
bool FileExists() const;
|
||||
static bool FileExists( const wxString &file );
|
||||
|
||||
// does the directory with this name exists?
|
||||
bool DirExists() const;
|
||||
static bool DirExists( const wxString &dir );
|
||||
|
||||
// VZ: also need: IsDirWritable(), IsFileExecutable() &c (TODO)
|
||||
|
||||
// time functions
|
||||
#if wxUSE_DATETIME
|
||||
// set the file last access/mod and creation times
|
||||
// (any of the pointers may be NULL)
|
||||
bool SetTimes(const wxDateTime *dtAccess,
|
||||
const wxDateTime *dtMod,
|
||||
const wxDateTime *dtCreate);
|
||||
|
||||
// set the access and modification times to the current moment
|
||||
bool Touch();
|
||||
|
||||
// return the last access, last modification and create times
|
||||
// (any of the pointers may be NULL)
|
||||
bool GetTimes(wxDateTime *dtAccess,
|
||||
wxDateTime *dtMod,
|
||||
wxDateTime *dtCreate) const;
|
||||
|
||||
// convenience wrapper: get just the last mod time of the file
|
||||
wxDateTime GetModificationTime() const
|
||||
{
|
||||
wxDateTime dtMod;
|
||||
(void)GetTimes(NULL, &dtMod, NULL);
|
||||
return dtMod;
|
||||
}
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
#ifdef __WXMAC__
|
||||
bool MacSetTypeAndCreator( wxUint32 type , wxUint32 creator ) ;
|
||||
bool MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator ) ;
|
||||
// gets the 'common' type and creator for a certain extension
|
||||
static bool MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator ) ;
|
||||
// registers application defined extensions and their default type and creator
|
||||
static void MacRegisterDefaultTypeAndCreator( const wxString& ext , wxUint32 type , wxUint32 creator ) ;
|
||||
// looks up the appropriate type and creator from the registration and then sets
|
||||
bool MacSetDefaultTypeAndCreator() ;
|
||||
#endif
|
||||
|
||||
// various file/dir operations
|
||||
|
||||
// retrieve the value of the current working directory
|
||||
void AssignCwd(const wxString& volume = wxEmptyString);
|
||||
static wxString GetCwd(const wxString& volume = wxEmptyString);
|
||||
|
||||
// change the current working directory
|
||||
bool SetCwd();
|
||||
static bool SetCwd( const wxString &cwd );
|
||||
|
||||
// get the value of user home (Unix only mainly)
|
||||
void AssignHomeDir();
|
||||
static wxString GetHomeDir();
|
||||
|
||||
// get a temp file name starting with the specified prefix and open the
|
||||
// file passed to us using this name for writing (atomically if
|
||||
// possible)
|
||||
void AssignTempFileName(const wxString& prefix, wxFile *fileTemp = NULL);
|
||||
static wxString CreateTempFileName(const wxString& prefix,
|
||||
wxFile *fileTemp = NULL);
|
||||
|
||||
// directory creation and removal.
|
||||
// if full is TRUE, will try to make each directory in the path.
|
||||
bool Mkdir( int perm = 0777, int flags = 0);
|
||||
static bool Mkdir( const wxString &dir, int perm = 0777, int flags = 0 );
|
||||
|
||||
bool Rmdir();
|
||||
static bool Rmdir( const wxString &dir );
|
||||
|
||||
// operations on the path
|
||||
|
||||
// normalize the path: with the default flags value, the path will be
|
||||
// made absolute, without any ".." and "." and all environment
|
||||
// variables will be expanded in it
|
||||
//
|
||||
// this may be done using another (than current) value of cwd
|
||||
bool Normalize(int flags = wxPATH_NORM_ALL,
|
||||
const wxString& cwd = wxEmptyString,
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// get a path path relative to the given base directory, i.e. opposite
|
||||
// of Normalize
|
||||
//
|
||||
// pass an empty string to get a path relative to the working directory
|
||||
//
|
||||
// returns TRUE if the file name was modified, FALSE if we failed to do
|
||||
// anything with it (happens when the file is on a different volume,
|
||||
// for example)
|
||||
bool MakeRelativeTo(const wxString& pathBase = _T(""),
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// make the path absolute
|
||||
//
|
||||
// this may be done using another (than current) value of cwd
|
||||
bool MakeAbsolute(const wxString& cwd = wxEmptyString,
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{ return Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE |
|
||||
wxPATH_NORM_TILDE, cwd, format); }
|
||||
|
||||
// Comparison
|
||||
|
||||
// compares with the rules of the given platforms format
|
||||
bool SameAs(const wxFileName& filepath,
|
||||
wxPathFormat format = wxPATH_NATIVE) const;
|
||||
|
||||
// compare with another filename object
|
||||
bool operator==(const wxFileName& filename) const
|
||||
{ return SameAs(filename); }
|
||||
bool operator!=(const wxFileName& filename) const
|
||||
{ return !SameAs(filename); }
|
||||
|
||||
// compare with a filename string interpreted as a native file name
|
||||
bool operator==(const wxString& filename) const
|
||||
{ return SameAs(wxFileName(filename)); }
|
||||
bool operator!=(const wxString& filename) const
|
||||
{ return !SameAs(wxFileName(filename)); }
|
||||
|
||||
// are the file names of this type cases sensitive?
|
||||
static bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE );
|
||||
|
||||
// is this filename absolute?
|
||||
bool IsAbsolute(wxPathFormat format = wxPATH_NATIVE) const;
|
||||
|
||||
// is this filename relative?
|
||||
bool IsRelative(wxPathFormat format = wxPATH_NATIVE) const
|
||||
{ return !IsAbsolute(format); }
|
||||
|
||||
// Information about path format
|
||||
|
||||
// get the string separating the volume from the path for this format,
|
||||
// return an empty string if this format doesn't support the notion of
|
||||
// volumes at all
|
||||
static wxString GetVolumeSeparator(wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// get the string of path separators for this format
|
||||
static wxString GetPathSeparators(wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// get the canonical path separator for this format
|
||||
static wxChar GetPathSeparator(wxPathFormat format = wxPATH_NATIVE)
|
||||
{ return GetPathSeparators(format)[0u]; }
|
||||
|
||||
// is the char a path separator for this format?
|
||||
static bool IsPathSeparator(wxChar ch, wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// Dir accessors
|
||||
void AppendDir( const wxString &dir );
|
||||
void PrependDir( const wxString &dir );
|
||||
void InsertDir( int before, const wxString &dir );
|
||||
void RemoveDir( int pos );
|
||||
size_t GetDirCount() const { return m_dirs.GetCount(); }
|
||||
|
||||
// Other accessors
|
||||
void SetExt( const wxString &ext ) { m_ext = ext; }
|
||||
wxString GetExt() const { return m_ext; }
|
||||
bool HasExt() const { return !m_ext.empty(); }
|
||||
|
||||
void SetName( const wxString &name ) { m_name = name; }
|
||||
wxString GetName() const { return m_name; }
|
||||
bool HasName() const { return !m_name.empty(); }
|
||||
|
||||
void SetVolume( const wxString &volume ) { m_volume = volume; }
|
||||
wxString GetVolume() const { return m_volume; }
|
||||
bool HasVolume() const { return !m_volume.empty(); }
|
||||
|
||||
// full name is the file name + extension (but without the path)
|
||||
void SetFullName(const wxString& fullname);
|
||||
wxString GetFullName() const;
|
||||
|
||||
const wxArrayString& GetDirs() const { return m_dirs; }
|
||||
|
||||
// flags are combination of wxPATH_GET_XXX flags
|
||||
wxString GetPath(int flags = 0, wxPathFormat format = wxPATH_NATIVE) const;
|
||||
|
||||
// Replace current path with this one
|
||||
void SetPath( const wxString &path, wxPathFormat format = wxPATH_NATIVE );
|
||||
|
||||
// Construct full path with name and ext
|
||||
wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
|
||||
|
||||
// Return the short form of the path (returns identity on non-Windows platforms)
|
||||
wxString GetShortPath() const;
|
||||
|
||||
// Return the long form of the path (returns identity on non-Windows platforms)
|
||||
wxString GetLongPath() const;
|
||||
|
||||
// Is this a file or directory (not necessarily an existing one)
|
||||
bool IsDir() const { return m_name.empty() && m_ext.empty(); }
|
||||
|
||||
// various helpers
|
||||
|
||||
// get the canonical path format for this platform
|
||||
static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE );
|
||||
|
||||
// split a fullpath into the volume, path, (base) name and extension
|
||||
// (all of the pointers can be NULL)
|
||||
static void SplitPath(const wxString& fullpath,
|
||||
wxString *volume,
|
||||
wxString *path,
|
||||
wxString *name,
|
||||
wxString *ext,
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
// compatibility version
|
||||
static void SplitPath(const wxString& fullpath,
|
||||
wxString *path,
|
||||
wxString *name,
|
||||
wxString *ext,
|
||||
wxPathFormat format = wxPATH_NATIVE);
|
||||
|
||||
|
||||
// deprecated methods, don't use any more
|
||||
// --------------------------------------
|
||||
|
||||
#ifndef __DIGITALMARS__
|
||||
wxString GetPath( bool withSep, wxPathFormat format = wxPATH_NATIVE ) const
|
||||
{ return GetPath(withSep ? wxPATH_GET_SEPARATOR : 0, format); }
|
||||
#endif
|
||||
wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const
|
||||
{ return GetPath(wxPATH_GET_SEPARATOR, format); }
|
||||
|
||||
private:
|
||||
// the drive/volume/device specification (always empty for Unix)
|
||||
wxString m_volume;
|
||||
|
||||
// the path components of the file
|
||||
wxArrayString m_dirs;
|
||||
|
||||
// the file name and extension (empty for directories)
|
||||
wxString m_name,
|
||||
m_ext;
|
||||
|
||||
// when m_dirs is empty it may mean either that we have no path at all or
|
||||
// that our path is '/', i.e. the root directory
|
||||
//
|
||||
// we use m_relative to distinguish between these two cases, it will be
|
||||
// TRUE in the former and FALSE in the latter
|
||||
//
|
||||
// NB: the path is not absolute just because m_relative is FALSE, it still
|
||||
// needs the drive (i.e. volume) in some formats (Windows)
|
||||
bool m_relative;
|
||||
};
|
||||
|
||||
#endif // _WX_FILENAME_H_
|
||||
|
||||
268
include/wx/filesys.h
Normal file
268
include/wx/filesys.h
Normal file
@@ -0,0 +1,268 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: filesys.h
|
||||
// Purpose: class for opening files - virtual file system
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __FILESYS_H__
|
||||
#define __FILESYS_H__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "filesys.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#if !wxUSE_STREAMS
|
||||
#error You cannot compile virtual file systems without wxUSE_STREAMS
|
||||
#endif
|
||||
|
||||
#if wxUSE_HTML && !wxUSE_FILESYSTEM
|
||||
#error You cannot compile wxHTML without virtual file systems
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILESYSTEM
|
||||
|
||||
#include "wx/stream.h"
|
||||
#include "wx/url.h"
|
||||
#include "wx/datetime.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
class wxFSFile;
|
||||
class wxFileSystemHandler;
|
||||
class wxFileSystem;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxFSFile
|
||||
// This class is a file opened using wxFileSystem. It consists of
|
||||
// input stream, location, mime type & optional anchor
|
||||
// (in 'index.htm#chapter2', 'chapter2' is anchor)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFSFile : public wxObject
|
||||
{
|
||||
public:
|
||||
wxFSFile(wxInputStream *stream, const wxString& loc,
|
||||
const wxString& mimetype, const wxString& anchor
|
||||
#if wxUSE_DATETIME
|
||||
, wxDateTime modif
|
||||
#endif // wxUSE_DATETIME
|
||||
)
|
||||
{
|
||||
m_Stream = stream;
|
||||
m_Location = loc;
|
||||
m_MimeType = mimetype; m_MimeType.MakeLower();
|
||||
m_Anchor = anchor;
|
||||
#if wxUSE_DATETIME
|
||||
m_Modif = modif;
|
||||
#endif // wxUSE_DATETIME
|
||||
}
|
||||
|
||||
virtual ~wxFSFile() { if (m_Stream) delete m_Stream; }
|
||||
|
||||
// returns stream. This doesn't _create_ stream, it only returns
|
||||
// pointer to it.
|
||||
wxInputStream *GetStream() const {return m_Stream;}
|
||||
|
||||
// returns file's mime type
|
||||
const wxString& GetMimeType() const {return m_MimeType;}
|
||||
|
||||
// returns the original location (aka filename) of the file
|
||||
const wxString& GetLocation() const {return m_Location;}
|
||||
|
||||
const wxString& GetAnchor() const {return m_Anchor;}
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
wxDateTime GetModificationTime() const {return m_Modif;}
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
private:
|
||||
wxInputStream *m_Stream;
|
||||
wxString m_Location;
|
||||
wxString m_MimeType;
|
||||
wxString m_Anchor;
|
||||
#if wxUSE_DATETIME
|
||||
wxDateTime m_Modif;
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(wxFSFile)
|
||||
DECLARE_NO_COPY_CLASS(wxFSFile)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxFileSystemHandler
|
||||
// This class is FS handler for wxFileSystem. It provides
|
||||
// interface to access certain
|
||||
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFileSystemHandler : public wxObject
|
||||
{
|
||||
public:
|
||||
wxFileSystemHandler() : wxObject() {}
|
||||
|
||||
// returns TRUE if this handler is able to open given location
|
||||
virtual bool CanOpen(const wxString& location) = 0;
|
||||
|
||||
// opens given file and returns pointer to input stream.
|
||||
// Returns NULL if opening failed.
|
||||
// The location is always absolute path.
|
||||
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location) = 0;
|
||||
|
||||
// Finds first/next file that matches spec wildcard. flags can be wxDIR for restricting
|
||||
// the query to directories or wxFILE for files only or 0 for either.
|
||||
// Returns filename or empty string if no more matching file exists
|
||||
virtual wxString FindFirst(const wxString& spec, int flags = 0);
|
||||
virtual wxString FindNext();
|
||||
|
||||
protected:
|
||||
// returns protocol ("file", "http", "tar" etc.) The last (most right)
|
||||
// protocol is used:
|
||||
// {it returns "tar" for "file:subdir/archive.tar.gz#tar:/README.txt"}
|
||||
wxString GetProtocol(const wxString& location) const;
|
||||
|
||||
// returns left part of address:
|
||||
// {it returns "file:subdir/archive.tar.gz" for "file:subdir/archive.tar.gz#tar:/README.txt"}
|
||||
wxString GetLeftLocation(const wxString& location) const;
|
||||
|
||||
// returns anchor part of address:
|
||||
// {it returns "anchor" for "file:subdir/archive.tar.gz#tar:/README.txt#anchor"}
|
||||
// NOTE: anchor is NOT a part of GetLeftLocation()'s return value
|
||||
wxString GetAnchor(const wxString& location) const;
|
||||
|
||||
// returns right part of address:
|
||||
// {it returns "/README.txt" for "file:subdir/archive.tar.gz#tar:/README.txt"}
|
||||
wxString GetRightLocation(const wxString& location) const;
|
||||
|
||||
// Returns MIME type of the file - w/o need to open it
|
||||
// (default behaviour is that it returns type based on extension)
|
||||
wxString GetMimeTypeFromExt(const wxString& location);
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(wxFileSystemHandler)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxFileSystem
|
||||
// This class provides simple interface for opening various
|
||||
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFileSystem : public wxObject
|
||||
{
|
||||
public:
|
||||
wxFileSystem() : wxObject() {m_Path = m_LastName = wxEmptyString; m_Handlers.DeleteContents(TRUE); m_FindFileHandler = NULL;}
|
||||
|
||||
// sets the current location. Every call to OpenFile is
|
||||
// relative to this location.
|
||||
// NOTE !!
|
||||
// unless is_dir = TRUE 'location' is *not* the directory but
|
||||
// file contained in this directory
|
||||
// (so ChangePathTo("dir/subdir/xh.htm") sets m_Path to "dir/subdir/")
|
||||
void ChangePathTo(const wxString& location, bool is_dir = FALSE);
|
||||
|
||||
wxString GetPath() const {return m_Path;}
|
||||
|
||||
// opens given file and returns pointer to input stream.
|
||||
// Returns NULL if opening failed.
|
||||
// It first tries to open the file in relative scope
|
||||
// (based on ChangePathTo()'s value) and then as an absolute
|
||||
// path.
|
||||
wxFSFile* OpenFile(const wxString& location);
|
||||
|
||||
// Finds first/next file that matches spec wildcard. flags can be wxDIR for restricting
|
||||
// the query to directories or wxFILE for files only or 0 for either.
|
||||
// Returns filename or empty string if no more matching file exists
|
||||
wxString FindFirst(const wxString& spec, int flags = 0);
|
||||
wxString FindNext();
|
||||
|
||||
// Adds FS handler.
|
||||
// In fact, this class is only front-end to the FS hanlers :-)
|
||||
static void AddHandler(wxFileSystemHandler *handler);
|
||||
|
||||
// remove all items from the m_Handlers list
|
||||
static void CleanUpHandlers();
|
||||
|
||||
// Returns the native path for a file URL
|
||||
static wxFileName URLToFileName(const wxString& url);
|
||||
|
||||
// Returns the file URL for a native path
|
||||
static wxString FileNameToURL(const wxFileName& filename);
|
||||
|
||||
|
||||
protected:
|
||||
wxString m_Path;
|
||||
// the path (location) we are currently in
|
||||
// this is path, not file!
|
||||
// (so if you opened test/demo.htm, it is
|
||||
// "test/", not "test/demo.htm")
|
||||
wxString m_LastName;
|
||||
// name of last opened file (full path)
|
||||
static wxList m_Handlers;
|
||||
// list of FS handlers
|
||||
wxFileSystemHandler *m_FindFileHandler;
|
||||
// handler that succeed in FindFirst query
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxFileSystem)
|
||||
DECLARE_NO_COPY_CLASS(wxFileSystem)
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
'location' syntax:
|
||||
|
||||
To determine FS type, we're using standard KDE notation:
|
||||
file:/absolute/path/file.htm
|
||||
file:relative_path/xxxxx.html
|
||||
/some/path/x.file ('file:' is default)
|
||||
http://www.gnome.org
|
||||
file:subdir/archive.tar.gz#tar:/README.txt
|
||||
|
||||
special characters :
|
||||
':' - FS identificator is before this char
|
||||
'#' - separator. It can be either HTML anchor ("index.html#news")
|
||||
(in case there is no ':' in the string to the right from it)
|
||||
or FS separator
|
||||
(example : http://www.wxhtml.org/wxhtml-0.1.tar.gz#tar:/include/wxhtml/filesys.h"
|
||||
this would access tgz archive stored on web)
|
||||
'/' - directory (path) separator. It is used to determine upper-level path.
|
||||
HEY! Don't use \ even if you're on Windows!
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class WXDLLEXPORT wxLocalFSHandler : public wxFileSystemHandler
|
||||
{
|
||||
public:
|
||||
virtual bool CanOpen(const wxString& location);
|
||||
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||
virtual wxString FindFirst(const wxString& spec, int flags = 0);
|
||||
virtual wxString FindNext();
|
||||
|
||||
// wxLocalFSHandler will prefix all filenames with 'root' before accessing
|
||||
// files on disk. This effectively makes 'root' the top-level directory
|
||||
// and prevents access to files outside this directory.
|
||||
// (This is similar to Unix command 'chroot'.)
|
||||
static void Chroot(const wxString& root) { ms_root = root; }
|
||||
|
||||
protected:
|
||||
static wxString ms_root;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
// wxUSE_FILESYSTEM
|
||||
|
||||
#endif
|
||||
// __FILESYS_H__
|
||||
74
include/wx/fmappriv.h
Normal file
74
include/wx/fmappriv.h
Normal file
@@ -0,0 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fmappriv.h
|
||||
// Purpose: private wxFontMapper stuff, not to be used by the library users
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 21.06.2003 (extracted from common/fontmap.cpp)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999-2003 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FMAPPRIV_H_
|
||||
#define _WX_FMAPPRIV_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// a special pseudo encoding which means "don't ask me about this charset
|
||||
// any more" -- we need it to avoid driving the user crazy with asking him
|
||||
// time after time about the same charset which he [presumably] doesn't
|
||||
// have the fonts for
|
||||
enum { wxFONTENCODING_UNKNOWN = -2 };
|
||||
|
||||
// the config paths we use
|
||||
#if wxUSE_CONFIG
|
||||
|
||||
#define FONTMAPPER_ROOT_PATH wxT("/wxWindows/FontMapper")
|
||||
#define FONTMAPPER_CHARSET_PATH wxT("Charsets")
|
||||
#define FONTMAPPER_CHARSET_ALIAS_PATH wxT("Aliases")
|
||||
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontMapperPathChanger: change the config path during our lifetime
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
|
||||
class wxFontMapperPathChanger
|
||||
{
|
||||
public:
|
||||
wxFontMapperPathChanger(wxFontMapperBase *fontMapper, const wxString& path)
|
||||
{
|
||||
m_fontMapper = fontMapper;
|
||||
m_ok = m_fontMapper->ChangePath(path, &m_pathOld);
|
||||
}
|
||||
|
||||
bool IsOk() const { return m_ok; }
|
||||
|
||||
~wxFontMapperPathChanger()
|
||||
{
|
||||
if ( IsOk() )
|
||||
m_fontMapper->RestorePath(m_pathOld);
|
||||
}
|
||||
|
||||
private:
|
||||
// the fontmapper object we're working with
|
||||
wxFontMapperBase *m_fontMapper;
|
||||
|
||||
// the old path to be restored if m_ok
|
||||
wxString m_pathOld;
|
||||
|
||||
// have we changed the path successfully?
|
||||
bool m_ok;
|
||||
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxFontMapperPathChanger)
|
||||
};
|
||||
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
#endif // _WX_FMAPPRIV_H_
|
||||
|
||||
237
include/wx/font.h
Normal file
237
include/wx/font.h
Normal file
@@ -0,0 +1,237 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/font.h
|
||||
// Purpose: wxFontBase class: the interface of wxFont
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 20.09.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FONT_H_BASE_
|
||||
#define _WX_FONT_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fontbase.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h" // for wxDEFAULT &c
|
||||
#include "wx/fontenc.h" // the font encoding constants
|
||||
#include "wx/gdiobj.h" // the base class
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFontData;
|
||||
class WXDLLEXPORT wxFontBase;
|
||||
class WXDLLEXPORT wxFont;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// standard font families: these may be used only for the font creation, it
|
||||
// doesn't make sense to query an existing font for its font family as,
|
||||
// especially if the font had been created from a native font description, it
|
||||
// may be unknown
|
||||
enum wxFontFamily
|
||||
{
|
||||
wxFONTFAMILY_DEFAULT = wxDEFAULT,
|
||||
wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
|
||||
wxFONTFAMILY_ROMAN = wxROMAN,
|
||||
wxFONTFAMILY_SCRIPT = wxSCRIPT,
|
||||
wxFONTFAMILY_SWISS = wxSWISS,
|
||||
wxFONTFAMILY_MODERN = wxMODERN,
|
||||
wxFONTFAMILY_TELETYPE = wxTELETYPE,
|
||||
wxFONTFAMILY_MAX,
|
||||
wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
|
||||
};
|
||||
|
||||
// font styles
|
||||
enum wxFontStyle
|
||||
{
|
||||
wxFONTSTYLE_NORMAL = wxNORMAL,
|
||||
wxFONTSTYLE_ITALIC = wxITALIC,
|
||||
wxFONTSTYLE_SLANT = wxSLANT,
|
||||
wxFONTSTYLE_MAX
|
||||
};
|
||||
|
||||
// font weights
|
||||
enum wxFontWeight
|
||||
{
|
||||
wxFONTWEIGHT_NORMAL = wxNORMAL,
|
||||
wxFONTWEIGHT_LIGHT = wxLIGHT,
|
||||
wxFONTWEIGHT_BOLD = wxBOLD,
|
||||
wxFONTWEIGHT_MAX
|
||||
};
|
||||
|
||||
// the font flag bits for the new font ctor accepting one combined flags word
|
||||
enum
|
||||
{
|
||||
// no special flags: font with default weight/slant/anti-aliasing
|
||||
wxFONTFLAG_DEFAULT = 0,
|
||||
|
||||
// slant flags (default: no slant)
|
||||
wxFONTFLAG_ITALIC = 1 << 0,
|
||||
wxFONTFLAG_SLANT = 1 << 1,
|
||||
|
||||
// weight flags (default: medium)
|
||||
wxFONTFLAG_LIGHT = 1 << 2,
|
||||
wxFONTFLAG_BOLD = 1 << 3,
|
||||
|
||||
// anti-aliasing flag: force on or off (default: the current system default)
|
||||
wxFONTFLAG_ANTIALIASED = 1 << 4,
|
||||
wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
|
||||
|
||||
// underlined/strikethrough flags (default: no lines)
|
||||
wxFONTFLAG_UNDERLINED = 1 << 6,
|
||||
wxFONTFLAG_STRIKETHROUGH = 1 << 7,
|
||||
|
||||
// the mask of all currently used flags
|
||||
wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
|
||||
wxFONTFLAG_SLANT |
|
||||
wxFONTFLAG_LIGHT |
|
||||
wxFONTFLAG_BOLD |
|
||||
wxFONTFLAG_ANTIALIASED |
|
||||
wxFONTFLAG_NOT_ANTIALIASED |
|
||||
wxFONTFLAG_UNDERLINED |
|
||||
wxFONTFLAG_STRIKETHROUGH
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontBase represents a font object
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFontRefData;
|
||||
struct WXDLLEXPORT wxNativeFontInfo;
|
||||
|
||||
class WXDLLEXPORT wxFontBase : public wxGDIObject
|
||||
{
|
||||
public:
|
||||
// creator function
|
||||
virtual ~wxFontBase();
|
||||
|
||||
// from the font components
|
||||
static wxFont *New(
|
||||
int pointSize, // size of the font in points
|
||||
int family, // see wxFontFamily enum
|
||||
int style, // see wxFontStyle enum
|
||||
int weight, // see wxFontWeight enum
|
||||
bool underlined = FALSE, // not underlined by default
|
||||
const wxString& face = wxEmptyString, // facename
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
|
||||
|
||||
// from the font components but using the font flags instead of separate
|
||||
// parameters for each flag
|
||||
static wxFont *New(int pointSize,
|
||||
wxFontFamily family,
|
||||
int flags = wxFONTFLAG_DEFAULT,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
// from the (opaque) native font description object
|
||||
static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
|
||||
|
||||
// from the string representation of wxNativeFontInfo
|
||||
static wxFont *New(const wxString& strNativeFontDesc);
|
||||
|
||||
// was the font successfully created?
|
||||
bool Ok() const { return m_refData != NULL; }
|
||||
|
||||
// comparison
|
||||
bool operator == (const wxFont& font) const;
|
||||
bool operator != (const wxFont& font) const;
|
||||
|
||||
// accessors: get the font characteristics
|
||||
virtual int GetPointSize() const = 0;
|
||||
virtual int GetFamily() const = 0;
|
||||
virtual int GetStyle() const = 0;
|
||||
virtual int GetWeight() const = 0;
|
||||
virtual bool GetUnderlined() const = 0;
|
||||
virtual wxString GetFaceName() const = 0;
|
||||
virtual wxFontEncoding GetEncoding() const = 0;
|
||||
virtual wxNativeFontInfo *GetNativeFontInfo() const;
|
||||
|
||||
virtual bool IsFixedWidth() const;
|
||||
|
||||
wxString GetNativeFontInfoDesc() const;
|
||||
wxString GetNativeFontInfoUserDesc() const;
|
||||
|
||||
// change the font characteristics
|
||||
virtual void SetPointSize( int pointSize ) = 0;
|
||||
virtual void SetFamily( int family ) = 0;
|
||||
virtual void SetStyle( int style ) = 0;
|
||||
virtual void SetWeight( int weight ) = 0;
|
||||
virtual void SetFaceName( const wxString& faceName ) = 0;
|
||||
virtual void SetUnderlined( bool underlined ) = 0;
|
||||
virtual void SetEncoding(wxFontEncoding encoding) = 0;
|
||||
void SetNativeFontInfo(const wxNativeFontInfo& info)
|
||||
{ DoSetNativeFontInfo(info); }
|
||||
|
||||
void SetNativeFontInfo(const wxString& info);
|
||||
void SetNativeFontInfoUserDesc(const wxString& info);
|
||||
|
||||
// translate the fonts into human-readable string (i.e. GetStyleString()
|
||||
// will return "wxITALIC" for an italic font, ...)
|
||||
wxString GetFamilyString() const;
|
||||
wxString GetStyleString() const;
|
||||
wxString GetWeightString() const;
|
||||
|
||||
// Unofficial API, don't use
|
||||
virtual void SetNoAntiAliasing( bool WXUNUSED(no) = TRUE ) { }
|
||||
virtual bool GetNoAntiAliasing() { return FALSE; }
|
||||
|
||||
// the default encoding is used for creating all fonts with default
|
||||
// encoding parameter
|
||||
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
|
||||
static void SetDefaultEncoding(wxFontEncoding encoding);
|
||||
|
||||
protected:
|
||||
// get the internal data
|
||||
wxFontRefData *GetFontData() const
|
||||
{ return (wxFontRefData *)m_refData; }
|
||||
|
||||
// the function called by both overloads of SetNativeFontInfo()
|
||||
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
||||
|
||||
private:
|
||||
// the currently default encoding: by default, it's the default system
|
||||
// encoding, but may be changed by the application using
|
||||
// SetDefaultEncoding() to make all subsequent fonts created without
|
||||
// specifing encoding parameter using this encoding
|
||||
static wxFontEncoding ms_encodingDefault;
|
||||
};
|
||||
|
||||
// include the real class declaration
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/font.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/font.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/font.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/font.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/font.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/font.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/font.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/font.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define M_FONTDATA GetFontData()
|
||||
|
||||
#endif
|
||||
// _WX_FONT_H_BASE_
|
||||
91
include/wx/fontdlg.h
Normal file
91
include/wx/fontdlg.h
Normal file
@@ -0,0 +1,91 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fontdlg.h
|
||||
// Purpose: common interface for different wxFontDialog classes
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 12.05.02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1997-2002 wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FONTDLG_H_BASE_
|
||||
#define _WX_FONTDLG_H_BASE_
|
||||
|
||||
#include "wx/defs.h" // for wxUSE_FONTDLG
|
||||
|
||||
#if wxUSE_FONTDLG
|
||||
|
||||
#include "wx/dialog.h" // the base class
|
||||
#include "wx/cmndata.h" // wxFontData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontDialog interface
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFontDialogBase : public wxDialog
|
||||
{
|
||||
public:
|
||||
// create the font dialog
|
||||
wxFontDialogBase() { }
|
||||
wxFontDialogBase(wxWindow *parent) { m_parent = parent; }
|
||||
wxFontDialogBase(wxWindow *parent, const wxFontData& data)
|
||||
{ m_parent = parent; InitFontData(&data); }
|
||||
|
||||
bool Create(wxWindow *parent)
|
||||
{ return DoCreate(parent); }
|
||||
bool Create(wxWindow *parent, const wxFontData& data)
|
||||
{ InitFontData(&data); return Create(parent); }
|
||||
|
||||
virtual ~wxFontDialogBase();
|
||||
|
||||
// retrieve the font data
|
||||
const wxFontData& GetFontData() const { return m_fontData; }
|
||||
wxFontData& GetFontData() { return m_fontData; }
|
||||
|
||||
// deprecated interface, for compatibility only, don't use
|
||||
wxFontDialogBase(wxWindow *parent, const wxFontData *data)
|
||||
{ m_parent = parent; InitFontData(data); }
|
||||
|
||||
bool Create(wxWindow *parent, const wxFontData *data)
|
||||
{ InitFontData(data); return Create(parent); }
|
||||
|
||||
protected:
|
||||
virtual bool DoCreate(wxWindow *parent) { m_parent = parent; return TRUE; }
|
||||
|
||||
void InitFontData(const wxFontData *data = NULL)
|
||||
{ if ( data ) m_fontData = *data; }
|
||||
|
||||
wxFontData m_fontData;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// platform-specific wxFontDialog implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXUNIVERSAL__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXCOCOA__)
|
||||
#include "wx/generic/fontdlgg.h"
|
||||
#define wxFontDialog wxGenericFontDialog
|
||||
#define sm_classwxFontDialog sm_classwxGenericFontDialog
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/fontdlg.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/fontdlg.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/fontdlg.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global public functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// get the font from user and return it, returns wxNullFont if the dialog was
|
||||
// cancelled
|
||||
wxFont WXDLLEXPORT
|
||||
wxGetFontFromUser(wxWindow *parent = (wxWindow *)NULL,
|
||||
const wxFont& fontInit = wxNullFont);
|
||||
|
||||
#endif // wxUSE_FONTDLG
|
||||
|
||||
#endif
|
||||
// _WX_FONTDLG_H_BASE_
|
||||
142
include/wx/fontenc.h
Normal file
142
include/wx/fontenc.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fontenc.h
|
||||
// Purpose: wxFontEncoding constants
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 29.03.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FONTENC_H_
|
||||
#define _WX_FONTENC_H_
|
||||
|
||||
#include "wx/string.h"
|
||||
|
||||
// font encodings
|
||||
enum wxFontEncoding
|
||||
{
|
||||
wxFONTENCODING_SYSTEM = -1, // system default
|
||||
wxFONTENCODING_DEFAULT, // current default encoding
|
||||
|
||||
// ISO8859 standard defines a number of single-byte charsets
|
||||
wxFONTENCODING_ISO8859_1, // West European (Latin1)
|
||||
wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
|
||||
wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
|
||||
wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
|
||||
wxFONTENCODING_ISO8859_5, // Cyrillic
|
||||
wxFONTENCODING_ISO8859_6, // Arabic
|
||||
wxFONTENCODING_ISO8859_7, // Greek
|
||||
wxFONTENCODING_ISO8859_8, // Hebrew
|
||||
wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
|
||||
wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
|
||||
wxFONTENCODING_ISO8859_11, // Thai
|
||||
wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
|
||||
// here anyhow to make all ISO8859
|
||||
// consecutive numbers
|
||||
wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
|
||||
wxFONTENCODING_ISO8859_14, // Latin8
|
||||
wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
|
||||
wxFONTENCODING_ISO8859_MAX,
|
||||
|
||||
// Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
|
||||
wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
|
||||
wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
|
||||
wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
|
||||
|
||||
// what would we do without Microsoft? They have their own encodings
|
||||
// for DOS
|
||||
wxFONTENCODING_CP437, // original MS-DOS codepage
|
||||
wxFONTENCODING_CP850, // CP437 merged with Latin1
|
||||
wxFONTENCODING_CP852, // CP437 merged with Latin2
|
||||
wxFONTENCODING_CP855, // another cyrillic encoding
|
||||
wxFONTENCODING_CP866, // and another one
|
||||
// and for Windows
|
||||
wxFONTENCODING_CP874, // WinThai
|
||||
wxFONTENCODING_CP932, // Japanese (shift-JIS)
|
||||
wxFONTENCODING_CP936, // Chinese simplified (GB)
|
||||
wxFONTENCODING_CP949, // Korean (Hangul charset)
|
||||
wxFONTENCODING_CP950, // Chinese (traditional - Big5)
|
||||
wxFONTENCODING_CP1250, // WinLatin2
|
||||
wxFONTENCODING_CP1251, // WinCyrillic
|
||||
wxFONTENCODING_CP1252, // WinLatin1
|
||||
wxFONTENCODING_CP1253, // WinGreek (8859-7)
|
||||
wxFONTENCODING_CP1254, // WinTurkish
|
||||
wxFONTENCODING_CP1255, // WinHebrew
|
||||
wxFONTENCODING_CP1256, // WinArabic
|
||||
wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
|
||||
wxFONTENCODING_CP12_MAX,
|
||||
|
||||
wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
|
||||
wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
|
||||
|
||||
// Far Eastern encodings
|
||||
// Chinese
|
||||
wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese
|
||||
wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese
|
||||
|
||||
// Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html)
|
||||
wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932, // Shift JIS
|
||||
wxFONTENCODING_EUC_JP = wxFONTENCODING_UTF8 + 1, // Extended Unix Codepage
|
||||
// for Japanese
|
||||
|
||||
wxFONTENCODING_UNICODE, // Unicode (for wxEncodingConverter only)
|
||||
|
||||
wxFONTENCODING_MAX
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
// This private structure specifies all the parameters needed to create a font
|
||||
// with the given encoding on this platform.
|
||||
//
|
||||
// Under X, it contains the last 2 elements of the font specifications
|
||||
// (registry and encoding).
|
||||
//
|
||||
// Under Windows, it contains a number which is one of predefined CHARSET_XXX
|
||||
// values.
|
||||
//
|
||||
// Under all platforms it also contains a facename string which should be
|
||||
// used, if not empty, to create fonts in this encoding (this is the only way
|
||||
// to create a font of non-standard encoding (like KOI8) under Windows - the
|
||||
// facename specifies the encoding then)
|
||||
|
||||
struct WXDLLEXPORT wxNativeEncodingInfo
|
||||
{
|
||||
wxString facename; // may be empty meaning "any"
|
||||
wxFontEncoding encoding; // so that we know what this struct represents
|
||||
|
||||
#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXCOCOA__) // FIXME: __WXCOCOA__
|
||||
wxNativeEncodingInfo()
|
||||
: facename()
|
||||
, encoding(wxFONTENCODING_SYSTEM)
|
||||
, charset(0) /* ANSI_CHARSET */
|
||||
{ }
|
||||
|
||||
int charset;
|
||||
#elif defined(_WX_X_FONTLIKE)
|
||||
wxString xregistry,
|
||||
xencoding;
|
||||
#elif defined(__WXGTK20__)
|
||||
// No way to specify this in Pango as this
|
||||
// seems to be handled internally.
|
||||
#elif defined(__WXMGL__)
|
||||
int mglEncoding;
|
||||
#else
|
||||
#error "Unsupported toolkit"
|
||||
#endif
|
||||
|
||||
// this struct is saved in config by wxFontMapper, so it should know to
|
||||
// serialise itself (implemented in platform-specific code)
|
||||
bool FromString(const wxString& s);
|
||||
wxString ToString() const;
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#endif // _WX_FONTENC_H_
|
||||
91
include/wx/fontenum.h
Normal file
91
include/wx/fontenum.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: fontenum.h
|
||||
// Purpose: wxFontEnumerator class for getting available fonts
|
||||
// Author: Julian Smart, Vadim Zeitlin
|
||||
// Modified by: extended to enumerate more than just font facenames and works
|
||||
// not only on Windows now (VZ)
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart, Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FONTENUM_H_
|
||||
#define _WX_FONTENUM_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fontenum.h"
|
||||
#endif
|
||||
|
||||
#include "wx/fontenc.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontEnumerator enumerates all available fonts on the system or only the
|
||||
// fonts with given attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFontEnumerator
|
||||
{
|
||||
public:
|
||||
wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
|
||||
|
||||
// start enumerating font facenames (either all of them or those which
|
||||
// support the given encoding) - will result in OnFacename() being
|
||||
// called for each available facename (until they are exhausted or
|
||||
// OnFacename returns FALSE)
|
||||
virtual bool EnumerateFacenames
|
||||
(
|
||||
wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
|
||||
bool fixedWidthOnly = FALSE
|
||||
);
|
||||
|
||||
// enumerate the different encodings either for given font facename or for
|
||||
// all facenames - will result in OnFontEncoding() being called for each
|
||||
// available (facename, encoding) couple
|
||||
virtual bool EnumerateEncodings(const wxString& facename = wxT(""));
|
||||
|
||||
// callbacks which are called after one of EnumerateXXX() functions from
|
||||
// above is invoked - all of them may return FALSE to stop enumeration or
|
||||
// TRUE to continue with it
|
||||
|
||||
// called by EnumerateFacenames
|
||||
virtual bool OnFacename(const wxString& facename)
|
||||
{
|
||||
if (m_Facenames == NULL) m_Facenames = new wxArrayString;
|
||||
m_Facenames -> Add(facename);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// called by EnumerateEncodings
|
||||
virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
|
||||
const wxString& encoding)
|
||||
{
|
||||
if (m_Encodings == NULL) m_Encodings = new wxArrayString;
|
||||
m_Encodings -> Add(encoding);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// convenience function that returns array of facenames. Cannot be called
|
||||
// before EnumerateFacenames.
|
||||
wxArrayString *GetFacenames()
|
||||
{ return m_Facenames; }
|
||||
|
||||
// convenience function that returns array of encodings.
|
||||
// Cannot be called before EnumerateEncodings.
|
||||
wxArrayString *GetEncodings()
|
||||
{ return m_Encodings; }
|
||||
|
||||
// virtual dtor for the base class
|
||||
virtual ~wxFontEnumerator()
|
||||
{
|
||||
if (m_Facenames) delete m_Facenames;
|
||||
if (m_Encodings) delete m_Encodings;
|
||||
}
|
||||
|
||||
private:
|
||||
wxArrayString *m_Facenames, *m_Encodings;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxFontEnumerator)
|
||||
};
|
||||
|
||||
#endif // _WX_FONTENUM_H_
|
||||
267
include/wx/fontmap.h
Normal file
267
include/wx/fontmap.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fontmap.h
|
||||
// Purpose: wxFontMapper class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 04.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FONTMAPPER_H_
|
||||
#define _WX_FONTMAPPER_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
#include "wx/fontenc.h" // for wxFontEncoding
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/fontutil.h" // for wxNativeEncodingInfo
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
class WXDLLEXPORT wxConfigBase;
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
class WXDLLEXPORT wxFontMapper;
|
||||
|
||||
#if wxUSE_GUI
|
||||
class WXDLLEXPORT wxWindow;
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// ============================================================================
|
||||
// wxFontMapper manages user-definable correspondence between wxWindows font
|
||||
// encodings and the fonts present on the machine.
|
||||
//
|
||||
// This is a singleton class, font mapper objects can only be accessed using
|
||||
// wxFontMapper::Get().
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontMapperBase: this is a non-interactive class which just uses its built
|
||||
// in knowledge of the encodings equivalence
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFontMapperBase
|
||||
{
|
||||
public:
|
||||
// constructtor and such
|
||||
// ---------------------
|
||||
|
||||
// default ctor
|
||||
wxFontMapperBase();
|
||||
|
||||
// virtual dtor for any base class
|
||||
virtual ~wxFontMapperBase();
|
||||
|
||||
// return instance of the wxFontMapper singleton
|
||||
static wxFontMapper *Get();
|
||||
|
||||
// set the sigleton to 'mapper' instance and return previous one
|
||||
static wxFontMapper *Set(wxFontMapper *mapper);
|
||||
|
||||
|
||||
// translates charset strings to encoding
|
||||
// --------------------------------------
|
||||
|
||||
// returns the encoding for the given charset (in the form of RFC 2046) or
|
||||
// wxFONTENCODING_SYSTEM if couldn't decode it
|
||||
//
|
||||
// interactive parameter is ignored in the base class, we behave as if it
|
||||
// were always false
|
||||
virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
|
||||
bool interactive = true);
|
||||
|
||||
|
||||
// information about supported encodings
|
||||
// -------------------------------------
|
||||
|
||||
// get the number of font encodings we know about
|
||||
static size_t GetSupportedEncodingsCount();
|
||||
|
||||
// get the n-th supported encoding
|
||||
static wxFontEncoding GetEncoding(size_t n);
|
||||
|
||||
// return internal string identifier for the encoding (see also
|
||||
// GetEncodingDescription())
|
||||
static wxString GetEncodingName(wxFontEncoding encoding);
|
||||
|
||||
// return user-readable string describing the given encoding
|
||||
//
|
||||
// NB: hard-coded now, but might change later (read it from config?)
|
||||
static wxString GetEncodingDescription(wxFontEncoding encoding);
|
||||
|
||||
|
||||
// functions which allow to configure the config object used: by default,
|
||||
// the global one (from wxConfigBase::Get() will be used) and the default
|
||||
// root path for the config settings is the string returned by
|
||||
// GetDefaultConfigPath()
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
// set the config object to use (may be NULL to use default)
|
||||
void SetConfig(wxConfigBase *config) { m_config = config; }
|
||||
|
||||
// set the root config path to use (should be an absolute path)
|
||||
void SetConfigPath(const wxString& prefix);
|
||||
|
||||
// return default config path
|
||||
static const wxChar *GetDefaultConfigPath();
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
|
||||
protected:
|
||||
#if wxUSE_CONFIG
|
||||
// get the config object we're using -- if it wasn't set explicitly, this
|
||||
// function will use wxConfig::Get() to get the global one
|
||||
wxConfigBase *GetConfig();
|
||||
|
||||
// gets the root path for our settings -- if it wasn't set explicitly, use
|
||||
// GetDefaultConfigPath()
|
||||
const wxString& GetConfigPath();
|
||||
|
||||
// change to the given (relative) path in the config, return true if ok
|
||||
// (then GetConfig() will return something !NULL), false if no config
|
||||
// object
|
||||
//
|
||||
// caller should provide a pointer to the string variable which should be
|
||||
// later passed to RestorePath()
|
||||
bool ChangePath(const wxString& pathNew, wxString *pathOld);
|
||||
|
||||
// restore the config path after use
|
||||
void RestorePath(const wxString& pathOld);
|
||||
|
||||
// config object and path (in it) to use
|
||||
wxConfigBase *m_config;
|
||||
bool m_configIsDummy;
|
||||
|
||||
wxString m_configRootPath;
|
||||
#endif // wxUSE_CONFIG
|
||||
|
||||
private:
|
||||
// the global fontmapper object or NULL
|
||||
static wxFontMapper *sm_instance;
|
||||
|
||||
friend class wxFontMapperPathChanger;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxFontMapperBase)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontMapper: interactive extension of wxFontMapperBase
|
||||
//
|
||||
// The default implementations of all functions will ask the user if they are
|
||||
// not capable of finding the answer themselves and store the answer in a
|
||||
// config file (configurable via SetConfigXXX functions). This behaviour may
|
||||
// be disabled by giving the value of false to "interactive" parameter.
|
||||
// However, the functions will always consult the config file to allow the
|
||||
// user-defined values override the default logic and there is no way to
|
||||
// disable this -- which shouldn't be ever needed because if "interactive" was
|
||||
// never true, the config file is never created anyhow.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
class WXDLLEXPORT wxFontMapper : public wxFontMapperBase
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
wxFontMapper();
|
||||
|
||||
// virtual dtor for a base class
|
||||
virtual ~wxFontMapper();
|
||||
|
||||
// working with the encodings
|
||||
// --------------------------
|
||||
|
||||
// returns the encoding for the given charset (in the form of RFC 2046) or
|
||||
// wxFONTENCODING_SYSTEM if couldn't decode it
|
||||
virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
|
||||
bool interactive = true);
|
||||
|
||||
// find an alternative for the given encoding (which is supposed to not be
|
||||
// available on this system). If successful, return true and fill info
|
||||
// structure with the parameters required to create the font, otherwise
|
||||
// return false
|
||||
virtual bool GetAltForEncoding(wxFontEncoding encoding,
|
||||
wxNativeEncodingInfo *info,
|
||||
const wxString& facename = wxEmptyString,
|
||||
bool interactive = true);
|
||||
|
||||
// version better suitable for 'public' use. Returns wxFontEcoding
|
||||
// that can be used it wxFont ctor
|
||||
bool GetAltForEncoding(wxFontEncoding encoding,
|
||||
wxFontEncoding *alt_encoding,
|
||||
const wxString& facename = wxEmptyString,
|
||||
bool interactive = true);
|
||||
|
||||
// checks whether given encoding is available in given face or not.
|
||||
// If no facename is given,
|
||||
virtual bool IsEncodingAvailable(wxFontEncoding encoding,
|
||||
const wxString& facename = wxEmptyString);
|
||||
|
||||
|
||||
// configure the appearance of the dialogs we may popup
|
||||
// ----------------------------------------------------
|
||||
|
||||
// the parent window for modal dialogs
|
||||
void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
|
||||
|
||||
// the title for the dialogs (note that default is quite reasonable)
|
||||
void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
|
||||
|
||||
|
||||
protected:
|
||||
// GetAltForEncoding() helper: tests for the existence of the given
|
||||
// encoding and saves the result in config if ok - this results in the
|
||||
// following (desired) behaviour: when an unknown/unavailable encoding is
|
||||
// requested for the first time, the user is asked about a replacement,
|
||||
// but if he doesn't choose any and the default logic finds one, it will
|
||||
// be saved in the config so that the user won't be asked about it any
|
||||
// more
|
||||
bool TestAltEncoding(const wxString& configEntry,
|
||||
wxFontEncoding encReplacement,
|
||||
wxNativeEncodingInfo *info);
|
||||
|
||||
// the title for our dialogs
|
||||
wxString m_titleDialog;
|
||||
|
||||
// the parent window for our dialogs
|
||||
wxWindow *m_windowParent;
|
||||
|
||||
private:
|
||||
DECLARE_NO_COPY_CLASS(wxFontMapper)
|
||||
};
|
||||
|
||||
#else // !wxUSE_GUI
|
||||
|
||||
class WXDLLEXPORT wxFontMapper : public wxFontMapperBase
|
||||
{
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI/!wxUSE_GUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the default font mapper for wxWindows programs do NOT use! This is for
|
||||
// backward compatibility, use wxFontMapper::Get() instead
|
||||
#define wxTheFontMapper (wxFontMapper::Get())
|
||||
|
||||
#else // !wxUSE_FONTMAP
|
||||
|
||||
#if wxUSE_GUI
|
||||
// wxEncodingToCodepage (utils.cpp) needs wxGetNativeFontEncoding
|
||||
#include "wx/fontutil.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
|
||||
|
||||
#endif // _WX_FONTMAPPER_H_
|
||||
|
||||
199
include/wx/fontutil.h
Normal file
199
include/wx/fontutil.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/fontutil.h
|
||||
// Purpose: font-related helper functions
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 05.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// General note: this header is private to wxWindows and is not supposed to be
|
||||
// included by user code. The functions declared here are implemented in
|
||||
// msw/fontutil.cpp for Windows, unix/fontutil.cpp for GTK/Motif &c.
|
||||
|
||||
#ifndef _WX_FONTUTIL_H_
|
||||
#define _WX_FONTUTIL_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fontutil.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/font.h" // for wxFont and wxFontEncoding
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include <windows.h>
|
||||
#include "wx/msw/winundef.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WX_X_FONTLIKE)
|
||||
|
||||
// the symbolic names for the XLFD fields (with examples for their value)
|
||||
//
|
||||
// NB: we suppose that the font always starts with the empty token (font name
|
||||
// registry field) as we never use nor generate it anyhow
|
||||
enum wxXLFDField
|
||||
{
|
||||
wxXLFD_FOUNDRY, // adobe
|
||||
wxXLFD_FAMILY, // courier, times, ...
|
||||
wxXLFD_WEIGHT, // black, bold, demibold, medium, regular, light
|
||||
wxXLFD_SLANT, // r/i/o (roman/italique/oblique)
|
||||
wxXLFD_SETWIDTH, // condensed, expanded, ...
|
||||
wxXLFD_ADDSTYLE, // whatever - usually nothing
|
||||
wxXLFD_PIXELSIZE, // size in pixels
|
||||
wxXLFD_POINTSIZE, // size in points
|
||||
wxXLFD_RESX, // 72, 75, 100, ...
|
||||
wxXLFD_RESY,
|
||||
wxXLFD_SPACING, // m/p/c (monospaced/proportional/character cell)
|
||||
wxXLFD_AVGWIDTH, // average width in 1/10 pixels
|
||||
wxXLFD_REGISTRY, // iso8859, rawin, koi8, ...
|
||||
wxXLFD_ENCODING, // 1, r, r, ...
|
||||
wxXLFD_MAX
|
||||
};
|
||||
|
||||
#endif // _WX_X_FONTLIKE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// wxNativeFontInfo is platform-specific font representation: this struct
|
||||
// should be considered as opaque font description only used by the native
|
||||
// functions, the user code can only get the objects of this type from
|
||||
// somewhere and pass it somewhere else (possibly save them somewhere using
|
||||
// ToString() and restore them using FromString())
|
||||
//
|
||||
// NB: it is a POD currently for max efficiency but if it continues to grow
|
||||
// further it might make sense to make it a real class with virtual methods
|
||||
struct WXDLLEXPORT wxNativeFontInfo
|
||||
{
|
||||
#if wxUSE_PANGO
|
||||
PangoFontDescription *description;
|
||||
#elif defined(_WX_X_FONTLIKE)
|
||||
// the members can't be accessed directly as we only parse the
|
||||
// xFontName on demand
|
||||
private:
|
||||
// the components of the XLFD
|
||||
wxString fontElements[wxXLFD_MAX];
|
||||
|
||||
// the full XLFD
|
||||
wxString xFontName;
|
||||
|
||||
// true until SetXFontName() is called
|
||||
bool m_isDefault;
|
||||
|
||||
// return true if we have already initialized fontElements
|
||||
inline bool HasElements() const;
|
||||
|
||||
public:
|
||||
// init the elements from an XLFD, return TRUE if ok
|
||||
bool FromXFontName(const wxString& xFontName);
|
||||
|
||||
// return false if we were never initialized with a valid XLFD
|
||||
bool IsDefault() const { return m_isDefault; }
|
||||
|
||||
// return the XLFD (using the fontElements if necessary)
|
||||
wxString GetXFontName() const;
|
||||
|
||||
// get the given XFLD component
|
||||
wxString GetXFontComponent(wxXLFDField field) const;
|
||||
|
||||
// change the font component
|
||||
void SetXFontComponent(wxXLFDField field, const wxString& value);
|
||||
|
||||
// set the XFLD
|
||||
void SetXFontName(const wxString& xFontName);
|
||||
#elif defined(__WXMSW__)
|
||||
LOGFONT lf;
|
||||
#elif defined(__WXPM__)
|
||||
// OS/2 native structures that define a font
|
||||
FATTRS fa;
|
||||
FONTMETRICS fm;
|
||||
FACENAMEDESC fn;
|
||||
#else // other platforms
|
||||
//
|
||||
// This is a generic implementation that should work on all ports
|
||||
// without specific support by the port.
|
||||
//
|
||||
#define wxNO_NATIVE_FONTINFO
|
||||
|
||||
int pointSize;
|
||||
wxFontFamily family;
|
||||
wxFontStyle style;
|
||||
wxFontWeight weight;
|
||||
bool underlined;
|
||||
wxString faceName;
|
||||
wxFontEncoding encoding;
|
||||
#endif // platforms
|
||||
|
||||
// default ctor (default copy ctor is ok)
|
||||
wxNativeFontInfo() { Init(); }
|
||||
|
||||
// reset to the default state
|
||||
void Init();
|
||||
|
||||
// accessors and modifiers for the font elements
|
||||
int GetPointSize() const;
|
||||
wxFontStyle GetStyle() const;
|
||||
wxFontWeight GetWeight() const;
|
||||
bool GetUnderlined() const;
|
||||
wxString GetFaceName() const;
|
||||
wxFontFamily GetFamily() const;
|
||||
wxFontEncoding GetEncoding() const;
|
||||
|
||||
void SetPointSize(int pointsize);
|
||||
void SetStyle(wxFontStyle style);
|
||||
void SetWeight(wxFontWeight weight);
|
||||
void SetUnderlined(bool underlined);
|
||||
void SetFaceName(wxString facename);
|
||||
void SetFamily(wxFontFamily family);
|
||||
void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
// it is important to be able to serialize wxNativeFontInfo objects to be
|
||||
// able to store them (in config file, for example)
|
||||
bool FromString(const wxString& s);
|
||||
wxString ToString() const;
|
||||
|
||||
// we also want to present the native font descriptions to the user in some
|
||||
// human-readable form (it is not platform independent neither, but can
|
||||
// hopefully be understood by the user)
|
||||
bool FromUserString(const wxString& s);
|
||||
wxString ToUserString() const;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions (common)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// translate a wxFontEncoding into native encoding parameter (defined above),
|
||||
// returning TRUE if an (exact) macth could be found, FALSE otherwise (without
|
||||
// attempting any substitutions)
|
||||
extern bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||
wxNativeEncodingInfo *info);
|
||||
|
||||
// test for the existence of the font described by this facename/encoding,
|
||||
// return TRUE if such font(s) exist, FALSE otherwise
|
||||
extern bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions (X and GTK)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _WX_X_FONTLIKE
|
||||
#include "wx/unix/fontutil.h"
|
||||
#endif // X || GDK
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// font-related functions (MGL)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXMGL__
|
||||
#include "wx/mgl/fontutil.h"
|
||||
#endif // __WXMGL__
|
||||
|
||||
#endif // _WX_FONTUTIL_H_
|
||||
241
include/wx/frame.h
Normal file
241
include/wx/frame.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/frame.h
|
||||
// Purpose: wxFrame class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 15.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FRAME_H_BASE_
|
||||
#define _WX_FRAME_H_BASE_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "framebase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/toplevel.h" // the base class
|
||||
|
||||
// the default names for various classs
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
|
||||
|
||||
class WXDLLEXPORT wxFrame;
|
||||
class WXDLLEXPORT wxMenuBar;
|
||||
class WXDLLEXPORT wxStatusBar;
|
||||
class WXDLLEXPORT wxToolBar;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFrame is a top-level window with optional menubar, statusbar and toolbar
|
||||
//
|
||||
// For each of *bars, a frame may have several of them, but only one is
|
||||
// managed by the frame, i.e. resized/moved when the frame is and whose size
|
||||
// is accounted for in client size calculations - all others should be taken
|
||||
// care of manually. The CreateXXXBar() functions create this, main, XXXBar,
|
||||
// but the actual creation is done in OnCreateXXXBar() functions which may be
|
||||
// overridden to create custom objects instead of standard ones when
|
||||
// CreateXXXBar() is called.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFrameBase : public wxTopLevelWindow
|
||||
{
|
||||
public:
|
||||
// construction
|
||||
wxFrameBase();
|
||||
virtual ~wxFrameBase();
|
||||
|
||||
wxFrame *New(wxWindow *parent,
|
||||
wxWindowID winid,
|
||||
const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr);
|
||||
|
||||
// frame state
|
||||
// -----------
|
||||
|
||||
// get the origin of the client area (which may be different from (0, 0)
|
||||
// if the frame has a toolbar) in client coordinates
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
|
||||
// sends a size event to the window using its current size -- this has an
|
||||
// effect of refreshing the window layout
|
||||
//
|
||||
// currently it is only implemented under MSW but is declared here to make
|
||||
// it possible to call it in portable code without using #ifdef's
|
||||
virtual void SendSizeEvent() { }
|
||||
|
||||
// menu bar functions
|
||||
// ------------------
|
||||
|
||||
#if wxUSE_MENUS
|
||||
virtual void SetMenuBar(wxMenuBar *menubar);
|
||||
virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
#ifdef WXWIN_COMPATIBILITY_2_2
|
||||
// call this to simulate a menu command
|
||||
bool Command(int winid) { return ProcessCommand(winid); }
|
||||
#endif // WXWIN_COMPATIBILITY_2_2
|
||||
|
||||
// process menu command: returns TRUE if processed
|
||||
bool ProcessCommand(int winid);
|
||||
|
||||
// status bar functions
|
||||
// --------------------
|
||||
#if wxUSE_STATUSBAR
|
||||
// create the main status bar by calling OnCreateStatusBar()
|
||||
virtual wxStatusBar* CreateStatusBar(int number = 1,
|
||||
long style = wxST_SIZEGRIP,
|
||||
wxWindowID winid = 0,
|
||||
const wxString& name =
|
||||
wxStatusLineNameStr);
|
||||
// return a new status bar
|
||||
virtual wxStatusBar *OnCreateStatusBar(int number,
|
||||
long style,
|
||||
wxWindowID winid,
|
||||
const wxString& name);
|
||||
// get the main status bar
|
||||
virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
|
||||
|
||||
// sets the main status bar
|
||||
void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; }
|
||||
|
||||
// forward these to status bar
|
||||
virtual void SetStatusText(const wxString &text, int number = 0);
|
||||
virtual void SetStatusWidths(int n, const int widths_field[]);
|
||||
void PushStatusText(const wxString &text, int number = 0);
|
||||
void PopStatusText(int number = 0);
|
||||
|
||||
// set the status bar pane the help will be shown in
|
||||
void SetStatusBarPane(int n) { m_statusBarPane = n; }
|
||||
int GetStatusBarPane() const { return m_statusBarPane; }
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
// toolbar functions
|
||||
// -----------------
|
||||
#if wxUSE_TOOLBAR
|
||||
// create main toolbar bycalling OnCreateToolBar()
|
||||
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL,
|
||||
wxWindowID winid = -1,
|
||||
const wxString& name = wxToolBarNameStr);
|
||||
// return a new toolbar
|
||||
virtual wxToolBar *OnCreateToolBar(long style,
|
||||
wxWindowID winid,
|
||||
const wxString& name );
|
||||
|
||||
// get/set the main toolbar
|
||||
virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
|
||||
virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// event handlers
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnMenuHighlight(wxMenuEvent& event);
|
||||
|
||||
#if wxUSE_MENUS
|
||||
// send wxUpdateUIEvents for all menu items (called from OnIdle())
|
||||
void DoMenuUpdates();
|
||||
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
// if there is no real wxTopLevelWindow on this platform we have to define
|
||||
// some wxTopLevelWindowBase pure virtual functions here to avoid breaking
|
||||
// old ports (wxMotif) which don't define them in wxFrame
|
||||
#ifndef wxTopLevelWindowNative
|
||||
virtual bool ShowFullScreen(bool WXUNUSED(show),
|
||||
long WXUNUSED(style) = wxFULLSCREEN_ALL)
|
||||
{ return FALSE; }
|
||||
virtual bool IsFullScreen() const
|
||||
{ return FALSE; }
|
||||
#endif // no wxTopLevelWindowNative
|
||||
|
||||
// show help text (typically in the statusbar); show is FALSE
|
||||
// if you are hiding the help, TRUE otherwise
|
||||
virtual void DoGiveHelp(const wxString& text, bool show);
|
||||
|
||||
protected:
|
||||
// the frame main menu/status/tool bars
|
||||
// ------------------------------------
|
||||
|
||||
// this (non virtual!) function should be called from dtor to delete the
|
||||
// main menubar, statusbar and toolbar (if any)
|
||||
void DeleteAllBars();
|
||||
|
||||
// test whether this window makes part of the frame
|
||||
virtual bool IsOneOfBars(const wxWindow *win) const;
|
||||
|
||||
#if wxUSE_MENUS
|
||||
// override to update menu bar position when the frame size changes
|
||||
virtual void PositionMenuBar() { }
|
||||
|
||||
// override to do something special when the menu bar is being removed
|
||||
// from the frame
|
||||
virtual void DetachMenuBar();
|
||||
|
||||
// override to do something special when the menu bar is attached to the
|
||||
// frame
|
||||
virtual void AttachMenuBar(wxMenuBar *menubar);
|
||||
|
||||
wxMenuBar *m_frameMenuBar;
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
// override to update status bar position (or anything else) when
|
||||
// something changes
|
||||
virtual void PositionStatusBar() { }
|
||||
|
||||
// show the help string for this menu item in the given status bar: the
|
||||
// status bar pointer can be NULL; return TRUE if help was shown
|
||||
bool ShowMenuHelp(wxStatusBar *statbar, int helpid);
|
||||
|
||||
wxStatusBar *m_frameStatusBar;
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
|
||||
int m_statusBarPane;
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
// override to update status bar position (or anything else) when
|
||||
// something changes
|
||||
virtual void PositionToolBar() { }
|
||||
|
||||
wxToolBar *m_frameToolBar;
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxFrameBase)
|
||||
};
|
||||
|
||||
// include the real class declaration
|
||||
#if defined(__WXUNIVERSAL__) // && !defined(__WXMICROWIN__)
|
||||
#include "wx/univ/frame.h"
|
||||
#else // !__WXUNIVERSAL__
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/frame.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/frame.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/frame.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/frame.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/frame.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/frame.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_FRAME_H_BASE_
|
||||
57
include/wx/fs_inet.h
Normal file
57
include/wx/fs_inet.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: fs_inet.h
|
||||
// Purpose: HTTP and FTP file system
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
|
||||
REMARKS :
|
||||
|
||||
This FS creates local cache (in /tmp directory). The cache is freed
|
||||
on program exit.
|
||||
|
||||
Size of cache is limited to cca 1000 items (due to GetTempFileName
|
||||
limitation)
|
||||
|
||||
|
||||
*/
|
||||
#ifndef _WX_FS_INET_H_
|
||||
#define _WX_FS_INET_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fs_inet.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_FILESYSTEM && wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS
|
||||
|
||||
#ifndef WXPRECOMP
|
||||
#include "wx/hash.h"
|
||||
#endif
|
||||
|
||||
#include "wx/filesys.h"
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxInternetFSHandler
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxInternetFSHandler : public wxFileSystemHandler
|
||||
{
|
||||
private:
|
||||
wxHashTable m_Cache;
|
||||
|
||||
public:
|
||||
virtual bool CanOpen(const wxString& location);
|
||||
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||
~wxInternetFSHandler();
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_FILESYSTEM && wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS
|
||||
|
||||
#endif // _WX_FS_INET_H_
|
||||
|
||||
72
include/wx/fs_mem.h
Normal file
72
include/wx/fs_mem.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: fs_mem.h
|
||||
// Purpose: in-memory file system
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 2000 Vaclav Slavik
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FS_MEM_H_
|
||||
#define _WX_FS_MEM_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fs_mem.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILESYSTEM
|
||||
|
||||
#include "wx/filesys.h"
|
||||
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class WXDLLEXPORT wxImage;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxMemoryFSHandler
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxMemoryFSHandlerBase : public wxFileSystemHandler
|
||||
{
|
||||
public:
|
||||
wxMemoryFSHandlerBase();
|
||||
~wxMemoryFSHandlerBase();
|
||||
|
||||
// Add file to list of files stored in memory. Stored data (bitmap, text or
|
||||
// raw data) will be copied into private memory stream and available under
|
||||
// name "memory:" + filename
|
||||
static void AddFile(const wxString& filename, const wxString& textdata);
|
||||
static void AddFile(const wxString& filename, const void *binarydata, size_t size);
|
||||
|
||||
// Remove file from memory FS and free occupied memory
|
||||
static void RemoveFile(const wxString& filename);
|
||||
|
||||
virtual bool CanOpen(const wxString& location);
|
||||
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||
virtual wxString FindFirst(const wxString& spec, int flags = 0);
|
||||
virtual wxString FindNext();
|
||||
|
||||
protected:
|
||||
static bool CheckHash(const wxString& filename);
|
||||
static wxHashTable *m_Hash;
|
||||
};
|
||||
|
||||
class wxMemoryFSHandler : public wxMemoryFSHandlerBase
|
||||
{
|
||||
public:
|
||||
#if wxUSE_GUI
|
||||
#if wxUSE_IMAGE
|
||||
static void AddFile(const wxString& filename, wxImage& image, long type);
|
||||
#endif // wxUSE_IMAGE
|
||||
static void AddFile(const wxString& filename, const wxBitmap& bitmap, long type);
|
||||
#endif // wxUSE_GUI
|
||||
};
|
||||
|
||||
#endif // wxUSE_FILESYSTEM
|
||||
|
||||
#endif // _WX_FS_MEM_H_
|
||||
|
||||
60
include/wx/fs_zip.h
Normal file
60
include/wx/fs_zip.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: fs_zip.h
|
||||
// Purpose: ZIP file system
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// CVS-ID: $Id$
|
||||
// Licence: wxWindows Licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FS_ZIP_H_
|
||||
#define _WX_FS_ZIP_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "fs_zip.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_STREAMS
|
||||
|
||||
#include "wx/filesys.h"
|
||||
|
||||
class WXDLLEXPORT wxHashTableLong;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxZipFSHandler
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxZipFSHandler : public wxFileSystemHandler
|
||||
{
|
||||
public:
|
||||
wxZipFSHandler();
|
||||
virtual bool CanOpen(const wxString& location);
|
||||
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||
virtual wxString FindFirst(const wxString& spec, int flags = 0);
|
||||
virtual wxString FindNext();
|
||||
~wxZipFSHandler();
|
||||
|
||||
private:
|
||||
// these vars are used by FindFirst/Next:
|
||||
void *m_Archive;
|
||||
wxString m_Pattern, m_BaseDir, m_ZipFile;
|
||||
bool m_AllowDirs, m_AllowFiles;
|
||||
wxHashTableLong *m_DirsFound;
|
||||
|
||||
wxString DoFind();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxZipFSHandler)
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_STREAMS
|
||||
|
||||
#endif // _WX_FS_ZIP_H_
|
||||
|
||||
95
include/wx/gauge.h
Normal file
95
include/wx/gauge.h
Normal file
@@ -0,0 +1,95 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/gauge.h
|
||||
// Purpose: wxGauge interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 20.02.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1996-2001 wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GAUGE_H_BASE_
|
||||
#define _WX_GAUGE_H_BASE_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "gaugebase.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_GAUGE
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxGaugeNameStr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGauge: a progress bar
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxGaugeBase : public wxControl
|
||||
{
|
||||
public:
|
||||
virtual ~wxGaugeBase();
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
int range,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxGA_HORIZONTAL,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxGaugeNameStr);
|
||||
|
||||
// set/get the control range
|
||||
virtual void SetRange(int range);
|
||||
virtual int GetRange() const;
|
||||
|
||||
// position
|
||||
virtual void SetValue(int pos);
|
||||
virtual int GetValue() const;
|
||||
|
||||
// appearance params (not implemented for most ports)
|
||||
|
||||
virtual void SetShadowWidth(int w);
|
||||
virtual int GetShadowWidth() const;
|
||||
|
||||
virtual void SetBezelFace(int w);
|
||||
virtual int GetBezelFace() const;
|
||||
|
||||
// overriden base class virtuals
|
||||
virtual bool AcceptsFocus() const { return FALSE; }
|
||||
|
||||
protected:
|
||||
// the max position
|
||||
int m_rangeMax;
|
||||
|
||||
// the current position
|
||||
int m_gaugePos;
|
||||
};
|
||||
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/gauge.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#ifdef __WIN95__
|
||||
#include "wx/msw/gauge95.h"
|
||||
#define wxGauge wxGauge95
|
||||
#define sm_classwxGauge sm_classwxGauge95
|
||||
#else // !__WIN95__
|
||||
// Gauge no longer supported on 16-bit Windows
|
||||
#endif
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/gauge.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/gauge.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/gauge.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/gauge.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_GAUGE
|
||||
|
||||
#endif
|
||||
// _WX_GAUGE_H_BASE_
|
||||
566
include/wx/gdicmn.h
Normal file
566
include/wx/gdicmn.h
Normal file
@@ -0,0 +1,566 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: gdicmn.h
|
||||
// Purpose: Common GDI classes, types and declarations
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GDICMNH__
|
||||
#define _WX_GDICMNH__
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "gdicmn.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/fontenc.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class WXDLLEXPORT wxBrush;
|
||||
class WXDLLEXPORT wxColour;
|
||||
class WXDLLEXPORT wxCursor;
|
||||
class WXDLLEXPORT wxFont;
|
||||
class WXDLLEXPORT wxIcon;
|
||||
class WXDLLEXPORT wxPalette;
|
||||
class WXDLLEXPORT wxPen;
|
||||
class WXDLLEXPORT wxRegion;
|
||||
class WXDLLEXPORT wxString;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// constants
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Bitmap flags
|
||||
enum wxBitmapType
|
||||
{
|
||||
wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
|
||||
wxBITMAP_TYPE_BMP,
|
||||
wxBITMAP_TYPE_BMP_RESOURCE,
|
||||
wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
|
||||
wxBITMAP_TYPE_ICO,
|
||||
wxBITMAP_TYPE_ICO_RESOURCE,
|
||||
wxBITMAP_TYPE_CUR,
|
||||
wxBITMAP_TYPE_CUR_RESOURCE,
|
||||
wxBITMAP_TYPE_XBM,
|
||||
wxBITMAP_TYPE_XBM_DATA,
|
||||
wxBITMAP_TYPE_XPM,
|
||||
wxBITMAP_TYPE_XPM_DATA,
|
||||
wxBITMAP_TYPE_TIF,
|
||||
wxBITMAP_TYPE_TIF_RESOURCE,
|
||||
wxBITMAP_TYPE_GIF,
|
||||
wxBITMAP_TYPE_GIF_RESOURCE,
|
||||
wxBITMAP_TYPE_PNG,
|
||||
wxBITMAP_TYPE_PNG_RESOURCE,
|
||||
wxBITMAP_TYPE_JPEG,
|
||||
wxBITMAP_TYPE_JPEG_RESOURCE,
|
||||
wxBITMAP_TYPE_PNM,
|
||||
wxBITMAP_TYPE_PNM_RESOURCE,
|
||||
wxBITMAP_TYPE_PCX,
|
||||
wxBITMAP_TYPE_PCX_RESOURCE,
|
||||
wxBITMAP_TYPE_PICT,
|
||||
wxBITMAP_TYPE_PICT_RESOURCE,
|
||||
wxBITMAP_TYPE_ICON,
|
||||
wxBITMAP_TYPE_ICON_RESOURCE,
|
||||
wxBITMAP_TYPE_ANI,
|
||||
wxBITMAP_TYPE_IFF,
|
||||
wxBITMAP_TYPE_MACCURSOR,
|
||||
wxBITMAP_TYPE_MACCURSOR_RESOURCE,
|
||||
wxBITMAP_TYPE_ANY = 50
|
||||
};
|
||||
|
||||
// Standard cursors
|
||||
enum wxStockCursor
|
||||
{
|
||||
wxCURSOR_NONE, // should be 0
|
||||
wxCURSOR_ARROW,
|
||||
wxCURSOR_RIGHT_ARROW,
|
||||
wxCURSOR_BULLSEYE,
|
||||
wxCURSOR_CHAR,
|
||||
wxCURSOR_CROSS,
|
||||
wxCURSOR_HAND,
|
||||
wxCURSOR_IBEAM,
|
||||
wxCURSOR_LEFT_BUTTON,
|
||||
wxCURSOR_MAGNIFIER,
|
||||
wxCURSOR_MIDDLE_BUTTON,
|
||||
wxCURSOR_NO_ENTRY,
|
||||
wxCURSOR_PAINT_BRUSH,
|
||||
wxCURSOR_PENCIL,
|
||||
wxCURSOR_POINT_LEFT,
|
||||
wxCURSOR_POINT_RIGHT,
|
||||
wxCURSOR_QUESTION_ARROW,
|
||||
wxCURSOR_RIGHT_BUTTON,
|
||||
wxCURSOR_SIZENESW,
|
||||
wxCURSOR_SIZENS,
|
||||
wxCURSOR_SIZENWSE,
|
||||
wxCURSOR_SIZEWE,
|
||||
wxCURSOR_SIZING,
|
||||
wxCURSOR_SPRAYCAN,
|
||||
wxCURSOR_WAIT,
|
||||
wxCURSOR_WATCH,
|
||||
wxCURSOR_BLANK,
|
||||
#ifdef __WXGTK__
|
||||
wxCURSOR_DEFAULT, // standard X11 cursor
|
||||
#endif
|
||||
#ifdef __WXMAC__
|
||||
wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
|
||||
#endif
|
||||
#ifdef __X__
|
||||
// Not yet implemented for Windows
|
||||
wxCURSOR_CROSS_REVERSE,
|
||||
wxCURSOR_DOUBLE_ARROW,
|
||||
wxCURSOR_BASED_ARROW_UP,
|
||||
wxCURSOR_BASED_ARROW_DOWN,
|
||||
#endif // X11
|
||||
|
||||
wxCURSOR_ARROWWAIT,
|
||||
|
||||
wxCURSOR_MAX
|
||||
};
|
||||
|
||||
#ifndef __WXGTK__
|
||||
#define wxCURSOR_DEFAULT wxCURSOR_ARROW
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// macros
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* Useful macro for creating icons portably, for example:
|
||||
|
||||
wxIcon *icon = new wxICON(mondrian);
|
||||
|
||||
expands into:
|
||||
|
||||
wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
|
||||
wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
|
||||
*/
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Load from a resource
|
||||
#define wxICON(X) wxIcon(wxT(#X))
|
||||
#elif defined(__WXPM__)
|
||||
// Load from a resource
|
||||
#define wxICON(X) wxIcon(wxT(#X))
|
||||
#elif defined(__WXMGL__)
|
||||
// Initialize from an included XPM
|
||||
#define wxICON(X) wxIcon( (const char**) X##_xpm )
|
||||
#elif defined(__WXGTK__)
|
||||
// Initialize from an included XPM
|
||||
#define wxICON(X) wxIcon( (const char**) X##_xpm )
|
||||
#elif defined(__WXMAC__)
|
||||
// Initialize from an included XPM
|
||||
#define wxICON(X) wxIcon( (const char**) X##_xpm )
|
||||
#elif defined(__WXMOTIF__)
|
||||
// Initialize from an included XPM
|
||||
#define wxICON(X) wxIcon( X##_xpm )
|
||||
#elif defined(__WXX11__)
|
||||
// Initialize from an included XPM
|
||||
#define wxICON(X) wxIcon( X##_xpm )
|
||||
#else
|
||||
// This will usually mean something on any platform
|
||||
#define wxICON(X) wxIcon(wxT(#X))
|
||||
#endif // platform
|
||||
|
||||
/* Another macro: this one is for portable creation of bitmaps. We assume that
|
||||
under Unix bitmaps live in XPMs and under Windows they're in ressources.
|
||||
*/
|
||||
|
||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
||||
#define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE)
|
||||
#elif defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__) || defined(__WXMAC__) || defined(__WXMGL__)
|
||||
// Initialize from an included XPM
|
||||
#define wxBITMAP(name) wxBitmap( (const char**) name##_xpm )
|
||||
#else // other platforms
|
||||
#define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM)
|
||||
#endif // platform
|
||||
|
||||
// ===========================================================================
|
||||
// classes
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxSize
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxSize
|
||||
{
|
||||
public:
|
||||
// members are public for compatibility, don't use them directly.
|
||||
int x, y;
|
||||
|
||||
// constructors
|
||||
wxSize() : x(0), y(0) { }
|
||||
wxSize(int xx, int yy) : x(xx), y(yy) { }
|
||||
|
||||
// no copy ctor or assignment operator - the defaults are ok
|
||||
|
||||
bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; }
|
||||
bool operator!=(const wxSize& sz) const { return x != sz.x || y != sz.y; }
|
||||
|
||||
// FIXME are these really useful? If they're, we should have += &c as well
|
||||
wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
|
||||
wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
|
||||
|
||||
// accessors
|
||||
void Set(int xx, int yy) { x = xx; y = yy; }
|
||||
void SetWidth(int w) { x = w; }
|
||||
void SetHeight(int h) { y = h; }
|
||||
|
||||
int GetWidth() const { return x; }
|
||||
int GetHeight() const { return y; }
|
||||
|
||||
// compatibility
|
||||
int GetX() const { return x; }
|
||||
int GetY() const { return y; }
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Point classes: with real or integer coordinates
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxRealPoint
|
||||
{
|
||||
public:
|
||||
double x;
|
||||
double y;
|
||||
|
||||
wxRealPoint() : x(0.0), y(0.0) { }
|
||||
wxRealPoint(double xx, double yy) : x(xx), y(yy) { }
|
||||
|
||||
wxRealPoint operator+(const wxRealPoint& pt) const { return wxRealPoint(x + pt.x, y + pt.y); }
|
||||
wxRealPoint operator-(const wxRealPoint& pt) const { return wxRealPoint(x - pt.x, y - pt.y); }
|
||||
|
||||
bool operator==(const wxRealPoint& pt) const { return x == pt.x && y == pt.y; }
|
||||
bool operator!=(const wxRealPoint& pt) const { return x != pt.x || y != pt.y; }
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxPoint
|
||||
{
|
||||
public:
|
||||
int x, y;
|
||||
|
||||
wxPoint() : x(0), y(0) { }
|
||||
wxPoint(int xx, int yy) : x(xx), y(yy) { }
|
||||
|
||||
// no copy ctor or assignment operator - the defaults are ok
|
||||
|
||||
// comparison
|
||||
bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; }
|
||||
bool operator!=(const wxPoint& p) const { return !(*this == p); }
|
||||
|
||||
// arithmetic operations (component wise)
|
||||
wxPoint operator+(const wxPoint& p) const { return wxPoint(x + p.x, y + p.y); }
|
||||
wxPoint operator-(const wxPoint& p) const { return wxPoint(x - p.x, y - p.y); }
|
||||
|
||||
wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; }
|
||||
wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; }
|
||||
};
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
#define wxIntPoint wxPoint
|
||||
#define wxRectangle wxRect
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxRect
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxRect
|
||||
{
|
||||
public:
|
||||
wxRect()
|
||||
: x(0), y(0), width(0), height(0)
|
||||
{ }
|
||||
wxRect(int xx, int yy, int ww, int hh)
|
||||
: x(xx), y(yy), width(ww), height(hh)
|
||||
{ }
|
||||
wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
|
||||
wxRect(const wxPoint& pos, const wxSize& size);
|
||||
|
||||
// default copy ctor and assignment operators ok
|
||||
|
||||
int GetX() const { return x; }
|
||||
void SetX(int xx) { x = xx; }
|
||||
|
||||
int GetY() const { return y; }
|
||||
void SetY(int yy) { y = yy; }
|
||||
|
||||
int GetWidth() const { return width; }
|
||||
void SetWidth(int w) { width = w; }
|
||||
|
||||
int GetHeight() const { return height; }
|
||||
void SetHeight(int h) { height = h; }
|
||||
|
||||
wxPoint GetPosition() const { return wxPoint(x, y); }
|
||||
void SetPosition( const wxPoint &p ) { x = p.x; y = p.y; }
|
||||
|
||||
wxSize GetSize() const { return wxSize(width, height); }
|
||||
void SetSize( const wxSize &s ) { width = s.GetWidth(); height = s.GetHeight(); }
|
||||
|
||||
int GetLeft() const { return x; }
|
||||
int GetTop() const { return y; }
|
||||
int GetBottom() const { return y + height - 1; }
|
||||
int GetRight() const { return x + width - 1; }
|
||||
|
||||
void SetLeft(int left) { x = left; }
|
||||
void SetRight(int right) { width = right - x + 1; }
|
||||
void SetTop(int top) { y = top; }
|
||||
void SetBottom(int bottom) { height = bottom - y + 1; }
|
||||
|
||||
// operations with rect
|
||||
wxRect& Inflate(wxCoord dx, wxCoord dy);
|
||||
wxRect& Inflate(wxCoord d) { return Inflate(d, d); }
|
||||
wxRect Inflate(wxCoord dx, wxCoord dy) const
|
||||
{
|
||||
wxRect r = *this;
|
||||
r.Inflate(dx, dy);
|
||||
return r;
|
||||
}
|
||||
|
||||
wxRect& Deflate(wxCoord dx, wxCoord dy) { return Inflate(-dx, -dy); }
|
||||
wxRect& Deflate(wxCoord d) { return Inflate(-d); }
|
||||
wxRect Deflate(wxCoord dx, wxCoord dy) const
|
||||
{
|
||||
wxRect r = *this;
|
||||
r.Deflate(dx, dy);
|
||||
return r;
|
||||
}
|
||||
|
||||
void Offset(wxCoord dx, wxCoord dy) { x += dx; y += dy; }
|
||||
void Offset(const wxPoint& pt) { Offset(pt.x, pt.y); }
|
||||
|
||||
wxRect& Intersect(const wxRect& rect);
|
||||
wxRect Intersect(const wxRect& rect) const
|
||||
{
|
||||
wxRect r = *this;
|
||||
r.Intersect(rect);
|
||||
return r;
|
||||
}
|
||||
|
||||
wxRect operator+(const wxRect& rect) const;
|
||||
wxRect& operator+=(const wxRect& rect);
|
||||
|
||||
// compare rectangles
|
||||
bool operator==(const wxRect& rect) const;
|
||||
bool operator!=(const wxRect& rect) const { return !(*this == rect); }
|
||||
|
||||
// return TRUE if the point is (not strcitly) inside the rect
|
||||
bool Inside(int x, int y) const;
|
||||
bool Inside(const wxPoint& pt) const { return Inside(pt.x, pt.y); }
|
||||
|
||||
// return TRUE if the rectangles have a non empty intersection
|
||||
bool Intersects(const wxRect& rect) const;
|
||||
|
||||
public:
|
||||
int x, y, width, height;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Management of pens, brushes and fonts
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef wxInt8 wxDash;
|
||||
|
||||
class WXDLLEXPORT wxPenList : public wxList
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxPenList)
|
||||
|
||||
public:
|
||||
wxPenList() { }
|
||||
~wxPenList();
|
||||
|
||||
void AddPen(wxPen *pen);
|
||||
void RemovePen(wxPen *pen);
|
||||
wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxBrushList : public wxList
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBrushList)
|
||||
|
||||
public:
|
||||
wxBrushList() { }
|
||||
~wxBrushList();
|
||||
|
||||
void AddBrush(wxBrush *brush);
|
||||
void RemoveBrush(wxBrush *brush);
|
||||
wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
|
||||
};
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
class WXDLLEXPORT wxFontList : public wxList
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxFontList)
|
||||
|
||||
public:
|
||||
wxFontList() { }
|
||||
~wxFontList();
|
||||
|
||||
void AddFont(wxFont *font);
|
||||
void RemoveFont(wxFont *font);
|
||||
wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
|
||||
bool underline = FALSE,
|
||||
const wxString& face = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxColourDatabase : public wxList
|
||||
{
|
||||
DECLARE_CLASS(wxColourDatabase)
|
||||
|
||||
public:
|
||||
wxColourDatabase(int type);
|
||||
~wxColourDatabase() ;
|
||||
|
||||
// Not const because it may add a name to the database
|
||||
wxColour *FindColour(const wxString& colour) ;
|
||||
wxString FindName(const wxColour& colour) const;
|
||||
void Initialize();
|
||||
#ifdef __WXPM__
|
||||
// PM keeps its own type of colour table
|
||||
long* m_palTable;
|
||||
size_t m_nSize;
|
||||
#endif
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxBitmapList : public wxList
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmapList)
|
||||
|
||||
public:
|
||||
wxBitmapList();
|
||||
~wxBitmapList();
|
||||
|
||||
void AddBitmap(wxBitmap *bitmap);
|
||||
void RemoveBitmap(wxBitmap *bitmap);
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxResourceCache: public wxList
|
||||
{
|
||||
public:
|
||||
wxResourceCache() { }
|
||||
wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
|
||||
~wxResourceCache();
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxResourceCache)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global variables
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Lists of GDI objects
|
||||
WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
|
||||
WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
|
||||
WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
|
||||
WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
|
||||
|
||||
// Stock objects
|
||||
WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
|
||||
WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
|
||||
WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
|
||||
WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
|
||||
WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
|
||||
WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxRED;
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
|
||||
WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
|
||||
|
||||
// 'Null' objects
|
||||
WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
|
||||
WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
|
||||
WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
|
||||
WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
|
||||
WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
|
||||
WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
|
||||
WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
|
||||
WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
|
||||
|
||||
// Stock cursors types
|
||||
WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
|
||||
WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
|
||||
WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
|
||||
WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
|
||||
|
||||
// The list of objects which should be deleted
|
||||
WXDLLEXPORT_DATA(extern wxList) wxPendingDelete;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// resource management
|
||||
extern void WXDLLEXPORT wxInitializeStockObjects();
|
||||
extern void WXDLLEXPORT wxInitializeStockLists();
|
||||
extern void WXDLLEXPORT wxDeleteStockObjects();
|
||||
extern void WXDLLEXPORT wxDeleteStockLists();
|
||||
|
||||
// is the display colour (or monochrome)?
|
||||
extern bool WXDLLEXPORT wxColourDisplay();
|
||||
|
||||
// Returns depth of screen
|
||||
extern int WXDLLEXPORT wxDisplayDepth();
|
||||
#define wxGetDisplayDepth wxDisplayDepth
|
||||
|
||||
// get the display size
|
||||
extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
|
||||
extern wxSize WXDLLEXPORT wxGetDisplaySize();
|
||||
extern void WXDLLEXPORT wxDisplaySizeMM(int *width, int *height);
|
||||
extern wxSize WXDLLEXPORT wxGetDisplaySizeMM();
|
||||
|
||||
// Get position and size of the display workarea
|
||||
extern void WXDLLEXPORT wxClientDisplayRect(int *x, int *y, int *width, int *height);
|
||||
extern wxRect WXDLLEXPORT wxGetClientDisplayRect();
|
||||
|
||||
// set global cursor
|
||||
extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
|
||||
|
||||
#endif
|
||||
// _WX_GDICMNH__
|
||||
23
include/wx/gdiobj.h
Normal file
23
include/wx/gdiobj.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _WX_GDIOBJ_H_BASE_
|
||||
#define _WX_GDIOBJ_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/gdiobj.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/gdiobj.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/gdiobj.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/gdiobj.h"
|
||||
#elif defined(__WXMGL__)
|
||||
#include "wx/mgl/gdiobj.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/gdiobj.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/gdiobj.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/gdiobj.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_GDIOBJ_H_BASE_
|
||||
2
include/wx/generic/.cvsignore
Normal file
2
include/wx/generic/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile.in
|
||||
|
||||
64
include/wx/generic/accel.h
Normal file
64
include/wx/generic/accel.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/accel.h
|
||||
// Purpose: wxAcceleratorTable class
|
||||
// Author: Robert Roebling
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GENERIC_ACCEL_H_
|
||||
#define _WX_GENERIC_ACCEL_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "accel.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxKeyEvent;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAcceleratorTable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxAcceleratorTable : public wxObject
|
||||
{
|
||||
public:
|
||||
wxAcceleratorTable();
|
||||
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
|
||||
virtual ~wxAcceleratorTable();
|
||||
|
||||
wxAcceleratorTable(const wxAcceleratorTable& accel)
|
||||
: wxObject()
|
||||
{ Ref(accel); }
|
||||
wxAcceleratorTable& operator=(const wxAcceleratorTable& accel)
|
||||
{ if ( m_refData != accel.m_refData ) Ref(accel); return *this; }
|
||||
|
||||
bool operator==(const wxAcceleratorTable& accel) const
|
||||
{ return m_refData == accel.m_refData; } // FIXME: this is wrong (VZ)
|
||||
bool operator!=(const wxAcceleratorTable& accel) const
|
||||
{ return !(*this == accel); }
|
||||
|
||||
bool Ok() const;
|
||||
|
||||
void Add(const wxAcceleratorEntry& entry);
|
||||
void Remove(const wxAcceleratorEntry& entry);
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
wxMenuItem *GetMenuItem(const wxKeyEvent& event) const;
|
||||
int GetCommand(const wxKeyEvent& event) const;
|
||||
|
||||
const wxAcceleratorEntry *GetEntry(const wxKeyEvent& event) const;
|
||||
|
||||
protected:
|
||||
// ref counting code
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
|
||||
};
|
||||
|
||||
#endif // _WX_GENERIC_ACCEL_H_
|
||||
|
||||
308
include/wx/generic/calctrl.h
Normal file
308
include/wx/generic/calctrl.h
Normal file
@@ -0,0 +1,308 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: generic/calctrl.h
|
||||
// Purpose: generic implementation of date-picker control
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 29.12.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "calctrl.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_GENERIC_CALCTRL_H
|
||||
#define _WX_GENERIC_CALCTRL_H
|
||||
|
||||
#include "wx/control.h" // the base class
|
||||
#include "wx/dcclient.h" // for wxPaintDC
|
||||
|
||||
class WXDLLEXPORT wxComboBox;
|
||||
class WXDLLEXPORT wxStaticText;
|
||||
class WXDLLEXPORT wxSpinCtrl;
|
||||
|
||||
#define wxCalendarNameStr _T("CalendarCtrl")
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxCalendarCtrl: a control allowing the user to pick a date interactively
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxCalendarCtrl : public wxControl
|
||||
{
|
||||
friend class wxMonthComboBox;
|
||||
friend class wxYearSpinCtrl;
|
||||
|
||||
public:
|
||||
// construction
|
||||
wxCalendarCtrl() { Init(); }
|
||||
wxCalendarCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxDateTime& date = wxDefaultDateTime,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
|
||||
const wxString& name = wxCalendarNameStr);
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxDateTime& date = wxDefaultDateTime,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
|
||||
const wxString& name = wxCalendarNameStr);
|
||||
|
||||
virtual ~wxCalendarCtrl();
|
||||
|
||||
virtual bool Destroy();
|
||||
|
||||
// set/get the current date
|
||||
// ------------------------
|
||||
|
||||
bool SetDate(const wxDateTime& date); // we need to be able to control if the event should be sent in SetDateAndNotify(...)
|
||||
const wxDateTime& GetDate() const { return m_date; }
|
||||
|
||||
// set/get the range in which selection can occur
|
||||
// ---------------------------------------------
|
||||
|
||||
bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
|
||||
const wxDateTime& GetLowerDateLimit() const { return m_lowdate; }
|
||||
bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
|
||||
const wxDateTime& GetUpperDateLimit() const { return m_highdate; }
|
||||
|
||||
bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, const wxDateTime& upperdate = wxDefaultDateTime);
|
||||
|
||||
// calendar mode
|
||||
// -------------
|
||||
|
||||
// some calendar styles can't be changed after the control creation by
|
||||
// just using SetWindowStyle() and Refresh() and the functions below
|
||||
// should be used instead for them
|
||||
|
||||
// corresponds to wxCAL_NO_YEAR_CHANGE bit
|
||||
void EnableYearChange(bool enable = TRUE);
|
||||
|
||||
// corresponds to wxCAL_NO_MONTH_CHANGE bit
|
||||
void EnableMonthChange(bool enable = TRUE);
|
||||
|
||||
// corresponds to wxCAL_SHOW_HOLIDAYS bit
|
||||
void EnableHolidayDisplay(bool display = TRUE);
|
||||
|
||||
// customization
|
||||
// -------------
|
||||
|
||||
// header colours are used for painting the weekdays at the top
|
||||
void SetHeaderColours(const wxColour& colFg, const wxColour& colBg)
|
||||
{
|
||||
m_colHeaderFg = colFg;
|
||||
m_colHeaderBg = colBg;
|
||||
}
|
||||
|
||||
const wxColour& GetHeaderColourFg() const { return m_colHeaderFg; }
|
||||
const wxColour& GetHeaderColourBg() const { return m_colHeaderBg; }
|
||||
|
||||
// highlight colour is used for the currently selected date
|
||||
void SetHighlightColours(const wxColour& colFg, const wxColour& colBg)
|
||||
{
|
||||
m_colHighlightFg = colFg;
|
||||
m_colHighlightBg = colBg;
|
||||
}
|
||||
|
||||
const wxColour& GetHighlightColourFg() const { return m_colHighlightFg; }
|
||||
const wxColour& GetHighlightColourBg() const { return m_colHighlightBg; }
|
||||
|
||||
// holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
|
||||
void SetHolidayColours(const wxColour& colFg, const wxColour& colBg)
|
||||
{
|
||||
m_colHolidayFg = colFg;
|
||||
m_colHolidayBg = colBg;
|
||||
}
|
||||
|
||||
const wxColour& GetHolidayColourFg() const { return m_colHolidayFg; }
|
||||
const wxColour& GetHolidayColourBg() const { return m_colHolidayBg; }
|
||||
|
||||
// an item without custom attributes is drawn with the default colours and
|
||||
// font and without border, setting custom attributes allows to modify this
|
||||
//
|
||||
// the day parameter should be in 1..31 range, for days 29, 30, 31 the
|
||||
// corresponding attribute is just unused if there is no such day in the
|
||||
// current month
|
||||
|
||||
wxCalendarDateAttr *GetAttr(size_t day) const
|
||||
{
|
||||
wxCHECK_MSG( day > 0 && day < 32, NULL, _T("invalid day") );
|
||||
|
||||
return m_attrs[day - 1];
|
||||
}
|
||||
|
||||
void SetAttr(size_t day, wxCalendarDateAttr *attr)
|
||||
{
|
||||
wxCHECK_RET( day > 0 && day < 32, _T("invalid day") );
|
||||
|
||||
delete m_attrs[day - 1];
|
||||
m_attrs[day - 1] = attr;
|
||||
}
|
||||
|
||||
void SetHoliday(size_t day);
|
||||
|
||||
void ResetAttr(size_t day) { SetAttr(day, (wxCalendarDateAttr *)NULL); }
|
||||
|
||||
// returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
|
||||
// with the corresponding value (none for NOWHERE, the date for DAY and wd
|
||||
// for HEADER)
|
||||
wxCalendarHitTestResult HitTest(const wxPoint& pos,
|
||||
wxDateTime *date = NULL,
|
||||
wxDateTime::WeekDay *wd = NULL);
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// forward these functions to all subcontrols
|
||||
virtual bool Enable(bool enable = TRUE);
|
||||
virtual bool Show(bool show = TRUE);
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// event handlers
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnClick(wxMouseEvent& event);
|
||||
void OnDClick(wxMouseEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnMonthChange(wxCommandEvent& event);
|
||||
void OnYearChange(wxCommandEvent& event);
|
||||
|
||||
// override some base class virtuals
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
virtual void DoGetPosition(int *x, int *y) const;
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
|
||||
// (re)calc m_widthCol and m_heightRow
|
||||
void RecalcGeometry();
|
||||
|
||||
// set the date and send the notification
|
||||
void SetDateAndNotify(const wxDateTime& date);
|
||||
|
||||
// get the week (row, in range 1..6) for the given date
|
||||
size_t GetWeek(const wxDateTime& date) const;
|
||||
|
||||
// get the date from which we start drawing days
|
||||
wxDateTime GetStartDate() const;
|
||||
|
||||
// is this date shown?
|
||||
bool IsDateShown(const wxDateTime& date) const;
|
||||
|
||||
// is this date in the given range?
|
||||
bool IsDateInRange(const wxDateTime& date) const;
|
||||
|
||||
// range helpers
|
||||
bool ChangeYear(wxDateTime* target) const;
|
||||
bool ChangeMonth(wxDateTime* target) const;
|
||||
|
||||
// redraw the given date
|
||||
void RefreshDate(const wxDateTime& date);
|
||||
|
||||
// change the date inside the same month/year
|
||||
void ChangeDay(const wxDateTime& date);
|
||||
|
||||
// set the attributes for the holidays if needed
|
||||
void SetHolidayAttrs();
|
||||
|
||||
// reset all holidays
|
||||
void ResetHolidayAttrs();
|
||||
|
||||
// generate the given calendar event(s)
|
||||
void GenerateEvent(wxEventType type)
|
||||
{
|
||||
wxCalendarEvent event(this, type);
|
||||
(void)GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
void GenerateEvents(wxEventType type1, wxEventType type2)
|
||||
{
|
||||
GenerateEvent(type1);
|
||||
GenerateEvent(type2);
|
||||
}
|
||||
|
||||
// do we allow changing the month/year?
|
||||
bool AllowMonthChange() const
|
||||
{
|
||||
return (GetWindowStyle() & wxCAL_NO_MONTH_CHANGE)
|
||||
!= wxCAL_NO_MONTH_CHANGE;
|
||||
}
|
||||
bool AllowYearChange() const
|
||||
{
|
||||
return !(GetWindowStyle() & wxCAL_NO_YEAR_CHANGE);
|
||||
}
|
||||
|
||||
// show the correct controls
|
||||
void ShowCurrentControls();
|
||||
|
||||
// get the currently shown control for month/year
|
||||
wxControl *GetMonthControl() const;
|
||||
wxControl *GetYearControl() const;
|
||||
|
||||
// OnPaint helper-methods
|
||||
|
||||
// Highlight the [fromdate : todate] range using pen and brush
|
||||
void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, wxPen* pen, wxBrush* brush);
|
||||
|
||||
// Get the "coordinates" for the date relative to the month currently displayed.
|
||||
// using (day, week): upper left coord is (1, 1), lower right coord is (7, 6)
|
||||
// if the date isn't visible (-1, -1) is put in (day, week) and false is returned
|
||||
bool GetDateCoord(const wxDateTime& date, int *day, int *week) const;
|
||||
|
||||
// Set the flag for SetDate(): otherwise it would overwrite the year
|
||||
// typed in by the user
|
||||
void SetUserChangedYear() { m_userChangedYear = TRUE; }
|
||||
|
||||
// the subcontrols
|
||||
wxStaticText *m_staticMonth;
|
||||
wxComboBox *m_comboMonth;
|
||||
|
||||
wxStaticText *m_staticYear;
|
||||
wxSpinCtrl *m_spinYear;
|
||||
|
||||
// the current selection
|
||||
wxDateTime m_date;
|
||||
|
||||
// the date-range
|
||||
wxDateTime m_lowdate;
|
||||
wxDateTime m_highdate;
|
||||
|
||||
// default attributes
|
||||
wxColour m_colHighlightFg,
|
||||
m_colHighlightBg,
|
||||
m_colHolidayFg,
|
||||
m_colHolidayBg,
|
||||
m_colHeaderFg,
|
||||
m_colHeaderBg;
|
||||
|
||||
// the attributes for each of the month days
|
||||
wxCalendarDateAttr *m_attrs[31];
|
||||
|
||||
// the width and height of one column/row in the calendar
|
||||
wxCoord m_widthCol,
|
||||
m_heightRow,
|
||||
m_rowOffset;
|
||||
|
||||
wxRect m_leftArrowRect,
|
||||
m_rightArrowRect;
|
||||
|
||||
// the week day names
|
||||
wxString m_weekdays[7];
|
||||
|
||||
// TRUE if SetDate() is being called as the result of changing the year in
|
||||
// the year control
|
||||
bool m_userChangedYear;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxCalendarCtrl)
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxCalendarCtrl)
|
||||
};
|
||||
|
||||
#endif // _WX_GENERIC_CALCTRL_H
|
||||
87
include/wx/generic/caret.h
Normal file
87
include/wx/generic/caret.h
Normal file
@@ -0,0 +1,87 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: generic/caret.h
|
||||
// Purpose: generic wxCaret class
|
||||
// Author: Vadim Zeitlin (original code by Robert Roebling)
|
||||
// Modified by:
|
||||
// Created: 25.05.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_CARET_H_
|
||||
#define _WX_CARET_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "caret.h"
|
||||
#endif
|
||||
|
||||
#include "wx/timer.h"
|
||||
|
||||
class wxCaret;
|
||||
|
||||
class WXDLLEXPORT wxCaretTimer : public wxTimer
|
||||
{
|
||||
public:
|
||||
wxCaretTimer(wxCaret *caret);
|
||||
virtual void Notify();
|
||||
|
||||
private:
|
||||
wxCaret *m_caret;
|
||||
};
|
||||
|
||||
class wxCaret : public wxCaretBase
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
// -----
|
||||
// default - use Create()
|
||||
wxCaret() : m_timer(this) { InitGeneric(); }
|
||||
// creates a block caret associated with the given window
|
||||
wxCaret(wxWindowBase *window, int width, int height)
|
||||
: wxCaretBase(window, width, height), m_timer(this) { InitGeneric(); }
|
||||
wxCaret(wxWindowBase *window, const wxSize& size)
|
||||
: wxCaretBase(window, size), m_timer(this) { InitGeneric(); }
|
||||
|
||||
virtual ~wxCaret();
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// called by wxWindow (not using the event tables)
|
||||
virtual void OnSetFocus();
|
||||
virtual void OnKillFocus();
|
||||
|
||||
// called by wxCaretTimer
|
||||
void OnTimer();
|
||||
|
||||
protected:
|
||||
virtual void DoShow();
|
||||
virtual void DoHide();
|
||||
virtual void DoMove();
|
||||
|
||||
// blink the caret once
|
||||
void Blink();
|
||||
|
||||
// refresh the caret
|
||||
void Refresh();
|
||||
|
||||
// draw the caret on the given DC
|
||||
void DoDraw(wxDC *dc);
|
||||
|
||||
private:
|
||||
// GTK specific initialization
|
||||
void InitGeneric();
|
||||
|
||||
// the bitmap holding the part of window hidden by the caret when it was
|
||||
// at (m_xOld, m_yOld)
|
||||
wxBitmap m_bmpUnderCaret;
|
||||
int m_xOld,
|
||||
m_yOld;
|
||||
|
||||
wxCaretTimer m_timer;
|
||||
bool m_blinkedOut, // TRUE => caret hidden right now
|
||||
m_hasFocus; // TRUE => our window has focus
|
||||
};
|
||||
|
||||
#endif // _WX_CARET_H_
|
||||
313
include/wx/generic/choicdgg.h
Normal file
313
include/wx/generic/choicdgg.h
Normal file
@@ -0,0 +1,313 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/choicdgg.h
|
||||
// Purpose: Generic choice dialogs
|
||||
// Author: Julian Smart
|
||||
// Modified by: 03.11.00: VZ to add wxArrayString and multiple sel functions
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __CHOICEDLGH_G__
|
||||
#define __CHOICEDLGH_G__
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "choicdgg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/dialog.h"
|
||||
|
||||
class WXDLLEXPORT wxListBox;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// some (ugly...) constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxCHOICE_HEIGHT 150
|
||||
#define wxCHOICE_WIDTH 200
|
||||
|
||||
#define wxCHOICEDLG_STYLE \
|
||||
(wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnyChoiceDialog: a base class for dialogs containing a listbox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxAnyChoiceDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
wxAnyChoiceDialog() { }
|
||||
|
||||
wxAnyChoiceDialog(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, const wxString *choices,
|
||||
long styleDlg = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
long styleLbox = wxLB_ALWAYS_SB)
|
||||
{
|
||||
(void)Create(parent, message, caption, n, choices,
|
||||
styleDlg, pos, styleLbox);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, const wxString *choices,
|
||||
long styleDlg = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
long styleLbox = wxLB_ALWAYS_SB);
|
||||
|
||||
protected:
|
||||
wxListBox *m_listbox;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxAnyChoiceDialog)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxSingleChoiceDialog: a dialog with single selection listbox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxSingleChoiceDialog : public wxAnyChoiceDialog
|
||||
{
|
||||
public:
|
||||
wxSingleChoiceDialog()
|
||||
{
|
||||
m_selection = -1;
|
||||
}
|
||||
|
||||
wxSingleChoiceDialog(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n,
|
||||
const wxString *choices,
|
||||
char **clientData = (char **)NULL,
|
||||
long style = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n,
|
||||
const wxString *choices,
|
||||
char **clientData = (char **)NULL,
|
||||
long style = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
|
||||
void SetSelection(int sel);
|
||||
int GetSelection() const { return m_selection; }
|
||||
wxString GetStringSelection() const { return m_stringSelection; }
|
||||
|
||||
// obsolete function (NB: no need to make it return wxChar, it's untyped)
|
||||
char *GetSelectionClientData() const { return (char *)m_clientData; }
|
||||
|
||||
// implementation from now on
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnListBoxDClick(wxCommandEvent& event);
|
||||
|
||||
// old, deprecated methods
|
||||
#if WXWIN_COMPATIBILITY_2
|
||||
wxSingleChoiceDialog(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
const wxStringList& choices,
|
||||
char **clientData = (char **)NULL,
|
||||
long style = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
const wxStringList& choices,
|
||||
char **clientData = (char **)NULL,
|
||||
long style = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
#endif // WXWIN_COMPATIBILITY_2
|
||||
|
||||
protected:
|
||||
int m_selection;
|
||||
wxString m_stringSelection;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMultiChoiceDialog: a dialog with multi selection listbox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxMultiChoiceDialog : public wxAnyChoiceDialog
|
||||
{
|
||||
public:
|
||||
wxMultiChoiceDialog() { }
|
||||
|
||||
wxMultiChoiceDialog(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n,
|
||||
const wxString *choices,
|
||||
long style = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition)
|
||||
{
|
||||
(void)Create(parent, message, caption, n, choices, style, pos);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n,
|
||||
const wxString *choices,
|
||||
long style = wxCHOICEDLG_STYLE,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
|
||||
void SetSelections(const wxArrayInt& selections);
|
||||
wxArrayInt GetSelections() const { return m_selections; }
|
||||
|
||||
// implementation from now on
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
protected:
|
||||
wxArrayInt m_selections;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMultiChoiceDialog)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wrapper functions which can be used to get selection(s) from the user
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// get the user selection as a string
|
||||
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
||||
const wxString& caption,
|
||||
const wxArrayString& choices,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, const wxString *choices,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
// Same as above but gets position in list of strings, instead of string,
|
||||
// or -1 if no selection
|
||||
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
||||
const wxString& caption,
|
||||
const wxArrayString& choices,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, const wxString *choices,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
// Return client data instead or NULL if cancelled
|
||||
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
|
||||
const wxString& caption,
|
||||
const wxArrayString& choices,
|
||||
void **client_data,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1, int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, const wxString *choices,
|
||||
void **client_data,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1, int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
// fill the array with the indices of the chosen items, it will be empty
|
||||
// if no items were selected or Cancel was pressed - return the number of
|
||||
// selections
|
||||
WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, const wxString *choices,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
WXDLLEXPORT size_t wxGetMultipleChoices(wxArrayInt& selections,
|
||||
const wxString& message,
|
||||
const wxString& caption,
|
||||
const wxArrayString& choices,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// these methods are for backwards compatibility only, not documented and
|
||||
// deprecated
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2
|
||||
|
||||
WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, wxChar *choices[],
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, wxChar *choices[],
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
WXDLLEXPORT void* wxGetSingleChoiceData(const wxString& message,
|
||||
const wxString& caption,
|
||||
int n, wxChar **choices,
|
||||
void **client_data,
|
||||
wxWindow *parent = (wxWindow *) NULL,
|
||||
int x = -1, int y = -1,
|
||||
bool centre = TRUE,
|
||||
int width = wxCHOICE_WIDTH,
|
||||
int height = wxCHOICE_HEIGHT);
|
||||
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2
|
||||
|
||||
#endif // __CHOICEDLGH_G__
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user