From: Włodzimierz Skiba Date: Wed, 19 Jan 2005 16:25:34 +0000 (+0000) Subject: wxTextPos for all GetLastPosition with constants for special cases. Make it virtual... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7d8268a1d64de58aab194e4d8ae800c755990aad wxTextPos for all GetLastPosition with constants for special cases. Make it virtual everywhere. Avoid doubling typedefs. Always include textctrl.h for combobox.h. Source cleaning. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/combobox.tex b/docs/latex/wx/combobox.tex index 917a541edb..60bb8d5449 100644 --- a/docs/latex/wx/combobox.tex +++ b/docs/latex/wx/combobox.tex @@ -36,7 +36,7 @@ See also \helpref{window styles overview}{windowstyles}. \twocolwidtha{7cm} \begin{twocollist}\itemsep=0pt \twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED event, -when an item on the list is selected. Note that calling +when an item on the list is selected. Note that calling \helpref{GetValue}{wxcomboboxgetvalue} returns the new value of selection.} \twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED event, when the combobox text changes.} @@ -152,14 +152,14 @@ text field. Only available on Windows. Returns true if the combobox is editable and the last undo can be redone. Only available on Windows. - + \membersection{wxComboBox::CanUndo}\label{wxcomboboxcanundo} \constfunc{bool}{CanUndo}{\void} Returns true if the combobox is editable and the last edit can be undone. Only available on Windows. - + \membersection{wxComboBox::Copy}\label{wxcomboboxcopy} \func{void}{Copy}{\void} @@ -180,7 +180,7 @@ Returns the insertion point for the combobox's text field. \membersection{wxComboBox::GetLastPosition}\label{wxcomboboxgetlastposition} -\constfunc{long}{GetLastPosition}{\void} +\constfunc{virtual wxTextPos}{GetLastPosition}{\void} Returns the last position in the combobox text field. @@ -257,7 +257,7 @@ Selects the text between the two positions, in the combobox text field. \docparam{to}{The second position.} \pythonnote{This method is called {\tt SetMark} in wxPython, {\tt SetSelection} -name is kept for +name is kept for \helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}.} \membersection{wxComboBox::SetValue}\label{wxcomboboxsetvalue} diff --git a/docs/latex/wx/text.tex b/docs/latex/wx/text.tex index 27d4a062ae..1aaf71ad3e 100644 --- a/docs/latex/wx/text.tex +++ b/docs/latex/wx/text.tex @@ -70,7 +70,7 @@ for a text control. \end{verbatim} } -The values below are the possible return codes of the +The values below are the possible return codes of the \helpref{HitTest}{wxtextctrlhittest} method: {\small \begin{verbatim} @@ -230,7 +230,7 @@ Sets the text font. \func{void}{SetLeftIndent}{\param{int }{indent}, \param{int }{subIndent = 0}} Sets the left indent in tenths of a millimetre. -subIndent sets the indent for all lines but the first line in a paragraph +subIndent sets the indent for all lines but the first line in a paragraph relative to the first line. @@ -320,17 +320,17 @@ The multiline text controls always store the text as a sequence of lines separated by {\tt $\backslash$n} characters, i.e. in the Unix text format even on non-Unix platforms. This allows the user code to ignore the differences between the platforms but at a price: the indices in the control such as those -returned by \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} or +returned by \helpref{GetInsertionPoint}{wxtextctrlgetinsertionpoint} or \helpref{GetSelection}{wxtextctrlgetselection} can {\bf not} be used as indices into the string returned by \helpref{GetValue}{wxtextctrlgetvalue} as -they're going to be slightly off for platforms using +they're going to be slightly off for platforms using {\tt $\backslash$r$\backslash$n} as separator (as Windows does), for example. Instead, if you need to obtain a substring between the $2$ indices obtained from the control with the help of the functions mentioned above, you should use \helpref{GetRange}{wxtextctrlgetrange}. And the indices themselves can -only be passed to other methods, for example -\helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint} or +only be passed to other methods, for example +\helpref{SetInsertionPoint}{wxtextctrlsetinsertionpoint} or \helpref{SetSelection}{wxtextctrlsetselection}. To summarize: never use the indices returned by (multiline) wxTextCtrl as @@ -633,7 +633,7 @@ Resets the internal `modified' flag as if the current edits had been saved. \func{bool}{EmulateKeyPress}{\param{const wxKeyEvent\& }{event}} This functions inserts into the control the character which would have been -inserted if the given key event had occured in the text control. The +inserted if the given key event had occured in the text control. The {\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN} handler previously by wxWidgets. @@ -683,7 +683,7 @@ point or the zero character if the point is at the end of the control. \membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition} -\constfunc{virtual long}{GetLastPosition}{\void} +\constfunc{virtual wxTextPos}{GetLastPosition}{\void} Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control. @@ -747,7 +747,7 @@ up to {\it to} in the control. The positions must have been returned by another wxTextCtrl method. Please note that the positions in a multiline wxTextCtrl do {\bf not} -correspond to the indices in the string returned by +correspond to the indices in the string returned by \helpref{GetValue}{wxtextctrlgetvalue} because of the different new line representations ({\tt CR} or {\tt CR LF}) and so this method should be used to obtain the correct results instead of extracting parts of the entire value. It @@ -822,7 +822,7 @@ sequence in the native control. This function finds the character at the specified position expressed in pixels. If the return code is not \texttt{wxTE\_HT\_UNKNOWN} the row and column -of the character closest to this position are returned in the \arg{col} and +of the character closest to this position are returned in the \arg{col} and \arg{row} parameters (unless the pointers are {\tt NULL} which is allowed). Please note that this function is currently only implemented in wxUniv, @@ -841,7 +841,7 @@ returns a 3-element list \texttt{(result, col, row)}}. Returns {\tt true} if the controls contents may be edited by user (note that it always can be changed by the program), i.e. if the control hasn't been put in -read-only mode by a previous call to +read-only mode by a previous call to \helpref{SetEditable}{wxtextctrlseteditable}. @@ -849,7 +849,7 @@ read-only mode by a previous call to \constfunc{bool}{IsModified}{\void} -Returns {\tt true} if the text has been modified by user. Note that calling +Returns {\tt true} if the text has been modified by user. Note that calling \helpref{SetValue}{wxtextctrlsetvalue} doesn't make the control modified. @@ -894,20 +894,20 @@ Loads and displays the named file, if it exists. % VZ: commenting this out as: (a) the docs are wrong (you can't replace % anything), (b) wxTextCtrl doesn't have any OnChar() anyhow %% \membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar} -%% +%% %% \func{void}{OnChar}{\param{wxKeyEvent\& }{event}} -%% +%% %% Default handler for character input. -%% +%% %% \wxheading{Remarks} -%% +%% %% It is possible to intercept character %% input by overriding this member. Call this function %% to let the default behaviour take place; not calling %% it results in the character being ignored. You can %% replace the {\it keyCode} member of {\it event} to %% translate keystrokes. -%% +%% %% Note that Windows and Motif have different ways %% of implementing the default behaviour. In Windows, %% calling wxTextCtrl::OnChar immediately @@ -916,9 +916,9 @@ Loads and displays the named file, if it exists. %% to let default processing happen. This might affect %% the way in which you write your OnChar function %% on different platforms. -%% +%% %% \wxheading{See also} -%% +%% %% \helpref{wxKeyEvent}{wxkeyevent} @@ -1167,7 +1167,7 @@ the styles are not supported under this platform. \func{virtual void}{SetValue}{\param{const wxString\& }{ value}} -Sets the text value and marks the control as not-modified (which means that +Sets the text value and marks the control as not-modified (which means that \helpref{IsModified}{wxtextctrlismodified} would return {\tt false} immediately after the call to SetValue). diff --git a/include/wx/cocoa/combobox.h b/include/wx/cocoa/combobox.h index 47316a81ae..4db5e44998 100644 --- a/include/wx/cocoa/combobox.h +++ b/include/wx/cocoa/combobox.h @@ -6,14 +6,12 @@ // Created: 2003/07/14 // RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __WX_COCOA_COMBOBOX_H__ #define __WX_COCOA_COMBOBOX_H__ -#include "wx/textctrl.h" - //#include "wx/cocoa/NSTableView.h" // ======================================================================== @@ -114,7 +112,7 @@ public: { wxTextCtrl::SetInsertionPointEnd(); } virtual long GetInsertionPoint() const { return wxTextCtrl::GetInsertionPoint(); } - virtual long GetLastPosition() const + virtual wxTextPos GetLastPosition() const { return wxTextCtrl::GetLastPosition(); } virtual void Replace(long from, long to, const wxString& value) { wxTextCtrl::Replace(from,to,value); } diff --git a/include/wx/cocoa/textctrl.h b/include/wx/cocoa/textctrl.h index b26da9254c..3746fc6a67 100644 --- a/include/wx/cocoa/textctrl.h +++ b/include/wx/cocoa/textctrl.h @@ -4,9 +4,9 @@ // Author: David Elliott // Modified by: // Created: 2003/03/16 -// RCS-ID: $Id: +// RCS-ID: $Id: // Copyright: (c) 2003 David Elliott -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __WX_COCOA_TEXTCTRL_H__ @@ -108,7 +108,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); // virtual void SelectAll(); diff --git a/include/wx/combobox.h b/include/wx/combobox.h index 51b88e169f..2f2050d573 100644 --- a/include/wx/combobox.h +++ b/include/wx/combobox.h @@ -22,6 +22,7 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr; // wxComboBoxBase: this interface defines the methods wxComboBox must implement // ---------------------------------------------------------------------------- +#include "wx/textctrl.h" #include "wx/ctrlsub.h" class WXDLLEXPORT wxComboBoxBase : public wxItemContainer @@ -36,7 +37,7 @@ public: virtual void Paste() = 0; virtual void SetInsertionPoint(long pos) = 0; virtual long GetInsertionPoint() const = 0; - virtual long GetLastPosition() const = 0; + virtual wxTextPos GetLastPosition() const = 0; virtual void Replace(long from, long to, const wxString& value) = 0; virtual void SetSelection(long from, long to) = 0; virtual void SetEditable(bool editable) = 0; diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index 7265f891e5..6bfc5cf1a3 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -5,7 +5,7 @@ // Created: 01/02/97 // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ public: void SetInsertionPoint( long pos ); void SetInsertionPointEnd() { SetInsertionPoint( -1 ); } long GetInsertionPoint() const; - long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; void Remove(long from, long to) { Replace(from, to, wxEmptyString); } void Replace( long from, long to, const wxString& value ); void SetSelection( long from, long to ); diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 2024575d7d..a13d3270c3 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -114,12 +114,12 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); - virtual bool Enable( bool enable = TRUE ); + virtual bool Enable( bool enable = true ); // Implementation from now on void OnDropFiles( wxDropFilesEvent &event ); @@ -154,13 +154,13 @@ public: void UpdateFontIfNeeded(); #endif // __WXGTK20__/!__WXGTK20__ - void SetModified() { m_modified = TRUE; } + void SetModified() { m_modified = true; } // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to // avoid horrible flicker/scrolling back and forth virtual void Freeze(); virtual void Thaw(); - + // textctrl specific scrolling virtual bool ScrollLines(int lines); virtual bool ScrollPages(int pages); @@ -180,7 +180,7 @@ public: static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - + protected: virtual wxSize DoGetBestSize() const; @@ -202,7 +202,7 @@ protected: // has the control been frozen by Freeze()? bool IsFrozen() const { return m_frozenness > 0; } #endif - + private: // change the font for everything in this control void ChangeFontGlobally(); @@ -224,7 +224,7 @@ private: // number of calls to Freeze() minus number of calls to Thaw() unsigned int m_frozenness; -#endif +#endif DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxTextCtrl); diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h index 7265f891e5..6bfc5cf1a3 100644 --- a/include/wx/gtk1/combobox.h +++ b/include/wx/gtk1/combobox.h @@ -5,7 +5,7 @@ // Created: 01/02/97 // Id: $Id$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ public: void SetInsertionPoint( long pos ); void SetInsertionPointEnd() { SetInsertionPoint( -1 ); } long GetInsertionPoint() const; - long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; void Remove(long from, long to) { Replace(from, to, wxEmptyString); } void Replace( long from, long to, const wxString& value ); void SetSelection( long from, long to ); diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h index 2024575d7d..a13d3270c3 100644 --- a/include/wx/gtk1/textctrl.h +++ b/include/wx/gtk1/textctrl.h @@ -114,12 +114,12 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); - virtual bool Enable( bool enable = TRUE ); + virtual bool Enable( bool enable = true ); // Implementation from now on void OnDropFiles( wxDropFilesEvent &event ); @@ -154,13 +154,13 @@ public: void UpdateFontIfNeeded(); #endif // __WXGTK20__/!__WXGTK20__ - void SetModified() { m_modified = TRUE; } + void SetModified() { m_modified = true; } // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to // avoid horrible flicker/scrolling back and forth virtual void Freeze(); virtual void Thaw(); - + // textctrl specific scrolling virtual bool ScrollLines(int lines); virtual bool ScrollPages(int pages); @@ -180,7 +180,7 @@ public: static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - + protected: virtual wxSize DoGetBestSize() const; @@ -202,7 +202,7 @@ protected: // has the control been frozen by Freeze()? bool IsFrozen() const { return m_frozenness > 0; } #endif - + private: // change the font for everything in this control void ChangeFontGlobally(); @@ -224,7 +224,7 @@ private: // number of calls to Freeze() minus number of calls to Thaw() unsigned int m_frozenness; -#endif +#endif DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxTextCtrl); diff --git a/include/wx/mac/carbon/combobox.h b/include/wx/mac/carbon/combobox.h index 93d4f549f1..b72509253d 100644 --- a/include/wx/mac/carbon/combobox.h +++ b/include/wx/mac/carbon/combobox.h @@ -16,7 +16,6 @@ #pragma interface "combobox.h" #endif -#include "wx/textctrl.h" #include "wx/choice.h" WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr; @@ -39,8 +38,8 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase virtual void DoMoveWindow(int x, int y, int width, int height); // forward these functions to all subcontrols - virtual bool Enable(bool enable = TRUE); - virtual bool Show(bool show = TRUE); + virtual bool Enable(bool enable = true); + virtual bool Show(bool show = true); virtual void SetFocus(); // callback functions @@ -111,7 +110,7 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const ; - virtual long GetLastPosition() const ; + virtual wxTextPos GetLastPosition() const ; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); diff --git a/include/wx/mac/carbon/textctrl.h b/include/wx/mac/carbon/textctrl.h index 109fbf394e..4930d5693b 100644 --- a/include/wx/mac/carbon/textctrl.h +++ b/include/wx/mac/carbon/textctrl.h @@ -26,7 +26,7 @@ class wxMacTextControl ; class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase { DECLARE_DYNAMIC_CLASS(wxTextCtrl) - + public: // creation // -------- @@ -43,14 +43,14 @@ public: Create(parent, id, value, pos, size, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); - + // accessors // --------- virtual wxString GetValue() const ; @@ -110,7 +110,7 @@ public: virtual void Copy(); virtual void Cut(); virtual void Paste(); - + virtual bool CanCopy() const; virtual bool CanCut() const; virtual bool CanPaste() const; @@ -126,7 +126,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); @@ -155,7 +155,7 @@ public: void OnUpdatePaste(wxUpdateUIEvent& event); void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); - + void OnEraseBackground(wxEraseEvent& event) ; virtual bool MacCanFocus() const { return true ; } diff --git a/include/wx/mac/classic/combobox.h b/include/wx/mac/classic/combobox.h index d21925377c..b59bce7a64 100644 --- a/include/wx/mac/classic/combobox.h +++ b/include/wx/mac/classic/combobox.h @@ -16,7 +16,6 @@ #pragma interface "combobox.h" #endif -#include "wx/textctrl.h" #include "wx/choice.h" WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr; @@ -34,8 +33,8 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase virtual void DoMoveWindow(int x, int y, int width, int height); // forward these functions to all subcontrols - virtual bool Enable(bool enable = TRUE); - virtual bool Show(bool show = TRUE); + virtual bool Enable(bool enable = true); + virtual bool Show(bool show = true); virtual void SetFocus(); // callback functions @@ -106,7 +105,7 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const ; - virtual long GetLastPosition() const ; + virtual wxTextPos GetLastPosition() const ; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); diff --git a/include/wx/mac/classic/textctrl.h b/include/wx/mac/classic/textctrl.h index df3a964339..23bea424ba 100644 --- a/include/wx/mac/classic/textctrl.h +++ b/include/wx/mac/classic/textctrl.h @@ -24,7 +24,7 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase { DECLARE_DYNAMIC_CLASS(wxTextCtrl) - + public: // creation // -------- @@ -41,14 +41,14 @@ public: Create(parent, id, value, pos, size, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); - + // accessors // --------- virtual wxString GetValue() const ; @@ -107,7 +107,7 @@ public: virtual void Copy(); virtual void Cut(); virtual void Paste(); - + virtual bool CanCopy() const; virtual bool CanCut() const; virtual bool CanPaste() const; @@ -123,7 +123,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); @@ -157,7 +157,7 @@ public: virtual bool MacSetupCursor( const wxPoint& pt ) ; virtual void MacSuperShown( bool show ) ; - virtual bool Show(bool show = TRUE) ; + virtual bool Show(bool show = true) ; protected: // common part of all ctors @@ -176,7 +176,7 @@ protected: void* m_macTXNvars ; bool m_macUsesTXN ; unsigned long m_maxLength ; - + DECLARE_EVENT_TABLE() }; diff --git a/include/wx/motif/combobox.h b/include/wx/motif/combobox.h index d0b5b2532c..b94cdb0d01 100644 --- a/include/wx/motif/combobox.h +++ b/include/wx/motif/combobox.h @@ -6,7 +6,7 @@ // Created: 17/09/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_COMBOBOX_H_ @@ -22,11 +22,11 @@ class WXDLLEXPORT wxComboBox: public wxChoice { DECLARE_DYNAMIC_CLASS(wxComboBox) - + public: wxComboBox() { m_inSetSelection = false; } ~wxComboBox(); - + inline wxComboBox(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, @@ -40,7 +40,7 @@ public: Create(parent, id, value, pos, size, n, choices, style, validator, name); } - + inline wxComboBox(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -54,7 +54,7 @@ public: Create(parent, id, value, pos, size, choices, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, @@ -63,7 +63,7 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr); - + bool Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -72,7 +72,7 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxComboBoxNameStr); - + // implementation of wxControlWithItems virtual int DoAppend(const wxString& item); virtual int DoInsert(const wxString& item, int pos); @@ -87,7 +87,7 @@ public: // Text field functions virtual wxString GetValue() const ; virtual void SetValue(const wxString& value); - + // Clipboard operations virtual void Copy(); virtual void Cut(); @@ -95,14 +95,14 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const ; - virtual long GetLastPosition() const ; + virtual wxTextPos GetLastPosition() const ; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); - + // Implementation - virtual void ChangeFont(bool keepOriginalSize = TRUE); + virtual void ChangeFont(bool keepOriginalSize = true); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); WXWidget GetTopWidget() const { return m_mainWidget; } diff --git a/include/wx/motif/textctrl.h b/include/wx/motif/textctrl.h index c8037713c7..3eaef48ab7 100644 --- a/include/wx/motif/textctrl.h +++ b/include/wx/motif/textctrl.h @@ -20,7 +20,7 @@ class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase { DECLARE_DYNAMIC_CLASS(wxTextCtrl) - + public: // creation // -------- @@ -36,26 +36,26 @@ public: { Create(parent, id, value, pos, size, style, validator, name); } - + bool Create(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); - + // accessors // --------- virtual wxString GetValue() const; virtual void SetValue(const wxString& value); - + virtual int GetLineLength(long lineNo) const; virtual wxString GetLineText(long lineNo) const; virtual int GetNumberOfLines() const; - + // operations // ---------- - + // Clipboard operations virtual void Copy(); virtual void Cut(); @@ -63,18 +63,18 @@ public: virtual bool CanCopy() const; virtual bool CanCut() const; virtual bool CanPaste() const; - + // Undo/redo virtual void Undo(); virtual void Redo(); - + virtual bool CanUndo() const; virtual bool CanRedo() const; - + virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); @@ -83,50 +83,50 @@ public: // selection. virtual void GetSelection(long* from, long* to) const; virtual bool IsEditable() const ; - + virtual void WriteText(const wxString& text); virtual void AppendText(const wxString& text); virtual void MarkDirty(); virtual void DiscardEdits(); virtual bool IsModified() const; - + virtual long XYToPosition(long x, long y) const; virtual bool PositionToXY(long pos, long *x, long *y) const; virtual void ShowPosition(long pos); virtual void Clear(); - + // callbacks // --------- void OnDropFiles(wxDropFilesEvent& event); void OnChar(wxKeyEvent& event); // void OnEraseBackground(wxEraseEvent& event); - + void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); void OnPaste(wxCommandEvent& event); void OnUndo(wxCommandEvent& event); void OnRedo(wxCommandEvent& event); - + void OnUpdateCut(wxUpdateUIEvent& event); void OnUpdateCopy(wxUpdateUIEvent& event); void OnUpdatePaste(wxUpdateUIEvent& event); void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); - + virtual void Command(wxCommandEvent& event); - + // implementation from here to the end // ----------------------------------- - virtual void ChangeFont(bool keepOriginalSize = TRUE); + virtual void ChangeFont(bool keepOriginalSize = true); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); void SetModified(bool mod) { m_modified = mod; } virtual WXWidget GetTopWidget() const; - + // send the CHAR and TEXT_UPDATED events void DoSendEvents(void /* XmTextVerifyCallbackStruct */ *cbs, long keycode); - + protected: wxString m_fileName; @@ -136,10 +136,10 @@ public: void* m_tempCallbackStruct; bool m_modified; wxString m_value; // Required for password text controls - + // Did we call wxTextCtrl::OnChar? If so, generate a command event. bool m_processedDefault; - + private: DECLARE_EVENT_TABLE() }; diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h index 4b269e401c..4a841ec05b 100644 --- a/include/wx/msw/combobox.h +++ b/include/wx/msw/combobox.h @@ -92,7 +92,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(int n) { wxChoice::SetSelection(n); } diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 1fb28361f6..736beed112 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -131,7 +131,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); diff --git a/include/wx/msw/wince/textctrlce.h b/include/wx/msw/wince/textctrlce.h index bad7dda85a..0556cdded6 100644 --- a/include/wx/msw/wince/textctrlce.h +++ b/include/wx/msw/wince/textctrlce.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/msw/wince/textctrlce.h -// Purpose: wxTextCtrl implementation for smart phones driven by WinCE +// Purpose: wxTextCtrl implementation for smart phones driven by WinCE // Author: Wlodzimierz ABX Skiba // Modified by: // Created: 30.08.2004 @@ -124,7 +124,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); diff --git a/include/wx/os2/combobox.h b/include/wx/os2/combobox.h index e1373b9bdc..3eebbb45f4 100644 --- a/include/wx/os2/combobox.h +++ b/include/wx/os2/combobox.h @@ -110,7 +110,7 @@ class WXDLLEXPORT wxComboBox : public wxChoice virtual void SetInsertionPoint(long lPos); virtual void SetInsertionPointEnd(void); virtual long GetInsertionPoint(void) const; - virtual long GetLastPosition(void) const; + virtual wxTextPos GetLastPosition(void) const; virtual void Replace( long lFrom ,long lTo ,const wxString& rsValue diff --git a/include/wx/os2/textctrl.h b/include/wx/os2/textctrl.h index 5e3c487683..7e4a1127b8 100644 --- a/include/wx/os2/textctrl.h +++ b/include/wx/os2/textctrl.h @@ -112,7 +112,7 @@ public: virtual void SetInsertionPoint(long lPos); virtual void SetInsertionPointEnd(void); virtual long GetInsertionPoint(void) const; - virtual long GetLastPosition(void) const; + virtual wxTextPos GetLastPosition(void) const; virtual void SetSelection( long lFrom ,long lTo diff --git a/include/wx/palmos/combobox.h b/include/wx/palmos/combobox.h index acfcbc0c48..405376ceb6 100644 --- a/include/wx/palmos/combobox.h +++ b/include/wx/palmos/combobox.h @@ -85,7 +85,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(int n) { wxChoice::SetSelection(n); } diff --git a/include/wx/palmos/textctrl.h b/include/wx/palmos/textctrl.h index 4a3528d1f2..35782d81bb 100644 --- a/include/wx/palmos/textctrl.h +++ b/include/wx/palmos/textctrl.h @@ -123,7 +123,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 582cf855cc..a944b5d8ba 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -70,6 +70,11 @@ typedef long wxTextCoord; WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; +// this is intentionally not enum to avoid warning fixes with +// typecasting from enum type to wxTextCoord +const wxTextCoord wxOutOfRangeTextCoord = -1; +const wxTextCoord wxInvalidTextCoord = -2; + // ---------------------------------------------------------------------------- // wxTextCtrl style flags // ---------------------------------------------------------------------------- @@ -359,7 +364,7 @@ public: virtual void SetInsertionPoint(long pos) = 0; virtual void SetInsertionPointEnd() = 0; virtual long GetInsertionPoint() const = 0; - virtual long GetLastPosition() const = 0; + virtual wxTextPos GetLastPosition() const = 0; virtual void SetSelection(long from, long to) = 0; virtual void SelectAll(); diff --git a/include/wx/univ/combobox.h b/include/wx/univ/combobox.h index b417a4e2f0..32f2881cad 100644 --- a/include/wx/univ/combobox.h +++ b/include/wx/univ/combobox.h @@ -277,7 +277,7 @@ public: virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void Replace(long from, long to, const wxString& value); virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); diff --git a/include/wx/x11/textctrl.h b/include/wx/x11/textctrl.h index a8377b2544..2e3b528c74 100644 --- a/include/wx/x11/textctrl.h +++ b/include/wx/x11/textctrl.h @@ -183,18 +183,18 @@ public: virtual void Redo() {} virtual bool CanUndo() const { return (m_undos.GetCount() > 0); } - virtual bool CanRedo() const { return FALSE; } + virtual bool CanRedo() const { return false; } // Insertion point virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); - virtual bool Enable( bool enable = TRUE ); + virtual bool Enable( bool enable = true ); void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); @@ -212,7 +212,7 @@ public: bool SetForegroundColour(const wxColour& colour); bool SetBackgroundColour(const wxColour& colour); - void SetModified() { m_modified = TRUE; } + void SetModified() { m_modified = true; } virtual void Freeze(); virtual void Thaw(); @@ -266,7 +266,7 @@ public: void OnInternalIdle(); void RefreshLine( int n ); void RefreshDown( int n ); - void MoveCursor( int new_x, int new_y, bool shift = FALSE, bool centre = FALSE ); + void MoveCursor( int new_x, int new_y, bool shift = false, bool centre = false ); void MyAdjustScrollbars(); protected: @@ -370,13 +370,6 @@ private: // wxTextCtrl types // ---------------------------------------------------------------------------- -// wxTextPos is the position in the text -typedef long wxTextPos; - -// wxTextCoord is the line or row number (which should have been unsigned but -// is long for backwards compatibility) -typedef long wxTextCoord; - class WXDLLEXPORT wxStdTextCtrlInputHandler : public wxStdInputHandler { public: @@ -384,10 +377,10 @@ public: virtual bool HandleKey(wxInputConsumer *consumer, const wxKeyEvent& event, - bool pressed) { return FALSE; } - virtual bool HandleMouse(wxInputConsumer *consumer, const wxMouseEvent& event) { return FALSE; } - virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event) { return FALSE; } - virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event) { return FALSE; } + bool pressed) { return false; } + virtual bool HandleMouse(wxInputConsumer *consumer, const wxMouseEvent& event) { return false; } + virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event) { return false; } + virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event) { return false; } protected: // get the position of the mouse click diff --git a/src/cocoa/textctrl.mm b/src/cocoa/textctrl.mm index 60533978a1..b1333610cb 100644 --- a/src/cocoa/textctrl.mm +++ b/src/cocoa/textctrl.mm @@ -6,7 +6,7 @@ // Created: 2003/03/16 // RCS-ID: $Id: // Copyright: (c) 2003 David Elliott -// Licence: wxWidgets licence +// Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -177,7 +177,7 @@ int wxTextCtrl::GetLineLength(long) const return 0; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { return 0; } diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index b31c830a00..977de53640 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -220,7 +220,7 @@ bool wxTextCtrlBase::LoadFile(const wxString& filename) bool wxTextCtrlBase::SaveFile(const wxString& filename) { - wxString filenameToUse = filename.IsEmpty() ? m_filename : filename; + wxString filenameToUse = filename.empty() ? m_filename : filename; if ( filenameToUse.empty() ) { // what kind of message to give? is it an error or a program bug? @@ -394,9 +394,8 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) case WXK_NUMPAD_DELETE: // delete the character at cursor { - const long pos = GetInsertionPoint(), - last = GetLastPosition(); - if ( pos < last ) + const long pos = GetInsertionPoint(); + if ( pos < GetLastPosition() ) Remove(pos, pos + 1); } break; diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index 727f33a11d..cda1784ab1 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -644,7 +644,7 @@ void wxLogWindow::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) // remove selection (WriteText is in fact ReplaceSelection) #ifdef __WXMSW__ - long nLen = pText->GetLastPosition(); + wxTextPos nLen = pText->GetLastPosition(); pText->SetSelection(nLen, nLen); #endif // Windows diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 627a4e3489..6c40b2d84a 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -51,7 +51,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) if (combo->m_ignoreNextUpdate) { - combo->m_ignoreNextUpdate = FALSE; + combo->m_ignoreNextUpdate = false; return; } @@ -70,7 +70,7 @@ gtk_dummy_callback(GtkEntry *WXUNUSED(entry), GtkCombo *WXUNUSED(combo)) static void gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) -{ +{ // when the popup is hidden, throw a SELECTED event only if the combobox // selection changed. int curSelection = combo->GetSelection(); @@ -82,7 +82,7 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) event.SetEventObject( combo ); combo->GetEventHandler()->ProcessEvent( event ); } - + // reset the selection flag to an identifiable value g_SelectionBeforePopup = -1; } @@ -192,16 +192,16 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, long style, const wxValidator& validator, const wxString& name ) { - m_ignoreNextUpdate = FALSE; - m_needParent = TRUE; - m_acceptsFocus = TRUE; + m_ignoreNextUpdate = false; + m_needParent = true; + m_acceptsFocus = true; m_prevSelection = 0; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); - return FALSE; + return false; } m_widget = gtk_combo_new(); @@ -211,7 +211,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id ); // ... and add surogate handler. combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed", - (GtkSignalFunc) gtk_dummy_callback, combo); + (GtkSignalFunc) gtk_dummy_callback, combo); // make it more useable gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget), TRUE ); @@ -223,7 +223,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, if (style & wxNO_BORDER) g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL ); #endif - + GtkWidget *list = GTK_COMBO(m_widget)->list; #ifndef __WXGTK20__ @@ -260,9 +260,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, // "show" and "hide" events are generated when user click on the combobox button which popups a list // this list is the "popwin" gtk widget gtk_signal_connect( GTK_OBJECT(GTK_COMBO(combo)->popwin), "hide", - GTK_SIGNAL_FUNC(gtk_popup_hide_callback), (gpointer)this ); + GTK_SIGNAL_FUNC(gtk_popup_hide_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(GTK_COMBO(combo)->popwin), "show", - GTK_SIGNAL_FUNC(gtk_popup_show_callback), (gpointer)this ); + GTK_SIGNAL_FUNC(gtk_popup_show_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(combo->entry), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this ); @@ -276,7 +276,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, wxSize setsize = GetSize(); gtk_widget_set_usize( m_widget, setsize.x, setsize.y ); - return TRUE; + return true; } wxComboBox::~wxComboBox() @@ -780,7 +780,7 @@ long wxComboBox::GetInsertionPoint() const return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry ); } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { GtkWidget *entry = GTK_COMBO(m_widget)->entry; int pos = GTK_ENTRY(entry)->text_length; diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 230e7d6646..b8e19bb2e6 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -292,13 +292,13 @@ END_EVENT_TABLE() void wxTextCtrl::Init() { m_ignoreNextUpdate = - m_modified = FALSE; - SetUpdateFont(FALSE); + m_modified = false; + SetUpdateFont(false); m_text = m_vScrollbar = (GtkWidget *)NULL; #ifdef __WXGTK20__ m_frozenness = 0; -#endif +#endif } wxTextCtrl::wxTextCtrl( wxWindow *parent, @@ -324,18 +324,18 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxValidator& validator, const wxString &name ) { - m_needParent = TRUE; - m_acceptsFocus = TRUE; + m_needParent = true; + m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxTextCtrl creation failed") ); - return FALSE; + return false; } - m_vScrollbarVisible = FALSE; + m_vScrollbarVisible = false; bool multi_line = (style & wxTE_MULTILINE) != 0; @@ -363,14 +363,14 @@ bool wxTextCtrl::Create( wxWindow *parent, if (!HasFlag(wxNO_BORDER)) gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN ); - + GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); #else // create our control ... m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); // ... and put into the upper left hand corner of the table - bool bHasHScrollbar = FALSE; + bool bHasHScrollbar = false; m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1, @@ -396,7 +396,7 @@ bool wxTextCtrl::Create( wxWindow *parent, m_widget = m_text = gtk_entry_new(); -#ifdef __WXGTK20__ +#ifdef __WXGTK20__ if (style & wxNO_BORDER) g_object_set( GTK_ENTRY(m_text), "has-frame", FALSE, NULL ); #endif @@ -431,7 +431,7 @@ bool wxTextCtrl::Create( wxWindow *parent, } #endif // GTK+ 1.x - if (!value.IsEmpty()) + if (!value.empty()) { #ifdef __WXGTK20__ SetValue( value ); @@ -505,7 +505,7 @@ bool wxTextCtrl::Create( wxWindow *parent, #endif } #endif // __WXGTK20__ - + // We want to be notified about text changes. #ifdef __WXGTK20__ if (multi_line) @@ -515,7 +515,7 @@ bool wxTextCtrl::Create( wxWindow *parent, } else #endif - + { gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); @@ -526,7 +526,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont()); SetDefaultStyle( attrDef ); - return TRUE; + return true; } @@ -542,7 +542,7 @@ void wxTextCtrl::CalculateScrollbar() if (m_vScrollbarVisible) { gtk_widget_hide( m_vScrollbar ); - m_vScrollbarVisible = FALSE; + m_vScrollbarVisible = false; } } else @@ -550,7 +550,7 @@ void wxTextCtrl::CalculateScrollbar() if (!m_vScrollbarVisible) { gtk_widget_show( m_vScrollbar ); - m_vScrollbarVisible = TRUE; + m_vScrollbarVisible = true; } } #endif @@ -629,7 +629,7 @@ void wxTextCtrl::SetValue( const wxString &value ) // customize this behaviour. SetInsertionPoint(0); - m_modified = FALSE; + m_modified = false; } void wxTextCtrl::WriteText( const wxString &text ) @@ -683,7 +683,7 @@ void wxTextCtrl::WriteText( const wxString &text ) // in UpdateFontIfNeeded() any longer if ( !text.empty() ) { - SetUpdateFont(FALSE); + SetUpdateFont(false); } // Bring editable's cursor back uptodate. @@ -785,7 +785,7 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const // cast to prevent warning. But pos really should've been unsigned. if( (unsigned long)pos > text.Len() ) - return FALSE; + return false; *x=0; // First Col *y=0; // First Line @@ -812,11 +812,11 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const else { // index out of bounds - return FALSE; + return false; } } - return TRUE; + return true; } long wxTextCtrl::XYToPosition(long x, long y ) const @@ -957,7 +957,7 @@ bool wxTextCtrl::Enable( bool enable ) if (!wxWindowBase::Enable(enable)) { // nothing to do - return FALSE; + return false; } if (m_windowStyle & wxTE_MULTILINE) @@ -974,7 +974,7 @@ bool wxTextCtrl::Enable( bool enable ) gtk_widget_set_sensitive( m_text, enable ); } - return TRUE; + return true; } // wxGTK-specific: called recursively by Enable, @@ -999,12 +999,12 @@ void wxTextCtrl::OnParentEnable( bool enable ) void wxTextCtrl::MarkDirty() { - m_modified = TRUE; + m_modified = true; } void wxTextCtrl::DiscardEdits() { - m_modified = FALSE; + m_modified = false; } // ---------------------------------------------------------------------------- @@ -1013,19 +1013,19 @@ void wxTextCtrl::DiscardEdits() void wxTextCtrl::IgnoreNextTextUpdate() { - m_ignoreNextUpdate = TRUE; + m_ignoreNextUpdate = true; } bool wxTextCtrl::IgnoreTextUpdate() { if ( m_ignoreNextUpdate ) { - m_ignoreNextUpdate = FALSE; + m_ignoreNextUpdate = false; - return TRUE; + return true; } - return FALSE; + return false; } void wxTextCtrl::SetMaxLength(unsigned long len) @@ -1178,7 +1178,7 @@ long wxTextCtrl::GetInsertionPoint() const } } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") ); @@ -1227,7 +1227,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) Remove( from, to ); - if (!value.IsEmpty()) + if (!value.empty()) { #ifdef __WXGTK20__ SetInsertionPoint( from ); @@ -1297,14 +1297,14 @@ bool wxTextCtrl::CanUndo() const { // TODO //wxFAIL_MSG( wxT("wxTextCtrl::CanUndo not implemented") ); - return FALSE; + return false; } bool wxTextCtrl::CanRedo() const { // TODO //wxFAIL_MSG( wxT("wxTextCtrl::CanRedo not implemented") ); - return FALSE; + return false; } // If the return values from and to are the same, there is no @@ -1315,7 +1315,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const gint from = -1; gint to = -1; - bool haveSelection = FALSE; + bool haveSelection = false; #ifdef __WXGTK20__ if (m_windowStyle & wxTE_MULTILINE) @@ -1323,7 +1323,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const GtkTextIter ifrom, ito; if ( gtk_text_buffer_get_selection_bounds(m_buffer, &ifrom, &ito) ) { - haveSelection = TRUE; + haveSelection = true; from = gtk_text_iter_get_offset(&ifrom); to = gtk_text_iter_get_offset(&ito); } @@ -1333,13 +1333,13 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const if ( gtk_editable_get_selection_bounds( GTK_EDITABLE(m_text), &from, &to) ) { - haveSelection = TRUE; + haveSelection = true; } } #else // not GTK2 if ( (GTK_EDITABLE(m_text)->has_selection) ) { - haveSelection = TRUE; + haveSelection = true; from = (long) GTK_EDITABLE(m_text)->selection_start_pos; to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } @@ -1365,7 +1365,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const bool wxTextCtrl::IsEditable() const { - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); + wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); #ifdef __WXGTK20__ if (m_windowStyle & wxTE_MULTILINE) @@ -1451,24 +1451,24 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) // the font will change for subsequent text insertiongs bool wxTextCtrl::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); + wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); if ( !wxTextCtrlBase::SetFont(font) ) { // font didn't change, nothing to do - return FALSE; + return false; } if ( m_windowStyle & wxTE_MULTILINE ) { - SetUpdateFont(TRUE); + SetUpdateFont(true); m_defaultStyle.SetFont(font); ChangeFontGlobally(); } - return TRUE; + return true; } void wxTextCtrl::ChangeFontGlobally() @@ -1487,9 +1487,9 @@ void wxTextCtrl::ChangeFontGlobally() #endif wxString value = GetValue(); - if ( !value.IsEmpty() ) + if ( !value.empty() ) { - SetUpdateFont(FALSE); + SetUpdateFont(false); Clear(); AppendText(value); @@ -1509,35 +1509,35 @@ void wxTextCtrl::UpdateFontIfNeeded() bool wxTextCtrl::SetForegroundColour(const wxColour& colour) { if ( !wxControl::SetForegroundColour(colour) ) - return FALSE; + return false; // update default fg colour too m_defaultStyle.SetTextColour(colour); - return TRUE; + return true; } bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); + wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); if ( !wxControl::SetBackgroundColour( colour ) ) - return FALSE; + return false; #ifndef __WXGTK20__ if (!m_widget->window) - return FALSE; + return false; #endif if (!m_backgroundColour.Ok()) - return FALSE; + return false; if (m_windowStyle & wxTE_MULTILINE) { #ifndef __WXGTK20__ GdkWindow *window = GTK_TEXT(m_text)->text_area; if (!window) - return FALSE; + return false; m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); gdk_window_clear( window ); @@ -1547,7 +1547,7 @@ bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) // change active background color too m_defaultStyle.SetBackgroundColour( colour ); - return TRUE; + return true; } bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) @@ -1557,12 +1557,12 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) if ( style.IsDefault() ) { // nothing to do - return TRUE; + return true; } #ifdef __WXGTK20__ gint l = gtk_text_buffer_get_char_count( m_buffer ); - wxCHECK_MSG( start >= 0 && end <= l, FALSE, + wxCHECK_MSG( start >= 0 && end <= l, false, _T("invalid range in wxTextCtrl::SetStyle") ); GtkTextIter starti, endi; @@ -1576,14 +1576,14 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi ); - return TRUE; + return true; #else // VERY dirty way to do that - removes the required text and re-adds it // with styling (FIXME) gint l = gtk_text_get_length( GTK_TEXT(m_text) ); - wxCHECK_MSG( start >= 0 && end <= l, FALSE, + wxCHECK_MSG( start >= 0 && end <= l, false, _T("invalid range in wxTextCtrl::SetStyle") ); gint old_pos = gtk_editable_get_position( GTK_EDITABLE(m_text) ); @@ -1615,12 +1615,12 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */ SetInsertionPoint( old_pos ); #endif - return TRUE; + return true; } else // singe line { // cannot do this for GTK+'s Entry widget - return FALSE; + return false; } } @@ -1808,7 +1808,7 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) if ( fabs(adj->value - value) < 0.2 ) { // well, this is what Robert does in wxScrollBar, so it must be good... - return FALSE; + return false; } adj->value = value; @@ -1819,14 +1819,14 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed"); #endif - return TRUE; + return true; } bool wxTextCtrl::ScrollLines(int lines) { GtkAdjustment *adj = GetVAdj(); if ( !adj ) - return FALSE; + return false; #ifdef __WXGTK20__ int diff = (int)ceil(lines*adj->step_increment); @@ -1842,7 +1842,7 @@ bool wxTextCtrl::ScrollPages(int pages) { GtkAdjustment *adj = GetVAdj(); if ( !adj ) - return FALSE; + return false; return DoScroll(adj, (int)ceil(pages*adj->page_increment)); } diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 627a4e3489..6c40b2d84a 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -51,7 +51,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) if (combo->m_ignoreNextUpdate) { - combo->m_ignoreNextUpdate = FALSE; + combo->m_ignoreNextUpdate = false; return; } @@ -70,7 +70,7 @@ gtk_dummy_callback(GtkEntry *WXUNUSED(entry), GtkCombo *WXUNUSED(combo)) static void gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) -{ +{ // when the popup is hidden, throw a SELECTED event only if the combobox // selection changed. int curSelection = combo->GetSelection(); @@ -82,7 +82,7 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) event.SetEventObject( combo ); combo->GetEventHandler()->ProcessEvent( event ); } - + // reset the selection flag to an identifiable value g_SelectionBeforePopup = -1; } @@ -192,16 +192,16 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, long style, const wxValidator& validator, const wxString& name ) { - m_ignoreNextUpdate = FALSE; - m_needParent = TRUE; - m_acceptsFocus = TRUE; + m_ignoreNextUpdate = false; + m_needParent = true; + m_acceptsFocus = true; m_prevSelection = 0; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); - return FALSE; + return false; } m_widget = gtk_combo_new(); @@ -211,7 +211,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id ); // ... and add surogate handler. combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed", - (GtkSignalFunc) gtk_dummy_callback, combo); + (GtkSignalFunc) gtk_dummy_callback, combo); // make it more useable gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget), TRUE ); @@ -223,7 +223,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, if (style & wxNO_BORDER) g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL ); #endif - + GtkWidget *list = GTK_COMBO(m_widget)->list; #ifndef __WXGTK20__ @@ -260,9 +260,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, // "show" and "hide" events are generated when user click on the combobox button which popups a list // this list is the "popwin" gtk widget gtk_signal_connect( GTK_OBJECT(GTK_COMBO(combo)->popwin), "hide", - GTK_SIGNAL_FUNC(gtk_popup_hide_callback), (gpointer)this ); + GTK_SIGNAL_FUNC(gtk_popup_hide_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(GTK_COMBO(combo)->popwin), "show", - GTK_SIGNAL_FUNC(gtk_popup_show_callback), (gpointer)this ); + GTK_SIGNAL_FUNC(gtk_popup_show_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(combo->entry), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this ); @@ -276,7 +276,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, wxSize setsize = GetSize(); gtk_widget_set_usize( m_widget, setsize.x, setsize.y ); - return TRUE; + return true; } wxComboBox::~wxComboBox() @@ -780,7 +780,7 @@ long wxComboBox::GetInsertionPoint() const return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry ); } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { GtkWidget *entry = GTK_COMBO(m_widget)->entry; int pos = GTK_ENTRY(entry)->text_length; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 230e7d6646..b8e19bb2e6 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -292,13 +292,13 @@ END_EVENT_TABLE() void wxTextCtrl::Init() { m_ignoreNextUpdate = - m_modified = FALSE; - SetUpdateFont(FALSE); + m_modified = false; + SetUpdateFont(false); m_text = m_vScrollbar = (GtkWidget *)NULL; #ifdef __WXGTK20__ m_frozenness = 0; -#endif +#endif } wxTextCtrl::wxTextCtrl( wxWindow *parent, @@ -324,18 +324,18 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxValidator& validator, const wxString &name ) { - m_needParent = TRUE; - m_acceptsFocus = TRUE; + m_needParent = true; + m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxTextCtrl creation failed") ); - return FALSE; + return false; } - m_vScrollbarVisible = FALSE; + m_vScrollbarVisible = false; bool multi_line = (style & wxTE_MULTILINE) != 0; @@ -363,14 +363,14 @@ bool wxTextCtrl::Create( wxWindow *parent, if (!HasFlag(wxNO_BORDER)) gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN ); - + GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); #else // create our control ... m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); // ... and put into the upper left hand corner of the table - bool bHasHScrollbar = FALSE; + bool bHasHScrollbar = false; m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1, @@ -396,7 +396,7 @@ bool wxTextCtrl::Create( wxWindow *parent, m_widget = m_text = gtk_entry_new(); -#ifdef __WXGTK20__ +#ifdef __WXGTK20__ if (style & wxNO_BORDER) g_object_set( GTK_ENTRY(m_text), "has-frame", FALSE, NULL ); #endif @@ -431,7 +431,7 @@ bool wxTextCtrl::Create( wxWindow *parent, } #endif // GTK+ 1.x - if (!value.IsEmpty()) + if (!value.empty()) { #ifdef __WXGTK20__ SetValue( value ); @@ -505,7 +505,7 @@ bool wxTextCtrl::Create( wxWindow *parent, #endif } #endif // __WXGTK20__ - + // We want to be notified about text changes. #ifdef __WXGTK20__ if (multi_line) @@ -515,7 +515,7 @@ bool wxTextCtrl::Create( wxWindow *parent, } else #endif - + { gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); @@ -526,7 +526,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont()); SetDefaultStyle( attrDef ); - return TRUE; + return true; } @@ -542,7 +542,7 @@ void wxTextCtrl::CalculateScrollbar() if (m_vScrollbarVisible) { gtk_widget_hide( m_vScrollbar ); - m_vScrollbarVisible = FALSE; + m_vScrollbarVisible = false; } } else @@ -550,7 +550,7 @@ void wxTextCtrl::CalculateScrollbar() if (!m_vScrollbarVisible) { gtk_widget_show( m_vScrollbar ); - m_vScrollbarVisible = TRUE; + m_vScrollbarVisible = true; } } #endif @@ -629,7 +629,7 @@ void wxTextCtrl::SetValue( const wxString &value ) // customize this behaviour. SetInsertionPoint(0); - m_modified = FALSE; + m_modified = false; } void wxTextCtrl::WriteText( const wxString &text ) @@ -683,7 +683,7 @@ void wxTextCtrl::WriteText( const wxString &text ) // in UpdateFontIfNeeded() any longer if ( !text.empty() ) { - SetUpdateFont(FALSE); + SetUpdateFont(false); } // Bring editable's cursor back uptodate. @@ -785,7 +785,7 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const // cast to prevent warning. But pos really should've been unsigned. if( (unsigned long)pos > text.Len() ) - return FALSE; + return false; *x=0; // First Col *y=0; // First Line @@ -812,11 +812,11 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const else { // index out of bounds - return FALSE; + return false; } } - return TRUE; + return true; } long wxTextCtrl::XYToPosition(long x, long y ) const @@ -957,7 +957,7 @@ bool wxTextCtrl::Enable( bool enable ) if (!wxWindowBase::Enable(enable)) { // nothing to do - return FALSE; + return false; } if (m_windowStyle & wxTE_MULTILINE) @@ -974,7 +974,7 @@ bool wxTextCtrl::Enable( bool enable ) gtk_widget_set_sensitive( m_text, enable ); } - return TRUE; + return true; } // wxGTK-specific: called recursively by Enable, @@ -999,12 +999,12 @@ void wxTextCtrl::OnParentEnable( bool enable ) void wxTextCtrl::MarkDirty() { - m_modified = TRUE; + m_modified = true; } void wxTextCtrl::DiscardEdits() { - m_modified = FALSE; + m_modified = false; } // ---------------------------------------------------------------------------- @@ -1013,19 +1013,19 @@ void wxTextCtrl::DiscardEdits() void wxTextCtrl::IgnoreNextTextUpdate() { - m_ignoreNextUpdate = TRUE; + m_ignoreNextUpdate = true; } bool wxTextCtrl::IgnoreTextUpdate() { if ( m_ignoreNextUpdate ) { - m_ignoreNextUpdate = FALSE; + m_ignoreNextUpdate = false; - return TRUE; + return true; } - return FALSE; + return false; } void wxTextCtrl::SetMaxLength(unsigned long len) @@ -1178,7 +1178,7 @@ long wxTextCtrl::GetInsertionPoint() const } } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") ); @@ -1227,7 +1227,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) Remove( from, to ); - if (!value.IsEmpty()) + if (!value.empty()) { #ifdef __WXGTK20__ SetInsertionPoint( from ); @@ -1297,14 +1297,14 @@ bool wxTextCtrl::CanUndo() const { // TODO //wxFAIL_MSG( wxT("wxTextCtrl::CanUndo not implemented") ); - return FALSE; + return false; } bool wxTextCtrl::CanRedo() const { // TODO //wxFAIL_MSG( wxT("wxTextCtrl::CanRedo not implemented") ); - return FALSE; + return false; } // If the return values from and to are the same, there is no @@ -1315,7 +1315,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const gint from = -1; gint to = -1; - bool haveSelection = FALSE; + bool haveSelection = false; #ifdef __WXGTK20__ if (m_windowStyle & wxTE_MULTILINE) @@ -1323,7 +1323,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const GtkTextIter ifrom, ito; if ( gtk_text_buffer_get_selection_bounds(m_buffer, &ifrom, &ito) ) { - haveSelection = TRUE; + haveSelection = true; from = gtk_text_iter_get_offset(&ifrom); to = gtk_text_iter_get_offset(&ito); } @@ -1333,13 +1333,13 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const if ( gtk_editable_get_selection_bounds( GTK_EDITABLE(m_text), &from, &to) ) { - haveSelection = TRUE; + haveSelection = true; } } #else // not GTK2 if ( (GTK_EDITABLE(m_text)->has_selection) ) { - haveSelection = TRUE; + haveSelection = true; from = (long) GTK_EDITABLE(m_text)->selection_start_pos; to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } @@ -1365,7 +1365,7 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const bool wxTextCtrl::IsEditable() const { - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); + wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); #ifdef __WXGTK20__ if (m_windowStyle & wxTE_MULTILINE) @@ -1451,24 +1451,24 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) // the font will change for subsequent text insertiongs bool wxTextCtrl::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); + wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); if ( !wxTextCtrlBase::SetFont(font) ) { // font didn't change, nothing to do - return FALSE; + return false; } if ( m_windowStyle & wxTE_MULTILINE ) { - SetUpdateFont(TRUE); + SetUpdateFont(true); m_defaultStyle.SetFont(font); ChangeFontGlobally(); } - return TRUE; + return true; } void wxTextCtrl::ChangeFontGlobally() @@ -1487,9 +1487,9 @@ void wxTextCtrl::ChangeFontGlobally() #endif wxString value = GetValue(); - if ( !value.IsEmpty() ) + if ( !value.empty() ) { - SetUpdateFont(FALSE); + SetUpdateFont(false); Clear(); AppendText(value); @@ -1509,35 +1509,35 @@ void wxTextCtrl::UpdateFontIfNeeded() bool wxTextCtrl::SetForegroundColour(const wxColour& colour) { if ( !wxControl::SetForegroundColour(colour) ) - return FALSE; + return false; // update default fg colour too m_defaultStyle.SetTextColour(colour); - return TRUE; + return true; } bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); + wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") ); if ( !wxControl::SetBackgroundColour( colour ) ) - return FALSE; + return false; #ifndef __WXGTK20__ if (!m_widget->window) - return FALSE; + return false; #endif if (!m_backgroundColour.Ok()) - return FALSE; + return false; if (m_windowStyle & wxTE_MULTILINE) { #ifndef __WXGTK20__ GdkWindow *window = GTK_TEXT(m_text)->text_area; if (!window) - return FALSE; + return false; m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); gdk_window_clear( window ); @@ -1547,7 +1547,7 @@ bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) // change active background color too m_defaultStyle.SetBackgroundColour( colour ); - return TRUE; + return true; } bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) @@ -1557,12 +1557,12 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) if ( style.IsDefault() ) { // nothing to do - return TRUE; + return true; } #ifdef __WXGTK20__ gint l = gtk_text_buffer_get_char_count( m_buffer ); - wxCHECK_MSG( start >= 0 && end <= l, FALSE, + wxCHECK_MSG( start >= 0 && end <= l, false, _T("invalid range in wxTextCtrl::SetStyle") ); GtkTextIter starti, endi; @@ -1576,14 +1576,14 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi ); - return TRUE; + return true; #else // VERY dirty way to do that - removes the required text and re-adds it // with styling (FIXME) gint l = gtk_text_get_length( GTK_TEXT(m_text) ); - wxCHECK_MSG( start >= 0 && end <= l, FALSE, + wxCHECK_MSG( start >= 0 && end <= l, false, _T("invalid range in wxTextCtrl::SetStyle") ); gint old_pos = gtk_editable_get_position( GTK_EDITABLE(m_text) ); @@ -1615,12 +1615,12 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */ SetInsertionPoint( old_pos ); #endif - return TRUE; + return true; } else // singe line { // cannot do this for GTK+'s Entry widget - return FALSE; + return false; } } @@ -1808,7 +1808,7 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) if ( fabs(adj->value - value) < 0.2 ) { // well, this is what Robert does in wxScrollBar, so it must be good... - return FALSE; + return false; } adj->value = value; @@ -1819,14 +1819,14 @@ bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed"); #endif - return TRUE; + return true; } bool wxTextCtrl::ScrollLines(int lines) { GtkAdjustment *adj = GetVAdj(); if ( !adj ) - return FALSE; + return false; #ifdef __WXGTK20__ int diff = (int)ceil(lines*adj->step_increment); @@ -1842,7 +1842,7 @@ bool wxTextCtrl::ScrollPages(int pages) { GtkAdjustment *adj = GetVAdj(); if ( !adj ) - return FALSE; + return false; return DoScroll(adj, (int)ceil(pages*adj->page_increment)); } diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 070285404f..2b758e3fb0 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -68,18 +68,18 @@ public: protected: void OnChar( wxKeyEvent& event ) { - // Allows processing the tab key to go to the next control - if (event.GetKeyCode() == WXK_TAB) - { - wxNavigationKeyEvent NavEvent; - NavEvent.SetEventObject(this); - NavEvent.SetDirection(true); - NavEvent.SetWindowChange(false); - - // Get the parent of the combo and have it process the navigation? - if (m_cb->GetParent()->GetEventHandler()->ProcessEvent(NavEvent)) + // Allows processing the tab key to go to the next control + if (event.GetKeyCode() == WXK_TAB) + { + wxNavigationKeyEvent NavEvent; + NavEvent.SetEventObject(this); + NavEvent.SetDirection(true); + NavEvent.SetWindowChange(false); + + // Get the parent of the combo and have it process the navigation? + if (m_cb->GetParent()->GetEventHandler()->ProcessEvent(NavEvent)) return; - } + } if ( event.GetKeyCode() == WXK_RETURN ) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_cb->GetId()); @@ -269,17 +269,17 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) bool wxComboBox::Enable(bool enable) { if ( !wxControl::Enable(enable) ) - return FALSE; + return false; - return TRUE; + return true; } bool wxComboBox::Show(bool show) { if ( !wxControl::Show(show) ) - return FALSE; + return false; - return TRUE; + return true; } void wxComboBox::SetFocus() @@ -330,7 +330,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style , wxDefaultValidator, name) ) { - return FALSE; + return false; } m_choice = new wxComboBoxChoice(this, style ); @@ -358,7 +358,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, SetBestSize(size); // Needed because it is a wxControlWithItems - return TRUE; + return true; } wxString wxComboBox::GetValue() const @@ -452,7 +452,7 @@ long wxComboBox::GetInsertionPoint() const return 0; } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { // TODO return 0; @@ -569,10 +569,10 @@ bool wxComboBox::SetStringSelection(const wxString& sel) if (s > -1) { SetSelection (s); - return TRUE; + return true; } else - return FALSE; + return false; } void wxComboBox::SetString(int n, const wxString& s) @@ -582,7 +582,7 @@ void wxComboBox::SetString(int n, const wxString& s) bool wxComboBox::IsEditable() const { - return m_text != NULL && !HasFlag(wxCB_READONLY); + return m_text != NULL && !HasFlag(wxCB_READONLY); } void wxComboBox::Undo() diff --git a/src/mac/carbon/combobxc.cpp b/src/mac/carbon/combobxc.cpp index b26e9741da..3bf9fce05d 100644 --- a/src/mac/carbon/combobxc.cpp +++ b/src/mac/carbon/combobxc.cpp @@ -19,7 +19,7 @@ #include "wx/mac/uma.h" #if TARGET_API_MAC_OSX #ifndef __HIVIEW__ - #include + #include #endif #endif @@ -246,7 +246,7 @@ wxComboBox::~wxComboBox() wxSize wxComboBox::DoGetBestSize() const { #if USE_HICOMBOBOX - return wxControl::DoGetBestSize(); + return wxControl::DoGetBestSize(); #else wxSize size = m_choice->GetBestSize(); @@ -263,7 +263,7 @@ wxSize wxComboBox::DoGetBestSize() const void wxComboBox::DoMoveWindow(int x, int y, int width, int height) { #if USE_HICOMBOBOX - wxControl::DoMoveWindow(x, y, width, height); + wxControl::DoMoveWindow(x, y, width, height); #else height = POPUPHEIGHT; @@ -293,23 +293,23 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) { bool wxComboBox::Enable(bool enable) { if ( !wxControl::Enable(enable) ) - return FALSE; + return false; - return TRUE; + return true; } bool wxComboBox::Show(bool show) { if ( !wxControl::Show(show) ) - return FALSE; + return false; - return TRUE; + return true; } void wxComboBox::SetFocus() { #if USE_HICOMBOBOX - wxControl::SetFocus(); + wxControl::SetFocus(); #else if ( m_text != NULL) { m_text->SetFocus(); @@ -358,12 +358,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, m_text = NULL; m_choice = NULL; #if USE_HICOMBOBOX - m_macIsUserPane = FALSE ; + m_macIsUserPane = false ; #endif if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style , wxDefaultValidator, name) ) { - return FALSE; + return false; } #if USE_HICOMBOBOX Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; @@ -380,8 +380,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, //hiRect.size.width = bounds.right - bounds.left; //hiRect.size.height = bounds.bottom - bounds.top; //printf("left = %d, right = %d, top = %d, bottom = %d\n", bounds.left, bounds.right, bounds.top, bounds.bottom); - //printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height); - m_peer = new wxMacControl() ; + //printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height); + m_peer = new wxMacControl() ; verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, *m_peer ) ); @@ -431,7 +431,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, SetBestSize(csize); // Needed because it is a wxControlWithItems #endif - return TRUE; + return true; } wxString wxComboBox::GetValue() const @@ -532,7 +532,7 @@ long wxComboBox::GetInsertionPoint() const return 0; } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { // TODO return 0; @@ -628,9 +628,9 @@ void wxComboBox::FreeData() int wxComboBox::GetCount() const { #if USE_HICOMBOBOX - return (int) HIComboBoxGetItemCount( *m_peer ); + return (int) HIComboBoxGetItemCount( *m_peer ); #else - return m_choice->GetCount() ; + return m_choice->GetCount() ; #endif } @@ -686,7 +686,7 @@ int wxComboBox::FindString(const wxString& s) const #if USE_HICOMBOBOX for( int i = 0 ; i < GetCount() ; i++ ) { - if ( GetString( i ).IsSameAs(s, FALSE) ) + if ( GetString( i ).IsSameAs(s, false) ) return i ; } return wxNOT_FOUND ; @@ -725,10 +725,10 @@ bool wxComboBox::SetStringSelection(const wxString& sel) if (s > -1) { SetSelection (s); - return TRUE; + return true; } else - return FALSE; + return false; } void wxComboBox::SetString(int n, const wxString& s) @@ -745,17 +745,17 @@ void wxComboBox::SetString(int n, const wxString& s) bool wxComboBox::IsEditable() const { #if USE_HICOMBOBOX - // TODO - return !HasFlag(wxCB_READONLY); + // TODO + return !HasFlag(wxCB_READONLY); #else - return m_text != NULL && !HasFlag(wxCB_READONLY); + return m_text != NULL && !HasFlag(wxCB_READONLY); #endif } void wxComboBox::Undo() { #if USE_HICOMBOBOX - // TODO + // TODO #else if (m_text != NULL) m_text->Undo(); @@ -765,7 +765,7 @@ void wxComboBox::Undo() void wxComboBox::Redo() { #if USE_HICOMBOBOX - // TODO + // TODO #else if (m_text != NULL) m_text->Redo(); @@ -775,7 +775,7 @@ void wxComboBox::Redo() void wxComboBox::SelectAll() { #if USE_HICOMBOBOX - // TODO + // TODO #else if (m_text != NULL) m_text->SelectAll(); @@ -785,8 +785,8 @@ void wxComboBox::SelectAll() bool wxComboBox::CanCopy() const { #if USE_HICOMBOBOX - // TODO - return false; + // TODO + return false; #else if (m_text != NULL) return m_text->CanCopy(); @@ -798,8 +798,8 @@ bool wxComboBox::CanCopy() const bool wxComboBox::CanCut() const { #if USE_HICOMBOBOX - // TODO - return false; + // TODO + return false; #else if (m_text != NULL) return m_text->CanCut(); @@ -811,8 +811,8 @@ bool wxComboBox::CanCut() const bool wxComboBox::CanPaste() const { #if USE_HICOMBOBOX - // TODO - return false; + // TODO + return false; #else if (m_text != NULL) return m_text->CanPaste(); @@ -824,8 +824,8 @@ bool wxComboBox::CanPaste() const bool wxComboBox::CanUndo() const { #if USE_HICOMBOBOX - // TODO - return false; + // TODO + return false; #else if (m_text != NULL) return m_text->CanUndo(); @@ -837,8 +837,8 @@ bool wxComboBox::CanUndo() const bool wxComboBox::CanRedo() const { #if USE_HICOMBOBOX - // TODO - return false; + // TODO + return false; #else if (m_text != NULL) return m_text->CanRedo(); diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 7cc3dd0fae..54cb030e19 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -70,11 +70,11 @@ class wxMacFunctor { -public : +public : wxMacFunctor(){} virtual ~wxMacFunctor() {} virtual void* operator()() = 0 ; - static void* CallBackProc(void *param) + static void* CallBackProc(void *param) { wxMacFunctor* f = (wxMacFunctor*) param ; void *result = (*f)() ; @@ -87,7 +87,7 @@ class wxMacObjectFunctor1 : public wxMacFunctor { typedef void (classtype::*function)( param1type p1 ) ; typedef void (classtype::*ref_function)( const param1type& p1 ) ; -public : +public : wxMacObjectFunctor1( classtype *obj , function f , param1type p1 ) : wxMacFunctor( ) { @@ -105,8 +105,8 @@ public : } ~wxMacObjectFunctor1() {} - - virtual void* operator()() + + virtual void* operator()() { (m_object->*m_function)(m_param1) ; return NULL ; @@ -121,25 +121,25 @@ private : } ; } ; -template +template void* wxMacMPRemoteCall( classtype *object , void (classtype::*function)( param1type p1 ) , param1type p1 ) { - wxMacObjectFunctor1 params(object,function,p1) ; - void *result = + wxMacObjectFunctor1 params(object,function,p1) ; + void *result = MPRemoteCall( wxMacFunctor::CallBackProc , ¶ms , kMPOwningProcessRemoteContext ) ; return result ; } -template +template void* wxMacMPRemoteCall( classtype *object , void (classtype::*function)( const param1type& p1 ) , param1type p1 ) { - wxMacObjectFunctor1 params(object,function,p1) ; - void *result = + wxMacObjectFunctor1 params(object,function,p1) ; + void *result = MPRemoteCall( wxMacFunctor::CallBackProc , ¶ms , kMPOwningProcessRemoteContext ) ; return result ; } -template +template void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( param1type p1 ) , param1type p1 ) { wxMutexGuiLeave() ; @@ -148,7 +148,7 @@ void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( par return result ; } -template +template void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( const param1type& p1 ) , param1type p1 ) { wxMutexGuiLeave() ; @@ -162,7 +162,7 @@ class wxMacTextControl : public wxMacControl public : wxMacTextControl() ; ~wxMacTextControl() ; - + virtual wxString GetStringValue() const = 0 ; virtual void SetStringValue( const wxString &val ) = 0 ; virtual void SetStyle(long start, long end, const wxTextAttr& style) ; @@ -171,7 +171,7 @@ public : virtual void Paste() ; virtual bool CanPaste() const ; virtual void SetEditable(bool editable) ; - virtual long GetLastPosition() const ; + virtual wxTextPos GetLastPosition() const ; virtual void Replace( long from , long to , const wxString str ) ; virtual void Remove( long from , long to ) = 0 ; virtual void SetSelection( long from , long to ) = 0 ; @@ -180,7 +180,7 @@ public : virtual void Clear() ; virtual bool CanUndo() const; - virtual void Undo() ; + virtual void Undo() ; virtual bool CanRedo() const; virtual void Redo() ; virtual int GetNumberOfLines() const ; @@ -198,7 +198,7 @@ class wxMacMLTEControl : public wxMacTextControl public : virtual wxString GetStringValue() const ; virtual void SetStringValue( const wxString &str) ; - + static TXNFrameOptions FrameOptionsFromWXStyle( long wxStyle ) ; void AdjustCreationAttributes( const wxColour& background , bool visible ) ; @@ -210,12 +210,12 @@ public : virtual void Paste() ; virtual bool CanPaste() const ; virtual void SetEditable(bool editable) ; - virtual long GetLastPosition() const ; + virtual wxTextPos GetLastPosition() const ; virtual void Replace( long from , long to , const wxString str ) ; virtual void Remove( long from , long to ) ; virtual void GetSelection( long* from, long* to) const ; virtual void SetSelection( long from , long to ) ; - + virtual void WriteText(const wxString& str) ; virtual void Clear() ; @@ -243,7 +243,7 @@ protected : #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 -class wxMacMLTEHIViewControl : public wxMacMLTEControl +class wxMacMLTEHIViewControl : public wxMacMLTEControl { public : wxMacMLTEHIViewControl( wxWindow *wxPeer, @@ -352,16 +352,16 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_macIsUserPane = FALSE ; + m_macIsUserPane = false ; m_editable = true ; if ( ! ( style & wxNO_BORDER) ) style = ( style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ; - + if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) - return FALSE; + return false; - Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; + Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; if ( m_windowStyle & wxTE_MULTILINE ) { @@ -381,7 +381,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, #endif #if !wxMAC_AWAYS_USE_MLTE if ( !m_peer ) - { + { m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ; } #endif @@ -392,8 +392,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( !HasFlag(wxNO_BORDER) ) { m_windowStyle &= ~wxSUNKEN_BORDER ; - bounds = wxMacGetBoundsForControl( this , pos , size ) ; - } + bounds = wxMacGetBoundsForControl( this , pos , size ) ; + } m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ; } @@ -403,17 +403,16 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, { SetEditable( false ) ; } - - return TRUE; + return true; } -void wxTextCtrl::MacVisibilityChanged() +void wxTextCtrl::MacVisibilityChanged() { GetPeer()->VisibilityChanged( MacIsReallyShown() ) ; } -void wxTextCtrl::MacEnabledStateChanged() +void wxTextCtrl::MacEnabledStateChanged() { } @@ -423,7 +422,7 @@ wxString wxTextCtrl::GetValue() const } void wxTextCtrl::GetSelection(long* from, long* to) const -{ +{ GetPeer()->GetSelection( from , to ) ; } @@ -449,8 +448,8 @@ void wxTextCtrl::SetMaxLength(unsigned long len) bool wxTextCtrl::SetFont( const wxFont& font ) { if ( !wxTextCtrlBase::SetFont( font ) ) - return FALSE ; - + return false ; + GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle() ) ; return true ; } @@ -465,7 +464,7 @@ bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style) { wxTextCtrlBase::SetDefaultStyle( style ) ; SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ; - return TRUE ; + return true ; } // Clipboard operations @@ -473,7 +472,7 @@ void wxTextCtrl::Copy() { if (CanCopy()) { - GetPeer()->Copy() ; + GetPeer()->Copy() ; } } @@ -481,7 +480,7 @@ void wxTextCtrl::Cut() { if (CanCut()) { - GetPeer()->Cut() ; + GetPeer()->Cut() ; wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); event.SetEventObject( this ); @@ -493,7 +492,7 @@ void wxTextCtrl::Paste() { if (CanPaste()) { - GetPeer()->Paste() ; + GetPeer()->Paste() ; // eventually we should add setting the default style again wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); @@ -525,7 +524,7 @@ bool wxTextCtrl::CanCut() const bool wxTextCtrl::CanPaste() const { if (!IsEditable()) - return FALSE; + return false; return GetPeer()->CanPaste() ; } @@ -546,7 +545,7 @@ void wxTextCtrl::SetInsertionPoint(long pos) void wxTextCtrl::SetInsertionPointEnd() { - long pos = GetLastPosition(); + wxTextPos pos = GetLastPosition(); SetInsertionPoint(pos); } @@ -557,7 +556,7 @@ long wxTextCtrl::GetInsertionPoint() const return begin ; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { return GetPeer()->GetLastPosition( ) ; } @@ -581,10 +580,10 @@ bool wxTextCtrl::LoadFile(const wxString& file) { if ( wxTextCtrlBase::LoadFile(file) ) { - return TRUE; + return true; } - return FALSE; + return false; } void wxTextCtrl::WriteText(const wxString& str) @@ -592,7 +591,7 @@ void wxTextCtrl::WriteText(const wxString& str) // TODO this MPRemoting will be moved into a remoting peer proxy for any command if ( !wxIsMainThread() ) { - // unfortunately CW 8 is not able to correctly deduce the template types, so we have + // unfortunately CW 8 is not able to correctly deduce the template types, so we have // to instantiate explicitely wxMacMPRemoteGUICall( this , &wxTextCtrl::WriteText , str ) ; return ; @@ -652,7 +651,7 @@ wxSize wxTextCtrl::DoGetBestSize() const break ; default : hText = 22 - 6; - break ; + break ; } // as the above numbers have some free space around the text @@ -690,18 +689,18 @@ void wxTextCtrl::Redo() bool wxTextCtrl::CanUndo() const { - if ( !IsEditable() ) + if ( !IsEditable() ) { - return false ; + return false ; } return GetPeer()->CanUndo() ; } bool wxTextCtrl::CanRedo() const { - if ( !IsEditable() ) + if ( !IsEditable() ) { - return false ; + return false ; } return GetPeer()->CanRedo() ; } @@ -853,7 +852,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // this will make wxWidgets eat the ENTER key so that // we actually prevent line wrapping in a single line // text control - eat_key = TRUE; + eat_key = true; } break; @@ -875,7 +874,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // be inserted. WriteText(wxT("\t")); } - + break; } @@ -884,7 +883,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // perform keystroke handling if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; - else + else { EventRecord rec ; if ( wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ) @@ -971,39 +970,39 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt ) // user pane implementation -void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part) +void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part) { } -wxInt16 wxTextCtrl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) +wxInt16 wxTextCtrl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) { return kControlNoPart ; } -wxInt16 wxTextCtrl::MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) +wxInt16 wxTextCtrl::MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) { return kControlNoPart ; } -void wxTextCtrl::MacControlUserPaneIdleProc() +void wxTextCtrl::MacControlUserPaneIdleProc() { } -wxInt16 wxTextCtrl::MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) +wxInt16 wxTextCtrl::MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) { return kControlNoPart ; } -void wxTextCtrl::MacControlUserPaneActivateProc(bool activating) +void wxTextCtrl::MacControlUserPaneActivateProc(bool activating) { } -wxInt16 wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action) +wxInt16 wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action) { return kControlNoPart ; } -void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info) +void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info) { } @@ -1011,66 +1010,66 @@ void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info) // implementation base class // ---------------------------------------------------------------------------- -wxMacTextControl::wxMacTextControl() +wxMacTextControl::wxMacTextControl() { } -wxMacTextControl::~wxMacTextControl() +wxMacTextControl::~wxMacTextControl() { } -void wxMacTextControl::SetStyle(long start, long end, const wxTextAttr& style) +void wxMacTextControl::SetStyle(long start, long end, const wxTextAttr& style) { } -void wxMacTextControl::Copy() +void wxMacTextControl::Copy() { } -void wxMacTextControl::Cut() +void wxMacTextControl::Cut() { } -void wxMacTextControl::Paste() +void wxMacTextControl::Paste() { } -bool wxMacTextControl::CanPaste() const -{ +bool wxMacTextControl::CanPaste() const +{ return false ; } -void wxMacTextControl::SetEditable(bool editable) +void wxMacTextControl::SetEditable(bool editable) { -} +} -long wxMacTextControl::GetLastPosition() const +wxTextPos wxMacTextControl::GetLastPosition() const { return GetStringValue().Length() ; } -void wxMacTextControl::Replace( long from , long to , const wxString str ) +void wxMacTextControl::Replace( long from , long to , const wxString str ) { } -void wxMacTextControl::Clear() +void wxMacTextControl::Clear() { SetStringValue( wxEmptyString ) ; } -bool wxMacTextControl::CanUndo() const +bool wxMacTextControl::CanUndo() const { return false ; } -void wxMacTextControl::Undo() { } +void wxMacTextControl::Undo() { } bool wxMacTextControl::CanRedo() const { return false ; -} +} -void wxMacTextControl::Redo() +void wxMacTextControl::Redo() { } @@ -1079,16 +1078,16 @@ long wxMacTextControl::XYToPosition(long x, long y) const return 0 ; } -bool wxMacTextControl::PositionToXY(long pos, long *x, long *y) const +bool wxMacTextControl::PositionToXY(long pos, long *x, long *y) const { return false ; } -void wxMacTextControl::ShowPosition( long WXUNUSED(pos) ) -{ -} +void wxMacTextControl::ShowPosition( long WXUNUSED(pos) ) +{ +} -int wxMacTextControl::GetNumberOfLines() const +int wxMacTextControl::GetNumberOfLines() const { ItemCount lines = 0 ; wxString content = GetStringValue() ; @@ -1104,7 +1103,7 @@ wxString wxMacTextControl::GetLineText(long lineNo) const { // TODO change this if possible to reflect real lines wxString content = GetStringValue() ; - + // Find line first int count = 0; for (size_t i = 0; i < content.Length() ; i++) @@ -1113,15 +1112,15 @@ wxString wxMacTextControl::GetLineText(long lineNo) const { // Add chars in line then wxString tmp; - + for (size_t j = i; j < content.Length(); j++) { if (content[j] == '\n') return tmp; - + tmp += content[j]; } - + return tmp; } if (content[i] == '\n') count++; @@ -1133,7 +1132,7 @@ int wxMacTextControl::GetLineLength(long lineNo) const { // TODO change this if possible to reflect real lines wxString content = GetStringValue() ; - + // Find line first int count = 0; for (size_t i = 0; i < content.Length() ; i++) @@ -1147,7 +1146,7 @@ int wxMacTextControl::GetLineLength(long lineNo) const count++; if (content[j] == '\n') return count; } - + return count; } if (content[i] == '\n') count++; @@ -1168,7 +1167,7 @@ wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxWindow *wxPeer, { m_font = wxPeer->GetFont() ; m_windowStyle = style ; - Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; + Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; wxMacConvertNewlines10To13( &st ) ; wxMacCFStringHolder cf(st , m_font.GetEncoding()) ; @@ -1176,7 +1175,7 @@ wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxWindow *wxPeer, Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ; m_valueTag = isPassword ? kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag ; CreateEditUnicodeTextControl( MAC_WXHWND(wxPeer->MacGetTopLevelWindowRef()), &bounds , cfr , isPassword , NULL , &m_controlRef ) ; - + if ( !(m_windowStyle & wxTE_MULTILINE) ) { SetData( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ; @@ -1187,7 +1186,7 @@ wxMacUnicodeTextControl::~wxMacUnicodeTextControl() { } -void wxMacUnicodeTextControl::VisibilityChanged(bool shown) +void wxMacUnicodeTextControl::VisibilityChanged(bool shown) { if ( !(m_windowStyle & wxTE_MULTILINE) && shown ) { @@ -1199,11 +1198,11 @@ void wxMacUnicodeTextControl::VisibilityChanged(bool shown) verify_noerr( GetData( 0, m_valueTag , &value ) ); verify_noerr( SetData( 0, m_valueTag, &value ) ); verify_noerr( SetData( 0, kControlEditTextSelectionTag, &sel ) ); - + CFRelease( value ) ; } } -wxString wxMacUnicodeTextControl::GetStringValue() const +wxString wxMacUnicodeTextControl::GetStringValue() const { wxString result ; CFStringRef value = GetData(0,m_valueTag) ; @@ -1219,7 +1218,7 @@ wxString wxMacUnicodeTextControl::GetStringValue() const #endif return result ; } -void wxMacUnicodeTextControl::SetStringValue( const wxString &str) +void wxMacUnicodeTextControl::SetStringValue( const wxString &str) { wxString st = str ; wxMacConvertNewlines10To13( &st ) ; @@ -1242,11 +1241,11 @@ bool wxMacUnicodeTextControl::CanPaste() const { return true ; } -void wxMacUnicodeTextControl::SetEditable(bool editable) +void wxMacUnicodeTextControl::SetEditable(bool editable) { SetData( 0 , kControlEditTextLockedTag , (Boolean) !editable ) ; } -void wxMacUnicodeTextControl::Remove( long from , long to ) +void wxMacUnicodeTextControl::Remove( long from , long to ) { } @@ -1258,7 +1257,7 @@ void wxMacUnicodeTextControl::GetSelection( long* from, long* to) const if ( to ) *to = sel.selEnd ; } -void wxMacUnicodeTextControl::SetSelection( long from , long to ) +void wxMacUnicodeTextControl::SetSelection( long from , long to ) { ControlEditTextSelectionRec sel ; sel.selStart = from ; @@ -1291,12 +1290,12 @@ void wxMacUnicodeTextControl::WriteText(const wxString& str) // MLTE control implementation (common part) // ---------------------------------------------------------------------------- -#if TARGET_API_MAC_OSX == 0 +#if TARGET_API_MAC_OSX == 0 // declaration needed because of one line in the code... static void TPUpdateVisibility(ControlRef theControl) ; #endif -// if mlte is on read only , no changes at all are allowed, not even from +// if mlte is on read only , no changes at all are allowed, not even from // procedural API, in order to allow changes via API all the same we must undo // the readonly status while we are executing, this class helps to do so @@ -1314,7 +1313,7 @@ public : TXNSetTXNObjectControls( m_txn , false , 1 , tag , data ) ; } } - ~EditHelper() + ~EditHelper() { TXNControlTag tag[] = { kTXNIOPrivilegesTag } ; if ( m_data[0].uValue == kTXNReadOnly ) @@ -1327,7 +1326,7 @@ public : TXNControlData m_data[1] ; } ; -wxString wxMacMLTEControl::GetStringValue() const +wxString wxMacMLTEControl::GetStringValue() const { wxString result ; OSStatus err ; @@ -1347,10 +1346,9 @@ wxString wxMacMLTEControl::GetStringValue() const if ( actualSize > 0 ) { wxChar *ptr = NULL ; -#if SIZEOF_WCHAR_T == 2 - ptr = new wxChar[actualSize + 1 ] ; +#if SIZEOF_WCHAR_T == 2 + ptr = new wxChar[actualSize + 1 ] ; wxStrncpy( ptr , (wxChar*) *theText , actualSize ) ; - #else SetHandleSize( theText , ( actualSize + 1 ) * sizeof( UniChar ) ) ; HLock( theText ) ; @@ -1358,7 +1356,7 @@ wxString wxMacMLTEControl::GetStringValue() const wxMBConvUTF16BE converter ; size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ; ptr = new wxChar[noChars + 1] ; - + noChars = converter.MB2WC( ptr , (const char*)*theText , noChars ) ; ptr[noChars] = 0 ; HUnlock( theText ) ; @@ -1398,7 +1396,7 @@ wxString wxMacMLTEControl::GetStringValue() const return result ; } -void wxMacMLTEControl::SetStringValue( const wxString &str) +void wxMacMLTEControl::SetStringValue( const wxString &str) { wxString st = str ; @@ -1437,10 +1435,10 @@ TXNFrameOptions wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle ) } else frameOptions |= kTXNSingleLineOnlyMask ; - + if ( wxStyle & wxHSCROLL ) frameOptions |= kTXNWantHScrollBarMask ; - + return frameOptions ; } @@ -1453,15 +1451,14 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo iControlTags[2] = kTXNVisibilityTag ; iControlData[2].uValue = visible ; toptag++ ; -#endif - +#endif + if ( m_windowStyle & wxTE_MULTILINE ) { if (m_windowStyle & wxTE_DONTWRAP) iControlData[1].uValue = kTXNNoAutoWrap ; else iControlData[1].uValue = kTXNAutoWrap ; - } verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData )) ; @@ -1497,7 +1494,7 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo TXNSetBackground( m_txn , &tback); } -void wxMacMLTEControl::SetBackground( const wxBrush &brush ) +void wxMacMLTEControl::SetBackground( const wxBrush &brush ) { // currently only solid background are supported TXNBackground tback; @@ -1508,7 +1505,7 @@ void wxMacMLTEControl::SetBackground( const wxBrush &brush ) void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to) { - TXNTypeAttributes typeAttr[4] ; + TXNTypeAttributes typeAttr[4] ; Str255 fontName = "\pMonaco" ; SInt16 fontSize = 12 ; Style fontStyle = normal ; @@ -1551,32 +1548,32 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo } } -void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) +void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) { EditHelper help(m_txn) ; TXNSetAttribute( wxTextAttr(foreground,wxNullColour,font) , kTXNStartOffset,kTXNEndOffset ) ; } -void wxMacMLTEControl::SetStyle(long start, long end, const wxTextAttr& style) -{ +void wxMacMLTEControl::SetStyle(long start, long end, const wxTextAttr& style) +{ EditHelper help(m_txn) ; TXNSetAttribute( style , start,end ) ; -} - -void wxMacMLTEControl::Copy() +} + +void wxMacMLTEControl::Copy() { ClearCurrentScrap(); TXNCopy(m_txn); TXNConvertToPublicScrap(); } -void wxMacMLTEControl::Cut() +void wxMacMLTEControl::Cut() { ClearCurrentScrap(); TXNCut(m_txn); TXNConvertToPublicScrap(); } -void wxMacMLTEControl::Paste() +void wxMacMLTEControl::Paste() { TXNConvertFromPublicScrap(); TXNPaste(m_txn); @@ -1587,16 +1584,16 @@ bool wxMacMLTEControl::CanPaste() const return TXNIsScrapPastable() ; } -void wxMacMLTEControl::SetEditable(bool editable) +void wxMacMLTEControl::SetEditable(bool editable) { TXNControlTag tag[] = { kTXNIOPrivilegesTag } ; TXNControlData data[] = { { editable ? kTXNReadWrite : kTXNReadOnly } } ; TXNSetTXNObjectControls( m_txn , false , sizeof(tag) / sizeof (TXNControlTag) , tag , data ) ; } -long wxMacMLTEControl::GetLastPosition() const +wxTextPos wxMacMLTEControl::GetLastPosition() const { - long actualsize = 0 ; + wxTextPos actualsize = 0 ; Handle theText ; OSErr err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); @@ -1614,7 +1611,7 @@ long wxMacMLTEControl::GetLastPosition() const return actualsize ; } -void wxMacMLTEControl::Replace( long from , long to , const wxString str ) +void wxMacMLTEControl::Replace( long from , long to , const wxString str ) { wxString value = str ; wxMacConvertNewlines10To13( &value ) ; @@ -1639,17 +1636,17 @@ void wxMacMLTEControl::GetSelection( long* from, long* to) const TXNGetSelection( m_txn , (TXNOffset*) from , (TXNOffset*) to ) ; } -void wxMacMLTEControl::SetSelection( long from , long to ) +void wxMacMLTEControl::SetSelection( long from , long to ) { /* change the selection */ if ((from == -1) && (to == -1)) - TXNSelectAll(m_txn); + TXNSelectAll(m_txn); else - TXNSetSelection( m_txn, from, to); + TXNSetSelection( m_txn, from, to); TXNShowSelection( m_txn, kTXNShowStart); } -void wxMacMLTEControl::WriteText(const wxString& str) +void wxMacMLTEControl::WriteText(const wxString& str) { EditHelper helper( m_txn ) ; wxString st = str ; @@ -1662,34 +1659,34 @@ void wxMacMLTEControl::WriteText(const wxString& str) // TODO SetStyle( start , end , GetDefaultStyle() ) ; } -void wxMacMLTEControl::Clear() +void wxMacMLTEControl::Clear() { EditHelper st(m_txn) ; TXNSetSelection( m_txn , kTXNStartOffset , kTXNEndOffset ) ; TXNClear(m_txn); } -bool wxMacMLTEControl::CanUndo() const +bool wxMacMLTEControl::CanUndo() const { return TXNCanUndo( m_txn , NULL ) ; } -void wxMacMLTEControl::Undo() +void wxMacMLTEControl::Undo() { - TXNUndo( m_txn ) ; -} + TXNUndo( m_txn ) ; +} bool wxMacMLTEControl::CanRedo() const { return TXNCanRedo( m_txn , NULL ) ; -} +} -void wxMacMLTEControl::Redo() -{ +void wxMacMLTEControl::Redo() +{ TXNRedo( m_txn ) ; } -int wxMacMLTEControl::GetNumberOfLines() const +int wxMacMLTEControl::GetNumberOfLines() const { ItemCount lines = 0 ; TXNGetLineCount(m_txn, &lines ) ; @@ -1699,14 +1696,14 @@ int wxMacMLTEControl::GetNumberOfLines() const long wxMacMLTEControl::XYToPosition(long x, long y) const { Point curpt ; - - long lastpos = GetLastPosition() ; - - // TODO find a better implementation : while we can get the + + wxTextPos lastpos = GetLastPosition() ; + + // TODO find a better implementation : while we can get the // line metrics of a certain line, we don't get its starting // position, so it would probably be rather a binary search // for the start position - long xpos = 0 ; + long xpos = 0 ; long ypos = 0 ; int lastHeight = 0 ; @@ -1715,7 +1712,7 @@ long wxMacMLTEControl::XYToPosition(long x, long y) const { if ( y == ypos && x == xpos ) return n ; - + TXNOffsetToPoint( m_txn , n , &curpt); if ( curpt.v > lastHeight ) @@ -1734,19 +1731,19 @@ long wxMacMLTEControl::XYToPosition(long x, long y) const bool wxMacMLTEControl::PositionToXY(long pos, long *x, long *y) const { Point curpt ; - - long lastpos = GetLastPosition() ; - + + wxTextPos lastpos = GetLastPosition() ; + if ( y ) *y = 0 ; if ( x ) *x = 0 ; - + if ( pos <= lastpos ) { - // TODO find a better implementation : while we can get the + // TODO find a better implementation : while we can get the // line metrics of a certain line, we don't get its starting // position, so it would probably be rather a binary search // for the start position - long xpos = 0 ; + long xpos = 0 ; long ypos = 0 ; int lastHeight = 0 ; @@ -1769,10 +1766,10 @@ bool wxMacMLTEControl::PositionToXY(long pos, long *x, long *y) const if ( x ) *x = xpos ; } - return FALSE ; + return false ; } -void wxMacMLTEControl::ShowPosition( long pos ) +void wxMacMLTEControl::ShowPosition( long pos ) { #if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER) { @@ -1789,7 +1786,7 @@ void wxMacMLTEControl::ShowPosition( long pos ) SInt32 dv = desired.v - current.v ; SInt32 dh = desired.h - current.h ; TXNShowSelection( m_txn , true ) ; - theErr = TXNScroll( m_txn, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh ); + theErr = TXNScroll( m_txn, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh ); wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") ); } } @@ -1800,23 +1797,23 @@ void wxMacMLTEControl::SetTXNData( const wxString& st , TXNOffset start , TXNOff { #if wxUSE_UNICODE #if SIZEOF_WCHAR_T == 2 - size_t len = st.Len() ; + size_t len = st.Len() ; TXNSetData( m_txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end); #else - wxMBConvUTF16BE converter ; - ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ; - UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; - converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ; + wxMBConvUTF16BE converter ; + ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ; + UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; + converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ; TXNSetData( m_txn , kTXNUnicodeTextData, (void*)unibuf, byteBufferLen , start, end); - free( unibuf ) ; + free( unibuf ) ; #endif #else - wxCharBuffer text = st.mb_str(wxConvLocal) ; + wxCharBuffer text = st.mb_str(wxConvLocal) ; TXNSetData( m_txn , kTXNTextData, (void*)text.data(), strlen( text ) , start, end); -#endif +#endif } @@ -1827,15 +1824,15 @@ wxString wxMacMLTEControl::GetLineText(long lineNo) const if ( lineNo < GetNumberOfLines() ) { long ypos = 0 ; - - Fixed lineWidth, + + Fixed lineWidth, lineHeight, currentHeight = 0; - + // get the first possible position in the control Point firstPoint; TXNOffsetToPoint(m_txn, 0, &firstPoint); - + // Iterate through the lines until we reach the one we want, // adding to our current y pixel point position while (ypos < lineNo) @@ -1843,11 +1840,11 @@ wxString wxMacMLTEControl::GetLineText(long lineNo) const TXNGetLineMetrics(m_txn, ypos++, &lineWidth, &lineHeight); currentHeight += lineHeight; } - + Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) }; TXNOffset theOffset; TXNPointToOffset(m_txn, thePoint, &theOffset); - + wxString content = GetStringValue() ; Point currentPoint = thePoint; while(thePoint.v == currentPoint.v && theOffset < content.length()) @@ -1866,15 +1863,15 @@ int wxMacMLTEControl::GetLineLength(long lineNo) const if ( lineNo < GetNumberOfLines() ) { long ypos = 0 ; - - Fixed lineWidth, + + Fixed lineWidth, lineHeight, currentHeight = 0; - + // get the first possible position in the control Point firstPoint; TXNOffsetToPoint(m_txn, 0, &firstPoint); - + // Iterate through the lines until we reach the one we want, // adding to our current y pixel point position while (ypos < lineNo) @@ -1882,11 +1879,11 @@ int wxMacMLTEControl::GetLineLength(long lineNo) const TXNGetLineMetrics(m_txn, ypos++, &lineWidth, &lineHeight); currentHeight += lineHeight; } - + Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) }; TXNOffset theOffset; TXNPointToOffset(m_txn, thePoint, &theOffset); - + wxString content = GetStringValue() ; Point currentPoint = thePoint; while(thePoint.v == currentPoint.v && theOffset < content.length()) @@ -1945,7 +1942,7 @@ public : Boolean fInFocus; /* true while the focus rect is drawn around the control */ Boolean fIsActive; /* true while the control is drawn in the active state */ Boolean fTXNObjectActive; /* reflects the activation state of the text edit record */ - Boolean fFocusDrawState; /* true if focus is drawn (default: true) */ + Boolean fFocusDrawState; /* true if focus is drawn (default: true) */ /* calculated locations */ Rect fRBounds; /* control bounds */ Rect fRTextArea; /* area where the text is drawn */ @@ -1972,7 +1969,7 @@ ControlUserPaneActivateUPP gTPActivateProc = NULL; ControlUserPaneFocusUPP gTPFocusProc = NULL; // one place for calculating all -static void TPCalculateBounds(STPTextPaneVars *varsp, const Rect& bounds) +static void TPCalculateBounds(STPTextPaneVars *varsp, const Rect& bounds) { SetRect(&varsp->fRBounds, bounds.left, bounds.top, bounds.right, bounds.bottom); SetRect(&varsp->fRFocusOutline, bounds.left, bounds.top, bounds.right, bounds.bottom); @@ -1980,7 +1977,7 @@ static void TPCalculateBounds(STPTextPaneVars *varsp, const Rect& bounds) SetRect(&varsp->fRTextOutline, bounds.left, bounds.top, bounds.right, bounds.bottom); if ( !varsp->fNoBorders ) { - SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) , + SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) , bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2)); } else @@ -1997,32 +1994,31 @@ OSStatus MLTESetObjectVisibility( STPTextPaneVars *varsp, Boolean vis , long wxS if ( textctrl ) { #if TARGET_API_MAC_OSX - TXNControlTag iControlTags[1] = { kTXNVisibilityTag }; - TXNControlData iControlData[1] = {{ vis }}; - err = ::TXNSetTXNObjectControls( varsp->fTXNRec, false, 1, iControlTags, iControlData ); + TXNControlTag iControlTags[1] = { kTXNVisibilityTag }; + TXNControlData iControlData[1] = {{ vis }}; + err = ::TXNSetTXNObjectControls( varsp->fTXNRec, false, 1, iControlTags, iControlData ); #endif Rect bounds ; UMAGetControlBoundsInWindowCoords( varsp->fUserPaneRec, &bounds); TPCalculateBounds( varsp , bounds ) ; - if ( vis ) - { - wxMacWindowClipper cl(textctrl) ; - TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left, - varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame); - TXNShowSelection( varsp->fTXNRec, kTXNShowStart); - } - else - { + if ( vis ) + { + wxMacWindowClipper cl(textctrl) ; + TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left, + varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame); + TXNShowSelection( varsp->fTXNRec, kTXNShowStart); + } + else + { #if TARGET_API_MAC_OSX - // in 10.2 the scrollbars are still actively redrawn when using only the code above - if ( UMAGetSystemVersion() < 0x1030 ) - { - TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 20000 , varsp->fRTextArea.left + 20000 , - varsp->fRTextArea.bottom + 20000 , varsp->fRTextArea.right + 20000 , varsp->fTXNFrame); - - } + // in 10.2 the scrollbars are still actively redrawn when using only the code above + if ( UMAGetSystemVersion() < 0x1030 ) + { + TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 20000 , varsp->fRTextArea.left + 20000 , + varsp->fRTextArea.bottom + 20000 , varsp->fRTextArea.right + 20000 , varsp->fTXNFrame); + } #endif - } + } } return err ; } @@ -2032,9 +2028,9 @@ static void TPUpdateVisibility(ControlRef theControl) { wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(theControl); if ( textctrl == NULL ) return ; - + STPTextPaneVars *varsp = (STPTextPaneVars *) ((wxMacMLTEClassicControl*)textctrl->GetPeer())->m_macTXNvars ; - + Rect bounds ; UMAGetControlBoundsInWindowCoords(theControl, &bounds); if ( textctrl->MacIsReallyShown() != varsp->fVisible ) @@ -2062,9 +2058,8 @@ static void TPUpdateVisibility(ControlRef theControl) { // make correct activations static void TPActivatePaneText(STPTextPaneVars *varsp, Boolean setActive) { - wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(varsp->fUserPaneRec); - if (varsp->fTXNObjectActive != setActive && textctrl->MacIsReallyShown() ) + if (varsp->fTXNObjectActive != setActive && textctrl->MacIsReallyShown() ) { varsp->fTXNObjectActive = setActive; TXNActivate(varsp->fTXNRec, varsp->fTXNFrame, varsp->fTXNObjectActive); @@ -2075,19 +2070,18 @@ static void TPActivatePaneText(STPTextPaneVars *varsp, Boolean setActive) { // update focus outlines static void TPRedrawFocusOutline(STPTextPaneVars *varsp) { - /* state changed */ - if (varsp->fFocusDrawState != (varsp->fIsActive && varsp->fInFocus)) - { - varsp->fFocusDrawState = (varsp->fIsActive && varsp->fInFocus); - // DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState); - } + if (varsp->fFocusDrawState != (varsp->fIsActive && varsp->fInFocus)) + { + varsp->fFocusDrawState = (varsp->fIsActive && varsp->fInFocus); + // DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState); + } } // update TXN focus state static void TPFocusPaneText(STPTextPaneVars *varsp, Boolean setFocus) { wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(varsp->fUserPaneRec); - + if (varsp->fInFocus != setFocus && textctrl->MacIsReallyShown()) { varsp->fInFocus = setFocus; TXNFocus( varsp->fTXNRec, varsp->fInFocus); @@ -2097,22 +2091,21 @@ static void TPFocusPaneText(STPTextPaneVars *varsp, Boolean setFocus) { // draw the control static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart) { /* set up our globals */ - + wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(theControl); if ( textctrl == NULL ) return ; TPUpdateVisibility( theControl ) ; - + STPTextPaneVars *varsp = (STPTextPaneVars *) ((wxMacMLTEClassicControl*)textctrl->GetPeer())->m_macTXNvars ; if ( textctrl->MacIsReallyShown() ) { wxMacWindowClipper clipper( textctrl ) ; TXNDraw(varsp->fTXNRec, NULL); if ( !varsp->fNoBorders ) - DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); + DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); TPRedrawFocusOutline( varsp ) ; } - } @@ -2129,11 +2122,11 @@ static pascal ControlPartCode TPPaneHitTestProc(ControlRef theControl, Point whe return 0 ; TPUpdateVisibility( theControl ) ; STPTextPaneVars *varsp = (STPTextPaneVars *) ((wxMacMLTEClassicControl*)textctrl->GetPeer())->m_macTXNvars ; - if (textctrl->MacIsReallyShown() ) + if (textctrl->MacIsReallyShown() ) { if (PtInRect(where, &varsp->fRBounds)) result = kmUPTextPart; - else + else { // sometimes we get the coords also in control local coordinates, therefore test again if ( textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ) @@ -2145,7 +2138,7 @@ static pascal ControlPartCode TPPaneHitTestProc(ControlRef theControl, Point whe } if (PtInRect(where, &varsp->fRBounds)) result = kmUPTextPart; - else + else result = 0; } } @@ -2160,25 +2153,25 @@ static pascal ControlPartCode TPPaneHitTestProc(ControlRef theControl, Point whe over our control. This routine handles clicks in the text area and in the scroll bar. */ static pascal ControlPartCode TPPaneTrackingProc(ControlRef theControl, Point startPt, ControlActionUPP actionProc) { - + ControlPartCode partCodeResult; - /* make sure we have some variables... */ + /* make sure we have some variables... */ partCodeResult = 0; wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(theControl); if ( textctrl == NULL ) return 0; TPUpdateVisibility( theControl ) ; STPTextPaneVars *varsp = (STPTextPaneVars *) ((wxMacMLTEClassicControl*)textctrl->GetPeer())->m_macTXNvars ; - if (textctrl->MacIsReallyShown() ) - { - /* we don't do any of these functions unless we're in focus */ + if (textctrl->MacIsReallyShown() ) + { + /* we don't do any of these functions unless we're in focus */ if ( ! varsp->fInFocus) { WindowPtr owner; owner = GetControlOwner(theControl); ClearKeyboardFocus(owner); SetKeyboardFocus(owner, theControl, kUserClickedToFocusPart); } - /* find the location for the click */ + /* find the location for the click */ // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them if ( textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ) { @@ -2187,22 +2180,21 @@ static pascal ControlPartCode TPPaneTrackingProc(ControlRef theControl, Point st startPt.h += x ; startPt.v += y ; } - - switch (TPPaneHitTestProc(theControl, startPt)) + + switch (TPPaneHitTestProc(theControl, startPt)) { - - /* handle clicks in the text part */ + /* handle clicks in the text part */ case kmUPTextPart: - { - wxMacWindowClipper clipper( textctrl ) ; - - EventRecord rec ; - ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; - TXNClick( varsp->fTXNRec, &rec ); - - } + { + wxMacWindowClipper clipper( textctrl ) ; + + EventRecord rec ; + ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; + TXNClick( varsp->fTXNRec, &rec ); + + } break; - + } } return partCodeResult; @@ -2223,7 +2215,7 @@ static pascal void TPPaneIdleProc(ControlRef theControl) { if (varsp->fIsActive) { Rect bounds; Point mousep; - + wxMacWindowClipper clipper( textctrl ) ; GetMouse(&mousep); /* there's a 'focus thing' and an 'unfocused thing' */ @@ -2260,14 +2252,14 @@ at our control. Here, we direct the keydown event to the text edit record and redraw the scroll bar and text field as appropriate. */ static pascal ControlPartCode TPPaneKeyDownProc(ControlRef theControl, SInt16 keyCode, SInt16 charCode, SInt16 modifiers) { - + wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(theControl); if ( textctrl == NULL ) return 0; TPUpdateVisibility( theControl ) ; - + STPTextPaneVars *varsp = (STPTextPaneVars *) ((wxMacMLTEClassicControl*)textctrl->GetPeer())->m_macTXNvars ; - if (varsp->fInFocus) + if (varsp->fInFocus) { /* turn autoscrolling on and send the key event to text edit */ wxMacWindowClipper clipper( textctrl ) ; @@ -2288,13 +2280,13 @@ the control and it's text as necessary for the activation state. */ static pascal void TPPaneActivateProc(ControlRef theControl, Boolean activating) { /* set up locals */ wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(theControl); - + if ( textctrl == NULL ) return ; TPUpdateVisibility( theControl ) ; - + STPTextPaneVars *varsp = (STPTextPaneVars *) ((wxMacMLTEClassicControl*)textctrl->GetPeer())->m_macTXNvars ; - + varsp->fIsActive = activating; wxMacWindowClipper clipper( textctrl ) ; TPActivatePaneText(varsp, varsp->fIsActive && varsp->fInFocus); @@ -2302,7 +2294,7 @@ static pascal void TPPaneActivateProc(ControlRef theControl, Boolean activating) if ( textctrl->MacIsReallyShown() ) { if ( !varsp->fNoBorders ) - DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); + DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); TPRedrawFocusOutline( varsp ) ; } } @@ -2314,7 +2306,7 @@ according to the parameters and redraw the control as necessary. */ static pascal ControlPartCode TPPaneFocusProc(ControlRef theControl, ControlFocusPart action) { ControlPartCode focusResult; - + focusResult = kControlFocusNoPart; wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(theControl); if ( textctrl == NULL ) @@ -2328,10 +2320,10 @@ static pascal ControlPartCode TPPaneFocusProc(ControlRef theControl, ControlFocu be received. The constant kControlFocusNoPart will be received when our control is the current focus and the user clicks in another control. In your focus routine, you should respond to these codes as follows: - + kControlFocusNoPart - turn off focus and return kControlFocusNoPart. redraw the control and the focus rectangle as necessary. - + kControlFocusPrevPart or kControlFocusNextPart - toggle focus on or off depending on its current state. redraw the control and the focus rectangle as appropriate for the new focus state. If the focus state is 'off', return the constant @@ -2362,7 +2354,7 @@ static pascal ControlPartCode TPPaneFocusProc(ControlRef theControl, ControlFocu { wxMacWindowClipper c( textctrl ) ; if ( !varsp->fNoBorders ) - DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); + DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); TPRedrawFocusOutline( varsp ) ; } return focusResult; @@ -2371,11 +2363,11 @@ static pascal ControlPartCode TPPaneFocusProc(ControlRef theControl, ControlFocu wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxWindow *wxPeer, const wxString& str, const wxPoint& pos, - const wxSize& size, long style ) + const wxSize& size, long style ) { m_font = wxPeer->GetFont() ; m_windowStyle = style ; - Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; + Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; wxMacConvertNewlines10To13( &st ) ; @@ -2387,17 +2379,17 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxWindow *wxPeer, /* create the control */ verify_noerr( ::CreateUserPaneControl( MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()), &bounds, featurSet, &m_controlRef ) ); - + { // wxMacWindowClipper c(wxPeer) ; DoCreate(); } - + if ( wxPeer->MacIsReallyShown() ) MLTESetObjectVisibility( (STPTextPaneVars*) m_macTXNvars, true , style ) ; { - // wxMacWindowClipper clipper( wxPeer ) ; + // wxMacWindowClipper clipper( wxPeer ) ; TPUpdateVisibility( m_controlRef ) ; @@ -2405,8 +2397,8 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxWindow *wxPeer, TXNSetSelection( m_txn, 0, 0); TXNShowSelection( m_txn, kTXNShowStart); - } - + } + AdjustCreationAttributes( *wxWHITE , true ) ; } @@ -2417,14 +2409,14 @@ wxMacMLTEClassicControl::~wxMacMLTEClassicControl() free(m_macTXNvars); } -void wxMacMLTEClassicControl::VisibilityChanged(bool shown) +void wxMacMLTEClassicControl::VisibilityChanged(bool shown) { MLTESetObjectVisibility((STPTextPaneVars*) m_macTXNvars , shown , m_windowStyle ) ; if ( !shown ) InvalWindowRect( GetControlOwner( m_controlRef ) , &((STPTextPaneVars *)m_macTXNvars)->fRBounds ) ; } -bool wxMacMLTEClassicControl::NeedsFocusRect() const +bool wxMacMLTEClassicControl::NeedsFocusRect() const { return true; } @@ -2435,7 +2427,7 @@ OSStatus wxMacMLTEClassicControl::DoCreate() WindowRef theWindow; OSStatus err = noErr ; - + /* set up our globals */ if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc); if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc); @@ -2444,24 +2436,24 @@ OSStatus wxMacMLTEClassicControl::DoCreate() if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc); if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc); if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc); - + /* allocate our private storage */ m_macTXNvars = (STPTextPaneVars *) malloc(sizeof(STPTextPaneVars)); - + /* set the initial settings for our private data */ m_macTXNvars->fMultiline = m_windowStyle & wxTE_MULTILINE ; m_macTXNvars->fNoBorders = m_windowStyle & wxNO_BORDER ; m_macTXNvars->fInFocus = false; m_macTXNvars->fIsActive = true; - m_macTXNvars->fTXNObjectActive = false; + m_macTXNvars->fTXNObjectActive = false; m_macTXNvars->fFocusDrawState = false ; m_macTXNvars->fUserPaneRec = m_controlRef ; m_macTXNvars->fVisible = true ; - + theWindow = m_macTXNvars->fOwner = GetControlOwner(m_controlRef); - + m_macTXNvars->fDrawingEnvironment = (GrafPtr) GetWindowPort(theWindow); - + /* set up the user pane procedures */ SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(gTPDrawProc), &gTPDrawProc); SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(gTPHitProc), &gTPHitProc); @@ -2470,19 +2462,19 @@ OSStatus wxMacMLTEClassicControl::DoCreate() SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneKeyDownProcTag, sizeof(gTPKeyProc), &gTPKeyProc); SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneActivateProcTag, sizeof(gTPActivateProc), &gTPActivateProc); SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc); - + /* calculate the rectangles used by the control */ UMAGetControlBoundsInWindowCoords(m_controlRef, &bounds); m_macTXNvars->fRTextOutlineRegion = NewRgn() ; TPCalculateBounds( m_macTXNvars , bounds ) ; - + /* set up the drawing environment */ SetPort(m_macTXNvars->fDrawingEnvironment); - + /* create the new edit field */ - + TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( m_windowStyle ) ; - + verify_noerr(TXNNewObject(NULL, m_macTXNvars->fOwner, &m_macTXNvars->fRTextArea, frameOptions , kTXNTextEditStyleFrameType, @@ -2490,7 +2482,7 @@ OSStatus wxMacMLTEClassicControl::DoCreate() kTXNSystemDefaultEncoding, &m_macTXNvars->fTXNRec, &m_macTXNvars->fTXNFrame, (TXNObjectRefcon) m_macTXNvars)); m_txn = m_macTXNvars->fTXNRec ; - + /* perform final activations and setup for our text field. Here, we assume that the window is going to be the 'active' window. */ TPActivatePaneText(m_macTXNvars, m_macTXNvars->fIsActive && m_macTXNvars->fInFocus); @@ -2509,27 +2501,27 @@ OSStatus wxMacMLTEClassicControl::DoCreate() wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxWindow *wxPeer, const wxString& str, const wxPoint& pos, - const wxSize& size, long style ) + const wxSize& size, long style ) { m_font = wxPeer->GetFont() ; m_windowStyle = style ; - Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; + Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; wxMacConvertNewlines10To13( &st ) ; - + HIRect hr = { bounds.left , bounds.top , bounds.right - bounds.left , bounds.bottom- bounds.top } ; m_scrollView = NULL ; TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ; if ( frameOptions & (kTXNWantVScrollBarMask|kTXNWantHScrollBarMask) ) { - HIScrollViewCreate(( frameOptions & kTXNWantHScrollBarMask ? kHIScrollViewOptionsHorizScroll : 0) | + HIScrollViewCreate(( frameOptions & kTXNWantHScrollBarMask ? kHIScrollViewOptionsHorizScroll : 0) | ( frameOptions & kTXNWantVScrollBarMask ? kHIScrollViewOptionsVertScroll: 0 ) , &m_scrollView ) ; - - HIViewSetFrame( m_scrollView, &hr ); - HIViewSetVisible( m_scrollView, true ); + + HIViewSetFrame( m_scrollView, &hr ); + HIViewSetVisible( m_scrollView, true ); } - + m_textView = NULL ; HITextViewCreate( NULL , 0, frameOptions , &m_textView ) ; m_txn = HITextViewGetTXNObject( m_textView) ; @@ -2542,11 +2534,10 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxWindow *wxPeer, } else { - HIViewSetFrame( m_textView, &hr ); + HIViewSetFrame( m_textView, &hr ); m_controlRef = m_textView ; } - - + SetTXNData( st , kTXNStartOffset, kTXNEndOffset ) ; TXNSetSelection( m_txn, 0, 0); @@ -2555,20 +2546,20 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxWindow *wxPeer, AdjustCreationAttributes( *wxWHITE , true ) ; } -OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart ) +OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart ) { - return SetKeyboardFocus( GetControlOwner( m_textView ) , + return SetKeyboardFocus( GetControlOwner( m_textView ) , m_textView , focusPart ) ; } -bool wxMacMLTEHIViewControl::HasFocus() const +bool wxMacMLTEHIViewControl::HasFocus() const { ControlRef control ; GetKeyboardFocus( GetUserFocusWindow() , &control ) ; return control == m_textView ; } -bool wxMacMLTEHIViewControl::NeedsFocusRect() const +bool wxMacMLTEHIViewControl::NeedsFocusRect() const { return m_windowStyle & wxNO_BORDER ? false : true; } diff --git a/src/mac/classic/combobox.cpp b/src/mac/classic/combobox.cpp index 061a8b165b..4991d4587c 100644 --- a/src/mac/classic/combobox.cpp +++ b/src/mac/classic/combobox.cpp @@ -223,17 +223,17 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) { bool wxComboBox::Enable(bool enable) { if ( !wxControl::Enable(enable) ) - return FALSE; + return false; - return TRUE; + return true; } bool wxComboBox::Show(bool show) { if ( !wxControl::Show(show) ) - return FALSE; + return false; - return TRUE; + return true; } void wxComboBox::SetFocus() @@ -284,7 +284,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style , wxDefaultValidator, name) ) { - return FALSE; + return false; } m_choice = new wxComboBoxChoice(this, style ); @@ -309,7 +309,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, m_choice->DoAppend( choices[ i ] ); } - return TRUE; + return true; } wxString wxComboBox::GetValue() const @@ -400,7 +400,7 @@ long wxComboBox::GetInsertionPoint() const return 0; } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { // TODO return 0; @@ -517,10 +517,10 @@ bool wxComboBox::SetStringSelection(const wxString& sel) if (s > -1) { SetSelection (s); - return TRUE; + return true; } else - return FALSE; + return false; } void wxComboBox::SetString(int n, const wxString& s) @@ -530,8 +530,7 @@ void wxComboBox::SetString(int n, const wxString& s) bool wxComboBox::IsEditable() const { - - return m_text != NULL && !HasFlag(wxCB_READONLY); + return m_text != NULL && !HasFlag(wxCB_READONLY); } void wxComboBox::Undo() diff --git a/src/mac/classic/textctrl.cpp b/src/mac/classic/textctrl.cpp index 93123e9740..5713099316 100644 --- a/src/mac/classic/textctrl.cpp +++ b/src/mac/classic/textctrl.cpp @@ -225,7 +225,7 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart else TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 30000 , varsp->fRTextArea.left + 30000 , varsp->fRTextArea.bottom + 30000 , varsp->fRTextArea.right + 30000 , varsp->fTXNFrame); - + } if ( IsControlVisible( theControl ) ) @@ -238,7 +238,7 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart /* restore the drawing environment */ /* draw the text frame and focus frame (if necessary) */ DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); - if ((**tpvars).fIsActive && varsp->fInFocus) + if ((**tpvars).fIsActive && varsp->fInFocus) DrawThemeFocusRect(&varsp->fRFocusOutline, true); /* release our globals */ HSetState((Handle) tpvars, state); @@ -420,7 +420,7 @@ static pascal void TPPaneActivateProc(ControlHandle theControl, Boolean activati if ( IsControlVisible( theControl ) ) { DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); - if (varsp->fInFocus) + if (varsp->fInFocus) DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive); } HSetState((Handle) tpvars, state); @@ -483,8 +483,8 @@ static pascal ControlPartCode TPPaneFocusProc(ControlHandle theControl, ControlF if ( IsControlVisible( theControl ) ) { /* save the drawing state */ - SetPort((**tpvars).fDrawingEnvironment); - wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ; + SetPort((**tpvars).fDrawingEnvironment); + wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ; DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive); DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive && varsp->fInFocus); } @@ -661,23 +661,23 @@ static void SetTXNData( TXNObject txn , const wxString& st , TXNOffset start , T { #if wxUSE_UNICODE #if SIZEOF_WCHAR_T == 2 - size_t len = st.Len() ; + size_t len = st.Len() ; TXNSetData( txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end); #else - wxMBConvUTF16BE converter ; - ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ; - UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; - converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ; + wxMBConvUTF16BE converter ; + ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ; + UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; + converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ; TXNSetData( txn , kTXNUnicodeTextData, (void*)unibuf, byteBufferLen , start, end); - free( unibuf ) ; + free( unibuf ) ; #endif #else - wxCharBuffer text = st.mb_str(wxConvLocal) ; + wxCharBuffer text = st.mb_str(wxConvLocal) ; TXNSetData( txn , kTXNTextData, (void*)text.data(), strlen( text ) , start, end); -#endif +#endif } // Text item @@ -728,7 +728,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, // base initialization if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) - return FALSE; + return false; wxSize mySize = size ; if ( m_macUsesTXN ) @@ -767,7 +767,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( m_windowStyle & wxTE_READONLY) { - m_editable = FALSE ; + m_editable = false ; } wxString st = str ; @@ -796,7 +796,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( !m_macUsesTXN ) { - wxCharBuffer text = st.mb_str(wxConvLocal) ; + wxCharBuffer text = st.mb_str(wxConvLocal) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; } else @@ -813,7 +813,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } - return TRUE; + return true; } wxString wxTextCtrl::GetValue() const @@ -826,12 +826,12 @@ wxString wxTextCtrl::GetValue() const err = ::GetControlDataSize((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; - if ( err ) - return wxEmptyString ; + if ( err ) + return wxEmptyString ; - if ( actualSize > 0 ) - { - wxCharBuffer buf(actualSize) ; + if ( actualSize > 0 ) + { + wxCharBuffer buf(actualSize) ; ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, actualSize , buf.data() , &actualSize ) ; @@ -854,13 +854,13 @@ wxString wxTextCtrl::GetValue() const if ( actualSize > 0 ) { wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ; -#if SIZEOF_WCHAR_T == 2 +#if SIZEOF_WCHAR_T == 2 wxStrncpy( ptr , (wxChar*) *theText , actualSize ) ; #else - wxMBConvUTF16BE converter ; - HLock( theText ) ; - converter.MB2WC( ptr , (const char*)*theText , actualSize ) ; - HUnlock( theText ) ; + wxMBConvUTF16BE converter ; + HLock( theText ) ; + converter.MB2WC( ptr , (const char*)*theText , actualSize ) ; + HUnlock( theText ) ; #endif ptr[actualSize] = 0 ; result.UngetWriteBuf( actualSize *sizeof(wxChar) ) ; @@ -911,7 +911,7 @@ void wxTextCtrl::SetValue(const wxString& str) wxMacConvertNewlines13To10( &st ) ; if ( !m_macUsesTXN ) { - wxCharBuffer text = st.mb_str(wxConvLocal) ; + wxCharBuffer text = st.mb_str(wxConvLocal) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ; } else @@ -990,14 +990,14 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) if ( !formerEditable ) SetEditable(formerEditable) ; } - return TRUE ; + return true ; } bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style) { wxTextCtrlBase::SetDefaultStyle( style ) ; SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ; - return TRUE ; + return true ; } // Clipboard operations @@ -1089,7 +1089,7 @@ bool wxTextCtrl::CanCut() const bool wxTextCtrl::CanPaste() const { if (!IsEditable()) - return FALSE; + return false; #if TARGET_CARBON OSStatus err = noErr; @@ -1105,20 +1105,20 @@ bool wxTextCtrl::CanPaste() const { if (( err = GetScrapFlavorSize( scrapRef, 'TEXT', &byteCount )) == noErr) { - return TRUE ; + return true ; } } } - return FALSE; + return false; #else long offset ; if ( GetScrap( NULL , 'TEXT' , &offset ) > 0 ) { - return TRUE ; + return true ; } #endif - return FALSE ; + return false ; } void wxTextCtrl::SetEditable(bool editable) @@ -1149,7 +1149,7 @@ void wxTextCtrl::SetInsertionPoint(long pos) void wxTextCtrl::SetInsertionPointEnd() { - long pos = GetLastPosition(); + wxTextPos pos = GetLastPosition(); SetInsertionPoint(pos); } @@ -1160,7 +1160,7 @@ long wxTextCtrl::GetInsertionPoint() const return begin ; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { if ( !m_macUsesTXN ) { @@ -1245,14 +1245,14 @@ void wxTextCtrl::SetSelection(long from, long to) ControlEditTextSelectionRec selection ; if ((from == -1) && (to == -1)) { - selection.selStart = 0 ; - selection.selEnd = 32767 ; - } + selection.selStart = 0 ; + selection.selEnd = 32767 ; + } else { - selection.selStart = from ; - selection.selEnd = to ; - } + selection.selStart = from ; + selection.selEnd = to ; + } TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; @@ -1267,9 +1267,9 @@ void wxTextCtrl::SetSelection(long from, long to) SetPort((**tpvars).fDrawingEnvironment); /* change the selection */ if ((from == -1) && (to == -1)) - TXNSelectAll((TXNObject) m_macTXN); + TXNSelectAll((TXNObject) m_macTXN); else - TXNSetSelection( (**tpvars).fTXNRec, from, to); + TXNSetSelection( (**tpvars).fTXNRec, from, to); TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } } @@ -1278,10 +1278,10 @@ bool wxTextCtrl::LoadFile(const wxString& file) { if ( wxTextCtrlBase::LoadFile(file) ) { - return TRUE; + return true; } - return FALSE; + return false; } void wxTextCtrl::WriteText(const wxString& str) @@ -1290,7 +1290,7 @@ void wxTextCtrl::WriteText(const wxString& str) wxMacConvertNewlines13To10( &st ) ; if ( !m_macUsesTXN ) { - wxCharBuffer text = st.mb_str(wxConvLocal) ; + wxCharBuffer text = st.mb_str(wxConvLocal) ; TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ; } else @@ -1386,9 +1386,9 @@ void wxTextCtrl::Undo() { if (CanUndo()) { - if ( m_macUsesTXN ) + if ( m_macUsesTXN ) { - TXNUndo((TXNObject)m_macTXN); + TXNUndo((TXNObject)m_macTXN); } } } @@ -1397,37 +1397,37 @@ void wxTextCtrl::Redo() { if (CanRedo()) { - if ( m_macUsesTXN ) + if ( m_macUsesTXN ) { - TXNRedo((TXNObject)m_macTXN); + TXNRedo((TXNObject)m_macTXN); } } } bool wxTextCtrl::CanUndo() const { - if ( !IsEditable() ) + if ( !IsEditable() ) { - return false ; + return false ; } - if ( m_macUsesTXN ) + if ( m_macUsesTXN ) { - return TXNCanUndo((TXNObject)m_macTXN,NULL); + return TXNCanUndo((TXNObject)m_macTXN,NULL); } - return FALSE ; + return false ; } bool wxTextCtrl::CanRedo() const { - if ( !IsEditable() ) + if ( !IsEditable() ) { - return false ; + return false ; } - if ( m_macUsesTXN ) + if ( m_macUsesTXN ) { - return TXNCanRedo((TXNObject)m_macTXN,NULL); + return TXNCanRedo((TXNObject)m_macTXN,NULL); } - return FALSE ; + return false ; } // Makes modifie or unmodified @@ -1443,14 +1443,14 @@ void wxTextCtrl::DiscardEdits() int wxTextCtrl::GetNumberOfLines() const { - if ( m_macUsesTXN ) + if ( m_macUsesTXN ) { ItemCount lines ; TXNGetLineCount((TXNObject)m_macTXN, &lines ) ; return lines ; } else - { + { wxString content = GetValue() ; int count = 1; @@ -1470,13 +1470,13 @@ long wxTextCtrl::XYToPosition(long x, long y) const bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const { - return FALSE ; + return false ; } void wxTextCtrl::ShowPosition(long pos) { #if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER) - if ( m_macUsesTXN ) + if ( m_macUsesTXN ) { Point current ; Point desired ; @@ -1491,7 +1491,7 @@ void wxTextCtrl::ShowPosition(long pos) SInt32 dv = desired.v - current.v ; SInt32 dh = desired.h - current.h ; TXNShowSelection( (TXNObject) m_macTXN , true ) ; - theErr = TXNScroll( (TXNObject) m_macTXN, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh ); + theErr = TXNScroll( (TXNObject) m_macTXN, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh ); wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") ); } } @@ -1641,7 +1641,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // this will make wxWidgets eat the ENTER key so that // we actually prevent line wrapping in a single line // text control - eat_key = TRUE; + eat_key = true; } break; @@ -1672,7 +1672,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) #if TARGET_CARBON if ( m_macUsesTXN && wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ; - else + else { EventRecord rec ; if ( wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ) diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index 01ed1c3816..0b6a229487 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -53,7 +53,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) - return FALSE; + return false; m_noStrings = n; @@ -83,7 +83,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, SetValue(value); - ChangeFont(FALSE); + ChangeFont(false); XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, (XtPointer) this); @@ -94,7 +94,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, ChangeBackgroundColour(); - return TRUE; + return true; } bool wxComboBox::Create(wxWindow *parent, wxWindowID id, @@ -107,7 +107,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& name) { wxCArrayString chs(choices); - return Create(parent, id, value, pos, size, chs.GetCount(), + return Create(parent, id, value, pos, size, chs.GetCount(), chs.GetStrings(), style, validator, name); } @@ -141,11 +141,11 @@ wxString wxComboBox::GetValue() const void wxComboBox::SetValue(const wxString& value) { - m_inSetValue = TRUE; + m_inSetValue = true; if( !value.empty() ) XmComboBoxSetString( (Widget)m_mainWidget, wxConstCast(value.c_str(), char) ); - m_inSetValue = FALSE; + m_inSetValue = false; } void wxComboBox::SetString(int n, const wxString& s) @@ -281,9 +281,9 @@ long wxComboBox::GetInsertionPoint() const return (long) XmComboBoxGetInsertionPosition ((Widget) m_mainWidget); } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { - return (long) XmComboBoxGetLastPosition ((Widget) m_mainWidget); + return (wxTextPos) XmComboBoxGetLastPosition ((Widget) m_mainWidget); } void wxComboBox::Replace(long from, long to, const wxString& value) diff --git a/src/motif/combobox_native.cpp b/src/motif/combobox_native.cpp index a6aad9ebb0..d7f6e74751 100644 --- a/src/motif/combobox_native.cpp +++ b/src/motif/combobox_native.cpp @@ -92,7 +92,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, Widget buttonWidget= XtVaCreateManagedWidget(name.c_str(), xmComboBoxWidgetClass, parentWidget, - XmNcomboBoxType, cb_type, + XmNcomboBoxType, cb_type, NULL); m_mainWidget = (Widget) buttonWidget; @@ -136,7 +136,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& name) { wxCArrayString chs(choices); - return Create(parent, id, value, pos, size, chs.GetCount(), + return Create(parent, id, value, pos, size, chs.GetCount(), chs.GetStrings(), style, validator, name); } @@ -252,7 +252,7 @@ void wxComboBox::Clear() #else while(m_noStrings > 0) { - XmComboBoxDeletePos((Widget) m_mainWidget, m_noStrings--); + XmComboBoxDeletePos((Widget) m_mainWidget, m_noStrings--); } #endif @@ -333,7 +333,7 @@ long wxComboBox::GetInsertionPoint() const return (long)XmTextGetInsertionPosition( GetXmText(this) ); } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { XmTextPosition pos = XmTextGetLastPosition( GetXmText(this) ); return (long)pos; diff --git a/src/motif/textctrl.cpp b/src/motif/textctrl.cpp index 090da09f5a..b604bab9e4 100644 --- a/src/motif/textctrl.cpp +++ b/src/motif/textctrl.cpp @@ -97,8 +97,8 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallba wxTextCtrl::wxTextCtrl() { m_tempCallbackStruct = (void*) NULL; - m_modified = FALSE; - m_processedDefault = FALSE; + m_modified = false; + m_processedDefault = false; } bool wxTextCtrl::Create(wxWindow *parent, @@ -114,8 +114,8 @@ bool wxTextCtrl::Create(wxWindow *parent, return false; m_tempCallbackStruct = (void*) NULL; - m_modified = FALSE; - m_processedDefault = FALSE; + m_modified = false; + m_processedDefault = false; m_backgroundColour = *wxWHITE; @@ -181,7 +181,7 @@ bool wxTextCtrl::Create(wxWindow *parent, XmNvalue, wxConstCast(value.c_str(), char), NULL); } - + // install callbacks XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this); @@ -194,7 +194,7 @@ bool wxTextCtrl::Create(wxWindow *parent, XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this); // font - ChangeFont(FALSE); + ChangeFont(false); wxSize best = GetBestSize(); if( size.x != -1 ) best.x = size.x; @@ -205,7 +205,7 @@ bool wxTextCtrl::Create(wxWindow *parent, ChangeBackgroundColour(); - return TRUE; + return true; } WXWidget wxTextCtrl::GetTopWidget() const @@ -248,7 +248,7 @@ wxString wxTextCtrl::GetValue() const void wxTextCtrl::SetValue(const wxString& value) { - m_inSetValue = TRUE; + m_inSetValue = true; // do this instead... MB // @@ -262,7 +262,7 @@ void wxTextCtrl::SetValue(const wxString& value) Clear(); AppendText( value ); - m_inSetValue = FALSE; + m_inSetValue = false; } // Clipboard operations @@ -316,13 +316,13 @@ void wxTextCtrl::Redo() bool wxTextCtrl::CanUndo() const { // No Undo in Motif - return FALSE; + return false; } bool wxTextCtrl::CanRedo() const { // No Redo in Motif - return FALSE; + return false; } // If the return values from and to are the same, there is no @@ -354,7 +354,7 @@ void wxTextCtrl::SetInsertionPoint(long pos) void wxTextCtrl::SetInsertionPointEnd() { - long pos = GetLastPosition(); + wxTextPos pos = GetLastPosition(); SetInsertionPoint(pos); } @@ -363,7 +363,7 @@ long wxTextCtrl::GetInsertionPoint() const return (long) XmTextGetInsertionPosition ((Widget) m_mainWidget); } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { return (long) XmTextGetLastPosition ((Widget) m_mainWidget); } @@ -398,24 +398,24 @@ void wxTextCtrl::WriteText(const wxString& text) XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL); SetInsertionPoint(textPosition); XmTextShowPosition ((Widget) m_mainWidget, textPosition); - m_modified = TRUE; + m_modified = true; } void wxTextCtrl::AppendText(const wxString& text) { - long textPosition = GetLastPosition() + text.length(); + wxTextPos textPosition = GetLastPosition() + text.length(); XmTextInsert ((Widget) m_mainWidget, GetLastPosition(), wxConstCast(text.c_str(), char)); XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL); SetInsertionPoint(textPosition); XmTextShowPosition ((Widget) m_mainWidget, textPosition); - m_modified = TRUE; + m_modified = true; } void wxTextCtrl::Clear() { XmTextSetString ((Widget) m_mainWidget, ""); - m_modified = FALSE; + m_modified = false; } bool wxTextCtrl::IsModified() const @@ -426,12 +426,12 @@ bool wxTextCtrl::IsModified() const // Makes modified or unmodified void wxTextCtrl::MarkDirty() { - m_modified = TRUE; + m_modified = true; } void wxTextCtrl::DiscardEdits() { - m_modified = FALSE; + m_modified = false; } int wxTextCtrl::GetNumberOfLines() const @@ -442,7 +442,7 @@ int wxTextCtrl::GetNumberOfLines() const { long i = 0; int currentLine = 0; - bool finished = FALSE; + bool finished = false; while (!finished) { int ch = s[i]; @@ -453,7 +453,7 @@ int wxTextCtrl::GetNumberOfLines() const } else if (ch == 0) { - finished = TRUE; + finished = true; } else i++; @@ -488,7 +488,7 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const if ( y ) *y = yy; - return TRUE; + return true; } void wxTextCtrl::ShowPosition(long pos) @@ -551,7 +551,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // Indicates that we should generate a normal command, because // we're letting default behaviour happen (otherwise it's vetoed // by virtue of overriding OnChar) - m_processedDefault = TRUE; + m_processedDefault = true; if (m_tempCallbackStruct) { @@ -588,12 +588,12 @@ void wxTextCtrl::ChangeBackgroundColour() NULL); wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); if (hsb) - wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, true); if (vsb) - wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); + wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, true); // MBN: why change parent background? - // DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); + // DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, true); } } @@ -677,7 +677,7 @@ wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget, return wxSize( x + 2 * xmargin + 2 * highlight + 2 * shadow, // MBN: +2 necessary: Lesstif bug or mine? - y + 2 * ymargin + 2 * highlight + 2 * shadow + 2 ); + y + 2 * ymargin + 2 * highlight + 2 * shadow + 2 ); } wxSize wxTextCtrl::DoGetBestSize() const @@ -756,14 +756,14 @@ wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr) return; wxTextCtrl *tw = (wxTextCtrl *) clientData; - tw->SetModified(TRUE); + tw->SetModified(true); } static void wxTextWindowModifyProc (Widget WXUNUSED(w), XtPointer clientData, XmTextVerifyCallbackStruct *cbs) { wxTextCtrl *tw = (wxTextCtrl *) clientData; - tw->m_processedDefault = FALSE; + tw->m_processedDefault = false; // First, do some stuff if it's a password control: in this case, we need // to store the string inside the class because GetValue() can't retrieve diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 94ded90fd1..c8ccafc1a5 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -620,7 +620,7 @@ void wxComboBox::SetInsertionPointEnd() // setting insertion point doesn't make sense for read only comboboxes if ( !(GetWindowStyle() & wxCB_READONLY) ) { - long pos = GetLastPosition(); + wxTextPos pos = GetLastPosition(); SetInsertionPoint(pos); } } @@ -635,15 +635,15 @@ long wxComboBox::GetInsertionPoint() const #endif } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { HWND hEditWnd = (HWND) GetEditHWND(); // Get number of characters in the last (only) line. We'll add this to the character // index for the last line, 1st position. - int lineLength = (int)SendMessage(hEditWnd, EM_LINELENGTH, (WPARAM) 0, (LPARAM)0L); + wxTextPos lineLength = (wxTextPos)SendMessage(hEditWnd, EM_LINELENGTH, (WPARAM) 0, (LPARAM)0L); - return (long)(lineLength); + return lineLength; } void wxComboBox::Replace(long from, long to, const wxString& value) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 4a2c859fe7..9899b14348 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1141,7 +1141,7 @@ long wxTextCtrl::GetInsertionPoint() const return Pos & 0xFFFF; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { int numLines = GetNumberOfLines(); long posStartLastLine = XYToPosition(0, numLines - 1); @@ -2082,7 +2082,7 @@ void wxTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event)) // Default colors for MSW text control // // Set default background color to the native white instead of -// the default wxSYS_COLOUR_BTNFACE (is triggered with wxNullColour). +// the default wxSYS_COLOUR_BTNFACE (is triggered with wxNullColour). // ---------------------------------------------------------------------------- wxVisualAttributes wxTextCtrl::GetDefaultAttributes() const @@ -2466,7 +2466,7 @@ bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style) { // we have to do this or the style wouldn't apply for the text typed by // the user - long posLast = GetLastPosition(); + wxTextPos posLast = GetLastPosition(); SetStyle(posLast, posLast, m_defaultStyle); } @@ -2531,7 +2531,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) wxStrcpy(lf.lfFaceName, cf.szFaceName); //NOTE: we _MUST_ set each of these values to _something_ since we - //do not call wxZeroMemory on the LOGFONT lf + //do not call wxZeroMemory on the LOGFONT lf if (cf.dwEffects & CFE_ITALIC) lf.lfItalic = TRUE; else diff --git a/src/msw/wince/textctrlce.cpp b/src/msw/wince/textctrlce.cpp index 2732c41a99..ab94159c46 100644 --- a/src/msw/wince/textctrlce.cpp +++ b/src/msw/wince/textctrlce.cpp @@ -566,7 +566,7 @@ long wxTextCtrl::GetInsertionPoint() const return Pos & 0xFFFF; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { int numLines = GetNumberOfLines(); long posStartLastLine = XYToPosition(0, numLines - 1); diff --git a/src/os2/combobox.cpp b/src/os2/combobox.cpp index 3bc56e0c4d..2a3f669fe9 100644 --- a/src/os2/combobox.cpp +++ b/src/os2/combobox.cpp @@ -81,9 +81,9 @@ bool wxComboBox::OS2Command( } // // There is no return value for the CBN_ notifications, so always return - // FALSE from here to pass the message to DefWindowProc() + // false from here to pass the message to DefWindowProc() // - return FALSE; + return false; } // end of wxComboBox::OS2Command bool wxComboBox::Create( @@ -117,7 +117,7 @@ bool wxComboBox::Create( , const wxString& rsName ) { - m_isShown = FALSE; + m_isShown = false; if (!CreateControl( pParent ,vId @@ -127,7 +127,7 @@ bool wxComboBox::Create( ,rValidator ,rsName )) - return FALSE; + return false; // // Get the right style @@ -150,7 +150,7 @@ bool wxComboBox::Create( if (!OS2CreateControl( "COMBOBOX" ,lSstyle )) - return FALSE; + return false; // // A choice/combobox normally has a white background (or other, depending @@ -171,7 +171,7 @@ bool wxComboBox::Create( ,rSize.x ,rSize.y ); - if (!rsValue.IsEmpty()) + if (!rsValue.empty()) { SetValue(rsValue); } @@ -179,8 +179,8 @@ bool wxComboBox::Create( ,(PFNWP)wxComboEditWndProc ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (ULONG)this); - Show(TRUE); - return TRUE; + Show(true); + return true; } // end of wxComboBox::Create void wxComboBox::SetValue( @@ -237,7 +237,7 @@ void wxComboBox::SetInsertionPoint( void wxComboBox::SetInsertionPointEnd() { - long lPos = GetLastPosition(); + wxTextPos lPos = GetLastPosition(); SetInsertionPoint(lPos); } // end of wxComboBox::SetInsertionPointEnd @@ -254,7 +254,7 @@ long wxComboBox::GetInsertionPoint() const return lPos; } // end of wxComboBox::GetInsertionPoint -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { long lLineLength = 0L; WNDPARAMS vParams; @@ -381,7 +381,7 @@ bool wxComboBox::ProcessEditMsg( case KC_CHAR: return (HandleChar( wParam ,lParam - ,TRUE /* isASCII */ + ,true /* isASCII */ )); case KC_PREVDOWN: @@ -403,7 +403,7 @@ bool wxComboBox::ProcessEditMsg( return(HandleKillFocus((WXHWND)(HWND)wParam)); break; } - return FALSE; + return false; } // end of WinGuiBase_CComboBox::ProcessEditMsg MRESULT EXPENTRY wxComboEditWndProc( diff --git a/src/os2/textctrl.cpp b/src/os2/textctrl.cpp index a1edc95104..be45467059 100644 --- a/src/os2/textctrl.cpp +++ b/src/os2/textctrl.cpp @@ -112,7 +112,7 @@ bool wxTextCtrl::Create( ,rValidator ,rsName )) - return FALSE; + return false; wxPoint vPos = rPos; // The OS/2 position SWP vSwp; @@ -123,7 +123,7 @@ bool wxTextCtrl::Create( } m_windowStyle = lStyle; - m_bIsMLE = FALSE; + m_bIsMLE = false; long lSstyle = WS_VISIBLE | WS_TABSTOP; @@ -133,7 +133,7 @@ bool wxTextCtrl::Create( if ( m_windowStyle & wxTE_MULTILINE ) { lSstyle |= MLS_BORDER | MLS_WORDWRAP; - m_bIsMLE = TRUE; + m_bIsMLE = true; if ((m_windowStyle & wxTE_NO_VSCROLL) == 0) lSstyle |= MLS_VSCROLL; @@ -191,7 +191,7 @@ bool wxTextCtrl::Create( if (m_hWnd == 0) { - return FALSE; + return false; } SubclassWin(GetHWND()); @@ -205,7 +205,7 @@ bool wxTextCtrl::Create( ,wxNORMAL ); SetFont(*pTextFont); - if (!rsValue.IsEmpty()) + if (!rsValue.empty()) { SetValue(rsValue); } @@ -223,7 +223,7 @@ bool wxTextCtrl::Create( ,rSize.y ); delete pTextFont; - return TRUE; + return true; } // end of wxTextCtrl::Create // @@ -456,10 +456,10 @@ bool wxTextCtrl::CanCut() const bool wxTextCtrl::CanPaste() const { - bool bIsTextAvailable = FALSE; + bool bIsTextAvailable = false; if (!IsEditable()) - return FALSE; + return false; // // Check for straight text on clipboard @@ -502,7 +502,7 @@ void wxTextCtrl::SetInsertionPoint( void wxTextCtrl::SetInsertionPointEnd() { - long lPos = GetLastPosition(); + wxTextPos lPos = GetLastPosition(); // // We must not do anything if the caret is already there because calling @@ -530,7 +530,7 @@ long wxTextCtrl::GetInsertionPoint() const return (dwPos & 0xFFFF); } // end of wxTextCtrl::GetInsertionPoint -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { HWND hWnd = GetHwnd(); long lCharIndex; @@ -687,9 +687,9 @@ bool wxTextCtrl::LoadFile( // Update the size limit if needed // AdjustSpaceLimit(); - return TRUE; + return true; } - return FALSE; + return false; } // end of wxTextCtrl::LoadFile bool wxTextCtrl::IsModified() const @@ -773,7 +773,7 @@ bool wxTextCtrl::PositionToXY( if (nLineNo == -1) { // no such line - return FALSE; + return false; } // @@ -805,7 +805,7 @@ bool wxTextCtrl::PositionToXY( if (lCharIndex == -1) { - return FALSE; + return false; } // @@ -816,7 +816,7 @@ bool wxTextCtrl::PositionToXY( if (plY) *plY = nLineNo; - return TRUE; + return true; } // end of wxTextCtrl::PositionToXY void wxTextCtrl::ShowPosition( @@ -956,7 +956,7 @@ bool wxTextCtrl::CanUndo() const if (m_bIsMLE) bOk = (::WinSendMsg(GetHwnd(), MLM_QUERYUNDO, 0, 0) != 0); else - bOk = FALSE; // can't undo regular edit fields in PM + bOk = false; // can't undo regular edit fields in PM return bOk; } // end of wxTextCtrl::CanUndo @@ -967,7 +967,7 @@ bool wxTextCtrl::CanRedo() const if (m_bIsMLE) bOk = (::WinSendMsg(GetHwnd(), MLM_QUERYUNDO, 0, 0) != 0); else - bOk = FALSE; // can't undo regular edit fields in PM + bOk = false; // can't undo regular edit fields in PM return bOk; } // end of wxTextCtrl::CanRedo @@ -1065,7 +1065,7 @@ void wxTextCtrl::OnChar( wxNavigationKeyEvent vEventNav; vEventNav.SetDirection(!rEvent.ShiftDown()); - vEventNav.SetWindowChange(FALSE); + vEventNav.SetWindowChange(false); vEventNav.SetEventObject(this); if ( GetEventHandler()->ProcessEvent(vEventNav) ) @@ -1117,15 +1117,15 @@ bool wxTextCtrl::OS2Command( case EN_SCROLL: case EN_INSERTMODETOGGLE: case EN_MEMERROR: - return FALSE; + return false; default: - return FALSE; + return false; } // // Processed // - return TRUE; + return true; } // end of wxTextCtrl::OS2Command void wxTextCtrl::AdjustSpaceLimit() @@ -1148,7 +1148,7 @@ void wxTextCtrl::AdjustSpaceLimit() WNDPARAMS vParams; vParams.fsStatus = WPM_CBCTLDATA; - vParams.pCtlData = &Efd; + vParams.pCtlData = &Efd; vParams.cbCtlData = sizeof(ENTRYFDATA); if (::WinSendMsg( GetHwnd() @@ -1325,7 +1325,7 @@ bool wxTextCtrl::SetBackgroundColour( { if (m_bIsMLE) ::WinSendMsg(GetHwnd(), MLM_SETBACKCOLOR, (MPARAM)rColour.GetPixel(), MLE_INDEX); - return TRUE; + return true; } // end of wxTextCtrl::SetBackgroundColour bool wxTextCtrl::SetForegroundColour( @@ -1334,7 +1334,7 @@ bool wxTextCtrl::SetForegroundColour( { if (m_bIsMLE) ::WinSendMsg(GetHwnd(), MLM_SETTEXTCOLOR, (MPARAM)rColour.GetPixel(), MLE_INDEX); - return TRUE; + return true; } // end of wxTextCtrl::SetForegroundColour bool wxTextCtrl::SetStyle( @@ -1381,6 +1381,6 @@ bool wxTextCtrl::SetStyle( // // TODO:: finish this part // - return TRUE; + return true; } // end of wxTextCtrl::SetStyle diff --git a/src/palmos/combobox.cpp b/src/palmos/combobox.cpp index d75825c416..e73b5a0e22 100644 --- a/src/palmos/combobox.cpp +++ b/src/palmos/combobox.cpp @@ -244,7 +244,7 @@ long wxComboBox::GetInsertionPoint() const return 0; } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { return 0; } @@ -263,7 +263,7 @@ void wxComboBox::SetSelection(long from, long to) bool wxComboBox::IsEditable() const { - return false; + return false; } void wxComboBox::Undo() @@ -280,27 +280,27 @@ void wxComboBox::SelectAll() bool wxComboBox::CanCopy() const { - return false; + return false; } bool wxComboBox::CanCut() const { - return false; + return false; } bool wxComboBox::CanPaste() const { - return false; + return false; } bool wxComboBox::CanUndo() const { - return false; + return false; } bool wxComboBox::CanRedo() const { - return false; + return false; } diff --git a/src/palmos/textctrl.cpp b/src/palmos/textctrl.cpp index 147c1fd8a4..61a3e7eef6 100644 --- a/src/palmos/textctrl.cpp +++ b/src/palmos/textctrl.cpp @@ -378,7 +378,7 @@ long wxTextCtrl::GetInsertionPoint() const return 0; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { return 0; } diff --git a/src/univ/combobox.cpp b/src/univ/combobox.cpp index 20a06a61d4..1a544c825e 100644 --- a/src/univ/combobox.cpp +++ b/src/univ/combobox.cpp @@ -763,7 +763,7 @@ long wxComboBox::GetInsertionPoint() const return GetText()->GetInsertionPoint(); } -long wxComboBox::GetLastPosition() const +wxTextPos wxComboBox::GetLastPosition() const { return GetText()->GetLastPosition(); } @@ -892,7 +892,7 @@ wxClientData* wxComboBox::DoGetItemClientObject(int n) const bool wxComboBox::IsEditable() const { - return GetText() != NULL && (!HasFlag(wxCB_READONLY) || GetText()->IsEditable()); + return GetText() != NULL && (!HasFlag(wxCB_READONLY) || GetText()->IsEditable()); } void wxComboBox::Undo() diff --git a/src/univ/textctrl.cpp b/src/univ/textctrl.cpp index a49704f65f..8583562101 100644 --- a/src/univ/textctrl.cpp +++ b/src/univ/textctrl.cpp @@ -47,7 +47,7 @@ is true in which case a single LINE may correspond to multiple ROWs. A text position is an unsigned int (which for reasons of compatibility is - still a long) from 0 to GetLastPosition() inclusive. The positions + still a long as wxTextPos) from 0 to GetLastPosition() inclusive. The positions correspond to the gaps between the letters so the position 0 is just before the first character and the last position is the one beyond the last character. For an empty text control GetLastPosition() returns 0. @@ -197,7 +197,7 @@ static inline void OrderPositions(wxTextPos& from, wxTextPos& to) // the value which is never used for text position, even not -1 which is // sometimes used for some special meaning -static const wxTextPos INVALID_POS_VALUE = -2; +static const wxTextPos INVALID_POS_VALUE = wxInvalidTextCoord; // overlap between pages (when using PageUp/Dn) in lines static const size_t PAGE_OVERLAP_IN_LINES = 1; @@ -1670,7 +1670,7 @@ wxTextPos wxTextCtrl::XYToPosition(wxTextCoord x, wxTextCoord y) const // if they are out of range if ( IsSingleLine() ) { - return x > GetLastPosition() || y > 0 ? wxDefaultCoord : x; + return ( x > GetLastPosition() || y > 0 ) ? wxOutOfRangeTextCoord : x; } else // multiline { diff --git a/src/x11/textctrl.cpp b/src/x11/textctrl.cpp index 3b778c72a9..e1a366aa37 100644 --- a/src/x11/textctrl.cpp +++ b/src/x11/textctrl.cpp @@ -37,10 +37,10 @@ wxSourceUndoStep::wxSourceUndoStep( wxSourceUndo type, int y1, int y2, wxTextCtr m_y1 = y1; m_y2 = y2; m_owner = owner; - + m_cursorX = m_owner->GetCursorX(); m_cursorY = m_owner->GetCursorY(); - + if (m_type == wxSOURCE_UNDO_LINE) { m_text = m_owner->m_lines[m_y1].m_text; @@ -138,7 +138,7 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_MOUSE_EVENTS(wxTextCtrl::OnMouse) EVT_KILL_FOCUS(wxTextCtrl::OnKillFocus) EVT_SET_FOCUS(wxTextCtrl::OnSetFocus) - + EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy) EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste) @@ -154,34 +154,34 @@ END_EVENT_TABLE() void wxTextCtrl::Init() { - m_editable = TRUE; - m_modified = FALSE; - + m_editable = true; + m_modified = false; + m_lang = wxSOURCE_LANG_NONE; - - m_capturing = FALSE; - + + m_capturing = false; + m_cursorX = 0; m_cursorY = 0; - + m_longestLine = 0; - + m_bracketX = -1; m_bracketY = -1; - - m_overwrite = FALSE; - m_ignoreInput = FALSE; - + + m_overwrite = false; + m_ignoreInput = false; + ClearSelection(); - + m_keywordColour = wxColour( 10, 140, 10 ); - + m_defineColour = *wxRED; - + m_variableColour = wxColour( 50, 120, 150 ); - + m_commentColour = wxColour( 130, 130, 130 ); - + m_stringColour = wxColour( 10, 140, 10 ); } @@ -216,19 +216,19 @@ bool wxTextCtrl::Create( wxWindow *parent, { if ((style & wxBORDER_MASK) == 0) style |= wxBORDER_SUNKEN; - + if ((style & wxTE_MULTILINE) != 0) style |= wxALWAYS_SHOW_SB; - + wxTextCtrlBase::Create( parent, id, pos /* wxDefaultPosition */, size, style | wxVSCROLL | wxHSCROLL); - + SetBackgroundColour( *wxWHITE ); - + SetCursor( wxCursor( wxCURSOR_IBEAM ) ); - + m_editable = ((m_windowStyle & wxTE_READONLY) == 0); - + if (HasFlag(wxTE_PASSWORD)) m_sourceFont = wxFont( 12, wxMODERN, wxNORMAL, wxNORMAL ); else @@ -238,7 +238,7 @@ bool wxTextCtrl::Create( wxWindow *parent, dc.SetFont( m_sourceFont ); m_lineHeight = dc.GetCharHeight(); m_charWidth = dc.GetCharWidth(); - + SetValue( value ); wxSize size_best( DoGetBestSize() ); @@ -249,13 +249,13 @@ bool wxTextCtrl::Create( wxWindow *parent, new_size.y = size_best.y; if ((new_size.x != size.x) || (new_size.y != size.y)) SetSize( new_size.x, new_size.y ); - + // We create an input handler since it might be useful CreateInputHandler(wxINP_HANDLER_TEXTCTRL); - + MyAdjustScrollbars(); - - return TRUE; + + return true; } //----------------------------------------------------------------------------- @@ -271,13 +271,13 @@ wxString wxTextCtrl::GetValue() const if (i+1 < m_lines.GetCount()) ret += wxT('\n'); } - + return ret; } void wxTextCtrl::SetValue(const wxString& value) { - m_modified = FALSE; + m_modified = false; wxString oldValue = GetValue(); @@ -287,7 +287,7 @@ void wxTextCtrl::SetValue(const wxString& value) m_lines.Clear(); m_longestLine = 0; - if (value.IsEmpty()) + if (value.empty()) { m_lines.Add( new wxSourceLine( wxT("") ) ); } @@ -302,7 +302,7 @@ void wxTextCtrl::SetValue(const wxString& value) { wxSourceLine *sl = new wxSourceLine( value.Mid( begin, value.Len()-begin ) ); m_lines.Add( sl ); - + // if (sl->m_text.Len() > m_longestLine) // m_longestLine = sl->m_text.Len(); int ww = 0; @@ -310,14 +310,14 @@ void wxTextCtrl::SetValue(const wxString& value) ww /= m_charWidth; if (ww > m_longestLine) m_longestLine = ww; - + break; } else { wxSourceLine *sl = new wxSourceLine( value.Mid( begin, pos-begin ) ); m_lines.Add( sl ); - + // if (sl->m_text.Len() > m_longestLine) // m_longestLine = sl->m_text.Len(); int ww = 0; @@ -325,7 +325,7 @@ void wxTextCtrl::SetValue(const wxString& value) ww /= m_charWidth; if (ww > m_longestLine) m_longestLine = ww; - + begin = pos+1; } } @@ -337,9 +337,9 @@ void wxTextCtrl::SetValue(const wxString& value) if (value == oldValue) return; } - + MyAdjustScrollbars(); - + Refresh(); } @@ -347,7 +347,7 @@ int wxTextCtrl::GetLineLength(long lineNo) const { if (lineNo >= (long)m_lines.GetCount()) return 0; - + return m_lines[lineNo].m_text.Len(); } @@ -355,7 +355,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const { if (lineNo >= (long)m_lines.GetCount()) return wxT(""); - + return m_lines[lineNo].m_text; } @@ -391,14 +391,14 @@ void wxTextCtrl::GetSelection(long* from, long* to) const void wxTextCtrl::Clear() { - m_modified = TRUE; + m_modified = true; m_cursorX = 0; m_cursorY = 0; ClearSelection(); - + m_lines.Clear(); m_lines.Add( new wxSourceLine( wxT("") ) ); - + SetScrollbars( m_charWidth, m_lineHeight, 0, 0, 0, 0 ); Refresh(); WX_CLEAR_LIST(wxList, m_undos); @@ -410,7 +410,6 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Remove(long from, long to) { - } void wxTextCtrl::DiscardEdits() @@ -429,16 +428,16 @@ int wxTextCtrl::PosToPixel( int line, int pos ) if (line >= (int)m_lines.GetCount()) return 0; if (pos < 0) return 0; - + wxString text = m_lines[line].m_text; - - if (text.IsEmpty()) return 0; - + + if (text.empty()) return 0; + if (pos < (int)text.Len()) text.Remove( pos, text.Len()-pos ); - + int w = 0; - + GetTextExtent( text, &w, NULL, NULL, NULL ); return w; @@ -447,40 +446,40 @@ int wxTextCtrl::PosToPixel( int line, int pos ) int wxTextCtrl::PixelToPos( int line, int pixel ) { if (pixel < 2) return 0; - + if (line >= (int)m_lines.GetCount()) return 0; - + wxString text = m_lines[line].m_text; - + int w = 0; int res = text.Len(); while (res > 0) { GetTextExtent( text, &w, NULL, NULL, NULL ); - + if (w < pixel) return res; - + res--; text.Remove( res,1 ); } - + return 0; } void wxTextCtrl::SetLanguage( wxSourceLanguage lang ) { m_lang = lang; - + m_keywords.Clear(); } void wxTextCtrl::WriteText(const wxString& text2) { - if (text2.IsEmpty()) return; + if (text2.empty()) return; + + m_modified = true; - m_modified = TRUE; - wxString text( text2 ); wxArrayString lines; int pos; @@ -491,11 +490,11 @@ void wxTextCtrl::WriteText(const wxString& text2) } lines.Add( text ); int count = (int)lines.GetCount(); - + wxString tmp1( m_lines[m_cursorY].m_text ); wxString tmp2( tmp1 ); int len = (int)tmp1.Len(); - + if (len < m_cursorX) { wxString tmp; @@ -509,11 +508,11 @@ void wxTextCtrl::WriteText(const wxString& text2) tmp1.Remove( m_cursorX ); tmp2.Remove( 0, m_cursorX ); tmp1.Append( lines[0] ); - + if (count == 1) { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, m_cursorY, m_cursorY, this ) ); - + tmp1.Append( tmp2 ); m_lines[m_cursorY].m_text = tmp1; RefreshLine( m_cursorY ); @@ -521,13 +520,13 @@ void wxTextCtrl::WriteText(const wxString& text2) else { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_PASTE, m_cursorY, m_cursorY+count-1, this ) ); - + m_lines[m_cursorY].m_text = tmp1; int i; for (i = 1; i < count; i++) m_lines.Insert( new wxSourceLine( lines[i] ), m_cursorY+i ); m_lines[m_cursorY+i-1].m_text.Append( tmp2 ); - + MyAdjustScrollbars(); RefreshDown( m_cursorY ); } @@ -535,10 +534,10 @@ void wxTextCtrl::WriteText(const wxString& text2) void wxTextCtrl::AppendText(const wxString& text2) { - if (text2.IsEmpty()) return; + if (text2.empty()) return; + + m_modified = true; - m_modified = TRUE; - wxString text( text2 ); wxArrayString lines; int pos; @@ -549,28 +548,28 @@ void wxTextCtrl::AppendText(const wxString& text2) } lines.Add( text ); int count = (int)lines.GetCount(); - + size_t y = m_lines.GetCount()-1; wxString tmp( m_lines[y].m_text ); tmp.Append( lines[0] ); - + if (count == 1) { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, y, y, this ) ); - + m_lines[y].m_text = tmp; RefreshLine( y ); } else { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_PASTE, y, y+count-1, this ) ); - + m_lines[y].m_text = tmp; int i; for (i = 1; i < count; i++) m_lines.Insert( new wxSourceLine( lines[i] ), y+i ); - + MyAdjustScrollbars(); RefreshDown( y ); } @@ -578,13 +577,13 @@ void wxTextCtrl::AppendText(const wxString& text2) bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) { - return FALSE; + return false; } long wxTextCtrl::XYToPosition(long x, long y) const { long ret = 0; - + for (size_t i = 0; i < m_lines.GetCount(); i++) { if (i < (size_t)y) @@ -593,13 +592,13 @@ long wxTextCtrl::XYToPosition(long x, long y) const ret += m_lines[i].m_text.Len() + 1; continue; } - + if ((size_t)x < (m_lines[i].m_text.Len()+1)) return (ret + x); else return (ret + m_lines[i].m_text.Len() + 1); } - + return ret; } @@ -615,7 +614,7 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const long xx = 0; long yy = 0; - + for (size_t i = 0; i < m_lines.GetCount(); i++) { //pos -= m_lines[i].m_text.Len(); @@ -628,19 +627,19 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const xx = pos; if (x) *x = xx; if (y) *y = yy; - return TRUE; + return true; } pos -= (m_lines[i].m_text.Len() + 1); yy++; } - + // Last pos //xx = m_lines[ m_lines.GetCount()-1 ].m_text.Len(); xx = pos; if (x) *x = xx; if (y) *y = yy; - - return FALSE; + + return false; } void wxTextCtrl::ShowPosition(long pos) @@ -650,14 +649,14 @@ void wxTextCtrl::ShowPosition(long pos) void wxTextCtrl::Copy() { if (!HasSelection()) return; - + wxString sel; - + int selStartY = m_selStartY; int selEndY = m_selEndY; int selStartX = m_selStartX; int selEndX = m_selEndX; - + if ((selStartY > selEndY) || ((selStartY == selEndY) && (selStartX > selEndX))) { @@ -668,22 +667,22 @@ void wxTextCtrl::Copy() selStartY = selEndY; selEndY = tmp; } - + if (selStartY == selEndY) { sel = m_lines[selStartY].m_text; - + if (selStartX >= (int)sel.Len()) return; if (selEndX > (int)sel.Len()) selEndX = sel.Len(); - + sel.Remove( selEndX, sel.Len()-selEndX ); sel.Remove( 0, selStartX ); } else { wxString tmp( m_lines[selStartY].m_text ); - + if (selStartX < (int)tmp.Len()) { tmp.Remove( 0, selStartX ); @@ -704,7 +703,7 @@ void wxTextCtrl::Copy() sel.Append( tmp ); } } - + if (wxTheClipboard->Open()) { wxTheClipboard->SetData( new wxTextDataObject( sel ) ); @@ -714,34 +713,34 @@ void wxTextCtrl::Copy() void wxTextCtrl::Cut() { - Copy(); - - Delete(); + Copy(); + + Delete(); } void wxTextCtrl::Paste() { Delete(); - + if (!wxTheClipboard->Open()) return; - + if (!wxTheClipboard->IsSupported( wxDF_TEXT )) { wxTheClipboard->Close(); - + return; } - + wxTextDataObject data; - + bool ret = wxTheClipboard->GetData( data ); - + wxTheClipboard->Close(); - + if (!ret) return; - - m_modified = TRUE; - + + m_modified = true; + wxString text( data.GetText() ); wxArrayString lines; int pos; @@ -752,11 +751,11 @@ void wxTextCtrl::Paste() } lines.Add( text ); int count = (int)lines.GetCount(); - + wxString tmp1( m_lines[m_cursorY].m_text ); wxString tmp2( tmp1 ); int len = (int)tmp1.Len(); - + if (len < m_cursorX) { wxString tmp; @@ -770,11 +769,11 @@ void wxTextCtrl::Paste() tmp1.Remove( m_cursorX ); tmp2.Remove( 0, m_cursorX ); tmp1.Append( lines[0] ); - + if (count == 1) { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, m_cursorY, m_cursorY, this ) ); - + tmp1.Append( tmp2 ); m_lines[m_cursorY].m_text = tmp1; RefreshLine( m_cursorY ); @@ -782,13 +781,13 @@ void wxTextCtrl::Paste() else { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_PASTE, m_cursorY, m_cursorY+count-1, this ) ); - + m_lines[m_cursorY].m_text = tmp1; int i; for (i = 1; i < count; i++) m_lines.Insert( new wxSourceLine( lines[i] ), m_cursorY+i ); m_lines[m_cursorY+i-1].m_text.Append( tmp2 ); - + MyAdjustScrollbars(); RefreshDown( m_cursorY ); } @@ -797,16 +796,16 @@ void wxTextCtrl::Paste() void wxTextCtrl::Undo() { if (m_undos.GetCount() == 0) return; - + wxList::compatibility_iterator node = m_undos.Item( m_undos.GetCount()-1 ); wxSourceUndoStep *undo = (wxSourceUndoStep*) node->GetData(); - + undo->Undo(); delete undo; m_undos.Erase( node ); - - m_modified = TRUE; + + m_modified = true; } void wxTextCtrl::SetInsertionPoint(long pos) @@ -830,7 +829,7 @@ long wxTextCtrl::GetInsertionPoint() const return XYToPosition( m_cursorX, m_cursorY ); } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { size_t lineCount = m_lines.GetCount() - 1; // It's the length of the line, not the length - 1, @@ -849,25 +848,25 @@ void wxTextCtrl::SetEditable(bool editable) bool wxTextCtrl::Enable( bool enable ) { - return FALSE; + return false; } bool wxTextCtrl::SetFont(const wxFont& font) { wxTextCtrlBase::SetFont( font ); - + m_sourceFont = font; - + wxClientDC dc(this); dc.SetFont( m_sourceFont ); m_lineHeight = dc.GetCharHeight(); m_charWidth = dc.GetCharWidth(); - + // TODO: recalc longest lines - + MyAdjustScrollbars(); - - return TRUE; + + return true; } bool wxTextCtrl::SetForegroundColour(const wxColour& colour) @@ -888,26 +887,26 @@ void wxTextCtrl::SearchForBrackets() { int oldBracketY = m_bracketY; int oldBracketX = m_bracketX; - + if (m_cursorY < 0 || m_cursorY >= (int)m_lines.GetCount()) return; - + wxString current = m_lines[m_cursorY].m_text; - + // reverse search first char bracket = ' '; - + if (m_cursorX > 0) bracket = current[(size_t) (m_cursorX-1)]; - + if (bracket == ')' || bracket == ']' || bracket == '}') { char antibracket = '('; if (bracket == ']') antibracket = '['; if (bracket == '}') antibracket = '{'; - + int count = 1; - + int endY = m_cursorY-60; if (endY < 0) endY = 0; for (int y = m_cursorY; y >= endY; y--) @@ -915,7 +914,7 @@ void wxTextCtrl::SearchForBrackets() current = m_lines[y].m_text; if (y == m_cursorY) current.erase(m_cursorX-1,current.Len()-m_cursorX+1); - + for (int n = current.Len()-1; n >= 0; n--) { // ignore chars @@ -932,7 +931,7 @@ void wxTextCtrl::SearchForBrackets() } continue; } - + // ignore strings if (current[(size_t) (n)] == '\"') { @@ -947,7 +946,7 @@ void wxTextCtrl::SearchForBrackets() } continue; } - + if (current[(size_t) (n)] == antibracket) { count--; @@ -969,7 +968,7 @@ void wxTextCtrl::SearchForBrackets() } } } - + // then forward bracket = ' '; @@ -980,9 +979,9 @@ void wxTextCtrl::SearchForBrackets() char antibracket = ')'; if (bracket == '[') antibracket = ']'; if (bracket == '{') antibracket = '}'; - + int count = 1; - + int endY = m_cursorY+60; if (endY > (int)(m_lines.GetCount()-1)) endY = m_lines.GetCount()-1; for (int y = m_cursorY; y <= endY; y++) @@ -991,7 +990,7 @@ void wxTextCtrl::SearchForBrackets() int start = 0; if (y == m_cursorY) start = m_cursorX+1; - + for (int n = start; n < (int)current.Len(); n++) { // ignore chars @@ -1008,7 +1007,7 @@ void wxTextCtrl::SearchForBrackets() } continue; } - + // ignore strings if (current[(size_t) (n)] == '\"') { @@ -1023,7 +1022,7 @@ void wxTextCtrl::SearchForBrackets() } continue; } - + if (current[(size_t) (n)] == antibracket) { count--; @@ -1045,7 +1044,7 @@ void wxTextCtrl::SearchForBrackets() } } } - + if (oldBracketY != -1) { m_bracketY = -1; @@ -1056,14 +1055,14 @@ void wxTextCtrl::SearchForBrackets() void wxTextCtrl::Delete() { if (!HasSelection()) return; - - m_modified = TRUE; - + + m_modified = true; + int selStartY = m_selStartY; int selEndY = m_selEndY; int selStartX = m_selStartX; int selEndX = m_selEndX; - + if ((selStartY > selEndY) || ((selStartY == selEndY) && (selStartX > selEndX))) { @@ -1074,13 +1073,13 @@ void wxTextCtrl::Delete() selStartY = selEndY; selEndY = tmp; } - + int len = (int)m_lines[selStartY].m_text.Len(); - + if (selStartY == selEndY) { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, selStartY, selStartY, this ) ); - + wxString tmp( m_lines[selStartY].m_text ); if (selStartX < len) { @@ -1096,25 +1095,25 @@ void wxTextCtrl::Delete() else { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_DELETE, selStartY, selEndY, this ) ); - + if (selStartX < len) m_lines[selStartY].m_text.Remove( selStartX ); - + for (int i = 0; i < selEndY-selStartY-1; i++) m_lines.RemoveAt( selStartY+1 ); - + if (selEndX < (int)m_lines[selStartY+1].m_text.Len()) m_lines[selStartY+1].m_text.Remove( 0, selEndX ); else m_lines[selStartY+1].m_text.Remove( 0 ); - + m_lines[selStartY].m_text.Append( m_lines[selStartY+1].m_text ); m_lines.RemoveAt( selStartY+1 ); - + ClearSelection(); MoveCursor( selStartX, selStartY ); MyAdjustScrollbars(); - + RefreshDown( selStartY ); } } @@ -1122,25 +1121,25 @@ void wxTextCtrl::Delete() void wxTextCtrl::DeleteLine() { if (HasSelection()) return; - + if (m_cursorY < 0 || m_cursorY >= (int)m_lines.GetCount()-1) return; // TODO - + m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_DELETE, m_cursorY, m_cursorY+1, this ) ); - + m_lines.RemoveAt( m_cursorY ); m_cursorX = 0; if (m_cursorY >= (int)m_lines.GetCount()) m_cursorY--; - + MyAdjustScrollbars(); RefreshDown( m_cursorY ); } void wxTextCtrl::DoChar( char c ) { - m_modified = TRUE; - + m_modified = true; + m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, m_cursorY, m_cursorY, this ) ); - + wxString tmp( m_lines[m_cursorY].m_text ); tmp.Trim(); if (m_cursorX >= (int)tmp.Len()) @@ -1157,15 +1156,15 @@ void wxTextCtrl::DoChar( char c ) else tmp.insert( m_cursorX, 1, c ); } - + m_lines[m_cursorY].m_text = tmp; - + // if (tmp.Len() > m_longestLine) // { // m_longestLine = tmp.Len(); // MyAdjustScrollbars(); // } - + int ww = 0; GetTextExtent( tmp, &ww, NULL, NULL, NULL ); ww /= m_charWidth; @@ -1176,29 +1175,29 @@ void wxTextCtrl::DoChar( char c ) } m_cursorX++; - + int y = m_cursorY*m_lineHeight; // int x = (m_cursorX-1)*m_charWidth; int x = PosToPixel( m_cursorY, m_cursorX-1 ); CalcScrolledPosition( x, y, &x, &y ); wxRect rect( x+2, y+2, 10000, m_lineHeight ); - Refresh( TRUE, &rect ); + Refresh( true, &rect ); // refresh whole line for syntax colour highlighting rect.x = 0; - Refresh( FALSE, &rect ); - + Refresh( false, &rect ); + int size_x = 0; int size_y = 0; GetClientSize( &size_x, &size_y ); size_x /= m_charWidth; - + int view_x = 0; int view_y = 0; GetViewStart( &view_x, &view_y ); - + //int xx = m_cursorX; int xx = PosToPixel( m_cursorY, m_cursorX ) / m_charWidth; - + if (xx < view_x) Scroll( xx, -1 ); else if (xx > view_x+size_x-1) @@ -1207,14 +1206,14 @@ void wxTextCtrl::DoChar( char c ) void wxTextCtrl::DoBack() { - m_modified = TRUE; - + m_modified = true; + if (m_cursorX == 0) { if (m_cursorY == 0) return; - + m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_BACK, m_cursorY-1, m_cursorY, this ) ); - + wxString tmp1( m_lines[m_cursorY-1].m_text ); tmp1.Trim(); wxString tmp2( m_lines[m_cursorY].m_text ); @@ -1224,34 +1223,34 @@ void wxTextCtrl::DoBack() tmp1.Append( tmp2 ); m_lines[m_cursorY].m_text = tmp1; m_lines.RemoveAt( m_cursorY+1 ); - + MyAdjustScrollbars(); RefreshDown( m_cursorY-1 ); } else { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, m_cursorY, m_cursorY, this ) ); - + if (m_cursorX <= (int)m_lines[m_cursorY].m_text.Len()) m_lines[m_cursorY].m_text.Remove( m_cursorX-1, 1 ); m_cursorX--; - + int y = m_cursorY*m_lineHeight; // int x = m_cursorX*m_charWidth; int x = PosToPixel( m_cursorY, m_cursorX ); CalcScrolledPosition( x, y, &x, &y ); wxRect rect( x+2, y+2, 10000, m_lineHeight ); - Refresh( TRUE, &rect ); + Refresh( true, &rect ); // refresh whole line for syntax colour highlighting rect.x = 0; - Refresh( FALSE, &rect ); + Refresh( false, &rect ); } } void wxTextCtrl::DoDelete() { - m_modified = TRUE; - + m_modified = true; + wxString tmp( m_lines[m_cursorY].m_text ); tmp.Trim(); int len = (int)tmp.Len(); @@ -1260,43 +1259,43 @@ void wxTextCtrl::DoDelete() if (m_cursorY == (int)m_lines.GetCount()-1) return; m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_DELETE, m_cursorY, m_cursorY+1, this ) ); - + for (int i = 0; i < (m_cursorX-len); i++) tmp += ' '; - + tmp += m_lines[m_cursorY+1].m_text; - + m_lines[m_cursorY] = tmp; m_lines.RemoveAt( m_cursorY+1 ); - + MyAdjustScrollbars(); RefreshDown( m_cursorY ); } else { m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, m_cursorY, m_cursorY, this ) ); - + tmp.Remove( m_cursorX, 1 ); m_lines[m_cursorY].m_text = tmp; - + int y = m_cursorY*m_lineHeight; // int x = m_cursorX*m_charWidth; int x = PosToPixel( m_cursorY, m_cursorX ); CalcScrolledPosition( x, y, &x, &y ); wxRect rect( x+2, y+2, 10000, m_lineHeight ); - Refresh( TRUE, &rect ); + Refresh( true, &rect ); // refresh whole line for syntax colour highlighting rect.x = 0; - Refresh( FALSE, &rect ); + Refresh( false, &rect ); } } void wxTextCtrl::DoReturn() { - m_modified = TRUE; - + m_modified = true; + m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_ENTER, m_cursorY, m_cursorY, this ) ); - + wxString tmp( m_lines[m_cursorY].m_text ); size_t indent = tmp.find_first_not_of( ' ' ); if (indent == wxSTRING_MAXLEN) indent = 0; @@ -1305,11 +1304,11 @@ void wxTextCtrl::DoReturn() { int cursorX = indent; int cursorY = m_cursorY + 1; - + wxString new_tmp; for (size_t i = 0; i < indent; i++) new_tmp.Append( ' ' ); m_lines.Insert( new wxSourceLine( new_tmp ), cursorY ); - + MyAdjustScrollbars(); MoveCursor( cursorX, cursorY ); RefreshDown( m_cursorY ); @@ -1319,18 +1318,18 @@ void wxTextCtrl::DoReturn() wxString tmp1( tmp ); tmp1.Remove( m_cursorX, tmp.Len()-m_cursorX ); m_lines[m_cursorY].m_text = tmp1; - + wxString tmp2( tmp ); tmp2.Remove( 0, m_cursorX ); - + int cursorX = indent; int cursorY = m_cursorY + 1; - + wxString new_tmp; for (size_t i = 0; i < indent; i++) new_tmp.Append( ' ' ); new_tmp.Append( tmp2 ); m_lines.Insert( new wxSourceLine( new_tmp ), cursorY ); - + MyAdjustScrollbars(); MoveCursor( cursorX, cursorY ); RefreshDown( m_cursorY-1 ); @@ -1364,7 +1363,7 @@ void wxTextCtrl::DoDClick() } } m_selStartX = p; - + p = m_cursorX; if (p < (int)line.Len()) { @@ -1410,7 +1409,7 @@ wxString wxTextCtrl::GetNextToken( wxString &line, size_t &pos ) return ret; } } - + if (line[p] == '"') { ret.Append( line[p] ); @@ -1423,7 +1422,7 @@ wxString wxTextCtrl::GetNextToken( wxString &line, size_t &pos ) pos = p; return ret; } - + if (line[p] == '\'') { ret.Append( line[p] ); @@ -1436,7 +1435,7 @@ wxString wxTextCtrl::GetNextToken( wxString &line, size_t &pos ) pos = p; return ret; } - + if (((line[p] >= 'a') && (line[p] <= 'z')) || ((line[p] >= 'A') && (line[p] <= 'Z')) || (line[p] == '_') || @@ -1463,7 +1462,7 @@ wxString wxTextCtrl::GetNextToken( wxString &line, size_t &pos ) return ret; } } - + return ret; } @@ -1484,9 +1483,9 @@ void wxTextCtrl::DrawLinePart( wxDC &dc, int x, int y, const wxString &toDraw, c pos++; if (pos == len) return; } - + size_t start = pos; - + wxString current; current += toDraw[pos]; pos++; @@ -1495,7 +1494,7 @@ void wxTextCtrl::DrawLinePart( wxDC &dc, int x, int y, const wxString &toDraw, c current += toDraw[pos]; pos++; } - + int xx = 0; wxString tmp = origin.Left( start ); GetTextExtent( tmp, &xx, NULL, NULL, NULL ); @@ -1511,7 +1510,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li int selEndY = m_selEndY; int selStartX = m_selStartX; int selEndX = m_selEndX; - + if ((selStartY > selEndY) || ((selStartY == selEndY) && (selStartX > selEndX))) { @@ -1536,7 +1535,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li wxString comment( ' ', line.Len() ); wxString my_string( ' ', line.Len() ); wxString selection( ' ', line.Len() ); - + if (m_lang != wxSOURCE_LANG_NONE) { if (lineNum == m_bracketY) @@ -1551,7 +1550,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li dc.SetTextForeground( *wxBLACK ); } } - + size_t pos = 0; wxString token( GetNextToken( line, pos ) ); while (!token.IsNull()) @@ -1628,7 +1627,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li DrawLinePart( dc, x, y, my_string, line2, m_stringColour ); return; } - + if (selStartY == selEndY) { // int xx = selStartX*m_charWidth; @@ -1636,7 +1635,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li // int ww = (selEndX-selStartX)*m_charWidth; int ww = PosToPixel( lineNum, selEndX ) - xx; dc.DrawRectangle( xx+2, lineNum*m_lineHeight+2, ww, m_lineHeight ); - + for (size_t i = (size_t)selStartX; i < (size_t)selEndX; i++) { selection[i] = line[i]; @@ -1646,7 +1645,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li if ((lineNum > selStartY) && (lineNum < selEndY)) { dc.DrawRectangle( 0+2, lineNum*m_lineHeight+2, 10000, m_lineHeight ); - + for (size_t i = 0; i < line.Len(); i++) { selection[i] = line[i]; @@ -1658,7 +1657,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li // int xx = selStartX*m_charWidth; int xx = PosToPixel( lineNum, selStartX ); dc.DrawRectangle( xx+2, lineNum*m_lineHeight+2, 10000, m_lineHeight ); - + for (size_t i = (size_t)selStartX; i < line.Len(); i++) { selection[i] = line[i]; @@ -1670,14 +1669,14 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li // int ww = selEndX*m_charWidth; int ww = PosToPixel( lineNum, selEndX ); dc.DrawRectangle( 0+2, lineNum*m_lineHeight+2, ww, m_lineHeight ); - + for (size_t i = 0; i < (size_t)selEndX; i++) { selection[i] = line[i]; line[i] = ' '; } } - + DrawLinePart( dc, x, y, line, line2, *wxBLACK ); DrawLinePart( dc, x, y, selection, line2, *wxWHITE ); DrawLinePart( dc, x, y, keyword, line2, m_keywordColour ); @@ -1690,25 +1689,25 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li void wxTextCtrl::OnPaint( wxPaintEvent &event ) { wxPaintDC dc(this); - + if (m_lines.GetCount() == 0) return; - + PrepareDC( dc ); - + dc.SetFont( m_sourceFont ); - + int scroll_y = 0; GetViewStart( NULL, &scroll_y ); - + // We have a inner border of two pixels // around the text, so scroll units do // not correspond to lines. if (scroll_y > 0) scroll_y--; - + int size_x = 0; int size_y = 0; GetClientSize( &size_x, &size_y ); - + dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetBrush( wxBrush( wxTHEME_COLOUR(HIGHLIGHT), wxSOLID ) ); int upper = wxMin( (int)m_lines.GetCount(), scroll_y+(size_y/m_lineHeight)+2 ); @@ -1722,7 +1721,7 @@ void wxTextCtrl::OnPaint( wxPaintEvent &event ) if (IsExposed(x,y,w,h)) DrawLine( dc, 0+2, i*m_lineHeight+2, m_lines[i].m_text, i ); } - + if (m_editable && (FindFocus() == this)) { ///dc.SetBrush( *wxRED_BRUSH ); @@ -1737,7 +1736,7 @@ void wxTextCtrl::OnMouse( wxMouseEvent &event ) { if (m_lines.GetCount() == 0) return; - + #if 0 // there is no middle button on iPAQs if (event.MiddleDown()) { @@ -1745,26 +1744,26 @@ void wxTextCtrl::OnMouse( wxMouseEvent &event ) return; } #endif - + if (event.LeftDClick()) { DoDClick(); return; } - + if (event.LeftDown()) - { - m_capturing = TRUE; + { + m_capturing = true; CaptureMouse(); } - + if (event.LeftUp()) - { - m_capturing = FALSE; + { + m_capturing = false; ReleaseMouse(); } - if (event.LeftDown() || + if (event.LeftDown() || (event.LeftIsDown() && m_capturing)) { int x = event.GetX(); @@ -1773,8 +1772,8 @@ void wxTextCtrl::OnMouse( wxMouseEvent &event ) y /= m_lineHeight; // x /= m_charWidth; x = PixelToPos( y, x ); - MoveCursor( - wxMin( 1000, wxMax( 0, x ) ), + MoveCursor( + wxMin( 1000, wxMax( 0, x ) ), wxMin( (int)m_lines.GetCount()-1, wxMax( 0, y ) ), event.ShiftDown() || !event.LeftDown() ); } @@ -1785,14 +1784,14 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) if (m_lines.GetCount() == 0) return; if (!m_editable) return; - + int size_x = 0; int size_y = 0; GetClientSize( &size_x, &size_y ); size_x /= m_charWidth; size_y /= m_lineHeight; size_y--; - + if (event.ShiftDown()) { switch (event.GetKeyCode()) @@ -1808,7 +1807,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) case '0': event.m_keyCode = WXK_INSERT; break; } } - + switch (event.GetKeyCode()) { case WXK_UP: @@ -1816,7 +1815,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) if (m_ignoreInput) return; if (m_cursorY > 0) MoveCursor( m_cursorX, m_cursorY-1, event.ShiftDown() ); - m_ignoreInput = TRUE; + m_ignoreInput = true; return; } case WXK_DOWN: @@ -1824,7 +1823,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) if (m_ignoreInput) return; if (m_cursorY < (int)(m_lines.GetCount()-1)) MoveCursor( m_cursorX, m_cursorY+1, event.ShiftDown() ); - m_ignoreInput = TRUE; + m_ignoreInput = true; return; } case WXK_LEFT: @@ -1839,7 +1838,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) if (m_cursorY > 0) MoveCursor( m_lines[m_cursorY-1].m_text.Len(), m_cursorY-1, event.ShiftDown() ); } - m_ignoreInput = TRUE; + m_ignoreInput = true; return; } case WXK_RIGHT: @@ -1847,7 +1846,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) if (m_ignoreInput) return; if (m_cursorX < 1000) MoveCursor( m_cursorX+1, m_cursorY, event.ShiftDown() ); - m_ignoreInput = TRUE; + m_ignoreInput = true; return; } case WXK_HOME: @@ -1870,14 +1869,14 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) { if (m_ignoreInput) return; MoveCursor( m_cursorX, wxMin( (int)(m_lines.GetCount()-1), m_cursorY+size_y ), event.ShiftDown() ); - m_ignoreInput = TRUE; + m_ignoreInput = true; return; } case WXK_PRIOR: { if (m_ignoreInput) return; MoveCursor( m_cursorX, wxMax( 0, m_cursorY-size_y ), event.ShiftDown() ); - m_ignoreInput = TRUE; + m_ignoreInput = true; return; } case WXK_INSERT: @@ -1899,13 +1898,13 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) event.SetString(GetValue()); if (GetEventHandler()->ProcessEvent(event)) return; } - + if (IsSingleLine()) { event.Skip(); return; } - + if (HasSelection()) Delete(); DoReturn(); @@ -1916,7 +1915,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) if (HasSelection()) Delete(); bool save_overwrite = m_overwrite; - m_overwrite = FALSE; + m_overwrite = false; int i = 4-(m_cursorX % 4); if (i == 0) i = 4; for (int c = 0; c < i; c++) @@ -1940,7 +1939,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) DoDelete(); return; } - default: + default: { if ( (event.GetKeyCode() >= 'a') && (event.GetKeyCode() <= 'z') && @@ -1950,8 +1949,8 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) event.Skip(); return; } - - if ( (event.GetKeyCode() >= 32) && + + if ( (event.GetKeyCode() >= 32) && (event.GetKeyCode() <= 255) && !(event.ControlDown() && !event.AltDown()) ) // filters out Ctrl-X but leaves Alt-Gr { @@ -1962,16 +1961,16 @@ void wxTextCtrl::OnChar( wxKeyEvent &event ) } } } - + event.Skip(); } void wxTextCtrl::OnInternalIdle() { wxControl::OnInternalIdle(); - - m_ignoreInput = FALSE; - + + m_ignoreInput = false; + if (m_lang != wxSOURCE_LANG_NONE) SearchForBrackets(); } @@ -1991,9 +1990,9 @@ void wxTextCtrl::Indent() endY = tmp; } } - + m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, startY, endY, this ) ); - + for (int i = startY; i <= endY; i++) { m_lines[i].m_text.insert( 0u, wxT(" ") ); @@ -2016,9 +2015,9 @@ void wxTextCtrl::Unindent() endY = tmp; } } - + m_undos.Append( new wxSourceUndoStep( wxSOURCE_UNDO_LINE, startY, endY, this ) ); - + for (int i = startY; i <= endY; i++) { for (int n = 0; n < 4; n++) @@ -2048,7 +2047,7 @@ void wxTextCtrl::RefreshLine( int n ) int x = 0; CalcScrolledPosition( x, y, &x, &y ); wxRect rect( 0+2, y+2, 10000, m_lineHeight ); - Refresh( TRUE, &rect ); + Refresh( true, &rect ); } void wxTextCtrl::RefreshDown( int n ) @@ -2070,9 +2069,9 @@ void wxTextCtrl::RefreshDown( int n ) int y = n*m_lineHeight; int x = 0; CalcScrolledPosition( x, y, &x, &y ); - + wxRect rect( 0+2, y+2, 10000, size_y ); - Refresh( TRUE, &rect ); + Refresh( true, &rect ); } } @@ -2088,19 +2087,19 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) if ((new_x == m_cursorX) && (new_y == m_cursorY)) return; - bool no_cursor_refresh = FALSE; + bool no_cursor_refresh = false; bool has_selection = HasSelection(); if (shift) { int x,y,w,h; - bool erase_background = TRUE; - + bool erase_background = true; + if (!has_selection) { m_selStartX = m_cursorX; m_selStartY = m_cursorY; - + x = 0; w = 10000; if (new_y > m_selStartY) @@ -2125,8 +2124,8 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) y = new_y*m_lineHeight; h = (-new_y+m_selStartY+1)*m_lineHeight; } - - no_cursor_refresh = TRUE; + + no_cursor_refresh = true; m_cursorX = new_x; m_cursorY = new_y; } @@ -2159,7 +2158,7 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) { y = m_selEndY*m_lineHeight; h = (new_y-m_selEndY+1) * m_lineHeight; - + erase_background = ((m_selEndY < m_selStartY) || ((m_selEndY == m_selStartY) && (m_selEndX < m_selStartX))); } @@ -2167,19 +2166,19 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) { y = new_y*m_lineHeight; h = (-new_y+m_selEndY+1) * m_lineHeight; - + erase_background = ((m_selEndY > m_selStartY) || ((m_selEndY == m_selStartY) && (m_selEndX > m_selStartX))); } - no_cursor_refresh = TRUE; + no_cursor_refresh = true; m_cursorX = new_x; m_cursorY = new_y; } } - + m_selEndX = new_x; m_selEndY = new_y; - + CalcScrolledPosition( x, y, &x, &y ); wxRect rect( x+2, y+2, w, h ); Refresh( erase_background, &rect ); @@ -2194,27 +2193,27 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) m_selEndY = -1; m_selStartX = -1; m_selStartY = -1; - + if (ry1 > ry2) { int tmp = ry2; ry2 = ry1; ry1 = tmp; } - + int x = 0; int y = ry1*m_lineHeight; CalcScrolledPosition( x, y, &x, &y ); wxRect rect( 0, y+2, 10000, (ry2-ry1+1)*m_lineHeight ); - - Refresh( TRUE, &rect ); + + Refresh( true, &rect ); } } - + /* - printf( "startx %d starty %d endx %d endy %d\n", + printf( "startx %d starty %d endx %d endy %d\n", m_selStartX, m_selStartY, m_selEndX, m_selEndY ); - + printf( "has %d\n", (int)HasSelection() ); */ @@ -2225,11 +2224,11 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) int y = m_cursorY*m_lineHeight; CalcScrolledPosition( x, y, &x, &y ); wxRect rect( x+2, y+2, 4, m_lineHeight+2 ); - + m_cursorX = new_x; m_cursorY = new_y; - - Refresh( TRUE, &rect ); + + Refresh( true, &rect ); if (FindFocus() == this) { @@ -2243,17 +2242,17 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) dc.DrawRectangle( xx+2, m_cursorY*m_lineHeight+2, 2, m_lineHeight ); } } - + int size_x = 0; int size_y = 0; GetClientSize( &size_x, &size_y ); size_x /= m_charWidth; size_y /= m_lineHeight; - + int view_x = 0; int view_y = 0; GetViewStart( &view_x, &view_y ); - + if (centre) { int sy = m_cursorY - (size_y/2); @@ -2267,10 +2266,10 @@ void wxTextCtrl::MoveCursor( int new_x, int new_y, bool shift, bool centre ) else if (m_cursorY > view_y+size_y-1) Scroll( -1, m_cursorY-size_y+1 ); } - + //int xx = m_cursorX; int xx = PosToPixel( m_cursorY, m_cursorX ) / m_charWidth; - + if (xx < view_x) Scroll( xx, -1 ); else if (xx > view_x+size_x-1) @@ -2289,11 +2288,11 @@ void wxTextCtrl::MyAdjustScrollbars() height -= 4; if (height >= (int)m_lines.GetCount() *m_lineHeight) y_range = 0; - + int view_x = 0; int view_y = 0; GetViewStart( &view_x, &view_y ); - + SetScrollbars( m_charWidth, m_lineHeight, m_longestLine+2, y_range, view_x, view_y ); } @@ -2356,13 +2355,13 @@ wxSize wxTextCtrl::DoGetBestSize() const if (IsSingleLine()) { wxSize ret(80, m_lineHeight + 4); - + if (HasFlag(wxBORDER_SUNKEN) || HasFlag(wxBORDER_RAISED)) ret.y += 4; - + if (HasFlag(wxBORDER_SIMPLE)) ret.y += 2; - + return ret; } else @@ -2403,13 +2402,13 @@ bool wxTextCtrl::ScrollLines(int lines) { wxFAIL_MSG( "wxTextCtrl::ScrollLines not implemented"); - return FALSE; + return false; } bool wxTextCtrl::ScrollPages(int pages) { wxFAIL_MSG( "wxTextCtrl::ScrollPages not implemented"); - - return FALSE; + + return false; }