1. new wxList code
2. fixes to allow compilation at -W4 with VisualC++ 6.0 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
621793f45e
commit
fd3f686c27
@ -41,9 +41,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Eliminate double/float warnings
|
||||
// suppress some Visual C++ warnings
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable:4244)
|
||||
# pragma warning(disable:4244) // cobversion from double to float
|
||||
# pragma warning(disable:4100) // unreferenced formal parameter
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -368,7 +368,7 @@ private: \
|
||||
|
||||
@memo declare list class 'name' containing elements of type 'T'
|
||||
*/
|
||||
#define WX_DECLARE_LIST(T, name) typedef T _L##name; \
|
||||
#define WX_DECLARE_OBJARRAY(T, name) typedef T _L##name; \
|
||||
_WX_DECLARE_LIST(_L##name, name)
|
||||
/**
|
||||
To use a list class you must
|
||||
@ -387,7 +387,7 @@ private: \
|
||||
|
||||
@memo define (must include listimpl.cpp!) list class 'name'
|
||||
*/
|
||||
#define WX_DEFINE_LIST(name) "don't forget to include listimpl.cpp!"
|
||||
#define WX_DEFINE_OBJARRAY(name) "don't forget to include listimpl.cpp!"
|
||||
//@}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -345,6 +345,26 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent
|
||||
wxClientData* m_clientObject; // Arbitrary client object
|
||||
};
|
||||
|
||||
// this class adds a possibility to react (from the user) code to a control
|
||||
// notification: allow or veto the operation being reported.
|
||||
class WXDLLEXPORT wxNotifyEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
||||
: wxCommandEvent(commandType, id) { m_bAllow = TRUE; }
|
||||
|
||||
// veto the operation (by default it's allowed)
|
||||
void Veto() { m_bAllow = FALSE; }
|
||||
|
||||
// for implementation code only: is the operation allowed?
|
||||
bool IsAllowed() const { return m_bAllow; }
|
||||
|
||||
private:
|
||||
bool m_bAllow;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxCommandEvent)
|
||||
};
|
||||
|
||||
// Scroll event class
|
||||
/*
|
||||
wxEVT_SCROLL_TOP
|
||||
|
@ -169,6 +169,10 @@ public:
|
||||
~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
|
||||
|
@ -353,11 +353,13 @@ extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
|
||||
|
||||
class WXDLLEXPORT wxResourceCache: public wxList
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxResourceCache)
|
||||
public:
|
||||
wxResourceCache();
|
||||
wxResourceCache(const unsigned int the_key_type);
|
||||
wxResourceCache() { }
|
||||
wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
|
||||
~wxResourceCache();
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxResourceCache)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -37,13 +37,27 @@ class wxNotebookEvent : public wxCommandEvent
|
||||
public:
|
||||
wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
|
||||
int nSel = -1, int nOldSel = -1)
|
||||
: wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
|
||||
: wxCommandEvent(commandType, id)
|
||||
{
|
||||
m_bAllow = TRUE;
|
||||
m_nSel = nSel;
|
||||
m_nOldSel = nOldSel;
|
||||
}
|
||||
|
||||
// accessors
|
||||
int GetSelection() const { return m_nSel; }
|
||||
int GetOldSelection() const { return m_nOldSel; }
|
||||
|
||||
// for wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event this method may be called
|
||||
// to disallow the page change
|
||||
void Veto() { m_bAllow = FALSE; }
|
||||
|
||||
// implementation: for wxNotebook usage only
|
||||
bool Allowed() const { return m_bAllow; }
|
||||
|
||||
private:
|
||||
bool m_bAllow;
|
||||
|
||||
int m_nSel, // currently selected page
|
||||
m_nOldSel; // previously selected page
|
||||
|
||||
|
@ -37,13 +37,27 @@ class wxNotebookEvent : public wxCommandEvent
|
||||
public:
|
||||
wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
|
||||
int nSel = -1, int nOldSel = -1)
|
||||
: wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
|
||||
: wxCommandEvent(commandType, id)
|
||||
{
|
||||
m_bAllow = TRUE;
|
||||
m_nSel = nSel;
|
||||
m_nOldSel = nOldSel;
|
||||
}
|
||||
|
||||
// accessors
|
||||
int GetSelection() const { return m_nSel; }
|
||||
int GetOldSelection() const { return m_nOldSel; }
|
||||
|
||||
// for wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event this method may be called
|
||||
// to disallow the page change
|
||||
void Veto() { m_bAllow = FALSE; }
|
||||
|
||||
// implementation: for wxNotebook usage only
|
||||
bool Allowed() const { return m_bAllow; }
|
||||
|
||||
private:
|
||||
bool m_bAllow;
|
||||
|
||||
int m_nSel, // currently selected page
|
||||
m_nOldSel; // previously selected page
|
||||
|
||||
|
@ -2,13 +2,26 @@
|
||||
// Name: list.h
|
||||
// Purpose: wxList, wxStringList classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Modified by: VZ at 16/11/98: WX_DECLARE_LIST() and typesafe lists added
|
||||
// Created: 29/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
All this is quite ugly but serves two purposes:
|
||||
1. Be almost 100% compatible with old, untyped, wxList class
|
||||
2. Ensure compile-time type checking for the linked lists
|
||||
|
||||
The idea is to have one base class (wxListBase) working with "void *" data,
|
||||
but to hide these untyped functions - i.e. make them protected, so they
|
||||
can only be used from derived classes which have inline member functions
|
||||
working with right types. This achieves the 2nd goal. As for the first one,
|
||||
we provide a special derivation of wxListBase called wxList which looks just
|
||||
like the old class.
|
||||
*/
|
||||
|
||||
#ifndef _WX_LISTH__
|
||||
#define _WX_LISTH__
|
||||
|
||||
@ -16,133 +29,445 @@
|
||||
#pragma interface "list.h"
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// headers
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/debug.h"
|
||||
#include "wx/object.h"
|
||||
|
||||
class WXDLLEXPORT wxList;
|
||||
// due to circular header dependencies this function has to be declared here
|
||||
// (normally it's found in utils.h which includes itself list.h...)
|
||||
extern char* WXDLLEXPORT copystring(const char *s);
|
||||
|
||||
#define wxKEY_NONE 0
|
||||
#define wxKEY_INTEGER 1
|
||||
#define wxKEY_STRING 2
|
||||
class WXDLLEXPORT wxNode: public wxObject
|
||||
class WXDLLEXPORT wxObjectListNode;
|
||||
typedef wxObjectListNode wxNode;
|
||||
|
||||
// undef it to get rid of old, deprecated functions
|
||||
#define wxLIST_COMPATIBILITY
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constants
|
||||
// -----------------------------------------------------------------------------
|
||||
enum wxKeyType
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxNode)
|
||||
private:
|
||||
wxKEY_NONE,
|
||||
wxKEY_INTEGER,
|
||||
wxKEY_STRING
|
||||
};
|
||||
|
||||
wxObject *data;
|
||||
wxNode *next;
|
||||
wxNode *previous;
|
||||
// -----------------------------------------------------------------------------
|
||||
// types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
wxList *list;
|
||||
// type of compare function for list sort operation (as in 'qsort'): it should
|
||||
// return a negative value, 0 or positive value if the first element is less
|
||||
// than, equal or greater than the second
|
||||
typedef int (*wxSortCompareFunction)(const void *elem1, const void *elem2);
|
||||
|
||||
// Optional key stuff
|
||||
union
|
||||
//
|
||||
typedef int (*wxListIterateFunction)(void *current);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// key stuff: a list may be optionally keyed on integer or string key
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
union wxListKeyValue
|
||||
{
|
||||
long integer;
|
||||
char *string;
|
||||
} key;
|
||||
|
||||
wxNode(wxList *the_list = (wxList *) NULL, wxNode *last_one = (wxNode *) NULL, wxNode *next_one = (wxNode *) NULL, wxObject *object = (wxObject *) NULL);
|
||||
wxNode(wxList *the_list, wxNode *last_one, wxNode *next_one,
|
||||
wxObject *object, long the_key);
|
||||
wxNode(wxList *the_list, wxNode *last_one, wxNode *next_one,
|
||||
wxObject *object, const char *the_key);
|
||||
~wxNode(void);
|
||||
|
||||
inline wxNode *Next(void) const { return next; }
|
||||
inline wxNode *Previous(void) const { return previous; }
|
||||
inline wxObject *Data(void) const { return (wxObject *)data; }
|
||||
inline void SetData(wxObject *the_data) { data = the_data; }
|
||||
};
|
||||
|
||||
// type of compare function for list sort operation (as in 'qsort')
|
||||
typedef int (*wxSortCompareFunction)(const void *elem1, const void *elem2);
|
||||
typedef int (*wxListIterateFunction)(wxObject *o);
|
||||
|
||||
class WXDLLEXPORT wxList: public wxObject
|
||||
// a struct which may contain both types of keys
|
||||
//
|
||||
// implementation note: on one hand, this class allows to have only one function
|
||||
// for any keyed operation instead of 2 almost equivalent. OTOH, it's needed to
|
||||
// resolve ambiguity which we would otherwise have with wxStringList::Find() and
|
||||
// wxList::Find(const char *).
|
||||
class WXDLLEXPORT wxListKey
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxList)
|
||||
|
||||
public:
|
||||
int n;
|
||||
int destroy_data;
|
||||
wxNode *first_node;
|
||||
wxNode *last_node;
|
||||
unsigned int key_type;
|
||||
// implicit ctors
|
||||
wxListKey()
|
||||
{ m_keyType = wxKEY_NONE; }
|
||||
wxListKey(long i)
|
||||
{ m_keyType = wxKEY_INTEGER; m_key.integer = i; }
|
||||
wxListKey(const char *s)
|
||||
{ m_keyType = wxKEY_STRING; m_key.string = strdup(s); }
|
||||
wxListKey(const wxString& s)
|
||||
{ m_keyType = wxKEY_STRING; m_key.string = strdup(s.c_str()); }
|
||||
|
||||
wxList(void);
|
||||
wxList(const unsigned int the_key_type);
|
||||
wxList(int N, wxObject *Objects[]);
|
||||
wxList(wxObject *object, ...);
|
||||
// accessors
|
||||
wxKeyType GetKeyType() const { return m_keyType; }
|
||||
const char *GetString() const
|
||||
{ wxASSERT( m_keyType == wxKEY_STRING ); return m_key.string; }
|
||||
long GetNumber() const
|
||||
{ wxASSERT( m_keyType == wxKEY_INTEGER ); return m_key.integer; }
|
||||
|
||||
~wxList(void);
|
||||
// comparaison
|
||||
bool operator==(wxListKeyValue value) const
|
||||
{
|
||||
switch ( m_keyType )
|
||||
{
|
||||
default:
|
||||
wxFAIL_MSG("bad key type.");
|
||||
// let compiler optimize the line above away in release build
|
||||
// by not putting return here...
|
||||
|
||||
inline int Number(void) const { return n; }
|
||||
inline int GetCount(void) const { return n; }
|
||||
case wxKEY_STRING:
|
||||
return strcmp(m_key.string, value.string) == 0;
|
||||
|
||||
// Append to end of list
|
||||
wxNode *Append(wxObject *object);
|
||||
case wxKEY_INTEGER:
|
||||
return m_key.integer == value.integer;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert at front of list
|
||||
wxNode *Insert(wxObject *object);
|
||||
// dtor
|
||||
~wxListKey()
|
||||
{
|
||||
if ( m_keyType == wxKEY_STRING )
|
||||
free(m_key.string);
|
||||
}
|
||||
|
||||
// Insert before given node
|
||||
wxNode *Insert(wxNode *position, wxObject *object);
|
||||
private:
|
||||
wxKeyType m_keyType;
|
||||
wxListKeyValue m_key;
|
||||
};
|
||||
|
||||
// Keyed append
|
||||
wxNode *Append(long key, wxObject *object);
|
||||
wxNode *Append(const char *key, wxObject *object);
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxNodeBase class is a (base for) node in a double linked list
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool DeleteNode(wxNode *node);
|
||||
bool DeleteObject(wxObject *object); // Finds object pointer and
|
||||
// deletes node (and object if
|
||||
// DeleteContents is on)
|
||||
virtual void Clear(void); // Delete all nodes
|
||||
class WXDLLEXPORT wxNodeBase
|
||||
{
|
||||
friend class wxListBase;
|
||||
public:
|
||||
// ctor
|
||||
wxNodeBase(wxListBase *list = (wxListBase *)NULL,
|
||||
wxNodeBase *previous = (wxNodeBase *)NULL,
|
||||
wxNodeBase *next = (wxNodeBase *)NULL,
|
||||
void *data = NULL,
|
||||
const wxListKey& key = wxListKey());
|
||||
|
||||
inline wxNode *First(void) const { return first_node; }
|
||||
inline wxNode *Last(void) const { return last_node; }
|
||||
wxNode *Nth(int i) const; // nth node counting from 0
|
||||
virtual ~wxNodeBase();
|
||||
|
||||
// Keyed search
|
||||
virtual wxNode *Find(long key) const;
|
||||
virtual wxNode *Find(const char *key) const;
|
||||
// @@ no check is done that the list is really keyed on strings
|
||||
const char *GetKeyString() const { return m_key.string; }
|
||||
|
||||
virtual wxNode *Member(wxObject *object) const;
|
||||
#ifdef wxLIST_COMPATIBILITY
|
||||
// compatibility methods
|
||||
wxNode *Next() const { return (wxNode *)GetNext(); }
|
||||
wxNode *Previous() const { return (wxNode *)GetPrevious(); }
|
||||
wxObject *Data() const { return (wxObject *)GetData(); }
|
||||
#endif // wxLIST_COMPATIBILITY
|
||||
|
||||
protected:
|
||||
// all these are going to be "overloaded" in the derived classes
|
||||
wxNodeBase *GetNext() const { return m_next; }
|
||||
wxNodeBase *GetPrevious() const { return m_previous; }
|
||||
|
||||
void *GetData() const { return m_data; }
|
||||
void SetData(void *data) { m_data = data; }
|
||||
|
||||
virtual void DeleteData() { }
|
||||
|
||||
private:
|
||||
// optional key stuff
|
||||
wxListKeyValue m_key;
|
||||
|
||||
void *m_data; // user data
|
||||
wxNodeBase *m_next, // next and previous nodes in the list
|
||||
*m_previous;
|
||||
|
||||
wxListBase *m_list; // list we belong to
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// a double-linked list class
|
||||
// -----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxListBase : public wxObject
|
||||
{
|
||||
friend class wxNodeBase; // should be able to call DetachNode()
|
||||
public:
|
||||
// default ctor & dtor
|
||||
wxListBase(wxKeyType keyType = wxKEY_NONE) { Init(keyType); }
|
||||
virtual ~wxListBase();
|
||||
|
||||
// accessors
|
||||
// count of items in the list
|
||||
size_t GetCount() const { return m_count; }
|
||||
|
||||
// operations
|
||||
// delete all nodes
|
||||
virtual void Clear();
|
||||
// instruct it to destroy user data when deleting nodes
|
||||
void DeleteContents(bool destroy) { m_destroy = destroy; }
|
||||
|
||||
protected:
|
||||
// all methods here are "overloaded" in derived classes to provide compile
|
||||
// time type checking
|
||||
|
||||
// create a node for the list of this type
|
||||
virtual wxNodeBase *CreateNode(wxNodeBase *prev, wxNodeBase *next,
|
||||
void *data,
|
||||
const wxListKey& key = wxListKey()) = 0;
|
||||
|
||||
// ctors
|
||||
// from an array
|
||||
wxListBase(size_t count, void *elements[]);
|
||||
// from a sequence of objects
|
||||
wxListBase(void *object, ... /* terminate with NULL */);
|
||||
|
||||
// copy ctor and assignment operator
|
||||
wxListBase(const wxListBase& list)
|
||||
{ DoCopy(list); }
|
||||
wxListBase& operator=(const wxListBase& list)
|
||||
{ Clear(); DoCopy(list); return *this; }
|
||||
|
||||
// get list head/tail
|
||||
wxNodeBase *GetFirst() const { return m_nodeFirst; }
|
||||
wxNodeBase *GetLast() const { return m_nodeLast; }
|
||||
|
||||
// by (0-based) index
|
||||
wxNodeBase *Item(size_t index) const;
|
||||
|
||||
// get the list item's data
|
||||
void *operator[](size_t index) const
|
||||
{ wxNodeBase *node = Item(index); return node ? node->GetData() : NULL; }
|
||||
|
||||
// operations
|
||||
// append to end of list
|
||||
wxNodeBase *Append(void *object);
|
||||
// insert a new item at the beginning of the list
|
||||
wxNodeBase *Insert(void *object) { return Insert(NULL, object); }
|
||||
// insert before given node or at front of list if prev == NULL
|
||||
wxNodeBase *Insert(wxNodeBase *prev, void *object);
|
||||
|
||||
// keyed append
|
||||
wxNodeBase *Append(long key, void *object);
|
||||
wxNodeBase *Append(const char *key, void *object);
|
||||
|
||||
// removes node from the list but doesn't delete it (returns pointer
|
||||
// to the node or NULL if it wasn't found in the list)
|
||||
wxNodeBase *DetachNode(wxNodeBase *node);
|
||||
// delete element from list, returns FALSE if node not found
|
||||
bool DeleteNode(wxNodeBase *node);
|
||||
// finds object pointer and deletes node (and object if DeleteContents
|
||||
// is on), returns FALSE if object not found
|
||||
bool DeleteObject(void *object);
|
||||
|
||||
// search (all return NULL if item not found)
|
||||
// by data
|
||||
wxNodeBase *Find(void *object) const;
|
||||
|
||||
// by key
|
||||
wxNodeBase *Find(const wxListKey& key) const;
|
||||
|
||||
inline void DeleteContents(int destroy) { destroy_data = destroy; }
|
||||
// Instruct it to destroy user data
|
||||
// when deleting nodes
|
||||
// this function allows the sorting of arbitrary lists by giving
|
||||
// a function to compare two list elements.
|
||||
void Sort(const wxSortCompareFunction compfunc);
|
||||
// a function to compare two list elements. The list is sorted in place.
|
||||
void Sort(wxSortCompareFunction compfunc);
|
||||
|
||||
wxObject *FirstThat(wxListIterateFunction func);
|
||||
// functions for iterating over the list
|
||||
void *FirstThat(wxListIterateFunction func);
|
||||
void ForEach(wxListIterateFunction func);
|
||||
wxObject *LastThat(wxListIterateFunction func);
|
||||
void *LastThat(wxListIterateFunction func);
|
||||
|
||||
private:
|
||||
// helpers
|
||||
// common part of all ctors
|
||||
void Init(wxKeyType keyType);
|
||||
// common part of copy ctor and assignment operator
|
||||
void DoCopy(const wxListBase& list);
|
||||
// common part of all Append()s
|
||||
wxNodeBase *AppendCommon(wxNodeBase *node);
|
||||
// free node's data and node itself
|
||||
void DoDeleteNode(wxNodeBase *node);
|
||||
|
||||
size_t m_count; // number of elements in the list
|
||||
bool m_destroy; // destroy user data when deleting list items?
|
||||
wxNodeBase *m_nodeFirst, // pointers to the head and tail of the list
|
||||
*m_nodeLast;
|
||||
|
||||
wxKeyType m_keyType; // type of our keys (may be wxKEY_NONE)
|
||||
};
|
||||
|
||||
// String list class. N.B. this always copies strings
|
||||
// with Add and deletes them itself.
|
||||
class WXDLLEXPORT wxStringList: public wxList
|
||||
// -----------------------------------------------------------------------------
|
||||
// macros for definition of "template" list type
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// and now some heavy magic...
|
||||
|
||||
// declare a list type named 'name' and containing elements of type 'T *'
|
||||
// (as a by product of macro expansion you also get wx##name##Node
|
||||
// wxNode-dervied type)
|
||||
//
|
||||
// implementation details:
|
||||
// 1. we define _WX_LIST_ITEM_TYPE_##name typedef to save in it the item type
|
||||
// for the list of given type - this allows us to pass only the list name
|
||||
// to WX_DEFINE_LIST() even if it needs both the name and the type
|
||||
//
|
||||
// 2. We redefine all not type-safe wxList functions withtype-safe versions
|
||||
// which don't take any place (everything is inline), but bring compile
|
||||
// time error checking.
|
||||
|
||||
#define WX_DECLARE_LIST_2(T, name, nodetype) \
|
||||
typedef int (*wxSortFuncFor_##name)(const T *, const T *); \
|
||||
\
|
||||
class WXDLLEXPORT nodetype : public wxNodeBase \
|
||||
{ \
|
||||
public: \
|
||||
nodetype(wxListBase *list = (wxListBase *)NULL, \
|
||||
nodetype *previous = (nodetype *)NULL, \
|
||||
nodetype *next = (nodetype *)NULL, \
|
||||
T *data = NULL, \
|
||||
const wxListKey& key = wxListKey()) \
|
||||
: wxNodeBase(list, previous, next, data, key) { } \
|
||||
\
|
||||
nodetype *GetNext() const \
|
||||
{ return (nodetype *)wxNodeBase::GetNext(); } \
|
||||
nodetype *GetPrevious() const \
|
||||
{ return (nodetype *)wxNodeBase::GetPrevious(); } \
|
||||
\
|
||||
T *GetData() const \
|
||||
{ return (T *)wxNodeBase::GetData(); } \
|
||||
void SetData(T *data) \
|
||||
{ wxNodeBase::SetData(data); } \
|
||||
\
|
||||
virtual void DeleteData(); \
|
||||
}; \
|
||||
\
|
||||
class name : public wxListBase \
|
||||
{ \
|
||||
public: \
|
||||
name(wxKeyType keyType = wxKEY_NONE) : wxListBase(keyType) \
|
||||
{ } \
|
||||
name(size_t count, T *elements[]) \
|
||||
: wxListBase(count, (void **)elements) { } \
|
||||
\
|
||||
nodetype *GetFirst() const \
|
||||
{ return (nodetype *)wxListBase::GetFirst(); } \
|
||||
nodetype *GetLast() const \
|
||||
{ return (nodetype *)wxListBase::GetLast(); } \
|
||||
\
|
||||
nodetype *Item(size_t index) const \
|
||||
{ return (nodetype *)wxListBase::Item(index); } \
|
||||
\
|
||||
T *operator[](size_t index) const \
|
||||
{ \
|
||||
nodetype *node = Item(index); \
|
||||
return node ? node->GetData() : NULL; \
|
||||
} \
|
||||
\
|
||||
nodetype *Append(T *object) \
|
||||
{ return (nodetype *)wxListBase::Append(object); } \
|
||||
nodetype *Insert(T *object) \
|
||||
{ return (nodetype *)Insert(NULL, object); } \
|
||||
nodetype *Insert(nodetype *prev, T *object) \
|
||||
{ return (nodetype *)wxListBase::Insert(prev, object); } \
|
||||
\
|
||||
nodetype *Append(long key, void *object) \
|
||||
{ return (nodetype *)wxListBase::Append(key, object); } \
|
||||
nodetype *Append(const char *key, void *object) \
|
||||
{ return (nodetype *)wxListBase::Append(key, object); } \
|
||||
\
|
||||
nodetype *DetachNode(nodetype *node) \
|
||||
{ return (nodetype *)wxListBase::DetachNode(node); } \
|
||||
bool DeleteNode(nodetype *node) \
|
||||
{ return wxListBase::DeleteNode(node); } \
|
||||
bool DeleteObject(T *object) \
|
||||
{ return wxListBase::DeleteObject(object); } \
|
||||
\
|
||||
nodetype *Find(T *object) const \
|
||||
{ return (nodetype *)wxListBase::Find(object); } \
|
||||
\
|
||||
virtual nodetype *Find(const wxListKey& key) const \
|
||||
{ return (nodetype *)wxListBase::Find(key); } \
|
||||
\
|
||||
void Sort(wxSortFuncFor_##name func) \
|
||||
{ wxListBase::Sort((wxSortCompareFunction)func); } \
|
||||
\
|
||||
protected: \
|
||||
wxNodeBase *CreateNode(wxNodeBase *prev, wxNodeBase *next, \
|
||||
void *data, \
|
||||
const wxListKey& key = wxListKey()) \
|
||||
{ \
|
||||
return new nodetype(this, \
|
||||
(nodetype *)prev, (nodetype *)next, \
|
||||
(T *)data, key); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WX_DECLARE_LIST(elementtype, listname) \
|
||||
typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \
|
||||
WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node)
|
||||
|
||||
// this macro must be inserted in your program after
|
||||
// #include <wx/listimpl.cpp>
|
||||
#define WX_DEFINE_LIST(name) "don't forget to include listimpl.cpp!"
|
||||
|
||||
|
||||
// =============================================================================
|
||||
// now we can define classes 100% compatible with the old ones
|
||||
// =============================================================================
|
||||
|
||||
#ifdef wxLIST_COMPATIBILITY
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxList compatibility class: in fact, it's a list of wxObjects
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_LIST_2(wxObject, wxObjectList, wxObjectListNode);
|
||||
|
||||
class WXDLLEXPORT wxList : public wxObjectList
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStringList)
|
||||
|
||||
public:
|
||||
wxStringList(void);
|
||||
wxStringList(const wxStringList& list);
|
||||
wxStringList(const char *first ...);
|
||||
~wxStringList(void);
|
||||
wxList(int key_type = wxKEY_NONE) : wxObjectList((wxKeyType)key_type) { }
|
||||
|
||||
virtual wxNode *Add(const char *s);
|
||||
virtual void Delete(const char *s);
|
||||
virtual char **ListToArray(bool new_copies = FALSE) const;
|
||||
virtual void Sort(void);
|
||||
virtual bool Member(const char *s) const;
|
||||
virtual void Clear(void);
|
||||
void operator= (const wxStringList& list);
|
||||
char* operator[] (int i) const;
|
||||
// compatibility methods
|
||||
int Number() const { return GetCount(); }
|
||||
wxNode *First() const { return (wxNode *)GetFirst(); }
|
||||
wxNode *Last() const { return (wxNode *)GetLast(); }
|
||||
wxNode *Nth(size_t index) const { return (wxNode *)Item(index); }
|
||||
wxNode *Member(wxObject *object) const { return (wxNode *)Find(object); }
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxStringList class for compatibility with the old code
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_LIST_2(char, wxStringListBase, wxStringListNode);
|
||||
|
||||
class WXDLLEXPORT wxStringList : public wxStringListBase
|
||||
{
|
||||
public:
|
||||
// ctors and such
|
||||
// default
|
||||
wxStringList() { DeleteContents(TRUE); }
|
||||
wxStringList(const char *first ...);
|
||||
|
||||
// operations
|
||||
// makes a copy of the string
|
||||
wxNode *Add(const char *s)
|
||||
{ return (wxNode *)wxStringListBase::Append(copystring(s)); }
|
||||
|
||||
void Delete(const char *s)
|
||||
{ wxStringListBase::DeleteObject((char *)s); }
|
||||
|
||||
char **ListToArray(bool new_copies = FALSE) const;
|
||||
bool Member(const char *s) const;
|
||||
|
||||
// alphabetic sort
|
||||
void Sort();
|
||||
|
||||
// compatibility methods
|
||||
int Number() const { return GetCount(); }
|
||||
wxNode *First() const { return (wxNode *)GetFirst(); }
|
||||
wxNode *Last() const { return (wxNode *)GetLast(); }
|
||||
wxNode *Nth(size_t index) const { return (wxNode *)Item(index); }
|
||||
};
|
||||
|
||||
#endif // wxLIST_COMPATIBILITY
|
||||
|
||||
#endif
|
||||
// _WX_LISTH__
|
||||
|
@ -1,111 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: listimpl.cpp
|
||||
// Purpose: helper file for implementation of dynamic lists
|
||||
// Purpose: second-part of macro based implementation of template lists
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 16.10.97
|
||||
// Created: 16/11/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1997 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Copyright: (c) 1998 Vadim Zeitlin
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*****************************************************************************
|
||||
* Purpose: implements methods of "template" class declared in DECLARE_LIST *
|
||||
* 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_LIST *
|
||||
* 3) #include listimpl.cpp *
|
||||
* 4) WX_DEFINE_LIST *
|
||||
*****************************************************************************/
|
||||
|
||||
// macro implements remaining (not inline) methods of template list
|
||||
// (it's private to this file)
|
||||
#define _DEFINE_LIST(T, name) \
|
||||
name::~name() \
|
||||
void wx##name##Node::DeleteData() \
|
||||
{ \
|
||||
Empty(); \
|
||||
} \
|
||||
\
|
||||
void name::DoCopy(const name& src) \
|
||||
{ \
|
||||
for ( uint 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) \
|
||||
{ \
|
||||
DoCopy(src); \
|
||||
} \
|
||||
\
|
||||
void name::Empty() \
|
||||
{ \
|
||||
for ( uint ui = 0; ui < Count(); ui++ ) \
|
||||
delete (T*)BaseArray::Item(ui); \
|
||||
\
|
||||
BaseArray::Clear(); \
|
||||
} \
|
||||
\
|
||||
void name::Remove(uint uiIndex) \
|
||||
{ \
|
||||
wxCHECK( uiIndex < Count() ); \
|
||||
\
|
||||
delete (T*)BaseArray::Item(uiIndex); \
|
||||
\
|
||||
BaseArray::Remove(uiIndex); \
|
||||
} \
|
||||
\
|
||||
void name::Add(const T& item) \
|
||||
{ \
|
||||
T* pItem = new T(item); \
|
||||
if ( pItem != NULL ) \
|
||||
Add(pItem); \
|
||||
} \
|
||||
\
|
||||
void name::Insert(const T& item, uint uiIndex) \
|
||||
{ \
|
||||
T* pItem = new T(item); \
|
||||
if ( pItem != NULL ) \
|
||||
Insert(pItem, uiIndex); \
|
||||
} \
|
||||
\
|
||||
int name::Index(const T& Item, Bool bFromEnd) const \
|
||||
{ \
|
||||
if ( bFromEnd ) { \
|
||||
if ( Count() > 0 ) { \
|
||||
uint ui = Count() - 1; \
|
||||
do { \
|
||||
if ( (T*)BaseArray::Item(ui) == &Item ) \
|
||||
return ui; \
|
||||
ui--; \
|
||||
} \
|
||||
while ( ui != 0 ); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
for( uint ui = 0; ui < Count(); ui++ ) { \
|
||||
if( (T*)BaseArray::Item(ui) == &Item ) \
|
||||
return ui; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return NOT_FOUND; \
|
||||
delete (T *)GetData(); \
|
||||
}
|
||||
|
||||
// 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_LIST
|
||||
#define WX_DEFINE_LIST(name) _DEFINE_LIST(_L##name, name)
|
||||
#define WX_DEFINE_LIST(name) _DEFINE_LIST(_WX_LIST_ITEM_TYPE_##name, name)
|
||||
|
||||
// don't pollute preprocessor's name space
|
||||
#undef _DEFINE_LIST
|
||||
|
||||
//#undef _DEFINE_LIST
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
// Window procedure
|
||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual void MSWOnMouseMove(int x, int y, WXUINT flags);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
|
||||
|
@ -418,8 +418,8 @@ class WXDLLEXPORT wxListCtrl: public wxControl
|
||||
void Command(wxCommandEvent& event) { ProcessCommand(event); };
|
||||
|
||||
// IMPLEMENTATION
|
||||
bool MSWCommand(WXUINT param, WXWORD id);
|
||||
bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
// Recreate window - seems to be necessary when changing a style.
|
||||
void RecreateWindow(void);
|
||||
@ -442,10 +442,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxListEvent: public wxCommandEvent
|
||||
class WXDLLEXPORT wxListEvent : public wxNotifyEvent
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxListEvent)
|
||||
|
||||
public:
|
||||
wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
|
||||
|
||||
@ -457,6 +455,8 @@ class WXDLLEXPORT wxListEvent: public wxCommandEvent
|
||||
wxPoint m_pointDrag;
|
||||
|
||||
wxListItem m_item;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxListEvent)
|
||||
};
|
||||
|
||||
typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
|
||||
|
@ -44,12 +44,16 @@ WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
|
||||
// ----------------------------------------------------------------------------
|
||||
// notebook events
|
||||
// ----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
|
||||
class WXDLLEXPORT wxNotebookEvent : public wxNotifyEvent
|
||||
{
|
||||
public:
|
||||
wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
|
||||
int nSel = -1, int nOldSel = -1)
|
||||
: wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
|
||||
: wxNotifyEvent(commandType, id)
|
||||
{
|
||||
m_nSel = nSel;
|
||||
m_nOldSel = nOldSel;
|
||||
}
|
||||
|
||||
// accessors
|
||||
// the currently selected page (-1 if none)
|
||||
@ -173,7 +177,7 @@ public:
|
||||
// base class virtuals
|
||||
// -------------------
|
||||
virtual void Command(wxCommandEvent& event);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
virtual void SetConstraintSizes(bool recurse = TRUE);
|
||||
virtual bool DoPhase(int nPhase);
|
||||
|
||||
|
@ -91,6 +91,10 @@ public:
|
||||
virtual bool DeleteAll();
|
||||
|
||||
private:
|
||||
// no copy ctor/assignment operator
|
||||
wxRegConfig(const wxRegConfig&);
|
||||
wxRegConfig& operator=(const wxRegConfig&);
|
||||
|
||||
// these keys are opened during all lifetime of wxRegConfig object
|
||||
wxRegKey m_keyLocalRoot, m_keyLocal,
|
||||
m_keyGlobalRoot, m_keyGlobal;
|
||||
|
@ -79,7 +79,7 @@
|
||||
#define wxUSE_SCROLLBAR 1
|
||||
// Define 1 to compile contributed wxScrollBar class
|
||||
#define wxUSE_XPM_IN_X 1
|
||||
#define wxUSE_XPM_IN_MSW 0
|
||||
#define wxUSE_XPM_IN_MSW 1
|
||||
// Define 1 to support the XPM package in wxBitmap,
|
||||
// separated by platform. If 1, you must link in
|
||||
// the XPM library to your applications.
|
||||
@ -114,12 +114,12 @@
|
||||
#define wxUSE_DYNAMIC_CLASSES 1
|
||||
// If 1, enables provision of run-time type information.
|
||||
// NOW MANDATORY: don't change.
|
||||
#define wxUSE_MEMORY_TRACING 1
|
||||
#define wxUSE_MEMORY_TRACING 0
|
||||
// If 1, enables debugging versions of wxObject::new and
|
||||
// wxObject::delete *IF* __WXDEBUG__ is also defined.
|
||||
// WARNING: this code may not work with all architectures, especially
|
||||
// if alignment is an issue.
|
||||
#define wxUSE_DEBUG_CONTEXT 1
|
||||
#define wxUSE_DEBUG_CONTEXT 0
|
||||
// If 1, enables wxDebugContext, for
|
||||
// writing error messages to file, etc.
|
||||
// If __WXDEBUG__ is not defined, will still use
|
||||
@ -128,7 +128,7 @@
|
||||
// since you may well need to output
|
||||
// an error log in a production
|
||||
// version (or non-debugging beta)
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 1
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
|
||||
// In debug mode, cause new and delete to be redefined globally.
|
||||
// If this causes problems (e.g. link errors), set this to 0.
|
||||
|
||||
|
@ -67,10 +67,10 @@ class WXDLLEXPORT wxSpinButton: public wxControl
|
||||
void Command(wxCommandEvent& event) { ProcessCommand(event); };
|
||||
|
||||
// IMPLEMENTATION
|
||||
bool MSWCommand(WXUINT param, WXWORD id);
|
||||
bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
void MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control);
|
||||
void MSWOnHScroll(WXWORD wParam, WXWORD pos, WXHWND control);
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
virtual void MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control);
|
||||
virtual void MSWOnHScroll(WXWORD wParam, WXWORD pos, WXHWND control);
|
||||
|
||||
protected:
|
||||
int m_min;
|
||||
|
@ -122,8 +122,9 @@ class WXDLLEXPORT wxTabCtrl: public wxControl
|
||||
void OnKillFocus(wxFocusEvent& event) { Default() ; }
|
||||
|
||||
void Command(wxCommandEvent& event);
|
||||
bool MSWCommand(WXUINT param, WXWORD id);
|
||||
bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
@ -81,8 +81,8 @@ class WXDLLEXPORT wxToolBar95: public wxToolBarBase
|
||||
bool Realize() { return CreateTools(); };
|
||||
|
||||
// IMPLEMENTATION
|
||||
bool MSWCommand(WXUINT param, WXWORD id);
|
||||
bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
// Responds to colour changes
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
@ -410,8 +410,8 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
void Command(wxCommandEvent& event) { ProcessCommand(event); };
|
||||
bool MSWCommand(WXUINT param, WXWORD id);
|
||||
bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
protected:
|
||||
// SetImageList helper
|
||||
@ -448,7 +448,7 @@ private:
|
||||
// NB: note that not all accessors make sense for all events, see the event
|
||||
// descriptions below
|
||||
// ----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxTreeEvent : public wxCommandEvent
|
||||
class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
|
||||
{
|
||||
friend wxTreeCtrl;
|
||||
public:
|
||||
@ -470,10 +470,6 @@ public:
|
||||
// keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only)
|
||||
int GetCode() const { return m_code; }
|
||||
|
||||
// set return code for wxEVT_COMMAND_TREE_ITEM_{EXPAND|COLLAPS}ING events
|
||||
// call this to forbid the change in item status
|
||||
void Veto() { m_code = TRUE; }
|
||||
|
||||
private:
|
||||
// @@ we could save some space by using union here
|
||||
int m_code;
|
||||
|
@ -89,18 +89,17 @@ class WXDLLEXPORT wxWindow: public wxEvtHandler
|
||||
friend class wxPaintDC;
|
||||
|
||||
public:
|
||||
wxWindow(void);
|
||||
inline wxWindow(wxWindow *parent, wxWindowID id,
|
||||
wxWindow();
|
||||
wxWindow(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxPanelNameStr)
|
||||
{
|
||||
m_children = new wxList;
|
||||
Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
virtual ~wxWindow(void);
|
||||
virtual ~wxWindow();
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
@ -109,25 +108,25 @@ public:
|
||||
const wxString& name = wxPanelNameStr);
|
||||
|
||||
// Fit the window around the items
|
||||
virtual void Fit(void);
|
||||
virtual void Fit();
|
||||
|
||||
// Show or hide the window
|
||||
virtual bool Show(bool show);
|
||||
|
||||
// Is the window shown?
|
||||
virtual bool IsShown(void) const;
|
||||
virtual bool IsShown() const;
|
||||
|
||||
// Raise the window to the top of the Z order
|
||||
virtual void Raise(void);
|
||||
virtual void Raise();
|
||||
|
||||
// Lower the window to the bottom of the Z order
|
||||
virtual void Lower(void);
|
||||
virtual void Lower();
|
||||
|
||||
// Is the window enabled?
|
||||
virtual bool IsEnabled(void) const;
|
||||
virtual bool IsEnabled() const;
|
||||
|
||||
// For compatibility
|
||||
inline bool Enabled(void) const { return IsEnabled(); }
|
||||
inline bool Enabled() const { return IsEnabled(); }
|
||||
|
||||
// Dialog support: override these and call
|
||||
// base class members to add functionality
|
||||
@ -135,30 +134,30 @@ public:
|
||||
|
||||
// Transfer values to controls. If returns FALSE,
|
||||
// it's an application error (pops up a dialog)
|
||||
virtual bool TransferDataToWindow(void);
|
||||
virtual bool TransferDataToWindow();
|
||||
|
||||
// Transfer values from controls. If returns FALSE,
|
||||
// transfer failed: don't quit
|
||||
virtual bool TransferDataFromWindow(void);
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
// Validate controls. If returns FALSE,
|
||||
// validation failed: don't quit
|
||||
virtual bool Validate(void);
|
||||
virtual bool Validate();
|
||||
|
||||
// Return code for dialogs
|
||||
inline void SetReturnCode(int retCode);
|
||||
inline int GetReturnCode(void);
|
||||
inline int GetReturnCode();
|
||||
|
||||
// Set the cursor
|
||||
virtual void SetCursor(const wxCursor& cursor);
|
||||
inline virtual wxCursor *GetCursor(void) const { return (wxCursor *)& m_windowCursor; };
|
||||
inline virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; };
|
||||
|
||||
// Get the window with the focus
|
||||
static wxWindow *FindFocus(void);
|
||||
static wxWindow *FindFocus();
|
||||
|
||||
// Get character size
|
||||
virtual int GetCharHeight(void) const;
|
||||
virtual int GetCharWidth(void) const;
|
||||
virtual int GetCharHeight() const;
|
||||
virtual int GetCharWidth() const;
|
||||
|
||||
// Get overall window size
|
||||
virtual void GetSize(int *width, int *height) const;
|
||||
@ -184,11 +183,11 @@ public:
|
||||
virtual void ScreenToClient(int *x, int *y) const;
|
||||
|
||||
// Set the focus to this window
|
||||
virtual void SetFocus(void);
|
||||
virtual void SetFocus();
|
||||
|
||||
// Capture/release mouse
|
||||
virtual void CaptureMouse(void);
|
||||
virtual void ReleaseMouse(void);
|
||||
virtual void CaptureMouse();
|
||||
virtual void ReleaseMouse();
|
||||
|
||||
// Enable or disable the window
|
||||
virtual void Enable(bool enable);
|
||||
@ -211,13 +210,13 @@ public:
|
||||
|
||||
// Set/get the window title
|
||||
virtual inline void SetTitle(const wxString& WXUNUSED(title)) {};
|
||||
inline virtual wxString GetTitle(void) const { return wxString(""); };
|
||||
inline virtual wxString GetTitle() const { return wxString(""); };
|
||||
// Most windows have the concept of a label; for frames, this is the
|
||||
// title; for items, this is the label or button text.
|
||||
inline virtual wxString GetLabel(void) const { return GetTitle(); }
|
||||
inline virtual wxString GetLabel() const { return GetTitle(); }
|
||||
|
||||
// Set/get the window name (used for resource setting in X)
|
||||
inline virtual wxString GetName(void) const;
|
||||
inline virtual wxString GetName() const;
|
||||
inline virtual void SetName(const wxString& name);
|
||||
|
||||
// Centre the window
|
||||
@ -252,7 +251,7 @@ public:
|
||||
// Caret manipulation
|
||||
virtual void CreateCaret(int w, int h);
|
||||
virtual void CreateCaret(const wxBitmap *bitmap);
|
||||
virtual void DestroyCaret(void);
|
||||
virtual void DestroyCaret();
|
||||
virtual void ShowCaret(bool show);
|
||||
virtual void SetCaretPos(int x, int y);
|
||||
virtual void GetCaretPos(int *x, int *y) const;
|
||||
@ -268,31 +267,31 @@ public:
|
||||
virtual void MakeModal(bool modal);
|
||||
|
||||
// Get the private handle (platform-dependent)
|
||||
inline void *GetHandle(void) const;
|
||||
inline void *GetHandle() const;
|
||||
|
||||
// Set/get the window's relatives
|
||||
inline wxWindow *GetParent(void) const;
|
||||
inline wxWindow *GetParent() const;
|
||||
inline void SetParent(wxWindow *p) ;
|
||||
inline wxWindow *GetGrandParent(void) const;
|
||||
inline wxWindow *GetGrandParent() const;
|
||||
inline wxList *GetChildren() const;
|
||||
|
||||
// Set/get the window's font
|
||||
virtual void SetFont(const wxFont& f);
|
||||
inline virtual wxFont *GetFont(void) const;
|
||||
inline virtual wxFont *GetFont() const;
|
||||
|
||||
// Set/get the window's validator
|
||||
void SetValidator(const wxValidator& validator);
|
||||
inline wxValidator *GetValidator(void) const;
|
||||
inline wxValidator *GetValidator() const;
|
||||
|
||||
// Set/get the window's style
|
||||
inline void SetWindowStyleFlag(long flag);
|
||||
inline long GetWindowStyleFlag(void) const;
|
||||
inline long GetWindowStyleFlag() const;
|
||||
|
||||
// Set/get double-clickability
|
||||
// TODO: we probably wish to get rid of this, and
|
||||
// always allow double clicks.
|
||||
inline void SetDoubleClick(bool flag);
|
||||
inline bool GetDoubleClick(void) const;
|
||||
inline bool GetDoubleClick() const;
|
||||
inline void AllowDoubleClick(bool value) { SetDoubleClick(value); }
|
||||
|
||||
// Handle a control command
|
||||
@ -300,7 +299,7 @@ public:
|
||||
|
||||
// Set/get event handler
|
||||
inline void SetEventHandler(wxEvtHandler *handler);
|
||||
inline wxEvtHandler *GetEventHandler(void) const;
|
||||
inline wxEvtHandler *GetEventHandler() const;
|
||||
|
||||
// Push/pop event handler (i.e. allow a chain of event handlers
|
||||
// be searched)
|
||||
@ -311,33 +310,33 @@ public:
|
||||
virtual bool Close(bool force = FALSE);
|
||||
|
||||
// Destroy the window (delayed, if a managed window)
|
||||
virtual bool Destroy(void) ;
|
||||
virtual bool Destroy() ;
|
||||
|
||||
// Mode for telling default OnSize members to
|
||||
// call Layout(), if not using Sizers, just top-down constraints
|
||||
inline void SetAutoLayout(bool a);
|
||||
inline bool GetAutoLayout(void) const;
|
||||
inline bool GetAutoLayout() const;
|
||||
|
||||
// Set/get constraints
|
||||
inline wxLayoutConstraints *GetConstraints(void) const;
|
||||
inline wxLayoutConstraints *GetConstraints() const;
|
||||
void SetConstraints(wxLayoutConstraints *c);
|
||||
|
||||
// Set/get window background colour
|
||||
inline virtual void SetBackgroundColour(const wxColour& col);
|
||||
inline virtual wxColour GetBackgroundColour(void) const;
|
||||
inline virtual wxColour GetBackgroundColour() const;
|
||||
|
||||
// Set/get window foreground colour
|
||||
inline virtual void SetForegroundColour(const wxColour& col);
|
||||
inline virtual wxColour GetForegroundColour(void) const;
|
||||
inline virtual wxColour GetForegroundColour() const;
|
||||
|
||||
// For backward compatibility
|
||||
inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
|
||||
inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
|
||||
inline virtual wxFont *GetLabelFont(void) const { return GetFont(); };
|
||||
inline virtual wxFont *GetButtonFont(void) const { return GetFont(); };
|
||||
inline virtual wxFont *GetLabelFont() const { return GetFont(); };
|
||||
inline virtual wxFont *GetButtonFont() const { return GetFont(); };
|
||||
|
||||
// Get the default button, if there is one
|
||||
inline virtual wxButton *GetDefaultItem(void) const;
|
||||
inline virtual wxButton *GetDefaultItem() const;
|
||||
inline virtual void SetDefaultItem(wxButton *but);
|
||||
|
||||
virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
|
||||
@ -365,27 +364,27 @@ public:
|
||||
const wxFont *theFont = NULL, bool use16 = FALSE) const;
|
||||
|
||||
// Is the window retained?
|
||||
inline bool IsRetained(void) const;
|
||||
inline bool IsRetained() const;
|
||||
|
||||
// Warp the pointer the given position
|
||||
virtual void WarpPointer(int x_pos, int y_pos) ;
|
||||
|
||||
// Clear the window
|
||||
virtual void Clear(void);
|
||||
virtual void Clear();
|
||||
|
||||
// Find a window by id or name
|
||||
virtual wxWindow *FindWindow(long id);
|
||||
virtual wxWindow *FindWindow(const wxString& name);
|
||||
|
||||
// Constraint operations
|
||||
bool Layout(void);
|
||||
bool Layout();
|
||||
void SetSizer(wxSizer *sizer); // Adds sizer child to this window
|
||||
inline wxSizer *GetSizer(void) const ;
|
||||
inline wxWindow *GetSizerParent(void) const ;
|
||||
inline wxSizer *GetSizer() const ;
|
||||
inline wxWindow *GetSizerParent() const ;
|
||||
inline void SetSizerParent(wxWindow *win);
|
||||
|
||||
// Do Update UI processing for controls
|
||||
void UpdateWindowUI(void);
|
||||
void UpdateWindowUI();
|
||||
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
@ -410,15 +409,18 @@ public:
|
||||
|
||||
// Windows subclassing
|
||||
void SubclassWin(WXHWND hWnd);
|
||||
void UnsubclassWin(void);
|
||||
virtual long Default(void);
|
||||
void UnsubclassWin();
|
||||
virtual long Default();
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
// returns TRUE if the event was processed
|
||||
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
virtual wxWindow *FindItem(int id) const;
|
||||
virtual wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const ;
|
||||
virtual void PreDelete(WXHDC dc); // Allows system cleanup
|
||||
// TO DO: how many of these need to be virtual?
|
||||
virtual WXHWND GetHWND(void) const ;
|
||||
virtual WXHWND GetHWND() const ;
|
||||
virtual void SetHWND(WXHWND hWnd);
|
||||
|
||||
// Make a Windows extended style from the given wxWindows window style
|
||||
@ -429,23 +431,23 @@ public:
|
||||
virtual void AddChild(wxWindow *child); // Adds reference to the child object
|
||||
virtual void RemoveChild(wxWindow *child); // Removes reference to child
|
||||
// (but doesn't delete the child object)
|
||||
virtual void DestroyChildren(void); // Removes and destroys all children
|
||||
virtual void DestroyChildren(); // Removes and destroys all children
|
||||
|
||||
inline bool IsBeingDeleted(void);
|
||||
inline bool IsBeingDeleted();
|
||||
|
||||
// MSW only: TRUE if this control is part of the main control
|
||||
virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
|
||||
|
||||
// Constraint implementation
|
||||
void UnsetConstraints(wxLayoutConstraints *c);
|
||||
inline wxList *GetConstraintsInvolvedIn(void) const ;
|
||||
inline wxList *GetConstraintsInvolvedIn() const ;
|
||||
// Back-pointer to other windows we're involved with, so if we delete
|
||||
// this window, we must delete any constraints we're involved with.
|
||||
void AddConstraintReference(wxWindow *otherWin);
|
||||
void RemoveConstraintReference(wxWindow *otherWin);
|
||||
void DeleteRelatedConstraints(void);
|
||||
void DeleteRelatedConstraints();
|
||||
|
||||
virtual void ResetConstraints(void);
|
||||
virtual void ResetConstraints();
|
||||
virtual void SetConstraintSizes(bool recurse = TRUE);
|
||||
virtual bool LayoutPhase1(int *noChanges);
|
||||
virtual bool LayoutPhase2(int *noChanges);
|
||||
@ -487,25 +489,25 @@ public:
|
||||
virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
|
||||
|
||||
// Make sure the window style reflects the HWND style (roughly)
|
||||
virtual void AdoptAttributesFromHWND(void);
|
||||
virtual void AdoptAttributesFromHWND();
|
||||
|
||||
// Setup background and foreground colours correctly
|
||||
virtual void SetupColours(void);
|
||||
virtual void SetupColours();
|
||||
|
||||
// Saves the last message information before calling base version
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
// Handlers
|
||||
virtual void MSWOnCreate(WXLPCREATESTRUCT cs);
|
||||
virtual bool MSWOnPaint(void);
|
||||
virtual WXHICON MSWOnQueryDragIcon(void) { return 0; }
|
||||
virtual bool MSWOnPaint();
|
||||
virtual WXHICON MSWOnQueryDragIcon() { return 0; }
|
||||
virtual void MSWOnSize(int x, int y, WXUINT flag);
|
||||
virtual void MSWOnWindowPosChanging(void *lpPos);
|
||||
virtual void MSWOnHScroll(WXWORD nSBCode, WXWORD pos, WXHWND control);
|
||||
virtual void MSWOnVScroll(WXWORD nSBCode, WXWORD pos, WXHWND control);
|
||||
virtual bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control);
|
||||
virtual long MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual long MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual WXHBRUSH MSWOnCtlColor(WXHDC dc, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
@ -514,11 +516,11 @@ public:
|
||||
virtual bool MSWOnEraseBkgnd(WXHDC pDC);
|
||||
virtual void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu);
|
||||
virtual void MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem);
|
||||
virtual bool MSWOnClose(void);
|
||||
virtual bool MSWOnClose();
|
||||
// Return TRUE to end session, FALSE to veto end session.
|
||||
virtual bool MSWOnQueryEndSession(long logOff);
|
||||
virtual bool MSWOnEndSession(bool endSession, long logOff);
|
||||
virtual bool MSWOnDestroy(void);
|
||||
virtual bool MSWOnDestroy();
|
||||
virtual bool MSWOnSetFocus(WXHWND wnd);
|
||||
virtual bool MSWOnKillFocus(WXHWND wnd);
|
||||
virtual void MSWOnDropFiles(WXWPARAM wParam);
|
||||
@ -565,10 +567,10 @@ public:
|
||||
virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
virtual bool MSWProcessMessage(WXMSG* pMsg);
|
||||
virtual bool MSWTranslateMessage(WXMSG* pMsg);
|
||||
virtual void MSWDestroyWindow(void);
|
||||
virtual void MSWDestroyWindow();
|
||||
|
||||
// Detach "Window" menu from menu bar so it doesn't get deleted
|
||||
void MSWDetachWindowMenu(void);
|
||||
void MSWDetachWindowMenu();
|
||||
|
||||
inline WXFARPROC MSWGetOldWndProc() const;
|
||||
inline void MSWSetOldWndProc(WXFARPROC proc);
|
||||
@ -578,9 +580,9 @@ public:
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
inline void SetShowing(bool show);
|
||||
inline bool IsUserEnabled(void) const;
|
||||
inline bool GetUseCtl3D(void) const ;
|
||||
inline bool GetTransparentBackground(void) const ;
|
||||
inline bool IsUserEnabled() const;
|
||||
inline bool GetUseCtl3D() const ;
|
||||
inline bool GetTransparentBackground() const ;
|
||||
|
||||
// Responds to colour changes: passes event on to children.
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
@ -590,7 +592,7 @@ public:
|
||||
|
||||
// Sends an OnInitDialog event, which in turns transfers data to
|
||||
// to the window via validators.
|
||||
virtual void InitDialog(void);
|
||||
virtual void InitDialog();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//// PROTECTED DATA
|
||||
@ -678,57 +680,61 @@ public:
|
||||
bool m_isBeingDeleted; // Fudge because can't access parent
|
||||
// when being deleted
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//// INLINES
|
||||
|
||||
inline void *wxWindow::GetHandle(void) const { return (void *)GetHWND(); }
|
||||
inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
|
||||
inline int wxWindow::GetId() const { return m_windowId; }
|
||||
inline void wxWindow::SetId(int id) { m_windowId = id; }
|
||||
inline wxWindow *wxWindow::GetParent(void) const { return m_windowParent; }
|
||||
inline wxWindow *wxWindow::GetParent() const { return m_windowParent; }
|
||||
inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
|
||||
inline wxWindow *wxWindow::GetGrandParent(void) const { return (m_windowParent ? m_windowParent->m_windowParent : NULL); }
|
||||
inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : NULL); }
|
||||
inline wxList *wxWindow::GetChildren() const { return m_children; }
|
||||
inline wxFont *wxWindow::GetFont(void) const { return (wxFont *) & m_windowFont; }
|
||||
inline wxString wxWindow::GetName(void) const { return m_windowName; }
|
||||
inline wxFont *wxWindow::GetFont() const { return (wxFont *) & m_windowFont; }
|
||||
inline wxString wxWindow::GetName() const { return m_windowName; }
|
||||
inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
|
||||
inline long wxWindow::GetWindowStyleFlag(void) const { return m_windowStyle; }
|
||||
inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; }
|
||||
inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; }
|
||||
inline void wxWindow::SetDoubleClick(bool flag) { m_doubleClickAllowed = flag; }
|
||||
inline bool wxWindow::GetDoubleClick(void) const { return m_doubleClickAllowed; }
|
||||
inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed; }
|
||||
inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; }
|
||||
inline wxEvtHandler *wxWindow::GetEventHandler(void) const { return m_windowEventHandler; }
|
||||
inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; }
|
||||
inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; }
|
||||
inline bool wxWindow::GetAutoLayout(void) const { return m_autoLayout; }
|
||||
inline wxLayoutConstraints *wxWindow::GetConstraints(void) const { return m_constraints; }
|
||||
inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; }
|
||||
inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; }
|
||||
inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; };
|
||||
inline wxColour wxWindow::GetBackgroundColour(void) const { return m_backgroundColour; };
|
||||
inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; };
|
||||
inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; };
|
||||
inline wxColour wxWindow::GetForegroundColour(void) const { return m_foregroundColour; };
|
||||
inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; };
|
||||
|
||||
inline wxButton *wxWindow::GetDefaultItem(void) const { return m_defaultItem; }
|
||||
inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
|
||||
inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
|
||||
inline bool wxWindow::IsRetained(void) const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
|
||||
inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
|
||||
|
||||
inline void wxWindow::SetShowing(bool show) { m_isShown = show; }
|
||||
inline wxList *wxWindow::GetConstraintsInvolvedIn(void) const { return m_constraintsInvolvedIn; }
|
||||
inline wxSizer *wxWindow::GetSizer(void) const { return m_windowSizer; }
|
||||
inline wxWindow *wxWindow::GetSizerParent(void) const { return m_sizerParent; }
|
||||
inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; }
|
||||
inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; }
|
||||
inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; }
|
||||
inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; }
|
||||
inline WXFARPROC wxWindow::MSWGetOldWndProc() const { return m_oldWndProc; }
|
||||
inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
|
||||
inline wxValidator *wxWindow::GetValidator(void) const { return m_windowValidator; }
|
||||
inline bool wxWindow::IsUserEnabled(void) const { return m_winEnabled; }
|
||||
inline bool wxWindow::GetUseCtl3D(void) const { return m_useCtl3D; }
|
||||
inline bool wxWindow::GetTransparentBackground(void) const { return m_backgroundTransparent; }
|
||||
inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; }
|
||||
inline bool wxWindow::IsUserEnabled() const { return m_winEnabled; }
|
||||
inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D; }
|
||||
inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent; }
|
||||
inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
|
||||
inline int wxWindow::GetReturnCode(void) { return m_returnCode; }
|
||||
inline bool wxWindow::IsBeingDeleted(void) { return m_isBeingDeleted; }
|
||||
inline int wxWindow::GetReturnCode() { return m_returnCode; }
|
||||
inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted; }
|
||||
|
||||
// Window specific (so far)
|
||||
WXDLLEXPORT wxWindow* wxGetActiveWindow(void);
|
||||
WXDLLEXPORT wxWindow* wxGetActiveWindow();
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows;
|
||||
|
||||
@ -736,7 +742,7 @@ WXDLLEXPORT int wxCharCodeMSWToWX(int keySym);
|
||||
WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual);
|
||||
|
||||
// Allocates control ids
|
||||
WXDLLEXPORT int NewControlId(void);
|
||||
WXDLLEXPORT int NewControlId();
|
||||
|
||||
#endif
|
||||
// _WX_WINDOW_H_
|
||||
|
@ -28,6 +28,11 @@
|
||||
#include "wx/utils.h"
|
||||
#include <wx/intl.h>
|
||||
|
||||
// there are just too many of those...
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4706) // assignment within conditional expression
|
||||
#endif // VC++
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -1545,5 +1550,9 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
|
||||
pattern++;
|
||||
return ((*str == '\0') && (*pattern == '\0'));
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4706) // assignment within conditional expression
|
||||
#endif // VC++
|
@ -328,7 +328,7 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const
|
||||
|
||||
if (col->Red () == red && col->Green () == green && col->Blue () == blue)
|
||||
{
|
||||
char *found = node->key.string;
|
||||
const char *found = node->GetKeyString();
|
||||
if (found)
|
||||
return wxString(found);
|
||||
}
|
||||
@ -621,12 +621,6 @@ wxSize wxGetDisplaySize()
|
||||
return wxSize(x, y);
|
||||
}
|
||||
|
||||
wxResourceCache::wxResourceCache () : wxList() {
|
||||
}
|
||||
|
||||
wxResourceCache::wxResourceCache (const unsigned int the_key_type) : wxList(the_key_type) {
|
||||
}
|
||||
|
||||
wxResourceCache::~wxResourceCache () {
|
||||
wxNode *node = First ();
|
||||
while (node) {
|
||||
|
@ -275,10 +275,8 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName)
|
||||
// examine header
|
||||
bool bValid = (size_t)nSize > sizeof(wxMsgCatalogHeader);
|
||||
|
||||
wxMsgCatalogHeader *pHeader;
|
||||
wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData;
|
||||
if ( bValid ) {
|
||||
pHeader = (wxMsgCatalogHeader *)m_pData;
|
||||
|
||||
// we'll have to swap all the integers if it's true
|
||||
m_bSwapped = pHeader->magic == MSGCATALOG_MAGIC_SW;
|
||||
|
||||
|
@ -1,14 +1,21 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Name: list.cpp
|
||||
// Purpose: wxList implementation
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Modified by: VZ at 16/11/98: WX_DECLARE_LIST() and typesafe lists added
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// =============================================================================
|
||||
// declarations
|
||||
// =============================================================================
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// headers
|
||||
// -----------------------------------------------------------------------------
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "list.h"
|
||||
#endif
|
||||
@ -20,11 +27,14 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include <wx/intl.h>
|
||||
#include "wx/utils.h" // for copystring() (beurk...)
|
||||
#endif
|
||||
|
||||
// Sun CC compatibility (interference with xview/pkg.h, apparently...)
|
||||
@ -35,371 +45,343 @@
|
||||
#undef va_list
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
// =============================================================================
|
||||
// implementation
|
||||
// =============================================================================
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNode, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxList, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStringList, wxList)
|
||||
#endif
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxNodeBase
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one,
|
||||
wxObject * object)
|
||||
wxNodeBase::wxNodeBase(wxListBase *list,
|
||||
wxNodeBase *previous, wxNodeBase *next,
|
||||
void *data, const wxListKey& key)
|
||||
{
|
||||
data = object;
|
||||
previous = last_one;
|
||||
next = next_one;
|
||||
list = the_list;
|
||||
key.string = (char *) NULL;
|
||||
m_list = list;
|
||||
m_data = data;
|
||||
m_previous = previous;
|
||||
m_next = next;
|
||||
|
||||
if (previous)
|
||||
previous->next = this;
|
||||
|
||||
if (next)
|
||||
next->previous = this;
|
||||
}
|
||||
|
||||
// Keyed constructor
|
||||
wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one,
|
||||
wxObject * object, long the_key)
|
||||
switch ( key.GetKeyType() )
|
||||
{
|
||||
data = object;
|
||||
previous = last_one;
|
||||
next = next_one;
|
||||
list = the_list;
|
||||
key.integer = the_key;
|
||||
|
||||
if (previous)
|
||||
previous->next = this;
|
||||
|
||||
if (next)
|
||||
next->previous = this;
|
||||
}
|
||||
|
||||
wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one,
|
||||
wxObject * object, const char *the_key)
|
||||
{
|
||||
data = object;
|
||||
previous = last_one;
|
||||
next = next_one;
|
||||
list = the_list;
|
||||
key.string = copystring (the_key);
|
||||
|
||||
if (previous)
|
||||
previous->next = this;
|
||||
|
||||
if (next)
|
||||
next->previous = this;
|
||||
}
|
||||
|
||||
|
||||
wxNode::~wxNode (void)
|
||||
{
|
||||
if (list)
|
||||
list->n--;
|
||||
|
||||
if (list && list->destroy_data)
|
||||
delete data;
|
||||
|
||||
if (list && list->key_type == wxKEY_STRING && key.string)
|
||||
delete[]key.string;
|
||||
|
||||
// Make next node point back to the previous node from here
|
||||
if (next)
|
||||
next->previous = previous;
|
||||
else if (list)
|
||||
// If there's a new end of list (deleting the last one)
|
||||
// make sure the list knows about it.
|
||||
list->last_node = previous;
|
||||
|
||||
// Make the previous node point to the next node from here
|
||||
if (previous)
|
||||
previous->next = next;
|
||||
|
||||
// Or if no previous node (start of list), make sure list points at
|
||||
// the next node which becomes the first!.
|
||||
else if (list)
|
||||
list->first_node = next;
|
||||
}
|
||||
|
||||
wxList::wxList (void)
|
||||
{
|
||||
first_node = (wxNode *) NULL;
|
||||
last_node = (wxNode *) NULL;
|
||||
n = 0;
|
||||
destroy_data = 0;
|
||||
key_type = wxKEY_NONE;
|
||||
}
|
||||
|
||||
wxList::wxList (int N, wxObject * Objects[])
|
||||
{
|
||||
wxNode *last = (wxNode *) NULL;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
wxNode *next = new wxNode (this, last, (wxNode *) NULL, Objects[i]);
|
||||
last = next;
|
||||
if (i == 0)
|
||||
first_node = next;
|
||||
}
|
||||
last_node = last;
|
||||
n = N;
|
||||
key_type = wxKEY_NONE;
|
||||
}
|
||||
|
||||
wxList::wxList (const unsigned int the_key_type)
|
||||
{
|
||||
n = 0;
|
||||
destroy_data = 0;
|
||||
first_node = (wxNode *) NULL;
|
||||
last_node = (wxNode *) NULL;
|
||||
key_type = the_key_type;
|
||||
}
|
||||
|
||||
// Variable argument list, terminated by a zero
|
||||
wxList::wxList (wxObject * first_one...)
|
||||
{
|
||||
// #ifndef __SGI__
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, first_one);
|
||||
|
||||
wxNode *last = new wxNode (this, (wxNode *) NULL, (wxNode *) NULL, first_one);
|
||||
first_node = last;
|
||||
n = 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
wxObject *object = va_arg (ap, wxObject *);
|
||||
// if (object == NULL) // Doesn't work in Windows -- segment is non-zero for NULL!
|
||||
#ifdef __WXMSW__
|
||||
if ((int) object == 0)
|
||||
#else
|
||||
if ((long) object == 0)
|
||||
#endif
|
||||
case wxKEY_NONE:
|
||||
break;
|
||||
else
|
||||
{
|
||||
wxNode *node = new wxNode (this, last, (wxNode *) NULL, object);
|
||||
last = node;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
last_node = last;
|
||||
va_end (ap);
|
||||
|
||||
destroy_data = 0;
|
||||
key_type = wxKEY_NONE;
|
||||
/*
|
||||
#else
|
||||
fprintf (stderr, "Error: cannot use variable-argument functions on SGI!\n");
|
||||
#endif
|
||||
*/
|
||||
case wxKEY_INTEGER:
|
||||
m_key.integer = key.GetNumber();
|
||||
break;
|
||||
|
||||
case wxKEY_STRING:
|
||||
// to be free()d later
|
||||
m_key.string = strdup(key.GetString());
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG("invalid key type");
|
||||
}
|
||||
|
||||
wxList::~wxList (void)
|
||||
if ( previous )
|
||||
previous->m_next = this;
|
||||
|
||||
if ( next )
|
||||
next->m_previous = this;
|
||||
}
|
||||
|
||||
wxNodeBase::~wxNodeBase()
|
||||
{
|
||||
wxNode *each = first_node;
|
||||
while (each)
|
||||
// handle the case when we're being deleted from the list by the user (i.e.
|
||||
// not by the list itself from DeleteNode) - we must do it for
|
||||
// compatibility with old code
|
||||
if ( m_list != NULL )
|
||||
{
|
||||
wxNode *next = each->Next ();
|
||||
delete each;
|
||||
m_list->DetachNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxListBase
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void wxListBase::Init(wxKeyType keyType = wxKEY_NONE)
|
||||
{
|
||||
m_nodeFirst =
|
||||
m_nodeLast = (wxNodeBase *) NULL;
|
||||
m_count = 0;
|
||||
m_destroy = FALSE;
|
||||
m_keyType = keyType;
|
||||
}
|
||||
|
||||
wxListBase::wxListBase(size_t count, void *elements[])
|
||||
{
|
||||
Init();
|
||||
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
Append(elements[n]);
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBase::DoCopy(const wxListBase& list)
|
||||
{
|
||||
wxASSERT_MSG( !list.m_destroy,
|
||||
"copying list which owns it's elements is a bad idea" );
|
||||
|
||||
m_count = list.m_count;
|
||||
m_destroy = list.m_destroy;
|
||||
m_keyType = list.m_keyType;
|
||||
m_nodeFirst =
|
||||
m_nodeLast = (wxNodeBase *) NULL;
|
||||
|
||||
for ( wxNodeBase *node = list.GetFirst(); node; node = node->GetNext() )
|
||||
{
|
||||
Append(node);
|
||||
}
|
||||
}
|
||||
|
||||
wxListBase::~wxListBase()
|
||||
{
|
||||
wxNodeBase *each = m_nodeFirst;
|
||||
while ( each != NULL )
|
||||
{
|
||||
wxNodeBase *next = each->GetNext();
|
||||
DoDeleteNode(each);
|
||||
each = next;
|
||||
}
|
||||
}
|
||||
|
||||
wxNode *wxList::Append(wxObject *object)
|
||||
wxNodeBase *wxListBase::AppendCommon(wxNodeBase *node)
|
||||
{
|
||||
wxNode *node = new wxNode(this, last_node, (wxNode *) NULL, object);
|
||||
if (!first_node)
|
||||
first_node = node;
|
||||
last_node = node;
|
||||
n ++;
|
||||
if ( !m_nodeFirst )
|
||||
{
|
||||
m_nodeFirst = node;
|
||||
m_nodeLast = m_nodeFirst;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nodeLast->m_next = node;
|
||||
m_nodeLast = node;
|
||||
}
|
||||
|
||||
m_count++;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
wxNode *wxList::Nth (int i) const
|
||||
wxNodeBase *wxListBase::Append(void *object)
|
||||
{
|
||||
int j = 0;
|
||||
for (wxNode * current = First (); current; current = current->Next ())
|
||||
// all objects in a keyed list should have a key
|
||||
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
|
||||
"need a key for the object to append" );
|
||||
|
||||
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object);
|
||||
|
||||
return AppendCommon(node);
|
||||
}
|
||||
|
||||
wxNodeBase *wxListBase::Append(long key, void *object)
|
||||
{
|
||||
wxCHECK_MSG( (m_keyType == wxKEY_INTEGER) ||
|
||||
(m_keyType == wxKEY_NONE && m_count == 0),
|
||||
(wxNodeBase *)NULL,
|
||||
"can't append object with numeric key to this list" );
|
||||
|
||||
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key);
|
||||
return AppendCommon(node);
|
||||
}
|
||||
|
||||
wxNodeBase *wxListBase::Append (const char *key, void *object)
|
||||
{
|
||||
wxCHECK_MSG( (m_keyType == wxKEY_STRING) ||
|
||||
(m_keyType == wxKEY_NONE && m_count == 0),
|
||||
(wxNodeBase *)NULL,
|
||||
"can't append object with string key to this list" );
|
||||
|
||||
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key);
|
||||
return AppendCommon(node);
|
||||
}
|
||||
|
||||
wxNodeBase *wxListBase::Insert(wxNodeBase *position, void *object)
|
||||
{
|
||||
// all objects in a keyed list should have a key
|
||||
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
|
||||
"need a key for the object to insert" );
|
||||
|
||||
wxNodeBase *prev = (wxNodeBase *)NULL;
|
||||
if ( position )
|
||||
prev = position->GetPrevious();
|
||||
//else
|
||||
// inserting in the beginning of the list
|
||||
|
||||
wxNodeBase *node = CreateNode(prev, position, object);
|
||||
if ( !m_nodeFirst )
|
||||
{
|
||||
m_nodeFirst = node;
|
||||
m_nodeLast = node;
|
||||
}
|
||||
|
||||
if ( prev == NULL )
|
||||
{
|
||||
m_nodeFirst = node;
|
||||
}
|
||||
|
||||
m_count++;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
wxNodeBase *wxListBase::Item(size_t n) const
|
||||
{
|
||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||
{
|
||||
if ( n-- == 0 )
|
||||
{
|
||||
if (j++ == i)
|
||||
return current;
|
||||
}
|
||||
return (wxNode *) NULL; // No such element
|
||||
|
||||
}
|
||||
|
||||
wxNode *wxList::Find (long key) const
|
||||
{
|
||||
wxNode *current = First();
|
||||
while (current)
|
||||
{
|
||||
if (current->key.integer == key)
|
||||
return current;
|
||||
current = current->Next();
|
||||
wxFAIL_MSG( "invalid index in wxListBase::Item" );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (wxNode *) NULL; // Not found!
|
||||
}
|
||||
wxNodeBase *wxListBase::Find(const wxListKey& key) const
|
||||
{
|
||||
wxASSERT_MSG( m_keyType == key.GetKeyType(),
|
||||
"this list is not keyed on the type of this key" );
|
||||
|
||||
wxNode *wxList::Find (const char *key) const
|
||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||
{
|
||||
wxNode *current = First();
|
||||
while (current)
|
||||
if ( key == current->m_key )
|
||||
{
|
||||
if (!current->key.string)
|
||||
{
|
||||
wxFatalError (_("wxList: string key not present, probably did not Append correctly!"));
|
||||
break;
|
||||
}
|
||||
if (strcmp (current->key.string, key) == 0)
|
||||
return current;
|
||||
current = current->Next();
|
||||
}
|
||||
|
||||
return (wxNode *) NULL; // Not found!
|
||||
|
||||
}
|
||||
|
||||
wxNode *wxList::Member (wxObject * object) const
|
||||
{
|
||||
for (wxNode * current = First (); current; current = current->Next ())
|
||||
{
|
||||
wxObject *each = current->Data ();
|
||||
if (each == object)
|
||||
return current;
|
||||
}
|
||||
return (wxNode *) NULL;
|
||||
}
|
||||
|
||||
bool wxList::DeleteNode (wxNode * node)
|
||||
// not found
|
||||
return (wxNodeBase *)NULL;
|
||||
}
|
||||
|
||||
wxNodeBase *wxListBase::Find(void *object) const
|
||||
{
|
||||
if (node)
|
||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||
{
|
||||
if ( current->GetData() == object )
|
||||
return current;
|
||||
}
|
||||
|
||||
// not found
|
||||
return (wxNodeBase *)NULL;
|
||||
}
|
||||
|
||||
void wxListBase::DoDeleteNode(wxNodeBase *node)
|
||||
{
|
||||
// free node's data
|
||||
if ( m_keyType == wxKEY_STRING )
|
||||
{
|
||||
free(node->m_key.string);
|
||||
}
|
||||
|
||||
if ( m_destroy )
|
||||
{
|
||||
node->DeleteData();
|
||||
}
|
||||
|
||||
delete node;
|
||||
}
|
||||
|
||||
wxNodeBase *wxListBase::DetachNode(wxNodeBase *node)
|
||||
{
|
||||
wxCHECK_MSG( node, NULL, "detaching NULL wxNodeBase" );
|
||||
wxCHECK_MSG( node->m_list == this, NULL,
|
||||
"detaching node which is not from this list" );
|
||||
|
||||
// update the list
|
||||
wxNodeBase **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next
|
||||
: &m_nodeFirst;
|
||||
wxNodeBase **nextPrev = node->GetNext() ? &node->GetNext()->m_previous
|
||||
: &m_nodeLast;
|
||||
|
||||
*prevNext = node->GetNext();
|
||||
*nextPrev = node->GetPrevious();
|
||||
|
||||
m_count--;
|
||||
|
||||
// mark the node as not belonging to this list any more
|
||||
node->m_list = NULL;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
bool wxListBase::DeleteNode(wxNodeBase *node)
|
||||
{
|
||||
if ( !DetachNode(node) )
|
||||
return FALSE;
|
||||
|
||||
DoDeleteNode(node);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxListBase::DeleteObject(void *object)
|
||||
{
|
||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||
{
|
||||
if ( current->GetData() == object )
|
||||
{
|
||||
DeleteNode(current);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxList::DeleteObject (wxObject * object)
|
||||
|
||||
void wxListBase::Clear()
|
||||
{
|
||||
// Search list for object
|
||||
for (wxNode * current = first_node; current; current = current->Next ())
|
||||
{
|
||||
if (current->Data () == object)
|
||||
{
|
||||
delete current;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE; // Did not find the object
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Insert new node at front of list
|
||||
wxNode *wxList::Insert (wxObject * object)
|
||||
{
|
||||
wxNode *node = new wxNode (this, (wxNode *) NULL, First (), object);
|
||||
first_node = node;
|
||||
|
||||
if (!(node->Next ()))
|
||||
last_node = node;
|
||||
|
||||
n++;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
// Insert new node before given node.
|
||||
wxNode *wxList::Insert (wxNode * position, wxObject * object)
|
||||
{
|
||||
wxNode *prev = (wxNode *) NULL;
|
||||
if (position)
|
||||
prev = position->Previous ();
|
||||
|
||||
wxNode *node = new wxNode (this, prev, position, object);
|
||||
if (!first_node)
|
||||
{
|
||||
first_node = node;
|
||||
last_node = node;
|
||||
}
|
||||
if (!prev)
|
||||
first_node = node;
|
||||
|
||||
n++;
|
||||
return node;
|
||||
}
|
||||
|
||||
// Keyed append
|
||||
wxNode *wxList::Append (long key, wxObject * object)
|
||||
{
|
||||
wxNode *node = new wxNode (this, last_node, (wxNode *) NULL, object, key);
|
||||
if (!first_node)
|
||||
first_node = node;
|
||||
last_node = node;
|
||||
n++;
|
||||
return node;
|
||||
}
|
||||
|
||||
wxNode *wxList::Append (const char *key, wxObject * object)
|
||||
{
|
||||
wxNode *node = new wxNode (this, last_node, (wxNode *) NULL, object, key);
|
||||
if (!first_node)
|
||||
first_node = node;
|
||||
last_node = node;
|
||||
n++;
|
||||
return node;
|
||||
}
|
||||
|
||||
void wxList::Clear (void)
|
||||
{
|
||||
wxNode *current = first_node;
|
||||
wxNodeBase *current = m_nodeFirst;
|
||||
while ( current )
|
||||
{
|
||||
wxNode *next = current->Next ();
|
||||
delete current;
|
||||
wxNodeBase *next = current->GetNext();
|
||||
DoDeleteNode(current);
|
||||
current = next;
|
||||
}
|
||||
first_node = (wxNode *) NULL;
|
||||
last_node = (wxNode *) NULL;
|
||||
n = 0;
|
||||
|
||||
m_nodeFirst =
|
||||
m_nodeLast = (wxNodeBase *)NULL;
|
||||
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
//Executes function F with all items present in the list
|
||||
void wxList::ForEach(wxListIterateFunction F)
|
||||
void wxListBase::ForEach(wxListIterateFunction F)
|
||||
{
|
||||
wxNode *each = first_node;
|
||||
while (each)
|
||||
{ (*F)( each->Data ());
|
||||
each = each->Next();
|
||||
}
|
||||
}
|
||||
// Returns a pointer to the item which returns TRUE with function F
|
||||
// or NULL if no such item found
|
||||
wxObject *wxList::FirstThat(wxListIterateFunction F)
|
||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||
{
|
||||
wxNode *each = first_node;
|
||||
while (each)
|
||||
{ if ((*F)( each->Data ())) return each->Data();
|
||||
each = each->Next();
|
||||
(*F)(current->GetData());
|
||||
}
|
||||
return (wxNode *) NULL;
|
||||
}
|
||||
// Like FirstThat, but proceeds from the end backward
|
||||
wxObject *wxList::LastThat(wxListIterateFunction F)
|
||||
|
||||
void *wxListBase::FirstThat(wxListIterateFunction F)
|
||||
{
|
||||
wxNode *each = last_node;
|
||||
while (each)
|
||||
{ if ((*F)( each->Data ())) return each->Data();
|
||||
each = each->Previous();
|
||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||
{
|
||||
if ( (*F)(current->GetData()) )
|
||||
return current->GetData();
|
||||
}
|
||||
return (wxNode *) NULL;
|
||||
|
||||
return (wxNodeBase *)NULL;
|
||||
}
|
||||
|
||||
void *wxListBase::LastThat(wxListIterateFunction F)
|
||||
{
|
||||
for ( wxNodeBase *current = GetLast(); current; current = current->GetPrevious() )
|
||||
{
|
||||
if ( (*F)(current->GetData()) )
|
||||
return current->GetData();
|
||||
}
|
||||
|
||||
return (wxNodeBase *)NULL;
|
||||
}
|
||||
|
||||
// (stefan.hammes@urz.uni-heidelberg.de)
|
||||
@ -422,7 +404,7 @@ wxObject *wxList::LastThat(wxListIterateFunction F)
|
||||
//
|
||||
// void main()
|
||||
// {
|
||||
// wxList list;
|
||||
// wxListBase list;
|
||||
//
|
||||
// list.Append(new wxString("DEF"));
|
||||
// list.Append(new wxString("GHI"));
|
||||
@ -430,72 +412,70 @@ wxObject *wxList::LastThat(wxListIterateFunction F)
|
||||
// list.Sort(listcompare);
|
||||
// }
|
||||
|
||||
void wxList::Sort(const wxSortCompareFunction compfunc)
|
||||
void wxListBase::Sort(const wxSortCompareFunction compfunc)
|
||||
{
|
||||
// allocate an array for the wxObject pointers of the list
|
||||
const size_t num = Number();
|
||||
wxObject **objArray = new wxObject *[num];
|
||||
wxObject **objPtr = objArray;
|
||||
const size_t num = GetCount();
|
||||
void **objArray = new void *[num];
|
||||
void **objPtr = objArray;
|
||||
|
||||
// go through the list and put the pointers into the array
|
||||
wxNode *node = First();
|
||||
while(node!=NULL){
|
||||
wxNodeBase *node;
|
||||
for ( node = GetFirst(); node; node = node->Next() )
|
||||
{
|
||||
*objPtr++ = node->Data();
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// sort the array
|
||||
qsort((void *)objArray,num,sizeof(wxObject *),compfunc);
|
||||
|
||||
// put the sorted pointers back into the list
|
||||
objPtr = objArray;
|
||||
node = First();
|
||||
while(node!=NULL){
|
||||
for ( node = GetFirst(); node; node = node->Next() )
|
||||
{
|
||||
node->SetData(*objPtr++);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// free the array
|
||||
delete[] objArray;
|
||||
}
|
||||
|
||||
/*
|
||||
* String list
|
||||
*
|
||||
*/
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxList (a.k.a. wxObjectList)
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
wxStringList::wxStringList (void):
|
||||
wxList ()
|
||||
void wxObjectListNode::DeleteData()
|
||||
{
|
||||
delete (wxObject *)GetData();
|
||||
}
|
||||
|
||||
wxStringList::wxStringList (const wxStringList& list)
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxStringList
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// instead of WX_DEFINE_LIST(wxStringListBase) we define this function
|
||||
// ourselves
|
||||
void wxStringListNode::DeleteData()
|
||||
{
|
||||
(*this) = list;
|
||||
delete [] (char *)GetData();
|
||||
}
|
||||
|
||||
// Variable argument list, terminated by a zero
|
||||
// Makes new storage for the strings
|
||||
wxStringList::wxStringList (const char *first...)
|
||||
wxStringList::wxStringList (const char *first, ...)
|
||||
{
|
||||
// #ifndef __SGI__
|
||||
n = 0;
|
||||
destroy_data = 0;
|
||||
key_type = wxKEY_NONE;
|
||||
first_node = (wxNode *) NULL;
|
||||
last_node = (wxNode *) NULL;
|
||||
|
||||
if ( !first )
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, first);
|
||||
|
||||
wxNode *last = new wxNode (this, (wxNode *) NULL, (wxNode *) NULL, (wxObject *) copystring (first));
|
||||
first_node = last;
|
||||
n = 1;
|
||||
|
||||
const char *s = first;
|
||||
for (;;)
|
||||
{
|
||||
char *s = va_arg (ap, char *);
|
||||
Add(s);
|
||||
|
||||
s = va_arg(ap, const char *);
|
||||
// if (s == NULL)
|
||||
#ifdef __WXMSW__
|
||||
if ((int) s == 0)
|
||||
@ -503,80 +483,42 @@ wxStringList::wxStringList (const char *first...)
|
||||
if ((long) s == 0)
|
||||
#endif
|
||||
break;
|
||||
else
|
||||
{
|
||||
wxNode *node = new wxNode (this, last, (wxNode *) NULL, (wxObject *) copystring (s));
|
||||
last = node;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
last_node = last;
|
||||
|
||||
va_end(ap);
|
||||
/*
|
||||
#else
|
||||
fprintf (stderr, "Error: cannot use variable-argument functions on SGI!\n");
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
wxStringList::~wxStringList (void)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void wxStringList::Clear(void)
|
||||
{
|
||||
wxNode *each = First();
|
||||
while (each)
|
||||
{
|
||||
char *s = (char *) each->Data ();
|
||||
delete[]s;
|
||||
wxNode *next = each->Next ();
|
||||
delete each;
|
||||
each = next;
|
||||
}
|
||||
wxList::Clear();
|
||||
}
|
||||
|
||||
wxNode *wxStringList::Add (const char *s)
|
||||
{
|
||||
return Append ((wxObject *) (copystring (s)));
|
||||
}
|
||||
|
||||
void wxStringList::Delete (const char *s)
|
||||
{
|
||||
for (wxNode * node = First (); node; node = node->Next ())
|
||||
{
|
||||
char *string = (char *) node->Data ();
|
||||
if (string == s || strcmp (string, s) == 0)
|
||||
{
|
||||
delete[]string;
|
||||
delete node;
|
||||
break; // Done!
|
||||
|
||||
}
|
||||
} // for
|
||||
|
||||
}
|
||||
|
||||
// Only makes new strings if arg is TRUE
|
||||
char **wxStringList::ListToArray(bool new_copies) const
|
||||
{
|
||||
char **string_array = new char *[Number ()];
|
||||
wxNode *node = First ();
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
char **string_array = new char *[GetCount()];
|
||||
wxStringListNode *node = GetFirst();
|
||||
for (size_t i = 0; i < GetCount(); i++)
|
||||
{
|
||||
char *s = (char *) node->Data ();
|
||||
char *s = node->GetData();
|
||||
if ( new_copies )
|
||||
string_array[i] = copystring(s);
|
||||
else
|
||||
string_array[i] = s;
|
||||
node = node->Next ();
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
return string_array;
|
||||
}
|
||||
|
||||
// Checks whether s is a member of the list
|
||||
bool wxStringList::Member(const char *s) const
|
||||
{
|
||||
for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() )
|
||||
{
|
||||
const char *s1 = node->GetData();
|
||||
if (s == s1 || strcmp (s, s1) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
wx_comparestrings(const void *arg1, const void *arg2)
|
||||
{
|
||||
@ -587,53 +529,23 @@ wx_comparestrings (const void *arg1, const void *arg2)
|
||||
}
|
||||
|
||||
// Sort a list of strings - deallocates old nodes, allocates new
|
||||
void wxStringList::Sort (void)
|
||||
void wxStringList::Sort()
|
||||
{
|
||||
size_t N = n;
|
||||
size_t N = GetCount();
|
||||
char **array = new char *[N];
|
||||
|
||||
size_t i = 0;
|
||||
for (wxNode * node = First (); node; node = node->Next ())
|
||||
array[i++] = (char *) node->Data ();
|
||||
for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() )
|
||||
{
|
||||
array[i++] = node->GetData();
|
||||
}
|
||||
|
||||
qsort (array, N, sizeof (char *), wx_comparestrings);
|
||||
Clear();
|
||||
|
||||
for (i = 0; i < N; i++)
|
||||
Append ((wxObject *) (array[i]));
|
||||
Append (array[i]);
|
||||
|
||||
delete[]array;
|
||||
}
|
||||
|
||||
// Checks whether s is a member of the list
|
||||
bool wxStringList::Member (const char *s) const
|
||||
{
|
||||
for (wxNode * node = First (); node; node = node->Next ())
|
||||
{
|
||||
const char *s1 = (const char *) node->Data ();
|
||||
if (s == s1 || strcmp (s, s1) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxStringList::operator= (const wxStringList& list)
|
||||
{
|
||||
Clear();
|
||||
|
||||
wxNode *node = list.First();
|
||||
while (node)
|
||||
{
|
||||
char *s = (char *) node->Data ();
|
||||
Add(s);
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
char* wxStringList::operator[] (int i) const
|
||||
{
|
||||
wxASSERT_MSG( (i < Number()), "Invalid index for wxStringList" );
|
||||
|
||||
return (char*) (Nth(i)->Data());
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,10 @@
|
||||
|
||||
#if wxUSE_ODBC
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4706) // assignment within conditional expression
|
||||
#endif // VC++
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/utils.h"
|
||||
#include "wx/dialog.h"
|
||||
@ -1827,4 +1831,8 @@ bool wxQueryField::IsDirty(void) {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4706) // assignment within conditional expression
|
||||
#endif // VC++
|
||||
|
||||
#endif // wxUSE_ODBC
|
||||
|
@ -20,6 +20,12 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4706) // assignment within conditional expression
|
||||
#endif // VC++
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#include "wx/setup.h"
|
||||
@ -59,8 +65,6 @@
|
||||
|
||||
#include "wx/log.h"
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
@ -2853,4 +2857,8 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso
|
||||
return table->CreateItem((wxWindow *)this, resource, parentResource);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4706) // assignment within conditional expression
|
||||
#endif // VC++
|
||||
|
||||
#endif // wxUSE_WX_RESOURCES
|
||||
|
@ -195,7 +195,7 @@ void wxToolBarBase::AddSeparator ()
|
||||
{
|
||||
wxToolBarTool *tool = new wxToolBarTool;
|
||||
tool->m_toolStyle = wxTOOL_STYLE_SEPARATOR;
|
||||
m_tools.Append(tool);
|
||||
m_tools.Append(-1, tool);
|
||||
}
|
||||
|
||||
void wxToolBarBase::ClearTools(void)
|
||||
|
@ -50,10 +50,15 @@
|
||||
#include <commctrl.h>
|
||||
#endif
|
||||
|
||||
// use debug CRT functions for memory leak detections in VC++
|
||||
/* Here we go again commenting it out. PLEASE don't
|
||||
* uncomment this again.
|
||||
#if defined(__WXDEBUG__) && defined(_MSC_VER)
|
||||
// use debug CRT functions for memory leak detections in VC++ if we're not
|
||||
// using wxWindows own methods
|
||||
#if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS
|
||||
#define wxUSE_VC_CRTDBG
|
||||
#else
|
||||
#undef wxUSE_VC_CRTDBG
|
||||
#endif
|
||||
|
||||
#ifdef wxUSE_VC_CRTDBG
|
||||
// VC++ uses this macro as debug/release mode indicator
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG
|
||||
@ -61,7 +66,6 @@
|
||||
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
*/
|
||||
|
||||
extern char *wxBuffer;
|
||||
extern char *wxOsVersion;
|
||||
@ -115,32 +119,12 @@ bool wxApp::Initialize()
|
||||
{
|
||||
wxBuffer = new char[1500];
|
||||
|
||||
/* PLEASE don't uncomment this again. IT DOESN'T WORK when building
|
||||
* using the makefile.
|
||||
#if defined(__WXDEBUG__) && defined(_MSC_VER)
|
||||
#ifdef wxUSE_VC_CRTDBG
|
||||
// do check for memory leaks on program exit
|
||||
// (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
|
||||
// deallocated memory which may be used to simulate low-memory condition)
|
||||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif // debug build under MS VC++
|
||||
*/
|
||||
|
||||
|
||||
// 22/11/98: we're converting to wxLogDebug instead of wxTrace,
|
||||
// so these are now obsolete.
|
||||
|
||||
#if 0
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
#if defined(_WINDLL)
|
||||
streambuf* sBuf = NULL;
|
||||
#else // EXE
|
||||
streambuf* sBuf = new wxDebugStreamBuf;
|
||||
#endif // DLL
|
||||
|
||||
ostream* oStr = new ostream(sBuf) ;
|
||||
wxDebugContext::SetStream(oStr, sBuf);
|
||||
#endif // wxUSE_MEMORY_TRACING
|
||||
#endif
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
|
@ -741,19 +741,19 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
||||
#if wxUSE_XPM_IN_MSW
|
||||
HDC dc = NULL;
|
||||
|
||||
Visual *visual = NULL;
|
||||
XImage ximage;
|
||||
|
||||
dc = CreateCompatibleDC(NULL);
|
||||
if (dc)
|
||||
{
|
||||
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
|
||||
{ /* for following SetPixel */
|
||||
{
|
||||
/* for following SetPixel */
|
||||
/* fill the XImage struct 'by hand' */
|
||||
ximage.width = M_BITMAPHANDLERDATA->m_width;
|
||||
ximage.height = M_BITMAPHANDLERDATA->m_height;
|
||||
ximage.depth = M_BITMAPHANDLERDATA->m_depth;
|
||||
ximage.bitmap = (void *)M_BITMAPHANDLERDATA->m_hBitmap;
|
||||
ximage.bitmap = (HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap;
|
||||
int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name,
|
||||
&ximage, (XImage *) NULL, (XpmAttributes *) NULL);
|
||||
|
||||
|
@ -240,6 +240,12 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
control_width = longest + cx*5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If non-default width...
|
||||
control_width = w1;
|
||||
}
|
||||
|
||||
|
||||
// Choice drop-down list depends on number of items (limited to 10)
|
||||
if (h1 <= 0)
|
||||
@ -250,10 +256,6 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMin(10, m_noStrings) + 1);
|
||||
}
|
||||
|
||||
// If non-default width...
|
||||
if (w1 >= 0)
|
||||
control_width = w1;
|
||||
|
||||
control_height = h1;
|
||||
|
||||
// Calculations may have made text size too small
|
||||
|
@ -185,7 +185,8 @@ long wxControl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam,
|
||||
WXLPARAM* WXUNUSED(result))
|
||||
{
|
||||
#if defined(__WIN95__)
|
||||
wxCommandEvent event(wxEVT_NULL, m_windowId);
|
||||
@ -237,15 +238,15 @@ bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
*/
|
||||
default:
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
event.SetEventType(eventType);
|
||||
event.SetEventObject(this);
|
||||
|
||||
if ( !GetEventHandler()->ProcessEvent(event) )
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
#else
|
||||
#else // !Win95
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ void wxDC::DrawText(const wxString& text, long x, long y, bool use16bit)
|
||||
if (m_textForegroundColour.Ok())
|
||||
SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ;
|
||||
|
||||
DWORD old_background;
|
||||
DWORD old_background = 0;
|
||||
if (m_textBackgroundColour.Ok())
|
||||
{
|
||||
old_background = SetBkColor((HDC) m_hDC, m_textBackgroundColour.GetPixel() ) ;
|
||||
@ -1132,7 +1132,7 @@ bool wxDC::Blit(long xdest, long ydest, long width, long height,
|
||||
rop == wxSRC_AND ? SRCAND :
|
||||
SRCCOPY;
|
||||
|
||||
bool success;
|
||||
bool success = TRUE;
|
||||
if (useMask && source->m_selectedBitmap.Ok() && source->m_selectedBitmap.GetMask())
|
||||
{
|
||||
|
||||
|
@ -473,7 +473,8 @@ BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
|
||||
goto ErrExit;
|
||||
}
|
||||
|
||||
if (!(nNumColors = (WORD)lpbi->biClrUsed))
|
||||
nNumColors = (WORD)lpbi->biClrUsed;
|
||||
if ( nNumColors == 0 )
|
||||
{
|
||||
/* no color table for 24-bit, default size otherwise */
|
||||
if (lpbi->biBitCount != 24)
|
||||
@ -594,7 +595,8 @@ BOOL PASCAL MakeBitmapAndPalette(HDC hDC, HANDLE hDIB,
|
||||
lpInfo = (LPBITMAPINFOHEADER) GlobalLock(hDIB);
|
||||
#endif
|
||||
|
||||
if ((hPalette = MakeDIBPalette(lpInfo)))
|
||||
hPalette = MakeDIBPalette(lpInfo);
|
||||
if ( hPalette )
|
||||
{
|
||||
// Need to realize palette for converting DIB to bitmap.
|
||||
hOldPal = SelectPalette(hDC, hPalette, TRUE);
|
||||
|
@ -271,7 +271,8 @@ int wxFileDialog::ShowModal(void)
|
||||
extension = extension + strlen( extension ) +1;
|
||||
}
|
||||
|
||||
if ( (extension = strrchr( extension, '.' )) // != "blabla"
|
||||
extension = strrchr( extension, '.' );
|
||||
if ( extension // != "blabla"
|
||||
&& !strrchr( extension, '*' ) // != "blabla.*"
|
||||
&& !strrchr( extension, '?' ) // != "blabla.?"
|
||||
&& extension[1] // != "blabla."
|
||||
|
@ -628,7 +628,7 @@ bool wxFrame::MSWOnPaint(void)
|
||||
HICON the_icon;
|
||||
if (m_icon.Ok())
|
||||
the_icon = (HICON) m_icon.GetHICON();
|
||||
if (the_icon == 0)
|
||||
else
|
||||
the_icon = (HICON) m_defaultIcon;
|
||||
|
||||
PAINTSTRUCT ps;
|
||||
@ -1037,7 +1037,6 @@ void wxFrame::PositionToolBar(void)
|
||||
// propagate our state change to all child frames
|
||||
void wxFrame::IconizeChildFrames(bool bIconize)
|
||||
{
|
||||
wxWindow *child = NULL;
|
||||
for ( wxNode *node = GetChildren()->First(); node; node = node->Next() ) {
|
||||
wxWindow *win = (wxWindow *)node->Data();
|
||||
if ( win->IsKindOf(CLASSINFO(wxFrame)) ) {
|
||||
|
@ -1111,22 +1111,31 @@ bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id)
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result)
|
||||
{
|
||||
wxListEvent event(wxEVT_NULL, m_windowId);
|
||||
wxEventType eventType = wxEVT_NULL;
|
||||
NMHDR *hdr1 = (NMHDR *) lParam;
|
||||
switch ( hdr1->code )
|
||||
{
|
||||
case LVN_BEGINRDRAG:
|
||||
eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
|
||||
// fall through
|
||||
|
||||
case LVN_BEGINDRAG:
|
||||
if ( eventType == wxEVT_NULL )
|
||||
{
|
||||
eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
|
||||
}
|
||||
|
||||
{
|
||||
NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam;
|
||||
event.m_itemIndex = hdr->iItem;
|
||||
event.m_pointDrag.x = hdr->ptAction.x;
|
||||
event.m_pointDrag.y = hdr->ptAction.y;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LVN_BEGINLABELEDIT:
|
||||
{
|
||||
eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
|
||||
@ -1134,15 +1143,7 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
|
||||
break;
|
||||
}
|
||||
case LVN_BEGINRDRAG:
|
||||
{
|
||||
eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
|
||||
NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
|
||||
event.m_itemIndex = hdr->iItem;
|
||||
event.m_pointDrag.x = hdr->ptAction.x;
|
||||
event.m_pointDrag.y = hdr->ptAction.y;
|
||||
break;
|
||||
}
|
||||
|
||||
case LVN_COLUMNCLICK:
|
||||
{
|
||||
eventType = wxEVT_COMMAND_LIST_COL_CLICK;
|
||||
@ -1228,8 +1229,7 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
}
|
||||
|
||||
default :
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
break;
|
||||
return wxControl::MSWNotify(wParam, lParam, result);
|
||||
}
|
||||
|
||||
event.SetEventObject( this );
|
||||
@ -1252,6 +1252,8 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
// wxConvertToMSWListItem(this, event.m_item, info->item);
|
||||
}
|
||||
|
||||
*result = !event.IsAllowed();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1430,8 +1432,8 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_
|
||||
// List event
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent)
|
||||
|
||||
wxListEvent::wxListEvent(wxEventType commandType, int id):
|
||||
wxCommandEvent(commandType, id)
|
||||
wxListEvent::wxListEvent(wxEventType commandType, int id)
|
||||
: wxNotifyEvent(commandType, id)
|
||||
{
|
||||
m_code = 0;
|
||||
m_itemIndex = 0;
|
||||
|
@ -595,8 +595,6 @@ long wxMDIParentFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARA
|
||||
|
||||
bool wxMDIParentFrame::MSWProcessMessage(WXMSG* msg)
|
||||
{
|
||||
MSG *pMsg = (MSG *)msg;
|
||||
|
||||
if ((m_currentChild != (wxWindow *)NULL) && (m_currentChild->GetHWND() != (WXHWND) NULL) && m_currentChild->MSWProcessMessage(msg))
|
||||
return TRUE;
|
||||
|
||||
|
@ -231,10 +231,10 @@ void wxMenu::Append(int Id, const wxString& label,
|
||||
void wxMenu::Delete(int id)
|
||||
{
|
||||
wxNode *node;
|
||||
wxMenuItem *item;
|
||||
int pos;
|
||||
HMENU menu;
|
||||
|
||||
wxMenuItem *item = NULL;
|
||||
for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) {
|
||||
item = (wxMenuItem *)node->Data();
|
||||
if (item->GetId() == id)
|
||||
@ -310,9 +310,9 @@ void wxMenu::SetTitle(const wxString& label)
|
||||
{
|
||||
if ( !label.IsEmpty() )
|
||||
{
|
||||
if ( !InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING,
|
||||
idMenuTitle, m_title) ||
|
||||
!InsertMenu(hMenu, 1, MF_BYPOSITION, -1, NULL) )
|
||||
if ( !InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING,
|
||||
(unsigned)idMenuTitle, m_title) ||
|
||||
!InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) )
|
||||
{
|
||||
wxLogLastError("InsertMenu");
|
||||
}
|
||||
@ -332,9 +332,9 @@ void wxMenu::SetTitle(const wxString& label)
|
||||
else
|
||||
{
|
||||
// modify the title
|
||||
if ( !ModifyMenu(hMenu, 0,
|
||||
if ( !ModifyMenu(hMenu, 0u,
|
||||
MF_BYPOSITION | MF_STRING,
|
||||
idMenuTitle, m_title) )
|
||||
(unsigned)idMenuTitle, m_title) )
|
||||
{
|
||||
wxLogLastError("ModifyMenu");
|
||||
}
|
||||
@ -667,7 +667,7 @@ bool wxMenuBar::Checked(int Id) const
|
||||
if (!item)
|
||||
return FALSE;
|
||||
|
||||
int Flag ;
|
||||
int Flag = 0;
|
||||
|
||||
if (itemMenu->m_hMenu)
|
||||
Flag=GetMenuState((HMENU)itemMenu->m_hMenu, Id, MF_BYCOMMAND) ;
|
||||
@ -892,8 +892,11 @@ wxMenuItem *wxMenuBar::FindItemForId (int Id, wxMenu ** itemMenu) const
|
||||
wxMenuItem *item = NULL;
|
||||
int i;
|
||||
for (i = 0; i < m_menuCount; i++)
|
||||
if ((item = m_menus[i]->FindItemForId (Id, itemMenu)))
|
||||
{
|
||||
item = m_menus[i]->FindItemForId (Id, itemMenu);
|
||||
if (item)
|
||||
return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -376,12 +376,19 @@ LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lPa
|
||||
cx = GetSystemMetrics( SM_CXFRAME ) ;
|
||||
cy = GetSystemMetrics( SM_CYFRAME ) ;
|
||||
}
|
||||
else
|
||||
if (TestWinStyle(hWnd, WS_BORDER ))
|
||||
else if (TestWinStyle(hWnd, WS_BORDER ))
|
||||
{
|
||||
cx = GetSystemMetrics( SM_CXBORDER ) ;
|
||||
cy = GetSystemMetrics( SM_CYBORDER ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// VZ: I don't know what should be here, but the vars must
|
||||
// be inited!
|
||||
wxFAIL_MSG("don't know how to initialize cx, cy");
|
||||
|
||||
cx = cy = 0;
|
||||
}
|
||||
|
||||
GetIconRect( hWnd, &rcMenu ) ;
|
||||
GetMinButtonRect( hWnd, &rcMin ) ;
|
||||
@ -865,7 +872,8 @@ BOOL PASCAL DrawCaption( HDC hDC, HWND hWnd, LPRECT lprc,
|
||||
int cy ;
|
||||
SIZE Size ;
|
||||
|
||||
if ((lpsz = (char*)GlobalAllocPtr( GHND, ui + 2 )))
|
||||
lpsz = (char*)GlobalAllocPtr( GHND, ui + 2 );
|
||||
if (lpsz)
|
||||
{
|
||||
UINT nBkMode ;
|
||||
|
||||
@ -1074,7 +1082,8 @@ BOOL PASCAL DoMenu( HWND hWnd )
|
||||
if (!TestWinStyle(hWnd, WS_SYSMENU))
|
||||
return FALSE ;
|
||||
|
||||
if ((hDC = GetWindowDC( hWnd )))
|
||||
hDC = GetWindowDC( hWnd );
|
||||
if (hDC)
|
||||
{
|
||||
// Invert the icon
|
||||
//
|
||||
|
@ -437,7 +437,7 @@ void wxNotebook::Command(wxCommandEvent& event)
|
||||
wxFAIL_MSG("wxNotebook::Command not implemented");
|
||||
}
|
||||
|
||||
bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM* result)
|
||||
{
|
||||
wxNotebookEvent event(wxEVT_NULL, m_windowId);
|
||||
|
||||
@ -451,21 +451,18 @@ bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
|
||||
break;
|
||||
|
||||
// prevent this msg from being passed to wxControl::MSWNotify which would
|
||||
// retrun FALSE disabling the change of page
|
||||
case UDN_DELTAPOS:
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
return wxControl::MSWNotify(wParam, lParam, result);
|
||||
}
|
||||
|
||||
event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
|
||||
event.SetOldSelection(m_nSelection);
|
||||
event.SetEventObject(this);
|
||||
event.SetInt(LOWORD(wParam));
|
||||
event.SetInt(LOWORD(wParam)); // ctrl id
|
||||
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
bool processed = GetEventHandler()->ProcessEvent(event);
|
||||
*result = !event.IsAllowed();
|
||||
return processed;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -475,11 +472,32 @@ bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
// hide the currently active panel and show the new one
|
||||
void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||
{
|
||||
// MT-FIXME should use a real semaphore
|
||||
static bool s_bInsideChangePage = FALSE;
|
||||
|
||||
// when we call ProcessEvent(), our own OnSelChange() is called which calls
|
||||
// this function - break the infinite loop
|
||||
if ( s_bInsideChangePage )
|
||||
return;
|
||||
|
||||
// it's not an error (the message may be generated by the tab control itself)
|
||||
// and it may happen - just do nothing
|
||||
if ( nSel == nOldSel )
|
||||
return;
|
||||
|
||||
s_bInsideChangePage = TRUE;
|
||||
|
||||
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
|
||||
event.SetSelection(nSel);
|
||||
event.SetOldSelection(nOldSel);
|
||||
event.SetEventObject(this);
|
||||
if ( ProcessEvent(event) && !event.IsAllowed() )
|
||||
{
|
||||
// program doesn't allow the page change
|
||||
s_bInsideChangePage = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( nOldSel != -1 )
|
||||
m_aPages[nOldSel]->Show(FALSE);
|
||||
|
||||
@ -487,7 +505,11 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||
pPage->Show(TRUE);
|
||||
pPage->SetFocus();
|
||||
|
||||
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
||||
ProcessEvent(event);
|
||||
|
||||
m_nSelection = nSel;
|
||||
s_bInsideChangePage = FALSE;
|
||||
}
|
||||
|
||||
void wxNotebook::OnEraseBackground(wxEraseEvent& event)
|
||||
|
@ -358,6 +358,11 @@ wxDataObject::~wxDataObject()
|
||||
const char *wxDataObject::GetFormatName(wxDataFormat format)
|
||||
{
|
||||
#ifdef __WXDEBUG__
|
||||
// case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4063)
|
||||
#endif // VC++
|
||||
|
||||
static char s_szBuf[128];
|
||||
switch ( format ) {
|
||||
case CF_TEXT: return "CF_TEXT";
|
||||
@ -380,9 +385,14 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
|
||||
sprintf(s_szBuf, "clipboard format %d (unknown)", format);
|
||||
return s_szBuf;
|
||||
}
|
||||
#else
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4063)
|
||||
#endif // VC++
|
||||
|
||||
#else // !Debug
|
||||
return "";
|
||||
#endif
|
||||
#endif // Debug
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -371,7 +371,7 @@ bool wxFileDropTarget::OnDrop(long x, long y, const void *pData)
|
||||
HDROP hdrop = (HDROP)pData; // @@ it works, but I'm not sure about it
|
||||
|
||||
// get number of files (magic value -1)
|
||||
UINT nFiles = ::DragQueryFile(hdrop, -1, NULL, 0);
|
||||
UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
|
||||
|
||||
// for each file get the length, allocate memory and then get the name
|
||||
char **aszFiles = new char *[nFiles];
|
||||
|
@ -144,7 +144,7 @@ wxRegKey::StdKey wxRegKey::ExtractKeyName(wxString& strKey)
|
||||
{
|
||||
wxString strRoot = strKey.Left(REG_SEPARATOR);
|
||||
|
||||
HKEY hRootKey;
|
||||
HKEY hRootKey = 0;
|
||||
size_t ui;
|
||||
for ( ui = 0; ui < nStdKeys; ui++ ) {
|
||||
if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 ||
|
||||
|
@ -233,19 +233,16 @@ bool wxSpinButton::MSWCommand(WXUINT cmd, WXWORD id)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxSpinButton::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
bool wxSpinButton::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM* result)
|
||||
{
|
||||
NMHDR* hdr1 = (NMHDR*) lParam;
|
||||
switch ( hdr1->code )
|
||||
{
|
||||
/* We don't process this message, currently */
|
||||
case UDN_DELTAPOS:
|
||||
{
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
return wxControl::MSWNotify(wParam, lParam, result);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
|
@ -146,7 +146,7 @@ bool wxTabCtrl::MSWCommand(WXUINT cmd, WXWORD id)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxTabCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
bool wxTabCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result)
|
||||
{
|
||||
wxTabEvent event(wxEVT_NULL, m_windowId);
|
||||
wxEventType eventType = wxEVT_NULL;
|
||||
@ -154,37 +154,29 @@ bool wxTabCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
switch ( hdr1->code )
|
||||
{
|
||||
case TCN_SELCHANGE:
|
||||
{
|
||||
eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
|
||||
event.SetInt( (int) LOWORD(wParam) ) ;
|
||||
break;
|
||||
}
|
||||
|
||||
case TCN_SELCHANGING:
|
||||
{
|
||||
eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
|
||||
event.SetInt( (int) LOWORD(wParam) ) ;
|
||||
break;
|
||||
}
|
||||
|
||||
case TTN_NEEDTEXT:
|
||||
{
|
||||
// TODO
|
||||
// if (tool->m_shortHelpString != "")
|
||||
// ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
break;
|
||||
return wxControl::MSWNotify(wParam, lParam, result);
|
||||
}
|
||||
|
||||
event.SetEventObject( this );
|
||||
event.SetEventType(eventType);
|
||||
event.SetInt( (int) LOWORD(wParam) ) ;
|
||||
|
||||
if ( !ProcessEvent(event) )
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return ProcessEvent(event);
|
||||
}
|
||||
|
||||
// Responds to colour changes, and passes event on to children.
|
||||
|
@ -325,7 +325,9 @@ bool wxToolBar95::MSWCommand(WXUINT cmd, WXWORD id)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxToolBar95::MSWNotify(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
|
||||
bool wxToolBar95::MSWNotify(WXWPARAM WXUNUSED(wParam),
|
||||
WXLPARAM lParam,
|
||||
WXLPARAM *result)
|
||||
{
|
||||
// First check if this applies to us
|
||||
NMHDR *hdr = (NMHDR *)lParam;
|
||||
|
@ -490,12 +490,18 @@ wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent,
|
||||
|
||||
tvIns.item.mask = mask;
|
||||
|
||||
HTREEITEM id = (HTREEITEM) TreeView_InsertItem(wxhWnd, &tvIns);
|
||||
HTREEITEM id = TreeView_InsertItem(wxhWnd, &tvIns);
|
||||
if ( id == 0 )
|
||||
{
|
||||
wxLogLastError("TreeView_InsertItem");
|
||||
}
|
||||
|
||||
if ( data != NULL )
|
||||
{
|
||||
// associate the application tree item with Win32 tree item handle
|
||||
data->SetId((WXHTREEITEM)id);
|
||||
}
|
||||
|
||||
return wxTreeItemId((WXHTREEITEM)id);
|
||||
}
|
||||
|
||||
@ -763,7 +769,7 @@ bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id)
|
||||
}
|
||||
|
||||
// process WM_NOTIFY Windows message
|
||||
bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result)
|
||||
{
|
||||
wxTreeEvent event(wxEVT_NULL, m_windowId);
|
||||
wxEventType eventType = wxEVT_NULL;
|
||||
@ -889,36 +895,28 @@ bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
}
|
||||
|
||||
default:
|
||||
return wxControl::MSWNotify(wParam, lParam);
|
||||
return wxControl::MSWNotify(wParam, lParam, result);
|
||||
}
|
||||
|
||||
event.SetEventObject(this);
|
||||
event.SetEventType(eventType);
|
||||
|
||||
bool rc = GetEventHandler()->ProcessEvent(event);
|
||||
bool processed = GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
// post processing
|
||||
switch ( hdr->code )
|
||||
if ( hdr->code == TVN_DELETEITEM )
|
||||
{
|
||||
// NB: we might process this message using wxWindows event tables, but
|
||||
// due to overhead of wxWin event system we prefer to do it here
|
||||
// (otherwise deleting a tree with many items is just too slow)
|
||||
case TVN_DELETEITEM:
|
||||
{
|
||||
NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam;
|
||||
wxTreeItemData *data = (wxTreeItemData *)tv->itemOld.lParam;
|
||||
delete data; // may be NULL, ok
|
||||
}
|
||||
break;
|
||||
|
||||
case TVN_ITEMEXPANDING:
|
||||
// if user called Veto(), don't allow expansion/collapse by
|
||||
// returning TRUE from here
|
||||
rc = event.m_code != 0;
|
||||
break;
|
||||
}
|
||||
*result = !event.IsAllowed();
|
||||
|
||||
return rc;
|
||||
return processed;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -928,7 +926,7 @@ bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent)
|
||||
|
||||
wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
|
||||
: wxCommandEvent(commandType, id)
|
||||
: wxNotifyEvent(commandType, id)
|
||||
{
|
||||
m_code = 0;
|
||||
m_itemOld = 0;
|
||||
|
@ -174,7 +174,9 @@ bool wxWindow::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam), WXLPARAM WXUNUSED(lParam))
|
||||
bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam),
|
||||
WXLPARAM WXUNUSED(lParam),
|
||||
WXLPARAM* WXUNUSED(result))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -193,8 +195,11 @@ void wxWindow::SetHWND(WXHWND hWnd)
|
||||
m_hWnd = hWnd;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
wxWindow::wxWindow(void)
|
||||
// ----------------------------------------------------------------------------
|
||||
// constructors and such
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxWindow::Init()
|
||||
{
|
||||
// Generic
|
||||
m_windowId = 0;
|
||||
@ -202,7 +207,6 @@ wxWindow::wxWindow(void)
|
||||
m_windowStyle = 0;
|
||||
m_windowParent = NULL;
|
||||
m_windowEventHandler = this;
|
||||
m_windowName = "";
|
||||
m_windowCursor = *wxSTANDARD_CURSOR;
|
||||
m_children = new wxList;
|
||||
m_doubleClickAllowed = 0 ;
|
||||
@ -217,41 +221,35 @@ wxWindow::wxWindow(void)
|
||||
// MSW-specific
|
||||
m_hWnd = 0;
|
||||
m_winEnabled = TRUE;
|
||||
m_caretWidth = 0; m_caretHeight = 0;
|
||||
m_caretEnabled = FALSE;
|
||||
m_caretWidth = m_caretHeight = 0;
|
||||
m_caretEnabled =
|
||||
m_caretShown = FALSE;
|
||||
m_inOnSize = FALSE;
|
||||
m_minSizeX = -1;
|
||||
m_minSizeY = -1;
|
||||
m_maxSizeX = -1;
|
||||
m_minSizeX =
|
||||
m_minSizeY =
|
||||
m_maxSizeX =
|
||||
m_maxSizeY = -1;
|
||||
// m_paintHDC = 0;
|
||||
// m_tempHDC = 0;
|
||||
|
||||
m_isBeingDeleted = FALSE;
|
||||
m_oldWndProc = 0;
|
||||
#ifndef __WIN32__
|
||||
m_globalHandle = 0;
|
||||
#endif
|
||||
m_useCtl3D = FALSE;
|
||||
m_mouseInWindow = FALSE;
|
||||
|
||||
m_windowParent = NULL;
|
||||
m_defaultItem = NULL;
|
||||
|
||||
wxSystemSettings settings;
|
||||
|
||||
m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
|
||||
// m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
|
||||
m_foregroundColour = *wxBLACK;
|
||||
|
||||
/*
|
||||
wxColour(GetRValue(GetSysColor(COLOR_WINDOW)),
|
||||
GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
|
||||
*/
|
||||
|
||||
// wxWnd
|
||||
m_lastMsg = 0;
|
||||
m_lastWParam = 0;
|
||||
m_lastLParam = 0;
|
||||
// m_acceleratorTable = 0;
|
||||
m_hMenu = 0;
|
||||
|
||||
m_xThumbSize = 0;
|
||||
@ -268,8 +266,13 @@ wxWindow::wxWindow(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
wxWindow::wxWindow()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
wxWindow::~wxWindow(void)
|
||||
wxWindow::~wxWindow()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
@ -346,7 +349,7 @@ wxWindow::~wxWindow(void)
|
||||
}
|
||||
|
||||
// Destroy the window (delayed, if a managed window)
|
||||
bool wxWindow::Destroy(void)
|
||||
bool wxWindow::Destroy()
|
||||
{
|
||||
delete this;
|
||||
return TRUE;
|
||||
@ -354,72 +357,18 @@ bool wxWindow::Destroy(void)
|
||||
|
||||
extern char wxCanvasClassName[];
|
||||
|
||||
// Constructor
|
||||
// real construction (Init() must have been called before!)
|
||||
bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
// Generic
|
||||
m_isBeingDeleted = FALSE;
|
||||
m_windowId = 0;
|
||||
m_isShown = TRUE;
|
||||
m_windowStyle = 0;
|
||||
m_windowParent = NULL;
|
||||
m_windowEventHandler = this;
|
||||
m_windowName = "";
|
||||
m_windowCursor = *wxSTANDARD_CURSOR;
|
||||
m_doubleClickAllowed = 0 ;
|
||||
m_winCaptured = FALSE;
|
||||
m_constraints = NULL;
|
||||
m_constraintsInvolvedIn = NULL;
|
||||
m_windowSizer = NULL;
|
||||
m_sizerParent = NULL;
|
||||
m_autoLayout = FALSE;
|
||||
m_windowValidator = NULL;
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
m_pDropTarget = NULL;
|
||||
#endif
|
||||
Init();
|
||||
|
||||
// MSW-specific
|
||||
m_hWnd = 0;
|
||||
m_winEnabled = TRUE;
|
||||
m_caretWidth = 0; m_caretHeight = 0;
|
||||
m_caretEnabled = FALSE;
|
||||
m_caretShown = FALSE;
|
||||
m_inOnSize = FALSE;
|
||||
m_minSizeX = -1;
|
||||
m_minSizeY = -1;
|
||||
m_maxSizeX = -1;
|
||||
m_maxSizeY = -1;
|
||||
m_oldWndProc = 0;
|
||||
#ifndef __WIN32__
|
||||
m_globalHandle = 0;
|
||||
#endif
|
||||
m_useCtl3D = FALSE;
|
||||
m_defaultItem = NULL;
|
||||
m_windowParent = NULL;
|
||||
m_mouseInWindow = FALSE;
|
||||
if (!parent)
|
||||
return FALSE;
|
||||
wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" );
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
// wxWnd
|
||||
m_lastMsg = 0;
|
||||
m_lastWParam = 0;
|
||||
m_lastLParam = 0;
|
||||
m_hMenu = 0;
|
||||
|
||||
m_xThumbSize = 0;
|
||||
m_yThumbSize = 0;
|
||||
m_backgroundTransparent = FALSE;
|
||||
|
||||
m_lastXPos = (float)-1.0;
|
||||
m_lastYPos = (float)-1.0;
|
||||
m_lastEvent = -1;
|
||||
m_returnCode = 0;
|
||||
parent->AddChild(this);
|
||||
|
||||
SetName(name);
|
||||
|
||||
@ -441,10 +390,6 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
wxSystemSettings settings;
|
||||
|
||||
m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
|
||||
// m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
|
||||
m_foregroundColour = *wxBLACK;
|
||||
|
||||
m_windowStyle = style;
|
||||
|
||||
DWORD msflags = 0;
|
||||
@ -466,15 +411,13 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
|
||||
msflags |= WS_BORDER;
|
||||
|
||||
m_mouseInWindow = FALSE ;
|
||||
|
||||
MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
|
||||
x, y, width, height, msflags, NULL, exStyle);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxWindow::SetFocus(void)
|
||||
void wxWindow::SetFocus()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
if (hWnd)
|
||||
@ -489,7 +432,7 @@ void wxWindow::Enable(bool enable)
|
||||
::EnableWindow(hWnd, (BOOL)enable);
|
||||
}
|
||||
|
||||
void wxWindow::CaptureMouse(void)
|
||||
void wxWindow::CaptureMouse()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
if (hWnd && !m_winCaptured)
|
||||
@ -499,7 +442,7 @@ void wxWindow::CaptureMouse(void)
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindow::ReleaseMouse(void)
|
||||
void wxWindow::ReleaseMouse()
|
||||
{
|
||||
if (m_winCaptured)
|
||||
{
|
||||
@ -814,7 +757,8 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
|
||||
HFONT was = 0;
|
||||
if (fontToUse && fontToUse->Ok())
|
||||
{
|
||||
if ((fnt=(HFONT) fontToUse->GetResourceHandle()))
|
||||
fnt = (HFONT)fontToUse->GetResourceHandle();
|
||||
if ( fnt )
|
||||
was = (HFONT) SelectObject(dc,fnt) ;
|
||||
}
|
||||
|
||||
@ -996,10 +940,11 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
||||
}
|
||||
case WM_QUERYDRAGICON:
|
||||
{
|
||||
HICON hIcon = 0;
|
||||
if ((hIcon = (HICON) MSWOnQueryDragIcon()))
|
||||
HICON hIcon = (HICON)MSWOnQueryDragIcon();
|
||||
if ( hIcon )
|
||||
return (long)hIcon;
|
||||
else return MSWDefWindowProc(message, wParam, lParam );
|
||||
else
|
||||
return MSWDefWindowProc(message, wParam, lParam );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1181,9 +1126,10 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
||||
#if defined(__WIN95__)
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
if (!MSWOnNotify(wParam, lParam))
|
||||
return MSWDefWindowProc(message, wParam, lParam );
|
||||
break;
|
||||
// for some messages (TVN_ITEMEXPANDING for example), the return
|
||||
// value of WM_NOTIFY handler is important, so don't just return 0
|
||||
// if we processed the message
|
||||
return MSWOnNotify(wParam, lParam);
|
||||
}
|
||||
#endif
|
||||
case WM_MENUSELECT:
|
||||
@ -1475,7 +1421,7 @@ void wxRemoveHandleAssociation(wxWindow *win)
|
||||
|
||||
// Default destroyer - override if you destroy it in some other way
|
||||
// (e.g. with MDI child windows)
|
||||
void wxWindow::MSWDestroyWindow(void)
|
||||
void wxWindow::MSWDestroyWindow()
|
||||
{
|
||||
}
|
||||
|
||||
@ -1562,7 +1508,7 @@ void wxWindow::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs))
|
||||
{
|
||||
}
|
||||
|
||||
bool wxWindow::MSWOnClose(void)
|
||||
bool wxWindow::MSWOnClose()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -1604,7 +1550,7 @@ bool wxWindow::MSWOnEndSession(bool endSession, long logOff)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxWindow::MSWOnDestroy(void)
|
||||
bool wxWindow::MSWOnDestroy()
|
||||
{
|
||||
// delete our drop target if we've got one
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
@ -1621,7 +1567,7 @@ bool wxWindow::MSWOnDestroy(void)
|
||||
|
||||
// Deal with child commands from buttons etc.
|
||||
|
||||
bool wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
long wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
#if defined(__WIN95__)
|
||||
// Find a child window to send the notification to, e.g. a toolbar.
|
||||
@ -1640,8 +1586,12 @@ bool wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
HWND hWnd = (HWND)hdr->hwndFrom;
|
||||
wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd);
|
||||
|
||||
WXLPARAM result = 0;
|
||||
|
||||
if ( win )
|
||||
return win->MSWNotify(wParam, lParam);
|
||||
{
|
||||
win->MSWNotify(wParam, lParam, &result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rely on MSWNotify to check whether the message
|
||||
@ -1650,15 +1600,15 @@ bool wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
|
||||
while (node)
|
||||
{
|
||||
wxWindow *child = (wxWindow *)node->Data();
|
||||
if ( child->MSWNotify(wParam, lParam) )
|
||||
return TRUE;
|
||||
if ( child->MSWNotify(wParam, lParam, &result) )
|
||||
break;
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return result;
|
||||
#endif // Win95
|
||||
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1926,11 +1876,11 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
||||
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
|
||||
}
|
||||
|
||||
bool bForward;
|
||||
bool bForward = TRUE;
|
||||
if ( bProcess ) {
|
||||
switch ( msg->wParam ) {
|
||||
case VK_TAB:
|
||||
if ( lDlgCode & DLGC_WANTTAB ) // this is FALSE for Ctrl-Tab
|
||||
if ( lDlgCode & DLGC_WANTTAB ) // FALSE for Ctrl-Tab
|
||||
bProcess = FALSE;
|
||||
else
|
||||
bForward = !(::GetKeyState(VK_SHIFT) & 0x100);
|
||||
@ -1948,8 +1898,6 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
||||
case VK_RIGHT:
|
||||
if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown )
|
||||
bProcess = FALSE;
|
||||
else
|
||||
bForward = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1987,7 +1935,7 @@ long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag), WXHWND WXUNUSED(activate),
|
||||
return 1;
|
||||
}
|
||||
|
||||
void wxWindow::MSWDetachWindowMenu(void)
|
||||
void wxWindow::MSWDetachWindowMenu()
|
||||
{
|
||||
if (m_hMenu)
|
||||
{
|
||||
@ -2006,7 +1954,7 @@ void wxWindow::MSWDetachWindowMenu(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool wxWindow::MSWOnPaint(void)
|
||||
bool wxWindow::MSWOnPaint()
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
|
||||
@ -2659,7 +2607,7 @@ bool wxWindow::MSWOnInitDialog(WXHWND WXUNUSED(hWndFocus))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxWindow::InitDialog(void)
|
||||
void wxWindow::InitDialog()
|
||||
{
|
||||
wxInitDialogEvent event(GetId());
|
||||
event.SetEventObject( this );
|
||||
@ -2682,7 +2630,8 @@ void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
|
||||
{
|
||||
// the_font->UseResource();
|
||||
// the_font->RealizeResource();
|
||||
if ((fnt=(HFONT) the_font->GetResourceHandle()))
|
||||
fnt = (HFONT)the_font->GetResourceHandle();
|
||||
if ( fnt )
|
||||
was = (HFONT) SelectObject(dc,fnt) ;
|
||||
}
|
||||
GetTextMetrics(dc, &tm);
|
||||
@ -2881,7 +2830,7 @@ void wxWindow::ShowCaret(bool show)
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindow::DestroyCaret(void)
|
||||
void wxWindow::DestroyCaret()
|
||||
{
|
||||
m_caretEnabled = FALSE;
|
||||
}
|
||||
@ -2899,7 +2848,7 @@ void wxWindow::GetCaretPos(int *x, int *y) const
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
wxWindow *wxGetActiveWindow(void)
|
||||
wxWindow *wxGetActiveWindow()
|
||||
{
|
||||
HWND hWnd = GetActiveWindow();
|
||||
if (hWnd != 0)
|
||||
@ -3007,7 +2956,7 @@ void wxWindow::Centre(int direction)
|
||||
}
|
||||
|
||||
/* TODO (maybe)
|
||||
void wxWindow::OnPaint(void)
|
||||
void wxWindow::OnPaint()
|
||||
{
|
||||
PaintSelectionHandles();
|
||||
}
|
||||
@ -3404,7 +3353,7 @@ void wxWindow::SubclassWin(WXHWND hWnd)
|
||||
SetWindowLong((HWND) hWnd, GWL_WNDPROC, (LONG) wxWndProc);
|
||||
}
|
||||
|
||||
void wxWindow::UnsubclassWin(void)
|
||||
void wxWindow::UnsubclassWin()
|
||||
{
|
||||
wxRemoveHandleAssociation(this);
|
||||
|
||||
@ -3541,7 +3490,7 @@ bool wxWindow::IsEnabled(void) const
|
||||
|
||||
// Transfer values to controls. If returns FALSE,
|
||||
// it's an application error (pops up a dialog)
|
||||
bool wxWindow::TransferDataToWindow(void)
|
||||
bool wxWindow::TransferDataToWindow()
|
||||
{
|
||||
wxNode *node = GetChildren()->First();
|
||||
while ( node )
|
||||
@ -3561,7 +3510,7 @@ bool wxWindow::TransferDataToWindow(void)
|
||||
|
||||
// Transfer values from controls. If returns FALSE,
|
||||
// validation failed: don't quit
|
||||
bool wxWindow::TransferDataFromWindow(void)
|
||||
bool wxWindow::TransferDataFromWindow()
|
||||
{
|
||||
wxNode *node = GetChildren()->First();
|
||||
while ( node )
|
||||
@ -3577,7 +3526,7 @@ bool wxWindow::TransferDataFromWindow(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxWindow::Validate(void)
|
||||
bool wxWindow::Validate()
|
||||
{
|
||||
wxNode *node = GetChildren()->First();
|
||||
while ( node )
|
||||
@ -3594,7 +3543,7 @@ bool wxWindow::Validate(void)
|
||||
}
|
||||
|
||||
// Get the window with the focus
|
||||
wxWindow *wxWindow::FindFocus(void)
|
||||
wxWindow *wxWindow::FindFocus()
|
||||
{
|
||||
HWND hWnd = ::GetFocus();
|
||||
if ( hWnd )
|
||||
@ -3617,7 +3566,7 @@ void wxWindow::RemoveChild(wxWindow *child)
|
||||
child->m_windowParent = NULL;
|
||||
}
|
||||
|
||||
void wxWindow::DestroyChildren(void)
|
||||
void wxWindow::DestroyChildren()
|
||||
{
|
||||
if (GetChildren()) {
|
||||
wxNode *node;
|
||||
@ -3733,7 +3682,7 @@ void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
|
||||
}
|
||||
|
||||
// Reset any constraints that mention this window
|
||||
void wxWindow::DeleteRelatedConstraints(void)
|
||||
void wxWindow::DeleteRelatedConstraints()
|
||||
{
|
||||
if (m_constraintsInvolvedIn)
|
||||
{
|
||||
@ -3775,7 +3724,7 @@ void wxWindow::SetSizer(wxSizer *sizer)
|
||||
* New version
|
||||
*/
|
||||
|
||||
bool wxWindow::Layout(void)
|
||||
bool wxWindow::Layout()
|
||||
{
|
||||
if (GetConstraints())
|
||||
{
|
||||
@ -3875,7 +3824,7 @@ bool wxWindow::DoPhase(int phase)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxWindow::ResetConstraints(void)
|
||||
void wxWindow::ResetConstraints()
|
||||
{
|
||||
wxLayoutConstraints *constr = GetConstraints();
|
||||
if (constr)
|
||||
@ -4137,7 +4086,7 @@ void wxWindow::OnDefaultAction(wxControl *initiatingItem)
|
||||
*/
|
||||
}
|
||||
|
||||
void wxWindow::Clear(void)
|
||||
void wxWindow::Clear()
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
wxBrush brush(GetBackgroundColour(), wxSOLID);
|
||||
@ -4146,7 +4095,7 @@ void wxWindow::Clear(void)
|
||||
}
|
||||
|
||||
// Fits the panel around the items
|
||||
void wxWindow::Fit(void)
|
||||
void wxWindow::Fit()
|
||||
{
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
@ -4315,7 +4264,7 @@ int y_pages = 0;
|
||||
*/
|
||||
|
||||
// Setup background and foreground colours correctly
|
||||
void wxWindow::SetupColours(void)
|
||||
void wxWindow::SetupColours()
|
||||
{
|
||||
if (GetParent())
|
||||
SetBackgroundColour(GetParent()->GetBackgroundColour());
|
||||
@ -4350,13 +4299,13 @@ void wxWindow::OnIdle(wxIdleEvent& event)
|
||||
}
|
||||
|
||||
// Raise the window to the top of the Z order
|
||||
void wxWindow::Raise(void)
|
||||
void wxWindow::Raise()
|
||||
{
|
||||
::BringWindowToTop((HWND) GetHWND());
|
||||
}
|
||||
|
||||
// Lower the window to the bottom of the Z order
|
||||
void wxWindow::Lower(void)
|
||||
void wxWindow::Lower()
|
||||
{
|
||||
::SetWindowPos((HWND) GetHWND(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user