diff --git a/include/wx/defs.h b/include/wx/defs.h index 6d684c34d0..06da9d41aa 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -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 ////////////////////////////////////////////////////////////////////////////////// diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 7174148866..6fd78a428f 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -368,8 +368,8 @@ private: \ @memo declare list class 'name' containing elements of type 'T' */ -#define WX_DECLARE_LIST(T, name) typedef T _L##name; \ - _WX_DECLARE_LIST(_L##name, 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!" //@} // ---------------------------------------------------------------------------- diff --git a/include/wx/event.h b/include/wx/event.h index e9eb695cd2..3ccfb3b428 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -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 diff --git a/include/wx/file.h b/include/wx/file.h index ede2b55b17..50074970d3 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -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 diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index fe995f30a5..36a892127d 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -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(); +public: + wxResourceCache() { } + wxResourceCache(const unsigned int keyType) : wxList(keyType) { } + ~wxResourceCache(); + +private: + DECLARE_DYNAMIC_CLASS(wxResourceCache) }; #endif diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index b188e6083f..8cfa171f7e 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -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 diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index b188e6083f..8cfa171f7e 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -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 diff --git a/include/wx/list.h b/include/wx/list.h index 61466cd3aa..6c9a9a3af5 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -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: - - wxObject *data; - wxNode *next; - wxNode *previous; + wxKEY_NONE, + wxKEY_INTEGER, + wxKEY_STRING +}; - public: - wxList *list; +// ----------------------------------------------------------------------------- +// types +// ----------------------------------------------------------------------------- - // Optional key stuff - union - { +// 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); + +// +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: + // 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()); } - public: - int n; - int destroy_data; - wxNode *first_node; - wxNode *last_node; - unsigned int key_type; + // 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); - wxList(const unsigned int the_key_type); - wxList(int N, wxObject *Objects[]); - wxList(wxObject *object, ...); - - ~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); - - // Keyed append - wxNode *Append(long key, wxObject *object); - wxNode *Append(const char *key, wxObject *object); - - 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 - - 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 - - // Keyed search - virtual wxNode *Find(long key) const; - virtual wxNode *Find(const char *key) const; - - virtual wxNode *Member(wxObject *object) 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); - - wxObject *FirstThat(wxListIterateFunction func); - void ForEach(wxListIterateFunction func); - wxObject *LastThat(wxListIterateFunction func); +private: + wxKeyType m_keyType; + wxListKeyValue m_key; }; -// String list class. N.B. this always copies strings -// with Add and deletes them itself. -class WXDLLEXPORT wxStringList: public wxList +// ----------------------------------------------------------------------------- +// wxNodeBase class is a (base for) node in a double linked list +// ----------------------------------------------------------------------------- + +class WXDLLEXPORT wxNodeBase { - DECLARE_DYNAMIC_CLASS(wxStringList) +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()); - public: - wxStringList(void); - wxStringList(const wxStringList& list); - wxStringList(const char *first ...); - ~wxStringList(void); + virtual ~wxNodeBase(); - 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; + // @@ no check is done that the list is really keyed on strings + const char *GetKeyString() const { return m_key.string; } + +#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; + + // this function allows the sorting of arbitrary lists by giving + // a function to compare two list elements. The list is sorted in place. + void Sort(wxSortCompareFunction compfunc); + + // functions for iterating over the list + void *FirstThat(wxListIterateFunction func); + void ForEach(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) +}; + +// ----------------------------------------------------------------------------- +// 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 +#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 +{ +public: + wxList(int key_type = wxKEY_NONE) : wxObjectList((wxKeyType)key_type) { } + + // 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__ diff --git a/include/wx/listimpl.cpp b/include/wx/listimpl.cpp index e3513099c8..ccb1e6397c 100644 --- a/include/wx/listimpl.cpp +++ b/include/wx/listimpl.cpp @@ -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 +// Modified by: +// Created: 16/11/98 // RCS-ID: $Id$ -// Copyright: (c) 1997 Vadim Zeitlin -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// +// 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() \ -{ \ - 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; \ -} +#define _DEFINE_LIST(T, name) \ + void wx##name##Node::DeleteData() \ + { \ + 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 diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h index 7516125e92..f6ab16ee18 100644 --- a/include/wx/msw/control.h +++ b/include/wx/msw/control.h @@ -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); diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index 9f6693955b..0677ecd2be 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -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,11 +442,9 @@ protected: }; -class WXDLLEXPORT wxListEvent: public wxCommandEvent +class WXDLLEXPORT wxListEvent : public wxNotifyEvent { - DECLARE_DYNAMIC_CLASS(wxListEvent) - - public: +public: wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0); int m_code; @@ -457,6 +455,8 @@ class WXDLLEXPORT wxListEvent: public wxCommandEvent wxPoint m_pointDrag; wxListItem m_item; + + DECLARE_DYNAMIC_CLASS(wxListEvent) }; typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index b75bc7f228..371152c770 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -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); diff --git a/include/wx/msw/regconf.h b/include/wx/msw/regconf.h index 3cb0213720..5d8b9fc39a 100644 --- a/include/wx/msw/regconf.h +++ b/include/wx/msw/regconf.h @@ -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; diff --git a/include/wx/msw/setup.h b/include/wx/msw/setup.h index 9e205cc1f2..d8db707bba 100644 --- a/include/wx/msw/setup.h +++ b/include/wx/msw/setup.h @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SETUP_H_ @@ -44,23 +44,23 @@ #define wxUSE_HELP 1 // 0 for no help facility #define wxUSE_RESOURCES 1 - // 0 for no wxGetResource/wxWriteResource + // 0 for no wxGetResource/wxWriteResource #define wxUSE_CONSTRAINTS 1 // 0 for no window layout constraint system - + #define wxUSE_TIMEDATE 1 // 0 for no wxTime/wxDate classes - + #define wxUSE_CLIPBOARD 1 - // 0 for no clipboard functions + // 0 for no clipboard functions #define wxUSE_SPLINES 1 - // 0 for no splines + // 0 for no splines #define wxUSE_XFIG_SPLINE_CODE 1 - // 1 for XFIG spline code, 0 for AIAI spline code. + // 1 for XFIG spline code, 0 for AIAI spline code. // AIAI spline code is slower, but freer of copyright issues. #define wxUSE_DRAG_AND_DROP 1 - // 0 for no drag and drop + // 0 for no drag and drop #define wxUSE_TOOLBAR 1 // Define 1 to use toolbar classes @@ -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. @@ -103,7 +103,7 @@ // symbol if 1? #define HAVE_SOCKET 1 - // Use WinSock if 1 + // Use WinSock if 1 #define wxUSE_DOC_VIEW_ARCHITECTURE 1 // Set to 0 to disable document/view architecture #define wxUSE_PRINTING_ARCHITECTURE 1 @@ -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. @@ -162,10 +162,10 @@ * */ -#define wxUSE_APPLE_IEEE 1 - // if enabled, the float codec written by Apple - // will be used to write, in a portable way, - // float on the disk +#define wxUSE_APPLE_IEEE 1 + // if enabled, the float codec written by Apple + // will be used to write, in a portable way, + // float on the disk /* * MS Windows/Windows NT @@ -218,9 +218,9 @@ #define wxUSE_TYPEDEFS 0 // Use typedefs not classes for wxPoint - // and others, to reduce overhead and avoid - // MS C7 memory bug. Bounds checker - // complains about deallocating + // and others, to reduce overhead and avoid + // MS C7 memory bug. Bounds checker + // complains about deallocating // arrays of wxPoints if wxPoint is a class. #if (!defined(WIN32) && !defined(__WIN32__)) || defined(__GNUWIN32__) || defined(__BORLANDC__) diff --git a/include/wx/msw/spinbutt.h b/include/wx/msw/spinbutt.h index 31e2b9dbf0..4f7d3f7824 100644 --- a/include/wx/msw/spinbutt.h +++ b/include/wx/msw/spinbutt.h @@ -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; diff --git a/include/wx/msw/tabctrl.h b/include/wx/msw/tabctrl.h index 798c61b322..cd975821e2 100644 --- a/include/wx/msw/tabctrl.h +++ b/include/wx/msw/tabctrl.h @@ -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); diff --git a/include/wx/msw/tbar95.h b/include/wx/msw/tbar95.h index 6bbcc4a019..4aae20d62a 100644 --- a/include/wx/msw/tbar95.h +++ b/include/wx/msw/tbar95.h @@ -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); diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index 1c2dd8b348..03795479dd 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -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; diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 51b44fdaf8..66e3dfc9ce 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -81,7 +81,7 @@ WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr; WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize; WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition; -class WXDLLEXPORT wxWindow: public wxEvtHandler +class WXDLLEXPORT wxWindow : public wxEvtHandler { DECLARE_ABSTRACT_CLASS(wxWindow) @@ -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 -DECLARE_EVENT_TABLE() +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_ diff --git a/include/wx/stubs/colour.h b/include/wx/stubs/colour.h index 8304b2d917..47d0e2ac21 100644 --- a/include/wx/stubs/colour.h +++ b/include/wx/stubs/colour.h @@ -6,7 +6,7 @@ // Created: ??/??/98 // RCS-ID: $Id$ // Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_COLOUR_H_ @@ -77,7 +77,7 @@ public: */ private: - bool m_isInit; + bool m_isInit; unsigned char m_red; unsigned char m_blue; unsigned char m_green; @@ -92,4 +92,4 @@ private: }; #endif - // _WX_COLOUR_H_ + // _WX_COLOUR_H_ diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 84c0a65c36..2f882a54dd 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -28,6 +28,11 @@ #include "wx/utils.h" #include +// there are just too many of those... +#ifdef _MSC_VER + #pragma warning(disable:4706) // assignment within conditional expression +#endif // VC++ + #include #include #include @@ -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++ \ No newline at end of file diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index a6c575f1c1..57c72604d3 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -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) { diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 6cb46f1be0..0a35449929 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -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; diff --git a/src/common/list.cpp b/src/common/list.cpp index 80841b6ea6..730134ae7d 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -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 -///////////////////////////////////////////////////////////////////////////// +// Licence: wxWindows license +//////////////////////////////////////////////////////////////////////////////// +// ============================================================================= +// declarations +// ============================================================================= + +// ----------------------------------------------------------------------------- +// headers +// ----------------------------------------------------------------------------- #ifdef __GNUG__ #pragma implementation "list.h" #endif @@ -17,389 +24,364 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/defs.h" -#include "wx/list.h" -#include "wx/utils.h" -#include -#endif - -// Sun CC compatibility (interference with xview/pkg.h, apparently...) -#if defined(SUN_CC) && defined(__XVIEW__) -#undef va_start -#undef va_end -#undef va_arg -#undef va_list + #pragma hdrstop #endif #include #include #include -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxNode, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxList, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxStringList, wxList) +#ifndef WX_PRECOMP + #include "wx/defs.h" + #include "wx/list.h" + #include "wx/utils.h" // for copystring() (beurk...) #endif -wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one, - wxObject * object) +// Sun CC compatibility (interference with xview/pkg.h, apparently...) +#if defined(SUN_CC) && defined(__XVIEW__) + #undef va_start + #undef va_end + #undef va_arg + #undef va_list +#endif + +// ============================================================================= +// implementation +// ============================================================================= + +// ----------------------------------------------------------------------------- +// wxNodeBase +// ----------------------------------------------------------------------------- + +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; - - 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) -{ - 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++) + m_list = list; + m_data = data; + m_previous = previous; + m_next = next; + + switch ( key.GetKeyType() ) { - wxNode *next = new wxNode (this, last, (wxNode *) NULL, Objects[i]); - last = next; - if (i == 0) - first_node = next; + case wxKEY_NONE: + break; + + 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"); } - last_node = last; - n = N; - key_type = wxKEY_NONE; + + if ( previous ) + previous->m_next = this; + + if ( next ) + next->m_previous = this; } -wxList::wxList (const unsigned int the_key_type) +wxNodeBase::~wxNodeBase() { - 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 (;;) + // 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 ) { - 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 - break; - else - { - wxNode *node = new wxNode (this, last, (wxNode *) NULL, object); - last = node; - n++; - } + m_list->DetachNode(this); } - 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 -*/ } -wxList::~wxList (void) +// ----------------------------------------------------------------------------- +// wxListBase +// ----------------------------------------------------------------------------- + +void wxListBase::Init(wxKeyType keyType = wxKEY_NONE) { - wxNode *each = first_node; - while (each) + 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() ) { - wxNode *next = each->Next (); - delete each; + 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 ) { - if (j++ == i) - return current; + m_nodeFirst = node; + m_nodeLast = node; } - 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(); - } - - return (wxNode *) NULL; // Not found! -} - -wxNode *wxList::Find (const char *key) const -{ - wxNode *current = First(); - while (current) - { - 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 ()) + if ( prev == NULL ) { - wxObject *each = current->Data (); - if (each == object) - return current; + m_nodeFirst = node; } - return (wxNode *) NULL; + + m_count++; + + return node; } -bool wxList::DeleteNode (wxNode * node) +wxNodeBase *wxListBase::Item(size_t n) const { - if (node) + for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() ) { - delete node; - return TRUE; + if ( n-- == 0 ) + { + return current; + } } - return FALSE; + + wxFAIL_MSG( "invalid index in wxListBase::Item" ); + + return NULL; } -bool wxList::DeleteObject (wxObject * object) +wxNodeBase *wxListBase::Find(const wxListKey& key) const { - // Search list for object - for (wxNode * current = first_node; current; current = current->Next ()) + wxASSERT_MSG( m_keyType == key.GetKeyType(), + "this list is not keyed on the type of this key" ); + + for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() ) { - if (current->Data () == object) - { - delete current; - return TRUE; - } + if ( key == current->m_key ) + { + return current; + } } - return FALSE; // Did not find the object + // not found + return (wxNodeBase *)NULL; } - -// Insert new node at front of list -wxNode *wxList::Insert (wxObject * object) +wxNodeBase *wxListBase::Find(void *object) const { - 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) + for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() ) { - first_node = node; - last_node = node; + if ( current->GetData() == object ) + return current; } - if (!prev) - first_node = node; - n++; - return node; + // not found + return (wxNodeBase *)NULL; } -// Keyed append -wxNode *wxList::Append (long key, wxObject * object) +void wxListBase::DoDeleteNode(wxNodeBase *node) { - 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; - while (current) + // free node's data + if ( m_keyType == wxKEY_STRING ) { - wxNode *next = current->Next (); - delete current; - current = next; + free(node->m_key.string); } - first_node = (wxNode *) NULL; - last_node = (wxNode *) NULL; - n = 0; + + if ( m_destroy ) + { + node->DeleteData(); + } + + delete node; } -//Executes function F with all items present in the list -void wxList::ForEach(wxListIterateFunction F) +wxNodeBase *wxListBase::DetachNode(wxNodeBase *node) { - wxNode *each = first_node; - while (each) - { (*F)( each->Data ()); - each = each->Next(); + 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; +} + + +void wxListBase::Clear() +{ + wxNodeBase *current = m_nodeFirst; + while ( current ) + { + wxNodeBase *next = current->GetNext(); + DoDeleteNode(current); + current = next; + } + + m_nodeFirst = + m_nodeLast = (wxNodeBase *)NULL; + + m_count = 0; +} + +void wxListBase::ForEach(wxListIterateFunction F) +{ + for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() ) + { + (*F)(current->GetData()); } } -// Returns a pointer to the item which returns TRUE with function F -// or NULL if no such item found -wxObject *wxList::FirstThat(wxListIterateFunction F) + +void *wxListBase::FirstThat(wxListIterateFunction F) { - wxNode *each = first_node; - while (each) - { if ((*F)( each->Data ())) return each->Data(); - each = each->Next(); + for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() ) + { + if ( (*F)(current->GetData()) ) + return current->GetData(); } - return (wxNode *) NULL; + + return (wxNodeBase *)NULL; } -// Like FirstThat, but proceeds from the end backward -wxObject *wxList::LastThat(wxListIterateFunction F) + +void *wxListBase::LastThat(wxListIterateFunction F) { - wxNode *each = last_node; - while (each) - { if ((*F)( each->Data ())) return each->Data(); - each = each->Previous(); + for ( wxNodeBase *current = GetLast(); current; current = current->GetPrevious() ) + { + if ( (*F)(current->GetData()) ) + return current->GetData(); } - return (wxNode *) NULL; + + return (wxNodeBase *)NULL; } // (stefan.hammes@urz.uni-heidelberg.de) @@ -421,8 +403,8 @@ wxObject *wxList::LastThat(wxListIterateFunction F) // } // // void main() -// { -// wxList list; +// { +// wxListBase list; // // list.Append(new wxString("DEF")); // list.Append(new wxString("GHI")); @@ -430,155 +412,115 @@ 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; - - // go through the list and put the pointers into the array - wxNode *node = First(); - while(node!=NULL){ - *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){ - node->SetData(*objPtr++); - node = node->Next(); - } - // free the array - delete[] objArray; + // allocate an array for the wxObject pointers of the list + const size_t num = GetCount(); + void **objArray = new void *[num]; + void **objPtr = objArray; + + // go through the list and put the pointers into the array + wxNodeBase *node; + for ( node = GetFirst(); node; node = node->Next() ) + { + *objPtr++ = node->Data(); + } + + // sort the array + qsort((void *)objArray,num,sizeof(wxObject *),compfunc); + + // put the sorted pointers back into the list + objPtr = objArray; + for ( node = GetFirst(); node; node = node->Next() ) + { + node->SetData(*objPtr++); + } + + // 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) + if ( !first ) return; va_list ap; + va_start(ap, first); - 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 *); -// if (s == NULL) + { + Add(s); + + s = va_arg(ap, const char *); + // if (s == NULL) #ifdef __WXMSW__ if ((int) s == 0) #else 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 + break; + } + va_end(ap); } // Only makes new strings if arg is TRUE -char **wxStringList::ListToArray (bool new_copies) const +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 (); - if (new_copies) - string_array[i] = copystring (s); - else - string_array[i] = s; - node = node->Next (); + char *s = node->GetData(); + if ( new_copies ) + string_array[i] = copystring(s); + else + string_array[i] = s; + node = node->GetNext(); } - return string_array; + + return string_array; } -static int -wx_comparestrings (const void *arg1, const void *arg2) +// 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) { char **s1 = (char **) arg1; char **s2 = (char **) 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; - char **array = new char *[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 (); - - qsort (array, N, sizeof (char *), wx_comparestrings); - Clear (); - - for (i = 0; i < N; i++) - Append ((wxObject *) (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 ()) + size_t i = 0; + for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() ) { - const char *s1 = (const char *) node->Data (); - if (s == s1 || strcmp (s, s1) == 0) - return TRUE; + array[i++] = node->GetData(); } - return FALSE; -} -void wxStringList::operator= (const wxStringList& list) -{ + qsort (array, N, sizeof (char *), wx_comparestrings); 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()); + for (i = 0; i < N; i++) + Append (array[i]); + + delete[]array; } diff --git a/src/common/odbc.cpp b/src/common/odbc.cpp index 84b145c36f..576ee3a487 100644 --- a/src/common/odbc.cpp +++ b/src/common/odbc.cpp @@ -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 diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 5816feab51..49c769a130 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -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 #include #include @@ -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 diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index dedda6cf6b..d50620d33f 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -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) diff --git a/src/msw/app.cpp b/src/msw/app.cpp index f0c45de1cd..812c615db0 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -50,10 +50,15 @@ #include #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 #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(); diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 44099f7598..67d698f32b 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -739,35 +739,35 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) { #if wxUSE_XPM_IN_MSW - HDC dc = NULL; - - Visual *visual = NULL; - XImage ximage; - - dc = CreateCompatibleDC(NULL); - if (dc) - { + HDC dc = NULL; + + XImage ximage; + + dc = CreateCompatibleDC(NULL); + if (dc) + { if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap)) - { /* 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; - int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name, - &ximage, (XImage *) NULL, (XpmAttributes *) NULL); - - if (dc) - DeleteDC(dc); - - if (errorStatus == XpmSuccess) - return TRUE; /* no error */ - else - return FALSE; + { + /* 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 = (HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap; + int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name, + &ximage, (XImage *) NULL, (XpmAttributes *) NULL); + + if (dc) + DeleteDC(dc); + + if (errorStatus == XpmSuccess) + return TRUE; /* no error */ + else + return FALSE; } else return FALSE; - } else return FALSE; + } else return FALSE; #else - return FALSE; + return FALSE; #endif } diff --git a/src/msw/bmpbuttn.cpp b/src/msw/bmpbuttn.cpp index ecfd0ea1d5..201529d4ca 100644 --- a/src/msw/bmpbuttn.cpp +++ b/src/msw/bmpbuttn.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -52,8 +52,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit if ( style & wxBU_AUTODRAW ) { - m_marginX = wxDEFAULT_BUTTON_MARGIN; - m_marginY = wxDEFAULT_BUTTON_MARGIN; + m_marginX = wxDEFAULT_BUTTON_MARGIN; + m_marginY = wxDEFAULT_BUTTON_MARGIN; } int x = pos.x; @@ -67,10 +67,10 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit m_windowId = id; if ( width == -1 && bitmap.Ok()) - width = bitmap.GetWidth() + 2*m_marginX; + width = bitmap.GetWidth() + 2*m_marginX; if ( height == -1 && bitmap.Ok()) - height = bitmap.GetHeight() + 2*m_marginY; + height = bitmap.GetHeight() + 2*m_marginY; HWND wx_button = CreateWindowEx(0, "BUTTON", "", BS_OWNERDRAW | WS_TABSTOP | WS_CHILD, @@ -97,22 +97,22 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap) bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item) { - long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE); + long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE); #if defined(__WIN95__) - if (style & BS_BITMAP) - { - // Should we call Default() here? -// Default(); + if (style & BS_BITMAP) + { + // Should we call Default() here? +// Default(); - // Let default procedure draw the bitmap, which is defined - // in the Windows resource. - return FALSE; - } + // Let default procedure draw the bitmap, which is defined + // in the Windows resource. + return FALSE; + } #endif LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) item; - wxBitmap* bitmap = &m_buttonBitmap; + wxBitmap* bitmap = &m_buttonBitmap; UINT state = lpDIS->itemState; if ((state & ODS_SELECTED) && m_buttonBitmapSelected.Ok()) @@ -143,24 +143,24 @@ bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item) DrawFace((WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, ((state & ODS_SELECTED) == ODS_SELECTED)); - // Centre the bitmap in the control area - int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2)); - int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2)); + // Centre the bitmap in the control area + int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2)); + int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2)); - if ( (state & ODS_SELECTED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) ) - { - x1 ++; - y1 ++; - } + if ( (state & ODS_SELECTED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) ) + { + x1 ++; + y1 ++; + } - ::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY); + ::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY); - if ( (state & ODS_DISABLED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) ) - DrawButtonDisable( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, TRUE ) ; - else if ( (state & ODS_FOCUS) && (GetWindowStyleFlag() & wxBU_AUTODRAW) ) - DrawButtonFocus( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, ((state & ODS_SELECTED) == ODS_SELECTED)); + if ( (state & ODS_DISABLED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) ) + DrawButtonDisable( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, TRUE ) ; + else if ( (state & ODS_FOCUS) && (GetWindowStyleFlag() & wxBU_AUTODRAW) ) + DrawButtonFocus( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, ((state & ODS_SELECTED) == ODS_SELECTED)); - ::SelectObject(memDC, old); + ::SelectObject(memDC, old); ::DeleteDC(memDC); @@ -169,8 +169,8 @@ bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item) void wxBitmapButton::DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel ) { - HPEN oldp; - HBRUSH oldb ; + HPEN oldp; + HBRUSH oldb ; HPEN penBorder; HPEN penLight; @@ -178,51 +178,51 @@ void wxBitmapButton::DrawFace( WXHDC dc, int left, int top, int right, int botto HBRUSH brushFace; COLORREF ms_color; - ms_color = GetSysColor(COLOR_WINDOWFRAME) ; - penBorder = CreatePen(PS_SOLID,0,ms_color) ; + ms_color = GetSysColor(COLOR_WINDOWFRAME) ; + penBorder = CreatePen(PS_SOLID,0,ms_color) ; - ms_color = GetSysColor(COLOR_BTNSHADOW) ; - penShadow = CreatePen(PS_SOLID,0,ms_color) ; + ms_color = GetSysColor(COLOR_BTNSHADOW) ; + penShadow = CreatePen(PS_SOLID,0,ms_color) ; - ms_color = GetSysColor(COLOR_BTNHIGHLIGHT) ; - penLight = CreatePen(PS_SOLID,0,ms_color) ; + ms_color = GetSysColor(COLOR_BTNHIGHLIGHT) ; + penLight = CreatePen(PS_SOLID,0,ms_color) ; - ms_color = GetSysColor(COLOR_BTNFACE) ; - brushFace = CreateSolidBrush(ms_color) ; + ms_color = GetSysColor(COLOR_BTNFACE) ; + brushFace = CreateSolidBrush(ms_color) ; - oldp = (HPEN) SelectObject( (HDC) dc, GetStockObject( NULL_PEN ) ) ; - oldb = (HBRUSH) SelectObject( (HDC) dc, brushFace ) ; - Rectangle( (HDC) dc, left, top, right, bottom ) ; - SelectObject( (HDC) dc, penBorder) ; + oldp = (HPEN) SelectObject( (HDC) dc, GetStockObject( NULL_PEN ) ) ; + oldb = (HBRUSH) SelectObject( (HDC) dc, brushFace ) ; + Rectangle( (HDC) dc, left, top, right, bottom ) ; + SelectObject( (HDC) dc, penBorder) ; MoveToEx((HDC) dc,left+1,top,NULL);LineTo((HDC) dc,right-1,top); MoveToEx((HDC) dc,left,top+1,NULL);LineTo((HDC) dc,left,bottom-1); MoveToEx((HDC) dc,left+1,bottom-1,NULL);LineTo((HDC) dc,right-1,bottom-1); MoveToEx((HDC) dc,right-1,top+1,NULL);LineTo((HDC) dc,right-1,bottom-1); - SelectObject( (HDC) dc, penShadow) ; - if (sel) - { - MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ; - LineTo((HDC) dc, left+1 ,top+1) ; - LineTo((HDC) dc, right-2 ,top+1) ; - } - else - { - MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ; - LineTo((HDC) dc, right-2 ,bottom-2) ; - LineTo((HDC) dc, right-2 ,top) ; - MoveToEx((HDC) dc,left+2 ,bottom-3 ,NULL) ; - LineTo((HDC) dc, right-3 ,bottom-3) ; - LineTo((HDC) dc, right-3 ,top+1) ; + SelectObject( (HDC) dc, penShadow) ; + if (sel) + { + MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ; + LineTo((HDC) dc, left+1 ,top+1) ; + LineTo((HDC) dc, right-2 ,top+1) ; + } + else + { + MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ; + LineTo((HDC) dc, right-2 ,bottom-2) ; + LineTo((HDC) dc, right-2 ,top) ; + MoveToEx((HDC) dc,left+2 ,bottom-3 ,NULL) ; + LineTo((HDC) dc, right-3 ,bottom-3) ; + LineTo((HDC) dc, right-3 ,top+1) ; - SelectObject( (HDC) dc, penLight) ; + SelectObject( (HDC) dc, penLight) ; - MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ; - LineTo((HDC) dc, left+1 ,top+1) ; - LineTo((HDC) dc, right-2 ,top+1) ; - } - SelectObject((HDC) dc,oldp) ; - SelectObject((HDC) dc,oldb) ; + MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ; + LineTo((HDC) dc, left+1 ,top+1) ; + LineTo((HDC) dc, right-2 ,top+1) ; + } + SelectObject((HDC) dc,oldp) ; + SelectObject((HDC) dc,oldb) ; DeleteObject(penBorder); DeleteObject(penLight); @@ -234,28 +234,28 @@ void wxBitmapButton::DrawFace( WXHDC dc, int left, int top, int right, int botto void wxBitmapButton::DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel ) { - RECT rect; - rect.left = left; - rect.top = top; - rect.right = right; - rect.bottom = bottom; - InflateRect( &rect, - FOCUS_MARGIN, - FOCUS_MARGIN ) ; - if ( sel ) - OffsetRect( &rect, 1, 1 ) ; - DrawFocusRect( (HDC) dc, &rect ) ; + RECT rect; + rect.left = left; + rect.top = top; + rect.right = right; + rect.bottom = bottom; + InflateRect( &rect, - FOCUS_MARGIN, - FOCUS_MARGIN ) ; + if ( sel ) + OffsetRect( &rect, 1, 1 ) ; + DrawFocusRect( (HDC) dc, &rect ) ; } extern HBRUSH wxDisableButtonBrush; void wxBitmapButton::DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg ) { - HBRUSH old = (HBRUSH) SelectObject( (HDC) dc, wxDisableButtonBrush ) ; + HBRUSH old = (HBRUSH) SelectObject( (HDC) dc, wxDisableButtonBrush ) ; - if ( with_marg ) - ::PatBlt( (HDC) dc, left + m_marginX, top + m_marginY, - right - 2 * m_marginX, bottom - 2 * m_marginY, - 0xfa0089ul ) ; - else ::PatBlt( (HDC) dc, left, top, right, bottom, 0xfa0089ul ) ; + if ( with_marg ) + ::PatBlt( (HDC) dc, left + m_marginX, top + m_marginY, + right - 2 * m_marginX, bottom - 2 * m_marginY, + 0xfa0089ul ) ; + else ::PatBlt( (HDC) dc, left, top, right, bottom, 0xfa0089ul ) ; - ::SelectObject( (HDC) dc, old ) ; + ::SelectObject( (HDC) dc, old ) ; } diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 956e0e418c..9688accf39 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -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 diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 8d4f4b718d..297d81e8fb 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -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); @@ -235,18 +236,18 @@ bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) break; } */ - default : + default: return FALSE; - break; } + event.SetEventType(eventType); event.SetEventObject(this); if ( !GetEventHandler()->ProcessEvent(event) ) return FALSE; return TRUE; -#else - return FALSE; +#else // !Win95 + return FALSE; #endif } diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 0870dbb183..5b4e8fddcd 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -242,7 +242,7 @@ void wxDC::SetPalette(const wxPalette& palette) m_oldPalette = 0; } - return; + return; } if (m_palette.Ok() && m_palette.GetHPALETTE()) @@ -474,28 +474,28 @@ void wxDC::DrawRectangle(long x, long y, long width, long height) do_pen = m_pen.Ok() && m_pen.GetStyle() != wxTRANSPARENT; if (do_brush) { - HPEN orig_pen = NULL; + HPEN orig_pen = NULL; - if (do_pen || !m_pen.Ok()) - orig_pen = (HPEN) ::SelectObject((HDC) m_hDC, (HPEN) ::GetStockObject(NULL_PEN)); + if (do_pen || !m_pen.Ok()) + orig_pen = (HPEN) ::SelectObject((HDC) m_hDC, (HPEN) ::GetStockObject(NULL_PEN)); - (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x2) + 1, YLOG2DEV(y2) + 1); + (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), + XLOG2DEV(x2) + 1, YLOG2DEV(y2) + 1); - if (do_pen || !m_pen.Ok()) - ::SelectObject((HDC) m_hDC , orig_pen); + if (do_pen || !m_pen.Ok()) + ::SelectObject((HDC) m_hDC , orig_pen); } if (do_pen) { - HBRUSH orig_brush = NULL; + HBRUSH orig_brush = NULL; - if (do_brush || !m_brush.Ok()) - orig_brush = (HBRUSH) ::SelectObject((HDC) m_hDC, (HBRUSH) ::GetStockObject(NULL_BRUSH)); + if (do_brush || !m_brush.Ok()) + orig_brush = (HBRUSH) ::SelectObject((HDC) m_hDC, (HBRUSH) ::GetStockObject(NULL_BRUSH)); - (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x2), YLOG2DEV(y2)); + (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), + XLOG2DEV(x2), YLOG2DEV(y2)); - if (do_brush || !m_brush.Ok()) - ::SelectObject((HDC) m_hDC, orig_brush); + if (do_brush || !m_brush.Ok()) + ::SelectObject((HDC) m_hDC, orig_brush); } #else (void)Rectangle((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2)); @@ -563,16 +563,16 @@ void wxDC::DrawEllipticArc(long x,long y,long w,long h,double sa,double ea) if (m_signY > 0) { (void)Pie((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2)+1, YLOG2DEV(y2)+1, - rx1, ry1, rx2, ry2); + rx1, ry1, rx2, ry2); } else { (void)Pie((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y)-1, XLOG2DEV(x2)+1, YLOG2DEV(y2), - rx1, ry1-1, rx2, ry2-1); + rx1, ry1-1, rx2, ry2-1); } ::SelectObject((HDC) m_hDC, orig_pen); (void)Arc((HDC) m_hDC, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2), - rx1, ry1, rx2, ry2); + rx1, ry1, rx2, ry2); CalcBoundingBox(x, y); CalcBoundingBox(x2, y2); @@ -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() ) ; @@ -1007,42 +1007,42 @@ void wxDC::SetDeviceOrigin(long x, long y) long wxDC::DeviceToLogicalX(long x) const { - return (long) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX) - m_logicalOriginX) ; + return (long) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX) - m_logicalOriginX) ; } long wxDC::DeviceToLogicalXRel(long x) const { - return (long) ((x)/(m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX)) ; + return (long) ((x)/(m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX)) ; } long wxDC::DeviceToLogicalY(long y) const { - return (long) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY) - m_logicalOriginY) ; + return (long) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY) - m_logicalOriginY) ; } long wxDC::DeviceToLogicalYRel(long y) const { - return (long) ((y)/(m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY)) ; + return (long) ((y)/(m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY)) ; } long wxDC::LogicalToDeviceX(long x) const { - return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX + m_deviceOriginX) ; + return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX + m_deviceOriginX) ; } long wxDC::LogicalToDeviceXRel(long x) const { - return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX) ; + return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_signX*m_systemScaleX) ; } long wxDC::LogicalToDeviceY(long y) const { - return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY + m_deviceOriginY); + return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY + m_deviceOriginY); } long wxDC::LogicalToDeviceYRel(long y) const { - return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY) ; + return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_signY*m_systemScaleY) ; } // This group of functions may not do any conversion @@ -1051,50 +1051,50 @@ long wxDC::LogicalToDeviceYRel(long y) const long wxDC::ImplDeviceToLogicalX(long x) const { -// return (m_scaleGDI ? x : DeviceToLogicalX(x)); - return x; +// return (m_scaleGDI ? x : DeviceToLogicalX(x)); + return x; } long wxDC::ImplDeviceToLogicalY(long y) const { -// return (m_scaleGDI ? y : DeviceToLogicalY(y)); - return y; +// return (m_scaleGDI ? y : DeviceToLogicalY(y)); + return y; } long wxDC::ImplDeviceToLogicalXRel(long x) const { -// return (m_scaleGDI ? x : DeviceToLogicalXRel(x)); - return x; +// return (m_scaleGDI ? x : DeviceToLogicalXRel(x)); + return x; } long wxDC::ImplDeviceToLogicalYRel(long y) const { -// return (m_scaleGDI ? y : DeviceToLogicalYRel(y)); - return y; +// return (m_scaleGDI ? y : DeviceToLogicalYRel(y)); + return y; } long wxDC::ImplLogicalToDeviceX(long x) const { -// return (m_scaleGDI ? (floor(double(x))) : LogicalToDeviceX(x)); - return x; +// return (m_scaleGDI ? (floor(double(x))) : LogicalToDeviceX(x)); + return x; } long wxDC::ImplLogicalToDeviceY(long y) const { -// return (m_scaleGDI ? (floor(double(y))) : LogicalToDeviceY(y)); - return y; +// return (m_scaleGDI ? (floor(double(y))) : LogicalToDeviceY(y)); + return y; } long wxDC::ImplLogicalToDeviceXRel(long x) const { -// return (m_scaleGDI ? (floor(double(x))) : LogicalToDeviceXRel(x)); - return x; +// return (m_scaleGDI ? (floor(double(x))) : LogicalToDeviceXRel(x)); + return x; } long wxDC::ImplLogicalToDeviceYRel(long y) const { -// return (m_scaleGDI ? (floor(double(y))) : LogicalToDeviceYRel(y)); - return y; +// return (m_scaleGDI ? (floor(double(y))) : LogicalToDeviceYRel(y)); + return y; } bool wxDC::Blit(long xdest, long ydest, long width, long height, @@ -1111,11 +1111,11 @@ bool wxDC::Blit(long xdest, long ydest, long width, long height, COLORREF old_background = ::GetBkColor((HDC)m_hDC); if (m_textForegroundColour.Ok()) { - ::SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ; + ::SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ; } if (m_textBackgroundColour.Ok()) { - ::SetBkColor((HDC) m_hDC, m_textBackgroundColour.GetPixel() ) ; + ::SetBkColor((HDC) m_hDC, m_textBackgroundColour.GetPixel() ) ; } DWORD dwRop = rop == wxCOPY ? SRCCOPY : @@ -1132,12 +1132,12 @@ 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()) { #if 0 // __WIN32__ - // Not implemented under Win95 (or maybe a specific device?) + // Not implemented under Win95 (or maybe a specific device?) if (MaskBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, (HDC) source->m_hDC, xsrc1, ysrc1, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap(), 0, 0, 0xAACC0020)) @@ -1149,116 +1149,116 @@ bool wxDC::Blit(long xdest, long ydest, long width, long height, { // Old code #if 0 - HDC dc_mask = CreateCompatibleDC((HDC) source->m_hDC); - ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap()); + HDC dc_mask = CreateCompatibleDC((HDC) source->m_hDC); + ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap()); success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, - dc_mask, xsrc1, ysrc1, 0x00220326 /* NOTSRCAND */) != 0); + dc_mask, xsrc1, ysrc1, 0x00220326 /* NOTSRCAND */) != 0); success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, - (HDC) source->m_hDC, xsrc1, ysrc1, SRCPAINT) != 0); - ::SelectObject(dc_mask, 0); - ::DeleteDC(dc_mask); + (HDC) source->m_hDC, xsrc1, ysrc1, SRCPAINT) != 0); + ::SelectObject(dc_mask, 0); + ::DeleteDC(dc_mask); #endif // New code from Chris Breeze, 15/7/98 - // Blit bitmap with mask + // Blit bitmap with mask - if (IsKindOf(CLASSINFO(wxPrinterDC))) - { - // If we are printing source colours are screen colours - // not printer colours and so we need copy the bitmap - // pixel by pixel. - RECT rect; - HDC dc_mask = ::CreateCompatibleDC((HDC) source->m_hDC); - HDC dc_src = (HDC) source->m_hDC; + if (IsKindOf(CLASSINFO(wxPrinterDC))) + { + // If we are printing source colours are screen colours + // not printer colours and so we need copy the bitmap + // pixel by pixel. + RECT rect; + HDC dc_mask = ::CreateCompatibleDC((HDC) source->m_hDC); + HDC dc_src = (HDC) source->m_hDC; - ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap()); - for (int x = 0; x < width; x++) - { - for (int y = 0; y < height; y++) - { - COLORREF cref = ::GetPixel(dc_mask, x, y); - if (cref) - { - HBRUSH brush = ::CreateSolidBrush(::GetPixel(dc_src, x, y)); - rect.left = xdest1 + x; rect.right = rect.left + 1; - rect.top = ydest1 + y; rect.bottom = rect.top + 1; - ::FillRect((HDC) m_hDC, &rect, brush); - ::DeleteObject(brush); - } - } - } - ::SelectObject(dc_mask, 0); - ::DeleteDC(dc_mask); - } - else - { - // create a temp buffer bitmap and DCs to access it and the mask - HDC dc_mask = ::CreateCompatibleDC((HDC) source->m_hDC); - HDC dc_buffer = ::CreateCompatibleDC((HDC) m_hDC); - HBITMAP buffer_bmap = ::CreateCompatibleBitmap((HDC) m_hDC, width, height); - ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap()); - ::SelectObject(dc_buffer, buffer_bmap); + ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap()); + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + COLORREF cref = ::GetPixel(dc_mask, x, y); + if (cref) + { + HBRUSH brush = ::CreateSolidBrush(::GetPixel(dc_src, x, y)); + rect.left = xdest1 + x; rect.right = rect.left + 1; + rect.top = ydest1 + y; rect.bottom = rect.top + 1; + ::FillRect((HDC) m_hDC, &rect, brush); + ::DeleteObject(brush); + } + } + } + ::SelectObject(dc_mask, 0); + ::DeleteDC(dc_mask); + } + else + { + // create a temp buffer bitmap and DCs to access it and the mask + HDC dc_mask = ::CreateCompatibleDC((HDC) source->m_hDC); + HDC dc_buffer = ::CreateCompatibleDC((HDC) m_hDC); + HBITMAP buffer_bmap = ::CreateCompatibleBitmap((HDC) m_hDC, width, height); + ::SelectObject(dc_mask, (HBITMAP) source->m_selectedBitmap.GetMask()->GetMaskBitmap()); + ::SelectObject(dc_buffer, buffer_bmap); - // copy dest to buffer - ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, - (HDC) m_hDC, xdest1, ydest1, SRCCOPY); + // copy dest to buffer + ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, + (HDC) m_hDC, xdest1, ydest1, SRCCOPY); - // copy src to buffer using selected raster op - ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, - (HDC) source->m_hDC, xsrc1, ysrc1, dwRop); + // copy src to buffer using selected raster op + ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, + (HDC) source->m_hDC, xsrc1, ysrc1, dwRop); - // set masked area in buffer to BLACK (pixel value 0) - COLORREF prevBkCol = ::SetBkColor((HDC) m_hDC, RGB(255, 255, 255)); - COLORREF prevCol = ::SetTextColor((HDC) m_hDC, RGB(0, 0, 0)); - ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, - dc_mask, xsrc1, ysrc1, SRCAND); + // set masked area in buffer to BLACK (pixel value 0) + COLORREF prevBkCol = ::SetBkColor((HDC) m_hDC, RGB(255, 255, 255)); + COLORREF prevCol = ::SetTextColor((HDC) m_hDC, RGB(0, 0, 0)); + ::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, + dc_mask, xsrc1, ysrc1, SRCAND); - // set unmasked area in dest to BLACK - ::SetBkColor((HDC) m_hDC, RGB(0, 0, 0)); - ::SetTextColor((HDC) m_hDC, RGB(255, 255, 255)); - ::BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, - dc_mask, xsrc1, ysrc1, SRCAND); - ::SetBkColor((HDC) m_hDC, prevBkCol); // restore colours to original values - ::SetTextColor((HDC) m_hDC, prevCol); + // set unmasked area in dest to BLACK + ::SetBkColor((HDC) m_hDC, RGB(0, 0, 0)); + ::SetTextColor((HDC) m_hDC, RGB(255, 255, 255)); + ::BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, + dc_mask, xsrc1, ysrc1, SRCAND); + ::SetBkColor((HDC) m_hDC, prevBkCol); // restore colours to original values + ::SetTextColor((HDC) m_hDC, prevCol); - // OR buffer to dest - success = (::BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, - dc_buffer, 0, 0, SRCPAINT) != 0); + // OR buffer to dest + success = (::BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, + dc_buffer, 0, 0, SRCPAINT) != 0); - // tidy up temporary DCs and bitmap - ::SelectObject(dc_mask, 0); - ::DeleteDC(dc_mask); - ::SelectObject(dc_buffer, 0); - ::DeleteDC(dc_buffer); - ::DeleteObject(buffer_bmap); - } - } + // tidy up temporary DCs and bitmap + ::SelectObject(dc_mask, 0); + ::DeleteDC(dc_mask); + ::SelectObject(dc_buffer, 0); + ::DeleteDC(dc_buffer); + ::DeleteObject(buffer_bmap); + } + } } else { - if (IsKindOf(CLASSINFO(wxPrinterDC))) - { + if (IsKindOf(CLASSINFO(wxPrinterDC))) + { // If we are printing source colours are screen colours // not printer colours and so we need copy the bitmap // pixel by pixel. HDC dc_src = (HDC) source->m_hDC; RECT rect; for (int x = 0; x < width; x++) - { + { for (int y = 0; y < height; y++) - { + { HBRUSH brush = ::CreateSolidBrush(::GetPixel(dc_src, x, y)); - rect.left = xdest1 + x; rect.right = rect.left + 1; - rect.top = ydest1 + y; rect.bottom = rect.top + 1; + rect.left = xdest1 + x; rect.right = rect.left + 1; + rect.top = ydest1 + y; rect.bottom = rect.top + 1; ::FillRect((HDC) m_hDC, &rect, brush); ::DeleteObject(brush); - } - } + } + } } - else - { + else + { success = (BitBlt((HDC) m_hDC, xdest1, ydest1, (int)width, (int)height, (HDC) source->m_hDC, xsrc1, ysrc1, dwRop) != 0); - } + } } ::SetTextColor((HDC)m_hDC, old_textground); ::SetBkColor((HDC)m_hDC, old_background); @@ -1356,8 +1356,8 @@ void wxDC::GetTextExtent(const wxString& string, float *x, float *y, wxFont *theFont, bool use16bit) const { long x1, y1, descent1, externalLeading1; - GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit); - *x = x1; *y = y1; + GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit); + *x = x1; *y = y1; if (descent) *descent = descent1; if (externalLeading) @@ -1473,10 +1473,10 @@ void wx_draw_open_spline(wxDC *dc, wxSpline *spline) while ((node = node->Next()) != NULL) { p = (wxPoint *)node->Data(); - x1 = x2; - y1 = y2; - x2 = p->x; - y2 = p->y; + x1 = x2; + y1 = y2; + x2 = p->x; + y2 = p->y; cx4 = (double)(x1 + x2) / 2; cy4 = (double)(y1 + y2) / 2; cx3 = (double)(x1 + cx4) / 2; @@ -1484,8 +1484,8 @@ void wx_draw_open_spline(wxDC *dc, wxSpline *spline) wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); - cx1 = cx4; - cy1 = cy4; + cx1 = cx4; + cy1 = cy4; cx2 = (double)(cx1 + x2) / 2; cy2 = (double)(cy1 + y2) / 2; } @@ -1499,23 +1499,23 @@ void wx_draw_open_spline(wxDC *dc, wxSpline *spline) /********************* CURVES FOR SPLINES ***************************** - The following spline drawing routine is from + The following spline drawing routine is from - "An Algorithm for High-Speed Curve Generation" - by George Merrill Chaikin, - Computer Graphics and Image Processing, 3, Academic Press, - 1974, 346-349. + "An Algorithm for High-Speed Curve Generation" + by George Merrill Chaikin, + Computer Graphics and Image Processing, 3, Academic Press, + 1974, 346-349. - and + and - "On Chaikin's Algorithm" by R. F. Riesenfeld, - Computer Graphics and Image Processing, 4, Academic Press, - 1975, 304-310. + "On Chaikin's Algorithm" by R. F. Riesenfeld, + Computer Graphics and Image Processing, 4, Academic Press, + 1975, 304-310. ***********************************************************************/ -#define half(z1, z2) ((z1+z2)/2.0) -#define THRESHOLD 5 +#define half(z1, z2) ((z1+z2)/2.0) +#define THRESHOLD 5 /* iterative version */ @@ -1531,16 +1531,16 @@ void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) { xmid = (double)half(x2, x3); ymid = (double)half(y2, y3); - if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD && - fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) { + if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD && + fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) { wx_spline_add_point((double)wx_round(x1), (double)wx_round(y1)); wx_spline_add_point((double)wx_round(xmid), (double)wx_round(ymid)); - } else { + } else { wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3), (double)half(x3, x4), (double)half(y3, y4), x4, y4); wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2), (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid); - } + } } } @@ -1582,7 +1582,7 @@ int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, double *y3, double *x4, double *y4) { if (wx_stack_count == 0) - return (0); + return (0); wx_stack_top--; wx_stack_count--; *x1 = wx_stack_top->x1; diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index d214648061..4694f6b261 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -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); diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 78b3437750..f5cc104122 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -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." diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 96d7733cac..0f5da8a297 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -626,9 +626,9 @@ bool wxFrame::MSWOnPaint(void) if (m_iconized) { HICON the_icon; - if (m_icon.Ok()) - the_icon = (HICON) m_icon.GetHICON(); - if (the_icon == 0) + if (m_icon.Ok()) + the_icon = (HICON) m_icon.GetHICON(); + 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)) ) { diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 5b3229a3b4..a8bf38fa72 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -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: - { - 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; - } + 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; + 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,7 +1252,9 @@ bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam) // wxConvertToMSWListItem(this, event.m_item, info->item); } - return TRUE; + *result = !event.IsAllowed(); + + return TRUE; } char *wxListCtrl::AddPool(const wxString& str) @@ -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; diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 5d4fab3316..953733d50a 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -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; diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 5c0c4cc9d4..cb90171636 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -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; } diff --git a/src/msw/minifram.cpp b/src/msw/minifram.cpp index c64fdf0e7d..c8c1ad14b5 100644 --- a/src/msw/minifram.cpp +++ b/src/msw/minifram.cpp @@ -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 )) + { + cx = GetSystemMetrics( SM_CXBORDER ) ; + cy = GetSystemMetrics( SM_CYBORDER ) ; + } else - if (TestWinStyle(hWnd, WS_BORDER )) - { - cx = GetSystemMetrics( SM_CXBORDER ) ; - cy = GetSystemMetrics( SM_CYBORDER ) ; - } + { + // 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 // diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index e58af84b52..74dfb4cd9d 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -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); + default: + 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) diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 944540a430..2718e36bbe 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -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 } // ---------------------------------------------------------------------------- diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index becfe73232..d1c729dbb4 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -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]; diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index ef80ce3c23..f9431a9d1f 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -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 || diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index 462d0513e0..89680b5f5e 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -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 */ + /* 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; } /* diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index de089033e5..0725df9d88 100644 --- a/src/msw/statbmp.cpp +++ b/src/msw/statbmp.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -50,9 +50,9 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_foregroundColour = parent->GetForegroundColour() ; if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; int x = pos.x; int y = pos.y; @@ -60,9 +60,9 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, int height = size.y; if ( width < 0 && bitmap.Ok() ) - width = bitmap.GetWidth(); + width = bitmap.GetWidth(); if ( height < 0 && bitmap.Ok() ) - height = bitmap.GetHeight(); + height = bitmap.GetHeight(); m_windowStyle = style; @@ -135,7 +135,7 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) rect.left = x; rect.top = y; rect.right = x + w; rect.bottom = y + h; if ( bitmap.Ok() ) - MoveWindow((HWND) GetHWND(), x, y, bitmap.GetWidth(), bitmap.GetHeight(), + MoveWindow((HWND) GetHWND(), x, y, bitmap.GetWidth(), bitmap.GetHeight(), FALSE); InvalidateRect((HWND) GetParent()->GetHWND(), &rect, TRUE); @@ -143,45 +143,45 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) bool wxStaticBitmap::MSWOnDraw(WXDRAWITEMSTRUCT *item) { - long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE); + long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE); #ifdef __WIN32__ - if ((style & 0xFF) == SS_BITMAP) - { - // Should we call Default() here? -// Default(); + if ((style & 0xFF) == SS_BITMAP) + { + // Should we call Default() here? +// Default(); - // Let default procedure draw the bitmap, which is defined - // in the Windows resource. - return FALSE; - } + // Let default procedure draw the bitmap, which is defined + // in the Windows resource. + return FALSE; + } #endif LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) item; - wxBitmap* bitmap = &m_messageBitmap; - if ( !bitmap->Ok() ) - return FALSE; + wxBitmap* bitmap = &m_messageBitmap; + if ( !bitmap->Ok() ) + return FALSE; - HDC hDC = lpDIS->hDC; - HDC memDC = ::CreateCompatibleDC(hDC); + HDC hDC = lpDIS->hDC; + HDC memDC = ::CreateCompatibleDC(hDC); - HBITMAP old = (HBITMAP) ::SelectObject(memDC, (HBITMAP) bitmap->GetHBITMAP()); + HBITMAP old = (HBITMAP) ::SelectObject(memDC, (HBITMAP) bitmap->GetHBITMAP()); - if (!old) - return FALSE; + if (!old) + return FALSE; int x = lpDIS->rcItem.left; int y = lpDIS->rcItem.top; int width = lpDIS->rcItem.right - x; int height = lpDIS->rcItem.bottom - y; - // Centre the bitmap in the control area - int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2)); - int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2)); + // Centre the bitmap in the control area + int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2)); + int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2)); - ::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY); + ::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY); - ::SelectObject(memDC, old); + ::SelectObject(memDC, old); ::DeleteDC(memDC); diff --git a/src/msw/tabctrl.cpp b/src/msw/tabctrl.cpp index d6f6a5415b..27decfb2f1 100644 --- a/src/msw/tabctrl.cpp +++ b/src/msw/tabctrl.cpp @@ -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. diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 772e4cab64..c4d19a9333 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -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; diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index aa41b2d722..7a5c6af4f2 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -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; + NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam; + wxTreeItemData *data = (wxTreeItemData *)tv->itemOld.lParam; + delete data; // may be NULL, ok } - return rc; + *result = !event.IsAllowed(); + + 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; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c3969cdf30..65ffdccfe9 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -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); + 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,34 +1876,32 @@ 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 - bProcess = FALSE; - else - bForward = !(::GetKeyState(VK_SHIFT) & 0x100); - break; + case VK_TAB: + if ( lDlgCode & DLGC_WANTTAB ) // FALSE for Ctrl-Tab + bProcess = FALSE; + else + bForward = !(::GetKeyState(VK_SHIFT) & 0x100); + break; - case VK_UP: - case VK_LEFT: - if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) - bProcess = FALSE; - else - bForward = FALSE; - break; + case VK_UP: + case VK_LEFT: + if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) + bProcess = FALSE; + else + bForward = FALSE; + break; - case VK_DOWN: - case VK_RIGHT: - if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) - bProcess = FALSE; - else - bForward = TRUE; - break; + case VK_DOWN: + case VK_RIGHT: + if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) + bProcess = FALSE; + break; - default: - bProcess = FALSE; + default: + bProcess = FALSE; } } @@ -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); }